repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
gplcart/cli | controllers/commands/Alias.php | Alias.getListAlias | protected function getListAlias()
{
$id = $this->getParam(0);
if (!isset($id)) {
return $this->alias->getList(array('limit' => $this->getLimit()));
}
if ($this->getParam('entity')) {
return $this->alias->getList(array('entity' => $id, 'limit' => $this->getLimit()));
}
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->alias->get($id);
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
return array($result);
} | php | protected function getListAlias()
{
$id = $this->getParam(0);
if (!isset($id)) {
return $this->alias->getList(array('limit' => $this->getLimit()));
}
if ($this->getParam('entity')) {
return $this->alias->getList(array('entity' => $id, 'limit' => $this->getLimit()));
}
if (!is_numeric($id)) {
$this->errorAndExit($this->text('Invalid argument'));
}
$result = $this->alias->get($id);
if (empty($result)) {
$this->errorAndExit($this->text('Unexpected result'));
}
return array($result);
} | [
"protected",
"function",
"getListAlias",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"alias",
"->",
"getList",
"(",
"array",
"(",
"'limit'",
"=>",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getParam",
"(",
"'entity'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"alias",
"->",
"getList",
"(",
"array",
"(",
"'entity'",
"=>",
"$",
"id",
",",
"'limit'",
"=>",
"$",
"this",
"->",
"getLimit",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Invalid argument'",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"alias",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'Unexpected result'",
")",
")",
";",
"}",
"return",
"array",
"(",
"$",
"result",
")",
";",
"}"
] | Returns an array of URL aliases
@return array | [
"Returns",
"an",
"array",
"of",
"URL",
"aliases"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Alias.php#L251-L274 | train |
linpax/microphp-framework | src/mvc/views/PhpView.php | PhpView.render | public function render()
{
if (!$this->view) {
return false;
}
return $this->renderRawData(
$this->data ?: $this->renderFile($this->getViewFile($this->view), $this->params)
);
} | php | public function render()
{
if (!$this->view) {
return false;
}
return $this->renderRawData(
$this->data ?: $this->renderFile($this->getViewFile($this->view), $this->params)
);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"view",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"renderRawData",
"(",
"$",
"this",
"->",
"data",
"?",
":",
"$",
"this",
"->",
"renderFile",
"(",
"$",
"this",
"->",
"getViewFile",
"(",
"$",
"this",
"->",
"view",
")",
",",
"$",
"this",
"->",
"params",
")",
")",
";",
"}"
] | Render insert data into view
@access protected
@return string
@throws Exception | [
"Render",
"insert",
"data",
"into",
"view"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/mvc/views/PhpView.php#L67-L76 | train |
linpax/microphp-framework | src/mvc/views/PhpView.php | PhpView.renderRawData | public function renderRawData($data = '')
{
$layoutPath = null;
if ($this->layout && (!$layoutPath = $this->getLayoutFile((new KernelInjector)->build()->getAppDir(),
$this->module))
) {
(new LoggerInjector)->build()->send('error', 'Layout `'.$this->layout.'` not found');
}
if ($layoutPath) {
$data = $this->insertStyleScripts($this->renderFile($layoutPath, ['content' => $data]));
}
return $data;
} | php | public function renderRawData($data = '')
{
$layoutPath = null;
if ($this->layout && (!$layoutPath = $this->getLayoutFile((new KernelInjector)->build()->getAppDir(),
$this->module))
) {
(new LoggerInjector)->build()->send('error', 'Layout `'.$this->layout.'` not found');
}
if ($layoutPath) {
$data = $this->insertStyleScripts($this->renderFile($layoutPath, ['content' => $data]));
}
return $data;
} | [
"public",
"function",
"renderRawData",
"(",
"$",
"data",
"=",
"''",
")",
"{",
"$",
"layoutPath",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"layout",
"&&",
"(",
"!",
"$",
"layoutPath",
"=",
"$",
"this",
"->",
"getLayoutFile",
"(",
"(",
"new",
"KernelInjector",
")",
"->",
"build",
"(",
")",
"->",
"getAppDir",
"(",
")",
",",
"$",
"this",
"->",
"module",
")",
")",
")",
"{",
"(",
"new",
"LoggerInjector",
")",
"->",
"build",
"(",
")",
"->",
"send",
"(",
"'error'",
",",
"'Layout `'",
".",
"$",
"this",
"->",
"layout",
".",
"'` not found'",
")",
";",
"}",
"if",
"(",
"$",
"layoutPath",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"insertStyleScripts",
"(",
"$",
"this",
"->",
"renderFile",
"(",
"$",
"layoutPath",
",",
"[",
"'content'",
"=>",
"$",
"data",
"]",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Render raw data in layout
@access public
@param string $data arguments array
@return string
@throws Exception | [
"Render",
"raw",
"data",
"in",
"layout"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/mvc/views/PhpView.php#L88-L102 | train |
linpax/microphp-framework | src/mvc/views/PhpView.php | PhpView.getLayoutFile | protected function getLayoutFile($appDir, $module)
{
if ($module) {
$module = strtolower(str_replace('\\', '/', $module));
$module = substr($module, strpos($module, '/') + 1);
$module = substr($module, 0, strrpos($module, '/'));
}
$layout = $appDir.'/'.($module ? $module.'/' : $module);
$afterPath = 'views/layouts/'.ucfirst($this->layout).'.php';
if (file_exists($layout.$afterPath)) {
return $layout.$afterPath;
}
if (file_exists($appDir.'/'.$afterPath)) {
return $appDir.'/'.$afterPath;
}
return false;
} | php | protected function getLayoutFile($appDir, $module)
{
if ($module) {
$module = strtolower(str_replace('\\', '/', $module));
$module = substr($module, strpos($module, '/') + 1);
$module = substr($module, 0, strrpos($module, '/'));
}
$layout = $appDir.'/'.($module ? $module.'/' : $module);
$afterPath = 'views/layouts/'.ucfirst($this->layout).'.php';
if (file_exists($layout.$afterPath)) {
return $layout.$afterPath;
}
if (file_exists($appDir.'/'.$afterPath)) {
return $appDir.'/'.$afterPath;
}
return false;
} | [
"protected",
"function",
"getLayoutFile",
"(",
"$",
"appDir",
",",
"$",
"module",
")",
"{",
"if",
"(",
"$",
"module",
")",
"{",
"$",
"module",
"=",
"strtolower",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"module",
")",
")",
";",
"$",
"module",
"=",
"substr",
"(",
"$",
"module",
",",
"strpos",
"(",
"$",
"module",
",",
"'/'",
")",
"+",
"1",
")",
";",
"$",
"module",
"=",
"substr",
"(",
"$",
"module",
",",
"0",
",",
"strrpos",
"(",
"$",
"module",
",",
"'/'",
")",
")",
";",
"}",
"$",
"layout",
"=",
"$",
"appDir",
".",
"'/'",
".",
"(",
"$",
"module",
"?",
"$",
"module",
".",
"'/'",
":",
"$",
"module",
")",
";",
"$",
"afterPath",
"=",
"'views/layouts/'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"layout",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"layout",
".",
"$",
"afterPath",
")",
")",
"{",
"return",
"$",
"layout",
".",
"$",
"afterPath",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"appDir",
".",
"'/'",
".",
"$",
"afterPath",
")",
")",
"{",
"return",
"$",
"appDir",
".",
"'/'",
".",
"$",
"afterPath",
";",
"}",
"return",
"false",
";",
"}"
] | Get layout path
@access protected
@param string $appDir path to base dir
@param string $module module name
@return string
@throws Exception | [
"Get",
"layout",
"path"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/mvc/views/PhpView.php#L115-L135 | train |
linpax/microphp-framework | src/mvc/views/PhpView.php | PhpView.renderFile | protected function renderFile($fileName, array $data = [])
{
/** @noinspection OnlyWritesOnParameterInspection */
/** @noinspection PhpUnusedLocalVariableInspection */
$lang = new Language($fileName);
extract($data, EXTR_PREFIX_SAME || EXTR_REFS, 'data');
ob_start();
/** @noinspection PhpIncludeInspection */
include str_replace('\\', '/', $fileName);
if (!empty($GLOBALS['widgetStack'])) {
throw new Exception(count($GLOBALS['widgetStack']).' widgets not endings.');
}
return ob_get_clean();
} | php | protected function renderFile($fileName, array $data = [])
{
/** @noinspection OnlyWritesOnParameterInspection */
/** @noinspection PhpUnusedLocalVariableInspection */
$lang = new Language($fileName);
extract($data, EXTR_PREFIX_SAME || EXTR_REFS, 'data');
ob_start();
/** @noinspection PhpIncludeInspection */
include str_replace('\\', '/', $fileName);
if (!empty($GLOBALS['widgetStack'])) {
throw new Exception(count($GLOBALS['widgetStack']).' widgets not endings.');
}
return ob_get_clean();
} | [
"protected",
"function",
"renderFile",
"(",
"$",
"fileName",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"/** @noinspection OnlyWritesOnParameterInspection */",
"/** @noinspection PhpUnusedLocalVariableInspection */",
"$",
"lang",
"=",
"new",
"Language",
"(",
"$",
"fileName",
")",
";",
"extract",
"(",
"$",
"data",
",",
"EXTR_PREFIX_SAME",
"||",
"EXTR_REFS",
",",
"'data'",
")",
";",
"ob_start",
"(",
")",
";",
"/** @noinspection PhpIncludeInspection */",
"include",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"fileName",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'widgetStack'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"count",
"(",
"$",
"GLOBALS",
"[",
"'widgetStack'",
"]",
")",
".",
"' widgets not endings.'",
")",
";",
"}",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] | Render file by path
@access protected
@param string $fileName file name
@param array $data arguments array
@return string
@throws Exception widget not declared | [
"Render",
"file",
"by",
"path"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/mvc/views/PhpView.php#L148-L164 | train |
linpax/microphp-framework | src/mvc/views/PhpView.php | PhpView.getViewFile | private function getViewFile($view)
{
$calledClass = $this->path;
// Calculate path to view
if (0 === strpos($calledClass, 'App')) {
$path = (new KernelInjector)->build()->getAppDir();
} else {
$path = Autoload::getAlias('Micro');
}
$cl = strtolower(dirname(str_replace('\\', '/', $calledClass)));
$cl = substr($cl, strpos($cl, '/'));
if ($this->asWidget) {
$path .= $cl.'/views/'.$view.'.php';
} else {
$className = str_replace('controller', '',
strtolower(basename(str_replace('\\', '/', '/'.$this->path))));
$path .= dirname($cl).'/views/'.$className.'/'.$view.'.php';
}
$path = str_replace('//', '/', $path);
if (!file_exists($path)) {
throw new Exception('View path `'.$path.'` not exists.');
}
return $path;
} | php | private function getViewFile($view)
{
$calledClass = $this->path;
// Calculate path to view
if (0 === strpos($calledClass, 'App')) {
$path = (new KernelInjector)->build()->getAppDir();
} else {
$path = Autoload::getAlias('Micro');
}
$cl = strtolower(dirname(str_replace('\\', '/', $calledClass)));
$cl = substr($cl, strpos($cl, '/'));
if ($this->asWidget) {
$path .= $cl.'/views/'.$view.'.php';
} else {
$className = str_replace('controller', '',
strtolower(basename(str_replace('\\', '/', '/'.$this->path))));
$path .= dirname($cl).'/views/'.$className.'/'.$view.'.php';
}
$path = str_replace('//', '/', $path);
if (!file_exists($path)) {
throw new Exception('View path `'.$path.'` not exists.');
}
return $path;
} | [
"private",
"function",
"getViewFile",
"(",
"$",
"view",
")",
"{",
"$",
"calledClass",
"=",
"$",
"this",
"->",
"path",
";",
"// Calculate path to view",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"calledClass",
",",
"'App'",
")",
")",
"{",
"$",
"path",
"=",
"(",
"new",
"KernelInjector",
")",
"->",
"build",
"(",
")",
"->",
"getAppDir",
"(",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"Autoload",
"::",
"getAlias",
"(",
"'Micro'",
")",
";",
"}",
"$",
"cl",
"=",
"strtolower",
"(",
"dirname",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"calledClass",
")",
")",
")",
";",
"$",
"cl",
"=",
"substr",
"(",
"$",
"cl",
",",
"strpos",
"(",
"$",
"cl",
",",
"'/'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"asWidget",
")",
"{",
"$",
"path",
".=",
"$",
"cl",
".",
"'/views/'",
".",
"$",
"view",
".",
"'.php'",
";",
"}",
"else",
"{",
"$",
"className",
"=",
"str_replace",
"(",
"'controller'",
",",
"''",
",",
"strtolower",
"(",
"basename",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"'/'",
".",
"$",
"this",
"->",
"path",
")",
")",
")",
")",
";",
"$",
"path",
".=",
"dirname",
"(",
"$",
"cl",
")",
".",
"'/views/'",
".",
"$",
"className",
".",
"'/'",
".",
"$",
"view",
".",
"'.php'",
";",
"}",
"$",
"path",
"=",
"str_replace",
"(",
"'//'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'View path `'",
".",
"$",
"path",
".",
"'` not exists.'",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Get view file
@access private
@param string $view view file name
@return string
@throws Exception | [
"Get",
"view",
"file"
] | 11f3370f3f64c516cce9b84ecd8276c6e9ae8df9 | https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/mvc/views/PhpView.php#L176-L205 | train |
iumio/framework-setup | Tools.php | Tools.checkPhpVersion | final public static function checkPhpVersion()
{
$phpv = phpversion();
if ($phpv >= self::$php_accept) {
return (json_encode(array("code" => 200, "results" => "OK", "phpv" => $phpv)));
} else {
return (json_encode(array("code" => 500, "results" => "NOK", "phpv" => $phpv, "msg" =>
"The version of PHP is incompatible with iumio Framework. You must have at least version 7.2
of PHP on your web server.")));
}
} | php | final public static function checkPhpVersion()
{
$phpv = phpversion();
if ($phpv >= self::$php_accept) {
return (json_encode(array("code" => 200, "results" => "OK", "phpv" => $phpv)));
} else {
return (json_encode(array("code" => 500, "results" => "NOK", "phpv" => $phpv, "msg" =>
"The version of PHP is incompatible with iumio Framework. You must have at least version 7.2
of PHP on your web server.")));
}
} | [
"final",
"public",
"static",
"function",
"checkPhpVersion",
"(",
")",
"{",
"$",
"phpv",
"=",
"phpversion",
"(",
")",
";",
"if",
"(",
"$",
"phpv",
">=",
"self",
"::",
"$",
"php_accept",
")",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"200",
",",
"\"results\"",
"=>",
"\"OK\"",
",",
"\"phpv\"",
"=>",
"$",
"phpv",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"phpv\"",
"=>",
"$",
"phpv",
",",
"\"msg\"",
"=>",
"\"The version of PHP is incompatible with iumio Framework. You must have at least version 7.2\n of PHP on your web server.\"",
")",
")",
")",
";",
"}",
"}"
] | Check the php version
@return string If php version is compatible | [
"Check",
"the",
"php",
"version"
] | 02bb46ce6aa3a52908ff4608bd14264608bb38d1 | https://github.com/iumio/framework-setup/blob/02bb46ce6aa3a52908ff4608bd14264608bb38d1/Tools.php#L59-L70 | train |
iumio/framework-setup | Tools.php | Tools.checkFrameworkBuildVersion | final public static function checkFrameworkBuildVersion()
{
$f = json_decode(file_get_contents(__DIR__."/../../elements/config_files/core/framework.config.json"));
if (!property_exists($f, 'installation')) {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
"msg" => "Property [installation] is undefined in framework.config.json file")));
}
if ($f->installation != null) {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
"msg" => "Cannot use iumio installer because you have already one app installed.")));
}
$v = $f->edition_version;
$build = $f->edition_build;
$e = $f->edition_fullname;
$st = $f->edition_stage;
if ($build >= self::$framework_build_accept) {
$_SESSION['version'] = trim($v);
return (json_encode(array("code" => 200, "results" => "OK", "fv" => trim($v), "edition" => $e,
'stage' => $st)));
} else {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => trim($v),
"msg" => "The version of iumio Framework is incompatible with iumio installer.
You must have at least version " . self::$framework_version_accept .
" of iumio Framework on your web server.")));
}
} | php | final public static function checkFrameworkBuildVersion()
{
$f = json_decode(file_get_contents(__DIR__."/../../elements/config_files/core/framework.config.json"));
if (!property_exists($f, 'installation')) {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
"msg" => "Property [installation] is undefined in framework.config.json file")));
}
if ($f->installation != null) {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => "unknow",
"msg" => "Cannot use iumio installer because you have already one app installed.")));
}
$v = $f->edition_version;
$build = $f->edition_build;
$e = $f->edition_fullname;
$st = $f->edition_stage;
if ($build >= self::$framework_build_accept) {
$_SESSION['version'] = trim($v);
return (json_encode(array("code" => 200, "results" => "OK", "fv" => trim($v), "edition" => $e,
'stage' => $st)));
} else {
return (json_encode(array("code" => 500, "results" => "NOK", "fv" => trim($v),
"msg" => "The version of iumio Framework is incompatible with iumio installer.
You must have at least version " . self::$framework_version_accept .
" of iumio Framework on your web server.")));
}
} | [
"final",
"public",
"static",
"function",
"checkFrameworkBuildVersion",
"(",
")",
"{",
"$",
"f",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"__DIR__",
".",
"\"/../../elements/config_files/core/framework.config.json\"",
")",
")",
";",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"f",
",",
"'installation'",
")",
")",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"fv\"",
"=>",
"\"unknow\"",
",",
"\"msg\"",
"=>",
"\"Property [installation] is undefined in framework.config.json file\"",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"f",
"->",
"installation",
"!=",
"null",
")",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"fv\"",
"=>",
"\"unknow\"",
",",
"\"msg\"",
"=>",
"\"Cannot use iumio installer because you have already one app installed.\"",
")",
")",
")",
";",
"}",
"$",
"v",
"=",
"$",
"f",
"->",
"edition_version",
";",
"$",
"build",
"=",
"$",
"f",
"->",
"edition_build",
";",
"$",
"e",
"=",
"$",
"f",
"->",
"edition_fullname",
";",
"$",
"st",
"=",
"$",
"f",
"->",
"edition_stage",
";",
"if",
"(",
"$",
"build",
">=",
"self",
"::",
"$",
"framework_build_accept",
")",
"{",
"$",
"_SESSION",
"[",
"'version'",
"]",
"=",
"trim",
"(",
"$",
"v",
")",
";",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"200",
",",
"\"results\"",
"=>",
"\"OK\"",
",",
"\"fv\"",
"=>",
"trim",
"(",
"$",
"v",
")",
",",
"\"edition\"",
"=>",
"$",
"e",
",",
"'stage'",
"=>",
"$",
"st",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"fv\"",
"=>",
"trim",
"(",
"$",
"v",
")",
",",
"\"msg\"",
"=>",
"\"The version of iumio Framework is incompatible with iumio installer.\n You must have at least version \"",
".",
"self",
"::",
"$",
"framework_version_accept",
".",
"\" of iumio Framework on your web server.\"",
")",
")",
")",
";",
"}",
"}"
] | Check the iumio Framework version
@return string If iumio Framework version is compatible | [
"Check",
"the",
"iumio",
"Framework",
"version"
] | 02bb46ce6aa3a52908ff4608bd14264608bb38d1 | https://github.com/iumio/framework-setup/blob/02bb46ce6aa3a52908ff4608bd14264608bb38d1/Tools.php#L75-L104 | train |
iumio/framework-setup | Tools.php | Tools.isDirEmpty | final public static function isDirEmpty($dir)
{
if (!is_readable($dir)) {
return (null);
}
$handle = opendir($dir);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
return (false);
}
}
return (true);
} | php | final public static function isDirEmpty($dir)
{
if (!is_readable($dir)) {
return (null);
}
$handle = opendir($dir);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
return (false);
}
}
return (true);
} | [
"final",
"public",
"static",
"function",
"isDirEmpty",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"(",
"null",
")",
";",
"}",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"dir",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"$",
"entry",
"!=",
"\".\"",
"&&",
"$",
"entry",
"!=",
"\"..\"",
")",
"{",
"return",
"(",
"false",
")",
";",
"}",
"}",
"return",
"(",
"true",
")",
";",
"}"
] | Check if dir is empty or not
@param $dir string Dir path
@return bool|null If empty or not | [
"Check",
"if",
"dir",
"is",
"empty",
"or",
"not"
] | 02bb46ce6aa3a52908ff4608bd14264608bb38d1 | https://github.com/iumio/framework-setup/blob/02bb46ce6aa3a52908ff4608bd14264608bb38d1/Tools.php#L149-L161 | train |
iumio/framework-setup | Tools.php | Tools.checkLibrariesRequired | final public static function checkLibrariesRequired()
{
$base = __DIR__."/../../";
foreach (self::$libs as $lib => $val) {
if (!is_dir($base.$lib) || !self::checkIsReadable($base.$lib) ||
!self::checkIsWritable($base.$lib) || self::isDirEmpty($base.$lib)) {
return (json_encode(array("code" => 500, "results" => "NOK", "libsr" => $lib, "msg" => $val)));
}
}
foreach (self::$php_extensions as $lib => $val) {
if (!extension_loaded($lib)) {
return (json_encode(array("code" => 500, "results" => "NOK", "libsr" => $lib, "msg" => $val)));
}
}
return (json_encode(array("code" => 200, "results" => "OK")));
} | php | final public static function checkLibrariesRequired()
{
$base = __DIR__."/../../";
foreach (self::$libs as $lib => $val) {
if (!is_dir($base.$lib) || !self::checkIsReadable($base.$lib) ||
!self::checkIsWritable($base.$lib) || self::isDirEmpty($base.$lib)) {
return (json_encode(array("code" => 500, "results" => "NOK", "libsr" => $lib, "msg" => $val)));
}
}
foreach (self::$php_extensions as $lib => $val) {
if (!extension_loaded($lib)) {
return (json_encode(array("code" => 500, "results" => "NOK", "libsr" => $lib, "msg" => $val)));
}
}
return (json_encode(array("code" => 200, "results" => "OK")));
} | [
"final",
"public",
"static",
"function",
"checkLibrariesRequired",
"(",
")",
"{",
"$",
"base",
"=",
"__DIR__",
".",
"\"/../../\"",
";",
"foreach",
"(",
"self",
"::",
"$",
"libs",
"as",
"$",
"lib",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"base",
".",
"$",
"lib",
")",
"||",
"!",
"self",
"::",
"checkIsReadable",
"(",
"$",
"base",
".",
"$",
"lib",
")",
"||",
"!",
"self",
"::",
"checkIsWritable",
"(",
"$",
"base",
".",
"$",
"lib",
")",
"||",
"self",
"::",
"isDirEmpty",
"(",
"$",
"base",
".",
"$",
"lib",
")",
")",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"libsr\"",
"=>",
"$",
"lib",
",",
"\"msg\"",
"=>",
"$",
"val",
")",
")",
")",
";",
"}",
"}",
"foreach",
"(",
"self",
"::",
"$",
"php_extensions",
"as",
"$",
"lib",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"extension_loaded",
"(",
"$",
"lib",
")",
")",
"{",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"500",
",",
"\"results\"",
"=>",
"\"NOK\"",
",",
"\"libsr\"",
"=>",
"$",
"lib",
",",
"\"msg\"",
"=>",
"$",
"val",
")",
")",
")",
";",
"}",
"}",
"return",
"(",
"json_encode",
"(",
"array",
"(",
"\"code\"",
"=>",
"200",
",",
"\"results\"",
"=>",
"\"OK\"",
")",
")",
")",
";",
"}"
] | Check if librairies required are installed
@return int Are installed or not | [
"Check",
"if",
"librairies",
"required",
"are",
"installed"
] | 02bb46ce6aa3a52908ff4608bd14264608bb38d1 | https://github.com/iumio/framework-setup/blob/02bb46ce6aa3a52908ff4608bd14264608bb38d1/Tools.php#L167-L184 | train |
FuzeWorks/Core | src/FuzeWorks/Configurator.php | Configurator.setParameters | public function setParameters(array $params): self
{
foreach ($params as $key => $value) {
$this->parameters[$key] = $value;
}
return $this;
} | php | public function setParameters(array $params): self
{
foreach ($params as $key => $value) {
$this->parameters[$key] = $value;
}
return $this;
} | [
"public",
"function",
"setParameters",
"(",
"array",
"$",
"params",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"parameters",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds new parameters. The %params% will be expanded.
@return self | [
"Adds",
"new",
"parameters",
".",
"The",
"%params%",
"will",
"be",
"expanded",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Configurator.php#L111-L117 | train |
FuzeWorks/Core | src/FuzeWorks/Configurator.php | Configurator.setDebugMode | public function setDebugMode($value): self
{
if (is_string($value) || is_array($value)) {
$value = static::detectDebugMode($value);
} elseif (!is_bool($value)) {
throw new InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value)));
}
$this->parameters['debugMode'] = $value;
return $this;
} | php | public function setDebugMode($value): self
{
if (is_string($value) || is_array($value)) {
$value = static::detectDebugMode($value);
} elseif (!is_bool($value)) {
throw new InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value)));
}
$this->parameters['debugMode'] = $value;
return $this;
} | [
"public",
"function",
"setDebugMode",
"(",
"$",
"value",
")",
":",
"self",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"||",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"detectDebugMode",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"!",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Value must be either a string, array, or boolean, %s given.'",
",",
"gettype",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"parameters",
"[",
"'debugMode'",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameter %debugMode%.
@param bool|string|array
@return self | [
"Set",
"parameter",
"%debugMode%",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Configurator.php#L142-L151 | train |
FuzeWorks/Core | src/FuzeWorks/Configurator.php | Configurator.createContainer | public function createContainer(): Factory
{
// First set all the directories
Core::$appDir = $this->parameters['appDir'];
Core::$wwwDir = $this->parameters['wwwDir'];
Core::$tempDir = $this->parameters['tempDir'];
Core::$logDir = $this->parameters['logDir'];
// Then set debug mode
if ($this->parameters['debugMode'])
{
define('ENVIRONMENT', 'DEVELOPMENT');
}
else
{
define('ENVIRONMENT', 'PRODUCTION');
}
// And enable Tracy Debugger
if (class_exists('Tracy\Debugger', true))
{
Debugger::enable(!$this->parameters['debugMode'], realpath($this->parameters['logDir']));
if (isset($this->parameters['debugEmail']))
{
Debugger::$email = $this->parameters['debugEmail'];
}
Logger::$useTracy = true;
}
// Then load the framework
Core::init();
return Factory::getInstance();
} | php | public function createContainer(): Factory
{
// First set all the directories
Core::$appDir = $this->parameters['appDir'];
Core::$wwwDir = $this->parameters['wwwDir'];
Core::$tempDir = $this->parameters['tempDir'];
Core::$logDir = $this->parameters['logDir'];
// Then set debug mode
if ($this->parameters['debugMode'])
{
define('ENVIRONMENT', 'DEVELOPMENT');
}
else
{
define('ENVIRONMENT', 'PRODUCTION');
}
// And enable Tracy Debugger
if (class_exists('Tracy\Debugger', true))
{
Debugger::enable(!$this->parameters['debugMode'], realpath($this->parameters['logDir']));
if (isset($this->parameters['debugEmail']))
{
Debugger::$email = $this->parameters['debugEmail'];
}
Logger::$useTracy = true;
}
// Then load the framework
Core::init();
return Factory::getInstance();
} | [
"public",
"function",
"createContainer",
"(",
")",
":",
"Factory",
"{",
"// First set all the directories",
"Core",
"::",
"$",
"appDir",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'appDir'",
"]",
";",
"Core",
"::",
"$",
"wwwDir",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'wwwDir'",
"]",
";",
"Core",
"::",
"$",
"tempDir",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'tempDir'",
"]",
";",
"Core",
"::",
"$",
"logDir",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'logDir'",
"]",
";",
"// Then set debug mode",
"if",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'debugMode'",
"]",
")",
"{",
"define",
"(",
"'ENVIRONMENT'",
",",
"'DEVELOPMENT'",
")",
";",
"}",
"else",
"{",
"define",
"(",
"'ENVIRONMENT'",
",",
"'PRODUCTION'",
")",
";",
"}",
"// And enable Tracy Debugger ",
"if",
"(",
"class_exists",
"(",
"'Tracy\\Debugger'",
",",
"true",
")",
")",
"{",
"Debugger",
"::",
"enable",
"(",
"!",
"$",
"this",
"->",
"parameters",
"[",
"'debugMode'",
"]",
",",
"realpath",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'logDir'",
"]",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"'debugEmail'",
"]",
")",
")",
"{",
"Debugger",
"::",
"$",
"email",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'debugEmail'",
"]",
";",
"}",
"Logger",
"::",
"$",
"useTracy",
"=",
"true",
";",
"}",
"// Then load the framework",
"Core",
"::",
"init",
"(",
")",
";",
"return",
"Factory",
"::",
"getInstance",
"(",
")",
";",
"}"
] | Create the container which holds FuzeWorks.
Due to the static nature of FuzeWorks, this is not yet possible.
When issue #101 is completed, this should be resolved.
@return Factory | [
"Create",
"the",
"container",
"which",
"holds",
"FuzeWorks",
"."
] | 051c64fdaa3a648174cbd54557d05ad553dd826b | https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Configurator.php#L194-L227 | train |
phpffcms/ffcms-core | src/Properties.php | Properties.get | public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
{
$this->load($configFile);
// check if configs for this file is loaded
if (!isset($this->data[$configFile])) {
return false;
}
// check if config key is exist
if (!isset($this->data[$configFile][$configKey])) {
return false;
}
$response = $this->data[$configFile][$configKey];
// try to convert config value by defined parse type
$parseType = Str::lowerCase($parseType);
switch ($parseType) {
case 'int':
case 'integer':
$response = (int)$response;
break;
case 'bool':
case 'boolean':
$response = (bool)$response;
break;
case 'float':
$response = (float)$response;
break;
case 'double':
$response = (double)$response;
break;
}
return $response;
} | php | public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
{
$this->load($configFile);
// check if configs for this file is loaded
if (!isset($this->data[$configFile])) {
return false;
}
// check if config key is exist
if (!isset($this->data[$configFile][$configKey])) {
return false;
}
$response = $this->data[$configFile][$configKey];
// try to convert config value by defined parse type
$parseType = Str::lowerCase($parseType);
switch ($parseType) {
case 'int':
case 'integer':
$response = (int)$response;
break;
case 'bool':
case 'boolean':
$response = (bool)$response;
break;
case 'float':
$response = (float)$response;
break;
case 'double':
$response = (double)$response;
break;
}
return $response;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"configKey",
",",
"string",
"$",
"configFile",
"=",
"'default'",
",",
"?",
"string",
"$",
"parseType",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"configFile",
")",
";",
"// check if configs for this file is loaded",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// check if config key is exist",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
"[",
"$",
"configKey",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
"[",
"$",
"configKey",
"]",
";",
"// try to convert config value by defined parse type",
"$",
"parseType",
"=",
"Str",
"::",
"lowerCase",
"(",
"$",
"parseType",
")",
";",
"switch",
"(",
"$",
"parseType",
")",
"{",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"$",
"response",
"=",
"(",
"int",
")",
"$",
"response",
";",
"break",
";",
"case",
"'bool'",
":",
"case",
"'boolean'",
":",
"$",
"response",
"=",
"(",
"bool",
")",
"$",
"response",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"response",
"=",
"(",
"float",
")",
"$",
"response",
";",
"break",
";",
"case",
"'double'",
":",
"$",
"response",
"=",
"(",
"double",
")",
"$",
"response",
";",
"break",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Get config value by config key from configuration file
@param string $configKey
@param string $configFile
@param string|null $parseType
@return mixed | [
"Get",
"config",
"value",
"by",
"config",
"key",
"from",
"configuration",
"file"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Properties.php#L61-L96 | train |
phpffcms/ffcms-core | src/Properties.php | Properties.getAll | public function getAll($configFile = 'default'): ?array
{
$this->load($configFile);
if (!Any::isArray($this->data) || !array_key_exists($configFile, $this->data)) {
return null;
}
return $this->data[$configFile];
} | php | public function getAll($configFile = 'default'): ?array
{
$this->load($configFile);
if (!Any::isArray($this->data) || !array_key_exists($configFile, $this->data)) {
return null;
}
return $this->data[$configFile];
} | [
"public",
"function",
"getAll",
"(",
"$",
"configFile",
"=",
"'default'",
")",
":",
"?",
"array",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"configFile",
")",
";",
"if",
"(",
"!",
"Any",
"::",
"isArray",
"(",
"$",
"this",
"->",
"data",
")",
"||",
"!",
"array_key_exists",
"(",
"$",
"configFile",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
";",
"}"
] | Get all configuration data of selected file
@param string $configFile
@return array|null | [
"Get",
"all",
"configuration",
"data",
"of",
"selected",
"file"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Properties.php#L103-L111 | train |
phpffcms/ffcms-core | src/Properties.php | Properties.updateConfig | public function updateConfig(string $configFile, array $newData, ?bool $mergeDeep = false): bool
{
$this->load($configFile);
if (!isset($this->data[$configFile])) {
return false;
}
$oldData = $this->data[$configFile];
$saveData = ($mergeDeep ? Arr::mergeRecursive($oldData, $newData) : Arr::merge($oldData, $newData));
return $this->writeConfig($configFile, $saveData);
} | php | public function updateConfig(string $configFile, array $newData, ?bool $mergeDeep = false): bool
{
$this->load($configFile);
if (!isset($this->data[$configFile])) {
return false;
}
$oldData = $this->data[$configFile];
$saveData = ($mergeDeep ? Arr::mergeRecursive($oldData, $newData) : Arr::merge($oldData, $newData));
return $this->writeConfig($configFile, $saveData);
} | [
"public",
"function",
"updateConfig",
"(",
"string",
"$",
"configFile",
",",
"array",
"$",
"newData",
",",
"?",
"bool",
"$",
"mergeDeep",
"=",
"false",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"configFile",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"oldData",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"configFile",
"]",
";",
"$",
"saveData",
"=",
"(",
"$",
"mergeDeep",
"?",
"Arr",
"::",
"mergeRecursive",
"(",
"$",
"oldData",
",",
"$",
"newData",
")",
":",
"Arr",
"::",
"merge",
"(",
"$",
"oldData",
",",
"$",
"newData",
")",
")",
";",
"return",
"$",
"this",
"->",
"writeConfig",
"(",
"$",
"configFile",
",",
"$",
"saveData",
")",
";",
"}"
] | Update configuration data based on key-value array of new data. Do not pass multi-level array on new position without existing keys
@param string $configFile
@param array $newData
@param bool $mergeDeep
@return bool | [
"Update",
"configuration",
"data",
"based",
"on",
"key",
"-",
"value",
"array",
"of",
"new",
"data",
".",
"Do",
"not",
"pass",
"multi",
"-",
"level",
"array",
"on",
"new",
"position",
"without",
"existing",
"keys"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Properties.php#L120-L130 | train |
phpffcms/ffcms-core | src/Properties.php | Properties.writeConfig | public function writeConfig(string $configFile, array $data): bool
{
$path = '/Private/Config/' . ucfirst(Str::lowerCase($configFile)) . '.php';
if (!File::exist($path) || !File::writable($path)) {
return false;
}
$saveData = '<?php return ' . Arr::exportVar($data) . ';';
File::write($path, $saveData);
// overload config values if changed
$this->load($configFile, true);
return true;
} | php | public function writeConfig(string $configFile, array $data): bool
{
$path = '/Private/Config/' . ucfirst(Str::lowerCase($configFile)) . '.php';
if (!File::exist($path) || !File::writable($path)) {
return false;
}
$saveData = '<?php return ' . Arr::exportVar($data) . ';';
File::write($path, $saveData);
// overload config values if changed
$this->load($configFile, true);
return true;
} | [
"public",
"function",
"writeConfig",
"(",
"string",
"$",
"configFile",
",",
"array",
"$",
"data",
")",
":",
"bool",
"{",
"$",
"path",
"=",
"'/Private/Config/'",
".",
"ucfirst",
"(",
"Str",
"::",
"lowerCase",
"(",
"$",
"configFile",
")",
")",
".",
"'.php'",
";",
"if",
"(",
"!",
"File",
"::",
"exist",
"(",
"$",
"path",
")",
"||",
"!",
"File",
"::",
"writable",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"saveData",
"=",
"'<?php return '",
".",
"Arr",
"::",
"exportVar",
"(",
"$",
"data",
")",
".",
"';'",
";",
"File",
"::",
"write",
"(",
"$",
"path",
",",
"$",
"saveData",
")",
";",
"// overload config values if changed",
"$",
"this",
"->",
"load",
"(",
"$",
"configFile",
",",
"true",
")",
";",
"return",
"true",
";",
"}"
] | Write configurations data from array to cfg file
@param string $configFile
@param array $data
@return bool | [
"Write",
"configurations",
"data",
"from",
"array",
"to",
"cfg",
"file"
] | 44a309553ef9f115ccfcfd71f2ac6e381c612082 | https://github.com/phpffcms/ffcms-core/blob/44a309553ef9f115ccfcfd71f2ac6e381c612082/src/Properties.php#L138-L150 | train |
ARCANESOFT/SEO | src/Models/Presenters/PagePresenter.php | PagePresenter.renderContent | protected function renderContent(array $replacements)
{
return $this->getContentReplacer()->replace($this->content, array_merge([
'app_name' => config('app.name'),
'app_url' => link_to(config('app.url'), config('app.name')),
'mobile' => html()->tel(config('cms.company.mobile')),
'phone' => html()->tel(config('cms.company.phone')),
'email' => html()->mailto(config('cms.company.email')),
], $replacements));
} | php | protected function renderContent(array $replacements)
{
return $this->getContentReplacer()->replace($this->content, array_merge([
'app_name' => config('app.name'),
'app_url' => link_to(config('app.url'), config('app.name')),
'mobile' => html()->tel(config('cms.company.mobile')),
'phone' => html()->tel(config('cms.company.phone')),
'email' => html()->mailto(config('cms.company.email')),
], $replacements));
} | [
"protected",
"function",
"renderContent",
"(",
"array",
"$",
"replacements",
")",
"{",
"return",
"$",
"this",
"->",
"getContentReplacer",
"(",
")",
"->",
"replace",
"(",
"$",
"this",
"->",
"content",
",",
"array_merge",
"(",
"[",
"'app_name'",
"=>",
"config",
"(",
"'app.name'",
")",
",",
"'app_url'",
"=>",
"link_to",
"(",
"config",
"(",
"'app.url'",
")",
",",
"config",
"(",
"'app.name'",
")",
")",
",",
"'mobile'",
"=>",
"html",
"(",
")",
"->",
"tel",
"(",
"config",
"(",
"'cms.company.mobile'",
")",
")",
",",
"'phone'",
"=>",
"html",
"(",
")",
"->",
"tel",
"(",
"config",
"(",
"'cms.company.phone'",
")",
")",
",",
"'email'",
"=>",
"html",
"(",
")",
"->",
"mailto",
"(",
"config",
"(",
"'cms.company.email'",
")",
")",
",",
"]",
",",
"$",
"replacements",
")",
")",
";",
"}"
] | Render the content.
@param array $replacements
@return string | [
"Render",
"the",
"content",
"."
] | ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2 | https://github.com/ARCANESOFT/SEO/blob/ce6d6135d55e8b2fd43cf7923839b4791b7c7ad2/src/Models/Presenters/PagePresenter.php#L56-L65 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.setLabel | public function setLabel(LabelElement $label)
{
$this->label = $label;
if(($for = $this->getAttribute('id'))) {
$label->setAttribute('for', $for);
}
return $this;
} | php | public function setLabel(LabelElement $label)
{
$this->label = $label;
if(($for = $this->getAttribute('id'))) {
$label->setAttribute('for', $for);
}
return $this;
} | [
"public",
"function",
"setLabel",
"(",
"LabelElement",
"$",
"label",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"$",
"label",
";",
"if",
"(",
"(",
"$",
"for",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
")",
")",
"{",
"$",
"label",
"->",
"setAttribute",
"(",
"'for'",
",",
"$",
"for",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | assign label element to this form element
"for" attribute of label is set if form element has an "id" attribute
@param LabelElement $label
@return $this | [
"assign",
"label",
"element",
"to",
"this",
"form",
"element",
"for",
"attribute",
"of",
"label",
"is",
"set",
"if",
"form",
"element",
"has",
"an",
"id",
"attribute"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L196-L207 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.setAttribute | public function setAttribute($attr, $value) {
$attr = strtolower($attr);
if($attr === 'value') {
return $this->setValue($value);
}
if($attr === 'name') {
return $this->setName($value);
}
if($attr === 'id' && $this->label) {
$this->label->setAttribute('for', $value);
}
if(is_null($value)) {
unset($this->attributes[$attr]);
}
else {
$this->attributes[$attr] = $value;
}
return $this;
} | php | public function setAttribute($attr, $value) {
$attr = strtolower($attr);
if($attr === 'value') {
return $this->setValue($value);
}
if($attr === 'name') {
return $this->setName($value);
}
if($attr === 'id' && $this->label) {
$this->label->setAttribute('for', $value);
}
if(is_null($value)) {
unset($this->attributes[$attr]);
}
else {
$this->attributes[$attr] = $value;
}
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"attr",
",",
"$",
"value",
")",
"{",
"$",
"attr",
"=",
"strtolower",
"(",
"$",
"attr",
")",
";",
"if",
"(",
"$",
"attr",
"===",
"'value'",
")",
"{",
"return",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"attr",
"===",
"'name'",
")",
"{",
"return",
"$",
"this",
"->",
"setName",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"attr",
"===",
"'id'",
"&&",
"$",
"this",
"->",
"label",
")",
"{",
"$",
"this",
"->",
"label",
"->",
"setAttribute",
"(",
"'for'",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attr",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attr",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | sets miscellaneous attribute of form element
attributes 'value', 'name' are treated by calling the according setters
setting 'id' will update 'for' when a label element is assigned
@param string $attr
@param mixed $value
@return \vxPHP\Form\FormElement\FormElement | [
"sets",
"miscellaneous",
"attribute",
"of",
"form",
"element",
"attributes",
"value",
"name",
"are",
"treated",
"by",
"calling",
"the",
"according",
"setters",
"setting",
"id",
"will",
"update",
"for",
"when",
"a",
"label",
"element",
"is",
"assigned"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L230-L254 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.setAttributes | public function setAttributes(Array $attributes) {
foreach($attributes as $k => $v) {
$this->setAttribute($k, $v);
}
return $this;
} | php | public function setAttributes(Array $attributes) {
foreach($attributes as $k => $v) {
$this->setAttribute($k, $v);
}
return $this;
} | [
"public",
"function",
"setAttributes",
"(",
"Array",
"$",
"attributes",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | sets several attributes with an associative array
@param array $attributes
@return \vxPHP\Form\FormElement\FormElement | [
"sets",
"several",
"attributes",
"with",
"an",
"associative",
"array"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L262-L269 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.getAttribute | public function getAttribute($name) {
$key = strtolower($name);
if('value' === $key) {
return $this->getValue();
}
if('name' === $key) {
return $this->getName();
}
if(array_key_exists($key, $this->attributes)) {
return $this->attributes[strtolower($name)];
}
return null;
} | php | public function getAttribute($name) {
$key = strtolower($name);
if('value' === $key) {
return $this->getValue();
}
if('name' === $key) {
return $this->getName();
}
if(array_key_exists($key, $this->attributes)) {
return $this->attributes[strtolower($name)];
}
return null;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"'value'",
"===",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"}",
"if",
"(",
"'name'",
"===",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | get a single attribute
name and value attributes are redirected to
the respective getter methods
@param $name
@return string|null | [
"get",
"a",
"single",
"attribute",
"name",
"and",
"value",
"attributes",
"are",
"redirected",
"to",
"the",
"respective",
"getter",
"methods"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L279-L299 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.isValid | public function isValid() {
if(!isset($this->valid)) {
$this->valid = $this->applyValidators(
$this->applyModifiers($this->getValue())
);
}
return $this->valid;
} | php | public function isValid() {
if(!isset($this->valid)) {
$this->valid = $this->applyValidators(
$this->applyModifiers($this->getValue())
);
}
return $this->valid;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"valid",
")",
")",
"{",
"$",
"this",
"->",
"valid",
"=",
"$",
"this",
"->",
"applyValidators",
"(",
"$",
"this",
"->",
"applyModifiers",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"valid",
";",
"}"
] | checks whether modified form element passes validation rules
@return boolean $success | [
"checks",
"whether",
"modified",
"form",
"element",
"passes",
"validation",
"rules"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L410-L420 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.canSubmit | public function canSubmit() {
return
$this instanceof InputElement && isset($this->attributes['type']) && $this->attributes['type'] == 'submit' ||
$this instanceof ImageElement ||
$this instanceof SubmitInputElement ||
$this instanceof ButtonElement && $this->attributes['type'] == 'submit';
} | php | public function canSubmit() {
return
$this instanceof InputElement && isset($this->attributes['type']) && $this->attributes['type'] == 'submit' ||
$this instanceof ImageElement ||
$this instanceof SubmitInputElement ||
$this instanceof ButtonElement && $this->attributes['type'] == 'submit';
} | [
"public",
"function",
"canSubmit",
"(",
")",
"{",
"return",
"$",
"this",
"instanceof",
"InputElement",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
")",
"&&",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
"==",
"'submit'",
"||",
"$",
"this",
"instanceof",
"ImageElement",
"||",
"$",
"this",
"instanceof",
"SubmitInputElement",
"||",
"$",
"this",
"instanceof",
"ButtonElement",
"&&",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
"==",
"'submit'",
";",
"}"
] | check whether element can submit a form
@return boolean $result | [
"check",
"whether",
"element",
"can",
"submit",
"a",
"form"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L427-L435 | train |
Vectrex/vxPHP | src/Form/FormElement/FormElement.php | FormElement.render | public function render()
{
if(!$this->template) {
throw new \RuntimeException(sprintf("No template for element '%s' defined.", $this->getName()));
}
$this->html = $this->template->assign('element', $this)->display();
return $this->html;
} | php | public function render()
{
if(!$this->template) {
throw new \RuntimeException(sprintf("No template for element '%s' defined.", $this->getName()));
}
$this->html = $this->template->assign('element', $this)->display();
return $this->html;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"template",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"\"No template for element '%s' defined.\"",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"html",
"=",
"$",
"this",
"->",
"template",
"->",
"assign",
"(",
"'element'",
",",
"$",
"this",
")",
"->",
"display",
"(",
")",
";",
"return",
"$",
"this",
"->",
"html",
";",
"}"
] | renders form element and returns markup
requires a template for rendering
@return string
@throws \vxPHP\Application\Exception\ApplicationException
@throws \vxPHP\Template\Exception\SimpleTemplateException | [
"renders",
"form",
"element",
"and",
"returns",
"markup",
"requires",
"a",
"template",
"for",
"rendering"
] | 295c21b00e7ef6085efcdf5b64fabb28d499b5a6 | https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Form/FormElement/FormElement.php#L577-L585 | train |
jmfeurprier/perf-database | lib/perf/Db/ConnectionPool.php | ConnectionPool.prepare | public function prepare($connectionId, Credentials $credentials)
{
$connection = Connection::fromCredentials($credentials);
$this->store($connectionId, $connection);
} | php | public function prepare($connectionId, Credentials $credentials)
{
$connection = Connection::fromCredentials($credentials);
$this->store($connectionId, $connection);
} | [
"public",
"function",
"prepare",
"(",
"$",
"connectionId",
",",
"Credentials",
"$",
"credentials",
")",
"{",
"$",
"connection",
"=",
"Connection",
"::",
"fromCredentials",
"(",
"$",
"credentials",
")",
";",
"$",
"this",
"->",
"store",
"(",
"$",
"connectionId",
",",
"$",
"connection",
")",
";",
"}"
] | Stores a new database connection with provided credentials.
@param string $connectionId
@param Credentials $credentials
@return void | [
"Stores",
"a",
"new",
"database",
"connection",
"with",
"provided",
"credentials",
"."
] | 9b39dc76be9f8a33d02aadc168fdb74d786f0ff2 | https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/ConnectionPool.php#L27-L32 | train |
jmfeurprier/perf-database | lib/perf/Db/ConnectionPool.php | ConnectionPool.store | public function store($connectionId, Connection $connection)
{
$connectionId = (string) $connectionId;
$this->connections[$connectionId] = $connection;
} | php | public function store($connectionId, Connection $connection)
{
$connectionId = (string) $connectionId;
$this->connections[$connectionId] = $connection;
} | [
"public",
"function",
"store",
"(",
"$",
"connectionId",
",",
"Connection",
"$",
"connection",
")",
"{",
"$",
"connectionId",
"=",
"(",
"string",
")",
"$",
"connectionId",
";",
"$",
"this",
"->",
"connections",
"[",
"$",
"connectionId",
"]",
"=",
"$",
"connection",
";",
"}"
] | Stores an existing database connection.
@param string $connectionId
@param Connection $connection
@return void | [
"Stores",
"an",
"existing",
"database",
"connection",
"."
] | 9b39dc76be9f8a33d02aadc168fdb74d786f0ff2 | https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/ConnectionPool.php#L41-L46 | train |
jmfeurprier/perf-database | lib/perf/Db/ConnectionPool.php | ConnectionPool.fetch | public function fetch($connectionId)
{
$connectionId = (string) $connectionId;
if ($this->exist($connectionId)) {
return $this->connections[$connectionId];
}
throw new \DomainException("Requested database connection '{$connectionId}' does not exist.");
} | php | public function fetch($connectionId)
{
$connectionId = (string) $connectionId;
if ($this->exist($connectionId)) {
return $this->connections[$connectionId];
}
throw new \DomainException("Requested database connection '{$connectionId}' does not exist.");
} | [
"public",
"function",
"fetch",
"(",
"$",
"connectionId",
")",
"{",
"$",
"connectionId",
"=",
"(",
"string",
")",
"$",
"connectionId",
";",
"if",
"(",
"$",
"this",
"->",
"exist",
"(",
"$",
"connectionId",
")",
")",
"{",
"return",
"$",
"this",
"->",
"connections",
"[",
"$",
"connectionId",
"]",
";",
"}",
"throw",
"new",
"\\",
"DomainException",
"(",
"\"Requested database connection '{$connectionId}' does not exist.\"",
")",
";",
"}"
] | Returns the database connection with provided identifier, or throws an exception if not found.
@param string $connectionId
@return Connection
@throws \DomainException | [
"Returns",
"the",
"database",
"connection",
"with",
"provided",
"identifier",
"or",
"throws",
"an",
"exception",
"if",
"not",
"found",
"."
] | 9b39dc76be9f8a33d02aadc168fdb74d786f0ff2 | https://github.com/jmfeurprier/perf-database/blob/9b39dc76be9f8a33d02aadc168fdb74d786f0ff2/lib/perf/Db/ConnectionPool.php#L55-L64 | train |
yuncms/yuncms-core | console/controllers/CronController.php | CronController.actionMinute | public function actionMinute()
{
$this->stdout("Executing minute tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_MINUTE_RUN);
Yii::$app->settings->set('cronLastMinuteRun', time(), 'core');
return ExitCode::OK;
} | php | public function actionMinute()
{
$this->stdout("Executing minute tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_MINUTE_RUN);
Yii::$app->settings->set('cronLastMinuteRun', time(), 'core');
return ExitCode::OK;
} | [
"public",
"function",
"actionMinute",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"\"Executing minute tasks:\"",
".",
"PHP_EOL",
",",
"Console",
"::",
"FG_YELLOW",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_ON_MINUTE_RUN",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"set",
"(",
"'cronLastMinuteRun'",
",",
"time",
"(",
")",
",",
"'core'",
")",
";",
"return",
"ExitCode",
"::",
"OK",
";",
"}"
] | Executes minute cron tasks.
@throws \yii\base\InvalidConfigException | [
"Executes",
"minute",
"cron",
"tasks",
"."
] | bfaf61c38e48979036c3ede3a0f2beb637500df5 | https://github.com/yuncms/yuncms-core/blob/bfaf61c38e48979036c3ede3a0f2beb637500df5/console/controllers/CronController.php#L49-L55 | train |
yuncms/yuncms-core | console/controllers/CronController.php | CronController.actionHourly | public function actionHourly()
{
$this->stdout("Executing hourly tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_HOURLY_RUN);
Yii::$app->settings->set('cronLastHourlyRun', time(), 'core');
return ExitCode::OK;
} | php | public function actionHourly()
{
$this->stdout("Executing hourly tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_HOURLY_RUN);
Yii::$app->settings->set('cronLastHourlyRun', time(), 'core');
return ExitCode::OK;
} | [
"public",
"function",
"actionHourly",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"\"Executing hourly tasks:\"",
".",
"PHP_EOL",
",",
"Console",
"::",
"FG_YELLOW",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_ON_HOURLY_RUN",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"set",
"(",
"'cronLastHourlyRun'",
",",
"time",
"(",
")",
",",
"'core'",
")",
";",
"return",
"ExitCode",
"::",
"OK",
";",
"}"
] | Executes hourly cron tasks.
@throws \yii\base\InvalidConfigException | [
"Executes",
"hourly",
"cron",
"tasks",
"."
] | bfaf61c38e48979036c3ede3a0f2beb637500df5 | https://github.com/yuncms/yuncms-core/blob/bfaf61c38e48979036c3ede3a0f2beb637500df5/console/controllers/CronController.php#L61-L67 | train |
yuncms/yuncms-core | console/controllers/CronController.php | CronController.actionDaily | public function actionDaily()
{
$this->stdout("Executing daily tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_DAILY_RUN);
Yii::$app->settings->set('cronLastDailyRun', time(), 'core');
return ExitCode::OK;
} | php | public function actionDaily()
{
$this->stdout("Executing daily tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_DAILY_RUN);
Yii::$app->settings->set('cronLastDailyRun', time(), 'core');
return ExitCode::OK;
} | [
"public",
"function",
"actionDaily",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"\"Executing daily tasks:\"",
".",
"PHP_EOL",
",",
"Console",
"::",
"FG_YELLOW",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_ON_DAILY_RUN",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"set",
"(",
"'cronLastDailyRun'",
",",
"time",
"(",
")",
",",
"'core'",
")",
";",
"return",
"ExitCode",
"::",
"OK",
";",
"}"
] | Executes daily cron tasks.
@throws \yii\base\InvalidConfigException | [
"Executes",
"daily",
"cron",
"tasks",
"."
] | bfaf61c38e48979036c3ede3a0f2beb637500df5 | https://github.com/yuncms/yuncms-core/blob/bfaf61c38e48979036c3ede3a0f2beb637500df5/console/controllers/CronController.php#L73-L79 | train |
yuncms/yuncms-core | console/controllers/CronController.php | CronController.actionMonth | public function actionMonth()
{
$this->stdout("Executing month tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_MONTH_RUN);
Yii::$app->settings->set('cronLastMonthRun', time(), 'core');
return ExitCode::OK;
} | php | public function actionMonth()
{
$this->stdout("Executing month tasks:" . PHP_EOL, Console::FG_YELLOW);
$this->trigger(self::EVENT_ON_MONTH_RUN);
Yii::$app->settings->set('cronLastMonthRun', time(), 'core');
return ExitCode::OK;
} | [
"public",
"function",
"actionMonth",
"(",
")",
"{",
"$",
"this",
"->",
"stdout",
"(",
"\"Executing month tasks:\"",
".",
"PHP_EOL",
",",
"Console",
"::",
"FG_YELLOW",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_ON_MONTH_RUN",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"set",
"(",
"'cronLastMonthRun'",
",",
"time",
"(",
")",
",",
"'core'",
")",
";",
"return",
"ExitCode",
"::",
"OK",
";",
"}"
] | Executes month cron tasks.
@throws \yii\base\InvalidConfigException | [
"Executes",
"month",
"cron",
"tasks",
"."
] | bfaf61c38e48979036c3ede3a0f2beb637500df5 | https://github.com/yuncms/yuncms-core/blob/bfaf61c38e48979036c3ede3a0f2beb637500df5/console/controllers/CronController.php#L85-L91 | train |
wasinger/adaptimage | src/ResponsiveImages/ResponsiveImageClass.php | ResponsiveImageClass.getImageResizeDefinitionByWidth | public function getImageResizeDefinitionByWidth($width)
{
if (!key_exists($width, $this->irds)) {
throw new WidthNotAllowedException($width);
}
return $this->irds[$width];
} | php | public function getImageResizeDefinitionByWidth($width)
{
if (!key_exists($width, $this->irds)) {
throw new WidthNotAllowedException($width);
}
return $this->irds[$width];
} | [
"public",
"function",
"getImageResizeDefinitionByWidth",
"(",
"$",
"width",
")",
"{",
"if",
"(",
"!",
"key_exists",
"(",
"$",
"width",
",",
"$",
"this",
"->",
"irds",
")",
")",
"{",
"throw",
"new",
"WidthNotAllowedException",
"(",
"$",
"width",
")",
";",
"}",
"return",
"$",
"this",
"->",
"irds",
"[",
"$",
"width",
"]",
";",
"}"
] | Get an ImageResizeDefinition for a given width
@param int $width
@return ImageResizeDefinition | [
"Get",
"an",
"ImageResizeDefinition",
"for",
"a",
"given",
"width"
] | 7b529b25081b399451c8bbd56d0cef7daaa83ec4 | https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/ResponsiveImages/ResponsiveImageClass.php#L181-L187 | train |
wasinger/adaptimage | src/ResponsiveImages/ResponsiveImageClass.php | ResponsiveImageClass.setScaleAlgorithm | public function setScaleAlgorithm($algorithm)
{
foreach ($this->available_image_widths as $width) {
$this->irds[$width]->setScaleAlgorithm($algorithm);
}
return $this;
} | php | public function setScaleAlgorithm($algorithm)
{
foreach ($this->available_image_widths as $width) {
$this->irds[$width]->setScaleAlgorithm($algorithm);
}
return $this;
} | [
"public",
"function",
"setScaleAlgorithm",
"(",
"$",
"algorithm",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"available_image_widths",
"as",
"$",
"width",
")",
"{",
"$",
"this",
"->",
"irds",
"[",
"$",
"width",
"]",
"->",
"setScaleAlgorithm",
"(",
"$",
"algorithm",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the algorithm used for scaling
@param string $algorithm One of the ImageInterface::FILTER_* constants
@return $this | [
"Set",
"the",
"algorithm",
"used",
"for",
"scaling"
] | 7b529b25081b399451c8bbd56d0cef7daaa83ec4 | https://github.com/wasinger/adaptimage/blob/7b529b25081b399451c8bbd56d0cef7daaa83ec4/src/ResponsiveImages/ResponsiveImageClass.php#L264-L270 | train |
bseddon/XPath20 | Value/DurationValue.php | DurationValue.getTotalDays | public function getTotalDays()
{
// Get a count of days. The 'diff' function generates an interval with a count of days in ->days
$dt = new \DateTimeImmutable();
return $dt->add( $this->Value )->diff( $dt )->days;
} | php | public function getTotalDays()
{
// Get a count of days. The 'diff' function generates an interval with a count of days in ->days
$dt = new \DateTimeImmutable();
return $dt->add( $this->Value )->diff( $dt )->days;
} | [
"public",
"function",
"getTotalDays",
"(",
")",
"{",
"// Get a count of days. The 'diff' function generates an interval with a count of days in ->days\r",
"$",
"dt",
"=",
"new",
"\\",
"DateTimeImmutable",
"(",
")",
";",
"return",
"$",
"dt",
"->",
"add",
"(",
"$",
"this",
"->",
"Value",
")",
"->",
"diff",
"(",
"$",
"dt",
")",
"->",
"days",
";",
"}"
] | Return the total days of the duration
@return int | [
"Return",
"the",
"total",
"days",
"of",
"the",
"duration"
] | 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Value/DurationValue.php#L323-L328 | train |
bseddon/XPath20 | Value/DurationValue.php | DurationValue.hasValue | public static function hasValue( $di )
{
$components = array( "s", "i", "h", "d", "m", "y" );
$hasValue = false;
foreach( $components as $component )
{
$hasValue = isset( $di->$component ) && $di->$component != 0;
if ( $hasValue ) break;
}
return $hasValue;
} | php | public static function hasValue( $di )
{
$components = array( "s", "i", "h", "d", "m", "y" );
$hasValue = false;
foreach( $components as $component )
{
$hasValue = isset( $di->$component ) && $di->$component != 0;
if ( $hasValue ) break;
}
return $hasValue;
} | [
"public",
"static",
"function",
"hasValue",
"(",
"$",
"di",
")",
"{",
"$",
"components",
"=",
"array",
"(",
"\"s\"",
",",
"\"i\"",
",",
"\"h\"",
",",
"\"d\"",
",",
"\"m\"",
",",
"\"y\"",
")",
";",
"$",
"hasValue",
"=",
"false",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"hasValue",
"=",
"isset",
"(",
"$",
"di",
"->",
"$",
"component",
")",
"&&",
"$",
"di",
"->",
"$",
"component",
"!=",
"0",
";",
"if",
"(",
"$",
"hasValue",
")",
"break",
";",
"}",
"return",
"$",
"hasValue",
";",
"}"
] | Returns true if the date interval parameter has a non zero value
@param \DateInterval $di
@return bool | [
"Returns",
"true",
"if",
"the",
"date",
"interval",
"parameter",
"has",
"a",
"non",
"zero",
"value"
] | 69882b6efffaa5470a819d5fdd2f6473ddeb046d | https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Value/DurationValue.php#L422-L432 | train |
koolkode/view-express | src/Tree/AttributeNode.php | AttributeNode.compile | public function compile(ExpressCompiler $compiler, $flags = 0)
{
try
{
if($flags & self::FLAG_RAW)
{
if(empty($this->childNodes))
{
$compiler->write("''");
}
else
{
$compiler->write('(');
foreach($this->childNodes as $i => $node)
{
if($i > 0)
{
$compiler->write(' . ');
}
$node->compile($compiler, self::FLAG_RAW);
}
$compiler->write(')');
}
}
else
{
foreach($this->childNodes as $node)
{
$node->compile($compiler);
}
}
}
catch(ExpressViewException $e)
{
throw $e;
}
catch(\Exception $e)
{
throw new ExpressViewException(sprintf('Unable to compile attribute "%s"', $this->name), $compiler->getResource(), $this->line, $e);
}
} | php | public function compile(ExpressCompiler $compiler, $flags = 0)
{
try
{
if($flags & self::FLAG_RAW)
{
if(empty($this->childNodes))
{
$compiler->write("''");
}
else
{
$compiler->write('(');
foreach($this->childNodes as $i => $node)
{
if($i > 0)
{
$compiler->write(' . ');
}
$node->compile($compiler, self::FLAG_RAW);
}
$compiler->write(')');
}
}
else
{
foreach($this->childNodes as $node)
{
$node->compile($compiler);
}
}
}
catch(ExpressViewException $e)
{
throw $e;
}
catch(\Exception $e)
{
throw new ExpressViewException(sprintf('Unable to compile attribute "%s"', $this->name), $compiler->getResource(), $this->line, $e);
}
} | [
"public",
"function",
"compile",
"(",
"ExpressCompiler",
"$",
"compiler",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"flags",
"&",
"self",
"::",
"FLAG_RAW",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"childNodes",
")",
")",
"{",
"$",
"compiler",
"->",
"write",
"(",
"\"''\"",
")",
";",
"}",
"else",
"{",
"$",
"compiler",
"->",
"write",
"(",
"'('",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"childNodes",
"as",
"$",
"i",
"=>",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"i",
">",
"0",
")",
"{",
"$",
"compiler",
"->",
"write",
"(",
"' . '",
")",
";",
"}",
"$",
"node",
"->",
"compile",
"(",
"$",
"compiler",
",",
"self",
"::",
"FLAG_RAW",
")",
";",
"}",
"$",
"compiler",
"->",
"write",
"(",
"')'",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"compile",
"(",
"$",
"compiler",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"ExpressViewException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ExpressViewException",
"(",
"sprintf",
"(",
"'Unable to compile attribute \"%s\"'",
",",
"$",
"this",
"->",
"name",
")",
",",
"$",
"compiler",
"->",
"getResource",
"(",
")",
",",
"$",
"this",
"->",
"line",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Compile the attribute value into it's PHP code.
@param ExpressCompiler $compiler
@param integer $flags Raw mode is used when the element is going to be morphed from a TagBuilder. | [
"Compile",
"the",
"attribute",
"value",
"into",
"it",
"s",
"PHP",
"code",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/Tree/AttributeNode.php#L91-L134 | train |
mkurc1/DoctrinePrefixBundle | Subscriber/TablePrefixSubscriber.php | TablePrefixSubscriber.loadClassMetadata | public function loadClassMetadata(LoadClassMetadataEventArgs $args)
{
if (empty($this->prefix)) {
return;
}
/** @var ClassMetadata $classMetadata */
$classMetadata = $args->getClassMetadata();
if (false === strpos($classMetadata->getTableName(), $this->prefix)) {
$tableName = $this->prefix . $classMetadata->getTableName();
$classMetadata->setPrimaryTable(['name' => $tableName]);
}
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide'] === true) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
if (false !== strpos($mappedTableName, $this->prefix)) {
continue;
}
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
}
} | php | public function loadClassMetadata(LoadClassMetadataEventArgs $args)
{
if (empty($this->prefix)) {
return;
}
/** @var ClassMetadata $classMetadata */
$classMetadata = $args->getClassMetadata();
if (false === strpos($classMetadata->getTableName(), $this->prefix)) {
$tableName = $this->prefix . $classMetadata->getTableName();
$classMetadata->setPrimaryTable(['name' => $tableName]);
}
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && $mapping['isOwningSide'] === true) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
if (false !== strpos($mappedTableName, $this->prefix)) {
continue;
}
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
}
}
} | [
"public",
"function",
"loadClassMetadata",
"(",
"LoadClassMetadataEventArgs",
"$",
"args",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"return",
";",
"}",
"/** @var ClassMetadata $classMetadata */",
"$",
"classMetadata",
"=",
"$",
"args",
"->",
"getClassMetadata",
"(",
")",
";",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"classMetadata",
"->",
"getTableName",
"(",
")",
",",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"classMetadata",
"->",
"getTableName",
"(",
")",
";",
"$",
"classMetadata",
"->",
"setPrimaryTable",
"(",
"[",
"'name'",
"=>",
"$",
"tableName",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"classMetadata",
"->",
"getAssociationMappings",
"(",
")",
"as",
"$",
"fieldName",
"=>",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"mapping",
"[",
"'type'",
"]",
"==",
"ClassMetadataInfo",
"::",
"MANY_TO_MANY",
"&&",
"$",
"mapping",
"[",
"'isOwningSide'",
"]",
"===",
"true",
")",
"{",
"$",
"mappedTableName",
"=",
"$",
"classMetadata",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinTable'",
"]",
"[",
"'name'",
"]",
";",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"mappedTableName",
",",
"$",
"this",
"->",
"prefix",
")",
")",
"{",
"continue",
";",
"}",
"$",
"classMetadata",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinTable'",
"]",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"mappedTableName",
";",
"}",
"}",
"}"
] | Load class meta data event
@param LoadClassMetadataEventArgs $args
@return void | [
"Load",
"class",
"meta",
"data",
"event"
] | eaea50e4d3a81c3b4e2648c425387deceacddac7 | https://github.com/mkurc1/DoctrinePrefixBundle/blob/eaea50e4d3a81c3b4e2648c425387deceacddac7/Subscriber/TablePrefixSubscriber.php#L45-L70 | train |
foxslider/cmg-plugin | common/components/Core.php | Core.init | public function init() {
parent::init();
// Foxslider Alias
Yii::setAlias( 'foxslider', dirname( dirname( dirname( __DIR__ ) ) ) );
// Register components and objects
$this->registerComponents();
} | php | public function init() {
parent::init();
// Foxslider Alias
Yii::setAlias( 'foxslider', dirname( dirname( dirname( __DIR__ ) ) ) );
// Register components and objects
$this->registerComponents();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"// Foxslider Alias",
"Yii",
"::",
"setAlias",
"(",
"'foxslider'",
",",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"__DIR__",
")",
")",
")",
")",
";",
"// Register components and objects",
"$",
"this",
"->",
"registerComponents",
"(",
")",
";",
"}"
] | Initialize the services. | [
"Initialize",
"the",
"services",
"."
] | 843f723ebb512ab833feff581beb9714df4e41bd | https://github.com/foxslider/cmg-plugin/blob/843f723ebb512ab833feff581beb9714df4e41bd/common/components/Core.php#L36-L45 | train |
FusePump/cli.php | lib/FusePump/Cli/Inputs.php | Inputs.checkInputs | private function checkInputs($short, $long)
{
$key = array_search($short, $this->inputs);
if ($key === false) {
$key = array_search($long, $this->inputs);
if ($key === false) {
return false;
} else {
return $key;
}
} else {
return $key;
}
} | php | private function checkInputs($short, $long)
{
$key = array_search($short, $this->inputs);
if ($key === false) {
$key = array_search($long, $this->inputs);
if ($key === false) {
return false;
} else {
return $key;
}
} else {
return $key;
}
} | [
"private",
"function",
"checkInputs",
"(",
"$",
"short",
",",
"$",
"long",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"short",
",",
"$",
"this",
"->",
"inputs",
")",
";",
"if",
"(",
"$",
"key",
"===",
"false",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"long",
",",
"$",
"this",
"->",
"inputs",
")",
";",
"if",
"(",
"$",
"key",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"key",
";",
"}",
"}"
] | Check input for flag
@param string $short
@param string $long
@return bool|mixed | [
"Check",
"input",
"for",
"flag"
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Inputs.php#L199-L212 | train |
FusePump/cli.php | lib/FusePump/Cli/Inputs.php | Inputs.checkRequired | private function checkRequired()
{
// Loop through all params
foreach ($this->params as $param) {
if (array_key_exists('required', $param) && $param['required'] == true) {
if (!array_key_exists($param['name'], $this->pinputs)) {
throw new \Exception('Parameter "' . $param['name'] . '" is required');
}
}
}
// Loop through all options
foreach ($this->options as $key => $option) {
// if option is required
if (array_key_exists('required', $option) && $option['required'] == true) {
// check that it is defined in pinputs
if ($this->pinputs[$option['short']] == false) {
throw new \Exception('Option "' . $option['help'] . '" is required');
}
}
}
} | php | private function checkRequired()
{
// Loop through all params
foreach ($this->params as $param) {
if (array_key_exists('required', $param) && $param['required'] == true) {
if (!array_key_exists($param['name'], $this->pinputs)) {
throw new \Exception('Parameter "' . $param['name'] . '" is required');
}
}
}
// Loop through all options
foreach ($this->options as $key => $option) {
// if option is required
if (array_key_exists('required', $option) && $option['required'] == true) {
// check that it is defined in pinputs
if ($this->pinputs[$option['short']] == false) {
throw new \Exception('Option "' . $option['help'] . '" is required');
}
}
}
} | [
"private",
"function",
"checkRequired",
"(",
")",
"{",
"// Loop through all params",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'required'",
",",
"$",
"param",
")",
"&&",
"$",
"param",
"[",
"'required'",
"]",
"==",
"true",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"param",
"[",
"'name'",
"]",
",",
"$",
"this",
"->",
"pinputs",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Parameter \"'",
".",
"$",
"param",
"[",
"'name'",
"]",
".",
"'\" is required'",
")",
";",
"}",
"}",
"}",
"// Loop through all options",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"key",
"=>",
"$",
"option",
")",
"{",
"// if option is required",
"if",
"(",
"array_key_exists",
"(",
"'required'",
",",
"$",
"option",
")",
"&&",
"$",
"option",
"[",
"'required'",
"]",
"==",
"true",
")",
"{",
"// check that it is defined in pinputs",
"if",
"(",
"$",
"this",
"->",
"pinputs",
"[",
"$",
"option",
"[",
"'short'",
"]",
"]",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Option \"'",
".",
"$",
"option",
"[",
"'help'",
"]",
".",
"'\" is required'",
")",
";",
"}",
"}",
"}",
"}"
] | Check required options
If a required option is not provided then throw and exception
@throws \Exception if required param or option is not present | [
"Check",
"required",
"options",
"If",
"a",
"required",
"option",
"is",
"not",
"provided",
"then",
"throw",
"and",
"exception"
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Inputs.php#L220-L242 | train |
FusePump/cli.php | lib/FusePump/Cli/Inputs.php | Inputs.confirm | public static function confirm($msg)
{
echo $msg;
$input = trim(fgets(STDIN));
if (strtolower($input) == 'y' || strtolower($input) == 'yes') {
return true;
} else {
return false;
}
} | php | public static function confirm($msg)
{
echo $msg;
$input = trim(fgets(STDIN));
if (strtolower($input) == 'y' || strtolower($input) == 'yes') {
return true;
} else {
return false;
}
} | [
"public",
"static",
"function",
"confirm",
"(",
"$",
"msg",
")",
"{",
"echo",
"$",
"msg",
";",
"$",
"input",
"=",
"trim",
"(",
"fgets",
"(",
"STDIN",
")",
")",
";",
"if",
"(",
"strtolower",
"(",
"$",
"input",
")",
"==",
"'y'",
"||",
"strtolower",
"(",
"$",
"input",
")",
"==",
"'yes'",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Add a confirmation
@param string $msg - question to ask
@static
@return bool - true if yes, false if anything else | [
"Add",
"a",
"confirmation"
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Inputs.php#L362-L372 | train |
FusePump/cli.php | lib/FusePump/Cli/Inputs.php | Inputs.outputHelp | public function outputHelp($short = false)
{
echo "Usage: " . $this->getName() . " ";
if (!empty($this->params)) {
foreach ($this->params as $param) {
if ($param['required'] == true) {
echo '<' . $param['name'] . '> ';
} else {
echo '[' . $param['name'] . '] ';
}
}
}
echo "[options]";
if (!$short) {
echo PHP_EOL . PHP_EOL;
if (!empty($this->params)) {
echo "Parameters:" . PHP_EOL;
foreach ($this->params as $param) {
echo "\t" . $param['help'] . PHP_EOL;
}
echo PHP_EOL;
}
echo "Options:" . PHP_EOL;
foreach ($this->options as $option) {
$output = "\t" . $option['help'];
if (array_key_exists('required', $option) && $option['required'] == true) {
$output .= " [required]";
}
$output .= PHP_EOL;
echo $output;
}
echo "\t" . $this->helpOption . PHP_EOL;
} else {
echo PHP_EOL;
}
} | php | public function outputHelp($short = false)
{
echo "Usage: " . $this->getName() . " ";
if (!empty($this->params)) {
foreach ($this->params as $param) {
if ($param['required'] == true) {
echo '<' . $param['name'] . '> ';
} else {
echo '[' . $param['name'] . '] ';
}
}
}
echo "[options]";
if (!$short) {
echo PHP_EOL . PHP_EOL;
if (!empty($this->params)) {
echo "Parameters:" . PHP_EOL;
foreach ($this->params as $param) {
echo "\t" . $param['help'] . PHP_EOL;
}
echo PHP_EOL;
}
echo "Options:" . PHP_EOL;
foreach ($this->options as $option) {
$output = "\t" . $option['help'];
if (array_key_exists('required', $option) && $option['required'] == true) {
$output .= " [required]";
}
$output .= PHP_EOL;
echo $output;
}
echo "\t" . $this->helpOption . PHP_EOL;
} else {
echo PHP_EOL;
}
} | [
"public",
"function",
"outputHelp",
"(",
"$",
"short",
"=",
"false",
")",
"{",
"echo",
"\"Usage: \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\" \"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"param",
"[",
"'required'",
"]",
"==",
"true",
")",
"{",
"echo",
"'<'",
".",
"$",
"param",
"[",
"'name'",
"]",
".",
"'> '",
";",
"}",
"else",
"{",
"echo",
"'['",
".",
"$",
"param",
"[",
"'name'",
"]",
".",
"'] '",
";",
"}",
"}",
"}",
"echo",
"\"[options]\"",
";",
"if",
"(",
"!",
"$",
"short",
")",
"{",
"echo",
"PHP_EOL",
".",
"PHP_EOL",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
")",
")",
"{",
"echo",
"\"Parameters:\"",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"param",
")",
"{",
"echo",
"\"\\t\"",
".",
"$",
"param",
"[",
"'help'",
"]",
".",
"PHP_EOL",
";",
"}",
"echo",
"PHP_EOL",
";",
"}",
"echo",
"\"Options:\"",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"output",
"=",
"\"\\t\"",
".",
"$",
"option",
"[",
"'help'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'required'",
",",
"$",
"option",
")",
"&&",
"$",
"option",
"[",
"'required'",
"]",
"==",
"true",
")",
"{",
"$",
"output",
".=",
"\" [required]\"",
";",
"}",
"$",
"output",
".=",
"PHP_EOL",
";",
"echo",
"$",
"output",
";",
"}",
"echo",
"\"\\t\"",
".",
"$",
"this",
"->",
"helpOption",
".",
"PHP_EOL",
";",
"}",
"else",
"{",
"echo",
"PHP_EOL",
";",
"}",
"}"
] | Output help text
Format:
Usage: {{name}} <param> [options]
Options:
-p, --peppers Add peppers
-c, --cheese [type] Add a cheese
-m, --mayo Add mayonaise
-h, --help Output usage information
@param bool $short - if true, short output text | [
"Output",
"help",
"text"
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Inputs.php#L389-L427 | train |
Wedeto/Log | src/Writer/FileWriter.php | FileWriter.writeLine | private function writeLine(string $str)
{
$now = time();
if ($this->file && $this->file_opened < $now - $this->reopen_interval)
{
// Close the file after a set interval
fclose($this->file);
$this->file = null;
}
if (!$this->file)
{
touch($this->filename);
try
{
Hook::execute("Wedeto.IO.FileCreated", ['path' => $this->filename]);
}
// @codeCoverageIgnoreStart
// Ignore recursion: if and error occurs in a hook it may end up
// calling the file writer again, resulting in a loop.
catch (RecursionException $e)
{}
// @codeCoverageIgnoreEnd
$this->file = fopen($this->filename, 'a');
$this->file_opened = time();
}
if ($this->file)
fwrite($this->file, $str . "\n");
} | php | private function writeLine(string $str)
{
$now = time();
if ($this->file && $this->file_opened < $now - $this->reopen_interval)
{
// Close the file after a set interval
fclose($this->file);
$this->file = null;
}
if (!$this->file)
{
touch($this->filename);
try
{
Hook::execute("Wedeto.IO.FileCreated", ['path' => $this->filename]);
}
// @codeCoverageIgnoreStart
// Ignore recursion: if and error occurs in a hook it may end up
// calling the file writer again, resulting in a loop.
catch (RecursionException $e)
{}
// @codeCoverageIgnoreEnd
$this->file = fopen($this->filename, 'a');
$this->file_opened = time();
}
if ($this->file)
fwrite($this->file, $str . "\n");
} | [
"private",
"function",
"writeLine",
"(",
"string",
"$",
"str",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"file",
"&&",
"$",
"this",
"->",
"file_opened",
"<",
"$",
"now",
"-",
"$",
"this",
"->",
"reopen_interval",
")",
"{",
"// Close the file after a set interval",
"fclose",
"(",
"$",
"this",
"->",
"file",
")",
";",
"$",
"this",
"->",
"file",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"file",
")",
"{",
"touch",
"(",
"$",
"this",
"->",
"filename",
")",
";",
"try",
"{",
"Hook",
"::",
"execute",
"(",
"\"Wedeto.IO.FileCreated\"",
",",
"[",
"'path'",
"=>",
"$",
"this",
"->",
"filename",
"]",
")",
";",
"}",
"// @codeCoverageIgnoreStart",
"// Ignore recursion: if and error occurs in a hook it may end up",
"// calling the file writer again, resulting in a loop.",
"catch",
"(",
"RecursionException",
"$",
"e",
")",
"{",
"}",
"// @codeCoverageIgnoreEnd",
"$",
"this",
"->",
"file",
"=",
"fopen",
"(",
"$",
"this",
"->",
"filename",
",",
"'a'",
")",
";",
"$",
"this",
"->",
"file_opened",
"=",
"time",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"fwrite",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"str",
".",
"\"\\n\"",
")",
";",
"}"
] | Write a line to the log file
@param string $str The line to write | [
"Write",
"a",
"line",
"to",
"the",
"log",
"file"
] | 88252c5052089fdcc5dae466d1ad5889bb2b735f | https://github.com/Wedeto/Log/blob/88252c5052089fdcc5dae466d1ad5889bb2b735f/src/Writer/FileWriter.php#L88-L119 | train |
irfantoor/database | src/Database/SQLite.php | SQLite.insertOrUpdate | public function insertOrUpdate($tableORq, $data)
{
if (is_string($tableORq)) {
$this->defaults['table'] = $tableORq;
$tableORq = [];
}
extract($this->defaults);
extract($tableORq);
if (!$table)
throw new Exception("table [$tabel] not defined", 1);
$sql = 'INSERT OR REPLACE INTO ' . $table . ' ' .
'(' . implode(', ', array_keys($data)) . ') ' .
'VALUES ( :' . implode(', :', array_keys($data)) . ');';
return $this->query($sql, $data);
} | php | public function insertOrUpdate($tableORq, $data)
{
if (is_string($tableORq)) {
$this->defaults['table'] = $tableORq;
$tableORq = [];
}
extract($this->defaults);
extract($tableORq);
if (!$table)
throw new Exception("table [$tabel] not defined", 1);
$sql = 'INSERT OR REPLACE INTO ' . $table . ' ' .
'(' . implode(', ', array_keys($data)) . ') ' .
'VALUES ( :' . implode(', :', array_keys($data)) . ');';
return $this->query($sql, $data);
} | [
"public",
"function",
"insertOrUpdate",
"(",
"$",
"tableORq",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"tableORq",
")",
")",
"{",
"$",
"this",
"->",
"defaults",
"[",
"'table'",
"]",
"=",
"$",
"tableORq",
";",
"$",
"tableORq",
"=",
"[",
"]",
";",
"}",
"extract",
"(",
"$",
"this",
"->",
"defaults",
")",
";",
"extract",
"(",
"$",
"tableORq",
")",
";",
"if",
"(",
"!",
"$",
"table",
")",
"throw",
"new",
"Exception",
"(",
"\"table [$tabel] not defined\"",
",",
"1",
")",
";",
"$",
"sql",
"=",
"'INSERT OR REPLACE INTO '",
".",
"$",
"table",
".",
"' '",
".",
"'('",
".",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
".",
"') '",
".",
"'VALUES ( :'",
".",
"implode",
"(",
"', :'",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
".",
"');'",
";",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"sql",
",",
"$",
"data",
")",
";",
"}"
] | inserts or update a record
@param array $record | [
"inserts",
"or",
"update",
"a",
"record"
] | 0e01e2f265b95f17b1a888137c4364714c367128 | https://github.com/irfantoor/database/blob/0e01e2f265b95f17b1a888137c4364714c367128/src/Database/SQLite.php#L57-L74 | train |
agentmedia/phine-builtin | src/BuiltIn/Modules/Frontend/HtmlCode.php | HtmlCode.Init | protected function Init()
{
$htmlCode = ContentHtmlCode::Schema()->ByContent($this->content);
$this->code= $htmlCode->GetCode();
return parent::Init();
} | php | protected function Init()
{
$htmlCode = ContentHtmlCode::Schema()->ByContent($this->content);
$this->code= $htmlCode->GetCode();
return parent::Init();
} | [
"protected",
"function",
"Init",
"(",
")",
"{",
"$",
"htmlCode",
"=",
"ContentHtmlCode",
"::",
"Schema",
"(",
")",
"->",
"ByContent",
"(",
"$",
"this",
"->",
"content",
")",
";",
"$",
"this",
"->",
"code",
"=",
"$",
"htmlCode",
"->",
"GetCode",
"(",
")",
";",
"return",
"parent",
"::",
"Init",
"(",
")",
";",
"}"
] | Initializes the html code frontend module
@return boolean | [
"Initializes",
"the",
"html",
"code",
"frontend",
"module"
] | 4dd05bc406a71e997bd4eaa16b12e23dbe62a456 | https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Frontend/HtmlCode.php#L23-L28 | train |
agentmedia/phine-builtin | src/BuiltIn/Modules/Frontend/HtmlCode.php | HtmlCode.BackendName | public function BackendName()
{
$result = 'code';
if (!$this->content)
{
return $result;
}
$htmlCode = ContentHtmlCode::Schema()->ByContent($this->content);
$code = Text::Shorten($htmlCode->GetCode());
if ($code)
{
$result .= ' - ' . $code;
}
return $result;
} | php | public function BackendName()
{
$result = 'code';
if (!$this->content)
{
return $result;
}
$htmlCode = ContentHtmlCode::Schema()->ByContent($this->content);
$code = Text::Shorten($htmlCode->GetCode());
if ($code)
{
$result .= ' - ' . $code;
}
return $result;
} | [
"public",
"function",
"BackendName",
"(",
")",
"{",
"$",
"result",
"=",
"'code'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"content",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"htmlCode",
"=",
"ContentHtmlCode",
"::",
"Schema",
"(",
")",
"->",
"ByContent",
"(",
"$",
"this",
"->",
"content",
")",
";",
"$",
"code",
"=",
"Text",
"::",
"Shorten",
"(",
"$",
"htmlCode",
"->",
"GetCode",
"(",
")",
")",
";",
"if",
"(",
"$",
"code",
")",
"{",
"$",
"result",
".=",
"' - '",
".",
"$",
"code",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | The backend name for the code
@return string | [
"The",
"backend",
"name",
"for",
"the",
"code"
] | 4dd05bc406a71e997bd4eaa16b12e23dbe62a456 | https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Frontend/HtmlCode.php#L52-L66 | train |
wb-crowdfusion/crowdfusion | system/core/classes/mvc/filters/PermissionFilterer.php | PermissionFilterer.pass | public function pass()
{
$action = $this->getParameter('action');
return $this->Permissions->checkPermission($action, $this->getLocal('SiteSlug'));
} | php | public function pass()
{
$action = $this->getParameter('action');
return $this->Permissions->checkPermission($action, $this->getLocal('SiteSlug'));
} | [
"public",
"function",
"pass",
"(",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'action'",
")",
";",
"return",
"$",
"this",
"->",
"Permissions",
"->",
"checkPermission",
"(",
"$",
"action",
",",
"$",
"this",
"->",
"getLocal",
"(",
"'SiteSlug'",
")",
")",
";",
"}"
] | Checks if the specified action is granted to the current user
Expected Params:
action string The action string to check
@return boolean True if the user is allowed access | [
"Checks",
"if",
"the",
"specified",
"action",
"is",
"granted",
"to",
"the",
"current",
"user"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/filters/PermissionFilterer.php#L60-L65 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.required | public function required($input, $key, $lang)
{
$lang = $this->custom('required', $lang);
if (empty($input[$key])) {
return str_replace(':field', $key, $lang);
}
} | php | public function required($input, $key, $lang)
{
$lang = $this->custom('required', $lang);
if (empty($input[$key])) {
return str_replace(':field', $key, $lang);
}
} | [
"public",
"function",
"required",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'required'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"str_replace",
"(",
"':field'",
",",
"$",
"key",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses a required validation field.
@param array $input - Input to be validated
@param string $key - Validation key
@param string $lang - Language string
@return string | [
"Parses",
"a",
"required",
"validation",
"field",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L57-L63 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.match | public function match($input, $key, $match, $lang)
{
$lang = $this->custom('match', $lang);
if ($input[$key] !== $input[$match]) {
return preg_replace_callback('/(\:field)(.*)(\:match)/i',
function ($m) use ($key, $match) {
return $key.$m[2].$match;
}, $lang);
}
} | php | public function match($input, $key, $match, $lang)
{
$lang = $this->custom('match', $lang);
if ($input[$key] !== $input[$match]) {
return preg_replace_callback('/(\:field)(.*)(\:match)/i',
function ($m) use ($key, $match) {
return $key.$m[2].$match;
}, $lang);
}
} | [
"public",
"function",
"match",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"match",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'match'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
"!==",
"$",
"input",
"[",
"$",
"match",
"]",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/(\\:field)(.*)(\\:match)/i'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"key",
",",
"$",
"match",
")",
"{",
"return",
"$",
"key",
".",
"$",
"m",
"[",
"2",
"]",
".",
"$",
"match",
";",
"}",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses a match validation field.
@param array $input - Input to be validated
@param string $key - Validation key
@param string $match - The option looking to be matched up with $key
@param string $lang - Language string
@return string | [
"Parses",
"a",
"match",
"validation",
"field",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L75-L84 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.email | public function email($input, $key, $lang)
{
$lang = $this->custom('email', $lang);
if (filter_var($input[$key], FILTER_VALIDATE_EMAIL) === false) {
return str_replace(':field', $key, $lang);
}
} | php | public function email($input, $key, $lang)
{
$lang = $this->custom('email', $lang);
if (filter_var($input[$key], FILTER_VALIDATE_EMAIL) === false) {
return str_replace(':field', $key, $lang);
}
} | [
"public",
"function",
"email",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'email'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"filter_var",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
",",
"FILTER_VALIDATE_EMAIL",
")",
"===",
"false",
")",
"{",
"return",
"str_replace",
"(",
"':field'",
",",
"$",
"key",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses an email validation field.
@param array $input - Input to be validated
@param string $key - Validation key
@param string $lang - Language string
@return string | [
"Parses",
"an",
"email",
"validation",
"field",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L95-L101 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.url | public function url($input, $key, $lang)
{
$lang = $this->custom('url', $lang);
if (filter_var($input[$key], FILTER_VALIDATE_URL) === false) {
return str_replace(':field', $key, $lang);
}
} | php | public function url($input, $key, $lang)
{
$lang = $this->custom('url', $lang);
if (filter_var($input[$key], FILTER_VALIDATE_URL) === false) {
return str_replace(':field', $key, $lang);
}
} | [
"public",
"function",
"url",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'url'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"filter_var",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
",",
"FILTER_VALIDATE_URL",
")",
"===",
"false",
")",
"{",
"return",
"str_replace",
"(",
"':field'",
",",
"$",
"key",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses URL validation field.
@param array $input - Input to be validated
@param string $key - Validation key
@param string $lang - Language string
@return string | [
"Parses",
"URL",
"validation",
"field",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L112-L118 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.min | public function min($input, $key, $min, $lang)
{
$lang = $this->custom('min', $lang);
if (strlen($input[$key]) < $min) {
return preg_replace_callback('/(:field)(.*)(\:num)/i',
function ($m) use ($key, $min) {
return $key.$m[2].$min;
}, $lang);
}
} | php | public function min($input, $key, $min, $lang)
{
$lang = $this->custom('min', $lang);
if (strlen($input[$key]) < $min) {
return preg_replace_callback('/(:field)(.*)(\:num)/i',
function ($m) use ($key, $min) {
return $key.$m[2].$min;
}, $lang);
}
} | [
"public",
"function",
"min",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"min",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'min'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
")",
"<",
"$",
"min",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/(:field)(.*)(\\:num)/i'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"key",
",",
"$",
"min",
")",
"{",
"return",
"$",
"key",
".",
"$",
"m",
"[",
"2",
"]",
".",
"$",
"min",
";",
"}",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses a set minimum number of characters.
@param array $input - Language string
@param string $key - Validation Key
@param int $min - The set minimum
@param string $lang - Language string
@return mixed | [
"Parses",
"a",
"set",
"minimum",
"number",
"of",
"characters",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L130-L139 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.max | public function max($input, $key, $max, $lang)
{
$lang = $this->custom('max', $lang);
if (strlen($input[$key]) > $max) {
return preg_replace_callback('/(:field)(.*)(\:num)/i',
function ($m) use ($key, $max) {
return $key.$m[2].$max;
}, $lang);
}
} | php | public function max($input, $key, $max, $lang)
{
$lang = $this->custom('max', $lang);
if (strlen($input[$key]) > $max) {
return preg_replace_callback('/(:field)(.*)(\:num)/i',
function ($m) use ($key, $max) {
return $key.$m[2].$max;
}, $lang);
}
} | [
"public",
"function",
"max",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"max",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'max'",
",",
"$",
"lang",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"input",
"[",
"$",
"key",
"]",
")",
">",
"$",
"max",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/(:field)(.*)(\\:num)/i'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"key",
",",
"$",
"max",
")",
"{",
"return",
"$",
"key",
".",
"$",
"m",
"[",
"2",
"]",
".",
"$",
"max",
";",
"}",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Parses a set maximum number of characters.
@param $input - Language string
@param string $key - Validation Key
@param int $max - The set maximum
@param string $lang - Language string
@return mixed | [
"Parses",
"a",
"set",
"maximum",
"number",
"of",
"characters",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L151-L160 | train |
ScaraMVC/Framework | src/Scara/Validation/ValidationParser.php | ValidationParser.from | public function from($input, $key, $rule, $lang)
{
$lang = $this->custom('from', $lang);
$db = new Database();
$cap = $db->getCapsule();
$exp = explode(':', $rule);
$table = $cap->table($exp[1]);
if ($table->where($exp[2], '=', $input[$key])->count() == 0) {
$tn = $exp[1];
return preg_replace_callback('/(:field)(.*)(\:from)/i',
function ($m) use ($input, $key, $tn) {
return $input[$key].$m[2].$tn;
}, $lang);
}
} | php | public function from($input, $key, $rule, $lang)
{
$lang = $this->custom('from', $lang);
$db = new Database();
$cap = $db->getCapsule();
$exp = explode(':', $rule);
$table = $cap->table($exp[1]);
if ($table->where($exp[2], '=', $input[$key])->count() == 0) {
$tn = $exp[1];
return preg_replace_callback('/(:field)(.*)(\:from)/i',
function ($m) use ($input, $key, $tn) {
return $input[$key].$m[2].$tn;
}, $lang);
}
} | [
"public",
"function",
"from",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"rule",
",",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"custom",
"(",
"'from'",
",",
"$",
"lang",
")",
";",
"$",
"db",
"=",
"new",
"Database",
"(",
")",
";",
"$",
"cap",
"=",
"$",
"db",
"->",
"getCapsule",
"(",
")",
";",
"$",
"exp",
"=",
"explode",
"(",
"':'",
",",
"$",
"rule",
")",
";",
"$",
"table",
"=",
"$",
"cap",
"->",
"table",
"(",
"$",
"exp",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"table",
"->",
"where",
"(",
"$",
"exp",
"[",
"2",
"]",
",",
"'='",
",",
"$",
"input",
"[",
"$",
"key",
"]",
")",
"->",
"count",
"(",
")",
"==",
"0",
")",
"{",
"$",
"tn",
"=",
"$",
"exp",
"[",
"1",
"]",
";",
"return",
"preg_replace_callback",
"(",
"'/(:field)(.*)(\\:from)/i'",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"input",
",",
"$",
"key",
",",
"$",
"tn",
")",
"{",
"return",
"$",
"input",
"[",
"$",
"key",
"]",
".",
"$",
"m",
"[",
"2",
"]",
".",
"$",
"tn",
";",
"}",
",",
"$",
"lang",
")",
";",
"}",
"}"
] | Checks if a given field exists in given database table.
@param $input - Language string
@param string $key - Validation Key
@param array $rule - The entire rule (Needed for multi-parsing)
@param string $lang - Language string
@return mixed | [
"Checks",
"if",
"a",
"given",
"field",
"exists",
"in",
"given",
"database",
"table",
"."
] | 199b08b45fadf5dae14ac4732af03b36e15bbef2 | https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Validation/ValidationParser.php#L172-L189 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setQueryController | protected function setQueryController($namespace, $crud_type = 'Read')
{
$options = $this->setQueryOptions($crud_type);
try {
$this->query = $this->resource->get('query://' . $namespace, $options);
} catch (Exception $e) {
throw new RuntimeException($e->getMessage());
}
return $this;
} | php | protected function setQueryController($namespace, $crud_type = 'Read')
{
$options = $this->setQueryOptions($crud_type);
try {
$this->query = $this->resource->get('query://' . $namespace, $options);
} catch (Exception $e) {
throw new RuntimeException($e->getMessage());
}
return $this;
} | [
"protected",
"function",
"setQueryController",
"(",
"$",
"namespace",
",",
"$",
"crud_type",
"=",
"'Read'",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"setQueryOptions",
"(",
"$",
"crud_type",
")",
";",
"try",
"{",
"$",
"this",
"->",
"query",
"=",
"$",
"this",
"->",
"resource",
"->",
"get",
"(",
"'query://'",
".",
"$",
"namespace",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set Query Controller
@param string $namespace
@param string $crud_type
@return $this
@since 1.0.0
@throws \CommonApi\Exception\RuntimeException | [
"Set",
"Query",
"Controller"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L85-L97 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setQueryOptions | protected function setQueryOptions($crud_type = 'Read')
{
$options = array();
$crud_type = ucfirst(strtolower($crud_type));
if ($crud_type === 'Create'
|| $crud_type === 'Read'
|| $crud_type === 'Update'
|| $crud_type === 'Delete'
) {
} else {
$crud_type = 'Read';
}
$options['crud_type'] = $crud_type;
$options['runtime_data'] = $this->runtime_data;
if (isset($this->plugin_data)) {
$options['plugin_data'] = $this->plugin_data;
}
return $options;
} | php | protected function setQueryOptions($crud_type = 'Read')
{
$options = array();
$crud_type = ucfirst(strtolower($crud_type));
if ($crud_type === 'Create'
|| $crud_type === 'Read'
|| $crud_type === 'Update'
|| $crud_type === 'Delete'
) {
} else {
$crud_type = 'Read';
}
$options['crud_type'] = $crud_type;
$options['runtime_data'] = $this->runtime_data;
if (isset($this->plugin_data)) {
$options['plugin_data'] = $this->plugin_data;
}
return $options;
} | [
"protected",
"function",
"setQueryOptions",
"(",
"$",
"crud_type",
"=",
"'Read'",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"crud_type",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"crud_type",
")",
")",
";",
"if",
"(",
"$",
"crud_type",
"===",
"'Create'",
"||",
"$",
"crud_type",
"===",
"'Read'",
"||",
"$",
"crud_type",
"===",
"'Update'",
"||",
"$",
"crud_type",
"===",
"'Delete'",
")",
"{",
"}",
"else",
"{",
"$",
"crud_type",
"=",
"'Read'",
";",
"}",
"$",
"options",
"[",
"'crud_type'",
"]",
"=",
"$",
"crud_type",
";",
"$",
"options",
"[",
"'runtime_data'",
"]",
"=",
"$",
"this",
"->",
"runtime_data",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"plugin_data",
")",
")",
"{",
"$",
"options",
"[",
"'plugin_data'",
"]",
"=",
"$",
"this",
"->",
"plugin_data",
";",
"}",
"return",
"$",
"options",
";",
"}"
] | Set Query Options
@param string $crud_type
@return array
@since 1.0.0 | [
"Set",
"Query",
"Options"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L107-L129 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setQueryControllerDefaults | protected function setQueryControllerDefaults(
$process_events = 0,
$query_object = 'item',
$get_customfields = 0,
$use_special_joins = 0,
$use_pagination = 0,
$check_view_level_access = 0,
$get_item_children = 0
) {
$this->query->setModelRegistry('process_events', $process_events);
$this->query->setModelRegistry('query_object', $query_object);
$this->query->setModelRegistry('get_customfields', $get_customfields);
$this->query->setModelRegistry('use_special_joins', $use_special_joins);
$this->query->setModelRegistry('use_pagination', $use_pagination);
$this->query->setModelRegistry('check_view_level_access', $check_view_level_access);
$this->query->setModelRegistry('get_item_children', $get_item_children);
return $this;
} | php | protected function setQueryControllerDefaults(
$process_events = 0,
$query_object = 'item',
$get_customfields = 0,
$use_special_joins = 0,
$use_pagination = 0,
$check_view_level_access = 0,
$get_item_children = 0
) {
$this->query->setModelRegistry('process_events', $process_events);
$this->query->setModelRegistry('query_object', $query_object);
$this->query->setModelRegistry('get_customfields', $get_customfields);
$this->query->setModelRegistry('use_special_joins', $use_special_joins);
$this->query->setModelRegistry('use_pagination', $use_pagination);
$this->query->setModelRegistry('check_view_level_access', $check_view_level_access);
$this->query->setModelRegistry('get_item_children', $get_item_children);
return $this;
} | [
"protected",
"function",
"setQueryControllerDefaults",
"(",
"$",
"process_events",
"=",
"0",
",",
"$",
"query_object",
"=",
"'item'",
",",
"$",
"get_customfields",
"=",
"0",
",",
"$",
"use_special_joins",
"=",
"0",
",",
"$",
"use_pagination",
"=",
"0",
",",
"$",
"check_view_level_access",
"=",
"0",
",",
"$",
"get_item_children",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'process_events'",
",",
"$",
"process_events",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'query_object'",
",",
"$",
"query_object",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'get_customfields'",
",",
"$",
"get_customfields",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'use_special_joins'",
",",
"$",
"use_special_joins",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'use_pagination'",
",",
"$",
"use_pagination",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'check_view_level_access'",
",",
"$",
"check_view_level_access",
")",
";",
"$",
"this",
"->",
"query",
"->",
"setModelRegistry",
"(",
"'get_item_children'",
",",
"$",
"get_item_children",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set Query Controller Default Values
@param integer $process_events
@param string $query_object
@param integer $get_customfields
@param integer $use_special_joins
@param integer $use_pagination
@param integer $check_view_level_access
@return $this
@since 1.0.0 | [
"Set",
"Query",
"Controller",
"Default",
"Values"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L144-L162 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setModelRegistryCriteria | protected function setModelRegistryCriteria()
{
$prefix = $this->query->getModelRegistry('primary_prefix', 'a');
$this->setModelRegistryCatalogTypeIdCriteria($prefix);
$this->setModelRegistryExtensionInstanceIdCriteria($prefix);
$this->setModelRegistryMenuIdCriteria($prefix);
$this->setModelRegistryStatusCriteria($prefix);
return $this;
} | php | protected function setModelRegistryCriteria()
{
$prefix = $this->query->getModelRegistry('primary_prefix', 'a');
$this->setModelRegistryCatalogTypeIdCriteria($prefix);
$this->setModelRegistryExtensionInstanceIdCriteria($prefix);
$this->setModelRegistryMenuIdCriteria($prefix);
$this->setModelRegistryStatusCriteria($prefix);
return $this;
} | [
"protected",
"function",
"setModelRegistryCriteria",
"(",
")",
"{",
"$",
"prefix",
"=",
"$",
"this",
"->",
"query",
"->",
"getModelRegistry",
"(",
"'primary_prefix'",
",",
"'a'",
")",
";",
"$",
"this",
"->",
"setModelRegistryCatalogTypeIdCriteria",
"(",
"$",
"prefix",
")",
";",
"$",
"this",
"->",
"setModelRegistryExtensionInstanceIdCriteria",
"(",
"$",
"prefix",
")",
";",
"$",
"this",
"->",
"setModelRegistryMenuIdCriteria",
"(",
"$",
"prefix",
")",
";",
"$",
"this",
"->",
"setModelRegistryStatusCriteria",
"(",
"$",
"prefix",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set Standard Model Registry Criteria
@return $this
@since 1.0.0 | [
"Set",
"Standard",
"Model",
"Registry",
"Criteria"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L210-L220 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setStandardFields | protected function setStandardFields($data, array $model_registry = array())
{
$fields = $model_registry['fields'];
$this->customfieldgroups = $model_registry['customfieldgroups'];
$base = $this->processQueryFields($data, $fields);
return $this->sortObject($base);
} | php | protected function setStandardFields($data, array $model_registry = array())
{
$fields = $model_registry['fields'];
$this->customfieldgroups = $model_registry['customfieldgroups'];
$base = $this->processQueryFields($data, $fields);
return $this->sortObject($base);
} | [
"protected",
"function",
"setStandardFields",
"(",
"$",
"data",
",",
"array",
"$",
"model_registry",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fields",
"=",
"$",
"model_registry",
"[",
"'fields'",
"]",
";",
"$",
"this",
"->",
"customfieldgroups",
"=",
"$",
"model_registry",
"[",
"'customfieldgroups'",
"]",
";",
"$",
"base",
"=",
"$",
"this",
"->",
"processQueryFields",
"(",
"$",
"data",
",",
"$",
"fields",
")",
";",
"return",
"$",
"this",
"->",
"sortObject",
"(",
"$",
"base",
")",
";",
"}"
] | Set Standard Fields
@param object $data
@param array $model_registry
@return stdClass
@since 1.0.0 | [
"Set",
"Standard",
"Fields"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L312-L321 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setCustomFields | protected function setCustomFields($base, $data, array $model_registry = array())
{
if (count($this->customfieldgroups) > 0) {
} else {
return $base;
}
foreach ($this->customfieldgroups as $group) {
$group_data = $this->processQueryFields(json_decode($data->$group), $model_registry [$group]);
$base->$group = $this->sortObject($group_data);
}
return $base;
} | php | protected function setCustomFields($base, $data, array $model_registry = array())
{
if (count($this->customfieldgroups) > 0) {
} else {
return $base;
}
foreach ($this->customfieldgroups as $group) {
$group_data = $this->processQueryFields(json_decode($data->$group), $model_registry [$group]);
$base->$group = $this->sortObject($group_data);
}
return $base;
} | [
"protected",
"function",
"setCustomFields",
"(",
"$",
"base",
",",
"$",
"data",
",",
"array",
"$",
"model_registry",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"customfieldgroups",
")",
">",
"0",
")",
"{",
"}",
"else",
"{",
"return",
"$",
"base",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"customfieldgroups",
"as",
"$",
"group",
")",
"{",
"$",
"group_data",
"=",
"$",
"this",
"->",
"processQueryFields",
"(",
"json_decode",
"(",
"$",
"data",
"->",
"$",
"group",
")",
",",
"$",
"model_registry",
"[",
"$",
"group",
"]",
")",
";",
"$",
"base",
"->",
"$",
"group",
"=",
"$",
"this",
"->",
"sortObject",
"(",
"$",
"group_data",
")",
";",
"}",
"return",
"$",
"base",
";",
"}"
] | Set Custom Fields
@param object $base
@param object $data
@param array $model_registry
@return object
@since 1.0.0 | [
"Set",
"Custom",
"Fields"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L333-L346 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.verifyFieldDefined | protected function verifyFieldDefined($key, $field)
{
if (count($field) === 0) {
throw new RuntimeException(
get_class($this)
. ' Field: ' . $key . ' not defined '
. ' in QueryUsageTrait::processQueryFields.'
);
}
return $this;
} | php | protected function verifyFieldDefined($key, $field)
{
if (count($field) === 0) {
throw new RuntimeException(
get_class($this)
. ' Field: ' . $key . ' not defined '
. ' in QueryUsageTrait::processQueryFields.'
);
}
return $this;
} | [
"protected",
"function",
"verifyFieldDefined",
"(",
"$",
"key",
",",
"$",
"field",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"field",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"get_class",
"(",
"$",
"this",
")",
".",
"' Field: '",
".",
"$",
"key",
".",
"' not defined '",
".",
"' in QueryUsageTrait::processQueryFields.'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Verify Field is Defined
@param string $key
@param array $fields
@return $this
@since 1.0.0
@throws \CommonApi\Exception\RuntimeException | [
"Verify",
"Field",
"is",
"Defined"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L391-L403 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.setFieldValue | protected function setFieldValue($key, $data, $default = null)
{
$value = null;
if (isset($data->$key)) {
$value = $data->$key;
}
if ($value === null) {
$value = $default;
}
return $value;
} | php | protected function setFieldValue($key, $data, $default = null)
{
$value = null;
if (isset($data->$key)) {
$value = $data->$key;
}
if ($value === null) {
$value = $default;
}
return $value;
} | [
"protected",
"function",
"setFieldValue",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"->",
"$",
"key",
")",
")",
"{",
"$",
"value",
"=",
"$",
"data",
"->",
"$",
"key",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"default",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Set Value for Field
@param string $key
@param object $data
@param null|mixed $default
@return stdClass
@since 1.0.0 | [
"Set",
"Value",
"for",
"Field"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L452-L465 | train |
CommonApi/Query | QueryUsageTrait.php | QueryUsageTrait.sortObject | protected function sortObject($object)
{
$sort_array = get_object_vars($object);
ksort($sort_array);
$new_object = new stdClass();
foreach ($sort_array as $key => $value) {
if (is_object($value)) {
$value = $this->sortObject($value);
}
$new_object->$key = $value;
}
unset($sort_array);
unset($object);
return $new_object;
} | php | protected function sortObject($object)
{
$sort_array = get_object_vars($object);
ksort($sort_array);
$new_object = new stdClass();
foreach ($sort_array as $key => $value) {
if (is_object($value)) {
$value = $this->sortObject($value);
}
$new_object->$key = $value;
}
unset($sort_array);
unset($object);
return $new_object;
} | [
"protected",
"function",
"sortObject",
"(",
"$",
"object",
")",
"{",
"$",
"sort_array",
"=",
"get_object_vars",
"(",
"$",
"object",
")",
";",
"ksort",
"(",
"$",
"sort_array",
")",
";",
"$",
"new_object",
"=",
"new",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"$",
"sort_array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"sortObject",
"(",
"$",
"value",
")",
";",
"}",
"$",
"new_object",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"unset",
"(",
"$",
"sort_array",
")",
";",
"unset",
"(",
"$",
"object",
")",
";",
"return",
"$",
"new_object",
";",
"}"
] | Sort an object
@param object $object
@return object
@since 1.0.0 | [
"Sort",
"an",
"object"
] | 0c4bdcd1dc82b1994fdce83cda581573ba56d6e7 | https://github.com/CommonApi/Query/blob/0c4bdcd1dc82b1994fdce83cda581573ba56d6e7/QueryUsageTrait.php#L494-L511 | train |
OpenConext-Attic/OpenConext-engineblock-metadata | src/X509/X509PrivateKey.php | X509PrivateKey.sign | public function sign($data)
{
$privateKeyResource = openssl_pkey_get_private('file://' . $this->filePath);
$signature = null;
openssl_sign($data, $signature, $privateKeyResource);
openssl_free_key($privateKeyResource);
return $signature;
} | php | public function sign($data)
{
$privateKeyResource = openssl_pkey_get_private('file://' . $this->filePath);
$signature = null;
openssl_sign($data, $signature, $privateKeyResource);
openssl_free_key($privateKeyResource);
return $signature;
} | [
"public",
"function",
"sign",
"(",
"$",
"data",
")",
"{",
"$",
"privateKeyResource",
"=",
"openssl_pkey_get_private",
"(",
"'file://'",
".",
"$",
"this",
"->",
"filePath",
")",
";",
"$",
"signature",
"=",
"null",
";",
"openssl_sign",
"(",
"$",
"data",
",",
"$",
"signature",
",",
"$",
"privateKeyResource",
")",
";",
"openssl_free_key",
"(",
"$",
"privateKeyResource",
")",
";",
"return",
"$",
"signature",
";",
"}"
] | Sign some data with this private key.
Note how we never actually load the private key into memory, we let OpenSSL do this and afterwards immediately
tell OpenSSL to forget the key to reduce chances of leakage.
@param string $data
@return string | [
"Sign",
"some",
"data",
"with",
"this",
"private",
"key",
"."
] | 236e2f52ef9cf28e71404544a1c4388f63ee535d | https://github.com/OpenConext-Attic/OpenConext-engineblock-metadata/blob/236e2f52ef9cf28e71404544a1c4388f63ee535d/src/X509/X509PrivateKey.php#L62-L72 | train |
gplcart/twocheckout | controllers/Settings.php | Settings.editSettings | public function editSettings()
{
$this->setTitleEditSettings();
$this->setBreadcrumbEditSettings();
$this->setData('statuses', $this->order->getStatuses());
$this->setData('settings', $this->module->getSettings('twocheckout'));
$this->submitSettings();
$this->outputEditSettings();
} | php | public function editSettings()
{
$this->setTitleEditSettings();
$this->setBreadcrumbEditSettings();
$this->setData('statuses', $this->order->getStatuses());
$this->setData('settings', $this->module->getSettings('twocheckout'));
$this->submitSettings();
$this->outputEditSettings();
} | [
"public",
"function",
"editSettings",
"(",
")",
"{",
"$",
"this",
"->",
"setTitleEditSettings",
"(",
")",
";",
"$",
"this",
"->",
"setBreadcrumbEditSettings",
"(",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'statuses'",
",",
"$",
"this",
"->",
"order",
"->",
"getStatuses",
"(",
")",
")",
";",
"$",
"this",
"->",
"setData",
"(",
"'settings'",
",",
"$",
"this",
"->",
"module",
"->",
"getSettings",
"(",
"'twocheckout'",
")",
")",
";",
"$",
"this",
"->",
"submitSettings",
"(",
")",
";",
"$",
"this",
"->",
"outputEditSettings",
"(",
")",
";",
"}"
] | Route page callback to display module settings form | [
"Route",
"page",
"callback",
"to",
"display",
"module",
"settings",
"form"
] | b1578f866ac29d37720e1d616b8b4783832d5107 | https://github.com/gplcart/twocheckout/blob/b1578f866ac29d37720e1d616b8b4783832d5107/controllers/Settings.php#L41-L51 | train |
PaulDevelop/Library.Modeling.Xml | src/class/Tag.php | Tag.toXml | public function toXml()
{
// init
$result = '';
$tagName = ($this->namespace == '' ? '' : $this->namespace.':').$this->name;
$attributes = '';
foreach ($this->attributes as $attribute) {
$attributes .= ' '.$attribute->Name.'="'.$attribute->Value.'"';
}
// action
$result .= '<'.$tagName.$attributes.'>';
foreach ($this->nodes as $node) {
/** @var INode $node */
$result .= $node->toXml();
}
$result .= '</'.$tagName.'>';
// return
return $result;
} | php | public function toXml()
{
// init
$result = '';
$tagName = ($this->namespace == '' ? '' : $this->namespace.':').$this->name;
$attributes = '';
foreach ($this->attributes as $attribute) {
$attributes .= ' '.$attribute->Name.'="'.$attribute->Value.'"';
}
// action
$result .= '<'.$tagName.$attributes.'>';
foreach ($this->nodes as $node) {
/** @var INode $node */
$result .= $node->toXml();
}
$result .= '</'.$tagName.'>';
// return
return $result;
} | [
"public",
"function",
"toXml",
"(",
")",
"{",
"// init",
"$",
"result",
"=",
"''",
";",
"$",
"tagName",
"=",
"(",
"$",
"this",
"->",
"namespace",
"==",
"''",
"?",
"''",
":",
"$",
"this",
"->",
"namespace",
".",
"':'",
")",
".",
"$",
"this",
"->",
"name",
";",
"$",
"attributes",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"attributes",
".=",
"' '",
".",
"$",
"attribute",
"->",
"Name",
".",
"'=\"'",
".",
"$",
"attribute",
"->",
"Value",
".",
"'\"'",
";",
"}",
"// action",
"$",
"result",
".=",
"'<'",
".",
"$",
"tagName",
".",
"$",
"attributes",
".",
"'>'",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"/** @var INode $node */",
"$",
"result",
".=",
"$",
"node",
"->",
"toXml",
"(",
")",
";",
"}",
"$",
"result",
".=",
"'</'",
".",
"$",
"tagName",
".",
"'>'",
";",
"// return",
"return",
"$",
"result",
";",
"}"
] | Convert to XML.
@return string | [
"Convert",
"to",
"XML",
"."
] | d13d302e1200ca5943169555265c9731c8eddaf5 | https://github.com/PaulDevelop/Library.Modeling.Xml/blob/d13d302e1200ca5943169555265c9731c8eddaf5/src/class/Tag.php#L95-L115 | train |
jayzeng/PHPEnum | Src/Util/Enum.php | Enum.getAllValues | final public function getAllValues() {
$subClass = get_called_class();
// Subclass has already been registered
if(isset($this->_cachedEnums[$subClass])) {
return FALSE;
}
$reflection = new \ReflectionClass($subClass);
return $reflection->getConstants();
} | php | final public function getAllValues() {
$subClass = get_called_class();
// Subclass has already been registered
if(isset($this->_cachedEnums[$subClass])) {
return FALSE;
}
$reflection = new \ReflectionClass($subClass);
return $reflection->getConstants();
} | [
"final",
"public",
"function",
"getAllValues",
"(",
")",
"{",
"$",
"subClass",
"=",
"get_called_class",
"(",
")",
";",
"// Subclass has already been registered",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_cachedEnums",
"[",
"$",
"subClass",
"]",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"subClass",
")",
";",
"return",
"$",
"reflection",
"->",
"getConstants",
"(",
")",
";",
"}"
] | Return all populated arrays
@return false|array return array of constants
or false when the subclass is
already registered in cache | [
"Return",
"all",
"populated",
"arrays"
] | af04fa72a664f19a0900de4b7a69af4888854d1d | https://github.com/jayzeng/PHPEnum/blob/af04fa72a664f19a0900de4b7a69af4888854d1d/Src/Util/Enum.php#L63-L74 | train |
KickAssCommerce/framework | src/Commerce/Product/Cache/Product.php | Product.afterMethodExecution | public function afterMethodExecution(MethodInvocation $invocation)
{
$filesystemAdapter = new Local(APP_BASE_DIR . 'storage/cache/api/');
$filesystem = new Filesystem($filesystemAdapter);
$pool = new FilesystemCachePool($filesystem);
$cacheKey = "products_" . md5(implode('_', $invocation->getArguments()));
$item = $pool->getItem($cacheKey);
$normalizer = new ObjectNormalizer();
if ($item->isHit()) { // found the item in cache
/** @var MapProduct $cacheItem */
$cacheItem = $normalizer->denormalize($item->get(), MapProduct::class);
return $cacheItem;
}
// execute the API call
/** @var \KickAss\Commerce\Product\Map\Product $returnValue */
$returnValue = $invocation->proceed();
$item->set($normalizer->normalize($returnValue, 'array'))
->setTags(['products']);
$item->expiresAfter(3600);
$pool->save($item);
// return value as expected
return $returnValue;
} | php | public function afterMethodExecution(MethodInvocation $invocation)
{
$filesystemAdapter = new Local(APP_BASE_DIR . 'storage/cache/api/');
$filesystem = new Filesystem($filesystemAdapter);
$pool = new FilesystemCachePool($filesystem);
$cacheKey = "products_" . md5(implode('_', $invocation->getArguments()));
$item = $pool->getItem($cacheKey);
$normalizer = new ObjectNormalizer();
if ($item->isHit()) { // found the item in cache
/** @var MapProduct $cacheItem */
$cacheItem = $normalizer->denormalize($item->get(), MapProduct::class);
return $cacheItem;
}
// execute the API call
/** @var \KickAss\Commerce\Product\Map\Product $returnValue */
$returnValue = $invocation->proceed();
$item->set($normalizer->normalize($returnValue, 'array'))
->setTags(['products']);
$item->expiresAfter(3600);
$pool->save($item);
// return value as expected
return $returnValue;
} | [
"public",
"function",
"afterMethodExecution",
"(",
"MethodInvocation",
"$",
"invocation",
")",
"{",
"$",
"filesystemAdapter",
"=",
"new",
"Local",
"(",
"APP_BASE_DIR",
".",
"'storage/cache/api/'",
")",
";",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
"$",
"filesystemAdapter",
")",
";",
"$",
"pool",
"=",
"new",
"FilesystemCachePool",
"(",
"$",
"filesystem",
")",
";",
"$",
"cacheKey",
"=",
"\"products_\"",
".",
"md5",
"(",
"implode",
"(",
"'_'",
",",
"$",
"invocation",
"->",
"getArguments",
"(",
")",
")",
")",
";",
"$",
"item",
"=",
"$",
"pool",
"->",
"getItem",
"(",
"$",
"cacheKey",
")",
";",
"$",
"normalizer",
"=",
"new",
"ObjectNormalizer",
"(",
")",
";",
"if",
"(",
"$",
"item",
"->",
"isHit",
"(",
")",
")",
"{",
"// found the item in cache",
"/** @var MapProduct $cacheItem */",
"$",
"cacheItem",
"=",
"$",
"normalizer",
"->",
"denormalize",
"(",
"$",
"item",
"->",
"get",
"(",
")",
",",
"MapProduct",
"::",
"class",
")",
";",
"return",
"$",
"cacheItem",
";",
"}",
"// execute the API call",
"/** @var \\KickAss\\Commerce\\Product\\Map\\Product $returnValue */",
"$",
"returnValue",
"=",
"$",
"invocation",
"->",
"proceed",
"(",
")",
";",
"$",
"item",
"->",
"set",
"(",
"$",
"normalizer",
"->",
"normalize",
"(",
"$",
"returnValue",
",",
"'array'",
")",
")",
"->",
"setTags",
"(",
"[",
"'products'",
"]",
")",
";",
"$",
"item",
"->",
"expiresAfter",
"(",
"3600",
")",
";",
"$",
"pool",
"->",
"save",
"(",
"$",
"item",
")",
";",
"// return value as expected",
"return",
"$",
"returnValue",
";",
"}"
] | Cache bridge file response
@param MethodInvocation $invocation
@return \KickAss\Commerce\Product\Map\Product
@Around("execution(public KickAss\Commerce\Product\Repository\Product->loadByAttribute(*))") | [
"Cache",
"bridge",
"file",
"response"
] | 492f4baa1e660f72acc83d37df45581aa8dfeb38 | https://github.com/KickAssCommerce/framework/blob/492f4baa1e660f72acc83d37df45581aa8dfeb38/src/Commerce/Product/Cache/Product.php#L32-L62 | train |
kael-shipman/php-std-traits | src/AbstractCliConfig.php | AbstractCliConfig.reload | public function reload(): void
{
$config = [];
foreach($this->configSources as $src) {
// If it's a string, then it's a file or directory path
if (is_string($src)) {
// If directory, get all config files within it, recursively
if (is_dir($src)) {
$getConfigFiles = function(string $path) use (&$getConfigFiles) {
$fragments = [];
if (is_dir($path)) {
$d = dir($path);
while (($f = $d->read()) !== false) {
if ($f[0] === '.') {
continue;
}
if (is_dir("$path/$f")) {
$fragments = array_merge($fragments, $getConfigFiles("$path/$f"));
} else {
$fragments[] = "$path/$f";
}
}
}
return $fragments;
};
$fragments = $getConfigFiles($src);
sort($fragments);
foreach($fragments as $c) {
$config = array_replace_recursive($config, $this->parseConfig(file_get_contents($c)));
}
// If it's a file, just merge it's contents over the current config array
} elseif (is_file($src)) {
$config = array_replace_recursive($config, $this->parseConfig(file_get_contents($src)));
// If it doesn't exist in the filesystem, and it's not optional, throw an exception
} elseif (array_search($src, $this->optional) === false) {
throw (new MissingConfigFileException("Required config file or directory `$src` is missing."))
->setMissingPath($src);
}
// If the source is an array, just merge it in
} elseif (is_array($src)) {
$config = array_replace_recursive($config, $src);
}
}
$this->config = $config;
} | php | public function reload(): void
{
$config = [];
foreach($this->configSources as $src) {
// If it's a string, then it's a file or directory path
if (is_string($src)) {
// If directory, get all config files within it, recursively
if (is_dir($src)) {
$getConfigFiles = function(string $path) use (&$getConfigFiles) {
$fragments = [];
if (is_dir($path)) {
$d = dir($path);
while (($f = $d->read()) !== false) {
if ($f[0] === '.') {
continue;
}
if (is_dir("$path/$f")) {
$fragments = array_merge($fragments, $getConfigFiles("$path/$f"));
} else {
$fragments[] = "$path/$f";
}
}
}
return $fragments;
};
$fragments = $getConfigFiles($src);
sort($fragments);
foreach($fragments as $c) {
$config = array_replace_recursive($config, $this->parseConfig(file_get_contents($c)));
}
// If it's a file, just merge it's contents over the current config array
} elseif (is_file($src)) {
$config = array_replace_recursive($config, $this->parseConfig(file_get_contents($src)));
// If it doesn't exist in the filesystem, and it's not optional, throw an exception
} elseif (array_search($src, $this->optional) === false) {
throw (new MissingConfigFileException("Required config file or directory `$src` is missing."))
->setMissingPath($src);
}
// If the source is an array, just merge it in
} elseif (is_array($src)) {
$config = array_replace_recursive($config, $src);
}
}
$this->config = $config;
} | [
"public",
"function",
"reload",
"(",
")",
":",
"void",
"{",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"configSources",
"as",
"$",
"src",
")",
"{",
"// If it's a string, then it's a file or directory path",
"if",
"(",
"is_string",
"(",
"$",
"src",
")",
")",
"{",
"// If directory, get all config files within it, recursively",
"if",
"(",
"is_dir",
"(",
"$",
"src",
")",
")",
"{",
"$",
"getConfigFiles",
"=",
"function",
"(",
"string",
"$",
"path",
")",
"use",
"(",
"&",
"$",
"getConfigFiles",
")",
"{",
"$",
"fragments",
"=",
"[",
"]",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"d",
"=",
"dir",
"(",
"$",
"path",
")",
";",
"while",
"(",
"(",
"$",
"f",
"=",
"$",
"d",
"->",
"read",
"(",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"f",
"[",
"0",
"]",
"===",
"'.'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_dir",
"(",
"\"$path/$f\"",
")",
")",
"{",
"$",
"fragments",
"=",
"array_merge",
"(",
"$",
"fragments",
",",
"$",
"getConfigFiles",
"(",
"\"$path/$f\"",
")",
")",
";",
"}",
"else",
"{",
"$",
"fragments",
"[",
"]",
"=",
"\"$path/$f\"",
";",
"}",
"}",
"}",
"return",
"$",
"fragments",
";",
"}",
";",
"$",
"fragments",
"=",
"$",
"getConfigFiles",
"(",
"$",
"src",
")",
";",
"sort",
"(",
"$",
"fragments",
")",
";",
"foreach",
"(",
"$",
"fragments",
"as",
"$",
"c",
")",
"{",
"$",
"config",
"=",
"array_replace_recursive",
"(",
"$",
"config",
",",
"$",
"this",
"->",
"parseConfig",
"(",
"file_get_contents",
"(",
"$",
"c",
")",
")",
")",
";",
"}",
"// If it's a file, just merge it's contents over the current config array",
"}",
"elseif",
"(",
"is_file",
"(",
"$",
"src",
")",
")",
"{",
"$",
"config",
"=",
"array_replace_recursive",
"(",
"$",
"config",
",",
"$",
"this",
"->",
"parseConfig",
"(",
"file_get_contents",
"(",
"$",
"src",
")",
")",
")",
";",
"// If it doesn't exist in the filesystem, and it's not optional, throw an exception",
"}",
"elseif",
"(",
"array_search",
"(",
"$",
"src",
",",
"$",
"this",
"->",
"optional",
")",
"===",
"false",
")",
"{",
"throw",
"(",
"new",
"MissingConfigFileException",
"(",
"\"Required config file or directory `$src` is missing.\"",
")",
")",
"->",
"setMissingPath",
"(",
"$",
"src",
")",
";",
"}",
"// If the source is an array, just merge it in",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"src",
")",
")",
"{",
"$",
"config",
"=",
"array_replace_recursive",
"(",
"$",
"config",
",",
"$",
"src",
")",
";",
"}",
"}",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
";",
"}"
] | Reload the config from it's sources (usually done on SIGHUP to load in
configuration changes in files
@return void | [
"Reload",
"the",
"config",
"from",
"it",
"s",
"sources",
"(",
"usually",
"done",
"on",
"SIGHUP",
"to",
"load",
"in",
"configuration",
"changes",
"in",
"files"
] | c21ddfc9dc682e6589e52f3717df81e0d2972c0e | https://github.com/kael-shipman/php-std-traits/blob/c21ddfc9dc682e6589e52f3717df81e0d2972c0e/src/AbstractCliConfig.php#L55-L102 | train |
kael-shipman/php-std-traits | src/AbstractCliConfig.php | AbstractCliConfig.parseConfig | protected function parseConfig(string $config): array
{
$config = json_decode($config, true);
if ($config === null) {
throw new ConfigFileFormatException("Config files should be written in valid JSON");
}
return $config;
} | php | protected function parseConfig(string $config): array
{
$config = json_decode($config, true);
if ($config === null) {
throw new ConfigFileFormatException("Config files should be written in valid JSON");
}
return $config;
} | [
"protected",
"function",
"parseConfig",
"(",
"string",
"$",
"config",
")",
":",
"array",
"{",
"$",
"config",
"=",
"json_decode",
"(",
"$",
"config",
",",
"true",
")",
";",
"if",
"(",
"$",
"config",
"===",
"null",
")",
"{",
"throw",
"new",
"ConfigFileFormatException",
"(",
"\"Config files should be written in valid JSON\"",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | An overridable method that allows parsing arbitrary strings into config arrays
@param string $config The contents of a config file (or sometimes the filename itself)
@return array The config array resulting from the parse | [
"An",
"overridable",
"method",
"that",
"allows",
"parsing",
"arbitrary",
"strings",
"into",
"config",
"arrays"
] | c21ddfc9dc682e6589e52f3717df81e0d2972c0e | https://github.com/kael-shipman/php-std-traits/blob/c21ddfc9dc682e6589e52f3717df81e0d2972c0e/src/AbstractCliConfig.php#L110-L117 | train |
ColibriPlatform/base | controllers/InstallController.php | InstallController.actionIndex | public function actionIndex($lang = '')
{
$model = new InstallForm();
if (!empty($lang)) {
Yii::$app->language = $lang;
$model->language = $lang;
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$this->createEnvFile($model);
Yii::$app->language = $model->language;
Yii::$app->setTimeZone($model->timeZone);
$installMessages = $this->processMigrations();
$this->initRbac($model);
$messages = $this->callModulesMethod('migrateUp');
$installMessages .= implode('\n', $messages);
$messages = $this->callModulesMethod('afterInstall');
$installMessages .= implode('\n', $messages);
return $this->render('resume', [
'messages' => $installMessages
]);
}
return $this->render('index', [
'model' => $model
]);
} | php | public function actionIndex($lang = '')
{
$model = new InstallForm();
if (!empty($lang)) {
Yii::$app->language = $lang;
$model->language = $lang;
}
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$this->createEnvFile($model);
Yii::$app->language = $model->language;
Yii::$app->setTimeZone($model->timeZone);
$installMessages = $this->processMigrations();
$this->initRbac($model);
$messages = $this->callModulesMethod('migrateUp');
$installMessages .= implode('\n', $messages);
$messages = $this->callModulesMethod('afterInstall');
$installMessages .= implode('\n', $messages);
return $this->render('resume', [
'messages' => $installMessages
]);
}
return $this->render('index', [
'model' => $model
]);
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"lang",
"=",
"''",
")",
"{",
"$",
"model",
"=",
"new",
"InstallForm",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"lang",
")",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"language",
"=",
"$",
"lang",
";",
"$",
"model",
"->",
"language",
"=",
"$",
"lang",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"this",
"->",
"createEnvFile",
"(",
"$",
"model",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"language",
"=",
"$",
"model",
"->",
"language",
";",
"Yii",
"::",
"$",
"app",
"->",
"setTimeZone",
"(",
"$",
"model",
"->",
"timeZone",
")",
";",
"$",
"installMessages",
"=",
"$",
"this",
"->",
"processMigrations",
"(",
")",
";",
"$",
"this",
"->",
"initRbac",
"(",
"$",
"model",
")",
";",
"$",
"messages",
"=",
"$",
"this",
"->",
"callModulesMethod",
"(",
"'migrateUp'",
")",
";",
"$",
"installMessages",
".=",
"implode",
"(",
"'\\n'",
",",
"$",
"messages",
")",
";",
"$",
"messages",
"=",
"$",
"this",
"->",
"callModulesMethod",
"(",
"'afterInstall'",
")",
";",
"$",
"installMessages",
".=",
"implode",
"(",
"'\\n'",
",",
"$",
"messages",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'resume'",
",",
"[",
"'messages'",
"=>",
"$",
"installMessages",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] | Display the install form
@param string $lang The lang to use
@return string | [
"Display",
"the",
"install",
"form"
] | b45db9c88317e28acc5b024ac98f8428685179aa | https://github.com/ColibriPlatform/base/blob/b45db9c88317e28acc5b024ac98f8428685179aa/controllers/InstallController.php#L31-L64 | train |
ColibriPlatform/base | controllers/InstallController.php | InstallController.processMigrations | protected function processMigrations()
{
$messages = '';
$migrationsPaths = [
'@vendor/dektrium/yii2-user/migrations',
'@yii/rbac/migrations',
'@pheme/settings/migrations',
];
foreach ($migrationsPaths as $path)
{
$migration = new Migration(Yii::getAlias($path));
$migration->up();
$messages .= implode("\n", $migration->messages);
}
return $messages;
} | php | protected function processMigrations()
{
$messages = '';
$migrationsPaths = [
'@vendor/dektrium/yii2-user/migrations',
'@yii/rbac/migrations',
'@pheme/settings/migrations',
];
foreach ($migrationsPaths as $path)
{
$migration = new Migration(Yii::getAlias($path));
$migration->up();
$messages .= implode("\n", $migration->messages);
}
return $messages;
} | [
"protected",
"function",
"processMigrations",
"(",
")",
"{",
"$",
"messages",
"=",
"''",
";",
"$",
"migrationsPaths",
"=",
"[",
"'@vendor/dektrium/yii2-user/migrations'",
",",
"'@yii/rbac/migrations'",
",",
"'@pheme/settings/migrations'",
",",
"]",
";",
"foreach",
"(",
"$",
"migrationsPaths",
"as",
"$",
"path",
")",
"{",
"$",
"migration",
"=",
"new",
"Migration",
"(",
"Yii",
"::",
"getAlias",
"(",
"$",
"path",
")",
")",
";",
"$",
"migration",
"->",
"up",
"(",
")",
";",
"$",
"messages",
".=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"migration",
"->",
"messages",
")",
";",
"}",
"return",
"$",
"messages",
";",
"}"
] | Process required migrations
@return string | [
"Process",
"required",
"migrations"
] | b45db9c88317e28acc5b024ac98f8428685179aa | https://github.com/ColibriPlatform/base/blob/b45db9c88317e28acc5b024ac98f8428685179aa/controllers/InstallController.php#L71-L89 | train |
ColibriPlatform/base | controllers/InstallController.php | InstallController.createEnvFile | protected function createEnvFile(InstallForm $model)
{
$envFile = Yii::getAlias('@app/.env');
if (!file_exists($envFile)) {
$dsn = '';
$buffer = "\n";
$cookieKey = $this->generateRandomString();
$buffer .= "YII_DEBUG = 0\n";
$buffer .= "YII_ENV = prod\n";
$buffer .= "APP_TIMEZONE = {$model->timeZone}\n";
$buffer .= "APP_LANGUAGE = {$model->language}\n";
$buffer .= "ADMIN_EMAIL = {$model->email}\n";
switch ($model->dbType) {
case 'mysql':
$dsn = "mysql:host={$model->dbHost};dbname={$model->dbName}";
break;
}
$buffer .= "DB_DSN = {$dsn}\n";
$buffer .= "DB_USER = {$model->dbUsername}\n";
$buffer .= "DB_PASSWORD = {$model->dbPassword}\n";
$buffer .= "DB_TABLE_PREFIX = {$model->dbTablePrefix}\n";
$buffer .= "REQUEST_COOKIE_VALIDATION_KEY = {$cookieKey}\n";
file_put_contents($envFile, $buffer);
}
} | php | protected function createEnvFile(InstallForm $model)
{
$envFile = Yii::getAlias('@app/.env');
if (!file_exists($envFile)) {
$dsn = '';
$buffer = "\n";
$cookieKey = $this->generateRandomString();
$buffer .= "YII_DEBUG = 0\n";
$buffer .= "YII_ENV = prod\n";
$buffer .= "APP_TIMEZONE = {$model->timeZone}\n";
$buffer .= "APP_LANGUAGE = {$model->language}\n";
$buffer .= "ADMIN_EMAIL = {$model->email}\n";
switch ($model->dbType) {
case 'mysql':
$dsn = "mysql:host={$model->dbHost};dbname={$model->dbName}";
break;
}
$buffer .= "DB_DSN = {$dsn}\n";
$buffer .= "DB_USER = {$model->dbUsername}\n";
$buffer .= "DB_PASSWORD = {$model->dbPassword}\n";
$buffer .= "DB_TABLE_PREFIX = {$model->dbTablePrefix}\n";
$buffer .= "REQUEST_COOKIE_VALIDATION_KEY = {$cookieKey}\n";
file_put_contents($envFile, $buffer);
}
} | [
"protected",
"function",
"createEnvFile",
"(",
"InstallForm",
"$",
"model",
")",
"{",
"$",
"envFile",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@app/.env'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"envFile",
")",
")",
"{",
"$",
"dsn",
"=",
"''",
";",
"$",
"buffer",
"=",
"\"\\n\"",
";",
"$",
"cookieKey",
"=",
"$",
"this",
"->",
"generateRandomString",
"(",
")",
";",
"$",
"buffer",
".=",
"\"YII_DEBUG = 0\\n\"",
";",
"$",
"buffer",
".=",
"\"YII_ENV = prod\\n\"",
";",
"$",
"buffer",
".=",
"\"APP_TIMEZONE = {$model->timeZone}\\n\"",
";",
"$",
"buffer",
".=",
"\"APP_LANGUAGE = {$model->language}\\n\"",
";",
"$",
"buffer",
".=",
"\"ADMIN_EMAIL = {$model->email}\\n\"",
";",
"switch",
"(",
"$",
"model",
"->",
"dbType",
")",
"{",
"case",
"'mysql'",
":",
"$",
"dsn",
"=",
"\"mysql:host={$model->dbHost};dbname={$model->dbName}\"",
";",
"break",
";",
"}",
"$",
"buffer",
".=",
"\"DB_DSN = {$dsn}\\n\"",
";",
"$",
"buffer",
".=",
"\"DB_USER = {$model->dbUsername}\\n\"",
";",
"$",
"buffer",
".=",
"\"DB_PASSWORD = {$model->dbPassword}\\n\"",
";",
"$",
"buffer",
".=",
"\"DB_TABLE_PREFIX = {$model->dbTablePrefix}\\n\"",
";",
"$",
"buffer",
".=",
"\"REQUEST_COOKIE_VALIDATION_KEY = {$cookieKey}\\n\"",
";",
"file_put_contents",
"(",
"$",
"envFile",
",",
"$",
"buffer",
")",
";",
"}",
"}"
] | Create the application env file
@param InstallForm $model
@return void | [
"Create",
"the",
"application",
"env",
"file"
] | b45db9c88317e28acc5b024ac98f8428685179aa | https://github.com/ColibriPlatform/base/blob/b45db9c88317e28acc5b024ac98f8428685179aa/controllers/InstallController.php#L98-L129 | train |
ColibriPlatform/base | controllers/InstallController.php | InstallController.callModulesMethod | protected function callModulesMethod($methodName)
{
$modules = Yii::$app->getModules();
$returns = [];
foreach ($modules as $moduleName => $module)
{
if (is_array($module)) {
$module = Yii::$app->getModule($moduleName);
}
if (method_exists($module, $methodName)) {
$returns[] = $module->$methodName();
}
}
return $returns;
} | php | protected function callModulesMethod($methodName)
{
$modules = Yii::$app->getModules();
$returns = [];
foreach ($modules as $moduleName => $module)
{
if (is_array($module)) {
$module = Yii::$app->getModule($moduleName);
}
if (method_exists($module, $methodName)) {
$returns[] = $module->$methodName();
}
}
return $returns;
} | [
"protected",
"function",
"callModulesMethod",
"(",
"$",
"methodName",
")",
"{",
"$",
"modules",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModules",
"(",
")",
";",
"$",
"returns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"moduleName",
"=>",
"$",
"module",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"module",
")",
")",
"{",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"$",
"moduleName",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"module",
",",
"$",
"methodName",
")",
")",
"{",
"$",
"returns",
"[",
"]",
"=",
"$",
"module",
"->",
"$",
"methodName",
"(",
")",
";",
"}",
"}",
"return",
"$",
"returns",
";",
"}"
] | Call a method if exists on every application modules
@param string $methodName The method to call
@return mixed[] | [
"Call",
"a",
"method",
"if",
"exists",
"on",
"every",
"application",
"modules"
] | b45db9c88317e28acc5b024ac98f8428685179aa | https://github.com/ColibriPlatform/base/blob/b45db9c88317e28acc5b024ac98f8428685179aa/controllers/InstallController.php#L204-L221 | train |
miguelibero/meinhof | src/Meinhof/Action/OutputAction.php | OutputAction.shouldWriteOutput | protected function shouldWriteOutput($min=0, $max=null)
{
$out = $this->getOutput();
if (!$out instanceof OutputInterface) {
return false;
}
$v = $out->getVerbosity();
return !($v<$min || ($max!==null && $v>$max));
} | php | protected function shouldWriteOutput($min=0, $max=null)
{
$out = $this->getOutput();
if (!$out instanceof OutputInterface) {
return false;
}
$v = $out->getVerbosity();
return !($v<$min || ($max!==null && $v>$max));
} | [
"protected",
"function",
"shouldWriteOutput",
"(",
"$",
"min",
"=",
"0",
",",
"$",
"max",
"=",
"null",
")",
"{",
"$",
"out",
"=",
"$",
"this",
"->",
"getOutput",
"(",
")",
";",
"if",
"(",
"!",
"$",
"out",
"instanceof",
"OutputInterface",
")",
"{",
"return",
"false",
";",
"}",
"$",
"v",
"=",
"$",
"out",
"->",
"getVerbosity",
"(",
")",
";",
"return",
"!",
"(",
"$",
"v",
"<",
"$",
"min",
"||",
"(",
"$",
"max",
"!==",
"null",
"&&",
"$",
"v",
">",
"$",
"max",
")",
")",
";",
"}"
] | Checks if the output verbositiy is between two given levels
@param integer $min minimum verbosity level
@param integer $max maximum verbosity level or null for no maximum
@return boolean if output should be written | [
"Checks",
"if",
"the",
"output",
"verbositiy",
"is",
"between",
"two",
"given",
"levels"
] | 3a090f08485dc0da3e27463cf349dba374201072 | https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Action/OutputAction.php#L30-L39 | train |
miguelibero/meinhof | src/Meinhof/Action/OutputAction.php | OutputAction.writeOutputLine | protected function writeOutputLine($msg, $min=0, $max=null)
{
if (!$this->shouldWriteOutput($min, $max)) {
return;
}
$this->getOutput()->writeln($msg);
} | php | protected function writeOutputLine($msg, $min=0, $max=null)
{
if (!$this->shouldWriteOutput($min, $max)) {
return;
}
$this->getOutput()->writeln($msg);
} | [
"protected",
"function",
"writeOutputLine",
"(",
"$",
"msg",
",",
"$",
"min",
"=",
"0",
",",
"$",
"max",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"shouldWriteOutput",
"(",
"$",
"min",
",",
"$",
"max",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"$",
"msg",
")",
";",
"}"
] | Prints a text line if the output verbositiy is between two given levels
@param string $msg the text to print
@param integer $min minimum verbosity level
@param integer $max maximum verbosity level or null for no maximum | [
"Prints",
"a",
"text",
"line",
"if",
"the",
"output",
"verbositiy",
"is",
"between",
"two",
"given",
"levels"
] | 3a090f08485dc0da3e27463cf349dba374201072 | https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Action/OutputAction.php#L48-L55 | train |
miguelibero/meinhof | src/Meinhof/Action/OutputAction.php | OutputAction.writeOutput | protected function writeOutput($msg, $min=0, $max=null)
{
if (!$this->shouldWriteOutput($min, $max)) {
return;
}
return $this->getOutput()->write($msg);
} | php | protected function writeOutput($msg, $min=0, $max=null)
{
if (!$this->shouldWriteOutput($min, $max)) {
return;
}
return $this->getOutput()->write($msg);
} | [
"protected",
"function",
"writeOutput",
"(",
"$",
"msg",
",",
"$",
"min",
"=",
"0",
",",
"$",
"max",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"shouldWriteOutput",
"(",
"$",
"min",
",",
"$",
"max",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"write",
"(",
"$",
"msg",
")",
";",
"}"
] | Prints a text if the output verbositiy is between two given levels
@param string $msg the text to print
@param integer $min minimum verbosity level
@param integer $max maximum verbosity level or null for no maximum | [
"Prints",
"a",
"text",
"if",
"the",
"output",
"verbositiy",
"is",
"between",
"two",
"given",
"levels"
] | 3a090f08485dc0da3e27463cf349dba374201072 | https://github.com/miguelibero/meinhof/blob/3a090f08485dc0da3e27463cf349dba374201072/src/Meinhof/Action/OutputAction.php#L79-L86 | train |
ivopetkov/html-server-components-bearframework-addon | classes/HTMLServerComponents/Internal/Compiler.php | Compiler.makeComponent | public function makeComponent(array $attributes = [], string $innerHTML = '', string $tagName = 'component')
{
$app = App::get();
if (self::$newComponentCache === null) {
self::$newComponentCache = new \IvoPetkov\BearFramework\Addons\HTMLServerComponents\Internal\Component();
}
$component = clone(self::$newComponentCache);
foreach ($attributes as $name => $value) {
$component->setAttribute($name, $value);
}
$component->innerHTML = $innerHTML;
$component->tagName = $tagName;
if ($app->components->hasEventListeners('makeComponent')) {
$app->components->dispatchEvent('makeComponent', new \IvoPetkov\BearFramework\Addons\HTMLServerComponents\MakeComponentEventDetails($component));
}
return $component;
} | php | public function makeComponent(array $attributes = [], string $innerHTML = '', string $tagName = 'component')
{
$app = App::get();
if (self::$newComponentCache === null) {
self::$newComponentCache = new \IvoPetkov\BearFramework\Addons\HTMLServerComponents\Internal\Component();
}
$component = clone(self::$newComponentCache);
foreach ($attributes as $name => $value) {
$component->setAttribute($name, $value);
}
$component->innerHTML = $innerHTML;
$component->tagName = $tagName;
if ($app->components->hasEventListeners('makeComponent')) {
$app->components->dispatchEvent('makeComponent', new \IvoPetkov\BearFramework\Addons\HTMLServerComponents\MakeComponentEventDetails($component));
}
return $component;
} | [
"public",
"function",
"makeComponent",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"string",
"$",
"innerHTML",
"=",
"''",
",",
"string",
"$",
"tagName",
"=",
"'component'",
")",
"{",
"$",
"app",
"=",
"App",
"::",
"get",
"(",
")",
";",
"if",
"(",
"self",
"::",
"$",
"newComponentCache",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"newComponentCache",
"=",
"new",
"\\",
"IvoPetkov",
"\\",
"BearFramework",
"\\",
"Addons",
"\\",
"HTMLServerComponents",
"\\",
"Internal",
"\\",
"Component",
"(",
")",
";",
"}",
"$",
"component",
"=",
"clone",
"(",
"self",
"::",
"$",
"newComponentCache",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"component",
"->",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"$",
"component",
"->",
"innerHTML",
"=",
"$",
"innerHTML",
";",
"$",
"component",
"->",
"tagName",
"=",
"$",
"tagName",
";",
"if",
"(",
"$",
"app",
"->",
"components",
"->",
"hasEventListeners",
"(",
"'makeComponent'",
")",
")",
"{",
"$",
"app",
"->",
"components",
"->",
"dispatchEvent",
"(",
"'makeComponent'",
",",
"new",
"\\",
"IvoPetkov",
"\\",
"BearFramework",
"\\",
"Addons",
"\\",
"HTMLServerComponents",
"\\",
"MakeComponentEventDetails",
"(",
"$",
"component",
")",
")",
";",
"}",
"return",
"$",
"component",
";",
"}"
] | Constructs a component object
@param array $attributes The attributes of the component object
@param string $innerHTML The innerHTML of the component object
@param string $tagName The tag name of the component object
@return \IvoPetkov\BearFramework\Addons\HTMLServerComponents\Internal\Component A component object | [
"Constructs",
"a",
"component",
"object"
] | c9a5f275d10f194b2216d733bfea612fd876a0b2 | https://github.com/ivopetkov/html-server-components-bearframework-addon/blob/c9a5f275d10f194b2216d733bfea612fd876a0b2/classes/HTMLServerComponents/Internal/Compiler.php#L33-L49 | train |
zhaoxianfang/tools | src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php | PassConfig.getPasses | public function getPasses()
{
return array_merge(
array($this->mergePass),
$this->getBeforeOptimizationPasses(),
$this->getOptimizationPasses(),
$this->getBeforeRemovingPasses(),
$this->getRemovingPasses(),
$this->getAfterRemovingPasses()
);
} | php | public function getPasses()
{
return array_merge(
array($this->mergePass),
$this->getBeforeOptimizationPasses(),
$this->getOptimizationPasses(),
$this->getBeforeRemovingPasses(),
$this->getRemovingPasses(),
$this->getAfterRemovingPasses()
);
} | [
"public",
"function",
"getPasses",
"(",
")",
"{",
"return",
"array_merge",
"(",
"array",
"(",
"$",
"this",
"->",
"mergePass",
")",
",",
"$",
"this",
"->",
"getBeforeOptimizationPasses",
"(",
")",
",",
"$",
"this",
"->",
"getOptimizationPasses",
"(",
")",
",",
"$",
"this",
"->",
"getBeforeRemovingPasses",
"(",
")",
",",
"$",
"this",
"->",
"getRemovingPasses",
"(",
")",
",",
"$",
"this",
"->",
"getAfterRemovingPasses",
"(",
")",
")",
";",
"}"
] | Returns all passes in order to be processed.
@return CompilerPassInterface[] | [
"Returns",
"all",
"passes",
"in",
"order",
"to",
"be",
"processed",
"."
] | d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7 | https://github.com/zhaoxianfang/tools/blob/d8fc8a9ecd75b5ce4236f0a2e9fdc055108573e7/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php#L101-L111 | train |
squareproton/Bond | src/Bond/Pg/Resource.php | Resource.ensure | public static function ensure()
{
$cnt = 0;
foreach( self::$instances as $instance ) {
if( !$instance->isAlive() ) {
$instance->reset();
$cnt++;
}
}
return $cnt;
} | php | public static function ensure()
{
$cnt = 0;
foreach( self::$instances as $instance ) {
if( !$instance->isAlive() ) {
$instance->reset();
$cnt++;
}
}
return $cnt;
} | [
"public",
"static",
"function",
"ensure",
"(",
")",
"{",
"$",
"cnt",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"$",
"instances",
"as",
"$",
"instance",
")",
"{",
"if",
"(",
"!",
"$",
"instance",
"->",
"isAlive",
"(",
")",
")",
"{",
"$",
"instance",
"->",
"reset",
"(",
")",
";",
"$",
"cnt",
"++",
";",
"}",
"}",
"return",
"$",
"cnt",
";",
"}"
] | Ensure all known, non terminated, resource objects are golden | [
"Ensure",
"all",
"known",
"non",
"terminated",
"resource",
"objects",
"are",
"golden"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Resource.php#L97-L107 | train |
squareproton/Bond | src/Bond/Pg/Resource.php | Resource.unserialize | public function unserialize($data)
{
$connectionSettings = new ConnectionSettings( json_decode( $data, true ) );
$this->__construct( $connectionSettings );
} | php | public function unserialize($data)
{
$connectionSettings = new ConnectionSettings( json_decode( $data, true ) );
$this->__construct( $connectionSettings );
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"connectionSettings",
"=",
"new",
"ConnectionSettings",
"(",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
")",
";",
"$",
"this",
"->",
"__construct",
"(",
"$",
"connectionSettings",
")",
";",
"}"
] | Unserialize. Object.
@waring. Unserializing a resource will generate a new resource | [
"Unserialize",
".",
"Object",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Resource.php#L131-L135 | train |
squareproton/Bond | src/Bond/Pg/Resource.php | Resource.isTerminated | public function isTerminated( $throwExceptionIfTerminated = true )
{
if( $this->terminated ) {
if( $throwExceptionIfTerminated ) {
throw new ConnectionTerminatedException( $this );
}
return true;
}
return false;
} | php | public function isTerminated( $throwExceptionIfTerminated = true )
{
if( $this->terminated ) {
if( $throwExceptionIfTerminated ) {
throw new ConnectionTerminatedException( $this );
}
return true;
}
return false;
} | [
"public",
"function",
"isTerminated",
"(",
"$",
"throwExceptionIfTerminated",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"terminated",
")",
"{",
"if",
"(",
"$",
"throwExceptionIfTerminated",
")",
"{",
"throw",
"new",
"ConnectionTerminatedException",
"(",
"$",
"this",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Has this resource been terminated?
@throws Bond\Pg\ConnectionTerminated
@return bool | [
"Has",
"this",
"resource",
"been",
"terminated?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Resource.php#L180-L189 | train |
squareproton/Bond | src/Bond/Pg/Resource.php | Resource.get | public function get( $reconnectOnFailure = false )
{
if( $reconnectOnFailure and !$this->isAlive() ) {
$this->reset();
}
return $this->resource;
} | php | public function get( $reconnectOnFailure = false )
{
if( $reconnectOnFailure and !$this->isAlive() ) {
$this->reset();
}
return $this->resource;
} | [
"public",
"function",
"get",
"(",
"$",
"reconnectOnFailure",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reconnectOnFailure",
"and",
"!",
"$",
"this",
"->",
"isAlive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resource",
";",
"}"
] | Return the pglink resource.
@param bool Reset the connection if, for any reason, it has gone away
@return pg_link resource | [
"Return",
"the",
"pglink",
"resource",
"."
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Resource.php#L220-L226 | train |
koolkode/context | src/Container.php | Container.createInstance | public function createInstance(Binding $binding, InjectionPointInterface $point = NULL)
{
switch($binding->getOptions() & BindingInterface::MASK_TYPE)
{
case BindingInterface::TYPE_ALIAS:
return $this->get($binding->getTarget(), $point);
case BindingInterface::TYPE_FACTORY:
case BindingInterface::TYPE_FACTORY_ALIAS:
return $this->createObjectUsingFactory($binding, $point);
default:
return $this->createObject(
$binding->getTarget(),
$binding->getResolvers(),
$binding->getInitializers(),
$binding->getMarkers(SetterInjection::class)
);
}
} | php | public function createInstance(Binding $binding, InjectionPointInterface $point = NULL)
{
switch($binding->getOptions() & BindingInterface::MASK_TYPE)
{
case BindingInterface::TYPE_ALIAS:
return $this->get($binding->getTarget(), $point);
case BindingInterface::TYPE_FACTORY:
case BindingInterface::TYPE_FACTORY_ALIAS:
return $this->createObjectUsingFactory($binding, $point);
default:
return $this->createObject(
$binding->getTarget(),
$binding->getResolvers(),
$binding->getInitializers(),
$binding->getMarkers(SetterInjection::class)
);
}
} | [
"public",
"function",
"createInstance",
"(",
"Binding",
"$",
"binding",
",",
"InjectionPointInterface",
"$",
"point",
"=",
"NULL",
")",
"{",
"switch",
"(",
"$",
"binding",
"->",
"getOptions",
"(",
")",
"&",
"BindingInterface",
"::",
"MASK_TYPE",
")",
"{",
"case",
"BindingInterface",
"::",
"TYPE_ALIAS",
":",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"binding",
"->",
"getTarget",
"(",
")",
",",
"$",
"point",
")",
";",
"case",
"BindingInterface",
"::",
"TYPE_FACTORY",
":",
"case",
"BindingInterface",
"::",
"TYPE_FACTORY_ALIAS",
":",
"return",
"$",
"this",
"->",
"createObjectUsingFactory",
"(",
"$",
"binding",
",",
"$",
"point",
")",
";",
"default",
":",
"return",
"$",
"this",
"->",
"createObject",
"(",
"$",
"binding",
"->",
"getTarget",
"(",
")",
",",
"$",
"binding",
"->",
"getResolvers",
"(",
")",
",",
"$",
"binding",
"->",
"getInitializers",
"(",
")",
",",
"$",
"binding",
"->",
"getMarkers",
"(",
"SetterInjection",
"::",
"class",
")",
")",
";",
"}",
"}"
] | Create an instance of the bound type, will NOT create or re-use a scoped proxy.
@param Binding $binding
@param InjectionPointInterface $point
@return object | [
"Create",
"an",
"instance",
"of",
"the",
"bound",
"type",
"will",
"NOT",
"create",
"or",
"re",
"-",
"use",
"a",
"scoped",
"proxy",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Container.php#L228-L245 | train |
koolkode/context | src/Container.php | Container.createObjectUsingFactory | protected function createObjectUsingFactory(Binding $binding, InjectionPointInterface $point = NULL)
{
$callback = $binding->getTarget();
if(is_array($callback))
{
$callback = [$this->get($callback[0]), $callback[1]];
$ref = new \ReflectionMethod(get_class($callback[0]), $callback[1]);
}
else
{
$ref = new \ReflectionFunction($callback);
}
$resolvers = (array)$binding->getResolvers();
// Special case: inject config of the type to be created into the factory:
foreach($ref->getParameters() as $param)
{
if($this->getParamType($param) === Configuration::class)
{
$resolvers[$param->name] = $this->config->getConfig(str_replace('\\', '.', $binding->getTypeName()));
}
}
$args = $this->populateArguments($ref, 0, $resolvers, $point);
switch(count($args))
{
case 0:
$object = $callback();
break;
case 1:
$object = $callback($args[0]);
break;
case 2:
$object = $callback($args[0], $args[1]);
break;
case 3:
$object = $callback($args[0], $args[1], $args[2]);
break;
case 4:
$object = $callback($args[0], $args[1], $args[2], $args[3]);
break;
default:
$object = call_user_func_array($callback, $args);
}
if($object instanceof ScopedProxyInterface)
{
return $object;
}
$object = $this->initialize($object);
foreach($binding->getMarkers(SetterInjection::class) as $setter)
{
$this->performSetterInjection($object, $setter);
}
$initializers = $binding->getInitializers();
if(!empty($initializers))
{
$object = $this->invokeBindingInitializers($binding->getTypeName(), $object, $initializers);
}
return $object;
} | php | protected function createObjectUsingFactory(Binding $binding, InjectionPointInterface $point = NULL)
{
$callback = $binding->getTarget();
if(is_array($callback))
{
$callback = [$this->get($callback[0]), $callback[1]];
$ref = new \ReflectionMethod(get_class($callback[0]), $callback[1]);
}
else
{
$ref = new \ReflectionFunction($callback);
}
$resolvers = (array)$binding->getResolvers();
// Special case: inject config of the type to be created into the factory:
foreach($ref->getParameters() as $param)
{
if($this->getParamType($param) === Configuration::class)
{
$resolvers[$param->name] = $this->config->getConfig(str_replace('\\', '.', $binding->getTypeName()));
}
}
$args = $this->populateArguments($ref, 0, $resolvers, $point);
switch(count($args))
{
case 0:
$object = $callback();
break;
case 1:
$object = $callback($args[0]);
break;
case 2:
$object = $callback($args[0], $args[1]);
break;
case 3:
$object = $callback($args[0], $args[1], $args[2]);
break;
case 4:
$object = $callback($args[0], $args[1], $args[2], $args[3]);
break;
default:
$object = call_user_func_array($callback, $args);
}
if($object instanceof ScopedProxyInterface)
{
return $object;
}
$object = $this->initialize($object);
foreach($binding->getMarkers(SetterInjection::class) as $setter)
{
$this->performSetterInjection($object, $setter);
}
$initializers = $binding->getInitializers();
if(!empty($initializers))
{
$object = $this->invokeBindingInitializers($binding->getTypeName(), $object, $initializers);
}
return $object;
} | [
"protected",
"function",
"createObjectUsingFactory",
"(",
"Binding",
"$",
"binding",
",",
"InjectionPointInterface",
"$",
"point",
"=",
"NULL",
")",
"{",
"$",
"callback",
"=",
"$",
"binding",
"->",
"getTarget",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"callback",
"=",
"[",
"$",
"this",
"->",
"get",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
",",
"$",
"callback",
"[",
"1",
"]",
"]",
";",
"$",
"ref",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"get_class",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
",",
"$",
"callback",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"ref",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"}",
"$",
"resolvers",
"=",
"(",
"array",
")",
"$",
"binding",
"->",
"getResolvers",
"(",
")",
";",
"// Special case: inject config of the type to be created into the factory:",
"foreach",
"(",
"$",
"ref",
"->",
"getParameters",
"(",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getParamType",
"(",
"$",
"param",
")",
"===",
"Configuration",
"::",
"class",
")",
"{",
"$",
"resolvers",
"[",
"$",
"param",
"->",
"name",
"]",
"=",
"$",
"this",
"->",
"config",
"->",
"getConfig",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'.'",
",",
"$",
"binding",
"->",
"getTypeName",
"(",
")",
")",
")",
";",
"}",
"}",
"$",
"args",
"=",
"$",
"this",
"->",
"populateArguments",
"(",
"$",
"ref",
",",
"0",
",",
"$",
"resolvers",
",",
"$",
"point",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"case",
"0",
":",
"$",
"object",
"=",
"$",
"callback",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"object",
"=",
"$",
"callback",
"(",
"$",
"args",
"[",
"0",
"]",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"object",
"=",
"$",
"callback",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"$",
"args",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"3",
":",
"$",
"object",
"=",
"$",
"callback",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"$",
"args",
"[",
"1",
"]",
",",
"$",
"args",
"[",
"2",
"]",
")",
";",
"break",
";",
"case",
"4",
":",
"$",
"object",
"=",
"$",
"callback",
"(",
"$",
"args",
"[",
"0",
"]",
",",
"$",
"args",
"[",
"1",
"]",
",",
"$",
"args",
"[",
"2",
"]",
",",
"$",
"args",
"[",
"3",
"]",
")",
";",
"break",
";",
"default",
":",
"$",
"object",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"args",
")",
";",
"}",
"if",
"(",
"$",
"object",
"instanceof",
"ScopedProxyInterface",
")",
"{",
"return",
"$",
"object",
";",
"}",
"$",
"object",
"=",
"$",
"this",
"->",
"initialize",
"(",
"$",
"object",
")",
";",
"foreach",
"(",
"$",
"binding",
"->",
"getMarkers",
"(",
"SetterInjection",
"::",
"class",
")",
"as",
"$",
"setter",
")",
"{",
"$",
"this",
"->",
"performSetterInjection",
"(",
"$",
"object",
",",
"$",
"setter",
")",
";",
"}",
"$",
"initializers",
"=",
"$",
"binding",
"->",
"getInitializers",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"initializers",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"invokeBindingInitializers",
"(",
"$",
"binding",
"->",
"getTypeName",
"(",
")",
",",
"$",
"object",
",",
"$",
"initializers",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | Create an object using the factory defined in the given binding.
@param Binding $binding
@param InjectionPointInterface $point
@return object | [
"Create",
"an",
"object",
"using",
"the",
"factory",
"defined",
"in",
"the",
"given",
"binding",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Container.php#L269-L337 | train |
koolkode/context | src/Container.php | Container.registerBindings | protected function registerBindings(array $bindings)
{
foreach($bindings as $binding)
{
$this->bindings[(string)$binding] = $binding;
foreach($binding->getMarkers() as $marker)
{
$marker = get_class($marker);
if(empty($this->markers[$marker]))
{
$this->markers[$marker] = new \SplObjectStorage();
}
$this->markers[$marker]->attach($binding);
}
}
} | php | protected function registerBindings(array $bindings)
{
foreach($bindings as $binding)
{
$this->bindings[(string)$binding] = $binding;
foreach($binding->getMarkers() as $marker)
{
$marker = get_class($marker);
if(empty($this->markers[$marker]))
{
$this->markers[$marker] = new \SplObjectStorage();
}
$this->markers[$marker]->attach($binding);
}
}
} | [
"protected",
"function",
"registerBindings",
"(",
"array",
"$",
"bindings",
")",
"{",
"foreach",
"(",
"$",
"bindings",
"as",
"$",
"binding",
")",
"{",
"$",
"this",
"->",
"bindings",
"[",
"(",
"string",
")",
"$",
"binding",
"]",
"=",
"$",
"binding",
";",
"foreach",
"(",
"$",
"binding",
"->",
"getMarkers",
"(",
")",
"as",
"$",
"marker",
")",
"{",
"$",
"marker",
"=",
"get_class",
"(",
"$",
"marker",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"markers",
"[",
"$",
"marker",
"]",
")",
")",
"{",
"$",
"this",
"->",
"markers",
"[",
"$",
"marker",
"]",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"}",
"$",
"this",
"->",
"markers",
"[",
"$",
"marker",
"]",
"->",
"attach",
"(",
"$",
"binding",
")",
";",
"}",
"}",
"}"
] | Register the given bindings with the container and prepare markers.
@param array<Binding> $bindings | [
"Register",
"the",
"given",
"bindings",
"with",
"the",
"container",
"and",
"prepare",
"markers",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Container.php#L344-L362 | train |
anime-db/catalog-bundle | src/Console/Progress/Export.php | Export.advance | public function advance($step = 1, $redraw = false)
{
parent::advance($step, $redraw);
$this->current += $step;
$percent = 0;
if ($this->max > 0) {
$percent = (float) $this->current / $this->max;
}
$this->output->write(sprintf('%d%%', floor($percent * 100)));
} | php | public function advance($step = 1, $redraw = false)
{
parent::advance($step, $redraw);
$this->current += $step;
$percent = 0;
if ($this->max > 0) {
$percent = (float) $this->current / $this->max;
}
$this->output->write(sprintf('%d%%', floor($percent * 100)));
} | [
"public",
"function",
"advance",
"(",
"$",
"step",
"=",
"1",
",",
"$",
"redraw",
"=",
"false",
")",
"{",
"parent",
"::",
"advance",
"(",
"$",
"step",
",",
"$",
"redraw",
")",
";",
"$",
"this",
"->",
"current",
"+=",
"$",
"step",
";",
"$",
"percent",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"max",
">",
"0",
")",
"{",
"$",
"percent",
"=",
"(",
"float",
")",
"$",
"this",
"->",
"current",
"/",
"$",
"this",
"->",
"max",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"write",
"(",
"sprintf",
"(",
"'%d%%'",
",",
"floor",
"(",
"$",
"percent",
"*",
"100",
")",
")",
")",
";",
"}"
] | Advances the progress output X steps.
@param int $step Number of steps to advance
@param bool $redraw Whether to redraw or not
@throws \LogicException | [
"Advances",
"the",
"progress",
"output",
"X",
"steps",
"."
] | 631b6f92a654e91bee84f46218c52cf42bdb8606 | https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Console/Progress/Export.php#L72-L83 | train |
AnonymPHP/Anonym-Database | Capsule/Capsule.php | Capsule.addConnection | public function addConnection(Base $connection = null, $name = '')
{
if($connection instanceof Base)
{
if($name !== '')
{
$this->connections[$name] = $connection;
}else{
$this->connections[] = $connection;
}
}else{
throw new CapsuleInstanceException(sprintf('Connection variable must be a instance of %s', Base::class));
}
} | php | public function addConnection(Base $connection = null, $name = '')
{
if($connection instanceof Base)
{
if($name !== '')
{
$this->connections[$name] = $connection;
}else{
$this->connections[] = $connection;
}
}else{
throw new CapsuleInstanceException(sprintf('Connection variable must be a instance of %s', Base::class));
}
} | [
"public",
"function",
"addConnection",
"(",
"Base",
"$",
"connection",
"=",
"null",
",",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"connection",
"instanceof",
"Base",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"''",
")",
"{",
"$",
"this",
"->",
"connections",
"[",
"$",
"name",
"]",
"=",
"$",
"connection",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"connections",
"[",
"]",
"=",
"$",
"connection",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"CapsuleInstanceException",
"(",
"sprintf",
"(",
"'Connection variable must be a instance of %s'",
",",
"Base",
"::",
"class",
")",
")",
";",
"}",
"}"
] | add a connection to capsule
@param Base $connection
@param string $name
@throws CapsuleInstanceException | [
"add",
"a",
"connection",
"to",
"capsule"
] | 4d034219e0e3eb2833fa53204e9f52a74a9a7e4b | https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Capsule/Capsule.php#L47-L60 | train |
AnonymPHP/Anonym-Database | Capsule/Capsule.php | Capsule.deleteConnection | public function deleteConnection($offset)
{
if(isset($this->connections[$offset]))
{
unset($this->connections[$offset]);
}
return $this;
} | php | public function deleteConnection($offset)
{
if(isset($this->connections[$offset]))
{
unset($this->connections[$offset]);
}
return $this;
} | [
"public",
"function",
"deleteConnection",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"offset",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"offset",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | delete a connection in capsule
@param mixed $offset
@return $this | [
"delete",
"a",
"connection",
"in",
"capsule"
] | 4d034219e0e3eb2833fa53204e9f52a74a9a7e4b | https://github.com/AnonymPHP/Anonym-Database/blob/4d034219e0e3eb2833fa53204e9f52a74a9a7e4b/Capsule/Capsule.php#L69-L77 | train |
sil-project/Product | Factory/CodeFactory.php | CodeFactory.generateProductVariantCode | public static function generateProductVariantCode(ProductInterface $product, array $productOptions): CodeInterface
{
$productVariantCodeGenerator = new ProductVariantCodeGenerator();
return $productVariantCodeGenerator->generate($product->getCode(), $productOptions);
} | php | public static function generateProductVariantCode(ProductInterface $product, array $productOptions): CodeInterface
{
$productVariantCodeGenerator = new ProductVariantCodeGenerator();
return $productVariantCodeGenerator->generate($product->getCode(), $productOptions);
} | [
"public",
"static",
"function",
"generateProductVariantCode",
"(",
"ProductInterface",
"$",
"product",
",",
"array",
"$",
"productOptions",
")",
":",
"CodeInterface",
"{",
"$",
"productVariantCodeGenerator",
"=",
"new",
"ProductVariantCodeGenerator",
"(",
")",
";",
"return",
"$",
"productVariantCodeGenerator",
"->",
"generate",
"(",
"$",
"product",
"->",
"getCode",
"(",
")",
",",
"$",
"productOptions",
")",
";",
"}"
] | Generate product variant code.
@param ProductInterface $product Current Product
@param array|Option[] $productOptions array of Options
@return CodeInterface Generated Code | [
"Generate",
"product",
"variant",
"code",
"."
] | 830dca4cc90502a7adcf3d6f0e1f14b4dddf80b4 | https://github.com/sil-project/Product/blob/830dca4cc90502a7adcf3d6f0e1f14b4dddf80b4/Factory/CodeFactory.php#L45-L50 | train |
helsingborg-stad/better-post-UI | source/php/Components/Comments.php | Comments.commentsFilter | public function commentsFilter()
{
$post_types = get_post_types();
foreach ($post_types as &$post_type) {
if (post_type_supports($post_type, 'comments')) {
$post_type_obj = get_post_type_object($post_type);
$post_type = array(
'name' => $post_type_obj->name,
'label' => $post_type_obj->label
);
} else {
unset($post_types[$post_type]);
}
}
echo '<select name="post_type"><option value="">' . __('Select post type', 'better-post-ui') . '</option>';
foreach ($post_types as $post_type) {
$selected = isset($_GET['post_type']) && $_GET['post_type'] == $post_type['name'] ? 'selected' : '';
echo '<option value="' . $post_type['name'] . '" ' . $selected . '>' . $post_type['label'] . '</option>';
}
echo '</select>';
} | php | public function commentsFilter()
{
$post_types = get_post_types();
foreach ($post_types as &$post_type) {
if (post_type_supports($post_type, 'comments')) {
$post_type_obj = get_post_type_object($post_type);
$post_type = array(
'name' => $post_type_obj->name,
'label' => $post_type_obj->label
);
} else {
unset($post_types[$post_type]);
}
}
echo '<select name="post_type"><option value="">' . __('Select post type', 'better-post-ui') . '</option>';
foreach ($post_types as $post_type) {
$selected = isset($_GET['post_type']) && $_GET['post_type'] == $post_type['name'] ? 'selected' : '';
echo '<option value="' . $post_type['name'] . '" ' . $selected . '>' . $post_type['label'] . '</option>';
}
echo '</select>';
} | [
"public",
"function",
"commentsFilter",
"(",
")",
"{",
"$",
"post_types",
"=",
"get_post_types",
"(",
")",
";",
"foreach",
"(",
"$",
"post_types",
"as",
"&",
"$",
"post_type",
")",
"{",
"if",
"(",
"post_type_supports",
"(",
"$",
"post_type",
",",
"'comments'",
")",
")",
"{",
"$",
"post_type_obj",
"=",
"get_post_type_object",
"(",
"$",
"post_type",
")",
";",
"$",
"post_type",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"post_type_obj",
"->",
"name",
",",
"'label'",
"=>",
"$",
"post_type_obj",
"->",
"label",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"post_types",
"[",
"$",
"post_type",
"]",
")",
";",
"}",
"}",
"echo",
"'<select name=\"post_type\"><option value=\"\">'",
".",
"__",
"(",
"'Select post type'",
",",
"'better-post-ui'",
")",
".",
"'</option>'",
";",
"foreach",
"(",
"$",
"post_types",
"as",
"$",
"post_type",
")",
"{",
"$",
"selected",
"=",
"isset",
"(",
"$",
"_GET",
"[",
"'post_type'",
"]",
")",
"&&",
"$",
"_GET",
"[",
"'post_type'",
"]",
"==",
"$",
"post_type",
"[",
"'name'",
"]",
"?",
"'selected'",
":",
"''",
";",
"echo",
"'<option value=\"'",
".",
"$",
"post_type",
"[",
"'name'",
"]",
".",
"'\" '",
".",
"$",
"selected",
".",
"'>'",
".",
"$",
"post_type",
"[",
"'label'",
"]",
".",
"'</option>'",
";",
"}",
"echo",
"'</select>'",
";",
"}"
] | Filter comments by post type
@return void | [
"Filter",
"comments",
"by",
"post",
"type"
] | 0454e8d6f42787244d02f0e976825ed8dca579f0 | https://github.com/helsingborg-stad/better-post-UI/blob/0454e8d6f42787244d02f0e976825ed8dca579f0/source/php/Components/Comments.php#L19-L41 | train |
helsingborg-stad/better-post-UI | source/php/Components/Comments.php | Comments.queryFilter | public function queryFilter($query)
{
global $pagenow;
if (!is_admin() || !$pagenow || $pagenow !== 'edit-comments.php' || !isset($_GET['post_type']) || !$_GET['post_type']) {
return;
}
$query->set('post_type', $_GET['post_type']);
} | php | public function queryFilter($query)
{
global $pagenow;
if (!is_admin() || !$pagenow || $pagenow !== 'edit-comments.php' || !isset($_GET['post_type']) || !$_GET['post_type']) {
return;
}
$query->set('post_type', $_GET['post_type']);
} | [
"public",
"function",
"queryFilter",
"(",
"$",
"query",
")",
"{",
"global",
"$",
"pagenow",
";",
"if",
"(",
"!",
"is_admin",
"(",
")",
"||",
"!",
"$",
"pagenow",
"||",
"$",
"pagenow",
"!==",
"'edit-comments.php'",
"||",
"!",
"isset",
"(",
"$",
"_GET",
"[",
"'post_type'",
"]",
")",
"||",
"!",
"$",
"_GET",
"[",
"'post_type'",
"]",
")",
"{",
"return",
";",
"}",
"$",
"query",
"->",
"set",
"(",
"'post_type'",
",",
"$",
"_GET",
"[",
"'post_type'",
"]",
")",
";",
"}"
] | Filter the wp query
@param WP_Query $query
@return void | [
"Filter",
"the",
"wp",
"query"
] | 0454e8d6f42787244d02f0e976825ed8dca579f0 | https://github.com/helsingborg-stad/better-post-UI/blob/0454e8d6f42787244d02f0e976825ed8dca579f0/source/php/Components/Comments.php#L48-L57 | train |
helsingborg-stad/better-post-UI | source/php/Components/Comments.php | Comments.tableColumnsContent | public function tableColumnsContent($column, $postId)
{
if ($column == 'post_type') {
$comment = get_comment($postId, OBJECT);
$post_type_slug = get_post_type($comment->comment_post_ID);
$post_type_obj = get_post_type_object($post_type_slug);
echo $post_type_obj->label;
}
} | php | public function tableColumnsContent($column, $postId)
{
if ($column == 'post_type') {
$comment = get_comment($postId, OBJECT);
$post_type_slug = get_post_type($comment->comment_post_ID);
$post_type_obj = get_post_type_object($post_type_slug);
echo $post_type_obj->label;
}
} | [
"public",
"function",
"tableColumnsContent",
"(",
"$",
"column",
",",
"$",
"postId",
")",
"{",
"if",
"(",
"$",
"column",
"==",
"'post_type'",
")",
"{",
"$",
"comment",
"=",
"get_comment",
"(",
"$",
"postId",
",",
"OBJECT",
")",
";",
"$",
"post_type_slug",
"=",
"get_post_type",
"(",
"$",
"comment",
"->",
"comment_post_ID",
")",
";",
"$",
"post_type_obj",
"=",
"get_post_type_object",
"(",
"$",
"post_type_slug",
")",
";",
"echo",
"$",
"post_type_obj",
"->",
"label",
";",
"}",
"}"
] | Content for table columns
@param string $column
@param int $postId
@return void | [
"Content",
"for",
"table",
"columns"
] | 0454e8d6f42787244d02f0e976825ed8dca579f0 | https://github.com/helsingborg-stad/better-post-UI/blob/0454e8d6f42787244d02f0e976825ed8dca579f0/source/php/Components/Comments.php#L82-L90 | train |
danielgp/composer-packages-listing | source/ComposerPackagesListing.php | ComposerPackagesListing.getFileModifiedTimestampOfFile | protected function getFileModifiedTimestampOfFile($fileName, $format = 'Y-m-d H:i:s', $resultInUtc = false)
{
if (!file_exists($fileName)) {
return ['error' => $fileName . ' was not found'];
}
$info = new \SplFileInfo($fileName);
if ($format === 'PHPtime') {
return $info->getMTime();
}
$sReturn = date($format, $info->getMTime());
if ($resultInUtc) {
$sReturn = gmdate($format, $info->getMTime());
}
return $sReturn;
} | php | protected function getFileModifiedTimestampOfFile($fileName, $format = 'Y-m-d H:i:s', $resultInUtc = false)
{
if (!file_exists($fileName)) {
return ['error' => $fileName . ' was not found'];
}
$info = new \SplFileInfo($fileName);
if ($format === 'PHPtime') {
return $info->getMTime();
}
$sReturn = date($format, $info->getMTime());
if ($resultInUtc) {
$sReturn = gmdate($format, $info->getMTime());
}
return $sReturn;
} | [
"protected",
"function",
"getFileModifiedTimestampOfFile",
"(",
"$",
"fileName",
",",
"$",
"format",
"=",
"'Y-m-d H:i:s'",
",",
"$",
"resultInUtc",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"return",
"[",
"'error'",
"=>",
"$",
"fileName",
".",
"' was not found'",
"]",
";",
"}",
"$",
"info",
"=",
"new",
"\\",
"SplFileInfo",
"(",
"$",
"fileName",
")",
";",
"if",
"(",
"$",
"format",
"===",
"'PHPtime'",
")",
"{",
"return",
"$",
"info",
"->",
"getMTime",
"(",
")",
";",
"}",
"$",
"sReturn",
"=",
"date",
"(",
"$",
"format",
",",
"$",
"info",
"->",
"getMTime",
"(",
")",
")",
";",
"if",
"(",
"$",
"resultInUtc",
")",
"{",
"$",
"sReturn",
"=",
"gmdate",
"(",
"$",
"format",
",",
"$",
"info",
"->",
"getMTime",
"(",
")",
")",
";",
"}",
"return",
"$",
"sReturn",
";",
"}"
] | Returns Modified date and time of a given file
@param string $fileName
@param string $format
@param boolean $resultInUtc
@return string | [
"Returns",
"Modified",
"date",
"and",
"time",
"of",
"a",
"given",
"file"
] | 400cdc599348cee1072df10fb207bc03bce94b9f | https://github.com/danielgp/composer-packages-listing/blob/400cdc599348cee1072df10fb207bc03bce94b9f/source/ComposerPackagesListing.php#L115-L129 | train |
danielgp/composer-packages-listing | source/ComposerPackagesListing.php | ComposerPackagesListing.getPackageDetailsFromGivenComposerLockFileEnhanced | protected function getPackageDetailsFromGivenComposerLockFileEnhanced($fileIn, $inParametersArray = [])
{
if (!file_exists($fileIn)) {
return ['error' => $fileIn . ' was not found'];
}
$alnfo = [];
$packages = $this->getPkgFileInListOfPackageArrayOut($fileIn);
$pkgType = $this->decisionPackageOrPackageDev($inParametersArray);
foreach ($packages[$pkgType] as $key => $value) {
$keyToUse = $value['name'];
if (array_key_exists('Not Grouped By Name', $inParametersArray)) {
$keyToUse = $key;
}
$alnfo[$keyToUse] = $this->mergePackageAttributes($value, $inParametersArray);
ksort($alnfo[$keyToUse]);
}
ksort($alnfo);
return $alnfo;
} | php | protected function getPackageDetailsFromGivenComposerLockFileEnhanced($fileIn, $inParametersArray = [])
{
if (!file_exists($fileIn)) {
return ['error' => $fileIn . ' was not found'];
}
$alnfo = [];
$packages = $this->getPkgFileInListOfPackageArrayOut($fileIn);
$pkgType = $this->decisionPackageOrPackageDev($inParametersArray);
foreach ($packages[$pkgType] as $key => $value) {
$keyToUse = $value['name'];
if (array_key_exists('Not Grouped By Name', $inParametersArray)) {
$keyToUse = $key;
}
$alnfo[$keyToUse] = $this->mergePackageAttributes($value, $inParametersArray);
ksort($alnfo[$keyToUse]);
}
ksort($alnfo);
return $alnfo;
} | [
"protected",
"function",
"getPackageDetailsFromGivenComposerLockFileEnhanced",
"(",
"$",
"fileIn",
",",
"$",
"inParametersArray",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileIn",
")",
")",
"{",
"return",
"[",
"'error'",
"=>",
"$",
"fileIn",
".",
"' was not found'",
"]",
";",
"}",
"$",
"alnfo",
"=",
"[",
"]",
";",
"$",
"packages",
"=",
"$",
"this",
"->",
"getPkgFileInListOfPackageArrayOut",
"(",
"$",
"fileIn",
")",
";",
"$",
"pkgType",
"=",
"$",
"this",
"->",
"decisionPackageOrPackageDev",
"(",
"$",
"inParametersArray",
")",
";",
"foreach",
"(",
"$",
"packages",
"[",
"$",
"pkgType",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"keyToUse",
"=",
"$",
"value",
"[",
"'name'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'Not Grouped By Name'",
",",
"$",
"inParametersArray",
")",
")",
"{",
"$",
"keyToUse",
"=",
"$",
"key",
";",
"}",
"$",
"alnfo",
"[",
"$",
"keyToUse",
"]",
"=",
"$",
"this",
"->",
"mergePackageAttributes",
"(",
"$",
"value",
",",
"$",
"inParametersArray",
")",
";",
"ksort",
"(",
"$",
"alnfo",
"[",
"$",
"keyToUse",
"]",
")",
";",
"}",
"ksort",
"(",
"$",
"alnfo",
")",
";",
"return",
"$",
"alnfo",
";",
"}"
] | Returns a complete list of packages and respective details from a composer.lock file
@param string $fileIn
@param array $inParametersArray
@return array | [
"Returns",
"a",
"complete",
"list",
"of",
"packages",
"and",
"respective",
"details",
"from",
"a",
"composer",
".",
"lock",
"file"
] | 400cdc599348cee1072df10fb207bc03bce94b9f | https://github.com/danielgp/composer-packages-listing/blob/400cdc599348cee1072df10fb207bc03bce94b9f/source/ComposerPackagesListing.php#L159-L177 | train |
1HappyPlace/ansi-terminal | src/ANSI/Color/Color.php | Color.setEmpty | public function setEmpty() {
// set all properties to null
$this->name = $this->ANSICode = $this->XTermCode = $this->RGB = null;
} | php | public function setEmpty() {
// set all properties to null
$this->name = $this->ANSICode = $this->XTermCode = $this->RGB = null;
} | [
"public",
"function",
"setEmpty",
"(",
")",
"{",
"// set all properties to null",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"ANSICode",
"=",
"$",
"this",
"->",
"XTermCode",
"=",
"$",
"this",
"->",
"RGB",
"=",
"null",
";",
"}"
] | Set the color object to empty | [
"Set",
"the",
"color",
"object",
"to",
"empty"
] | 3a550eadb21bb87a6909436c3b961919d2731923 | https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/Color/Color.php#L228-L232 | train |
1HappyPlace/ansi-terminal | src/ANSI/Color/Color.php | Color.isEmpty | public function isEmpty() {
// return true if all properties are null
return (is_null($this->name) && is_null($this->ANSICode) && is_null($this->XTermCode) && is_null($this->RGB));
} | php | public function isEmpty() {
// return true if all properties are null
return (is_null($this->name) && is_null($this->ANSICode) && is_null($this->XTermCode) && is_null($this->RGB));
} | [
"public",
"function",
"isEmpty",
"(",
")",
"{",
"// return true if all properties are null",
"return",
"(",
"is_null",
"(",
"$",
"this",
"->",
"name",
")",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"ANSICode",
")",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"XTermCode",
")",
"&&",
"is_null",
"(",
"$",
"this",
"->",
"RGB",
")",
")",
";",
"}"
] | Return whether the object is empty
@return bool | [
"Return",
"whether",
"the",
"object",
"is",
"empty"
] | 3a550eadb21bb87a6909436c3b961919d2731923 | https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/Color/Color.php#L238-L243 | train |
1HappyPlace/ansi-terminal | src/ANSI/Color/Color.php | Color.setColor | public function setColor($color) {
// if null is passed in, then just leave everything null
if (!is_null($color)) {
// if it an instance of another color
if ($color instanceof ColorInterface) {
// save the name
$this->name = $color->getName();
// save the xterm code
$this->XTermCode = $color->getXTermCode();
// save the RGB
$this->RGB = $color->getRGB();
// save the ansi code
$this->ANSICode = $color->getANSICode();
// if it is string, then it is a color name (maybe)
} else if (is_string($color)) {
if (Colors::isValidColorName($color)) {
$this->name = Colors::stripName($color);
// get the code for that name
$this->XTermCode = Colors::getXTermCode($this->name);
// save the RGB
$this->RGB = Colors::getRGB($this->name);
// get the ANSI code
$this->ANSICode = Colors::getANSICode($this->name);
}
// if it is an integer, then it is likely a xterm code
} else if (is_int($color)) {
// if it is between 0 and 255
if ($color >= 0 && $color <= 255) {
// save this code
$this->XTermCode = $color;
// get the RGB for it
$this->name = Colors::getColorIndexForXTermCode($this->XTermCode);
// get the RGB
$this->RGB = Colors::getRGB($this->name);
// get the ANSI Code
$this->ANSICode = Colors::getANSICode($this->name);
}
// if it is an RGB array
} else if (is_array($color)) {
// there must be three items in the array
if (count($color) === 3) {
// save the RGB
$this->RGB = $color;
// match this RGB to some code
$this->name = Colors::matchRGB($this->RGB);
// get the nearest ANSI Code
$this->ANSICode = Colors::getANSICode($this->name);
// get the nearest XTerm code
$this->XTermCode = Colors::getXTermCode($this->name);
}
}
// null was passed in
} else {
// set the color to be empty
$this->setEmpty();
}
} | php | public function setColor($color) {
// if null is passed in, then just leave everything null
if (!is_null($color)) {
// if it an instance of another color
if ($color instanceof ColorInterface) {
// save the name
$this->name = $color->getName();
// save the xterm code
$this->XTermCode = $color->getXTermCode();
// save the RGB
$this->RGB = $color->getRGB();
// save the ansi code
$this->ANSICode = $color->getANSICode();
// if it is string, then it is a color name (maybe)
} else if (is_string($color)) {
if (Colors::isValidColorName($color)) {
$this->name = Colors::stripName($color);
// get the code for that name
$this->XTermCode = Colors::getXTermCode($this->name);
// save the RGB
$this->RGB = Colors::getRGB($this->name);
// get the ANSI code
$this->ANSICode = Colors::getANSICode($this->name);
}
// if it is an integer, then it is likely a xterm code
} else if (is_int($color)) {
// if it is between 0 and 255
if ($color >= 0 && $color <= 255) {
// save this code
$this->XTermCode = $color;
// get the RGB for it
$this->name = Colors::getColorIndexForXTermCode($this->XTermCode);
// get the RGB
$this->RGB = Colors::getRGB($this->name);
// get the ANSI Code
$this->ANSICode = Colors::getANSICode($this->name);
}
// if it is an RGB array
} else if (is_array($color)) {
// there must be three items in the array
if (count($color) === 3) {
// save the RGB
$this->RGB = $color;
// match this RGB to some code
$this->name = Colors::matchRGB($this->RGB);
// get the nearest ANSI Code
$this->ANSICode = Colors::getANSICode($this->name);
// get the nearest XTerm code
$this->XTermCode = Colors::getXTermCode($this->name);
}
}
// null was passed in
} else {
// set the color to be empty
$this->setEmpty();
}
} | [
"public",
"function",
"setColor",
"(",
"$",
"color",
")",
"{",
"// if null is passed in, then just leave everything null",
"if",
"(",
"!",
"is_null",
"(",
"$",
"color",
")",
")",
"{",
"// if it an instance of another color",
"if",
"(",
"$",
"color",
"instanceof",
"ColorInterface",
")",
"{",
"// save the name",
"$",
"this",
"->",
"name",
"=",
"$",
"color",
"->",
"getName",
"(",
")",
";",
"// save the xterm code",
"$",
"this",
"->",
"XTermCode",
"=",
"$",
"color",
"->",
"getXTermCode",
"(",
")",
";",
"// save the RGB",
"$",
"this",
"->",
"RGB",
"=",
"$",
"color",
"->",
"getRGB",
"(",
")",
";",
"// save the ansi code",
"$",
"this",
"->",
"ANSICode",
"=",
"$",
"color",
"->",
"getANSICode",
"(",
")",
";",
"// if it is string, then it is a color name (maybe)",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"color",
")",
")",
"{",
"if",
"(",
"Colors",
"::",
"isValidColorName",
"(",
"$",
"color",
")",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"Colors",
"::",
"stripName",
"(",
"$",
"color",
")",
";",
"// get the code for that name",
"$",
"this",
"->",
"XTermCode",
"=",
"Colors",
"::",
"getXTermCode",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// save the RGB",
"$",
"this",
"->",
"RGB",
"=",
"Colors",
"::",
"getRGB",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// get the ANSI code",
"$",
"this",
"->",
"ANSICode",
"=",
"Colors",
"::",
"getANSICode",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"// if it is an integer, then it is likely a xterm code",
"}",
"else",
"if",
"(",
"is_int",
"(",
"$",
"color",
")",
")",
"{",
"// if it is between 0 and 255",
"if",
"(",
"$",
"color",
">=",
"0",
"&&",
"$",
"color",
"<=",
"255",
")",
"{",
"// save this code",
"$",
"this",
"->",
"XTermCode",
"=",
"$",
"color",
";",
"// get the RGB for it",
"$",
"this",
"->",
"name",
"=",
"Colors",
"::",
"getColorIndexForXTermCode",
"(",
"$",
"this",
"->",
"XTermCode",
")",
";",
"// get the RGB",
"$",
"this",
"->",
"RGB",
"=",
"Colors",
"::",
"getRGB",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// get the ANSI Code",
"$",
"this",
"->",
"ANSICode",
"=",
"Colors",
"::",
"getANSICode",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"// if it is an RGB array",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"color",
")",
")",
"{",
"// there must be three items in the array",
"if",
"(",
"count",
"(",
"$",
"color",
")",
"===",
"3",
")",
"{",
"// save the RGB",
"$",
"this",
"->",
"RGB",
"=",
"$",
"color",
";",
"// match this RGB to some code",
"$",
"this",
"->",
"name",
"=",
"Colors",
"::",
"matchRGB",
"(",
"$",
"this",
"->",
"RGB",
")",
";",
"// get the nearest ANSI Code",
"$",
"this",
"->",
"ANSICode",
"=",
"Colors",
"::",
"getANSICode",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// get the nearest XTerm code",
"$",
"this",
"->",
"XTermCode",
"=",
"Colors",
"::",
"getXTermCode",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"}",
"// null was passed in",
"}",
"else",
"{",
"// set the color to be empty",
"$",
"this",
"->",
"setEmpty",
"(",
")",
";",
"}",
"}"
] | The variety of ways to set a color
@param ColorInterface | string | integer | int[] $color - Many options for initializing a color object - SEE CONSTRUCTOR | [
"The",
"variety",
"of",
"ways",
"to",
"set",
"a",
"color"
] | 3a550eadb21bb87a6909436c3b961919d2731923 | https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/Color/Color.php#L249-L333 | train |
1HappyPlace/ansi-terminal | src/ANSI/Color/Color.php | Color.generateColorCoding | public function generateColorCoding($mode, $isFill = false) {
// initialize the returned code
$codes = "";
// ensure the color has a value
if ($this->isValid()) {
// cast the mode into the class
$mode = new Mode($mode);
// generally you add 10 to escape numbers to switch to fill
$base = 0;
// if is fill
if ($isFill) {
// use a base of 10
$base = 10;
}
// go through the different terminal modes
switch ($mode->getMode()) {
// legacy mode, uses straight-up ansi codes
case Mode::VT100:
// return the coding for old style color (and make it a string like the rest)
$codes = ($base + $this->getANSICode()) . "";
break;
// Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers
case Mode::RGB:
// get the [R,G,B]
$RGB = $this->getRGB();
// return the full RGB coding
$codes =($base + 38) . ";2;" . $RGB[0] . ";" . $RGB[1] . ";" . $RGB[2];
break;
// Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors
case Mode::XTERM:
// return the coding for xterm colors
$codes = ($base + 38) . ";5;" . $this->getXTermCode();
break;
}
}
// return the sequence
return $codes;
} | php | public function generateColorCoding($mode, $isFill = false) {
// initialize the returned code
$codes = "";
// ensure the color has a value
if ($this->isValid()) {
// cast the mode into the class
$mode = new Mode($mode);
// generally you add 10 to escape numbers to switch to fill
$base = 0;
// if is fill
if ($isFill) {
// use a base of 10
$base = 10;
}
// go through the different terminal modes
switch ($mode->getMode()) {
// legacy mode, uses straight-up ansi codes
case Mode::VT100:
// return the coding for old style color (and make it a string like the rest)
$codes = ($base + $this->getANSICode()) . "";
break;
// Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers
case Mode::RGB:
// get the [R,G,B]
$RGB = $this->getRGB();
// return the full RGB coding
$codes =($base + 38) . ";2;" . $RGB[0] . ";" . $RGB[1] . ";" . $RGB[2];
break;
// Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors
case Mode::XTERM:
// return the coding for xterm colors
$codes = ($base + 38) . ";5;" . $this->getXTermCode();
break;
}
}
// return the sequence
return $codes;
} | [
"public",
"function",
"generateColorCoding",
"(",
"$",
"mode",
",",
"$",
"isFill",
"=",
"false",
")",
"{",
"// initialize the returned code",
"$",
"codes",
"=",
"\"\"",
";",
"// ensure the color has a value",
"if",
"(",
"$",
"this",
"->",
"isValid",
"(",
")",
")",
"{",
"// cast the mode into the class ",
"$",
"mode",
"=",
"new",
"Mode",
"(",
"$",
"mode",
")",
";",
"// generally you add 10 to escape numbers to switch to fill",
"$",
"base",
"=",
"0",
";",
"// if is fill",
"if",
"(",
"$",
"isFill",
")",
"{",
"// use a base of 10",
"$",
"base",
"=",
"10",
";",
"}",
"// go through the different terminal modes",
"switch",
"(",
"$",
"mode",
"->",
"getMode",
"(",
")",
")",
"{",
"// legacy mode, uses straight-up ansi codes",
"case",
"Mode",
"::",
"VT100",
":",
"// return the coding for old style color (and make it a string like the rest)",
"$",
"codes",
"=",
"(",
"$",
"base",
"+",
"$",
"this",
"->",
"getANSICode",
"(",
")",
")",
".",
"\"\"",
";",
"break",
";",
"// Full RGB color, starts with 38;2 for text, or 48;2 for fill followed by R;G;B numbers",
"case",
"Mode",
"::",
"RGB",
":",
"// get the [R,G,B]",
"$",
"RGB",
"=",
"$",
"this",
"->",
"getRGB",
"(",
")",
";",
"// return the full RGB coding",
"$",
"codes",
"=",
"(",
"$",
"base",
"+",
"38",
")",
".",
"\";2;\"",
".",
"$",
"RGB",
"[",
"0",
"]",
".",
"\";\"",
".",
"$",
"RGB",
"[",
"1",
"]",
".",
"\";\"",
".",
"$",
"RGB",
"[",
"2",
"]",
";",
"break",
";",
"// Xterm codes, start with 38;5 for text and 48;5 for fill followed by a number from 0-255 for different colors",
"case",
"Mode",
"::",
"XTERM",
":",
"// return the coding for xterm colors",
"$",
"codes",
"=",
"(",
"$",
"base",
"+",
"38",
")",
".",
"\";5;\"",
".",
"$",
"this",
"->",
"getXTermCode",
"(",
")",
";",
"break",
";",
"}",
"}",
"// return the sequence",
"return",
"$",
"codes",
";",
"}"
] | Generate a color coding based on the terminal type
@param Mode | int | string $mode
Mode
send in a Mode object built already
integer -
send in the desired number of colors to pick the closest mode (<16 for VT100, >16 and <256 for xterm and > 256 for RGB)
string -
send in one of the constants Mode::VT100, Mode::XTERM, or Mode::RGB
send in one of the actual string values for the constants (case insensitive) "vt100", "RGB", "xterm"
@param boolean $isFill - whether the color is a fill
@return string | [
"Generate",
"a",
"color",
"coding",
"based",
"on",
"the",
"terminal",
"type"
] | 3a550eadb21bb87a6909436c3b961919d2731923 | https://github.com/1HappyPlace/ansi-terminal/blob/3a550eadb21bb87a6909436c3b961919d2731923/src/ANSI/Color/Color.php#L478-L533 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.