repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.get_plugin_view
|
public function get_plugin_view(string $path, string $mode, array $data, string $plugin){
if ( !router::is_mode($mode) ){
die("Incorrect mode $path $mode");
}
if (
($name = $this->plugin_name($plugin)) &&
($file = $this->router->route($path, $mode, BBN_APP_PATH.'plugins/'.$name.'/'.$mode.'/'))
){
$view = new mvc\view($file);
if ( $view->check() ){
return \is_array($data) ? $view->get($data) : $view->get();
}
return '';
}
}
|
php
|
public function get_plugin_view(string $path, string $mode, array $data, string $plugin){
if ( !router::is_mode($mode) ){
die("Incorrect mode $path $mode");
}
if (
($name = $this->plugin_name($plugin)) &&
($file = $this->router->route($path, $mode, BBN_APP_PATH.'plugins/'.$name.'/'.$mode.'/'))
){
$view = new mvc\view($file);
if ( $view->check() ){
return \is_array($data) ? $view->get($data) : $view->get();
}
return '';
}
}
|
[
"public",
"function",
"get_plugin_view",
"(",
"string",
"$",
"path",
",",
"string",
"$",
"mode",
",",
"array",
"$",
"data",
",",
"string",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"router",
"::",
"is_mode",
"(",
"$",
"mode",
")",
")",
"{",
"die",
"(",
"\"Incorrect mode $path $mode\"",
")",
";",
"}",
"if",
"(",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"plugin_name",
"(",
"$",
"plugin",
")",
")",
"&&",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"router",
"->",
"route",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"BBN_APP_PATH",
".",
"'plugins/'",
".",
"$",
"name",
".",
"'/'",
".",
"$",
"mode",
".",
"'/'",
")",
")",
")",
"{",
"$",
"view",
"=",
"new",
"mvc",
"\\",
"view",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"view",
"->",
"check",
"(",
")",
")",
"{",
"return",
"\\",
"is_array",
"(",
"$",
"data",
")",
"?",
"$",
"view",
"->",
"get",
"(",
"$",
"data",
")",
":",
"$",
"view",
"->",
"get",
"(",
")",
";",
"}",
"return",
"''",
";",
"}",
"}"
] |
This will get a view.
@param string $path
@param string $mode
@param array $data
@param string $plugin
@return string|false
|
[
"This",
"will",
"get",
"a",
"view",
"."
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L514-L528
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.get_model
|
public function get_model($path, array $data, mvc\controller $ctrl){
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->get($data);
}
return [];
}
|
php
|
public function get_model($path, array $data, mvc\controller $ctrl){
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->get($data);
}
return [];
}
|
[
"public",
"function",
"get_model",
"(",
"$",
"path",
",",
"array",
"$",
"data",
",",
"mvc",
"\\",
"controller",
"$",
"ctrl",
")",
"{",
"if",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"router",
"->",
"route",
"(",
"$",
"path",
",",
"'model'",
")",
")",
"{",
"$",
"model",
"=",
"new",
"mvc",
"\\",
"model",
"(",
"$",
"this",
"->",
"db",
",",
"$",
"route",
",",
"$",
"ctrl",
",",
"$",
"this",
")",
";",
"return",
"$",
"model",
"->",
"get",
"(",
"$",
"data",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
This will get the model. There is no order for the arguments.
@params string path to the model
@params array data to send to the model
@return array|false A data model
|
[
"This",
"will",
"get",
"the",
"model",
".",
"There",
"is",
"no",
"order",
"for",
"the",
"arguments",
"."
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L537-L543
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.get_cached_model
|
public function get_cached_model($path, array $data, mvc\controller $ctrl, $ttl = 10){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->get_from_cache($data, '', $ttl);
}
return [];
}
|
php
|
public function get_cached_model($path, array $data, mvc\controller $ctrl, $ttl = 10){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->get_from_cache($data, '', $ttl);
}
return [];
}
|
[
"public",
"function",
"get_cached_model",
"(",
"$",
"path",
",",
"array",
"$",
"data",
",",
"mvc",
"\\",
"controller",
"$",
"ctrl",
",",
"$",
"ttl",
"=",
"10",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"if",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"router",
"->",
"route",
"(",
"$",
"path",
",",
"'model'",
")",
")",
"{",
"$",
"model",
"=",
"new",
"mvc",
"\\",
"model",
"(",
"$",
"this",
"->",
"db",
",",
"$",
"route",
",",
"$",
"ctrl",
",",
"$",
"this",
")",
";",
"return",
"$",
"model",
"->",
"get_from_cache",
"(",
"$",
"data",
",",
"''",
",",
"$",
"ttl",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
This will get the model as it is in cache if any and otherwise will save it in cache then return it
@params string path to the model
@params array data to send to the model
@return array|false A data model
|
[
"This",
"will",
"get",
"the",
"model",
"as",
"it",
"is",
"in",
"cache",
"if",
"any",
"and",
"otherwise",
"will",
"save",
"it",
"in",
"cache",
"then",
"return",
"it"
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L561-L570
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.set_cached_model
|
public function set_cached_model($path, array $data, mvc\controller $ctrl, $ttl = 10){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->set_cache($data, '', $ttl);
}
return [];
}
|
php
|
public function set_cached_model($path, array $data, mvc\controller $ctrl, $ttl = 10){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->set_cache($data, '', $ttl);
}
return [];
}
|
[
"public",
"function",
"set_cached_model",
"(",
"$",
"path",
",",
"array",
"$",
"data",
",",
"mvc",
"\\",
"controller",
"$",
"ctrl",
",",
"$",
"ttl",
"=",
"10",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"if",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"router",
"->",
"route",
"(",
"$",
"path",
",",
"'model'",
")",
")",
"{",
"$",
"model",
"=",
"new",
"mvc",
"\\",
"model",
"(",
"$",
"this",
"->",
"db",
",",
"$",
"route",
",",
"$",
"ctrl",
",",
"$",
"this",
")",
";",
"return",
"$",
"model",
"->",
"set_cache",
"(",
"$",
"data",
",",
"''",
",",
"$",
"ttl",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
This will set the model in cache
@params string path to the model
@params array data to send to the model
@return array|false A data model
|
[
"This",
"will",
"set",
"the",
"model",
"in",
"cache"
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L579-L588
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.delete_cached_model
|
public function delete_cached_model($path, array $data, mvc\controller $ctrl){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->delete_cache($data, '');
}
return [];
}
|
php
|
public function delete_cached_model($path, array $data, mvc\controller $ctrl){
if ( \is_null($data) ){
$data = $this->data;
}
if ( $route = $this->router->route($path, 'model') ){
$model = new mvc\model($this->db, $route, $ctrl, $this);
return $model->delete_cache($data, '');
}
return [];
}
|
[
"public",
"function",
"delete_cached_model",
"(",
"$",
"path",
",",
"array",
"$",
"data",
",",
"mvc",
"\\",
"controller",
"$",
"ctrl",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"if",
"(",
"$",
"route",
"=",
"$",
"this",
"->",
"router",
"->",
"route",
"(",
"$",
"path",
",",
"'model'",
")",
")",
"{",
"$",
"model",
"=",
"new",
"mvc",
"\\",
"model",
"(",
"$",
"this",
"->",
"db",
",",
"$",
"route",
",",
"$",
"ctrl",
",",
"$",
"this",
")",
";",
"return",
"$",
"model",
"->",
"delete_cache",
"(",
"$",
"data",
",",
"''",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
This will unset the model in cache
@params string path to the model
@params array data to send to the model
@return array|false A data model
|
[
"This",
"will",
"unset",
"the",
"model",
"in",
"cache"
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L598-L607
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.add_inc
|
public function add_inc($name, $obj){
if ( !isset($this->inc->{$name}) ){
$this->inc->{$name} = $obj;
}
}
|
php
|
public function add_inc($name, $obj){
if ( !isset($this->inc->{$name}) ){
$this->inc->{$name} = $obj;
}
}
|
[
"public",
"function",
"add_inc",
"(",
"$",
"name",
",",
"$",
"obj",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"inc",
"->",
"{",
"$",
"name",
"}",
")",
")",
"{",
"$",
"this",
"->",
"inc",
"->",
"{",
"$",
"name",
"}",
"=",
"$",
"obj",
";",
"}",
"}"
] |
Adds a property to the MVC object inc if it has not been declared.
@return bool
|
[
"Adds",
"a",
"property",
"to",
"the",
"MVC",
"object",
"inc",
"if",
"it",
"has",
"not",
"been",
"declared",
"."
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L614-L618
|
nabab/bbn
|
src/bbn/mvc.php
|
mvc.process
|
public function process(){
if ( $this->check() ){
$this->obj = new \stdClass();
if ( !\is_array($this->info)){
$this->log("No info in MVC", $this->info);
die("No info in MVC");
}
if ( !$this->controller ){
$this->controller = new mvc\controller($this, $this->info, $this->data, $this->obj);
}
$this->controller->process();
}
}
|
php
|
public function process(){
if ( $this->check() ){
$this->obj = new \stdClass();
if ( !\is_array($this->info)){
$this->log("No info in MVC", $this->info);
die("No info in MVC");
}
if ( !$this->controller ){
$this->controller = new mvc\controller($this, $this->info, $this->data, $this->obj);
}
$this->controller->process();
}
}
|
[
"public",
"function",
"process",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"check",
"(",
")",
")",
"{",
"$",
"this",
"->",
"obj",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"info",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"No info in MVC\"",
",",
"$",
"this",
"->",
"info",
")",
";",
"die",
"(",
"\"No info in MVC\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"controller",
")",
"{",
"$",
"this",
"->",
"controller",
"=",
"new",
"mvc",
"\\",
"controller",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"info",
",",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"obj",
")",
";",
"}",
"$",
"this",
"->",
"controller",
"->",
"process",
"(",
")",
";",
"}",
"}"
] |
Returns the rendered result from the current mvc if successufully processed
process() (or check()) must have been called before.
@return string|false
|
[
"Returns",
"the",
"rendered",
"result",
"from",
"the",
"current",
"mvc",
"if",
"successufully",
"processed",
"process",
"()",
"(",
"or",
"check",
"()",
")",
"must",
"have",
"been",
"called",
"before",
"."
] |
train
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc.php#L626-L638
|
mvccore/ext-router-module
|
src/MvcCore/Ext/Routers/Module/UrlByQuery.php
|
UrlByQuery.UrlByQueryString
|
public function UrlByQueryString ($controllerActionOrRouteName = 'Index:Index', array & $params = [], $givenRouteName = NULL) {
if ($givenRouteName == 'self') {
$params = array_merge($this->requestedParams ?: [], $params);
if ($controllerActionOrRouteName === static::DEFAULT_ROUTE_NAME && isset($params[static::URL_PARAM_PATH]))
unset($params[static::URL_PARAM_PATH]);
}
list($targetModule, $targetDomainRoute, $domainParamsDefault) = $this->urlGetDomainRouteAndDefaultDomainParams(
$params, isset($params[static::URL_PARAM_MODULE]), $this->currentDomainRoute !== NULL
);
if ($targetModule !== NULL) {
$domainUrlBaseSection = $this->urlGetDomainUrlAndClasifyParamsAndDomainParams(
$params, $domainParamsDefault, $targetDomainRoute
);
list($ctrlPc, $actionPc) = $this->urlByQueryStringCompleteCtrlAction(
$controllerActionOrRouteName, $params
);
$absolute = $this->urlGetAbsoluteParam($params);
$result = $this->urlByQueryStringCompleteResult(
$ctrlPc, $actionPc, $params
);
if ($domainUrlBaseSection !== NULL) {
$result = $domainUrlBaseSection . $result;
} else {
$result = $this->request->GetBasePath() . $result;
if ($absolute)
$result = $this->request->GetDomainUrl() . $result;
}
return $result;
} else {
return parent::UrlByQueryString($controllerActionOrRouteName, $params, $givenRouteName);
}
}
|
php
|
public function UrlByQueryString ($controllerActionOrRouteName = 'Index:Index', array & $params = [], $givenRouteName = NULL) {
if ($givenRouteName == 'self') {
$params = array_merge($this->requestedParams ?: [], $params);
if ($controllerActionOrRouteName === static::DEFAULT_ROUTE_NAME && isset($params[static::URL_PARAM_PATH]))
unset($params[static::URL_PARAM_PATH]);
}
list($targetModule, $targetDomainRoute, $domainParamsDefault) = $this->urlGetDomainRouteAndDefaultDomainParams(
$params, isset($params[static::URL_PARAM_MODULE]), $this->currentDomainRoute !== NULL
);
if ($targetModule !== NULL) {
$domainUrlBaseSection = $this->urlGetDomainUrlAndClasifyParamsAndDomainParams(
$params, $domainParamsDefault, $targetDomainRoute
);
list($ctrlPc, $actionPc) = $this->urlByQueryStringCompleteCtrlAction(
$controllerActionOrRouteName, $params
);
$absolute = $this->urlGetAbsoluteParam($params);
$result = $this->urlByQueryStringCompleteResult(
$ctrlPc, $actionPc, $params
);
if ($domainUrlBaseSection !== NULL) {
$result = $domainUrlBaseSection . $result;
} else {
$result = $this->request->GetBasePath() . $result;
if ($absolute)
$result = $this->request->GetDomainUrl() . $result;
}
return $result;
} else {
return parent::UrlByQueryString($controllerActionOrRouteName, $params, $givenRouteName);
}
}
|
[
"public",
"function",
"UrlByQueryString",
"(",
"$",
"controllerActionOrRouteName",
"=",
"'Index:Index'",
",",
"array",
"&",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"givenRouteName",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"givenRouteName",
"==",
"'self'",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"requestedParams",
"?",
":",
"[",
"]",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"controllerActionOrRouteName",
"===",
"static",
"::",
"DEFAULT_ROUTE_NAME",
"&&",
"isset",
"(",
"$",
"params",
"[",
"static",
"::",
"URL_PARAM_PATH",
"]",
")",
")",
"unset",
"(",
"$",
"params",
"[",
"static",
"::",
"URL_PARAM_PATH",
"]",
")",
";",
"}",
"list",
"(",
"$",
"targetModule",
",",
"$",
"targetDomainRoute",
",",
"$",
"domainParamsDefault",
")",
"=",
"$",
"this",
"->",
"urlGetDomainRouteAndDefaultDomainParams",
"(",
"$",
"params",
",",
"isset",
"(",
"$",
"params",
"[",
"static",
"::",
"URL_PARAM_MODULE",
"]",
")",
",",
"$",
"this",
"->",
"currentDomainRoute",
"!==",
"NULL",
")",
";",
"if",
"(",
"$",
"targetModule",
"!==",
"NULL",
")",
"{",
"$",
"domainUrlBaseSection",
"=",
"$",
"this",
"->",
"urlGetDomainUrlAndClasifyParamsAndDomainParams",
"(",
"$",
"params",
",",
"$",
"domainParamsDefault",
",",
"$",
"targetDomainRoute",
")",
";",
"list",
"(",
"$",
"ctrlPc",
",",
"$",
"actionPc",
")",
"=",
"$",
"this",
"->",
"urlByQueryStringCompleteCtrlAction",
"(",
"$",
"controllerActionOrRouteName",
",",
"$",
"params",
")",
";",
"$",
"absolute",
"=",
"$",
"this",
"->",
"urlGetAbsoluteParam",
"(",
"$",
"params",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"urlByQueryStringCompleteResult",
"(",
"$",
"ctrlPc",
",",
"$",
"actionPc",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"domainUrlBaseSection",
"!==",
"NULL",
")",
"{",
"$",
"result",
"=",
"$",
"domainUrlBaseSection",
".",
"$",
"result",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"->",
"GetBasePath",
"(",
")",
".",
"$",
"result",
";",
"if",
"(",
"$",
"absolute",
")",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"->",
"GetDomainUrl",
"(",
")",
".",
"$",
"result",
";",
"}",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"return",
"parent",
"::",
"UrlByQueryString",
"(",
"$",
"controllerActionOrRouteName",
",",
"$",
"params",
",",
"$",
"givenRouteName",
")",
";",
"}",
"}"
] |
Complete relative (or absolute) URL with all params in query string. If
there is defined any target module in `$params`, absolute URL is returned.
Example: `"/application/base-bath/index.php?controller=ctrlName&action=actionName&name=cool-product-name&color=blue"`
@param string $controllerActionOrRouteName
@param array $params
@param string $givenRouteName
@return string
|
[
"Complete",
"relative",
"(",
"or",
"absolute",
")",
"URL",
"with",
"all",
"params",
"in",
"query",
"string",
".",
"If",
"there",
"is",
"defined",
"any",
"target",
"module",
"in",
"$params",
"absolute",
"URL",
"is",
"returned",
".",
"Example",
":",
"/",
"application",
"/",
"base",
"-",
"bath",
"/",
"index",
".",
"php?controller",
"=",
"ctrlName&",
";",
"action",
"=",
"actionName&",
";",
"name",
"=",
"cool",
"-",
"product",
"-",
"name&",
";",
"color",
"=",
"blue"
] |
train
|
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Module/UrlByQuery.php#L27-L66
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php
|
AssemblerAbstract.assembleDocBlock
|
protected function assembleDocBlock($docBlock, $target)
{
if (!$docBlock) {
return;
}
$target->setSummary($docBlock->getShortDescription());
$target->setDescription($docBlock->getLongDescription()->getContents());
/** @var DocBlock\Tag $tag */
foreach ($docBlock->getTags() as $tag) {
$tagDescriptor = $this->builder->buildDescriptor($tag);
// allow filtering of tags
if (!$tagDescriptor) {
continue;
}
$target->getTags()
->get($tag->getName(), new Collection())
->add($tagDescriptor);
}
}
|
php
|
protected function assembleDocBlock($docBlock, $target)
{
if (!$docBlock) {
return;
}
$target->setSummary($docBlock->getShortDescription());
$target->setDescription($docBlock->getLongDescription()->getContents());
/** @var DocBlock\Tag $tag */
foreach ($docBlock->getTags() as $tag) {
$tagDescriptor = $this->builder->buildDescriptor($tag);
// allow filtering of tags
if (!$tagDescriptor) {
continue;
}
$target->getTags()
->get($tag->getName(), new Collection())
->add($tagDescriptor);
}
}
|
[
"protected",
"function",
"assembleDocBlock",
"(",
"$",
"docBlock",
",",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"$",
"docBlock",
")",
"{",
"return",
";",
"}",
"$",
"target",
"->",
"setSummary",
"(",
"$",
"docBlock",
"->",
"getShortDescription",
"(",
")",
")",
";",
"$",
"target",
"->",
"setDescription",
"(",
"$",
"docBlock",
"->",
"getLongDescription",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"/** @var DocBlock\\Tag $tag */",
"foreach",
"(",
"$",
"docBlock",
"->",
"getTags",
"(",
")",
"as",
"$",
"tag",
")",
"{",
"$",
"tagDescriptor",
"=",
"$",
"this",
"->",
"builder",
"->",
"buildDescriptor",
"(",
"$",
"tag",
")",
";",
"// allow filtering of tags",
"if",
"(",
"!",
"$",
"tagDescriptor",
")",
"{",
"continue",
";",
"}",
"$",
"target",
"->",
"getTags",
"(",
")",
"->",
"get",
"(",
"$",
"tag",
"->",
"getName",
"(",
")",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"add",
"(",
"$",
"tagDescriptor",
")",
";",
"}",
"}"
] |
Assemble DocBlock.
@param DocBlock|null $docBlock
@param DescriptorAbstract $target
@return void
|
[
"Assemble",
"DocBlock",
"."
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php#L29-L51
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php
|
AssemblerAbstract.extractPackageFromDocBlock
|
protected function extractPackageFromDocBlock($docBlock)
{
$packageTags = $docBlock ? $docBlock->getTagsByName('package') : null;
if (! $packageTags) {
return null;
}
/** @var DocBlock\Tag $tag */
$tag = reset($packageTags);
return trim($tag->getContent());
}
|
php
|
protected function extractPackageFromDocBlock($docBlock)
{
$packageTags = $docBlock ? $docBlock->getTagsByName('package') : null;
if (! $packageTags) {
return null;
}
/** @var DocBlock\Tag $tag */
$tag = reset($packageTags);
return trim($tag->getContent());
}
|
[
"protected",
"function",
"extractPackageFromDocBlock",
"(",
"$",
"docBlock",
")",
"{",
"$",
"packageTags",
"=",
"$",
"docBlock",
"?",
"$",
"docBlock",
"->",
"getTagsByName",
"(",
"'package'",
")",
":",
"null",
";",
"if",
"(",
"!",
"$",
"packageTags",
")",
"{",
"return",
"null",
";",
"}",
"/** @var DocBlock\\Tag $tag */",
"$",
"tag",
"=",
"reset",
"(",
"$",
"packageTags",
")",
";",
"return",
"trim",
"(",
"$",
"tag",
"->",
"getContent",
"(",
")",
")",
";",
"}"
] |
Extracts the package from the DocBlock.
@param DocBlock $docBlock
@return string|null
|
[
"Extracts",
"the",
"package",
"from",
"the",
"DocBlock",
"."
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/AssemblerAbstract.php#L60-L71
|
eghojansu/moe
|
src/tools/Session.php
|
Session.read
|
function read($id) {
if ($id!=$this->sid)
$this->sid=$id;
return Cache::instance()->exists($id.'.@',$data)?$data['data']:FALSE;
}
|
php
|
function read($id) {
if ($id!=$this->sid)
$this->sid=$id;
return Cache::instance()->exists($id.'.@',$data)?$data['data']:FALSE;
}
|
[
"function",
"read",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"id",
"!=",
"$",
"this",
"->",
"sid",
")",
"$",
"this",
"->",
"sid",
"=",
"$",
"id",
";",
"return",
"Cache",
"::",
"instance",
"(",
")",
"->",
"exists",
"(",
"$",
"id",
".",
"'.@'",
",",
"$",
"data",
")",
"?",
"$",
"data",
"[",
"'data'",
"]",
":",
"FALSE",
";",
"}"
] |
Return session data in serialized format
@return string|FALSE
@param $id string
|
[
"Return",
"session",
"data",
"in",
"serialized",
"format"
] |
train
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Session.php#L38-L42
|
eghojansu/moe
|
src/tools/Session.php
|
Session.write
|
function write($id,$data) {
$fw=Base::instance();
$sent=headers_sent();
$headers=$fw->get('HEADERS');
$csrf=$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash(mt_rand());
$jar=$fw->get('JAR');
if ($id!=$this->sid)
$this->sid=$id;
Cache::instance()->set($id.'.@',
array(
'data'=>$data,
'csrf'=>$sent?$this->csrf():$csrf,
'ip'=>$fw->get('IP'),
'agent'=>isset($headers['User-Agent'])?
$headers['User-Agent']:'',
'stamp'=>time()
),
$jar['expire']?($jar['expire']-time()):0
);
return TRUE;
}
|
php
|
function write($id,$data) {
$fw=Base::instance();
$sent=headers_sent();
$headers=$fw->get('HEADERS');
$csrf=$fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'.
$fw->hash(mt_rand());
$jar=$fw->get('JAR');
if ($id!=$this->sid)
$this->sid=$id;
Cache::instance()->set($id.'.@',
array(
'data'=>$data,
'csrf'=>$sent?$this->csrf():$csrf,
'ip'=>$fw->get('IP'),
'agent'=>isset($headers['User-Agent'])?
$headers['User-Agent']:'',
'stamp'=>time()
),
$jar['expire']?($jar['expire']-time()):0
);
return TRUE;
}
|
[
"function",
"write",
"(",
"$",
"id",
",",
"$",
"data",
")",
"{",
"$",
"fw",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"$",
"sent",
"=",
"headers_sent",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"fw",
"->",
"get",
"(",
"'HEADERS'",
")",
";",
"$",
"csrf",
"=",
"$",
"fw",
"->",
"hash",
"(",
"$",
"fw",
"->",
"get",
"(",
"'ROOT'",
")",
".",
"$",
"fw",
"->",
"get",
"(",
"'BASE'",
")",
")",
".",
"'.'",
".",
"$",
"fw",
"->",
"hash",
"(",
"mt_rand",
"(",
")",
")",
";",
"$",
"jar",
"=",
"$",
"fw",
"->",
"get",
"(",
"'JAR'",
")",
";",
"if",
"(",
"$",
"id",
"!=",
"$",
"this",
"->",
"sid",
")",
"$",
"this",
"->",
"sid",
"=",
"$",
"id",
";",
"Cache",
"::",
"instance",
"(",
")",
"->",
"set",
"(",
"$",
"id",
".",
"'.@'",
",",
"array",
"(",
"'data'",
"=>",
"$",
"data",
",",
"'csrf'",
"=>",
"$",
"sent",
"?",
"$",
"this",
"->",
"csrf",
"(",
")",
":",
"$",
"csrf",
",",
"'ip'",
"=>",
"$",
"fw",
"->",
"get",
"(",
"'IP'",
")",
",",
"'agent'",
"=>",
"isset",
"(",
"$",
"headers",
"[",
"'User-Agent'",
"]",
")",
"?",
"$",
"headers",
"[",
"'User-Agent'",
"]",
":",
"''",
",",
"'stamp'",
"=>",
"time",
"(",
")",
")",
",",
"$",
"jar",
"[",
"'expire'",
"]",
"?",
"(",
"$",
"jar",
"[",
"'expire'",
"]",
"-",
"time",
"(",
")",
")",
":",
"0",
")",
";",
"return",
"TRUE",
";",
"}"
] |
Write session data
@return TRUE
@param $id string
@param $data string
|
[
"Write",
"session",
"data"
] |
train
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Session.php#L50-L71
|
eghojansu/moe
|
src/tools/Session.php
|
Session.destroy
|
function destroy($id) {
Cache::instance()->clear($id.'.@');
setcookie(session_name(),'',strtotime('-1 year'));
unset($_COOKIE[session_name()]);
header_remove('Set-Cookie');
return TRUE;
}
|
php
|
function destroy($id) {
Cache::instance()->clear($id.'.@');
setcookie(session_name(),'',strtotime('-1 year'));
unset($_COOKIE[session_name()]);
header_remove('Set-Cookie');
return TRUE;
}
|
[
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"Cache",
"::",
"instance",
"(",
")",
"->",
"clear",
"(",
"$",
"id",
".",
"'.@'",
")",
";",
"setcookie",
"(",
"session_name",
"(",
")",
",",
"''",
",",
"strtotime",
"(",
"'-1 year'",
")",
")",
";",
"unset",
"(",
"$",
"_COOKIE",
"[",
"session_name",
"(",
")",
"]",
")",
";",
"header_remove",
"(",
"'Set-Cookie'",
")",
";",
"return",
"TRUE",
";",
"}"
] |
Destroy session
@return TRUE
@param $id string
|
[
"Destroy",
"session"
] |
train
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Session.php#L78-L84
|
eghojansu/moe
|
src/tools/Session.php
|
Session.csrf
|
function csrf() {
return Cache::instance()->
exists(($this->sid?:session_id()).'.@',$data)?
$data['csrf']:FALSE;
}
|
php
|
function csrf() {
return Cache::instance()->
exists(($this->sid?:session_id()).'.@',$data)?
$data['csrf']:FALSE;
}
|
[
"function",
"csrf",
"(",
")",
"{",
"return",
"Cache",
"::",
"instance",
"(",
")",
"->",
"exists",
"(",
"(",
"$",
"this",
"->",
"sid",
"?",
":",
"session_id",
"(",
")",
")",
".",
"'.@'",
",",
"$",
"data",
")",
"?",
"$",
"data",
"[",
"'csrf'",
"]",
":",
"FALSE",
";",
"}"
] |
Return anti-CSRF token
@return string|FALSE
|
[
"Return",
"anti",
"-",
"CSRF",
"token"
] |
train
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Session.php#L100-L104
|
inhere/php-librarys
|
src/Components/Language.php
|
Language.init
|
protected function init()
{
$this->data = new Collection();
if ($this->defaultFile) {
$file = $this->buildLangFilePath($this->defaultFile . '.' . $this->format);
if (is_file($file)) {
$this->data->load($file, $this->format);
}
}
}
|
php
|
protected function init()
{
$this->data = new Collection();
if ($this->defaultFile) {
$file = $this->buildLangFilePath($this->defaultFile . '.' . $this->format);
if (is_file($file)) {
$this->data->load($file, $this->format);
}
}
}
|
[
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"new",
"Collection",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"defaultFile",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"buildLangFilePath",
"(",
"$",
"this",
"->",
"defaultFile",
".",
"'.'",
".",
"$",
"this",
"->",
"format",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"load",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"format",
")",
";",
"}",
"}",
"}"
] |
{@inheritDoc}
@throws \RangeException
|
[
"{"
] |
train
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/Language.php#L107-L118
|
inhere/php-librarys
|
src/Components/Language.php
|
Language.tl
|
public function tl($key, array $args = [], $lang = null)
{
return $this->translate($key, $args, $lang);
}
|
php
|
public function tl($key, array $args = [], $lang = null)
{
return $this->translate($key, $args, $lang);
}
|
[
"public",
"function",
"tl",
"(",
"$",
"key",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"translate",
"(",
"$",
"key",
",",
"$",
"args",
",",
"$",
"lang",
")",
";",
"}"
] |
{@inheritdoc}
@see self::translate()
@throws \InvalidArgumentException
@throws \Inhere\Exceptions\NotFoundException
|
[
"{"
] |
train
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/Language.php#L137-L140
|
inhere/php-librarys
|
src/Components/Language.php
|
Language.trans
|
public function trans($key, array $args = [], $lang = null)
{
return $this->translate($key, $args, $lang);
}
|
php
|
public function trans($key, array $args = [], $lang = null)
{
return $this->translate($key, $args, $lang);
}
|
[
"public",
"function",
"trans",
"(",
"$",
"key",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"lang",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"translate",
"(",
"$",
"key",
",",
"$",
"args",
",",
"$",
"lang",
")",
";",
"}"
] |
{@inheritdoc}
@see self::translate()
@throws \InvalidArgumentException
@throws \Inhere\Exceptions\NotFoundException
|
[
"{"
] |
train
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/Language.php#L148-L151
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.getFormView
|
public function getFormView(): FormView
{
if (!$this->formView) {
$this->formView = $this->getForm()->createView();
}
return $this->formView;
}
|
php
|
public function getFormView(): FormView
{
if (!$this->formView) {
$this->formView = $this->getForm()->createView();
}
return $this->formView;
}
|
[
"public",
"function",
"getFormView",
"(",
")",
":",
"FormView",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"formView",
")",
"{",
"$",
"this",
"->",
"formView",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"createView",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"formView",
";",
"}"
] |
@throws \LogicException
@return FormView
|
[
"@throws",
"\\",
"LogicException"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L330-L337
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.buildForm
|
public function buildForm(FormBuilderInterface $builder): FormInterface
{
$this->buildFilterActions($builder);
$this->buildDataGridActions($builder);
$this->form = $this->getQueryHandler()->buildForm($builder);
return $this->form;
}
|
php
|
public function buildForm(FormBuilderInterface $builder): FormInterface
{
$this->buildFilterActions($builder);
$this->buildDataGridActions($builder);
$this->form = $this->getQueryHandler()->buildForm($builder);
return $this->form;
}
|
[
"public",
"function",
"buildForm",
"(",
"FormBuilderInterface",
"$",
"builder",
")",
":",
"FormInterface",
"{",
"$",
"this",
"->",
"buildFilterActions",
"(",
"$",
"builder",
")",
";",
"$",
"this",
"->",
"buildDataGridActions",
"(",
"$",
"builder",
")",
";",
"$",
"this",
"->",
"form",
"=",
"$",
"this",
"->",
"getQueryHandler",
"(",
")",
"->",
"buildForm",
"(",
"$",
"builder",
")",
";",
"return",
"$",
"this",
"->",
"form",
";",
"}"
] |
@param FormBuilderInterface $builder
@throws \Exception
@return FormInterface
|
[
"@param",
"FormBuilderInterface",
"$builder"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L346-L354
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.setActionParameters
|
public function setActionParameters($action, array $parameters): void
{
if ('submit_button' === $action) {
$this->setSubmitButton(
array_merge(
$this->getSubmitButton(),
[
'route_parameters' => $parameters,
]
)
);
return;
}
if ('reset_button' === $action) {
$this->setResetButton(
array_merge(
$this->getResetButton(),
[
'route_parameters' => $parameters,
]
)
);
return;
}
$this->setAction(
$action,
array_merge(
$this->getAction($action),
[
'route_parameters' => $parameters,
]
)
);
}
|
php
|
public function setActionParameters($action, array $parameters): void
{
if ('submit_button' === $action) {
$this->setSubmitButton(
array_merge(
$this->getSubmitButton(),
[
'route_parameters' => $parameters,
]
)
);
return;
}
if ('reset_button' === $action) {
$this->setResetButton(
array_merge(
$this->getResetButton(),
[
'route_parameters' => $parameters,
]
)
);
return;
}
$this->setAction(
$action,
array_merge(
$this->getAction($action),
[
'route_parameters' => $parameters,
]
)
);
}
|
[
"public",
"function",
"setActionParameters",
"(",
"$",
"action",
",",
"array",
"$",
"parameters",
")",
":",
"void",
"{",
"if",
"(",
"'submit_button'",
"===",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"setSubmitButton",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getSubmitButton",
"(",
")",
",",
"[",
"'route_parameters'",
"=>",
"$",
"parameters",
",",
"]",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"'reset_button'",
"===",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"setResetButton",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getResetButton",
"(",
")",
",",
"[",
"'route_parameters'",
"=>",
"$",
"parameters",
",",
"]",
")",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"setAction",
"(",
"$",
"action",
",",
"array_merge",
"(",
"$",
"this",
"->",
"getAction",
"(",
"$",
"action",
")",
",",
"[",
"'route_parameters'",
"=>",
"$",
"parameters",
",",
"]",
")",
")",
";",
"}"
] |
@param string $action
@param array $parameters
@throws \UnexpectedValueException
|
[
"@param",
"string",
"$action",
"@param",
"array",
"$parameters"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L392-L427
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.buildFilterActions
|
protected function buildFilterActions(FormBuilderInterface $builder): void
{
$visibleFilterCount = 0;
foreach ($this->getQueryHandler()->getConfiguration()->getFilters() as $filter) {
$filter->getOption('hidden') ?: $visibleFilterCount++;
}
if ($visibleFilterCount > 0) {
$this->buildResetAction($builder);
$this->buildSubmitAction($builder);
}
}
|
php
|
protected function buildFilterActions(FormBuilderInterface $builder): void
{
$visibleFilterCount = 0;
foreach ($this->getQueryHandler()->getConfiguration()->getFilters() as $filter) {
$filter->getOption('hidden') ?: $visibleFilterCount++;
}
if ($visibleFilterCount > 0) {
$this->buildResetAction($builder);
$this->buildSubmitAction($builder);
}
}
|
[
"protected",
"function",
"buildFilterActions",
"(",
"FormBuilderInterface",
"$",
"builder",
")",
":",
"void",
"{",
"$",
"visibleFilterCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getQueryHandler",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getFilters",
"(",
")",
"as",
"$",
"filter",
")",
"{",
"$",
"filter",
"->",
"getOption",
"(",
"'hidden'",
")",
"?",
":",
"$",
"visibleFilterCount",
"++",
";",
"}",
"if",
"(",
"$",
"visibleFilterCount",
">",
"0",
")",
"{",
"$",
"this",
"->",
"buildResetAction",
"(",
"$",
"builder",
")",
";",
"$",
"this",
"->",
"buildSubmitAction",
"(",
"$",
"builder",
")",
";",
"}",
"}"
] |
@param FormBuilderInterface $builder
@throws \Exception
|
[
"@param",
"FormBuilderInterface",
"$builder"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L434-L444
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.buildResetAction
|
protected function buildResetAction(FormBuilderInterface $builder): void
{
$action = $builder->getOption('action');
$defaults = [
'form_type' => LinkType::class,
'label' => 'sidus.datagrid.reset.label',
'uri' => $action ?: '?',
];
$options = array_merge($defaults, $this->getResetButton());
$type = $options['form_type'];
unset($options['form_type']);
$builder->add('filterResetButton', $type, $options);
}
|
php
|
protected function buildResetAction(FormBuilderInterface $builder): void
{
$action = $builder->getOption('action');
$defaults = [
'form_type' => LinkType::class,
'label' => 'sidus.datagrid.reset.label',
'uri' => $action ?: '?',
];
$options = array_merge($defaults, $this->getResetButton());
$type = $options['form_type'];
unset($options['form_type']);
$builder->add('filterResetButton', $type, $options);
}
|
[
"protected",
"function",
"buildResetAction",
"(",
"FormBuilderInterface",
"$",
"builder",
")",
":",
"void",
"{",
"$",
"action",
"=",
"$",
"builder",
"->",
"getOption",
"(",
"'action'",
")",
";",
"$",
"defaults",
"=",
"[",
"'form_type'",
"=>",
"LinkType",
"::",
"class",
",",
"'label'",
"=>",
"'sidus.datagrid.reset.label'",
",",
"'uri'",
"=>",
"$",
"action",
"?",
":",
"'?'",
",",
"]",
";",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"this",
"->",
"getResetButton",
"(",
")",
")",
";",
"$",
"type",
"=",
"$",
"options",
"[",
"'form_type'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'form_type'",
"]",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'filterResetButton'",
",",
"$",
"type",
",",
"$",
"options",
")",
";",
"}"
] |
@param FormBuilderInterface $builder
@throws \Exception
|
[
"@param",
"FormBuilderInterface",
"$builder"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L451-L463
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.buildSubmitAction
|
protected function buildSubmitAction(FormBuilderInterface $builder): void
{
$defaults = [
'form_type' => SubmitType::class,
'label' => 'sidus.datagrid.submit.label',
'attr' => [
'class' => 'btn-primary',
],
];
$options = array_merge($defaults, $this->getSubmitButton());
$type = $options['form_type'];
unset($options['form_type']);
$builder->add('filterSubmitButton', $type, $options);
}
|
php
|
protected function buildSubmitAction(FormBuilderInterface $builder): void
{
$defaults = [
'form_type' => SubmitType::class,
'label' => 'sidus.datagrid.submit.label',
'attr' => [
'class' => 'btn-primary',
],
];
$options = array_merge($defaults, $this->getSubmitButton());
$type = $options['form_type'];
unset($options['form_type']);
$builder->add('filterSubmitButton', $type, $options);
}
|
[
"protected",
"function",
"buildSubmitAction",
"(",
"FormBuilderInterface",
"$",
"builder",
")",
":",
"void",
"{",
"$",
"defaults",
"=",
"[",
"'form_type'",
"=>",
"SubmitType",
"::",
"class",
",",
"'label'",
"=>",
"'sidus.datagrid.submit.label'",
",",
"'attr'",
"=>",
"[",
"'class'",
"=>",
"'btn-primary'",
",",
"]",
",",
"]",
";",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"this",
"->",
"getSubmitButton",
"(",
")",
")",
";",
"$",
"type",
"=",
"$",
"options",
"[",
"'form_type'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'form_type'",
"]",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'filterSubmitButton'",
",",
"$",
"type",
",",
"$",
"options",
")",
";",
"}"
] |
@param FormBuilderInterface $builder
@throws \Exception
|
[
"@param",
"FormBuilderInterface",
"$builder"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L470-L483
|
VincentChalnot/SidusDataGridBundle
|
Model/DataGrid.php
|
DataGrid.createColumn
|
protected function createColumn(string $key, array $columnConfiguration): void
{
$this->columns[] = new Column($key, $this, $columnConfiguration);
}
|
php
|
protected function createColumn(string $key, array $columnConfiguration): void
{
$this->columns[] = new Column($key, $this, $columnConfiguration);
}
|
[
"protected",
"function",
"createColumn",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"columnConfiguration",
")",
":",
"void",
"{",
"$",
"this",
"->",
"columns",
"[",
"]",
"=",
"new",
"Column",
"(",
"$",
"key",
",",
"$",
"this",
",",
"$",
"columnConfiguration",
")",
";",
"}"
] |
@param string $key
@param array $columnConfiguration
@throws \Symfony\Component\PropertyAccess\Exception\ExceptionInterface
|
[
"@param",
"string",
"$key",
"@param",
"array",
"$columnConfiguration"
] |
train
|
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/DataGrid.php#L511-L514
|
Danack/GithubArtaxService
|
lib/GithubService/GithubArtaxService/GithubService.php
|
GithubService.parseRateLimit
|
function parseRateLimit(Response $response) {
$newRateLimit = \GithubService\RateLimit::createFromResponse($response);
if ($newRateLimit != null) {
$this->rateLimit = $newRateLimit;
}
}
|
php
|
function parseRateLimit(Response $response) {
$newRateLimit = \GithubService\RateLimit::createFromResponse($response);
if ($newRateLimit != null) {
$this->rateLimit = $newRateLimit;
}
}
|
[
"function",
"parseRateLimit",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"newRateLimit",
"=",
"\\",
"GithubService",
"\\",
"RateLimit",
"::",
"createFromResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"newRateLimit",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"rateLimit",
"=",
"$",
"newRateLimit",
";",
"}",
"}"
] |
Try to get some rate limiting info from the response, and store it if it is
available.
@param Response $response
|
[
"Try",
"to",
"get",
"some",
"rate",
"limiting",
"info",
"from",
"the",
"response",
"and",
"store",
"it",
"if",
"it",
"is",
"available",
"."
] |
train
|
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubService.php#L144-L149
|
Danack/GithubArtaxService
|
lib/GithubService/GithubArtaxService/GithubService.php
|
GithubService.createOrRetrieveAuth
|
function createOrRetrieveAuth(
$username,
$password,
callable $enterPasswordCallback,
$scopes,
$note,
$noteURL = "http://www.github.com/danack/GithubArtaxService",
$maxAttempts = 3
) {
$basicToken = new BasicAuthToken($username, $password);
$otp = false;
for ($i = 0; $i < $maxAttempts; $i++) {
try {
$createAuthToken = $this->createAuthorization(
$basicToken->__toString(),
$scopes,
$note
);
$createAuthToken->setNote_url($noteURL);
if ($otp) {
$createAuthToken->setOtp($otp);
}
$authResult = $createAuthToken->execute();
return $authResult;
}
catch (OneTimePasswordAppException $otpae) {
$otp = $enterPasswordCallback(
"Please enter the code from your 2nd factor auth app:"
);
}
catch (OneTimePasswordSMSException $otse) {
$otp = $enterPasswordCallback(
"Please enter the code from the SMS Github should have sent you:"
);
}
}
throw new GithubArtaxServiceException("Failed to create or retrieve oauth token.");
}
|
php
|
function createOrRetrieveAuth(
$username,
$password,
callable $enterPasswordCallback,
$scopes,
$note,
$noteURL = "http://www.github.com/danack/GithubArtaxService",
$maxAttempts = 3
) {
$basicToken = new BasicAuthToken($username, $password);
$otp = false;
for ($i = 0; $i < $maxAttempts; $i++) {
try {
$createAuthToken = $this->createAuthorization(
$basicToken->__toString(),
$scopes,
$note
);
$createAuthToken->setNote_url($noteURL);
if ($otp) {
$createAuthToken->setOtp($otp);
}
$authResult = $createAuthToken->execute();
return $authResult;
}
catch (OneTimePasswordAppException $otpae) {
$otp = $enterPasswordCallback(
"Please enter the code from your 2nd factor auth app:"
);
}
catch (OneTimePasswordSMSException $otse) {
$otp = $enterPasswordCallback(
"Please enter the code from the SMS Github should have sent you:"
);
}
}
throw new GithubArtaxServiceException("Failed to create or retrieve oauth token.");
}
|
[
"function",
"createOrRetrieveAuth",
"(",
"$",
"username",
",",
"$",
"password",
",",
"callable",
"$",
"enterPasswordCallback",
",",
"$",
"scopes",
",",
"$",
"note",
",",
"$",
"noteURL",
"=",
"\"http://www.github.com/danack/GithubArtaxService\"",
",",
"$",
"maxAttempts",
"=",
"3",
")",
"{",
"$",
"basicToken",
"=",
"new",
"BasicAuthToken",
"(",
"$",
"username",
",",
"$",
"password",
")",
";",
"$",
"otp",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"maxAttempts",
";",
"$",
"i",
"++",
")",
"{",
"try",
"{",
"$",
"createAuthToken",
"=",
"$",
"this",
"->",
"createAuthorization",
"(",
"$",
"basicToken",
"->",
"__toString",
"(",
")",
",",
"$",
"scopes",
",",
"$",
"note",
")",
";",
"$",
"createAuthToken",
"->",
"setNote_url",
"(",
"$",
"noteURL",
")",
";",
"if",
"(",
"$",
"otp",
")",
"{",
"$",
"createAuthToken",
"->",
"setOtp",
"(",
"$",
"otp",
")",
";",
"}",
"$",
"authResult",
"=",
"$",
"createAuthToken",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"authResult",
";",
"}",
"catch",
"(",
"OneTimePasswordAppException",
"$",
"otpae",
")",
"{",
"$",
"otp",
"=",
"$",
"enterPasswordCallback",
"(",
"\"Please enter the code from your 2nd factor auth app:\"",
")",
";",
"}",
"catch",
"(",
"OneTimePasswordSMSException",
"$",
"otse",
")",
"{",
"$",
"otp",
"=",
"$",
"enterPasswordCallback",
"(",
"\"Please enter the code from the SMS Github should have sent you:\"",
")",
";",
"}",
"}",
"throw",
"new",
"GithubArtaxServiceException",
"(",
"\"Failed to create or retrieve oauth token.\"",
")",
";",
"}"
] |
Creates an Oauth token for a named application.
@param $username string The username to create the oauth token for
@param $password string The password of the user
@param $enterPasswordCallback callable A callback to get the one-time password
if the user has two factor auth enabled on their account.
@param $scopes array The scopes/permissions that the token should
have e.g. \GithubService\Github::SCOPE_USER_EMAIL and
https://developer.github.com/v3/oauth/#scopes
@param $applicationName string The name of the application
@param $noteURL string The URL of application i.e. where a user should go to
find help for the application.
@param $maxAttempts int The maximum number of attempts. This only allows retries
for the two-factor auth failing, not the password
@return \GithubService\Model\OauthAccess
|
[
"Creates",
"an",
"Oauth",
"token",
"for",
"a",
"named",
"application",
"."
] |
train
|
https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/GithubArtaxService/GithubService.php#L227-L268
|
highday/glitter
|
src/Services/Office/Finder/FinderGroup.php
|
FinderGroup.getFinder
|
public function getFinder(string $name)
{
return $this->first(function (FinderItem $item) use ($name) {
return $item->getName() === $name;
});
}
|
php
|
public function getFinder(string $name)
{
return $this->first(function (FinderItem $item) use ($name) {
return $item->getName() === $name;
});
}
|
[
"public",
"function",
"getFinder",
"(",
"string",
"$",
"name",
")",
"{",
"return",
"$",
"this",
"->",
"first",
"(",
"function",
"(",
"FinderItem",
"$",
"item",
")",
"use",
"(",
"$",
"name",
")",
"{",
"return",
"$",
"item",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
";",
"}",
")",
";",
"}"
] |
@param string $name
@return FinderItem|null
|
[
"@param",
"string",
"$name"
] |
train
|
https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Services/Office/Finder/FinderGroup.php#L19-L24
|
highday/glitter
|
src/Services/Office/Finder/FinderGroup.php
|
FinderGroup.factory
|
public static function factory(string $config)
{
return function (Application $app) use ($config) {
$collection = new FinderGroup($app->make('config')
->get($config));
$collection->transform(function (string $itemClass) {
return new $itemClass();
});
return $collection;
};
}
|
php
|
public static function factory(string $config)
{
return function (Application $app) use ($config) {
$collection = new FinderGroup($app->make('config')
->get($config));
$collection->transform(function (string $itemClass) {
return new $itemClass();
});
return $collection;
};
}
|
[
"public",
"static",
"function",
"factory",
"(",
"string",
"$",
"config",
")",
"{",
"return",
"function",
"(",
"Application",
"$",
"app",
")",
"use",
"(",
"$",
"config",
")",
"{",
"$",
"collection",
"=",
"new",
"FinderGroup",
"(",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"$",
"config",
")",
")",
";",
"$",
"collection",
"->",
"transform",
"(",
"function",
"(",
"string",
"$",
"itemClass",
")",
"{",
"return",
"new",
"$",
"itemClass",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"collection",
";",
"}",
";",
"}"
] |
@param string $config
@return \Closure
|
[
"@param",
"string",
"$config"
] |
train
|
https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Services/Office/Finder/FinderGroup.php#L41-L52
|
mothership-ec/composer
|
src/Composer/Downloader/PerforceDownloader.php
|
PerforceDownloader.getCommitLogs
|
protected function getCommitLogs($fromReference, $toReference, $path)
{
$commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference);
return $commitLogs;
}
|
php
|
protected function getCommitLogs($fromReference, $toReference, $path)
{
$commitLogs = $this->perforce->getCommitLogs($fromReference, $toReference);
return $commitLogs;
}
|
[
"protected",
"function",
"getCommitLogs",
"(",
"$",
"fromReference",
",",
"$",
"toReference",
",",
"$",
"path",
")",
"{",
"$",
"commitLogs",
"=",
"$",
"this",
"->",
"perforce",
"->",
"getCommitLogs",
"(",
"$",
"fromReference",
",",
"$",
"toReference",
")",
";",
"return",
"$",
"commitLogs",
";",
"}"
] |
{@inheritDoc}
|
[
"{"
] |
train
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/PerforceDownloader.php#L96-L101
|
silvercommerce/geozones
|
src/Forms/RegionSelectionField.php
|
RegionSelectionField.getSource
|
public function getSource()
{
$field = $this
->getForm()
->Fields()
->dataFieldByName($this->country_field);
if (empty($field) || empty($field->Value())) {
$locale = strtoupper(Locale::getRegion(i18n::get_locale()));
} else {
$locale = $field->Value();
}
return $this
->getList($locale)
->map("Code", "Name")
->toArray();
}
|
php
|
public function getSource()
{
$field = $this
->getForm()
->Fields()
->dataFieldByName($this->country_field);
if (empty($field) || empty($field->Value())) {
$locale = strtoupper(Locale::getRegion(i18n::get_locale()));
} else {
$locale = $field->Value();
}
return $this
->getList($locale)
->map("Code", "Name")
->toArray();
}
|
[
"public",
"function",
"getSource",
"(",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"Fields",
"(",
")",
"->",
"dataFieldByName",
"(",
"$",
"this",
"->",
"country_field",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"field",
")",
"||",
"empty",
"(",
"$",
"field",
"->",
"Value",
"(",
")",
")",
")",
"{",
"$",
"locale",
"=",
"strtoupper",
"(",
"Locale",
"::",
"getRegion",
"(",
"i18n",
"::",
"get_locale",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"locale",
"=",
"$",
"field",
"->",
"Value",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getList",
"(",
"$",
"locale",
")",
"->",
"map",
"(",
"\"Code\"",
",",
"\"Name\"",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Overwrite default get source to return
custom list of regions
@return array|ArrayAccess
|
[
"Overwrite",
"default",
"get",
"source",
"to",
"return",
"custom",
"list",
"of",
"regions"
] |
train
|
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Forms/RegionSelectionField.php#L65-L82
|
silvercommerce/geozones
|
src/Forms/RegionSelectionField.php
|
RegionSelectionField.Field
|
public function Field($properties = [])
{
Requirements::javascript("silvercommerce/geozones: client/dist/js/RegionSelectionField.min.js");
$country_field = $this->country_field;
// Get source based on selected country (or current/default locale)
$field = $this
->getForm()
->Fields()
->dataFieldByName($country_field);
// Add reference to base field
$this
->setAttribute("data-region-field", true)
->setAttribute("data-country-field", $field->ID())
->setAttribute("data-link", $this->Link("regionslist"));
if ($this->getHasEmptyDefault()) {
$this->setAttribute("data-empty-string", $this->getEmptyString());
}
return parent::Field($properties);
}
|
php
|
public function Field($properties = [])
{
Requirements::javascript("silvercommerce/geozones: client/dist/js/RegionSelectionField.min.js");
$country_field = $this->country_field;
// Get source based on selected country (or current/default locale)
$field = $this
->getForm()
->Fields()
->dataFieldByName($country_field);
// Add reference to base field
$this
->setAttribute("data-region-field", true)
->setAttribute("data-country-field", $field->ID())
->setAttribute("data-link", $this->Link("regionslist"));
if ($this->getHasEmptyDefault()) {
$this->setAttribute("data-empty-string", $this->getEmptyString());
}
return parent::Field($properties);
}
|
[
"public",
"function",
"Field",
"(",
"$",
"properties",
"=",
"[",
"]",
")",
"{",
"Requirements",
"::",
"javascript",
"(",
"\"silvercommerce/geozones: client/dist/js/RegionSelectionField.min.js\"",
")",
";",
"$",
"country_field",
"=",
"$",
"this",
"->",
"country_field",
";",
"// Get source based on selected country (or current/default locale)",
"$",
"field",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
"->",
"Fields",
"(",
")",
"->",
"dataFieldByName",
"(",
"$",
"country_field",
")",
";",
"// Add reference to base field",
"$",
"this",
"->",
"setAttribute",
"(",
"\"data-region-field\"",
",",
"true",
")",
"->",
"setAttribute",
"(",
"\"data-country-field\"",
",",
"$",
"field",
"->",
"ID",
"(",
")",
")",
"->",
"setAttribute",
"(",
"\"data-link\"",
",",
"$",
"this",
"->",
"Link",
"(",
"\"regionslist\"",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getHasEmptyDefault",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setAttribute",
"(",
"\"data-empty-string\"",
",",
"$",
"this",
"->",
"getEmptyString",
"(",
")",
")",
";",
"}",
"return",
"parent",
"::",
"Field",
"(",
"$",
"properties",
")",
";",
"}"
] |
Render the final field
|
[
"Render",
"the",
"final",
"field"
] |
train
|
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Forms/RegionSelectionField.php#L103-L126
|
silvercommerce/geozones
|
src/Forms/RegionSelectionField.php
|
RegionSelectionField.getList
|
public function getList($country)
{
$list = Region::get()
->filter("CountryCode", strtoupper($country));
if (!$list->exists() && $this->getCreateEmptyDefault()) {
$countries = i18n::getData()->getCountries();
if (isset($countries[strtolower($country)])) {
$name = $countries[strtolower($country)];
} else {
$name = $country;
}
$list = ArrayList::create();
$list->push(Region::create([
"Name" => $name,
"Type" => "Nation",
"Code" => strtoupper($country),
"CountryCode" => strtoupper($country)
]));
}
return $list;
}
|
php
|
public function getList($country)
{
$list = Region::get()
->filter("CountryCode", strtoupper($country));
if (!$list->exists() && $this->getCreateEmptyDefault()) {
$countries = i18n::getData()->getCountries();
if (isset($countries[strtolower($country)])) {
$name = $countries[strtolower($country)];
} else {
$name = $country;
}
$list = ArrayList::create();
$list->push(Region::create([
"Name" => $name,
"Type" => "Nation",
"Code" => strtoupper($country),
"CountryCode" => strtoupper($country)
]));
}
return $list;
}
|
[
"public",
"function",
"getList",
"(",
"$",
"country",
")",
"{",
"$",
"list",
"=",
"Region",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"\"CountryCode\"",
",",
"strtoupper",
"(",
"$",
"country",
")",
")",
";",
"if",
"(",
"!",
"$",
"list",
"->",
"exists",
"(",
")",
"&&",
"$",
"this",
"->",
"getCreateEmptyDefault",
"(",
")",
")",
"{",
"$",
"countries",
"=",
"i18n",
"::",
"getData",
"(",
")",
"->",
"getCountries",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"countries",
"[",
"strtolower",
"(",
"$",
"country",
")",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"countries",
"[",
"strtolower",
"(",
"$",
"country",
")",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"country",
";",
"}",
"$",
"list",
"=",
"ArrayList",
"::",
"create",
"(",
")",
";",
"$",
"list",
"->",
"push",
"(",
"Region",
"::",
"create",
"(",
"[",
"\"Name\"",
"=>",
"$",
"name",
",",
"\"Type\"",
"=>",
"\"Nation\"",
",",
"\"Code\"",
"=>",
"strtoupper",
"(",
"$",
"country",
")",
",",
"\"CountryCode\"",
"=>",
"strtoupper",
"(",
"$",
"country",
")",
"]",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
Get a list of regions, filtered by the provided country code
@return SSList
|
[
"Get",
"a",
"list",
"of",
"regions",
"filtered",
"by",
"the",
"provided",
"country",
"code"
] |
train
|
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Forms/RegionSelectionField.php#L133-L155
|
silvercommerce/geozones
|
src/Forms/RegionSelectionField.php
|
RegionSelectionField.regionslist
|
public function regionslist()
{
$id = $this->getRequest()->param("ID");
$data = $this->getList($id)->map("Code", "Name")->toArray();
return json_encode($data);
}
|
php
|
public function regionslist()
{
$id = $this->getRequest()->param("ID");
$data = $this->getList($id)->map("Code", "Name")->toArray();
return json_encode($data);
}
|
[
"public",
"function",
"regionslist",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"param",
"(",
"\"ID\"",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getList",
"(",
"$",
"id",
")",
"->",
"map",
"(",
"\"Code\"",
",",
"\"Name\"",
")",
"->",
"toArray",
"(",
")",
";",
"return",
"json_encode",
"(",
"$",
"data",
")",
";",
"}"
] |
Return a list of regions based on the supplied country ID
@return string
|
[
"Return",
"a",
"list",
"of",
"regions",
"based",
"on",
"the",
"supplied",
"country",
"ID"
] |
train
|
https://github.com/silvercommerce/geozones/blob/85af587805ae5cc6dce6a890ca04b338cf5552cb/src/Forms/RegionSelectionField.php#L162-L168
|
hametuha/wpametu
|
src/WPametu/Traits/Reflection.php
|
Reflection.is_sub_class_of
|
protected function is_sub_class_of($class_name, $should, $allow_abstract = false){
if( class_exists($class_name) ){
// Check if this is subclass
$refl = new \ReflectionClass($class_name);
return ( $allow_abstract || !$refl->isAbstract() ) && $refl->isSubclassOf($should);
}
return false;
}
|
php
|
protected function is_sub_class_of($class_name, $should, $allow_abstract = false){
if( class_exists($class_name) ){
// Check if this is subclass
$refl = new \ReflectionClass($class_name);
return ( $allow_abstract || !$refl->isAbstract() ) && $refl->isSubclassOf($should);
}
return false;
}
|
[
"protected",
"function",
"is_sub_class_of",
"(",
"$",
"class_name",
",",
"$",
"should",
",",
"$",
"allow_abstract",
"=",
"false",
")",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"class_name",
")",
")",
"{",
"// Check if this is subclass",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class_name",
")",
";",
"return",
"(",
"$",
"allow_abstract",
"||",
"!",
"$",
"refl",
"->",
"isAbstract",
"(",
")",
")",
"&&",
"$",
"refl",
"->",
"isSubclassOf",
"(",
"$",
"should",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Detect if specifies class is subclass
@param string $class_name
@param string $should Parent class name
@param bool $allow_abstract Default false
@return bool
|
[
"Detect",
"if",
"specifies",
"class",
"is",
"subclass"
] |
train
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Traits/Reflection.php#L46-L53
|
FriendsOfApi/phraseapp
|
src/Model/Translation/Key.php
|
Key.createFromArray
|
public static function createFromArray(array $data)
{
$self = new self();
if (isset($data['id'])) {
$self->setId($data['id']);
}
if (isset($data['name'])) {
$self->setName($data['name']);
}
if (isset($data['plural'])) {
$self->setPlural($data['plural']);
}
if (isset($data['data_type'])) {
$self->setDataType($data['data_type']);
}
if (isset($data['tags'])) {
$self->setTags($data['tags']);
}
return $self;
}
|
php
|
public static function createFromArray(array $data)
{
$self = new self();
if (isset($data['id'])) {
$self->setId($data['id']);
}
if (isset($data['name'])) {
$self->setName($data['name']);
}
if (isset($data['plural'])) {
$self->setPlural($data['plural']);
}
if (isset($data['data_type'])) {
$self->setDataType($data['data_type']);
}
if (isset($data['tags'])) {
$self->setTags($data['tags']);
}
return $self;
}
|
[
"public",
"static",
"function",
"createFromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"self",
"=",
"new",
"self",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setId",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setName",
"(",
"$",
"data",
"[",
"'name'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'plural'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setPlural",
"(",
"$",
"data",
"[",
"'plural'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'data_type'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setDataType",
"(",
"$",
"data",
"[",
"'data_type'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'tags'",
"]",
")",
")",
"{",
"$",
"self",
"->",
"setTags",
"(",
"$",
"data",
"[",
"'tags'",
"]",
")",
";",
"}",
"return",
"$",
"self",
";",
"}"
] |
@param array $data
@return Key
|
[
"@param",
"array",
"$data"
] |
train
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Model/Translation/Key.php#L49-L70
|
thupan/framework
|
src/Service/Request.php
|
Request.getData
|
protected static function getData($request, &$data = [], $upper = true)
{
if (!empty($request)) {
foreach ($request as $key => $value) {
if (empty($key)) {
continue;
}
if (self::$require) {
if (in_array($key, self::$require)) {
if (Validator::blank($value)) {
self::$error[] = $key;
}
}
}
if (strpos($key, '|')) {
$key = str_replace('|','.',$key);
}
if (!is_array($value)) {
$data[$key] = ($upper) ? mb_strtoupper(addslashes(trim($value)), 'UTF-8') : addslashes(trim($value));
} else {
$data[$key] = $value;
}
}
if ($request['request_data']) {
parse_str_to_array($request['request_data'], $data_rd);
foreach ($data_rd as $key => $value) {
if (empty($key)) {
continue;
}
if (strpos($key, '|')) {
$key = str_replace('|','.',$key);
}
if (!is_array($value)) {
$data_rd[$key] = ($upper) ? mb_strtoupper(addslashes(trim($value)), 'UTF-8') : addslashes(trim($value));
} else {
$data_rd[$key] = $value;
}
}
$data = array_merge($data, $data_rd);
unset($data['request_data']);
}
} else {
// nenhuma requisição passada sem nenhum retorno de dados.
return false;
}
// todo request foi verificado e teve retorno de dados.
return true;
}
|
php
|
protected static function getData($request, &$data = [], $upper = true)
{
if (!empty($request)) {
foreach ($request as $key => $value) {
if (empty($key)) {
continue;
}
if (self::$require) {
if (in_array($key, self::$require)) {
if (Validator::blank($value)) {
self::$error[] = $key;
}
}
}
if (strpos($key, '|')) {
$key = str_replace('|','.',$key);
}
if (!is_array($value)) {
$data[$key] = ($upper) ? mb_strtoupper(addslashes(trim($value)), 'UTF-8') : addslashes(trim($value));
} else {
$data[$key] = $value;
}
}
if ($request['request_data']) {
parse_str_to_array($request['request_data'], $data_rd);
foreach ($data_rd as $key => $value) {
if (empty($key)) {
continue;
}
if (strpos($key, '|')) {
$key = str_replace('|','.',$key);
}
if (!is_array($value)) {
$data_rd[$key] = ($upper) ? mb_strtoupper(addslashes(trim($value)), 'UTF-8') : addslashes(trim($value));
} else {
$data_rd[$key] = $value;
}
}
$data = array_merge($data, $data_rd);
unset($data['request_data']);
}
} else {
// nenhuma requisição passada sem nenhum retorno de dados.
return false;
}
// todo request foi verificado e teve retorno de dados.
return true;
}
|
[
"protected",
"static",
"function",
"getData",
"(",
"$",
"request",
",",
"&",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"upper",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"request",
")",
")",
"{",
"foreach",
"(",
"$",
"request",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"require",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"require",
")",
")",
"{",
"if",
"(",
"Validator",
"::",
"blank",
"(",
"$",
"value",
")",
")",
"{",
"self",
"::",
"$",
"error",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"}",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'|'",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"'|'",
",",
"'.'",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"(",
"$",
"upper",
")",
"?",
"mb_strtoupper",
"(",
"addslashes",
"(",
"trim",
"(",
"$",
"value",
")",
")",
",",
"'UTF-8'",
")",
":",
"addslashes",
"(",
"trim",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"if",
"(",
"$",
"request",
"[",
"'request_data'",
"]",
")",
"{",
"parse_str_to_array",
"(",
"$",
"request",
"[",
"'request_data'",
"]",
",",
"$",
"data_rd",
")",
";",
"foreach",
"(",
"$",
"data_rd",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'|'",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"'|'",
",",
"'.'",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data_rd",
"[",
"$",
"key",
"]",
"=",
"(",
"$",
"upper",
")",
"?",
"mb_strtoupper",
"(",
"addslashes",
"(",
"trim",
"(",
"$",
"value",
")",
")",
",",
"'UTF-8'",
")",
":",
"addslashes",
"(",
"trim",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"data_rd",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"$",
"data_rd",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"'request_data'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"// nenhuma requisição passada sem nenhum retorno de dados.",
"return",
"false",
";",
"}",
"// todo request foi verificado e teve retorno de dados.",
"return",
"true",
";",
"}"
] |
Método protegido que faz a validação das requisições.
@method getData()
@param Request
@param array
@param bool
@return bool
|
[
"Método",
"protegido",
"que",
"faz",
"a",
"validação",
"das",
"requisições",
"."
] |
train
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Request.php#L84-L141
|
thupan/framework
|
src/Service/Request.php
|
Request.clean
|
public static function clean($request = null)
{
switch ($request) {
case 'post':
unset($_POST);
break;
case 'get':
unset($_GET);
break;
case 'any':
unset($_REQUEST);
break;
default:
unset($_POST);
unset($_REQUEST);
unset($_GET);
}
}
|
php
|
public static function clean($request = null)
{
switch ($request) {
case 'post':
unset($_POST);
break;
case 'get':
unset($_GET);
break;
case 'any':
unset($_REQUEST);
break;
default:
unset($_POST);
unset($_REQUEST);
unset($_GET);
}
}
|
[
"public",
"static",
"function",
"clean",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"request",
")",
"{",
"case",
"'post'",
":",
"unset",
"(",
"$",
"_POST",
")",
";",
"break",
";",
"case",
"'get'",
":",
"unset",
"(",
"$",
"_GET",
")",
";",
"break",
";",
"case",
"'any'",
":",
"unset",
"(",
"$",
"_REQUEST",
")",
";",
"break",
";",
"default",
":",
"unset",
"(",
"$",
"_POST",
")",
";",
"unset",
"(",
"$",
"_REQUEST",
")",
";",
"unset",
"(",
"$",
"_GET",
")",
";",
"}",
"}"
] |
limpa toda requisicao passada
|
[
"limpa",
"toda",
"requisicao",
"passada"
] |
train
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/Request.php#L204-L224
|
Speicher210/monsum-api
|
src/Service/Invoice/InvoiceService.php
|
InvoiceService.getInvoices
|
public function getInvoices(Get\RequestData $requestData)
{
$request = new Get\Request($requestData);
$apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
/** @var Get\Response $response */
$response = $apiResponse->getResponse();
foreach ($response->getInvoices() as $invoice) {
$invoiceDate = $invoice->getInvoiceDate();
if ($invoiceDate !== null) {
$invoiceDate->setTime(0, 0, 0);
}
// We need to convert the due date to DateTime because of inconsistencies in the Monsum API response.
$dueDate = $invoice->getDueDate();
if ($dueDate !== null) {
$dueDate = new \DateTime($dueDate);
$dueDate->setTime(0, 0, 0);
$invoice->setDueDate($dueDate);
}
}
return $apiResponse;
}
|
php
|
public function getInvoices(Get\RequestData $requestData)
{
$request = new Get\Request($requestData);
$apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
/** @var Get\Response $response */
$response = $apiResponse->getResponse();
foreach ($response->getInvoices() as $invoice) {
$invoiceDate = $invoice->getInvoiceDate();
if ($invoiceDate !== null) {
$invoiceDate->setTime(0, 0, 0);
}
// We need to convert the due date to DateTime because of inconsistencies in the Monsum API response.
$dueDate = $invoice->getDueDate();
if ($dueDate !== null) {
$dueDate = new \DateTime($dueDate);
$dueDate->setTime(0, 0, 0);
$invoice->setDueDate($dueDate);
}
}
return $apiResponse;
}
|
[
"public",
"function",
"getInvoices",
"(",
"Get",
"\\",
"RequestData",
"$",
"requestData",
")",
"{",
"$",
"request",
"=",
"new",
"Get",
"\\",
"Request",
"(",
"$",
"requestData",
")",
";",
"$",
"apiResponse",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
",",
"Get",
"\\",
"ApiResponse",
"::",
"class",
")",
";",
"/** @var Get\\Response $response */",
"$",
"response",
"=",
"$",
"apiResponse",
"->",
"getResponse",
"(",
")",
";",
"foreach",
"(",
"$",
"response",
"->",
"getInvoices",
"(",
")",
"as",
"$",
"invoice",
")",
"{",
"$",
"invoiceDate",
"=",
"$",
"invoice",
"->",
"getInvoiceDate",
"(",
")",
";",
"if",
"(",
"$",
"invoiceDate",
"!==",
"null",
")",
"{",
"$",
"invoiceDate",
"->",
"setTime",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"}",
"// We need to convert the due date to DateTime because of inconsistencies in the Monsum API response.",
"$",
"dueDate",
"=",
"$",
"invoice",
"->",
"getDueDate",
"(",
")",
";",
"if",
"(",
"$",
"dueDate",
"!==",
"null",
")",
"{",
"$",
"dueDate",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"dueDate",
")",
";",
"$",
"dueDate",
"->",
"setTime",
"(",
"0",
",",
"0",
",",
"0",
")",
";",
"$",
"invoice",
"->",
"setDueDate",
"(",
"$",
"dueDate",
")",
";",
"}",
"}",
"return",
"$",
"apiResponse",
";",
"}"
] |
Get the invoices.
@param Get\RequestData $requestData The request data.
@return Get\ApiResponse
|
[
"Get",
"the",
"invoices",
"."
] |
train
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Invoice/InvoiceService.php#L18-L41
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/options/storage_memcache.php
|
ezcCacheStorageMemcacheOptions.__isset
|
public function __isset( $name )
{
return ( isset( $this->properties[$name] ) || isset( $this->storageOptions->$name ) );
}
|
php
|
public function __isset( $name )
{
return ( isset( $this->properties[$name] ) || isset( $this->storageOptions->$name ) );
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"name",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"name",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"storageOptions",
"->",
"$",
"name",
")",
")",
";",
"}"
] |
Returns if option $name is defined.
@param string $name Option name to check for
@return bool
@ignore
|
[
"Returns",
"if",
"option",
"$name",
"is",
"defined",
"."
] |
train
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/options/storage_memcache.php#L155-L158
|
wenbinye/PhalconX
|
src/Mvc/Auth.php
|
Auth.login
|
public function login($identity)
{
if ($this->needRegenerate) {
session_regenerate_id(true);
}
foreach ($identity as $name => $val) {
$this->sessionData[$name] = $val;
}
$lifetime = ini_get('session.cookie_lifetime');
$this->sessionData[self::REGENERATE_AFTER] = time() + $lifetime - min($lifetime*0.2, 300);
$this->getSession()->set($this->sessionKey, $this->sessionData);
}
|
php
|
public function login($identity)
{
if ($this->needRegenerate) {
session_regenerate_id(true);
}
foreach ($identity as $name => $val) {
$this->sessionData[$name] = $val;
}
$lifetime = ini_get('session.cookie_lifetime');
$this->sessionData[self::REGENERATE_AFTER] = time() + $lifetime - min($lifetime*0.2, 300);
$this->getSession()->set($this->sessionKey, $this->sessionData);
}
|
[
"public",
"function",
"login",
"(",
"$",
"identity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"needRegenerate",
")",
"{",
"session_regenerate_id",
"(",
"true",
")",
";",
"}",
"foreach",
"(",
"$",
"identity",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"sessionData",
"[",
"$",
"name",
"]",
"=",
"$",
"val",
";",
"}",
"$",
"lifetime",
"=",
"ini_get",
"(",
"'session.cookie_lifetime'",
")",
";",
"$",
"this",
"->",
"sessionData",
"[",
"self",
"::",
"REGENERATE_AFTER",
"]",
"=",
"time",
"(",
")",
"+",
"$",
"lifetime",
"-",
"min",
"(",
"$",
"lifetime",
"*",
"0.2",
",",
"300",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"sessionKey",
",",
"$",
"this",
"->",
"sessionData",
")",
";",
"}"
] |
用户登录操作
@param $identity 用户数据
|
[
"用户登录操作"
] |
train
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Auth.php#L82-L93
|
wenbinye/PhalconX
|
src/Mvc/Auth.php
|
Auth.logout
|
public function logout($destroySession = true)
{
if ($destroySession) {
$this->getSession()->destroy();
} else {
$this->getSession()->set($this->sessionKey, false);
}
$this->sessionData = false;
}
|
php
|
public function logout($destroySession = true)
{
if ($destroySession) {
$this->getSession()->destroy();
} else {
$this->getSession()->set($this->sessionKey, false);
}
$this->sessionData = false;
}
|
[
"public",
"function",
"logout",
"(",
"$",
"destroySession",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"destroySession",
")",
"{",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"destroy",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"sessionKey",
",",
"false",
")",
";",
"}",
"$",
"this",
"->",
"sessionData",
"=",
"false",
";",
"}"
] |
用户注销操作
|
[
"用户注销操作"
] |
train
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Mvc/Auth.php#L98-L106
|
InactiveProjects/limoncello-illuminate
|
app/Api/Policies/BasePolicy.php
|
BasePolicy.setRelationshipOnUpdate
|
public function setRelationshipOnUpdate(
AccountInterface $current,
Model $model,
$relationshipName,
$idx,
$relModelClass
) {
$current && $model && $relationshipName ?: null;
$isAllowed = true;
if ($idx !== null) {
// find model by id and check if it exists
/** @noinspection PhpUndefinedMethodInspection */
$relModel = $relModelClass::find($idx);
$isAllowed = $relModel !== null && $this->getGuard()->allows(self::CAN_READ, [$relModel]);
}
return $isAllowed;
}
|
php
|
public function setRelationshipOnUpdate(
AccountInterface $current,
Model $model,
$relationshipName,
$idx,
$relModelClass
) {
$current && $model && $relationshipName ?: null;
$isAllowed = true;
if ($idx !== null) {
// find model by id and check if it exists
/** @noinspection PhpUndefinedMethodInspection */
$relModel = $relModelClass::find($idx);
$isAllowed = $relModel !== null && $this->getGuard()->allows(self::CAN_READ, [$relModel]);
}
return $isAllowed;
}
|
[
"public",
"function",
"setRelationshipOnUpdate",
"(",
"AccountInterface",
"$",
"current",
",",
"Model",
"$",
"model",
",",
"$",
"relationshipName",
",",
"$",
"idx",
",",
"$",
"relModelClass",
")",
"{",
"$",
"current",
"&&",
"$",
"model",
"&&",
"$",
"relationshipName",
"?",
":",
"null",
";",
"$",
"isAllowed",
"=",
"true",
";",
"if",
"(",
"$",
"idx",
"!==",
"null",
")",
"{",
"// find model by id and check if it exists",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"relModel",
"=",
"$",
"relModelClass",
"::",
"find",
"(",
"$",
"idx",
")",
";",
"$",
"isAllowed",
"=",
"$",
"relModel",
"!==",
"null",
"&&",
"$",
"this",
"->",
"getGuard",
"(",
")",
"->",
"allows",
"(",
"self",
"::",
"CAN_READ",
",",
"[",
"$",
"relModel",
"]",
")",
";",
"}",
"return",
"$",
"isAllowed",
";",
"}"
] |
@param AccountInterface $current
@param Model $model
@param string $relationshipName
@param string $idx
@param string $relModelClass
@return bool
|
[
"@param",
"AccountInterface",
"$current",
"@param",
"Model",
"$model",
"@param",
"string",
"$relationshipName",
"@param",
"string",
"$idx",
"@param",
"string",
"$relModelClass"
] |
train
|
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/Policies/BasePolicy.php#L108-L126
|
InactiveProjects/limoncello-illuminate
|
app/Api/Policies/BasePolicy.php
|
BasePolicy.isAdmin
|
protected function isAdmin(AccountInterface $account)
{
/** @var Model $resource */
if ($this->isAuthenticated($account) === true) {
/** @var User $user */
$user = $account->user();
$isAdmin = $user->hasRole(Role::ENUM_ROLE_ADMIN_ID);
return $isAdmin;
}
return false;
}
|
php
|
protected function isAdmin(AccountInterface $account)
{
/** @var Model $resource */
if ($this->isAuthenticated($account) === true) {
/** @var User $user */
$user = $account->user();
$isAdmin = $user->hasRole(Role::ENUM_ROLE_ADMIN_ID);
return $isAdmin;
}
return false;
}
|
[
"protected",
"function",
"isAdmin",
"(",
"AccountInterface",
"$",
"account",
")",
"{",
"/** @var Model $resource */",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
"$",
"account",
")",
"===",
"true",
")",
"{",
"/** @var User $user */",
"$",
"user",
"=",
"$",
"account",
"->",
"user",
"(",
")",
";",
"$",
"isAdmin",
"=",
"$",
"user",
"->",
"hasRole",
"(",
"Role",
"::",
"ENUM_ROLE_ADMIN_ID",
")",
";",
"return",
"$",
"isAdmin",
";",
"}",
"return",
"false",
";",
"}"
] |
@param AccountInterface $account
@return bool
|
[
"@param",
"AccountInterface",
"$account"
] |
train
|
https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/Policies/BasePolicy.php#L157-L169
|
loevgaard/altapay-php-sdk
|
src/Callback/CallbackFactory.php
|
CallbackFactory.create
|
public function create(ServerRequestInterface $request) : CallbackInterface
{
$callbacks = [
XmlCallback::class,
FormCallback::class,
RedirectCallback::class
];
foreach ($callbacks as $callback) {
if (call_user_func([$callback, 'initable'], $request)) {
return new $callback($request);
}
}
throw new \InvalidArgumentException('A callback could not be instantiated');
}
|
php
|
public function create(ServerRequestInterface $request) : CallbackInterface
{
$callbacks = [
XmlCallback::class,
FormCallback::class,
RedirectCallback::class
];
foreach ($callbacks as $callback) {
if (call_user_func([$callback, 'initable'], $request)) {
return new $callback($request);
}
}
throw new \InvalidArgumentException('A callback could not be instantiated');
}
|
[
"public",
"function",
"create",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"CallbackInterface",
"{",
"$",
"callbacks",
"=",
"[",
"XmlCallback",
"::",
"class",
",",
"FormCallback",
"::",
"class",
",",
"RedirectCallback",
"::",
"class",
"]",
";",
"foreach",
"(",
"$",
"callbacks",
"as",
"$",
"callback",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"[",
"$",
"callback",
",",
"'initable'",
"]",
",",
"$",
"request",
")",
")",
"{",
"return",
"new",
"$",
"callback",
"(",
"$",
"request",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'A callback could not be instantiated'",
")",
";",
"}"
] |
Will take a Psr Server Request and return a Form, Xml or Redirect
callback object that represent the actual callback
@param ServerRequestInterface $request
@throws \InvalidArgumentException
@return CallbackInterface
|
[
"Will",
"take",
"a",
"Psr",
"Server",
"Request",
"and",
"return",
"a",
"Form",
"Xml",
"or",
"Redirect",
"callback",
"object",
"that",
"represent",
"the",
"actual",
"callback"
] |
train
|
https://github.com/loevgaard/altapay-php-sdk/blob/476664e8725407249c04ca7ae76f92882e4f4583/src/Callback/CallbackFactory.php#L20-L35
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.generate
|
public function generate(array $config)
{
$defaultHTTPCodes = $this->getDefaultHTTPCodes($config);
$defaultOptions = $this->getDefaultOptions($config);
return $this->createUrlChainFromConfig(
$config,
$defaultHTTPCodes,
$defaultOptions
);
}
|
php
|
public function generate(array $config)
{
$defaultHTTPCodes = $this->getDefaultHTTPCodes($config);
$defaultOptions = $this->getDefaultOptions($config);
return $this->createUrlChainFromConfig(
$config,
$defaultHTTPCodes,
$defaultOptions
);
}
|
[
"public",
"function",
"generate",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"defaultHTTPCodes",
"=",
"$",
"this",
"->",
"getDefaultHTTPCodes",
"(",
"$",
"config",
")",
";",
"$",
"defaultOptions",
"=",
"$",
"this",
"->",
"getDefaultOptions",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createUrlChainFromConfig",
"(",
"$",
"config",
",",
"$",
"defaultHTTPCodes",
",",
"$",
"defaultOptions",
")",
";",
"}"
] |
Given a configuration array, generates a chain of urls
@param array $config Configuration
@return UrlChain Chain of URL instances
|
[
"Given",
"a",
"configuration",
"array",
"generates",
"a",
"chain",
"of",
"urls"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L61-L71
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.getDefaultHTTPCodes
|
protected function getDefaultHTTPCodes($config)
{
$defaultHttpCodes = (
isset($config['defaults']) &&
is_array($config['defaults']) &&
isset($config['defaults']['http_codes']) &&
!empty($config['defaults']['http_codes'])
)
? $config['defaults']['http_codes']
: [200];
if (!is_array($defaultHttpCodes)) {
$defaultHttpCodes = [$defaultHttpCodes];
}
return $defaultHttpCodes;
}
|
php
|
protected function getDefaultHTTPCodes($config)
{
$defaultHttpCodes = (
isset($config['defaults']) &&
is_array($config['defaults']) &&
isset($config['defaults']['http_codes']) &&
!empty($config['defaults']['http_codes'])
)
? $config['defaults']['http_codes']
: [200];
if (!is_array($defaultHttpCodes)) {
$defaultHttpCodes = [$defaultHttpCodes];
}
return $defaultHttpCodes;
}
|
[
"protected",
"function",
"getDefaultHTTPCodes",
"(",
"$",
"config",
")",
"{",
"$",
"defaultHttpCodes",
"=",
"(",
"isset",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
")",
"&&",
"isset",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'http_codes'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'http_codes'",
"]",
")",
")",
"?",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'http_codes'",
"]",
":",
"[",
"200",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"defaultHttpCodes",
")",
")",
"{",
"$",
"defaultHttpCodes",
"=",
"[",
"$",
"defaultHttpCodes",
"]",
";",
"}",
"return",
"$",
"defaultHttpCodes",
";",
"}"
] |
Get default http Codes
@param array $config Configuration
@return string[] Array of HTTP Codes
|
[
"Get",
"default",
"http",
"Codes"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L80-L96
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.getDefaultOptions
|
protected function getDefaultOptions($config)
{
$defaultOptions = (
isset($config['defaults']) &&
is_array($config['defaults']) &&
isset($config['defaults']['options']) &&
is_array($config['defaults']['options'])
)
? $config['defaults']['options']
: [];
return $defaultOptions;
}
|
php
|
protected function getDefaultOptions($config)
{
$defaultOptions = (
isset($config['defaults']) &&
is_array($config['defaults']) &&
isset($config['defaults']['options']) &&
is_array($config['defaults']['options'])
)
? $config['defaults']['options']
: [];
return $defaultOptions;
}
|
[
"protected",
"function",
"getDefaultOptions",
"(",
"$",
"config",
")",
"{",
"$",
"defaultOptions",
"=",
"(",
"isset",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
")",
"&&",
"isset",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'options'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'options'",
"]",
")",
")",
"?",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'options'",
"]",
":",
"[",
"]",
";",
"return",
"$",
"defaultOptions",
";",
"}"
] |
Get default options
@param array $config Configuration
@return array Default options
|
[
"Get",
"default",
"options"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L105-L117
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.createUrlChainFromConfig
|
protected function createUrlChainFromConfig(
array $config,
array $defaultHTTPCodes,
array $defaultOptions
) {
$urlChain = $this
->urlChainFactory
->create();
if (
!isset($config['urls']) ||
!is_array($config['urls'])
) {
return $urlChain;
}
$profiles = (
isset($config['profiles']) &&
is_array($config['profiles'])
)
? $config['profiles']
: [];
foreach ($config['urls'] as $urlConfig) {
$urlChain->addUrl(
$this->getURLInstanceFromConfig(
$urlConfig,
$defaultHTTPCodes,
$defaultOptions,
$profiles
)
);
}
return $urlChain;
}
|
php
|
protected function createUrlChainFromConfig(
array $config,
array $defaultHTTPCodes,
array $defaultOptions
) {
$urlChain = $this
->urlChainFactory
->create();
if (
!isset($config['urls']) ||
!is_array($config['urls'])
) {
return $urlChain;
}
$profiles = (
isset($config['profiles']) &&
is_array($config['profiles'])
)
? $config['profiles']
: [];
foreach ($config['urls'] as $urlConfig) {
$urlChain->addUrl(
$this->getURLInstanceFromConfig(
$urlConfig,
$defaultHTTPCodes,
$defaultOptions,
$profiles
)
);
}
return $urlChain;
}
|
[
"protected",
"function",
"createUrlChainFromConfig",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"defaultHTTPCodes",
",",
"array",
"$",
"defaultOptions",
")",
"{",
"$",
"urlChain",
"=",
"$",
"this",
"->",
"urlChainFactory",
"->",
"create",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'urls'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"config",
"[",
"'urls'",
"]",
")",
")",
"{",
"return",
"$",
"urlChain",
";",
"}",
"$",
"profiles",
"=",
"(",
"isset",
"(",
"$",
"config",
"[",
"'profiles'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'profiles'",
"]",
")",
")",
"?",
"$",
"config",
"[",
"'profiles'",
"]",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"[",
"'urls'",
"]",
"as",
"$",
"urlConfig",
")",
"{",
"$",
"urlChain",
"->",
"addUrl",
"(",
"$",
"this",
"->",
"getURLInstanceFromConfig",
"(",
"$",
"urlConfig",
",",
"$",
"defaultHTTPCodes",
",",
"$",
"defaultOptions",
",",
"$",
"profiles",
")",
")",
";",
"}",
"return",
"$",
"urlChain",
";",
"}"
] |
Given a config array, create an URLChain instance filled with all defined
URL instances.
@param array $config Configuration
@param string[] $defaultHTTPCodes Array of HTTP Codes
@param array $defaultOptions Default options
@return Url[] Array of URL instances
|
[
"Given",
"a",
"config",
"array",
"create",
"an",
"URLChain",
"instance",
"filled",
"with",
"all",
"defined",
"URL",
"instances",
"."
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L129-L164
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.getUrlInstanceFromConfig
|
protected function getUrlInstanceFromConfig(
$urlConfig,
array $defaultHTTPCodes,
array $defaultOptions,
array $profiles
) {
$url = $this->getUrlPathFromConfig($urlConfig);
$urlHTTPCodes = $this->getUrlHTTPCodesFromConfig(
$urlConfig,
$defaultHTTPCodes
);
$urlOptions = $this->getUrlOptionsFromConfig(
$urlConfig,
$defaultOptions
);
if (
isset($urlOptions['profile']) &&
isset($profiles[$urlOptions['profile']]) &&
is_array($profiles[$urlOptions['profile']])
) {
$urlOptions = array_merge(
$profiles[$urlOptions['profile']],
$urlOptions
);
}
return $this
->urlFactory
->create(
$url,
$urlHTTPCodes,
$urlOptions
);
}
|
php
|
protected function getUrlInstanceFromConfig(
$urlConfig,
array $defaultHTTPCodes,
array $defaultOptions,
array $profiles
) {
$url = $this->getUrlPathFromConfig($urlConfig);
$urlHTTPCodes = $this->getUrlHTTPCodesFromConfig(
$urlConfig,
$defaultHTTPCodes
);
$urlOptions = $this->getUrlOptionsFromConfig(
$urlConfig,
$defaultOptions
);
if (
isset($urlOptions['profile']) &&
isset($profiles[$urlOptions['profile']]) &&
is_array($profiles[$urlOptions['profile']])
) {
$urlOptions = array_merge(
$profiles[$urlOptions['profile']],
$urlOptions
);
}
return $this
->urlFactory
->create(
$url,
$urlHTTPCodes,
$urlOptions
);
}
|
[
"protected",
"function",
"getUrlInstanceFromConfig",
"(",
"$",
"urlConfig",
",",
"array",
"$",
"defaultHTTPCodes",
",",
"array",
"$",
"defaultOptions",
",",
"array",
"$",
"profiles",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrlPathFromConfig",
"(",
"$",
"urlConfig",
")",
";",
"$",
"urlHTTPCodes",
"=",
"$",
"this",
"->",
"getUrlHTTPCodesFromConfig",
"(",
"$",
"urlConfig",
",",
"$",
"defaultHTTPCodes",
")",
";",
"$",
"urlOptions",
"=",
"$",
"this",
"->",
"getUrlOptionsFromConfig",
"(",
"$",
"urlConfig",
",",
"$",
"defaultOptions",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"urlOptions",
"[",
"'profile'",
"]",
")",
"&&",
"isset",
"(",
"$",
"profiles",
"[",
"$",
"urlOptions",
"[",
"'profile'",
"]",
"]",
")",
"&&",
"is_array",
"(",
"$",
"profiles",
"[",
"$",
"urlOptions",
"[",
"'profile'",
"]",
"]",
")",
")",
"{",
"$",
"urlOptions",
"=",
"array_merge",
"(",
"$",
"profiles",
"[",
"$",
"urlOptions",
"[",
"'profile'",
"]",
"]",
",",
"$",
"urlOptions",
")",
";",
"}",
"return",
"$",
"this",
"->",
"urlFactory",
"->",
"create",
"(",
"$",
"url",
",",
"$",
"urlHTTPCodes",
",",
"$",
"urlOptions",
")",
";",
"}"
] |
Get Url instance given its configuration
@param mixed $urlConfig Url configuration
@param string[] $defaultHTTPCodes Array of HTTP Codes
@param array $defaultOptions Default options
@param array $profiles Profiles
@return URL Url instance
|
[
"Get",
"Url",
"instance",
"given",
"its",
"configuration"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L176-L212
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.getUrlHTTPCodesFromConfig
|
protected function getUrlHTTPCodesFromConfig(
$urlConfig,
array $defaultHTTPCodes
) {
$HTTPCodes = (
is_array($urlConfig) &&
isset($urlConfig[1]) &&
!empty($urlConfig[1])
)
? $urlConfig[1]
: $defaultHTTPCodes;
return is_array($HTTPCodes)
? $HTTPCodes
: [$HTTPCodes];
}
|
php
|
protected function getUrlHTTPCodesFromConfig(
$urlConfig,
array $defaultHTTPCodes
) {
$HTTPCodes = (
is_array($urlConfig) &&
isset($urlConfig[1]) &&
!empty($urlConfig[1])
)
? $urlConfig[1]
: $defaultHTTPCodes;
return is_array($HTTPCodes)
? $HTTPCodes
: [$HTTPCodes];
}
|
[
"protected",
"function",
"getUrlHTTPCodesFromConfig",
"(",
"$",
"urlConfig",
",",
"array",
"$",
"defaultHTTPCodes",
")",
"{",
"$",
"HTTPCodes",
"=",
"(",
"is_array",
"(",
"$",
"urlConfig",
")",
"&&",
"isset",
"(",
"$",
"urlConfig",
"[",
"1",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"urlConfig",
"[",
"1",
"]",
")",
")",
"?",
"$",
"urlConfig",
"[",
"1",
"]",
":",
"$",
"defaultHTTPCodes",
";",
"return",
"is_array",
"(",
"$",
"HTTPCodes",
")",
"?",
"$",
"HTTPCodes",
":",
"[",
"$",
"HTTPCodes",
"]",
";",
"}"
] |
Get url HTTP Codes given its configuration
@param mixed $urlConfig Url configuration
@param string[] $defaultHTTPCodes Array of HTTP Codes
@return string[] Set of HTTP Codes
|
[
"Get",
"url",
"HTTP",
"Codes",
"given",
"its",
"configuration"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L236-L251
|
Visithor/visithor
|
src/Visithor/Generator/UrlGenerator.php
|
UrlGenerator.getUrlOptionsFromConfig
|
protected function getUrlOptionsFromConfig(
$urlConfig,
array $defaultOptions
) {
$urlOptions = (
is_array($urlConfig) &&
isset($urlConfig[2]) &&
is_array($urlConfig[2])
)
? $urlConfig[2]
: [];
return array_merge(
$defaultOptions,
$urlOptions
);
}
|
php
|
protected function getUrlOptionsFromConfig(
$urlConfig,
array $defaultOptions
) {
$urlOptions = (
is_array($urlConfig) &&
isset($urlConfig[2]) &&
is_array($urlConfig[2])
)
? $urlConfig[2]
: [];
return array_merge(
$defaultOptions,
$urlOptions
);
}
|
[
"protected",
"function",
"getUrlOptionsFromConfig",
"(",
"$",
"urlConfig",
",",
"array",
"$",
"defaultOptions",
")",
"{",
"$",
"urlOptions",
"=",
"(",
"is_array",
"(",
"$",
"urlConfig",
")",
"&&",
"isset",
"(",
"$",
"urlConfig",
"[",
"2",
"]",
")",
"&&",
"is_array",
"(",
"$",
"urlConfig",
"[",
"2",
"]",
")",
")",
"?",
"$",
"urlConfig",
"[",
"2",
"]",
":",
"[",
"]",
";",
"return",
"array_merge",
"(",
"$",
"defaultOptions",
",",
"$",
"urlOptions",
")",
";",
"}"
] |
Get url options
@param mixed $urlConfig Url configuration
@param array $defaultOptions Default options
@return string[] Set of HTTP Codes
|
[
"Get",
"url",
"options"
] |
train
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Generator/UrlGenerator.php#L261-L277
|
oroinc/OroLayoutComponent
|
Loader/Generator/Extension/ImportsLayoutUpdateExtension.php
|
ImportsLayoutUpdateExtension.prepare
|
public function prepare(GeneratorData $data, VisitorCollection $visitorCollection)
{
$source = $data->getSource();
// layout update contains imports
if (!empty($source[self::NODE_IMPORTS])) {
$visitorCollection->append(new ImportsAwareLayoutUpdateVisitor($source[self::NODE_IMPORTS]));
}
// imported layout update
$delimiter = PathProviderInterface::DELIMITER;
if (strpos($data->getFilename(), $delimiter.ImportVisitor::IMPORT_FOLDER.$delimiter) !== false) {
$visitorCollection->append(new ImportLayoutUpdateVisitor());
}
}
|
php
|
public function prepare(GeneratorData $data, VisitorCollection $visitorCollection)
{
$source = $data->getSource();
// layout update contains imports
if (!empty($source[self::NODE_IMPORTS])) {
$visitorCollection->append(new ImportsAwareLayoutUpdateVisitor($source[self::NODE_IMPORTS]));
}
// imported layout update
$delimiter = PathProviderInterface::DELIMITER;
if (strpos($data->getFilename(), $delimiter.ImportVisitor::IMPORT_FOLDER.$delimiter) !== false) {
$visitorCollection->append(new ImportLayoutUpdateVisitor());
}
}
|
[
"public",
"function",
"prepare",
"(",
"GeneratorData",
"$",
"data",
",",
"VisitorCollection",
"$",
"visitorCollection",
")",
"{",
"$",
"source",
"=",
"$",
"data",
"->",
"getSource",
"(",
")",
";",
"// layout update contains imports",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
"[",
"self",
"::",
"NODE_IMPORTS",
"]",
")",
")",
"{",
"$",
"visitorCollection",
"->",
"append",
"(",
"new",
"ImportsAwareLayoutUpdateVisitor",
"(",
"$",
"source",
"[",
"self",
"::",
"NODE_IMPORTS",
"]",
")",
")",
";",
"}",
"// imported layout update",
"$",
"delimiter",
"=",
"PathProviderInterface",
"::",
"DELIMITER",
";",
"if",
"(",
"strpos",
"(",
"$",
"data",
"->",
"getFilename",
"(",
")",
",",
"$",
"delimiter",
".",
"ImportVisitor",
"::",
"IMPORT_FOLDER",
".",
"$",
"delimiter",
")",
"!==",
"false",
")",
"{",
"$",
"visitorCollection",
"->",
"append",
"(",
"new",
"ImportLayoutUpdateVisitor",
"(",
")",
")",
";",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Generator/Extension/ImportsLayoutUpdateExtension.php#L18-L32
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.containsEntities
|
public function containsEntities(array $entities)
{
foreach ($entities as $entity) {
if (!$this->entities->contains($entity)) {
return false;
}
}
return true;
}
|
php
|
public function containsEntities(array $entities)
{
foreach ($entities as $entity) {
if (!$this->entities->contains($entity)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"containsEntities",
"(",
"array",
"$",
"entities",
")",
"{",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"entities",
"->",
"contains",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Contains entities
@param Entity[] $entities
@return bool
|
[
"Contains",
"entities"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L150-L159
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.removeEntity
|
public function removeEntity(Entity $entity)
{
foreach ($this->entities as $key => $entityElement) {
if ($entityElement === $entity) {
unset($this->entities[$key]);
break;
}
}
return $this;
}
|
php
|
public function removeEntity(Entity $entity)
{
foreach ($this->entities as $key => $entityElement) {
if ($entityElement === $entity) {
unset($this->entities[$key]);
break;
}
}
return $this;
}
|
[
"public",
"function",
"removeEntity",
"(",
"Entity",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"key",
"=>",
"$",
"entityElement",
")",
"{",
"if",
"(",
"$",
"entityElement",
"===",
"$",
"entity",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"entities",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove entity
@param Entity $entity
@return Project
|
[
"Remove",
"entity"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L168-L178
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setLog
|
public function setLog($log)
{
if (!is_string($log)) {
throw new \InvalidArgumentException('The attribute log on the class Project has to be string (' . gettype($log) . ('object' === gettype($log) ? ' ' . get_class($log) : '') . ' given).');
}
$this->log = $log;
return $this;
}
|
php
|
public function setLog($log)
{
if (!is_string($log)) {
throw new \InvalidArgumentException('The attribute log on the class Project has to be string (' . gettype($log) . ('object' === gettype($log) ? ' ' . get_class($log) : '') . ' given).');
}
$this->log = $log;
return $this;
}
|
[
"public",
"function",
"setLog",
"(",
"$",
"log",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"log",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute log on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"log",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"log",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"log",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"log",
"=",
"$",
"log",
";",
"return",
"$",
"this",
";",
"}"
] |
Set log
@param string $log
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"log"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L215-L224
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.containsModules
|
public function containsModules(array $modules)
{
foreach ($modules as $module) {
if (!$this->modules->contains($module)) {
return false;
}
}
return true;
}
|
php
|
public function containsModules(array $modules)
{
foreach ($modules as $module) {
if (!$this->modules->contains($module)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"containsModules",
"(",
"array",
"$",
"modules",
")",
"{",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"modules",
"->",
"contains",
"(",
"$",
"module",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Contains modules
@param string[] $modules
@return bool
|
[
"Contains",
"modules"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L299-L308
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.removeModule
|
public function removeModule($module)
{
foreach ($this->modules as $key => $moduleElement) {
if ($moduleElement === $module) {
unset($this->modules[$key]);
break;
}
}
return $this;
}
|
php
|
public function removeModule($module)
{
foreach ($this->modules as $key => $moduleElement) {
if ($moduleElement === $module) {
unset($this->modules[$key]);
break;
}
}
return $this;
}
|
[
"public",
"function",
"removeModule",
"(",
"$",
"module",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"key",
"=>",
"$",
"moduleElement",
")",
"{",
"if",
"(",
"$",
"moduleElement",
"===",
"$",
"module",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove module
@param string $module
@return Project
|
[
"Remove",
"module"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L317-L327
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.containsModuleEntities
|
public function containsModuleEntities(array $moduleEntities)
{
foreach ($moduleEntities as $moduleEntity) {
if (!$this->moduleEntities->contains($moduleEntity)) {
return false;
}
}
return true;
}
|
php
|
public function containsModuleEntities(array $moduleEntities)
{
foreach ($moduleEntities as $moduleEntity) {
if (!$this->moduleEntities->contains($moduleEntity)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"containsModuleEntities",
"(",
"array",
"$",
"moduleEntities",
")",
"{",
"foreach",
"(",
"$",
"moduleEntities",
"as",
"$",
"moduleEntity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"moduleEntities",
"->",
"contains",
"(",
"$",
"moduleEntity",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Contains moduleEntities
@param string[] $moduleEntities
@return bool
|
[
"Contains",
"moduleEntities"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L418-L427
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.removeModuleEntity
|
public function removeModuleEntity($moduleEntity)
{
foreach ($this->moduleEntities as $key => $moduleEntityElement) {
if ($moduleEntityElement === $moduleEntity) {
unset($this->moduleEntities[$key]);
break;
}
}
return $this;
}
|
php
|
public function removeModuleEntity($moduleEntity)
{
foreach ($this->moduleEntities as $key => $moduleEntityElement) {
if ($moduleEntityElement === $moduleEntity) {
unset($this->moduleEntities[$key]);
break;
}
}
return $this;
}
|
[
"public",
"function",
"removeModuleEntity",
"(",
"$",
"moduleEntity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"moduleEntities",
"as",
"$",
"key",
"=>",
"$",
"moduleEntityElement",
")",
"{",
"if",
"(",
"$",
"moduleEntityElement",
"===",
"$",
"moduleEntity",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"moduleEntities",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove moduleEntity
@param string $moduleEntity
@return Project
|
[
"Remove",
"moduleEntity"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L436-L446
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.containsModuleNamespaces
|
public function containsModuleNamespaces(array $moduleNamespaces)
{
foreach ($moduleNamespaces as $moduleNamespace) {
if (!$this->moduleNamespaces->contains($moduleNamespace)) {
return false;
}
}
return true;
}
|
php
|
public function containsModuleNamespaces(array $moduleNamespaces)
{
foreach ($moduleNamespaces as $moduleNamespace) {
if (!$this->moduleNamespaces->contains($moduleNamespace)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"containsModuleNamespaces",
"(",
"array",
"$",
"moduleNamespaces",
")",
"{",
"foreach",
"(",
"$",
"moduleNamespaces",
"as",
"$",
"moduleNamespace",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"moduleNamespaces",
"->",
"contains",
"(",
"$",
"moduleNamespace",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Contains moduleNamespaces
@param string[] $moduleNamespaces
@return bool
|
[
"Contains",
"moduleNamespaces"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L537-L546
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.removeModuleNamespace
|
public function removeModuleNamespace($moduleNamespace)
{
foreach ($this->moduleNamespaces as $key => $moduleNamespaceElement) {
if ($moduleNamespaceElement === $moduleNamespace) {
unset($this->moduleNamespaces[$key]);
break;
}
}
return $this;
}
|
php
|
public function removeModuleNamespace($moduleNamespace)
{
foreach ($this->moduleNamespaces as $key => $moduleNamespaceElement) {
if ($moduleNamespaceElement === $moduleNamespace) {
unset($this->moduleNamespaces[$key]);
break;
}
}
return $this;
}
|
[
"public",
"function",
"removeModuleNamespace",
"(",
"$",
"moduleNamespace",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"moduleNamespaces",
"as",
"$",
"key",
"=>",
"$",
"moduleNamespaceElement",
")",
"{",
"if",
"(",
"$",
"moduleNamespaceElement",
"===",
"$",
"moduleNamespace",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"moduleNamespaces",
"[",
"$",
"key",
"]",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove moduleNamespace
@param string $moduleNamespace
@return Project
|
[
"Remove",
"moduleNamespace"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L555-L565
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setLanguage
|
public function setLanguage($language)
{
if (!is_string($language)) {
throw new \InvalidArgumentException('The attribute language on the class Project has to be string (' . gettype($language) . ('object' === gettype($language) ? ' ' . get_class($language) : '') . ' given).');
}
$this->language = $language;
return $this;
}
|
php
|
public function setLanguage($language)
{
if (!is_string($language)) {
throw new \InvalidArgumentException('The attribute language on the class Project has to be string (' . gettype($language) . ('object' === gettype($language) ? ' ' . get_class($language) : '') . ' given).');
}
$this->language = $language;
return $this;
}
|
[
"public",
"function",
"setLanguage",
"(",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"language",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute language on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"language",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"language",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"language",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"language",
"=",
"$",
"language",
";",
"return",
"$",
"this",
";",
"}"
] |
Set language
@param string $language
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"language"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L602-L611
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setOrm
|
public function setOrm($orm)
{
if (!is_string($orm)) {
throw new \InvalidArgumentException('The attribute orm on the class Project has to be string (' . gettype($orm) . ('object' === gettype($orm) ? ' ' . get_class($orm) : '') . ' given).');
}
$this->orm = $orm;
return $this;
}
|
php
|
public function setOrm($orm)
{
if (!is_string($orm)) {
throw new \InvalidArgumentException('The attribute orm on the class Project has to be string (' . gettype($orm) . ('object' === gettype($orm) ? ' ' . get_class($orm) : '') . ' given).');
}
$this->orm = $orm;
return $this;
}
|
[
"public",
"function",
"setOrm",
"(",
"$",
"orm",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"orm",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute orm on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"orm",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"orm",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"orm",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"orm",
"=",
"$",
"orm",
";",
"return",
"$",
"this",
";",
"}"
] |
Set orm
@param string $orm
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"orm"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L662-L671
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setFramework
|
public function setFramework($framework)
{
if (!is_string($framework)) {
throw new \InvalidArgumentException('The attribute framework on the class Project has to be string (' . gettype($framework) . ('object' === gettype($framework) ? ' ' . get_class($framework) : '') . ' given).');
}
$this->framework = $framework;
return $this;
}
|
php
|
public function setFramework($framework)
{
if (!is_string($framework)) {
throw new \InvalidArgumentException('The attribute framework on the class Project has to be string (' . gettype($framework) . ('object' === gettype($framework) ? ' ' . get_class($framework) : '') . ' given).');
}
$this->framework = $framework;
return $this;
}
|
[
"public",
"function",
"setFramework",
"(",
"$",
"framework",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"framework",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute framework on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"framework",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"framework",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"framework",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"framework",
"=",
"$",
"framework",
";",
"return",
"$",
"this",
";",
"}"
] |
Set framework
@param string $framework
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"framework"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L692-L701
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setAttributeClass
|
public function setAttributeClass($attributeClass)
{
if (!is_string($attributeClass)) {
throw new \InvalidArgumentException('The attribute attributeClass on the class Project has to be string (' . gettype($attributeClass) . ('object' === gettype($attributeClass) ? ' ' . get_class($attributeClass) : '') . ' given).');
}
$this->attributeClass = $attributeClass;
return $this;
}
|
php
|
public function setAttributeClass($attributeClass)
{
if (!is_string($attributeClass)) {
throw new \InvalidArgumentException('The attribute attributeClass on the class Project has to be string (' . gettype($attributeClass) . ('object' === gettype($attributeClass) ? ' ' . get_class($attributeClass) : '') . ' given).');
}
$this->attributeClass = $attributeClass;
return $this;
}
|
[
"public",
"function",
"setAttributeClass",
"(",
"$",
"attributeClass",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"attributeClass",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute attributeClass on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"attributeClass",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"attributeClass",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"attributeClass",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"attributeClass",
"=",
"$",
"attributeClass",
";",
"return",
"$",
"this",
";",
"}"
] |
Set attributeClass
@param string $attributeClass
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"attributeClass"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L722-L731
|
j-d/draggy
|
src/Draggy/Autocode/Base/ProjectBase.php
|
ProjectBase.setEntityClass
|
public function setEntityClass($entityClass)
{
if (!is_string($entityClass)) {
throw new \InvalidArgumentException('The attribute entityClass on the class Project has to be string (' . gettype($entityClass) . ('object' === gettype($entityClass) ? ' ' . get_class($entityClass) : '') . ' given).');
}
$this->entityClass = $entityClass;
return $this;
}
|
php
|
public function setEntityClass($entityClass)
{
if (!is_string($entityClass)) {
throw new \InvalidArgumentException('The attribute entityClass on the class Project has to be string (' . gettype($entityClass) . ('object' === gettype($entityClass) ? ' ' . get_class($entityClass) : '') . ' given).');
}
$this->entityClass = $entityClass;
return $this;
}
|
[
"public",
"function",
"setEntityClass",
"(",
"$",
"entityClass",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"entityClass",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The attribute entityClass on the class Project has to be string ('",
".",
"gettype",
"(",
"$",
"entityClass",
")",
".",
"(",
"'object'",
"===",
"gettype",
"(",
"$",
"entityClass",
")",
"?",
"' '",
".",
"get_class",
"(",
"$",
"entityClass",
")",
":",
"''",
")",
".",
"' given).'",
")",
";",
"}",
"$",
"this",
"->",
"entityClass",
"=",
"$",
"entityClass",
";",
"return",
"$",
"this",
";",
"}"
] |
Set entityClass
@param string $entityClass
@return Project
@throws \InvalidArgumentException
|
[
"Set",
"entityClass"
] |
train
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Base/ProjectBase.php#L752-L761
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Entity.php
|
Entity.count
|
public function count($entityType, $filter = '')
{
$params = array('type_name' => $entityType);
if (!empty($filter)) {
$params['filter'] = $filter;
}
return $this->post('entity.count', $params);
}
|
php
|
public function count($entityType, $filter = '')
{
$params = array('type_name' => $entityType);
if (!empty($filter)) {
$params['filter'] = $filter;
}
return $this->post('entity.count', $params);
}
|
[
"public",
"function",
"count",
"(",
"$",
"entityType",
",",
"$",
"filter",
"=",
"''",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'type_name'",
"=>",
"$",
"entityType",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"filter",
")",
")",
"{",
"$",
"params",
"[",
"'filter'",
"]",
"=",
"$",
"filter",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'entity.count'",
",",
"$",
"params",
")",
";",
"}"
] |
Count the number of records in an entityType.
@param string $entityType The entityType of the entity
@param string $filter The expression to use to filter the results.
|
[
"Count",
"the",
"number",
"of",
"records",
"in",
"an",
"entityType",
"."
] |
train
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Entity.php#L53-L60
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Entity.php
|
Entity.delete
|
public function delete($uuid, array $params = array())
{
$params['uuid'] = $uuid;
if (!isset($params['type_name'])) {
throw new MissingArgumentException('type_name');
}
return $this->_del($params);
}
|
php
|
public function delete($uuid, array $params = array())
{
$params['uuid'] = $uuid;
if (!isset($params['type_name'])) {
throw new MissingArgumentException('type_name');
}
return $this->_del($params);
}
|
[
"public",
"function",
"delete",
"(",
"$",
"uuid",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"[",
"'uuid'",
"]",
"=",
"$",
"uuid",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'type_name'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingArgumentException",
"(",
"'type_name'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_del",
"(",
"$",
"params",
")",
";",
"}"
] |
Default by UUID.
|
[
"Default",
"by",
"UUID",
"."
] |
train
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Entity.php#L96-L104
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Entity.php
|
Entity.replaceByAttribute
|
public function replaceByAttribute($attributeKey, $attributeValue, array $params)
{
$params['key_attribute'] = $attributeKey;
$params['key_value'] = $this->wrapAttributeValueWithQuotes($attributeValue);
return $this->_replace($params);
}
|
php
|
public function replaceByAttribute($attributeKey, $attributeValue, array $params)
{
$params['key_attribute'] = $attributeKey;
$params['key_value'] = $this->wrapAttributeValueWithQuotes($attributeValue);
return $this->_replace($params);
}
|
[
"public",
"function",
"replaceByAttribute",
"(",
"$",
"attributeKey",
",",
"$",
"attributeValue",
",",
"array",
"$",
"params",
")",
"{",
"$",
"params",
"[",
"'key_attribute'",
"]",
"=",
"$",
"attributeKey",
";",
"$",
"params",
"[",
"'key_value'",
"]",
"=",
"$",
"this",
"->",
"wrapAttributeValueWithQuotes",
"(",
"$",
"attributeValue",
")",
";",
"return",
"$",
"this",
"->",
"_replace",
"(",
"$",
"params",
")",
";",
"}"
] |
Replace part of an entity by attribute.
|
[
"Replace",
"part",
"of",
"an",
"entity",
"by",
"attribute",
"."
] |
train
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Entity.php#L207-L213
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Entity.php
|
Entity.updateByAttribute
|
public function updateByAttribute($attributeKey, $attributeValue, array $params)
{
$params['key_attribute'] = $attributeKey;
$params['key_value'] = $this->wrapAttributeValueWithQuotes($attributeValue);
return $this->_update($params);
}
|
php
|
public function updateByAttribute($attributeKey, $attributeValue, array $params)
{
$params['key_attribute'] = $attributeKey;
$params['key_value'] = $this->wrapAttributeValueWithQuotes($attributeValue);
return $this->_update($params);
}
|
[
"public",
"function",
"updateByAttribute",
"(",
"$",
"attributeKey",
",",
"$",
"attributeValue",
",",
"array",
"$",
"params",
")",
"{",
"$",
"params",
"[",
"'key_attribute'",
"]",
"=",
"$",
"attributeKey",
";",
"$",
"params",
"[",
"'key_value'",
"]",
"=",
"$",
"this",
"->",
"wrapAttributeValueWithQuotes",
"(",
"$",
"attributeValue",
")",
";",
"return",
"$",
"this",
"->",
"_update",
"(",
"$",
"params",
")",
";",
"}"
] |
Update entity by attribute
|
[
"Update",
"entity",
"by",
"attribute"
] |
train
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Entity.php#L259-L265
|
alevilar/ristorantino-vendor
|
Printers/Lib/PrinterOutput/AfipFacturasPrinterOutput.php
|
AfipFacturasPrinterOutput.send
|
public function send( $printaitorViewObj ) {
$dv = $printaitorViewObj->dataToView;
$factura['AfipFactura'] = array(
'json_data' => $printaitorViewObj->viewTextRender,
'mesa_id' => Hash::get( $dv, 'Mesa.id'),
'importe_total' => Hash::get( $dv, 'Mesa.total'),
'importe_neto' => Hash::get( $dv, 'importe_neto'),
'importe_iva' => Hash::get( $dv, 'importe_iva'),
'punto_de_venta' => Hash::get( $dv, 'punto_de_venta'),
'comprobante_nro' => Hash::get( $dv, 'numero_comprobante'),
'tipo_factura_id' => Hash::get( $dv, 'tipo_factura_id'),
'cae' => Hash::get( $dv, 'cae'),
'iva_porcentaje' => Configure::read('Afip.default_iva_porcentaje'),
);
$AfipFactura = ClassRegistry::init("Printers.AfipFactura");
$factura = $AfipFactura->save($factura);
if ( !$factura ) {
foreach ( $AfipFactura->validationErrors as $field => $msg) {
$msgErr = implode(',', $msg);
throw new CakeException( __("No se pudo guardar la factura. Campo: %s, Error: %s", $field, $msgErr), 1);
}
}
return $factura;
}
|
php
|
public function send( $printaitorViewObj ) {
$dv = $printaitorViewObj->dataToView;
$factura['AfipFactura'] = array(
'json_data' => $printaitorViewObj->viewTextRender,
'mesa_id' => Hash::get( $dv, 'Mesa.id'),
'importe_total' => Hash::get( $dv, 'Mesa.total'),
'importe_neto' => Hash::get( $dv, 'importe_neto'),
'importe_iva' => Hash::get( $dv, 'importe_iva'),
'punto_de_venta' => Hash::get( $dv, 'punto_de_venta'),
'comprobante_nro' => Hash::get( $dv, 'numero_comprobante'),
'tipo_factura_id' => Hash::get( $dv, 'tipo_factura_id'),
'cae' => Hash::get( $dv, 'cae'),
'iva_porcentaje' => Configure::read('Afip.default_iva_porcentaje'),
);
$AfipFactura = ClassRegistry::init("Printers.AfipFactura");
$factura = $AfipFactura->save($factura);
if ( !$factura ) {
foreach ( $AfipFactura->validationErrors as $field => $msg) {
$msgErr = implode(',', $msg);
throw new CakeException( __("No se pudo guardar la factura. Campo: %s, Error: %s", $field, $msgErr), 1);
}
}
return $factura;
}
|
[
"public",
"function",
"send",
"(",
"$",
"printaitorViewObj",
")",
"{",
"$",
"dv",
"=",
"$",
"printaitorViewObj",
"->",
"dataToView",
";",
"$",
"factura",
"[",
"'AfipFactura'",
"]",
"=",
"array",
"(",
"'json_data'",
"=>",
"$",
"printaitorViewObj",
"->",
"viewTextRender",
",",
"'mesa_id'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'Mesa.id'",
")",
",",
"'importe_total'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'Mesa.total'",
")",
",",
"'importe_neto'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'importe_neto'",
")",
",",
"'importe_iva'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'importe_iva'",
")",
",",
"'punto_de_venta'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'punto_de_venta'",
")",
",",
"'comprobante_nro'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'numero_comprobante'",
")",
",",
"'tipo_factura_id'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'tipo_factura_id'",
")",
",",
"'cae'",
"=>",
"Hash",
"::",
"get",
"(",
"$",
"dv",
",",
"'cae'",
")",
",",
"'iva_porcentaje'",
"=>",
"Configure",
"::",
"read",
"(",
"'Afip.default_iva_porcentaje'",
")",
",",
")",
";",
"$",
"AfipFactura",
"=",
"ClassRegistry",
"::",
"init",
"(",
"\"Printers.AfipFactura\"",
")",
";",
"$",
"factura",
"=",
"$",
"AfipFactura",
"->",
"save",
"(",
"$",
"factura",
")",
";",
"if",
"(",
"!",
"$",
"factura",
")",
"{",
"foreach",
"(",
"$",
"AfipFactura",
"->",
"validationErrors",
"as",
"$",
"field",
"=>",
"$",
"msg",
")",
"{",
"$",
"msgErr",
"=",
"implode",
"(",
"','",
",",
"$",
"msg",
")",
";",
"throw",
"new",
"CakeException",
"(",
"__",
"(",
"\"No se pudo guardar la factura. Campo: %s, Error: %s\"",
",",
"$",
"field",
",",
"$",
"msgErr",
")",
",",
"1",
")",
";",
"}",
"}",
"return",
"$",
"factura",
";",
"}"
] |
Crea un archivo y lo guarda en la tabla afip_facturas
@param PrintaitorViewObj $printaitorViewObj
@return type boolean true si salio todo bien false caso contrario
|
[
"Crea",
"un",
"archivo",
"y",
"lo",
"guarda",
"en",
"la",
"tabla",
"afip_facturas"
] |
train
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/PrinterOutput/AfipFacturasPrinterOutput.php#L269-L293
|
technote-space/wordpress-plugin-base
|
src/classes/models/lib/upgrade.php
|
Upgrade.show_plugin_update_notices
|
private function show_plugin_update_notices() {
add_action( 'in_plugin_update_message-' . $this->app->define->plugin_base_name, function ( $data, $r ) {
$new_version = $r->new_version;
$url = $this->app->utility->array_get( $data, 'PluginURI' );
$notices = $this->get_upgrade_notices( $new_version, $url );
if ( ! empty( $notices ) ) {
$this->get_view( 'admin/include/upgrade', [
'notices' => $notices,
], true );
}
}, 10, 2 );
}
|
php
|
private function show_plugin_update_notices() {
add_action( 'in_plugin_update_message-' . $this->app->define->plugin_base_name, function ( $data, $r ) {
$new_version = $r->new_version;
$url = $this->app->utility->array_get( $data, 'PluginURI' );
$notices = $this->get_upgrade_notices( $new_version, $url );
if ( ! empty( $notices ) ) {
$this->get_view( 'admin/include/upgrade', [
'notices' => $notices,
], true );
}
}, 10, 2 );
}
|
[
"private",
"function",
"show_plugin_update_notices",
"(",
")",
"{",
"add_action",
"(",
"'in_plugin_update_message-'",
".",
"$",
"this",
"->",
"app",
"->",
"define",
"->",
"plugin_base_name",
",",
"function",
"(",
"$",
"data",
",",
"$",
"r",
")",
"{",
"$",
"new_version",
"=",
"$",
"r",
"->",
"new_version",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"app",
"->",
"utility",
"->",
"array_get",
"(",
"$",
"data",
",",
"'PluginURI'",
")",
";",
"$",
"notices",
"=",
"$",
"this",
"->",
"get_upgrade_notices",
"(",
"$",
"new_version",
",",
"$",
"url",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"notices",
")",
")",
"{",
"$",
"this",
"->",
"get_view",
"(",
"'admin/include/upgrade'",
",",
"[",
"'notices'",
"=>",
"$",
"notices",
",",
"]",
",",
"true",
")",
";",
"}",
"}",
",",
"10",
",",
"2",
")",
";",
"}"
] |
show plugin upgrade notices
@since 2.4.1
@since 2.4.3 Fixed: get plugin upgrade notice from plugin directory
|
[
"show",
"plugin",
"upgrade",
"notices"
] |
train
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/upgrade.php#L175-L186
|
technote-space/wordpress-plugin-base
|
src/classes/models/lib/upgrade.php
|
Upgrade.get_upgrade_notice
|
private function get_upgrade_notice( $slug ) {
$notice = $this->apply_filters( 'pre_get_update_notice', false, $slug );
if ( is_array( $notice ) ) {
return $notice;
}
foreach (
[
'get_config_readme_url',
'get_readme_url_from_update_info_url',
'get_trunk_readme_url',
] as $method
) {
$response = wp_safe_remote_get( $this->$method( $slug ) );
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
return $this->parse_update_notice( $response['body'] );
}
}
return false;
}
|
php
|
private function get_upgrade_notice( $slug ) {
$notice = $this->apply_filters( 'pre_get_update_notice', false, $slug );
if ( is_array( $notice ) ) {
return $notice;
}
foreach (
[
'get_config_readme_url',
'get_readme_url_from_update_info_url',
'get_trunk_readme_url',
] as $method
) {
$response = wp_safe_remote_get( $this->$method( $slug ) );
if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
return $this->parse_update_notice( $response['body'] );
}
}
return false;
}
|
[
"private",
"function",
"get_upgrade_notice",
"(",
"$",
"slug",
")",
"{",
"$",
"notice",
"=",
"$",
"this",
"->",
"apply_filters",
"(",
"'pre_get_update_notice'",
",",
"false",
",",
"$",
"slug",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"notice",
")",
")",
"{",
"return",
"$",
"notice",
";",
"}",
"foreach",
"(",
"[",
"'get_config_readme_url'",
",",
"'get_readme_url_from_update_info_url'",
",",
"'get_trunk_readme_url'",
",",
"]",
"as",
"$",
"method",
")",
"{",
"$",
"response",
"=",
"wp_safe_remote_get",
"(",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"slug",
")",
")",
";",
"if",
"(",
"!",
"is_wp_error",
"(",
"$",
"response",
")",
"&&",
"!",
"empty",
"(",
"$",
"response",
"[",
"'body'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parse_update_notice",
"(",
"$",
"response",
"[",
"'body'",
"]",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
@since 2.9.9
@param $slug
@return array|false
|
[
"@since",
"2",
".",
"9",
".",
"9"
] |
train
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/upgrade.php#L237-L257
|
technote-space/wordpress-plugin-base
|
src/classes/models/lib/upgrade.php
|
Upgrade.get_upgrade_notices
|
private function get_upgrade_notices( $version, $url ) {
$slug = $this->get_plugin_slug( $url );
if ( empty( $slug ) ) {
return false;
}
$transient_name = 'upgrade_notice-' . $slug . '_' . $version;
$upgrade_notice = get_transient( $transient_name );
if ( false === $upgrade_notice ) {
$upgrade_notice = $this->get_upgrade_notice( $slug );
if ( $upgrade_notice ) {
set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
}
}
return $upgrade_notice;
}
|
php
|
private function get_upgrade_notices( $version, $url ) {
$slug = $this->get_plugin_slug( $url );
if ( empty( $slug ) ) {
return false;
}
$transient_name = 'upgrade_notice-' . $slug . '_' . $version;
$upgrade_notice = get_transient( $transient_name );
if ( false === $upgrade_notice ) {
$upgrade_notice = $this->get_upgrade_notice( $slug );
if ( $upgrade_notice ) {
set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
}
}
return $upgrade_notice;
}
|
[
"private",
"function",
"get_upgrade_notices",
"(",
"$",
"version",
",",
"$",
"url",
")",
"{",
"$",
"slug",
"=",
"$",
"this",
"->",
"get_plugin_slug",
"(",
"$",
"url",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"slug",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"transient_name",
"=",
"'upgrade_notice-'",
".",
"$",
"slug",
".",
"'_'",
".",
"$",
"version",
";",
"$",
"upgrade_notice",
"=",
"get_transient",
"(",
"$",
"transient_name",
")",
";",
"if",
"(",
"false",
"===",
"$",
"upgrade_notice",
")",
"{",
"$",
"upgrade_notice",
"=",
"$",
"this",
"->",
"get_upgrade_notice",
"(",
"$",
"slug",
")",
";",
"if",
"(",
"$",
"upgrade_notice",
")",
"{",
"set_transient",
"(",
"$",
"transient_name",
",",
"$",
"upgrade_notice",
",",
"DAY_IN_SECONDS",
")",
";",
"}",
"}",
"return",
"$",
"upgrade_notice",
";",
"}"
] |
@since 2.4.3
@since 2.6.0 Fixed: debug code
@param string $version
@param string $url
@return bool|mixed
|
[
"@since",
"2",
".",
"4",
".",
"3",
"@since",
"2",
".",
"6",
".",
"0",
"Fixed",
":",
"debug",
"code"
] |
train
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/upgrade.php#L268-L285
|
technote-space/wordpress-plugin-base
|
src/classes/models/lib/upgrade.php
|
Upgrade.get_plugin_slug
|
private function get_plugin_slug( $url ) {
if ( $this->app->utility->starts_with( $url, 'https://wordpress.org/plugins/' ) ) {
return trim( str_replace( 'https://wordpress.org/plugins/', '', $url ), '/' );
}
return false;
}
|
php
|
private function get_plugin_slug( $url ) {
if ( $this->app->utility->starts_with( $url, 'https://wordpress.org/plugins/' ) ) {
return trim( str_replace( 'https://wordpress.org/plugins/', '', $url ), '/' );
}
return false;
}
|
[
"private",
"function",
"get_plugin_slug",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"utility",
"->",
"starts_with",
"(",
"$",
"url",
",",
"'https://wordpress.org/plugins/'",
")",
")",
"{",
"return",
"trim",
"(",
"str_replace",
"(",
"'https://wordpress.org/plugins/'",
",",
"''",
",",
"$",
"url",
")",
",",
"'/'",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
@since 2.4.3
@param string $url
@return false|string
|
[
"@since",
"2",
".",
"4",
".",
"3"
] |
train
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/upgrade.php#L294-L300
|
technote-space/wordpress-plugin-base
|
src/classes/models/lib/upgrade.php
|
Upgrade.parse_update_notice
|
private function parse_update_notice( $content ) {
$notices = [];
$version_notices = [];
if ( preg_match( '#==\s*Upgrade Notice\s*==([\s\S]+?)==#', $content, $matches ) ) {
$version = false;
foreach ( (array) preg_split( '~[\r\n]+~', trim( $matches[1] ) ) as $line ) {
$line = preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
$line = preg_replace( '#\A\s*\*+\s*#', '', $line );
if ( preg_match( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', $line, $m1 ) && preg_match( '#\s*(v\.?)?(\d+[\d.]*)*\s*#', $m1[1], $m2 ) ) {
$version = $m2[2];
continue;
}
if ( $version && version_compare( $version, $this->app->get_plugin_version(), '<=' ) ) {
continue;
}
$line = preg_replace( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', '[ $1 ]', $line );
$line = trim( $line );
if ( '' !== $line ) {
if ( $version ) {
$version_notices[ $version ][] = $line;
} else {
$notices[] = $line;
}
}
}
if ( ! empty( $version_notices ) ) {
ksort( $version_notices );
foreach ( $version_notices as $version => $items ) {
$notices[ $version ] = $items;
}
}
}
return $notices;
}
|
php
|
private function parse_update_notice( $content ) {
$notices = [];
$version_notices = [];
if ( preg_match( '#==\s*Upgrade Notice\s*==([\s\S]+?)==#', $content, $matches ) ) {
$version = false;
foreach ( (array) preg_split( '~[\r\n]+~', trim( $matches[1] ) ) as $line ) {
$line = preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
$line = preg_replace( '#\A\s*\*+\s*#', '', $line );
if ( preg_match( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', $line, $m1 ) && preg_match( '#\s*(v\.?)?(\d+[\d.]*)*\s*#', $m1[1], $m2 ) ) {
$version = $m2[2];
continue;
}
if ( $version && version_compare( $version, $this->app->get_plugin_version(), '<=' ) ) {
continue;
}
$line = preg_replace( '#\A\s*=\s*([^\s]+)\s*=\s*\z#', '[ $1 ]', $line );
$line = trim( $line );
if ( '' !== $line ) {
if ( $version ) {
$version_notices[ $version ][] = $line;
} else {
$notices[] = $line;
}
}
}
if ( ! empty( $version_notices ) ) {
ksort( $version_notices );
foreach ( $version_notices as $version => $items ) {
$notices[ $version ] = $items;
}
}
}
return $notices;
}
|
[
"private",
"function",
"parse_update_notice",
"(",
"$",
"content",
")",
"{",
"$",
"notices",
"=",
"[",
"]",
";",
"$",
"version_notices",
"=",
"[",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'#==\\s*Upgrade Notice\\s*==([\\s\\S]+?)==#'",
",",
"$",
"content",
",",
"$",
"matches",
")",
")",
"{",
"$",
"version",
"=",
"false",
";",
"foreach",
"(",
"(",
"array",
")",
"preg_split",
"(",
"'~[\\r\\n]+~'",
",",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"preg_replace",
"(",
"'~\\[([^\\]]*)\\]\\(([^\\)]*)\\)~'",
",",
"'<a href=\"${2}\">${1}</a>'",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"preg_replace",
"(",
"'#\\A\\s*\\*+\\s*#'",
",",
"''",
",",
"$",
"line",
")",
";",
"if",
"(",
"preg_match",
"(",
"'#\\A\\s*=\\s*([^\\s]+)\\s*=\\s*\\z#'",
",",
"$",
"line",
",",
"$",
"m1",
")",
"&&",
"preg_match",
"(",
"'#\\s*(v\\.?)?(\\d+[\\d.]*)*\\s*#'",
",",
"$",
"m1",
"[",
"1",
"]",
",",
"$",
"m2",
")",
")",
"{",
"$",
"version",
"=",
"$",
"m2",
"[",
"2",
"]",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"version",
"&&",
"version_compare",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"app",
"->",
"get_plugin_version",
"(",
")",
",",
"'<='",
")",
")",
"{",
"continue",
";",
"}",
"$",
"line",
"=",
"preg_replace",
"(",
"'#\\A\\s*=\\s*([^\\s]+)\\s*=\\s*\\z#'",
",",
"'[ $1 ]'",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"version",
")",
"{",
"$",
"version_notices",
"[",
"$",
"version",
"]",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"else",
"{",
"$",
"notices",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"version_notices",
")",
")",
"{",
"ksort",
"(",
"$",
"version_notices",
")",
";",
"foreach",
"(",
"$",
"version_notices",
"as",
"$",
"version",
"=>",
"$",
"items",
")",
"{",
"$",
"notices",
"[",
"$",
"version",
"]",
"=",
"$",
"items",
";",
"}",
"}",
"}",
"return",
"$",
"notices",
";",
"}"
] |
@since 2.4.3
@since 2.10.0 Improved: multiple version
@param string $content
@return array
|
[
"@since",
"2",
".",
"4",
".",
"3",
"@since",
"2",
".",
"10",
".",
"0",
"Improved",
":",
"multiple",
"version"
] |
train
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/upgrade.php#L310-L344
|
GordonSchmidt/GSOcr
|
src/GSOcr/Service/OcrServiceFactory.php
|
OcrServiceFactory.createService
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Configuration');
if (!isset($config['ocr'])) {
throw new Exception\RuntimeException('No "ocr" section available in configuration.');
}
if (!isset($config['ocr']['service'])) {
throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
}
$service = $serviceLocator->get($config['ocr']['service']);
if (!$service instanceof OcrServiceInterface) {
throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
}
if (isset($config['ocr']['config'])) {
$service->setConfig($config['ocr']['config']);
}
return $service;
}
|
php
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Configuration');
if (!isset($config['ocr'])) {
throw new Exception\RuntimeException('No "ocr" section available in configuration.');
}
if (!isset($config['ocr']['service'])) {
throw new Exception\RuntimeException('No "service" specified in "ocr" section of configuration.');
}
$service = $serviceLocator->get($config['ocr']['service']);
if (!$service instanceof OcrServiceInterface) {
throw new Exception\RuntimeException('Provided service class is not a valid ocr service.');
}
if (isset($config['ocr']['config'])) {
$service->setConfig($config['ocr']['config']);
}
return $service;
}
|
[
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Configuration'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'ocr'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'No \"ocr\" section available in configuration.'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'ocr'",
"]",
"[",
"'service'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'No \"service\" specified in \"ocr\" section of configuration.'",
")",
";",
"}",
"$",
"service",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"$",
"config",
"[",
"'ocr'",
"]",
"[",
"'service'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"service",
"instanceof",
"OcrServiceInterface",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Provided service class is not a valid ocr service.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'ocr'",
"]",
"[",
"'config'",
"]",
")",
")",
"{",
"$",
"service",
"->",
"setConfig",
"(",
"$",
"config",
"[",
"'ocr'",
"]",
"[",
"'config'",
"]",
")",
";",
"}",
"return",
"$",
"service",
";",
"}"
] |
Create OCR service
@param ServiceLocatorInterface $serviceLocator
@return OcrServiceInterface
@throws InvalidArgumentException
|
[
"Create",
"OCR",
"service"
] |
train
|
https://github.com/GordonSchmidt/GSOcr/blob/b306f52d35fca8972957051d99cf96927051be79/src/GSOcr/Service/OcrServiceFactory.php#L32-L49
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.hasEndpoint
|
public function hasEndpoint($uri)
{
/** @var ArrayCollection $urlsFound */
$urlsFound = $this->getEndpoints()->filter(function (Endpoint $endpoint) use ($uri) {
// return when URI and URI string are equal
return (string) $endpoint->getUri() === $uri;
});
return $urlsFound->isEmpty() === false;
}
|
php
|
public function hasEndpoint($uri)
{
/** @var ArrayCollection $urlsFound */
$urlsFound = $this->getEndpoints()->filter(function (Endpoint $endpoint) use ($uri) {
// return when URI and URI string are equal
return (string) $endpoint->getUri() === $uri;
});
return $urlsFound->isEmpty() === false;
}
|
[
"public",
"function",
"hasEndpoint",
"(",
"$",
"uri",
")",
"{",
"/** @var ArrayCollection $urlsFound */",
"$",
"urlsFound",
"=",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"Endpoint",
"$",
"endpoint",
")",
"use",
"(",
"$",
"uri",
")",
"{",
"// return when URI and URI string are equal",
"return",
"(",
"string",
")",
"$",
"endpoint",
"->",
"getUri",
"(",
")",
"===",
"$",
"uri",
";",
"}",
")",
";",
"return",
"$",
"urlsFound",
"->",
"isEmpty",
"(",
")",
"===",
"false",
";",
"}"
] |
Checks if the given uri is already added to collection.
@param string $uri
@return bool
|
[
"Checks",
"if",
"the",
"given",
"uri",
"is",
"already",
"added",
"to",
"collection",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L60-L69
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.addEndpoint
|
public function addEndpoint(Endpoint $newEndpoint)
{
if ($this->hasEndpoint((string) $newEndpoint->getUri())) {
throw new InputException('Endpoint already added');
}
// all newly added Endpoints are set to DISABLED, apart from the first one
$status = $this->getEndpoints()->isEmpty() ? Endpoint::STATUS_ACTIVE : Endpoint::STATUS_DISABLED;
$newEndpoint->setStatus($status);
$this->getEndpoints()->add($newEndpoint);
}
|
php
|
public function addEndpoint(Endpoint $newEndpoint)
{
if ($this->hasEndpoint((string) $newEndpoint->getUri())) {
throw new InputException('Endpoint already added');
}
// all newly added Endpoints are set to DISABLED, apart from the first one
$status = $this->getEndpoints()->isEmpty() ? Endpoint::STATUS_ACTIVE : Endpoint::STATUS_DISABLED;
$newEndpoint->setStatus($status);
$this->getEndpoints()->add($newEndpoint);
}
|
[
"public",
"function",
"addEndpoint",
"(",
"Endpoint",
"$",
"newEndpoint",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasEndpoint",
"(",
"(",
"string",
")",
"$",
"newEndpoint",
"->",
"getUri",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InputException",
"(",
"'Endpoint already added'",
")",
";",
"}",
"// all newly added Endpoints are set to DISABLED, apart from the first one",
"$",
"status",
"=",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"isEmpty",
"(",
")",
"?",
"Endpoint",
"::",
"STATUS_ACTIVE",
":",
"Endpoint",
"::",
"STATUS_DISABLED",
";",
"$",
"newEndpoint",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"add",
"(",
"$",
"newEndpoint",
")",
";",
"}"
] |
Add Endpoint into the pool.
@param Endpoint $newEndpoint
@throws InputException
|
[
"Add",
"Endpoint",
"into",
"the",
"pool",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L78-L89
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.activateEndpoint
|
public function activateEndpoint(Endpoint $newActive, $force = false)
{
if (!$this->getEndpoints()->contains($newActive)) {
throw new InputException('Endpoint is not part of this manager');
}
if ($force === false && $this->canBeActivated($newActive) === false) {
throw new InputException('Can not activate this endpoint');
}
$this->disableAll();
$newActive->setStatus(Endpoint::STATUS_ACTIVE);
return $newActive;
}
|
php
|
public function activateEndpoint(Endpoint $newActive, $force = false)
{
if (!$this->getEndpoints()->contains($newActive)) {
throw new InputException('Endpoint is not part of this manager');
}
if ($force === false && $this->canBeActivated($newActive) === false) {
throw new InputException('Can not activate this endpoint');
}
$this->disableAll();
$newActive->setStatus(Endpoint::STATUS_ACTIVE);
return $newActive;
}
|
[
"public",
"function",
"activateEndpoint",
"(",
"Endpoint",
"$",
"newActive",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"contains",
"(",
"$",
"newActive",
")",
")",
"{",
"throw",
"new",
"InputException",
"(",
"'Endpoint is not part of this manager'",
")",
";",
"}",
"if",
"(",
"$",
"force",
"===",
"false",
"&&",
"$",
"this",
"->",
"canBeActivated",
"(",
"$",
"newActive",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"InputException",
"(",
"'Can not activate this endpoint'",
")",
";",
"}",
"$",
"this",
"->",
"disableAll",
"(",
")",
";",
"$",
"newActive",
"->",
"setStatus",
"(",
"Endpoint",
"::",
"STATUS_ACTIVE",
")",
";",
"return",
"$",
"newActive",
";",
"}"
] |
Try to activate an Endpoint as the active endpoint.
If endpoint status is Error, first check if it can be safely enabled.
@param Endpoint $newActive Endpoint to be enabled
@param bool $force when true, skips the cool down check
@throws InputException
@return Endpoint
|
[
"Try",
"to",
"activate",
"an",
"Endpoint",
"as",
"the",
"active",
"endpoint",
".",
"If",
"endpoint",
"status",
"is",
"Error",
"first",
"check",
"if",
"it",
"can",
"be",
"safely",
"enabled",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L112-L126
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.canBeActivated
|
private function canBeActivated(Endpoint $newActive)
{
// if newActive is currently in error, see if it can be re-enabled
if ($newActive->isError() === true) {
$offlineInterval = new \DateTime();
$offlineInterval->modify('-60 minutes');
return $newActive->getLastConnected() !== null && $newActive->getLastConnected() <= $offlineInterval;
}
return true;
}
|
php
|
private function canBeActivated(Endpoint $newActive)
{
// if newActive is currently in error, see if it can be re-enabled
if ($newActive->isError() === true) {
$offlineInterval = new \DateTime();
$offlineInterval->modify('-60 minutes');
return $newActive->getLastConnected() !== null && $newActive->getLastConnected() <= $offlineInterval;
}
return true;
}
|
[
"private",
"function",
"canBeActivated",
"(",
"Endpoint",
"$",
"newActive",
")",
"{",
"// if newActive is currently in error, see if it can be re-enabled",
"if",
"(",
"$",
"newActive",
"->",
"isError",
"(",
")",
"===",
"true",
")",
"{",
"$",
"offlineInterval",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"offlineInterval",
"->",
"modify",
"(",
"'-60 minutes'",
")",
";",
"return",
"$",
"newActive",
"->",
"getLastConnected",
"(",
")",
"!==",
"null",
"&&",
"$",
"newActive",
"->",
"getLastConnected",
"(",
")",
"<=",
"$",
"offlineInterval",
";",
"}",
"return",
"true",
";",
"}"
] |
Determine if this endpoint can re-enabled.
@param Endpoint $newActive
@return bool
|
[
"Determine",
"if",
"this",
"endpoint",
"can",
"re",
"-",
"enabled",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L135-L146
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.disableAll
|
private function disableAll()
{
// set all non-error endpoints to disabled
$this->getEndpoints()->map(function (Endpoint $endpoint) {
if ($endpoint->isError() === false) {
$endpoint->setStatus(Endpoint::STATUS_DISABLED);
}
});
}
|
php
|
private function disableAll()
{
// set all non-error endpoints to disabled
$this->getEndpoints()->map(function (Endpoint $endpoint) {
if ($endpoint->isError() === false) {
$endpoint->setStatus(Endpoint::STATUS_DISABLED);
}
});
}
|
[
"private",
"function",
"disableAll",
"(",
")",
"{",
"// set all non-error endpoints to disabled",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"Endpoint",
"$",
"endpoint",
")",
"{",
"if",
"(",
"$",
"endpoint",
"->",
"isError",
"(",
")",
"===",
"false",
")",
"{",
"$",
"endpoint",
"->",
"setStatus",
"(",
"Endpoint",
"::",
"STATUS_DISABLED",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Disable all endpoints, except the ones in error.
@throws InputException
|
[
"Disable",
"all",
"endpoints",
"except",
"the",
"ones",
"in",
"error",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L153-L161
|
webservices-nl/common
|
src/Common/Endpoint/Manager.php
|
Manager.getActiveEndpoint
|
public function getActiveEndpoint()
{
// try to get endpoint with status active
$active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
return $endpoint->isActive();
});
// when empty, try other endpoints
if ($active->isEmpty() === true) {
$active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
return $this->canBeActivated($endpoint);
});
}
if ($active->isEmpty() === true) {
throw new NoServerAvailableException('No active server available');
}
/** @var Endpoint $endpoint */
$endpoint = $active->first();
$endpoint->setStatus(Endpoint::STATUS_ACTIVE);
return $endpoint;
}
|
php
|
public function getActiveEndpoint()
{
// try to get endpoint with status active
$active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
return $endpoint->isActive();
});
// when empty, try other endpoints
if ($active->isEmpty() === true) {
$active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
return $this->canBeActivated($endpoint);
});
}
if ($active->isEmpty() === true) {
throw new NoServerAvailableException('No active server available');
}
/** @var Endpoint $endpoint */
$endpoint = $active->first();
$endpoint->setStatus(Endpoint::STATUS_ACTIVE);
return $endpoint;
}
|
[
"public",
"function",
"getActiveEndpoint",
"(",
")",
"{",
"// try to get endpoint with status active",
"$",
"active",
"=",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"Endpoint",
"$",
"endpoint",
")",
"{",
"return",
"$",
"endpoint",
"->",
"isActive",
"(",
")",
";",
"}",
")",
";",
"// when empty, try other endpoints",
"if",
"(",
"$",
"active",
"->",
"isEmpty",
"(",
")",
"===",
"true",
")",
"{",
"$",
"active",
"=",
"$",
"this",
"->",
"getEndpoints",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"Endpoint",
"$",
"endpoint",
")",
"{",
"return",
"$",
"this",
"->",
"canBeActivated",
"(",
"$",
"endpoint",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"$",
"active",
"->",
"isEmpty",
"(",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"NoServerAvailableException",
"(",
"'No active server available'",
")",
";",
"}",
"/** @var Endpoint $endpoint */",
"$",
"endpoint",
"=",
"$",
"active",
"->",
"first",
"(",
")",
";",
"$",
"endpoint",
"->",
"setStatus",
"(",
"Endpoint",
"::",
"STATUS_ACTIVE",
")",
";",
"return",
"$",
"endpoint",
";",
"}"
] |
Returns a active endpoint.
Tries to find the current active endpoint, or enable one.
@return Endpoint
@throws NoServerAvailableException
|
[
"Returns",
"a",
"active",
"endpoint",
".",
"Tries",
"to",
"find",
"the",
"current",
"active",
"endpoint",
"or",
"enable",
"one",
"."
] |
train
|
https://github.com/webservices-nl/common/blob/f867fb5969636b185b26442446bb021743a6515e/src/Common/Endpoint/Manager.php#L171-L194
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.connect
|
public function connect() {
// check if we need to convert host to IP
if (!preg_match('/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/', $this->host)) {
$ip = gethostbyname($this->host);
if ($this->host == $ip) {
throw new \Exception("Cannot resolve $this->host");
} else {
$this->host = $ip;
}
}
// attempt connection
$this->socket = fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout);
if (!$this->socket) {
throw new \Exception("Cannot connect to " . $this->host . " on port " . $this->port . "\n" . $this->errstr . ": " . $this->errstr);
}
return true;
}
|
php
|
public function connect() {
// check if we need to convert host to IP
if (!preg_match('/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/', $this->host)) {
$ip = gethostbyname($this->host);
if ($this->host == $ip) {
throw new \Exception("Cannot resolve $this->host");
} else {
$this->host = $ip;
}
}
// attempt connection
$this->socket = fsockopen($this->host, $this->port, $this->errno, $this->errstr, $this->timeout);
if (!$this->socket) {
throw new \Exception("Cannot connect to " . $this->host . " on port " . $this->port . "\n" . $this->errstr . ": " . $this->errstr);
}
return true;
}
|
[
"public",
"function",
"connect",
"(",
")",
"{",
"// check if we need to convert host to IP",
"if",
"(",
"!",
"preg_match",
"(",
"'/([0-9]{1,3}\\\\.){3,3}[0-9]{1,3}/'",
",",
"$",
"this",
"->",
"host",
")",
")",
"{",
"$",
"ip",
"=",
"gethostbyname",
"(",
"$",
"this",
"->",
"host",
")",
";",
"if",
"(",
"$",
"this",
"->",
"host",
"==",
"$",
"ip",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Cannot resolve $this->host\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"host",
"=",
"$",
"ip",
";",
"}",
"}",
"// attempt connection",
"$",
"this",
"->",
"socket",
"=",
"fsockopen",
"(",
"$",
"this",
"->",
"host",
",",
"$",
"this",
"->",
"port",
",",
"$",
"this",
"->",
"errno",
",",
"$",
"this",
"->",
"errstr",
",",
"$",
"this",
"->",
"timeout",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Cannot connect to \"",
".",
"$",
"this",
"->",
"host",
".",
"\" on port \"",
".",
"$",
"this",
"->",
"port",
".",
"\"\\n\"",
".",
"$",
"this",
"->",
"errstr",
".",
"\": \"",
".",
"$",
"this",
"->",
"errstr",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Attempts connection to remote host. Returns TRUE if sucessful.
@return boolean
|
[
"Attempts",
"connection",
"to",
"remote",
"host",
".",
"Returns",
"TRUE",
"if",
"sucessful",
"."
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L173-L196
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.disconnect
|
public function disconnect() {
if ($this->socket) {
if (!fclose($this->socket)) {
throw new \Exception("Error while closing telnet socket");
}
$this->socket = NULL;
}
return true;
}
|
php
|
public function disconnect() {
if ($this->socket) {
if (!fclose($this->socket)) {
throw new \Exception("Error while closing telnet socket");
}
$this->socket = NULL;
}
return true;
}
|
[
"public",
"function",
"disconnect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"socket",
")",
"{",
"if",
"(",
"!",
"fclose",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Error while closing telnet socket\"",
")",
";",
"}",
"$",
"this",
"->",
"socket",
"=",
"NULL",
";",
"}",
"return",
"true",
";",
"}"
] |
Closes IP socket
@return boolean
|
[
"Closes",
"IP",
"socket"
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L203-L211
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.readTo
|
public function readTo($prompt) {
if (!$this->socket) {
throw new \Exception("Telnet connection closed");
}
// clear the buffer
$this->clearBuffer();
$until_t = time() + $this->timeout;
do {
// time's up (loop can be exited at end or through continue!)
if (time() > $until_t) {
throw new \Exception("Couldn't find the requested : '$prompt' within {$this->timeout} seconds");
}
$c = $this->getc();
if ($c === false) {
throw new \Exception("Couldn't find the requested : '" . $prompt . "', it was not in the data returned from server: " . $this->buffer);
}
// Interpreted As Command
if ($c == $this->IAC) {
if ($this->negotiateTelnetOptions()) {
continue;
}
}
// append current char to global buffer
$this->buffer .= $c;
if ($this->debug_mode === 1 || $this->debug_mode === 3) {
$this->log($c);
}
// we've encountered the prompt. Break out of the loop
if ((substr($this->buffer, strlen($this->buffer) - strlen($prompt))) == $prompt) {
return true;
}
} while ($c != $this->NULL || $c != $this->DC1);
}
|
php
|
public function readTo($prompt) {
if (!$this->socket) {
throw new \Exception("Telnet connection closed");
}
// clear the buffer
$this->clearBuffer();
$until_t = time() + $this->timeout;
do {
// time's up (loop can be exited at end or through continue!)
if (time() > $until_t) {
throw new \Exception("Couldn't find the requested : '$prompt' within {$this->timeout} seconds");
}
$c = $this->getc();
if ($c === false) {
throw new \Exception("Couldn't find the requested : '" . $prompt . "', it was not in the data returned from server: " . $this->buffer);
}
// Interpreted As Command
if ($c == $this->IAC) {
if ($this->negotiateTelnetOptions()) {
continue;
}
}
// append current char to global buffer
$this->buffer .= $c;
if ($this->debug_mode === 1 || $this->debug_mode === 3) {
$this->log($c);
}
// we've encountered the prompt. Break out of the loop
if ((substr($this->buffer, strlen($this->buffer) - strlen($prompt))) == $prompt) {
return true;
}
} while ($c != $this->NULL || $c != $this->DC1);
}
|
[
"public",
"function",
"readTo",
"(",
"$",
"prompt",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Telnet connection closed\"",
")",
";",
"}",
"// clear the buffer ",
"$",
"this",
"->",
"clearBuffer",
"(",
")",
";",
"$",
"until_t",
"=",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"timeout",
";",
"do",
"{",
"// time's up (loop can be exited at end or through continue!)",
"if",
"(",
"time",
"(",
")",
">",
"$",
"until_t",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Couldn't find the requested : '$prompt' within {$this->timeout} seconds\"",
")",
";",
"}",
"$",
"c",
"=",
"$",
"this",
"->",
"getc",
"(",
")",
";",
"if",
"(",
"$",
"c",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Couldn't find the requested : '\"",
".",
"$",
"prompt",
".",
"\"', it was not in the data returned from server: \"",
".",
"$",
"this",
"->",
"buffer",
")",
";",
"}",
"// Interpreted As Command",
"if",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"IAC",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"negotiateTelnetOptions",
"(",
")",
")",
"{",
"continue",
";",
"}",
"}",
"// append current char to global buffer ",
"$",
"this",
"->",
"buffer",
".=",
"$",
"c",
";",
"if",
"(",
"$",
"this",
"->",
"debug_mode",
"===",
"1",
"||",
"$",
"this",
"->",
"debug_mode",
"===",
"3",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"c",
")",
";",
"}",
"// we've encountered the prompt. Break out of the loop",
"if",
"(",
"(",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"strlen",
"(",
"$",
"this",
"->",
"buffer",
")",
"-",
"strlen",
"(",
"$",
"prompt",
")",
")",
")",
"==",
"$",
"prompt",
")",
"{",
"return",
"true",
";",
"}",
"}",
"while",
"(",
"$",
"c",
"!=",
"$",
"this",
"->",
"NULL",
"||",
"$",
"c",
"!=",
"$",
"this",
"->",
"DC1",
")",
";",
"}"
] |
Reads characters from the socket and adds them to command buffer.
Handles telnet control characters. Stops when prompt is ecountered.
@param string $prompt
@return boolean
|
[
"Reads",
"characters",
"from",
"the",
"socket",
"and",
"adds",
"them",
"to",
"command",
"buffer",
".",
"Handles",
"telnet",
"control",
"characters",
".",
"Stops",
"when",
"prompt",
"is",
"ecountered",
"."
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L266-L306
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.write
|
public function write($buffer, $addNewLine = true) {
if (!$this->socket) {
throw new \Exception("Telnet connection closed");
}
// clear buffer from last command
$this->clearBuffer();
if ($addNewLine == true) {
$buffer .= "\n";
}
$this->global_buffer .= $buffer;
if ($this->debug_mode === 2 || $this->debug_mode === 3) {
$this->log($buffer);
}
if (!fwrite($this->socket, $buffer) < 0) {
throw new \Exception("Error writing to socket");
}
return true;
}
|
php
|
public function write($buffer, $addNewLine = true) {
if (!$this->socket) {
throw new \Exception("Telnet connection closed");
}
// clear buffer from last command
$this->clearBuffer();
if ($addNewLine == true) {
$buffer .= "\n";
}
$this->global_buffer .= $buffer;
if ($this->debug_mode === 2 || $this->debug_mode === 3) {
$this->log($buffer);
}
if (!fwrite($this->socket, $buffer) < 0) {
throw new \Exception("Error writing to socket");
}
return true;
}
|
[
"public",
"function",
"write",
"(",
"$",
"buffer",
",",
"$",
"addNewLine",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Telnet connection closed\"",
")",
";",
"}",
"// clear buffer from last command",
"$",
"this",
"->",
"clearBuffer",
"(",
")",
";",
"if",
"(",
"$",
"addNewLine",
"==",
"true",
")",
"{",
"$",
"buffer",
".=",
"\"\\n\"",
";",
"}",
"$",
"this",
"->",
"global_buffer",
".=",
"$",
"buffer",
";",
"if",
"(",
"$",
"this",
"->",
"debug_mode",
"===",
"2",
"||",
"$",
"this",
"->",
"debug_mode",
"===",
"3",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"buffer",
")",
";",
"}",
"if",
"(",
"!",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"buffer",
")",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Error writing to socket\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Write command to a socket
@param string $buffer Stuff to write to socket
@param boolean $addNewLine Default true, adds newline to the command
@return boolean
|
[
"Write",
"command",
"to",
"a",
"socket"
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L315-L337
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.getBuffer
|
public function getBuffer() {
// cut last line (is always prompt)
$buf = explode("\n", $this->buffer);
unset($buf[count($buf) - 1]);
$buf = implode("\n", $buf);
return trim($buf);
}
|
php
|
public function getBuffer() {
// cut last line (is always prompt)
$buf = explode("\n", $this->buffer);
unset($buf[count($buf) - 1]);
$buf = implode("\n", $buf);
return trim($buf);
}
|
[
"public",
"function",
"getBuffer",
"(",
")",
"{",
"// cut last line (is always prompt)",
"$",
"buf",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"buffer",
")",
";",
"unset",
"(",
"$",
"buf",
"[",
"count",
"(",
"$",
"buf",
")",
"-",
"1",
"]",
")",
";",
"$",
"buf",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"buf",
")",
";",
"return",
"trim",
"(",
"$",
"buf",
")",
";",
"}"
] |
Returns the content of the command buffer
@return string Content of the command buffer
|
[
"Returns",
"the",
"content",
"of",
"the",
"command",
"buffer"
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L360-L366
|
surebert/surebert-framework
|
src/sb/Telnet.php
|
Telnet.negotiateTelnetOptions
|
public function negotiateTelnetOptions() {
$c = $this->getc();
if ($c != $this->IAC) {
if (($c == $this->DO) || ($c == $this->DONT)) {
$opt = $this->getc();
fwrite($this->socket, $this->IAC . $this->WONT . $opt);
} else if (($c == $this->WILL) || ($c == $this->WONT)) {
$opt = $this->getc();
fwrite($this->socket, $this->IAC . $this->DONT . $opt);
} else {
throw new \Exception('Error: unknown control character ' . ord($c));
}
} else {
throw new \Exception('Error: Something Wicked Happened');
}
return true;
}
|
php
|
public function negotiateTelnetOptions() {
$c = $this->getc();
if ($c != $this->IAC) {
if (($c == $this->DO) || ($c == $this->DONT)) {
$opt = $this->getc();
fwrite($this->socket, $this->IAC . $this->WONT . $opt);
} else if (($c == $this->WILL) || ($c == $this->WONT)) {
$opt = $this->getc();
fwrite($this->socket, $this->IAC . $this->DONT . $opt);
} else {
throw new \Exception('Error: unknown control character ' . ord($c));
}
} else {
throw new \Exception('Error: Something Wicked Happened');
}
return true;
}
|
[
"public",
"function",
"negotiateTelnetOptions",
"(",
")",
"{",
"$",
"c",
"=",
"$",
"this",
"->",
"getc",
"(",
")",
";",
"if",
"(",
"$",
"c",
"!=",
"$",
"this",
"->",
"IAC",
")",
"{",
"if",
"(",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"DO",
")",
"||",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"DONT",
")",
")",
"{",
"$",
"opt",
"=",
"$",
"this",
"->",
"getc",
"(",
")",
";",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"this",
"->",
"IAC",
".",
"$",
"this",
"->",
"WONT",
".",
"$",
"opt",
")",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"WILL",
")",
"||",
"(",
"$",
"c",
"==",
"$",
"this",
"->",
"WONT",
")",
")",
"{",
"$",
"opt",
"=",
"$",
"this",
"->",
"getc",
"(",
")",
";",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"this",
"->",
"IAC",
".",
"$",
"this",
"->",
"DONT",
".",
"$",
"opt",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Error: unknown control character '",
".",
"ord",
"(",
"$",
"c",
")",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Error: Something Wicked Happened'",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Telnet control character magic
@param string $command Character to check
@return boolean
|
[
"Telnet",
"control",
"character",
"magic"
] |
train
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Telnet.php#L383-L405
|
zhouyl/mellivora
|
Mellivora/Validation/Validator.php
|
Validator.rule
|
public function rule($field, callable $rule, $params = null, $message = null)
{
if ($message === null) {
$message = $params;
$params = [];
}
$this->rules[] = [$field, $rule, $params, $message];
return $this;
}
|
php
|
public function rule($field, callable $rule, $params = null, $message = null)
{
if ($message === null) {
$message = $params;
$params = [];
}
$this->rules[] = [$field, $rule, $params, $message];
return $this;
}
|
[
"public",
"function",
"rule",
"(",
"$",
"field",
",",
"callable",
"$",
"rule",
",",
"$",
"params",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"message",
"===",
"null",
")",
"{",
"$",
"message",
"=",
"$",
"params",
";",
"$",
"params",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"rules",
"[",
"]",
"=",
"[",
"$",
"field",
",",
"$",
"rule",
",",
"$",
"params",
",",
"$",
"message",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
新增校验规则
@param string $field
@param callable $rule
@param mixed $params
@param null|string $message
@return \Mellivora\Validation\Validator
|
[
"新增校验规则"
] |
train
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Validation/Validator.php#L90-L100
|
zhouyl/mellivora
|
Mellivora/Validation/Validator.php
|
Validator.check
|
public function check()
{
$required = Valid::class . '::required';
foreach ($this->rules as $rule) {
list($field, $rule, $params, $message) = $rule;
// 如果已经存在一条错误了,则后面的错误不再验证
if (isset($this->errors[$field])) {
continue;
}
$value = Arr::get($this->data, $field);
// 当规则为非空校验时,如果值为空,则不进行判断
if ($rule !== $required && !Valid::required($value)) {
continue;
}
$params = $this->normalizeParams($params, $rule, $value);
if (!call_user_func_array($rule, $params)) {
$this->errors[$field] = $message;
}
}
return count($this->errors) === 0;
}
|
php
|
public function check()
{
$required = Valid::class . '::required';
foreach ($this->rules as $rule) {
list($field, $rule, $params, $message) = $rule;
// 如果已经存在一条错误了,则后面的错误不再验证
if (isset($this->errors[$field])) {
continue;
}
$value = Arr::get($this->data, $field);
// 当规则为非空校验时,如果值为空,则不进行判断
if ($rule !== $required && !Valid::required($value)) {
continue;
}
$params = $this->normalizeParams($params, $rule, $value);
if (!call_user_func_array($rule, $params)) {
$this->errors[$field] = $message;
}
}
return count($this->errors) === 0;
}
|
[
"public",
"function",
"check",
"(",
")",
"{",
"$",
"required",
"=",
"Valid",
"::",
"class",
".",
"'::required'",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"list",
"(",
"$",
"field",
",",
"$",
"rule",
",",
"$",
"params",
",",
"$",
"message",
")",
"=",
"$",
"rule",
";",
"// 如果已经存在一条错误了,则后面的错误不再验证",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"field",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"field",
")",
";",
"// 当规则为非空校验时,如果值为空,则不进行判断",
"if",
"(",
"$",
"rule",
"!==",
"$",
"required",
"&&",
"!",
"Valid",
"::",
"required",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"normalizeParams",
"(",
"$",
"params",
",",
"$",
"rule",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"call_user_func_array",
"(",
"$",
"rule",
",",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"$",
"field",
"]",
"=",
"$",
"message",
";",
"}",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"errors",
")",
"===",
"0",
";",
"}"
] |
检查校验结果是否存在错误
@return bool
|
[
"检查校验结果是否存在错误"
] |
train
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Validation/Validator.php#L107-L134
|
zhouyl/mellivora
|
Mellivora/Validation/Validator.php
|
Validator.normalizeParams
|
protected function normalizeParams($params, $rule, $value)
{
if (is_array($params)) {
if (is_array($rule)) {
$ref = new ReflectionMethod(...$rule);
} elseif (is_string($rule) && strpos($rule, '::') !== false) {
$ref = new ReflectionMethod($rule);
} elseif ($rule instanceof Closure) {
$ref = new ReflectionFunction($rule);
}
if (isset($ref)) {
$parameters = $ref->getParameters();
if (isset($parameters[1]) && $parameters[1]->isArray()) {
$params = [$params];
}
} else {
$params = [$params];
}
} else {
$params = is_null($params) ? [] : [$params];
}
array_unshift($params, $value);
return $params;
}
|
php
|
protected function normalizeParams($params, $rule, $value)
{
if (is_array($params)) {
if (is_array($rule)) {
$ref = new ReflectionMethod(...$rule);
} elseif (is_string($rule) && strpos($rule, '::') !== false) {
$ref = new ReflectionMethod($rule);
} elseif ($rule instanceof Closure) {
$ref = new ReflectionFunction($rule);
}
if (isset($ref)) {
$parameters = $ref->getParameters();
if (isset($parameters[1]) && $parameters[1]->isArray()) {
$params = [$params];
}
} else {
$params = [$params];
}
} else {
$params = is_null($params) ? [] : [$params];
}
array_unshift($params, $value);
return $params;
}
|
[
"protected",
"function",
"normalizeParams",
"(",
"$",
"params",
",",
"$",
"rule",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"rule",
")",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionMethod",
"(",
"...",
"$",
"rule",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"rule",
")",
"&&",
"strpos",
"(",
"$",
"rule",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"rule",
")",
";",
"}",
"elseif",
"(",
"$",
"rule",
"instanceof",
"Closure",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"rule",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"ref",
")",
")",
"{",
"$",
"parameters",
"=",
"$",
"ref",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"1",
"]",
")",
"&&",
"$",
"parameters",
"[",
"1",
"]",
"->",
"isArray",
"(",
")",
")",
"{",
"$",
"params",
"=",
"[",
"$",
"params",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"params",
"=",
"[",
"$",
"params",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"params",
"=",
"is_null",
"(",
"$",
"params",
")",
"?",
"[",
"]",
":",
"[",
"$",
"params",
"]",
";",
"}",
"array_unshift",
"(",
"$",
"params",
",",
"$",
"value",
")",
";",
"return",
"$",
"params",
";",
"}"
] |
获得有效的验证参数
@param mixed $params
@param mixed $rule
@param mixed $value
@return array
|
[
"获得有效的验证参数"
] |
train
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Validation/Validator.php#L145-L171
|
rhosocial/yii2-user
|
forms/UsernameForm.php
|
UsernameForm.changeUsername
|
public function changeUsername()
{
if ($this->validate()) {
$username = $this->user->createUsername($this->username);
if (!$username) {
return false;
}
return $username->save();
}
return false;
}
|
php
|
public function changeUsername()
{
if ($this->validate()) {
$username = $this->user->createUsername($this->username);
if (!$username) {
return false;
}
return $username->save();
}
return false;
}
|
[
"public",
"function",
"changeUsername",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"username",
"=",
"$",
"this",
"->",
"user",
"->",
"createUsername",
"(",
"$",
"this",
"->",
"username",
")",
";",
"if",
"(",
"!",
"$",
"username",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"username",
"->",
"save",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Change username.
@return bool
|
[
"Change",
"username",
"."
] |
train
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/forms/UsernameForm.php#L84-L94
|
mikemiles86/bazaarvoice-request
|
src/Request/BazaarvoiceRequest.php
|
BazaarvoiceRequest.buildUrl
|
private function buildUrl($endpoint, array $additional_parameters = []) {
// Build base domain URI.
$base = ($this->use_stage ? 'stg.' : '') . $this->domain;
// Build initial array of parameters.
$parameters = [
'passKey=' . $this->apiKey,
'ApiVersion=' . self::$api_version,
];
// Adding additional parameters?
if (!empty($additional_parameters)) {
// Loop through each parameter to build out correctly.
foreach ($additional_parameters as $param_name => $param_value) {
// If value is an array, then passing multiple sub parameter values.
if (is_array($param_value)) {
// Build each sub parameter.
foreach ($param_value as $sub_param_name => $sub_param_value) {
// Add to parameters array.
$sub_param_value = is_array($sub_param_value) ? implode(",", $sub_param_value) : $sub_param_value;
$parameters[] = $param_name . '=' . $sub_param_name . ':' . $sub_param_value;
}
}
// Else it is just a single value parameter.
else {
// Add to parameters array.
$parameters[] = $param_name . '=' . $param_value;
}
}
}
// Implode all of the parameters.
$parameters = implode('&', $parameters);
// return the built url.
return $base . '/' . $endpoint . '.json?' . $parameters;
}
|
php
|
private function buildUrl($endpoint, array $additional_parameters = []) {
// Build base domain URI.
$base = ($this->use_stage ? 'stg.' : '') . $this->domain;
// Build initial array of parameters.
$parameters = [
'passKey=' . $this->apiKey,
'ApiVersion=' . self::$api_version,
];
// Adding additional parameters?
if (!empty($additional_parameters)) {
// Loop through each parameter to build out correctly.
foreach ($additional_parameters as $param_name => $param_value) {
// If value is an array, then passing multiple sub parameter values.
if (is_array($param_value)) {
// Build each sub parameter.
foreach ($param_value as $sub_param_name => $sub_param_value) {
// Add to parameters array.
$sub_param_value = is_array($sub_param_value) ? implode(",", $sub_param_value) : $sub_param_value;
$parameters[] = $param_name . '=' . $sub_param_name . ':' . $sub_param_value;
}
}
// Else it is just a single value parameter.
else {
// Add to parameters array.
$parameters[] = $param_name . '=' . $param_value;
}
}
}
// Implode all of the parameters.
$parameters = implode('&', $parameters);
// return the built url.
return $base . '/' . $endpoint . '.json?' . $parameters;
}
|
[
"private",
"function",
"buildUrl",
"(",
"$",
"endpoint",
",",
"array",
"$",
"additional_parameters",
"=",
"[",
"]",
")",
"{",
"// Build base domain URI.",
"$",
"base",
"=",
"(",
"$",
"this",
"->",
"use_stage",
"?",
"'stg.'",
":",
"''",
")",
".",
"$",
"this",
"->",
"domain",
";",
"// Build initial array of parameters.",
"$",
"parameters",
"=",
"[",
"'passKey='",
".",
"$",
"this",
"->",
"apiKey",
",",
"'ApiVersion='",
".",
"self",
"::",
"$",
"api_version",
",",
"]",
";",
"// Adding additional parameters?",
"if",
"(",
"!",
"empty",
"(",
"$",
"additional_parameters",
")",
")",
"{",
"// Loop through each parameter to build out correctly.",
"foreach",
"(",
"$",
"additional_parameters",
"as",
"$",
"param_name",
"=>",
"$",
"param_value",
")",
"{",
"// If value is an array, then passing multiple sub parameter values.",
"if",
"(",
"is_array",
"(",
"$",
"param_value",
")",
")",
"{",
"// Build each sub parameter.",
"foreach",
"(",
"$",
"param_value",
"as",
"$",
"sub_param_name",
"=>",
"$",
"sub_param_value",
")",
"{",
"// Add to parameters array.",
"$",
"sub_param_value",
"=",
"is_array",
"(",
"$",
"sub_param_value",
")",
"?",
"implode",
"(",
"\",\"",
",",
"$",
"sub_param_value",
")",
":",
"$",
"sub_param_value",
";",
"$",
"parameters",
"[",
"]",
"=",
"$",
"param_name",
".",
"'='",
".",
"$",
"sub_param_name",
".",
"':'",
".",
"$",
"sub_param_value",
";",
"}",
"}",
"// Else it is just a single value parameter.",
"else",
"{",
"// Add to parameters array.",
"$",
"parameters",
"[",
"]",
"=",
"$",
"param_name",
".",
"'='",
".",
"$",
"param_value",
";",
"}",
"}",
"}",
"// Implode all of the parameters.",
"$",
"parameters",
"=",
"implode",
"(",
"'&'",
",",
"$",
"parameters",
")",
";",
"// return the built url.",
"return",
"$",
"base",
".",
"'/'",
".",
"$",
"endpoint",
".",
"'.json?'",
".",
"$",
"parameters",
";",
"}"
] |
Create Bazaarvoice URL with added parameters.
@param string $endpoint
API endpoint to call.
@param array $additional_parameters
Key/value of url parameters to add to URL.
@return string
Formatted API request URL.
|
[
"Create",
"Bazaarvoice",
"URL",
"with",
"added",
"parameters",
"."
] |
train
|
https://github.com/mikemiles86/bazaarvoice-request/blob/7993b6252ef71437736cb6dc8ddbf2ca6f7b09bd/src/Request/BazaarvoiceRequest.php#L122-L157
|
mikemiles86/bazaarvoice-request
|
src/Request/BazaarvoiceRequest.php
|
BazaarvoiceRequest.splitConfiguration
|
private function splitConfiguration(array $options) {
$return_array = [
'method' => 'GET',
'arguments' => [],
'options' => [],
];
// Request method passed?
if (isset($options['method'])) {
$return_array['method'] = $options['method'];
}
// URL arguments passed?
if (isset($options['arguments'])) {
$return_array['arguments'] = $options['arguments'];
};
// Request options passed?
if (isset($options['options'])) {
$return_array['options'] = $options['options'];
}
return array_values($return_array);
}
|
php
|
private function splitConfiguration(array $options) {
$return_array = [
'method' => 'GET',
'arguments' => [],
'options' => [],
];
// Request method passed?
if (isset($options['method'])) {
$return_array['method'] = $options['method'];
}
// URL arguments passed?
if (isset($options['arguments'])) {
$return_array['arguments'] = $options['arguments'];
};
// Request options passed?
if (isset($options['options'])) {
$return_array['options'] = $options['options'];
}
return array_values($return_array);
}
|
[
"private",
"function",
"splitConfiguration",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"return_array",
"=",
"[",
"'method'",
"=>",
"'GET'",
",",
"'arguments'",
"=>",
"[",
"]",
",",
"'options'",
"=>",
"[",
"]",
",",
"]",
";",
"// Request method passed?",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'method'",
"]",
")",
")",
"{",
"$",
"return_array",
"[",
"'method'",
"]",
"=",
"$",
"options",
"[",
"'method'",
"]",
";",
"}",
"// URL arguments passed?",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'arguments'",
"]",
")",
")",
"{",
"$",
"return_array",
"[",
"'arguments'",
"]",
"=",
"$",
"options",
"[",
"'arguments'",
"]",
";",
"}",
";",
"// Request options passed?",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"return_array",
"[",
"'options'",
"]",
"=",
"$",
"options",
"[",
"'options'",
"]",
";",
"}",
"return",
"array_values",
"(",
"$",
"return_array",
")",
";",
"}"
] |
Splits API request options array into main buckets.
@param array $options
Key/Value array of api request options.
@return array
|
[
"Splits",
"API",
"request",
"options",
"array",
"into",
"main",
"buckets",
"."
] |
train
|
https://github.com/mikemiles86/bazaarvoice-request/blob/7993b6252ef71437736cb6dc8ddbf2ca6f7b09bd/src/Request/BazaarvoiceRequest.php#L167-L189
|
mikemiles86/bazaarvoice-request
|
src/Request/BazaarvoiceRequest.php
|
BazaarvoiceRequest.buildResponse
|
private function buildResponse($response_type, $method, $status_code, $request_url, array $configuration = [], array $response_data = []) {
$object = FALSE;
// Check that a string was passed.
if (is_string($response_type)) {
// Check to see if this class exists.
if (class_exists($response_type)) {
// Check that this class extends the ContentTypeBase class.
if (is_subclass_of($response_type, 'BazaarvoiceRequest\\Response\\BazaarvoiceResponseBase')) {
// Instantiate object of this class.
$object = new $response_type($method, $status_code, $request_url, $configuration, $response_data);
}
}
}
return $object;
}
|
php
|
private function buildResponse($response_type, $method, $status_code, $request_url, array $configuration = [], array $response_data = []) {
$object = FALSE;
// Check that a string was passed.
if (is_string($response_type)) {
// Check to see if this class exists.
if (class_exists($response_type)) {
// Check that this class extends the ContentTypeBase class.
if (is_subclass_of($response_type, 'BazaarvoiceRequest\\Response\\BazaarvoiceResponseBase')) {
// Instantiate object of this class.
$object = new $response_type($method, $status_code, $request_url, $configuration, $response_data);
}
}
}
return $object;
}
|
[
"private",
"function",
"buildResponse",
"(",
"$",
"response_type",
",",
"$",
"method",
",",
"$",
"status_code",
",",
"$",
"request_url",
",",
"array",
"$",
"configuration",
"=",
"[",
"]",
",",
"array",
"$",
"response_data",
"=",
"[",
"]",
")",
"{",
"$",
"object",
"=",
"FALSE",
";",
"// Check that a string was passed.",
"if",
"(",
"is_string",
"(",
"$",
"response_type",
")",
")",
"{",
"// Check to see if this class exists.",
"if",
"(",
"class_exists",
"(",
"$",
"response_type",
")",
")",
"{",
"// Check that this class extends the ContentTypeBase class.",
"if",
"(",
"is_subclass_of",
"(",
"$",
"response_type",
",",
"'BazaarvoiceRequest\\\\Response\\\\BazaarvoiceResponseBase'",
")",
")",
"{",
"// Instantiate object of this class.",
"$",
"object",
"=",
"new",
"$",
"response_type",
"(",
"$",
"method",
",",
"$",
"status_code",
",",
"$",
"request_url",
",",
"$",
"configuration",
",",
"$",
"response_data",
")",
";",
"}",
"}",
"}",
"return",
"$",
"object",
";",
"}"
] |
Returns a BazaarvoiceRequest\Response object.
@param string $response_type
Class name of response type to load.
@param string $method
HTTP request method.
@param string $status_code
HTTP request status code.
@param string $request_url
URL that request was made to.
@param array $configuration
Configuration settings that were used in request.
@param array $response_data
Raw data that was returned from response.
@return bool|mixed
FALSE or instance of response class.
|
[
"Returns",
"a",
"BazaarvoiceRequest",
"\\",
"Response",
"object",
"."
] |
train
|
https://github.com/mikemiles86/bazaarvoice-request/blob/7993b6252ef71437736cb6dc8ddbf2ca6f7b09bd/src/Request/BazaarvoiceRequest.php#L215-L230
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php
|
MethodAssembler.create
|
public function create($data)
{
$descriptor = new MethodDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$descriptor->setMethodName($data->getMethodName());
$response = new ReturnDescriptor('return');
$response->setTypes($this->builder->buildDescriptor(new Collection($data->getTypes())));
$descriptor->setResponse($response);
foreach ($data->getArguments() as $argument) {
$argumentDescriptor = $this->createArgumentDescriptorForMagicMethod($argument);
$descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
}
return $descriptor;
}
|
php
|
public function create($data)
{
$descriptor = new MethodDescriptor($data->getName());
$descriptor->setDescription($data->getDescription());
$descriptor->setMethodName($data->getMethodName());
$response = new ReturnDescriptor('return');
$response->setTypes($this->builder->buildDescriptor(new Collection($data->getTypes())));
$descriptor->setResponse($response);
foreach ($data->getArguments() as $argument) {
$argumentDescriptor = $this->createArgumentDescriptorForMagicMethod($argument);
$descriptor->getArguments()->set($argumentDescriptor->getName(), $argumentDescriptor);
}
return $descriptor;
}
|
[
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"descriptor",
"=",
"new",
"MethodDescriptor",
"(",
"$",
"data",
"->",
"getName",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setDescription",
"(",
"$",
"data",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"descriptor",
"->",
"setMethodName",
"(",
"$",
"data",
"->",
"getMethodName",
"(",
")",
")",
";",
"$",
"response",
"=",
"new",
"ReturnDescriptor",
"(",
"'return'",
")",
";",
"$",
"response",
"->",
"setTypes",
"(",
"$",
"this",
"->",
"builder",
"->",
"buildDescriptor",
"(",
"new",
"Collection",
"(",
"$",
"data",
"->",
"getTypes",
"(",
")",
")",
")",
")",
";",
"$",
"descriptor",
"->",
"setResponse",
"(",
"$",
"response",
")",
";",
"foreach",
"(",
"$",
"data",
"->",
"getArguments",
"(",
")",
"as",
"$",
"argument",
")",
"{",
"$",
"argumentDescriptor",
"=",
"$",
"this",
"->",
"createArgumentDescriptorForMagicMethod",
"(",
"$",
"argument",
")",
";",
"$",
"descriptor",
"->",
"getArguments",
"(",
")",
"->",
"set",
"(",
"$",
"argumentDescriptor",
"->",
"getName",
"(",
")",
",",
"$",
"argumentDescriptor",
")",
";",
"}",
"return",
"$",
"descriptor",
";",
"}"
] |
Creates a new Descriptor from the given Reflector.
@param MethodTag $data
@return MethodDescriptor
|
[
"Creates",
"a",
"new",
"Descriptor",
"from",
"the",
"given",
"Reflector",
"."
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php#L36-L52
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php
|
MethodAssembler.createArgumentDescriptorForMagicMethod
|
private function createArgumentDescriptorForMagicMethod($argument)
{
$argumentType = null;
$argumentName = null;
$argumentDefault = false; // false means we have not encountered the '=' yet.
foreach ($argument as $part) {
$part = trim($part);
if (!$part) {
continue;
}
// Type should not be assigned after name
if (!$argumentName && !$argumentType && $part{0} != '$') {
$argumentType = $part;
} elseif (!$argumentName && $part{0} == '$') {
$argumentName = $part;
} elseif ($part == '=') {
$argumentDefault = null;
} elseif ($argumentDefault === null) {
$argumentDefault = $part;
}
}
if ($argumentDefault === false) {
$argumentDefault = null;
}
// if no name is set but a type is then the input is malformed and we correct for it
if ($argumentType && !$argumentName) {
$argumentName = $argumentType;
$argumentType = null;
}
// if there is no type then we assume it is 'mixed'
if (!$argumentType) {
$argumentType = 'mixed';
}
$argumentDescriptor = new ArgumentDescriptor();
$argumentDescriptor->setTypes($this->builder->buildDescriptor(new Collection(array($argumentType))));
$argumentDescriptor->setName($argumentName[0] == '$' ? $argumentName : '$' . $argumentName);
$argumentDescriptor->setDefault($argumentDefault);
return $argumentDescriptor;
}
|
php
|
private function createArgumentDescriptorForMagicMethod($argument)
{
$argumentType = null;
$argumentName = null;
$argumentDefault = false; // false means we have not encountered the '=' yet.
foreach ($argument as $part) {
$part = trim($part);
if (!$part) {
continue;
}
// Type should not be assigned after name
if (!$argumentName && !$argumentType && $part{0} != '$') {
$argumentType = $part;
} elseif (!$argumentName && $part{0} == '$') {
$argumentName = $part;
} elseif ($part == '=') {
$argumentDefault = null;
} elseif ($argumentDefault === null) {
$argumentDefault = $part;
}
}
if ($argumentDefault === false) {
$argumentDefault = null;
}
// if no name is set but a type is then the input is malformed and we correct for it
if ($argumentType && !$argumentName) {
$argumentName = $argumentType;
$argumentType = null;
}
// if there is no type then we assume it is 'mixed'
if (!$argumentType) {
$argumentType = 'mixed';
}
$argumentDescriptor = new ArgumentDescriptor();
$argumentDescriptor->setTypes($this->builder->buildDescriptor(new Collection(array($argumentType))));
$argumentDescriptor->setName($argumentName[0] == '$' ? $argumentName : '$' . $argumentName);
$argumentDescriptor->setDefault($argumentDefault);
return $argumentDescriptor;
}
|
[
"private",
"function",
"createArgumentDescriptorForMagicMethod",
"(",
"$",
"argument",
")",
"{",
"$",
"argumentType",
"=",
"null",
";",
"$",
"argumentName",
"=",
"null",
";",
"$",
"argumentDefault",
"=",
"false",
";",
"// false means we have not encountered the '=' yet.",
"foreach",
"(",
"$",
"argument",
"as",
"$",
"part",
")",
"{",
"$",
"part",
"=",
"trim",
"(",
"$",
"part",
")",
";",
"if",
"(",
"!",
"$",
"part",
")",
"{",
"continue",
";",
"}",
"// Type should not be assigned after name",
"if",
"(",
"!",
"$",
"argumentName",
"&&",
"!",
"$",
"argumentType",
"&&",
"$",
"part",
"{",
"0",
"}",
"!=",
"'$'",
")",
"{",
"$",
"argumentType",
"=",
"$",
"part",
";",
"}",
"elseif",
"(",
"!",
"$",
"argumentName",
"&&",
"$",
"part",
"{",
"0",
"}",
"==",
"'$'",
")",
"{",
"$",
"argumentName",
"=",
"$",
"part",
";",
"}",
"elseif",
"(",
"$",
"part",
"==",
"'='",
")",
"{",
"$",
"argumentDefault",
"=",
"null",
";",
"}",
"elseif",
"(",
"$",
"argumentDefault",
"===",
"null",
")",
"{",
"$",
"argumentDefault",
"=",
"$",
"part",
";",
"}",
"}",
"if",
"(",
"$",
"argumentDefault",
"===",
"false",
")",
"{",
"$",
"argumentDefault",
"=",
"null",
";",
"}",
"// if no name is set but a type is then the input is malformed and we correct for it",
"if",
"(",
"$",
"argumentType",
"&&",
"!",
"$",
"argumentName",
")",
"{",
"$",
"argumentName",
"=",
"$",
"argumentType",
";",
"$",
"argumentType",
"=",
"null",
";",
"}",
"// if there is no type then we assume it is 'mixed'",
"if",
"(",
"!",
"$",
"argumentType",
")",
"{",
"$",
"argumentType",
"=",
"'mixed'",
";",
"}",
"$",
"argumentDescriptor",
"=",
"new",
"ArgumentDescriptor",
"(",
")",
";",
"$",
"argumentDescriptor",
"->",
"setTypes",
"(",
"$",
"this",
"->",
"builder",
"->",
"buildDescriptor",
"(",
"new",
"Collection",
"(",
"array",
"(",
"$",
"argumentType",
")",
")",
")",
")",
";",
"$",
"argumentDescriptor",
"->",
"setName",
"(",
"$",
"argumentName",
"[",
"0",
"]",
"==",
"'$'",
"?",
"$",
"argumentName",
":",
"'$'",
".",
"$",
"argumentName",
")",
";",
"$",
"argumentDescriptor",
"->",
"setDefault",
"(",
"$",
"argumentDefault",
")",
";",
"return",
"$",
"argumentDescriptor",
";",
"}"
] |
Construct an argument descriptor given the array representing an argument with a Method Tag in the Reflection
component.
@param string[] $argument
@return ArgumentDescriptor
|
[
"Construct",
"an",
"argument",
"descriptor",
"given",
"the",
"array",
"representing",
"an",
"argument",
"with",
"a",
"Method",
"Tag",
"in",
"the",
"Reflection",
"component",
"."
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/Tags/MethodAssembler.php#L62-L105
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Checkstyle.php
|
Checkstyle.transform
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $this->getDestinationPath($transformation);
$this->checkForSpacesInPath($artifact);
$document = new \DOMDocument();
$document->formatOutput = true;
$report = $document->createElement('checkstyle');
$report->setAttribute('version', '1.3.0');
$document->appendChild($report);
/** @var FileDescriptor $fileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$file = $document->createElement('file');
$file->setAttribute('name', $fileDescriptor->getPath());
$report->appendChild($file);
/** @var Error $error */
foreach ($fileDescriptor->getAllErrors()->getAll() as $error) {
$item = $document->createElement('error');
$item->setAttribute('line', $error->getLine());
$item->setAttribute('severity', $error->getSeverity());
$item->setAttribute(
'message',
vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext())
);
$item->setAttribute('source', 'phpDocumentor.file.'.$error->getCode());
$file->appendChild($item);
}
}
$this->saveCheckstyleReport($artifact, $document);
}
|
php
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $this->getDestinationPath($transformation);
$this->checkForSpacesInPath($artifact);
$document = new \DOMDocument();
$document->formatOutput = true;
$report = $document->createElement('checkstyle');
$report->setAttribute('version', '1.3.0');
$document->appendChild($report);
/** @var FileDescriptor $fileDescriptor */
foreach ($project->getFiles()->getAll() as $fileDescriptor) {
$file = $document->createElement('file');
$file->setAttribute('name', $fileDescriptor->getPath());
$report->appendChild($file);
/** @var Error $error */
foreach ($fileDescriptor->getAllErrors()->getAll() as $error) {
$item = $document->createElement('error');
$item->setAttribute('line', $error->getLine());
$item->setAttribute('severity', $error->getSeverity());
$item->setAttribute(
'message',
vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext())
);
$item->setAttribute('source', 'phpDocumentor.file.'.$error->getCode());
$file->appendChild($item);
}
}
$this->saveCheckstyleReport($artifact, $document);
}
|
[
"public",
"function",
"transform",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"artifact",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
"$",
"transformation",
")",
";",
"$",
"this",
"->",
"checkForSpacesInPath",
"(",
"$",
"artifact",
")",
";",
"$",
"document",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"document",
"->",
"formatOutput",
"=",
"true",
";",
"$",
"report",
"=",
"$",
"document",
"->",
"createElement",
"(",
"'checkstyle'",
")",
";",
"$",
"report",
"->",
"setAttribute",
"(",
"'version'",
",",
"'1.3.0'",
")",
";",
"$",
"document",
"->",
"appendChild",
"(",
"$",
"report",
")",
";",
"/** @var FileDescriptor $fileDescriptor */",
"foreach",
"(",
"$",
"project",
"->",
"getFiles",
"(",
")",
"->",
"getAll",
"(",
")",
"as",
"$",
"fileDescriptor",
")",
"{",
"$",
"file",
"=",
"$",
"document",
"->",
"createElement",
"(",
"'file'",
")",
";",
"$",
"file",
"->",
"setAttribute",
"(",
"'name'",
",",
"$",
"fileDescriptor",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"report",
"->",
"appendChild",
"(",
"$",
"file",
")",
";",
"/** @var Error $error */",
"foreach",
"(",
"$",
"fileDescriptor",
"->",
"getAllErrors",
"(",
")",
"->",
"getAll",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"item",
"=",
"$",
"document",
"->",
"createElement",
"(",
"'error'",
")",
";",
"$",
"item",
"->",
"setAttribute",
"(",
"'line'",
",",
"$",
"error",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"item",
"->",
"setAttribute",
"(",
"'severity'",
",",
"$",
"error",
"->",
"getSeverity",
"(",
")",
")",
";",
"$",
"item",
"->",
"setAttribute",
"(",
"'message'",
",",
"vsprintf",
"(",
"$",
"this",
"->",
"getTranslator",
"(",
")",
"->",
"translate",
"(",
"$",
"error",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"error",
"->",
"getContext",
"(",
")",
")",
")",
";",
"$",
"item",
"->",
"setAttribute",
"(",
"'source'",
",",
"'phpDocumentor.file.'",
".",
"$",
"error",
"->",
"getCode",
"(",
")",
")",
";",
"$",
"file",
"->",
"appendChild",
"(",
"$",
"item",
")",
";",
"}",
"}",
"$",
"this",
"->",
"saveCheckstyleReport",
"(",
"$",
"artifact",
",",
"$",
"document",
")",
";",
"}"
] |
This method generates the checkstyle.xml report
@param ProjectDescriptor $project Document containing the structure.
@param Transformation $transformation Transformation to execute.
@return void
|
[
"This",
"method",
"generates",
"the",
"checkstyle",
".",
"xml",
"report"
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Checkstyle.php#L60-L93
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Checkstyle.php
|
Checkstyle.getDestinationPath
|
protected function getDestinationPath(Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR . $transformation->getArtifact();
return $artifact;
}
|
php
|
protected function getDestinationPath(Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR . $transformation->getArtifact();
return $artifact;
}
|
[
"protected",
"function",
"getDestinationPath",
"(",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"artifact",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
";",
"return",
"$",
"artifact",
";",
"}"
] |
Retrieves the destination location for this artifact.
@param \phpDocumentor\Transformer\Transformation $transformation
@return string
|
[
"Retrieves",
"the",
"destination",
"location",
"for",
"this",
"artifact",
"."
] |
train
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Checkstyle.php#L102-L108
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.