id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
238,800
|
bkdotcom/Form
|
src/Field.php
|
Field.setValue
|
private function setValue($value, $store)
{
if (\in_array($this->attribs['type'], array('checkbox','select'))) {
if (\is_null($value)) {
$value = array();
}
$this->props['values'] = (array) $value;
} else {
$this->attribs['value'] = $value;
}
if ($store) {
if ($this->props['setValRaw']) {
\call_user_func($this->props['setValRaw'], $this, $value);
} elseif ($this->form) {
$this->form->setValue($this->attribs['name'], $value, $this->props['pageI']);
}
}
}
|
php
|
private function setValue($value, $store)
{
if (\in_array($this->attribs['type'], array('checkbox','select'))) {
if (\is_null($value)) {
$value = array();
}
$this->props['values'] = (array) $value;
} else {
$this->attribs['value'] = $value;
}
if ($store) {
if ($this->props['setValRaw']) {
\call_user_func($this->props['setValRaw'], $this, $value);
} elseif ($this->form) {
$this->form->setValue($this->attribs['name'], $value, $this->props['pageI']);
}
}
}
|
[
"private",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"store",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"this",
"->",
"attribs",
"[",
"'type'",
"]",
",",
"array",
"(",
"'checkbox'",
",",
"'select'",
")",
")",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"props",
"[",
"'values'",
"]",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attribs",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"store",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"props",
"[",
"'setValRaw'",
"]",
")",
"{",
"\\",
"call_user_func",
"(",
"$",
"this",
"->",
"props",
"[",
"'setValRaw'",
"]",
",",
"$",
"this",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"form",
")",
"{",
"$",
"this",
"->",
"form",
"->",
"setValue",
"(",
"$",
"this",
"->",
"attribs",
"[",
"'name'",
"]",
",",
"$",
"value",
",",
"$",
"this",
"->",
"props",
"[",
"'pageI'",
"]",
")",
";",
"}",
"}",
"}"
] |
Set field's value
@param mixed $value value
@param boolean $store store the value?
@return void
|
[
"Set",
"field",
"s",
"value"
] |
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
|
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L300-L317
|
238,801
|
bkdotcom/Form
|
src/Field.php
|
Field.val
|
public function val($val = null, $store = true)
{
if (\func_num_args()) {
// setting
$this->setValue($val, $store);
} else {
if ($this->props['getValFormatted'] && !\in_array('getValFormatted', $this->callStack)) {
$this->callStack[] = 'getValFormatted';
$return = \call_user_func($this->props['getValFormatted'], $this);
ArrayUtil::removeVal($this->callStack, 'getValFormatted');
return $return;
} else {
return $this->valRaw();
}
}
}
|
php
|
public function val($val = null, $store = true)
{
if (\func_num_args()) {
// setting
$this->setValue($val, $store);
} else {
if ($this->props['getValFormatted'] && !\in_array('getValFormatted', $this->callStack)) {
$this->callStack[] = 'getValFormatted';
$return = \call_user_func($this->props['getValFormatted'], $this);
ArrayUtil::removeVal($this->callStack, 'getValFormatted');
return $return;
} else {
return $this->valRaw();
}
}
}
|
[
"public",
"function",
"val",
"(",
"$",
"val",
"=",
"null",
",",
"$",
"store",
"=",
"true",
")",
"{",
"if",
"(",
"\\",
"func_num_args",
"(",
")",
")",
"{",
"// setting",
"$",
"this",
"->",
"setValue",
"(",
"$",
"val",
",",
"$",
"store",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"props",
"[",
"'getValFormatted'",
"]",
"&&",
"!",
"\\",
"in_array",
"(",
"'getValFormatted'",
",",
"$",
"this",
"->",
"callStack",
")",
")",
"{",
"$",
"this",
"->",
"callStack",
"[",
"]",
"=",
"'getValFormatted'",
";",
"$",
"return",
"=",
"\\",
"call_user_func",
"(",
"$",
"this",
"->",
"props",
"[",
"'getValFormatted'",
"]",
",",
"$",
"this",
")",
";",
"ArrayUtil",
"::",
"removeVal",
"(",
"$",
"this",
"->",
"callStack",
",",
"'getValFormatted'",
")",
";",
"return",
"$",
"return",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"valRaw",
"(",
")",
";",
"}",
"}",
"}"
] |
Get or set field's value
If getting, will return
+ formatted value if field has getValFormatted callable
+ raw value otherwise
@param mixed $val (optional) new value
@param boolean $store (true) store value?
@return mixed
|
[
"Get",
"or",
"set",
"field",
"s",
"value",
"If",
"getting",
"will",
"return",
"+",
"formatted",
"value",
"if",
"field",
"has",
"getValFormatted",
"callable",
"+",
"raw",
"value",
"otherwise"
] |
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
|
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L330-L345
|
238,802
|
bkdotcom/Form
|
src/Field.php
|
Field.validateCrs
|
protected function validateCrs()
{
$nonEmpty = array();
$enabled = array();
$required = array();
$optsValid = array();
foreach ($this->props['options'] as $opt) {
if (empty($opt['attribs']['disabled']) && !isset($opt['optgroup'])) {
$enabled[] = $opt['attribs']['value'];
$optsValid[] = $opt['attribs']['value'];
}
if (!empty($opt['attribs']['required'])) {
$required[] = $opt['attribs']['value'];
}
}
$values = $this->attribs['type'] == 'radio'
? (array) $this->attribs['value']
: $this->props['values'];
if (!empty($values)) {
$this->debug->log('values', $values);
foreach ($values as $k => $val) {
if (!\in_array($val, $optsValid)) {
$this->debug->warn('invalid answer!', $val);
unset($values[$k]);
} elseif ($val != '') {
$nonEmpty[] = $val;
}
}
}
if (($this->isRequired() || !empty($required) ) && !empty($enabled) && empty($nonEmpty)) {
$this->debug->log('required, enabled, & no value!');
$this->props['isValid'] = false;
}
}
|
php
|
protected function validateCrs()
{
$nonEmpty = array();
$enabled = array();
$required = array();
$optsValid = array();
foreach ($this->props['options'] as $opt) {
if (empty($opt['attribs']['disabled']) && !isset($opt['optgroup'])) {
$enabled[] = $opt['attribs']['value'];
$optsValid[] = $opt['attribs']['value'];
}
if (!empty($opt['attribs']['required'])) {
$required[] = $opt['attribs']['value'];
}
}
$values = $this->attribs['type'] == 'radio'
? (array) $this->attribs['value']
: $this->props['values'];
if (!empty($values)) {
$this->debug->log('values', $values);
foreach ($values as $k => $val) {
if (!\in_array($val, $optsValid)) {
$this->debug->warn('invalid answer!', $val);
unset($values[$k]);
} elseif ($val != '') {
$nonEmpty[] = $val;
}
}
}
if (($this->isRequired() || !empty($required) ) && !empty($enabled) && empty($nonEmpty)) {
$this->debug->log('required, enabled, & no value!');
$this->props['isValid'] = false;
}
}
|
[
"protected",
"function",
"validateCrs",
"(",
")",
"{",
"$",
"nonEmpty",
"=",
"array",
"(",
")",
";",
"$",
"enabled",
"=",
"array",
"(",
")",
";",
"$",
"required",
"=",
"array",
"(",
")",
";",
"$",
"optsValid",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"props",
"[",
"'options'",
"]",
"as",
"$",
"opt",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"opt",
"[",
"'attribs'",
"]",
"[",
"'disabled'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"opt",
"[",
"'optgroup'",
"]",
")",
")",
"{",
"$",
"enabled",
"[",
"]",
"=",
"$",
"opt",
"[",
"'attribs'",
"]",
"[",
"'value'",
"]",
";",
"$",
"optsValid",
"[",
"]",
"=",
"$",
"opt",
"[",
"'attribs'",
"]",
"[",
"'value'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"opt",
"[",
"'attribs'",
"]",
"[",
"'required'",
"]",
")",
")",
"{",
"$",
"required",
"[",
"]",
"=",
"$",
"opt",
"[",
"'attribs'",
"]",
"[",
"'value'",
"]",
";",
"}",
"}",
"$",
"values",
"=",
"$",
"this",
"->",
"attribs",
"[",
"'type'",
"]",
"==",
"'radio'",
"?",
"(",
"array",
")",
"$",
"this",
"->",
"attribs",
"[",
"'value'",
"]",
":",
"$",
"this",
"->",
"props",
"[",
"'values'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'values'",
",",
"$",
"values",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"k",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"val",
",",
"$",
"optsValid",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"warn",
"(",
"'invalid answer!'",
",",
"$",
"val",
")",
";",
"unset",
"(",
"$",
"values",
"[",
"$",
"k",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"val",
"!=",
"''",
")",
"{",
"$",
"nonEmpty",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"}",
"if",
"(",
"(",
"$",
"this",
"->",
"isRequired",
"(",
")",
"||",
"!",
"empty",
"(",
"$",
"required",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"enabled",
")",
"&&",
"empty",
"(",
"$",
"nonEmpty",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"->",
"log",
"(",
"'required, enabled, & no value!'",
")",
";",
"$",
"this",
"->",
"props",
"[",
"'isValid'",
"]",
"=",
"false",
";",
"}",
"}"
] |
Validate Checkbox, Radio, Select
@return void
|
[
"Validate",
"Checkbox",
"Radio",
"Select"
] |
6aa5704b20300e1c8bd1c187a4fa88db9d442cee
|
https://github.com/bkdotcom/Form/blob/6aa5704b20300e1c8bd1c187a4fa88db9d442cee/src/Field.php#L500-L533
|
238,803
|
apitude/apitude
|
src/API/Controller/AbstractCrudController.php
|
AbstractCrudController.read
|
public function read($id)
{
$class = $this->getEntityClassFromType($this->apiRecordType);
$entity = $this->getEntityManager()->find($class, $id);
if (!$entity) {
return new Response('', Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->getApiWriter()->writeObject($entity), Response::HTTP_CREATED);
}
|
php
|
public function read($id)
{
$class = $this->getEntityClassFromType($this->apiRecordType);
$entity = $this->getEntityManager()->find($class, $id);
if (!$entity) {
return new Response('', Response::HTTP_NOT_FOUND);
}
return new JsonResponse($this->getApiWriter()->writeObject($entity), Response::HTTP_CREATED);
}
|
[
"public",
"function",
"read",
"(",
"$",
"id",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getEntityClassFromType",
"(",
"$",
"this",
"->",
"apiRecordType",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"find",
"(",
"$",
"class",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"return",
"new",
"Response",
"(",
"''",
",",
"Response",
"::",
"HTTP_NOT_FOUND",
")",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"this",
"->",
"getApiWriter",
"(",
")",
"->",
"writeObject",
"(",
"$",
"entity",
")",
",",
"Response",
"::",
"HTTP_CREATED",
")",
";",
"}"
] |
Note that route must be set up to include an id parameter
@param $id
@return JsonResponse|Response
@internal param Request $request
|
[
"Note",
"that",
"route",
"must",
"be",
"set",
"up",
"to",
"include",
"an",
"id",
"parameter"
] |
ccf503e42214184f96cd73b4e0fc5d06c377bce5
|
https://github.com/apitude/apitude/blob/ccf503e42214184f96cd73b4e0fc5d06c377bce5/src/API/Controller/AbstractCrudController.php#L82-L92
|
238,804
|
seyon/Teamspeak3Framework
|
examples/apps/webinterface/lib/module.class.php
|
TS3WA_Module.getTS3Connection
|
protected function getTS3Connection()
{
$serverqry = TeamSpeak3_Helper_Uri::getSessParam("_serverqry");
if(!$serverqry)
{
throw new Exception("TeamSpeak3_Node_Abstract object does not exist in your current session");
}
$this->ts3 = unserialize($serverqry);
}
|
php
|
protected function getTS3Connection()
{
$serverqry = TeamSpeak3_Helper_Uri::getSessParam("_serverqry");
if(!$serverqry)
{
throw new Exception("TeamSpeak3_Node_Abstract object does not exist in your current session");
}
$this->ts3 = unserialize($serverqry);
}
|
[
"protected",
"function",
"getTS3Connection",
"(",
")",
"{",
"$",
"serverqry",
"=",
"TeamSpeak3_Helper_Uri",
"::",
"getSessParam",
"(",
"\"_serverqry\"",
")",
";",
"if",
"(",
"!",
"$",
"serverqry",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"TeamSpeak3_Node_Abstract object does not exist in your current session\"",
")",
";",
"}",
"$",
"this",
"->",
"ts3",
"=",
"unserialize",
"(",
"$",
"serverqry",
")",
";",
"}"
] |
Loads the TeamSpeak3_Node_Abstract object stored in the current session.
@return void
|
[
"Loads",
"the",
"TeamSpeak3_Node_Abstract",
"object",
"stored",
"in",
"the",
"current",
"session",
"."
] |
03f57dbac2197f3fe7cf95ae0124152d19d78832
|
https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/examples/apps/webinterface/lib/module.class.php#L135-L145
|
238,805
|
seyon/Teamspeak3Framework
|
examples/apps/webinterface/lib/module.class.php
|
TS3WA_Module.assignLastEvent
|
protected function assignLastEvent()
{
$this->tpl->assign("eventMesg", TeamSpeak3_Helper_Uri::getSessParam("_eventmesg"));
$this->tpl->assign("eventType", TeamSpeak3_Helper_Uri::getSessParam("_eventtype", "user"));
unset($_SESSION["_eventmesg"]);
unset($_SESSION["_eventtype"]);
}
|
php
|
protected function assignLastEvent()
{
$this->tpl->assign("eventMesg", TeamSpeak3_Helper_Uri::getSessParam("_eventmesg"));
$this->tpl->assign("eventType", TeamSpeak3_Helper_Uri::getSessParam("_eventtype", "user"));
unset($_SESSION["_eventmesg"]);
unset($_SESSION["_eventtype"]);
}
|
[
"protected",
"function",
"assignLastEvent",
"(",
")",
"{",
"$",
"this",
"->",
"tpl",
"->",
"assign",
"(",
"\"eventMesg\"",
",",
"TeamSpeak3_Helper_Uri",
"::",
"getSessParam",
"(",
"\"_eventmesg\"",
")",
")",
";",
"$",
"this",
"->",
"tpl",
"->",
"assign",
"(",
"\"eventType\"",
",",
"TeamSpeak3_Helper_Uri",
"::",
"getSessParam",
"(",
"\"_eventtype\"",
",",
"\"user\"",
")",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"\"_eventmesg\"",
"]",
")",
";",
"unset",
"(",
"$",
"_SESSION",
"[",
"\"_eventtype\"",
"]",
")",
";",
"}"
] |
Assigns available event messages to the template and deletes them from the session.
@return void
|
[
"Assigns",
"available",
"event",
"messages",
"to",
"the",
"template",
"and",
"deletes",
"them",
"from",
"the",
"session",
"."
] |
03f57dbac2197f3fe7cf95ae0124152d19d78832
|
https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/examples/apps/webinterface/lib/module.class.php#L163-L170
|
238,806
|
seyon/Teamspeak3Framework
|
examples/apps/webinterface/lib/module.class.php
|
TS3WA_Module.redirect
|
protected function redirect($module, $action = "index", $params = array())
{
$module = $this->app->getModuleKey() . "=" . $module;
$action = $action != "index" ? '&' . $this->app->getActionKey() . "=" . $action : "";
foreach($params as $key => $val)
{
$action .= "&" . $key . "=" . $val;
}
header("Location: " . TeamSpeak3_Helper_Uri::getBaseUri() . "?" . $module . $action);
exit;
}
|
php
|
protected function redirect($module, $action = "index", $params = array())
{
$module = $this->app->getModuleKey() . "=" . $module;
$action = $action != "index" ? '&' . $this->app->getActionKey() . "=" . $action : "";
foreach($params as $key => $val)
{
$action .= "&" . $key . "=" . $val;
}
header("Location: " . TeamSpeak3_Helper_Uri::getBaseUri() . "?" . $module . $action);
exit;
}
|
[
"protected",
"function",
"redirect",
"(",
"$",
"module",
",",
"$",
"action",
"=",
"\"index\"",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"app",
"->",
"getModuleKey",
"(",
")",
".",
"\"=\"",
".",
"$",
"module",
";",
"$",
"action",
"=",
"$",
"action",
"!=",
"\"index\"",
"?",
"'&'",
".",
"$",
"this",
"->",
"app",
"->",
"getActionKey",
"(",
")",
".",
"\"=\"",
".",
"$",
"action",
":",
"\"\"",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"action",
".=",
"\"&\"",
".",
"$",
"key",
".",
"\"=\"",
".",
"$",
"val",
";",
"}",
"header",
"(",
"\"Location: \"",
".",
"TeamSpeak3_Helper_Uri",
"::",
"getBaseUri",
"(",
")",
".",
"\"?\"",
".",
"$",
"module",
".",
"$",
"action",
")",
";",
"exit",
";",
"}"
] |
Redirects the client to a specified module and action.
@param string $module
@param string $action
@return void
|
[
"Redirects",
"the",
"client",
"to",
"a",
"specified",
"module",
"and",
"action",
"."
] |
03f57dbac2197f3fe7cf95ae0124152d19d78832
|
https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/examples/apps/webinterface/lib/module.class.php#L179-L192
|
238,807
|
seyon/Teamspeak3Framework
|
examples/apps/webinterface/lib/module.class.php
|
TS3WA_Module.dispatch
|
public function dispatch()
{
$moduleName = $this->app->getModuleName();
$actionName = $this->app->getActionName();
$layoutFile = $moduleName . ($actionName != "index" ? "_" . $actionName : "") . ".tpl.php";
$this->tpl->render($layoutFile);
}
|
php
|
public function dispatch()
{
$moduleName = $this->app->getModuleName();
$actionName = $this->app->getActionName();
$layoutFile = $moduleName . ($actionName != "index" ? "_" . $actionName : "") . ".tpl.php";
$this->tpl->render($layoutFile);
}
|
[
"public",
"function",
"dispatch",
"(",
")",
"{",
"$",
"moduleName",
"=",
"$",
"this",
"->",
"app",
"->",
"getModuleName",
"(",
")",
";",
"$",
"actionName",
"=",
"$",
"this",
"->",
"app",
"->",
"getActionName",
"(",
")",
";",
"$",
"layoutFile",
"=",
"$",
"moduleName",
".",
"(",
"$",
"actionName",
"!=",
"\"index\"",
"?",
"\"_\"",
".",
"$",
"actionName",
":",
"\"\"",
")",
".",
"\".tpl.php\"",
";",
"$",
"this",
"->",
"tpl",
"->",
"render",
"(",
"$",
"layoutFile",
")",
";",
"}"
] |
Renders a page for the module.
@return void
|
[
"Renders",
"a",
"page",
"for",
"the",
"module",
"."
] |
03f57dbac2197f3fe7cf95ae0124152d19d78832
|
https://github.com/seyon/Teamspeak3Framework/blob/03f57dbac2197f3fe7cf95ae0124152d19d78832/examples/apps/webinterface/lib/module.class.php#L199-L206
|
238,808
|
atelierspierrot/library
|
src/Library/CommandLine/Stream.php
|
Stream.error
|
public function error($str, $status = 1, $new_line = true)
{
fwrite($this->error, $str.( true===$new_line ? PHP_EOL : '' ));
fflush($this->error);
if ($status>0) exit($status);
}
|
php
|
public function error($str, $status = 1, $new_line = true)
{
fwrite($this->error, $str.( true===$new_line ? PHP_EOL : '' ));
fflush($this->error);
if ($status>0) exit($status);
}
|
[
"public",
"function",
"error",
"(",
"$",
"str",
",",
"$",
"status",
"=",
"1",
",",
"$",
"new_line",
"=",
"true",
")",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"error",
",",
"$",
"str",
".",
"(",
"true",
"===",
"$",
"new_line",
"?",
"PHP_EOL",
":",
"''",
")",
")",
";",
"fflush",
"(",
"$",
"this",
"->",
"error",
")",
";",
"if",
"(",
"$",
"status",
">",
"0",
")",
"exit",
"(",
"$",
"status",
")",
";",
"}"
] |
Write a message on `STDERR` and exit with an error status
@param string $str The error message string to write
@param int $status The error status for exit (default is `1`) ; you can set it on `0` to not exit
@param bool $new_line Pass a new line befor exit (default is `true`)
@return void
|
[
"Write",
"a",
"message",
"on",
"STDERR",
"and",
"exit",
"with",
"an",
"error",
"status"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/CommandLine/Stream.php#L93-L98
|
238,809
|
atelierspierrot/library
|
src/Library/CommandLine/Stream.php
|
Stream.write
|
public function write($str, $new_line = true)
{
fwrite($this->stream, $str.( true===$new_line ? PHP_EOL : '' ));
fflush($this->stream);
}
|
php
|
public function write($str, $new_line = true)
{
fwrite($this->stream, $str.( true===$new_line ? PHP_EOL : '' ));
fflush($this->stream);
}
|
[
"public",
"function",
"write",
"(",
"$",
"str",
",",
"$",
"new_line",
"=",
"true",
")",
"{",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"str",
".",
"(",
"true",
"===",
"$",
"new_line",
"?",
"PHP_EOL",
":",
"''",
")",
")",
";",
"fflush",
"(",
"$",
"this",
"->",
"stream",
")",
";",
"}"
] |
Write a message on `STDOUT`
@param string $str The error message string to write
@param bool $new_line Pass a new line befor exit (default is `true`)
@return void
|
[
"Write",
"a",
"message",
"on",
"STDOUT"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/CommandLine/Stream.php#L107-L111
|
238,810
|
atelierspierrot/library
|
src/Library/CommandLine/Stream.php
|
Stream.prompt
|
public function prompt($str)
{
self::write( $str, false );
$this->user_response = trim( fgets( $this->input, 4096 ) );
}
|
php
|
public function prompt($str)
{
self::write( $str, false );
$this->user_response = trim( fgets( $this->input, 4096 ) );
}
|
[
"public",
"function",
"prompt",
"(",
"$",
"str",
")",
"{",
"self",
"::",
"write",
"(",
"$",
"str",
",",
"false",
")",
";",
"$",
"this",
"->",
"user_response",
"=",
"trim",
"(",
"fgets",
"(",
"$",
"this",
"->",
"input",
",",
"4096",
")",
")",
";",
"}"
] |
Write a message on `STDOUT` and wait for a user input on `STDIN`
@param string $str The error message string to write
@return void
|
[
"Write",
"a",
"message",
"on",
"STDOUT",
"and",
"wait",
"for",
"a",
"user",
"input",
"on",
"STDIN"
] |
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
|
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/CommandLine/Stream.php#L119-L123
|
238,811
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.renderElement
|
protected function renderElement(ElementInterface $element)
{
$collection = $this->getAttributesCollection($element);
$this->addElementChildren($element, $collection);
$this->addElementDependencies($element, $collection);
$this->addElementRules($element, $collection);
return $this->formatter->formatAttributesCollection($collection);
}
|
php
|
protected function renderElement(ElementInterface $element)
{
$collection = $this->getAttributesCollection($element);
$this->addElementChildren($element, $collection);
$this->addElementDependencies($element, $collection);
$this->addElementRules($element, $collection);
return $this->formatter->formatAttributesCollection($collection);
}
|
[
"protected",
"function",
"renderElement",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getAttributesCollection",
"(",
"$",
"element",
")",
";",
"$",
"this",
"->",
"addElementChildren",
"(",
"$",
"element",
",",
"$",
"collection",
")",
";",
"$",
"this",
"->",
"addElementDependencies",
"(",
"$",
"element",
",",
"$",
"collection",
")",
";",
"$",
"this",
"->",
"addElementRules",
"(",
"$",
"element",
",",
"$",
"collection",
")",
";",
"return",
"$",
"this",
"->",
"formatter",
"->",
"formatAttributesCollection",
"(",
"$",
"collection",
")",
";",
"}"
] |
Renders single form element with additional attributes
@param ElementInterface $element
@return array
|
[
"Renders",
"single",
"form",
"element",
"with",
"additional",
"attributes"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L68-L77
|
238,812
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.addElementChildren
|
protected function addElementChildren(ElementInterface $element, AttributeCollection $collection)
{
$children = $element->getChildren();
if ($children->count()) {
$attribute = new Attribute('aoFields', $this->renderChildren($children), Attribute::TYPE_ARRAY);
$collection->add($attribute);
}
}
|
php
|
protected function addElementChildren(ElementInterface $element, AttributeCollection $collection)
{
$children = $element->getChildren();
if ($children->count()) {
$attribute = new Attribute('aoFields', $this->renderChildren($children), Attribute::TYPE_ARRAY);
$collection->add($attribute);
}
}
|
[
"protected",
"function",
"addElementChildren",
"(",
"ElementInterface",
"$",
"element",
",",
"AttributeCollection",
"$",
"collection",
")",
"{",
"$",
"children",
"=",
"$",
"element",
"->",
"getChildren",
"(",
")",
";",
"if",
"(",
"$",
"children",
"->",
"count",
"(",
")",
")",
"{",
"$",
"attribute",
"=",
"new",
"Attribute",
"(",
"'aoFields'",
",",
"$",
"this",
"->",
"renderChildren",
"(",
"$",
"children",
")",
",",
"Attribute",
"::",
"TYPE_ARRAY",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"$",
"attribute",
")",
";",
"}",
"}"
] |
Adds javascript children to element
@param ElementInterface $element
@param AttributeCollection $collection
|
[
"Adds",
"javascript",
"children",
"to",
"element"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L85-L92
|
238,813
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.addElementDependencies
|
protected function addElementDependencies(ElementInterface $element, AttributeCollection $collection)
{
if ($element->hasOption('dependencies') && count($element->getOption('dependencies'))) {
$dependencies = $this->formatter->formatDependencies($element->getOption('dependencies'));
$collection->add(new Attribute('agDependencies', $dependencies, Attribute::TYPE_ARRAY));
}
}
|
php
|
protected function addElementDependencies(ElementInterface $element, AttributeCollection $collection)
{
if ($element->hasOption('dependencies') && count($element->getOption('dependencies'))) {
$dependencies = $this->formatter->formatDependencies($element->getOption('dependencies'));
$collection->add(new Attribute('agDependencies', $dependencies, Attribute::TYPE_ARRAY));
}
}
|
[
"protected",
"function",
"addElementDependencies",
"(",
"ElementInterface",
"$",
"element",
",",
"AttributeCollection",
"$",
"collection",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"hasOption",
"(",
"'dependencies'",
")",
"&&",
"count",
"(",
"$",
"element",
"->",
"getOption",
"(",
"'dependencies'",
")",
")",
")",
"{",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"formatter",
"->",
"formatDependencies",
"(",
"$",
"element",
"->",
"getOption",
"(",
"'dependencies'",
")",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"new",
"Attribute",
"(",
"'agDependencies'",
",",
"$",
"dependencies",
",",
"Attribute",
"::",
"TYPE_ARRAY",
")",
")",
";",
"}",
"}"
] |
Adds javascript dependencies to element
@param ElementInterface $element
@param AttributeCollection $collection
|
[
"Adds",
"javascript",
"dependencies",
"to",
"element"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L100-L106
|
238,814
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.addElementRules
|
protected function addElementRules(ElementInterface $element, AttributeCollection $collection)
{
if ($element->hasOption('rules') && count($element->getOption('rules'))) {
$rules = $this->formatter->formatRules($element->getOption('rules'));
$collection->add(new Attribute('aoRules', $rules, Attribute::TYPE_ARRAY));
}
}
|
php
|
protected function addElementRules(ElementInterface $element, AttributeCollection $collection)
{
if ($element->hasOption('rules') && count($element->getOption('rules'))) {
$rules = $this->formatter->formatRules($element->getOption('rules'));
$collection->add(new Attribute('aoRules', $rules, Attribute::TYPE_ARRAY));
}
}
|
[
"protected",
"function",
"addElementRules",
"(",
"ElementInterface",
"$",
"element",
",",
"AttributeCollection",
"$",
"collection",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"hasOption",
"(",
"'rules'",
")",
"&&",
"count",
"(",
"$",
"element",
"->",
"getOption",
"(",
"'rules'",
")",
")",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"formatter",
"->",
"formatRules",
"(",
"$",
"element",
"->",
"getOption",
"(",
"'rules'",
")",
")",
";",
"$",
"collection",
"->",
"add",
"(",
"new",
"Attribute",
"(",
"'aoRules'",
",",
"$",
"rules",
",",
"Attribute",
"::",
"TYPE_ARRAY",
")",
")",
";",
"}",
"}"
] |
Adds javascript rules to element
@param ElementInterface $element
@param AttributeCollection $collection
|
[
"Adds",
"javascript",
"rules",
"to",
"element"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L114-L120
|
238,815
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.getAttributesCollection
|
protected function getAttributesCollection(ElementInterface $element) : AttributeCollection
{
$collection = new AttributeCollection();
$element->prepareAttributesCollection($collection);
return $collection;
}
|
php
|
protected function getAttributesCollection(ElementInterface $element) : AttributeCollection
{
$collection = new AttributeCollection();
$element->prepareAttributesCollection($collection);
return $collection;
}
|
[
"protected",
"function",
"getAttributesCollection",
"(",
"ElementInterface",
"$",
"element",
")",
":",
"AttributeCollection",
"{",
"$",
"collection",
"=",
"new",
"AttributeCollection",
"(",
")",
";",
"$",
"element",
"->",
"prepareAttributesCollection",
"(",
"$",
"collection",
")",
";",
"return",
"$",
"collection",
";",
"}"
] |
Returns attributes collection for element
@param ElementInterface $element
@return AttributeCollection
|
[
"Returns",
"attributes",
"collection",
"for",
"element"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L129-L135
|
238,816
|
WellCommerce/Form
|
Renderer/JavascriptRenderer.php
|
JavascriptRenderer.renderChildren
|
protected function renderChildren(ElementCollection $children)
{
$attributes = [];
$children->forAll(function (ElementInterface $child) use (&$attributes) {
$attributes[] = $this->renderElement($child);
});
return $attributes;
}
|
php
|
protected function renderChildren(ElementCollection $children)
{
$attributes = [];
$children->forAll(function (ElementInterface $child) use (&$attributes) {
$attributes[] = $this->renderElement($child);
});
return $attributes;
}
|
[
"protected",
"function",
"renderChildren",
"(",
"ElementCollection",
"$",
"children",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"children",
"->",
"forAll",
"(",
"function",
"(",
"ElementInterface",
"$",
"child",
")",
"use",
"(",
"&",
"$",
"attributes",
")",
"{",
"$",
"attributes",
"[",
"]",
"=",
"$",
"this",
"->",
"renderElement",
"(",
"$",
"child",
")",
";",
"}",
")",
";",
"return",
"$",
"attributes",
";",
"}"
] |
Renders all children elements
@param ElementCollection $children
@return array
|
[
"Renders",
"all",
"children",
"elements"
] |
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
|
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/Renderer/JavascriptRenderer.php#L144-L153
|
238,817
|
marando/phpSOFA
|
src/Marando/IAU/iauFw2m.php
|
iauFw2m.Fw2m
|
public static function Fw2m($gamb, $phib, $psi, $eps, array &$r) {
/* Construct the matrix. */
IAU::Ir($r);
IAU::Rz($gamb, $r);
IAU::Rx($phib, $r);
IAU::Rz(-$psi, $r);
IAU::Rx(-$eps, $r);
return;
}
|
php
|
public static function Fw2m($gamb, $phib, $psi, $eps, array &$r) {
/* Construct the matrix. */
IAU::Ir($r);
IAU::Rz($gamb, $r);
IAU::Rx($phib, $r);
IAU::Rz(-$psi, $r);
IAU::Rx(-$eps, $r);
return;
}
|
[
"public",
"static",
"function",
"Fw2m",
"(",
"$",
"gamb",
",",
"$",
"phib",
",",
"$",
"psi",
",",
"$",
"eps",
",",
"array",
"&",
"$",
"r",
")",
"{",
"/* Construct the matrix. */",
"IAU",
"::",
"Ir",
"(",
"$",
"r",
")",
";",
"IAU",
"::",
"Rz",
"(",
"$",
"gamb",
",",
"$",
"r",
")",
";",
"IAU",
"::",
"Rx",
"(",
"$",
"phib",
",",
"$",
"r",
")",
";",
"IAU",
"::",
"Rz",
"(",
"-",
"$",
"psi",
",",
"$",
"r",
")",
";",
"IAU",
"::",
"Rx",
"(",
"-",
"$",
"eps",
",",
"$",
"r",
")",
";",
"return",
";",
"}"
] |
- - - - - - - -
i a u F w 2 m
- - - - - - - -
Form rotation matrix given the Fukushima-Williams angles.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: support function.
Given:
gamb double F-W angle gamma_bar (radians)
phib double F-W angle phi_bar (radians)
psi double F-W angle psi (radians)
eps double F-W angle epsilon (radians)
Returned:
r double[3][3] rotation matrix
Notes:
1) Naming the following points:
e = J2000.0 ecliptic pole,
p = GCRS pole,
E = ecliptic pole of date,
and P = CIP,
the four Fukushima-Williams angles are as follows:
gamb = gamma = epE
phib = phi = pE
psi = psi = pEP
eps = epsilon = EP
2) The matrix representing the combined effects of frame bias,
precession and nutation is:
NxPxB = R_1(-eps).R_3(-psi).R_1(phib).R_3(gamb)
3) Three different matrices can be constructed, depending on the
supplied angles:
o To obtain the nutation x precession x frame bias matrix,
generate the four precession angles, generate the nutation
components and add them to the psi_bar and epsilon_A angles,
and call the present function.
o To obtain the precession x frame bias matrix, generate the
four precession angles and call the present function.
o To obtain the frame bias matrix, generate the four precession
angles for date J2000.0 and call the present function.
The nutation-only and precession-only matrices can if necessary
be obtained by combining these three appropriately.
Called:
iauIr initialize r-matrix to identity
iauRz rotate around Z-axis
iauRx rotate around X-axis
Reference:
Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"F",
"w",
"2",
"m",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauFw2m.php#L81-L90
|
238,818
|
lhs168/fasim
|
src/Fasim/Facades/Facade.php
|
Facade.getFacadeRoot
|
public static function getFacadeRoot() {
$accessor = static::getFacadeAccessor();
$instance = Application::getInstance()->make($accessor);
if ($instance == null) {
throw new Exception('Facade get null for: '.$accessor);
}
return $instance;
}
|
php
|
public static function getFacadeRoot() {
$accessor = static::getFacadeAccessor();
$instance = Application::getInstance()->make($accessor);
if ($instance == null) {
throw new Exception('Facade get null for: '.$accessor);
}
return $instance;
}
|
[
"public",
"static",
"function",
"getFacadeRoot",
"(",
")",
"{",
"$",
"accessor",
"=",
"static",
"::",
"getFacadeAccessor",
"(",
")",
";",
"$",
"instance",
"=",
"Application",
"::",
"getInstance",
"(",
")",
"->",
"make",
"(",
"$",
"accessor",
")",
";",
"if",
"(",
"$",
"instance",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Facade get null for: '",
".",
"$",
"accessor",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Get the root object behind the facade.
@return mixed
|
[
"Get",
"the",
"root",
"object",
"behind",
"the",
"facade",
"."
] |
df31e249593380421785f0be342cfb92cbb1d1d7
|
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Facades/Facade.php#L43-L50
|
238,819
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
PhpErrorException.recover
|
public function recover()
{
// handle the error based on the config and the environment we're in
if (static::$count <= Config::get('errors.throttle', 10))
{
logger(\Fuel::L_ERROR, $this->code.' - '.$this->message.' in '.$this->file.' on line '.$this->line);
if (\Fuel::$env != \Fuel::PRODUCTION and ($this->code & error_reporting()) == $this->code)
{
static::$count++;
\Error::show_php_error(new \ErrorException($this->message, $this->code, 0, $this->file, $this->line));
}
}
elseif (\Fuel::$env != \Fuel::PRODUCTION
and static::$count == (\Config::get('errors.throttle', 10) + 1)
and ($this->severity & error_reporting()) == $this->severity)
{
static::$count++;
\Error::notice('Error throttling threshold was reached, no more full error reports are shown.', true);
}
}
|
php
|
public function recover()
{
// handle the error based on the config and the environment we're in
if (static::$count <= Config::get('errors.throttle', 10))
{
logger(\Fuel::L_ERROR, $this->code.' - '.$this->message.' in '.$this->file.' on line '.$this->line);
if (\Fuel::$env != \Fuel::PRODUCTION and ($this->code & error_reporting()) == $this->code)
{
static::$count++;
\Error::show_php_error(new \ErrorException($this->message, $this->code, 0, $this->file, $this->line));
}
}
elseif (\Fuel::$env != \Fuel::PRODUCTION
and static::$count == (\Config::get('errors.throttle', 10) + 1)
and ($this->severity & error_reporting()) == $this->severity)
{
static::$count++;
\Error::notice('Error throttling threshold was reached, no more full error reports are shown.', true);
}
}
|
[
"public",
"function",
"recover",
"(",
")",
"{",
"// handle the error based on the config and the environment we're in",
"if",
"(",
"static",
"::",
"$",
"count",
"<=",
"Config",
"::",
"get",
"(",
"'errors.throttle'",
",",
"10",
")",
")",
"{",
"logger",
"(",
"\\",
"Fuel",
"::",
"L_ERROR",
",",
"$",
"this",
"->",
"code",
".",
"' - '",
".",
"$",
"this",
"->",
"message",
".",
"' in '",
".",
"$",
"this",
"->",
"file",
".",
"' on line '",
".",
"$",
"this",
"->",
"line",
")",
";",
"if",
"(",
"\\",
"Fuel",
"::",
"$",
"env",
"!=",
"\\",
"Fuel",
"::",
"PRODUCTION",
"and",
"(",
"$",
"this",
"->",
"code",
"&",
"error_reporting",
"(",
")",
")",
"==",
"$",
"this",
"->",
"code",
")",
"{",
"static",
"::",
"$",
"count",
"++",
";",
"\\",
"Error",
"::",
"show_php_error",
"(",
"new",
"\\",
"ErrorException",
"(",
"$",
"this",
"->",
"message",
",",
"$",
"this",
"->",
"code",
",",
"0",
",",
"$",
"this",
"->",
"file",
",",
"$",
"this",
"->",
"line",
")",
")",
";",
"}",
"}",
"elseif",
"(",
"\\",
"Fuel",
"::",
"$",
"env",
"!=",
"\\",
"Fuel",
"::",
"PRODUCTION",
"and",
"static",
"::",
"$",
"count",
"==",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'errors.throttle'",
",",
"10",
")",
"+",
"1",
")",
"and",
"(",
"$",
"this",
"->",
"severity",
"&",
"error_reporting",
"(",
")",
")",
"==",
"$",
"this",
"->",
"severity",
")",
"{",
"static",
"::",
"$",
"count",
"++",
";",
"\\",
"Error",
"::",
"notice",
"(",
"'Error throttling threshold was reached, no more full error reports are shown.'",
",",
"true",
")",
";",
"}",
"}"
] |
Allow the error handler from recovering from error types defined in the config
|
[
"Allow",
"the",
"error",
"handler",
"from",
"recovering",
"from",
"error",
"types",
"defined",
"in",
"the",
"config"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L25-L45
|
238,820
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
Error.shutdown_handler
|
public static function shutdown_handler()
{
$last_error = error_get_last();
// Only show valid fatal errors
if ($last_error AND in_array($last_error['type'], static::$fatal_levels))
{
$severity = static::$levels[$last_error['type']];
logger(\Fuel::L_ERROR, $severity.' - '.$last_error['message'].' in '.$last_error['file'].' on line '.$last_error['line']);
$error = new \ErrorException($last_error['message'], $last_error['type'], 0, $last_error['file'], $last_error['line']);
if (\Fuel::$env != \Fuel::PRODUCTION)
{
static::show_php_error($error);
}
else
{
static::show_production_error($error);
}
exit(1);
}
}
|
php
|
public static function shutdown_handler()
{
$last_error = error_get_last();
// Only show valid fatal errors
if ($last_error AND in_array($last_error['type'], static::$fatal_levels))
{
$severity = static::$levels[$last_error['type']];
logger(\Fuel::L_ERROR, $severity.' - '.$last_error['message'].' in '.$last_error['file'].' on line '.$last_error['line']);
$error = new \ErrorException($last_error['message'], $last_error['type'], 0, $last_error['file'], $last_error['line']);
if (\Fuel::$env != \Fuel::PRODUCTION)
{
static::show_php_error($error);
}
else
{
static::show_production_error($error);
}
exit(1);
}
}
|
[
"public",
"static",
"function",
"shutdown_handler",
"(",
")",
"{",
"$",
"last_error",
"=",
"error_get_last",
"(",
")",
";",
"// Only show valid fatal errors",
"if",
"(",
"$",
"last_error",
"AND",
"in_array",
"(",
"$",
"last_error",
"[",
"'type'",
"]",
",",
"static",
"::",
"$",
"fatal_levels",
")",
")",
"{",
"$",
"severity",
"=",
"static",
"::",
"$",
"levels",
"[",
"$",
"last_error",
"[",
"'type'",
"]",
"]",
";",
"logger",
"(",
"\\",
"Fuel",
"::",
"L_ERROR",
",",
"$",
"severity",
".",
"' - '",
".",
"$",
"last_error",
"[",
"'message'",
"]",
".",
"' in '",
".",
"$",
"last_error",
"[",
"'file'",
"]",
".",
"' on line '",
".",
"$",
"last_error",
"[",
"'line'",
"]",
")",
";",
"$",
"error",
"=",
"new",
"\\",
"ErrorException",
"(",
"$",
"last_error",
"[",
"'message'",
"]",
",",
"$",
"last_error",
"[",
"'type'",
"]",
",",
"0",
",",
"$",
"last_error",
"[",
"'file'",
"]",
",",
"$",
"last_error",
"[",
"'line'",
"]",
")",
";",
"if",
"(",
"\\",
"Fuel",
"::",
"$",
"env",
"!=",
"\\",
"Fuel",
"::",
"PRODUCTION",
")",
"{",
"static",
"::",
"show_php_error",
"(",
"$",
"error",
")",
";",
"}",
"else",
"{",
"static",
"::",
"show_production_error",
"(",
"$",
"error",
")",
";",
"}",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] |
Native PHP shutdown handler
@return string
|
[
"Native",
"PHP",
"shutdown",
"handler"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L82-L104
|
238,821
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
Error.exception_handler
|
public static function exception_handler(\Exception $e)
{
if (method_exists($e, 'handle'))
{
return $e->handle();
}
$severity = ( ! isset(static::$levels[$e->getCode()])) ? $e->getCode() : static::$levels[$e->getCode()];
logger(\Fuel::L_ERROR, $severity.' - '.$e->getMessage().' in '.$e->getFile().' on line '.$e->getLine());
if (\Fuel::$env != \Fuel::PRODUCTION)
{
static::show_php_error($e);
}
else
{
static::show_production_error($e);
}
}
|
php
|
public static function exception_handler(\Exception $e)
{
if (method_exists($e, 'handle'))
{
return $e->handle();
}
$severity = ( ! isset(static::$levels[$e->getCode()])) ? $e->getCode() : static::$levels[$e->getCode()];
logger(\Fuel::L_ERROR, $severity.' - '.$e->getMessage().' in '.$e->getFile().' on line '.$e->getLine());
if (\Fuel::$env != \Fuel::PRODUCTION)
{
static::show_php_error($e);
}
else
{
static::show_production_error($e);
}
}
|
[
"public",
"static",
"function",
"exception_handler",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"e",
",",
"'handle'",
")",
")",
"{",
"return",
"$",
"e",
"->",
"handle",
"(",
")",
";",
"}",
"$",
"severity",
"=",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"levels",
"[",
"$",
"e",
"->",
"getCode",
"(",
")",
"]",
")",
")",
"?",
"$",
"e",
"->",
"getCode",
"(",
")",
":",
"static",
"::",
"$",
"levels",
"[",
"$",
"e",
"->",
"getCode",
"(",
")",
"]",
";",
"logger",
"(",
"\\",
"Fuel",
"::",
"L_ERROR",
",",
"$",
"severity",
".",
"' - '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"' in '",
".",
"$",
"e",
"->",
"getFile",
"(",
")",
".",
"' on line '",
".",
"$",
"e",
"->",
"getLine",
"(",
")",
")",
";",
"if",
"(",
"\\",
"Fuel",
"::",
"$",
"env",
"!=",
"\\",
"Fuel",
"::",
"PRODUCTION",
")",
"{",
"static",
"::",
"show_php_error",
"(",
"$",
"e",
")",
";",
"}",
"else",
"{",
"static",
"::",
"show_production_error",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
PHP Exception handler
@param Exception $e the exception
@return bool
|
[
"PHP",
"Exception",
"handler"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L112-L130
|
238,822
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
Error.error_handler
|
public static function error_handler($severity, $message, $filepath, $line)
{
// don't do anything if error reporting is disabled
if (error_reporting() !== 0)
{
$fatal = (bool)( ! in_array($severity, \Config::get('errors.continue_on', array())));
if ($fatal)
{
throw new \PhpErrorException($message, $severity, 0, $filepath, $line);
}
else
{
// non-fatal, recover from the error
$e = new \PhpErrorException($message, $severity, 0, $filepath, $line);
$e->recover();
}
}
return true;
}
|
php
|
public static function error_handler($severity, $message, $filepath, $line)
{
// don't do anything if error reporting is disabled
if (error_reporting() !== 0)
{
$fatal = (bool)( ! in_array($severity, \Config::get('errors.continue_on', array())));
if ($fatal)
{
throw new \PhpErrorException($message, $severity, 0, $filepath, $line);
}
else
{
// non-fatal, recover from the error
$e = new \PhpErrorException($message, $severity, 0, $filepath, $line);
$e->recover();
}
}
return true;
}
|
[
"public",
"static",
"function",
"error_handler",
"(",
"$",
"severity",
",",
"$",
"message",
",",
"$",
"filepath",
",",
"$",
"line",
")",
"{",
"// don't do anything if error reporting is disabled",
"if",
"(",
"error_reporting",
"(",
")",
"!==",
"0",
")",
"{",
"$",
"fatal",
"=",
"(",
"bool",
")",
"(",
"!",
"in_array",
"(",
"$",
"severity",
",",
"\\",
"Config",
"::",
"get",
"(",
"'errors.continue_on'",
",",
"array",
"(",
")",
")",
")",
")",
";",
"if",
"(",
"$",
"fatal",
")",
"{",
"throw",
"new",
"\\",
"PhpErrorException",
"(",
"$",
"message",
",",
"$",
"severity",
",",
"0",
",",
"$",
"filepath",
",",
"$",
"line",
")",
";",
"}",
"else",
"{",
"// non-fatal, recover from the error",
"$",
"e",
"=",
"new",
"\\",
"PhpErrorException",
"(",
"$",
"message",
",",
"$",
"severity",
",",
"0",
",",
"$",
"filepath",
",",
"$",
"line",
")",
";",
"$",
"e",
"->",
"recover",
"(",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
PHP Error handler
@param int $severity the severity code
@param string $message the error message
@param string $filepath the path to the file throwing the error
@param int $line the line number of the error
@return bool whether to continue with execution
|
[
"PHP",
"Error",
"handler"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L141-L161
|
238,823
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
Error.show_php_error
|
public static function show_php_error(\Exception $e)
{
$fatal = (bool)( ! in_array($e->getCode(), \Config::get('errors.continue_on', array())));
$data = static::prepare_exception($e, $fatal);
if ($fatal)
{
$data['contents'] = ob_get_contents();
while (ob_get_level() > 0)
{
ob_end_clean();
}
ob_start(\Config::get('ob_callback', null));
}
else
{
static::$non_fatal_cache[] = $data;
}
if (\Fuel::$is_cli)
{
\Cli::write(\Cli::color($data['severity'].' - '.$data['message'].' in '.\Fuel::clean_path($data['filepath']).' on line '.$data['error_line'], 'red'));
if (\Config::get('cli_backtrace'))
{
\Cli::write('Stack trace:');
\Cli::write(\Debug::backtrace($e->getTrace()));
}
return;
}
if ($fatal)
{
if ( ! headers_sent())
{
$protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1';
header($protocol.' 500 Internal Server Error');
}
$data['non_fatal'] = static::$non_fatal_cache;
try
{
exit(\View::forge('errors'.DS.'php_fatal_error', $data, false));
}
catch (\FuelException $view_exception)
{
exit($data['severity'].' - '.$data['message'].' in '.\Fuel::clean_path($data['filepath']).' on line '.$data['error_line']);
}
}
try
{
echo \View::forge('errors'.DS.'php_error', $data, false);
}
catch (\FuelException $e)
{
echo $e->getMessage().'<br />';
}
}
|
php
|
public static function show_php_error(\Exception $e)
{
$fatal = (bool)( ! in_array($e->getCode(), \Config::get('errors.continue_on', array())));
$data = static::prepare_exception($e, $fatal);
if ($fatal)
{
$data['contents'] = ob_get_contents();
while (ob_get_level() > 0)
{
ob_end_clean();
}
ob_start(\Config::get('ob_callback', null));
}
else
{
static::$non_fatal_cache[] = $data;
}
if (\Fuel::$is_cli)
{
\Cli::write(\Cli::color($data['severity'].' - '.$data['message'].' in '.\Fuel::clean_path($data['filepath']).' on line '.$data['error_line'], 'red'));
if (\Config::get('cli_backtrace'))
{
\Cli::write('Stack trace:');
\Cli::write(\Debug::backtrace($e->getTrace()));
}
return;
}
if ($fatal)
{
if ( ! headers_sent())
{
$protocol = \Input::server('SERVER_PROTOCOL') ? \Input::server('SERVER_PROTOCOL') : 'HTTP/1.1';
header($protocol.' 500 Internal Server Error');
}
$data['non_fatal'] = static::$non_fatal_cache;
try
{
exit(\View::forge('errors'.DS.'php_fatal_error', $data, false));
}
catch (\FuelException $view_exception)
{
exit($data['severity'].' - '.$data['message'].' in '.\Fuel::clean_path($data['filepath']).' on line '.$data['error_line']);
}
}
try
{
echo \View::forge('errors'.DS.'php_error', $data, false);
}
catch (\FuelException $e)
{
echo $e->getMessage().'<br />';
}
}
|
[
"public",
"static",
"function",
"show_php_error",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"fatal",
"=",
"(",
"bool",
")",
"(",
"!",
"in_array",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"\\",
"Config",
"::",
"get",
"(",
"'errors.continue_on'",
",",
"array",
"(",
")",
")",
")",
")",
";",
"$",
"data",
"=",
"static",
"::",
"prepare_exception",
"(",
"$",
"e",
",",
"$",
"fatal",
")",
";",
"if",
"(",
"$",
"fatal",
")",
"{",
"$",
"data",
"[",
"'contents'",
"]",
"=",
"ob_get_contents",
"(",
")",
";",
"while",
"(",
"ob_get_level",
"(",
")",
">",
"0",
")",
"{",
"ob_end_clean",
"(",
")",
";",
"}",
"ob_start",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'ob_callback'",
",",
"null",
")",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"non_fatal_cache",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"if",
"(",
"\\",
"Fuel",
"::",
"$",
"is_cli",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"\\",
"Cli",
"::",
"color",
"(",
"$",
"data",
"[",
"'severity'",
"]",
".",
"' - '",
".",
"$",
"data",
"[",
"'message'",
"]",
".",
"' in '",
".",
"\\",
"Fuel",
"::",
"clean_path",
"(",
"$",
"data",
"[",
"'filepath'",
"]",
")",
".",
"' on line '",
".",
"$",
"data",
"[",
"'error_line'",
"]",
",",
"'red'",
")",
")",
";",
"if",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'cli_backtrace'",
")",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"'Stack trace:'",
")",
";",
"\\",
"Cli",
"::",
"write",
"(",
"\\",
"Debug",
"::",
"backtrace",
"(",
"$",
"e",
"->",
"getTrace",
"(",
")",
")",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"$",
"fatal",
")",
"{",
"if",
"(",
"!",
"headers_sent",
"(",
")",
")",
"{",
"$",
"protocol",
"=",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_PROTOCOL'",
")",
"?",
"\\",
"Input",
"::",
"server",
"(",
"'SERVER_PROTOCOL'",
")",
":",
"'HTTP/1.1'",
";",
"header",
"(",
"$",
"protocol",
".",
"' 500 Internal Server Error'",
")",
";",
"}",
"$",
"data",
"[",
"'non_fatal'",
"]",
"=",
"static",
"::",
"$",
"non_fatal_cache",
";",
"try",
"{",
"exit",
"(",
"\\",
"View",
"::",
"forge",
"(",
"'errors'",
".",
"DS",
".",
"'php_fatal_error'",
",",
"$",
"data",
",",
"false",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"FuelException",
"$",
"view_exception",
")",
"{",
"exit",
"(",
"$",
"data",
"[",
"'severity'",
"]",
".",
"' - '",
".",
"$",
"data",
"[",
"'message'",
"]",
".",
"' in '",
".",
"\\",
"Fuel",
"::",
"clean_path",
"(",
"$",
"data",
"[",
"'filepath'",
"]",
")",
".",
"' on line '",
".",
"$",
"data",
"[",
"'error_line'",
"]",
")",
";",
"}",
"}",
"try",
"{",
"echo",
"\\",
"View",
"::",
"forge",
"(",
"'errors'",
".",
"DS",
".",
"'php_error'",
",",
"$",
"data",
",",
"false",
")",
";",
"}",
"catch",
"(",
"\\",
"FuelException",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"'<br />'",
";",
"}",
"}"
] |
Shows an error. It will stop script execution if the error code is not
in the errors.continue_on whitelist.
@param Exception $e the exception to show
@return void
|
[
"Shows",
"an",
"error",
".",
"It",
"will",
"stop",
"script",
"execution",
"if",
"the",
"error",
"code",
"is",
"not",
"in",
"the",
"errors",
".",
"continue_on",
"whitelist",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L170-L228
|
238,824
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/error.php
|
Error.notice
|
public static function notice($msg, $always_show = false)
{
$trace = array_merge(array('file' => '(unknown)', 'line' => '(unknown)'), \Arr::get(debug_backtrace(), 1));
logger(\Fuel::L_DEBUG, 'Notice - '.$msg.' in '.$trace['file'].' on line '.$trace['line']);
if (\Fuel::$is_test or ( ! $always_show and (\Fuel::$env == \Fuel::PRODUCTION or \Config::get('errors.notices', true) === false)))
{
return;
}
$data['message'] = $msg;
$data['type'] = 'Notice';
$data['filepath'] = \Fuel::clean_path($trace['file']);
$data['line'] = $trace['line'];
$data['function'] = $trace['function'];
echo \View::forge('errors'.DS.'php_short', $data, false);
}
|
php
|
public static function notice($msg, $always_show = false)
{
$trace = array_merge(array('file' => '(unknown)', 'line' => '(unknown)'), \Arr::get(debug_backtrace(), 1));
logger(\Fuel::L_DEBUG, 'Notice - '.$msg.' in '.$trace['file'].' on line '.$trace['line']);
if (\Fuel::$is_test or ( ! $always_show and (\Fuel::$env == \Fuel::PRODUCTION or \Config::get('errors.notices', true) === false)))
{
return;
}
$data['message'] = $msg;
$data['type'] = 'Notice';
$data['filepath'] = \Fuel::clean_path($trace['file']);
$data['line'] = $trace['line'];
$data['function'] = $trace['function'];
echo \View::forge('errors'.DS.'php_short', $data, false);
}
|
[
"public",
"static",
"function",
"notice",
"(",
"$",
"msg",
",",
"$",
"always_show",
"=",
"false",
")",
"{",
"$",
"trace",
"=",
"array_merge",
"(",
"array",
"(",
"'file'",
"=>",
"'(unknown)'",
",",
"'line'",
"=>",
"'(unknown)'",
")",
",",
"\\",
"Arr",
"::",
"get",
"(",
"debug_backtrace",
"(",
")",
",",
"1",
")",
")",
";",
"logger",
"(",
"\\",
"Fuel",
"::",
"L_DEBUG",
",",
"'Notice - '",
".",
"$",
"msg",
".",
"' in '",
".",
"$",
"trace",
"[",
"'file'",
"]",
".",
"' on line '",
".",
"$",
"trace",
"[",
"'line'",
"]",
")",
";",
"if",
"(",
"\\",
"Fuel",
"::",
"$",
"is_test",
"or",
"(",
"!",
"$",
"always_show",
"and",
"(",
"\\",
"Fuel",
"::",
"$",
"env",
"==",
"\\",
"Fuel",
"::",
"PRODUCTION",
"or",
"\\",
"Config",
"::",
"get",
"(",
"'errors.notices'",
",",
"true",
")",
"===",
"false",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"data",
"[",
"'message'",
"]",
"=",
"$",
"msg",
";",
"$",
"data",
"[",
"'type'",
"]",
"=",
"'Notice'",
";",
"$",
"data",
"[",
"'filepath'",
"]",
"=",
"\\",
"Fuel",
"::",
"clean_path",
"(",
"$",
"trace",
"[",
"'file'",
"]",
")",
";",
"$",
"data",
"[",
"'line'",
"]",
"=",
"$",
"trace",
"[",
"'line'",
"]",
";",
"$",
"data",
"[",
"'function'",
"]",
"=",
"$",
"trace",
"[",
"'function'",
"]",
";",
"echo",
"\\",
"View",
"::",
"forge",
"(",
"'errors'",
".",
"DS",
".",
"'php_short'",
",",
"$",
"data",
",",
"false",
")",
";",
"}"
] |
Shows a small notice error, only when not in production or when forced.
This is used by several libraries to notify the developer of certain things.
@param string $msg the message to display
@param bool $always_show whether to force display the notice or not
@return void
|
[
"Shows",
"a",
"small",
"notice",
"error",
"only",
"when",
"not",
"in",
"production",
"or",
"when",
"forced",
".",
"This",
"is",
"used",
"by",
"several",
"libraries",
"to",
"notify",
"the",
"developer",
"of",
"certain",
"things",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/error.php#L238-L255
|
238,825
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.userWithPass
|
public function userWithPass($username, $password)
{
$header = base64_encode(sprintf('%s:%s', $username, $password));
$this->headers['Authorization'] = 'Basic ' . $header;
}
|
php
|
public function userWithPass($username, $password)
{
$header = base64_encode(sprintf('%s:%s', $username, $password));
$this->headers['Authorization'] = 'Basic ' . $header;
}
|
[
"public",
"function",
"userWithPass",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"header",
"=",
"base64_encode",
"(",
"sprintf",
"(",
"'%s:%s'",
",",
"$",
"username",
",",
"$",
"password",
")",
")",
";",
"$",
"this",
"->",
"headers",
"[",
"'Authorization'",
"]",
"=",
"'Basic '",
".",
"$",
"header",
";",
"}"
] |
Set the username and password for send request
@Given /^user "([^"]+)" with pass "([^"]+)"$/
@param string $username
@param string $password
|
[
"Set",
"the",
"username",
"and",
"password",
"for",
"send",
"request"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L72-L77
|
238,826
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.responseIsSuccessfully
|
public function responseIsSuccessfully()
{
Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
'Response with error "%s".',
$this->response->getBody()
));
Assertions::assertNull($this->response->getRpcErrorCode(), sprintf(
'Response with error "%s".',
$this->response->getBody()
));
}
|
php
|
public function responseIsSuccessfully()
{
Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
'Response with error "%s".',
$this->response->getBody()
));
Assertions::assertNull($this->response->getRpcErrorCode(), sprintf(
'Response with error "%s".',
$this->response->getBody()
));
}
|
[
"public",
"function",
"responseIsSuccessfully",
"(",
")",
"{",
"Assertions",
"::",
"assertEquals",
"(",
"200",
",",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"sprintf",
"(",
"'Response with error \"%s\".'",
",",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"Assertions",
"::",
"assertNull",
"(",
"$",
"this",
"->",
"response",
"->",
"getRpcErrorCode",
"(",
")",
",",
"sprintf",
"(",
"'Response with error \"%s\".'",
",",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"}"
] |
Check response is successfully
@Then /^response is successfully$/
|
[
"Check",
"response",
"is",
"successfully"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L135-L146
|
238,827
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.responseIsSuccessfullyWithContainScalarResult
|
public function responseIsSuccessfullyWithContainScalarResult($result)
{
Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
'Response with error "%s"',
$this->response->getBody()
));
Assertions::assertTrue(is_null($this->response->getRpcErrorCode()), sprintf(
'Response with error "%s"',
$this->response->getBody()
));
Assertions::assertEquals($result, $this->response->getRpcResult(), sprintf(
'Result must be a contain "%s"',
$result
));
}
|
php
|
public function responseIsSuccessfullyWithContainScalarResult($result)
{
Assertions::assertEquals(200, $this->response->getStatusCode(), sprintf(
'Response with error "%s"',
$this->response->getBody()
));
Assertions::assertTrue(is_null($this->response->getRpcErrorCode()), sprintf(
'Response with error "%s"',
$this->response->getBody()
));
Assertions::assertEquals($result, $this->response->getRpcResult(), sprintf(
'Result must be a contain "%s"',
$result
));
}
|
[
"public",
"function",
"responseIsSuccessfullyWithContainScalarResult",
"(",
"$",
"result",
")",
"{",
"Assertions",
"::",
"assertEquals",
"(",
"200",
",",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"sprintf",
"(",
"'Response with error \"%s\"'",
",",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"Assertions",
"::",
"assertTrue",
"(",
"is_null",
"(",
"$",
"this",
"->",
"response",
"->",
"getRpcErrorCode",
"(",
")",
")",
",",
"sprintf",
"(",
"'Response with error \"%s\"'",
",",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
")",
")",
";",
"Assertions",
"::",
"assertEquals",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"response",
"->",
"getRpcResult",
"(",
")",
",",
"sprintf",
"(",
"'Result must be a contain \"%s\"'",
",",
"$",
"result",
")",
")",
";",
"}"
] |
Check success response with scalar result
@Then /^response is successfully with contain result "([^"]+)"$/
@param string $result
|
[
"Check",
"success",
"response",
"with",
"scalar",
"result"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L197-L213
|
238,828
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.responseIsSuccessfullyWithContainListResult
|
public function responseIsSuccessfullyWithContainListResult(TableNode $table, $count = null)
{
$this->responseIsSuccessfully();
$rpcResult = $this->response->getRpcResult();
Assertions::assertTrue(is_array($rpcResult), sprintf(
'The RPC response must be a array, but "%s" given.',
gettype($rpcResult)
));
if ($count !== null) {
Assertions::assertCount((int) $count, $rpcResult, sprintf(
'The response should have %d elements, but %d given.',
$count,
count($rpcResult)
));
}
foreach($table->getHash() as $key => $row) {
if (isset($row['__key__'])) {
$key = $row['__key__'];
unset ($row['__key__']);
}
Assertions::assertArrayHasKey($key, $rpcResult, sprintf(
'Not found data with key "%s" in array (%s).',
$key,
json_encode($rpcResult)
));
$this->assertArrayEquals($rpcResult[$key], $row);
}
}
|
php
|
public function responseIsSuccessfullyWithContainListResult(TableNode $table, $count = null)
{
$this->responseIsSuccessfully();
$rpcResult = $this->response->getRpcResult();
Assertions::assertTrue(is_array($rpcResult), sprintf(
'The RPC response must be a array, but "%s" given.',
gettype($rpcResult)
));
if ($count !== null) {
Assertions::assertCount((int) $count, $rpcResult, sprintf(
'The response should have %d elements, but %d given.',
$count,
count($rpcResult)
));
}
foreach($table->getHash() as $key => $row) {
if (isset($row['__key__'])) {
$key = $row['__key__'];
unset ($row['__key__']);
}
Assertions::assertArrayHasKey($key, $rpcResult, sprintf(
'Not found data with key "%s" in array (%s).',
$key,
json_encode($rpcResult)
));
$this->assertArrayEquals($rpcResult[$key], $row);
}
}
|
[
"public",
"function",
"responseIsSuccessfullyWithContainListResult",
"(",
"TableNode",
"$",
"table",
",",
"$",
"count",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"responseIsSuccessfully",
"(",
")",
";",
"$",
"rpcResult",
"=",
"$",
"this",
"->",
"response",
"->",
"getRpcResult",
"(",
")",
";",
"Assertions",
"::",
"assertTrue",
"(",
"is_array",
"(",
"$",
"rpcResult",
")",
",",
"sprintf",
"(",
"'The RPC response must be a array, but \"%s\" given.'",
",",
"gettype",
"(",
"$",
"rpcResult",
")",
")",
")",
";",
"if",
"(",
"$",
"count",
"!==",
"null",
")",
"{",
"Assertions",
"::",
"assertCount",
"(",
"(",
"int",
")",
"$",
"count",
",",
"$",
"rpcResult",
",",
"sprintf",
"(",
"'The response should have %d elements, but %d given.'",
",",
"$",
"count",
",",
"count",
"(",
"$",
"rpcResult",
")",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"table",
"->",
"getHash",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"'__key__'",
"]",
")",
")",
"{",
"$",
"key",
"=",
"$",
"row",
"[",
"'__key__'",
"]",
";",
"unset",
"(",
"$",
"row",
"[",
"'__key__'",
"]",
")",
";",
"}",
"Assertions",
"::",
"assertArrayHasKey",
"(",
"$",
"key",
",",
"$",
"rpcResult",
",",
"sprintf",
"(",
"'Not found data with key \"%s\" in array (%s).'",
",",
"$",
"key",
",",
"json_encode",
"(",
"$",
"rpcResult",
")",
")",
")",
";",
"$",
"this",
"->",
"assertArrayEquals",
"(",
"$",
"rpcResult",
"[",
"$",
"key",
"]",
",",
"$",
"row",
")",
";",
"}",
"}"
] |
Check response successfully with list result
@Then /^response is successfully with collection result:$/
@param TableNode $table
@param int $count
|
[
"Check",
"response",
"successfully",
"with",
"list",
"result"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L223-L256
|
238,829
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.iSendARequest
|
public function iSendARequest($method, TableNode $params)
{
$id = $this->getRequestId() ? $this->getRequestId() : uniqid();
$params = $params->getRowsHash();
$requestParameters = [];
foreach ($params as $parameterKey => $parameterValue) {
$property = new PropertyPath($parameterKey);
$propertyElements = $property->getElements();
$activeKeyReference = &$requestParameters;
while (null !== $propertyElement = array_shift($propertyElements)) {
if (!isset($activeKeyReference[$propertyElement])) {
$activeKeyReference[$propertyElement] = []; // Force set array value
}
$activeKeyReference = &$activeKeyReference[$propertyElement];
}
if (preg_match('/^@\[([^\]]+)?\]$/', trim($parameterValue), $parts)) {
if (!empty($parts[1])) {
$elements = explode(',', $parts[1]);
$elements = array_map('trim', $elements);
} else {
// Empty string
$elements = [];
}
$parameterValue = $elements;
}
$activeKeyReference = $parameterValue;
}
/** @var \Graze\GuzzleHttp\JsonRpc\Message\RequestInterface $request */
$request = $this->client->request($id, $method, $requestParameters);
foreach ($this->headers as $headerName => $headerValue) {
$request = $request->withHeader($headerName, $headerValue);
}
$uri = $request->getUri();
$uri = $uri->withPath($uri->getPath() . $this->path);
$request = $request->withUri($uri);
$this->request = $request;
$this->sendRequest();
}
|
php
|
public function iSendARequest($method, TableNode $params)
{
$id = $this->getRequestId() ? $this->getRequestId() : uniqid();
$params = $params->getRowsHash();
$requestParameters = [];
foreach ($params as $parameterKey => $parameterValue) {
$property = new PropertyPath($parameterKey);
$propertyElements = $property->getElements();
$activeKeyReference = &$requestParameters;
while (null !== $propertyElement = array_shift($propertyElements)) {
if (!isset($activeKeyReference[$propertyElement])) {
$activeKeyReference[$propertyElement] = []; // Force set array value
}
$activeKeyReference = &$activeKeyReference[$propertyElement];
}
if (preg_match('/^@\[([^\]]+)?\]$/', trim($parameterValue), $parts)) {
if (!empty($parts[1])) {
$elements = explode(',', $parts[1]);
$elements = array_map('trim', $elements);
} else {
// Empty string
$elements = [];
}
$parameterValue = $elements;
}
$activeKeyReference = $parameterValue;
}
/** @var \Graze\GuzzleHttp\JsonRpc\Message\RequestInterface $request */
$request = $this->client->request($id, $method, $requestParameters);
foreach ($this->headers as $headerName => $headerValue) {
$request = $request->withHeader($headerName, $headerValue);
}
$uri = $request->getUri();
$uri = $uri->withPath($uri->getPath() . $this->path);
$request = $request->withUri($uri);
$this->request = $request;
$this->sendRequest();
}
|
[
"public",
"function",
"iSendARequest",
"(",
"$",
"method",
",",
"TableNode",
"$",
"params",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getRequestId",
"(",
")",
"?",
"$",
"this",
"->",
"getRequestId",
"(",
")",
":",
"uniqid",
"(",
")",
";",
"$",
"params",
"=",
"$",
"params",
"->",
"getRowsHash",
"(",
")",
";",
"$",
"requestParameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"parameterKey",
"=>",
"$",
"parameterValue",
")",
"{",
"$",
"property",
"=",
"new",
"PropertyPath",
"(",
"$",
"parameterKey",
")",
";",
"$",
"propertyElements",
"=",
"$",
"property",
"->",
"getElements",
"(",
")",
";",
"$",
"activeKeyReference",
"=",
"&",
"$",
"requestParameters",
";",
"while",
"(",
"null",
"!==",
"$",
"propertyElement",
"=",
"array_shift",
"(",
"$",
"propertyElements",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"activeKeyReference",
"[",
"$",
"propertyElement",
"]",
")",
")",
"{",
"$",
"activeKeyReference",
"[",
"$",
"propertyElement",
"]",
"=",
"[",
"]",
";",
"// Force set array value",
"}",
"$",
"activeKeyReference",
"=",
"&",
"$",
"activeKeyReference",
"[",
"$",
"propertyElement",
"]",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^@\\[([^\\]]+)?\\]$/'",
",",
"trim",
"(",
"$",
"parameterValue",
")",
",",
"$",
"parts",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"$",
"elements",
"=",
"explode",
"(",
"','",
",",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"$",
"elements",
"=",
"array_map",
"(",
"'trim'",
",",
"$",
"elements",
")",
";",
"}",
"else",
"{",
"// Empty string",
"$",
"elements",
"=",
"[",
"]",
";",
"}",
"$",
"parameterValue",
"=",
"$",
"elements",
";",
"}",
"$",
"activeKeyReference",
"=",
"$",
"parameterValue",
";",
"}",
"/** @var \\Graze\\GuzzleHttp\\JsonRpc\\Message\\RequestInterface $request */",
"$",
"request",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"id",
",",
"$",
"method",
",",
"$",
"requestParameters",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"headerName",
"=>",
"$",
"headerValue",
")",
"{",
"$",
"request",
"=",
"$",
"request",
"->",
"withHeader",
"(",
"$",
"headerName",
",",
"$",
"headerValue",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withPath",
"(",
"$",
"uri",
"->",
"getPath",
"(",
")",
".",
"$",
"this",
"->",
"path",
")",
";",
"$",
"request",
"=",
"$",
"request",
"->",
"withUri",
"(",
"$",
"uri",
")",
";",
"$",
"this",
"->",
"request",
"=",
"$",
"request",
";",
"$",
"this",
"->",
"sendRequest",
"(",
")",
";",
"}"
] |
Sends Json rpc request to specific method.
@param string $method request method
@param TableNode $params table of params values
@When /^(?:I )?send a request to "([^"]+)" with params:$/
|
[
"Sends",
"Json",
"rpc",
"request",
"to",
"specific",
"method",
"."
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L278-L328
|
238,830
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.theServerShouldReturnStatusCode
|
public function theServerShouldReturnStatusCode($status)
{
Assertions::assertNotNull($this->response, 'Missing response. Can you not send request?');
Assertions::assertEquals($status, $this->response->getStatusCode(), 'Invalid HTTP status code.');
}
|
php
|
public function theServerShouldReturnStatusCode($status)
{
Assertions::assertNotNull($this->response, 'Missing response. Can you not send request?');
Assertions::assertEquals($status, $this->response->getStatusCode(), 'Invalid HTTP status code.');
}
|
[
"public",
"function",
"theServerShouldReturnStatusCode",
"(",
"$",
"status",
")",
"{",
"Assertions",
"::",
"assertNotNull",
"(",
"$",
"this",
"->",
"response",
",",
"'Missing response. Can you not send request?'",
")",
";",
"Assertions",
"::",
"assertEquals",
"(",
"$",
"status",
",",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"'Invalid HTTP status code.'",
")",
";",
"}"
] |
The server should return status code
@param integer $status
@Then /^(?:the )?server should return "([^"]+)" status code$/
|
[
"The",
"server",
"should",
"return",
"status",
"code"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L348-L352
|
238,831
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.theServerShouldReturnHeaders
|
public function theServerShouldReturnHeaders(TableNode $headers)
{
Assertions::assertNotNull($this->response, 'Missing response. Can you not send request?');
$responseHeaders = [];
foreach ($this->response->getHeaders() as $name => $value) {
$responseHeaders[strtolower($name)] = $value;
}
foreach ($headers->getRowsHash() as $headerName => $headerValue) {
$headerName = strtolower($headerName);
Assertions::assertArrayHasKey($headerName, $responseHeaders, 'Missing header in response.');
$responseHeader = $responseHeaders[$headerName];
$responseHeader = implode('; ', $responseHeader);
Assertions::assertEquals($headerValue, $responseHeader, 'The header is not equals.');
}
}
|
php
|
public function theServerShouldReturnHeaders(TableNode $headers)
{
Assertions::assertNotNull($this->response, 'Missing response. Can you not send request?');
$responseHeaders = [];
foreach ($this->response->getHeaders() as $name => $value) {
$responseHeaders[strtolower($name)] = $value;
}
foreach ($headers->getRowsHash() as $headerName => $headerValue) {
$headerName = strtolower($headerName);
Assertions::assertArrayHasKey($headerName, $responseHeaders, 'Missing header in response.');
$responseHeader = $responseHeaders[$headerName];
$responseHeader = implode('; ', $responseHeader);
Assertions::assertEquals($headerValue, $responseHeader, 'The header is not equals.');
}
}
|
[
"public",
"function",
"theServerShouldReturnHeaders",
"(",
"TableNode",
"$",
"headers",
")",
"{",
"Assertions",
"::",
"assertNotNull",
"(",
"$",
"this",
"->",
"response",
",",
"'Missing response. Can you not send request?'",
")",
";",
"$",
"responseHeaders",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"responseHeaders",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"=",
"$",
"value",
";",
"}",
"foreach",
"(",
"$",
"headers",
"->",
"getRowsHash",
"(",
")",
"as",
"$",
"headerName",
"=>",
"$",
"headerValue",
")",
"{",
"$",
"headerName",
"=",
"strtolower",
"(",
"$",
"headerName",
")",
";",
"Assertions",
"::",
"assertArrayHasKey",
"(",
"$",
"headerName",
",",
"$",
"responseHeaders",
",",
"'Missing header in response.'",
")",
";",
"$",
"responseHeader",
"=",
"$",
"responseHeaders",
"[",
"$",
"headerName",
"]",
";",
"$",
"responseHeader",
"=",
"implode",
"(",
"'; '",
",",
"$",
"responseHeader",
")",
";",
"Assertions",
"::",
"assertEquals",
"(",
"$",
"headerValue",
",",
"$",
"responseHeader",
",",
"'The header is not equals.'",
")",
";",
"}",
"}"
] |
The server should return headers
@param TableNode $headers
@Then /^(?:the )?server should return headers:$/
|
[
"The",
"server",
"should",
"return",
"headers"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L361-L380
|
238,832
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.theResponseShouldContainErrorWithMessage
|
public function theResponseShouldContainErrorWithMessage($id, $message)
{
Assertions::assertEquals(intval($id), $this->response->getRpcErrorCode());
Assertions::assertEquals($message, $this->response->getRpcErrorMessage());
}
|
php
|
public function theResponseShouldContainErrorWithMessage($id, $message)
{
Assertions::assertEquals(intval($id), $this->response->getRpcErrorCode());
Assertions::assertEquals($message, $this->response->getRpcErrorMessage());
}
|
[
"public",
"function",
"theResponseShouldContainErrorWithMessage",
"(",
"$",
"id",
",",
"$",
"message",
")",
"{",
"Assertions",
"::",
"assertEquals",
"(",
"intval",
"(",
"$",
"id",
")",
",",
"$",
"this",
"->",
"response",
"->",
"getRpcErrorCode",
"(",
")",
")",
";",
"Assertions",
"::",
"assertEquals",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"response",
"->",
"getRpcErrorMessage",
"(",
")",
")",
";",
"}"
] |
Parse json-rpc error response
@param string|integer $id
@param string $message
@Then /^(?:the )?response should be error with id "([^"]+)", message "(.+)"$/
|
[
"Parse",
"json",
"-",
"rpc",
"error",
"response"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L390-L394
|
238,833
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.theResponseShouldContainErrorData
|
public function theResponseShouldContainErrorData($id, $message, TableNode $table)
{
Assertions::assertEquals(200, $this->response->getStatusCode());
$this->theResponseShouldContainErrorWithMessage($id, $message);
$error = $this->getFieldFromBody('error', $this->response->getBody());
Assertions::assertArrayHasKey('data', $error);
Assertions::assertEquals($table->getRowsHash(), $error['data']);
}
|
php
|
public function theResponseShouldContainErrorData($id, $message, TableNode $table)
{
Assertions::assertEquals(200, $this->response->getStatusCode());
$this->theResponseShouldContainErrorWithMessage($id, $message);
$error = $this->getFieldFromBody('error', $this->response->getBody());
Assertions::assertArrayHasKey('data', $error);
Assertions::assertEquals($table->getRowsHash(), $error['data']);
}
|
[
"public",
"function",
"theResponseShouldContainErrorData",
"(",
"$",
"id",
",",
"$",
"message",
",",
"TableNode",
"$",
"table",
")",
"{",
"Assertions",
"::",
"assertEquals",
"(",
"200",
",",
"$",
"this",
"->",
"response",
"->",
"getStatusCode",
"(",
")",
")",
";",
"$",
"this",
"->",
"theResponseShouldContainErrorWithMessage",
"(",
"$",
"id",
",",
"$",
"message",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"getFieldFromBody",
"(",
"'error'",
",",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"Assertions",
"::",
"assertArrayHasKey",
"(",
"'data'",
",",
"$",
"error",
")",
";",
"Assertions",
"::",
"assertEquals",
"(",
"$",
"table",
"->",
"getRowsHash",
"(",
")",
",",
"$",
"error",
"[",
"'data'",
"]",
")",
";",
"}"
] |
Check json-rpc error data
@param string|integer $id
@param string $message
@param TableNode $table
@Then /^(?:the )?response should be error with id "([^"]+)", message "(.+)", data:$/
|
[
"Check",
"json",
"-",
"rpc",
"error",
"data"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L417-L426
|
238,834
|
f1nder/BehatJsonRpcExtension
|
src/Context/JsonRpcClientContext.php
|
JsonRpcClientContext.getFieldFromBody
|
protected function getFieldFromBody($key, $body)
{
$rpc = json_decode($body, true);
return isset($rpc[$key]) ? $rpc[$key] : null;
}
|
php
|
protected function getFieldFromBody($key, $body)
{
$rpc = json_decode($body, true);
return isset($rpc[$key]) ? $rpc[$key] : null;
}
|
[
"protected",
"function",
"getFieldFromBody",
"(",
"$",
"key",
",",
"$",
"body",
")",
"{",
"$",
"rpc",
"=",
"json_decode",
"(",
"$",
"body",
",",
"true",
")",
";",
"return",
"isset",
"(",
"$",
"rpc",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"rpc",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] |
Get field from body
@param string $key
@param string $body
@return mixed
|
[
"Get",
"field",
"from",
"body"
] |
1737faf32e9458d883b77d468f3ffd2d934dae37
|
https://github.com/f1nder/BehatJsonRpcExtension/blob/1737faf32e9458d883b77d468f3ffd2d934dae37/src/Context/JsonRpcClientContext.php#L550-L555
|
238,835
|
perinatologie/hub-client-php
|
src/Security/UserbaseJwtAuthenticatorClient.php
|
UserbaseJwtAuthenticatorClient.authenticate
|
public function authenticate($username, $password)
{
$authRequest = new Request('GET', $this->userbaseUrl);
$client = new GuzzleClient(
[
'verify' => $this->tlsCertVerification,
'headers' => [
'User-Agent' => 'HubUserbaseClient (Guzzle)',
],
'auth' => [$username, $password],
]
);
try {
$response = $client->send($authRequest);
} catch (BadResponseException $e) {
$this->handleBadResponseException($e);
} catch (GuzzleException $e) {
throw new AuthenticationFailureException(
null,
"The authentication request failed unexpectedly.",
null,
$e
);
}
$json = $this->getResponseData($response);
if (!$json) {
throw new AuthenticationFailureException(
$response,
"Authentication failed because the authentication request did not result in the expected response data."
);
}
if (!isset($json['jwt'])) {
throw new AuthenticationFailureException(
$response,
"Authentication failed because an authentication token was not obtained."
);
}
return $json['jwt'];
}
|
php
|
public function authenticate($username, $password)
{
$authRequest = new Request('GET', $this->userbaseUrl);
$client = new GuzzleClient(
[
'verify' => $this->tlsCertVerification,
'headers' => [
'User-Agent' => 'HubUserbaseClient (Guzzle)',
],
'auth' => [$username, $password],
]
);
try {
$response = $client->send($authRequest);
} catch (BadResponseException $e) {
$this->handleBadResponseException($e);
} catch (GuzzleException $e) {
throw new AuthenticationFailureException(
null,
"The authentication request failed unexpectedly.",
null,
$e
);
}
$json = $this->getResponseData($response);
if (!$json) {
throw new AuthenticationFailureException(
$response,
"Authentication failed because the authentication request did not result in the expected response data."
);
}
if (!isset($json['jwt'])) {
throw new AuthenticationFailureException(
$response,
"Authentication failed because an authentication token was not obtained."
);
}
return $json['jwt'];
}
|
[
"public",
"function",
"authenticate",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"authRequest",
"=",
"new",
"Request",
"(",
"'GET'",
",",
"$",
"this",
"->",
"userbaseUrl",
")",
";",
"$",
"client",
"=",
"new",
"GuzzleClient",
"(",
"[",
"'verify'",
"=>",
"$",
"this",
"->",
"tlsCertVerification",
",",
"'headers'",
"=>",
"[",
"'User-Agent'",
"=>",
"'HubUserbaseClient (Guzzle)'",
",",
"]",
",",
"'auth'",
"=>",
"[",
"$",
"username",
",",
"$",
"password",
"]",
",",
"]",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"send",
"(",
"$",
"authRequest",
")",
";",
"}",
"catch",
"(",
"BadResponseException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"handleBadResponseException",
"(",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"GuzzleException",
"$",
"e",
")",
"{",
"throw",
"new",
"AuthenticationFailureException",
"(",
"null",
",",
"\"The authentication request failed unexpectedly.\"",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"$",
"json",
"=",
"$",
"this",
"->",
"getResponseData",
"(",
"$",
"response",
")",
";",
"if",
"(",
"!",
"$",
"json",
")",
"{",
"throw",
"new",
"AuthenticationFailureException",
"(",
"$",
"response",
",",
"\"Authentication failed because the authentication request did not result in the expected response data.\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"json",
"[",
"'jwt'",
"]",
")",
")",
"{",
"throw",
"new",
"AuthenticationFailureException",
"(",
"$",
"response",
",",
"\"Authentication failed because an authentication token was not obtained.\"",
")",
";",
"}",
"return",
"$",
"json",
"[",
"'jwt'",
"]",
";",
"}"
] |
Authenticate with UserBase.
The credentials given here will be used to request a Json Web Token,
claiming the username, from UserBase.
@param string $username
@param string $password
@return string
@throws \Hub\Client\Exception\AuthenticationFailureException
|
[
"Authenticate",
"with",
"UserBase",
"."
] |
3a0cf7ec6e3e5bf465167c283ee3dad9f4daaca3
|
https://github.com/perinatologie/hub-client-php/blob/3a0cf7ec6e3e5bf465167c283ee3dad9f4daaca3/src/Security/UserbaseJwtAuthenticatorClient.php#L61-L99
|
238,836
|
wasabi-cms/cms
|
src/Controller/PagesController.php
|
PagesController.reorderPages
|
public function reorderPages()
{
if (!$this->request->isAll(['ajax', 'post'])) {
throw new MethodNotAllowedException();
}
if (empty($this->request->data)) {
throw new BadRequestException();
}
$this->request->data = Hash::map($this->request->data, '{n}', function($page) {
if ($page['parent_id'] === 'null') {
$page['parent_id'] = null;
}
return $page;
});
$pages = $this->Pages->patchEntities($this->Pages->find('all'), $this->request->data, ['associated' => false]);
/** @var Connection $connection */
$connection = $this->Pages->connection();
$connection->begin();
foreach ($pages as $page) {
$this->Pages->behaviors()->unload('Tree');
if (!$this->Pages->save($page)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
$status = 'success';
$flashMessage = __d('wasabi_cms', 'The page positions have been updated.');
} else {
$status = 'error';
$flashMessage = $this->dbErrorMessage;
}
$this->set([
'status' => $status,
'flashMessage' => $flashMessage,
'_serialize' => ['status', 'flashMessage']
]);
$this->RequestHandler->renderAs($this, 'json');
}
|
php
|
public function reorderPages()
{
if (!$this->request->isAll(['ajax', 'post'])) {
throw new MethodNotAllowedException();
}
if (empty($this->request->data)) {
throw new BadRequestException();
}
$this->request->data = Hash::map($this->request->data, '{n}', function($page) {
if ($page['parent_id'] === 'null') {
$page['parent_id'] = null;
}
return $page;
});
$pages = $this->Pages->patchEntities($this->Pages->find('all'), $this->request->data, ['associated' => false]);
/** @var Connection $connection */
$connection = $this->Pages->connection();
$connection->begin();
foreach ($pages as $page) {
$this->Pages->behaviors()->unload('Tree');
if (!$this->Pages->save($page)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
$status = 'success';
$flashMessage = __d('wasabi_cms', 'The page positions have been updated.');
} else {
$status = 'error';
$flashMessage = $this->dbErrorMessage;
}
$this->set([
'status' => $status,
'flashMessage' => $flashMessage,
'_serialize' => ['status', 'flashMessage']
]);
$this->RequestHandler->renderAs($this, 'json');
}
|
[
"public",
"function",
"reorderPages",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"isAll",
"(",
"[",
"'ajax'",
",",
"'post'",
"]",
")",
")",
"{",
"throw",
"new",
"MethodNotAllowedException",
"(",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"request",
"->",
"data",
"=",
"Hash",
"::",
"map",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
",",
"'{n}'",
",",
"function",
"(",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"[",
"'parent_id'",
"]",
"===",
"'null'",
")",
"{",
"$",
"page",
"[",
"'parent_id'",
"]",
"=",
"null",
";",
"}",
"return",
"$",
"page",
";",
"}",
")",
";",
"$",
"pages",
"=",
"$",
"this",
"->",
"Pages",
"->",
"patchEntities",
"(",
"$",
"this",
"->",
"Pages",
"->",
"find",
"(",
"'all'",
")",
",",
"$",
"this",
"->",
"request",
"->",
"data",
",",
"[",
"'associated'",
"=>",
"false",
"]",
")",
";",
"/** @var Connection $connection */",
"$",
"connection",
"=",
"$",
"this",
"->",
"Pages",
"->",
"connection",
"(",
")",
";",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"Pages",
"->",
"behaviors",
"(",
")",
"->",
"unload",
"(",
"'Tree'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"Pages",
"->",
"save",
"(",
"$",
"page",
")",
")",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"connection",
"->",
"inTransaction",
"(",
")",
")",
"{",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"$",
"status",
"=",
"'success'",
";",
"$",
"flashMessage",
"=",
"__d",
"(",
"'wasabi_cms'",
",",
"'The page positions have been updated.'",
")",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"'error'",
";",
"$",
"flashMessage",
"=",
"$",
"this",
"->",
"dbErrorMessage",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"[",
"'status'",
"=>",
"$",
"status",
",",
"'flashMessage'",
"=>",
"$",
"flashMessage",
",",
"'_serialize'",
"=>",
"[",
"'status'",
",",
"'flashMessage'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"RequestHandler",
"->",
"renderAs",
"(",
"$",
"this",
",",
"'json'",
")",
";",
"}"
] |
reorderPages action
AJAX POST
|
[
"reorderPages",
"action",
"AJAX",
"POST"
] |
2787b6422ea1d719cf49951b3253fd0ac31d22ca
|
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/Controller/PagesController.php#L250-L295
|
238,837
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php
|
AdminStockChangeLogController.indexAction
|
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$qb = $em->getRepository(StockChangeLog::class)->createQueryBuilder('s');
$this->addQueryBuilderSort($qb, 'stockchangelog');
$paginator = $this->get('knp_paginator')->paginate($qb, $request->query->get('page', 1), 20);
return array(
'paginator' => $paginator,
);
}
|
php
|
public function indexAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$qb = $em->getRepository(StockChangeLog::class)->createQueryBuilder('s');
$this->addQueryBuilderSort($qb, 'stockchangelog');
$paginator = $this->get('knp_paginator')->paginate($qb, $request->query->get('page', 1), 20);
return array(
'paginator' => $paginator,
);
}
|
[
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"qb",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"StockChangeLog",
"::",
"class",
")",
"->",
"createQueryBuilder",
"(",
"'s'",
")",
";",
"$",
"this",
"->",
"addQueryBuilderSort",
"(",
"$",
"qb",
",",
"'stockchangelog'",
")",
";",
"$",
"paginator",
"=",
"$",
"this",
"->",
"get",
"(",
"'knp_paginator'",
")",
"->",
"paginate",
"(",
"$",
"qb",
",",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
",",
"20",
")",
";",
"return",
"array",
"(",
"'paginator'",
"=>",
"$",
"paginator",
",",
")",
";",
"}"
] |
Lists all StockChangeLog entities.
@Route("/", name="admin_shop_changelog")
@Method("GET")
@Template()
|
[
"Lists",
"all",
"StockChangeLog",
"entities",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php#L28-L38
|
238,838
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php
|
AdminStockChangeLogController.showAction
|
public function showAction(StockChangeLog $stockchangelog)
{
$editForm = $this->createForm(new StockChangeLogType(), $stockchangelog, array(
'action' => $this->generateUrl('admin_shop_changelog_update', array('id' => $stockchangelog->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stockchangelog->getId(), 'admin_shop_changelog_delete');
return array(
'stockchangelog' => $stockchangelog,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function showAction(StockChangeLog $stockchangelog)
{
$editForm = $this->createForm(new StockChangeLogType(), $stockchangelog, array(
'action' => $this->generateUrl('admin_shop_changelog_update', array('id' => $stockchangelog->getid())),
'method' => 'PUT',
));
$deleteForm = $this->createDeleteForm($stockchangelog->getId(), 'admin_shop_changelog_delete');
return array(
'stockchangelog' => $stockchangelog,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"showAction",
"(",
"StockChangeLog",
"$",
"stockchangelog",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockChangeLogType",
"(",
")",
",",
"$",
"stockchangelog",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_changelog_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stockchangelog",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"stockchangelog",
"->",
"getId",
"(",
")",
",",
"'admin_shop_changelog_delete'",
")",
";",
"return",
"array",
"(",
"'stockchangelog'",
"=>",
"$",
"stockchangelog",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Finds and displays a StockChangeLog entity.
@Route("/{id}/show", name="admin_shop_changelog_show", requirements={"id"="\d+"})
@Method("GET")
@Template()
|
[
"Finds",
"and",
"displays",
"a",
"StockChangeLog",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php#L47-L62
|
238,839
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php
|
AdminStockChangeLogController.newAction
|
public function newAction()
{
$stockchangelog = new StockChangeLog();
$form = $this->createForm(new StockChangeLogType(), $stockchangelog);
return array(
'stockchangelog' => $stockchangelog,
'form' => $form->createView(),
);
}
|
php
|
public function newAction()
{
$stockchangelog = new StockChangeLog();
$form = $this->createForm(new StockChangeLogType(), $stockchangelog);
return array(
'stockchangelog' => $stockchangelog,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"stockchangelog",
"=",
"new",
"StockChangeLog",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockChangeLogType",
"(",
")",
",",
"$",
"stockchangelog",
")",
";",
"return",
"array",
"(",
"'stockchangelog'",
"=>",
"$",
"stockchangelog",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to create a new StockChangeLog entity.
@Route("/new", name="admin_shop_changelog_new")
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"StockChangeLog",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php#L71-L80
|
238,840
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php
|
AdminStockChangeLogController.createAction
|
public function createAction(Request $request)
{
$stockchangelog = new StockChangeLog();
$form = $this->createForm(new StockChangeLogType(), $stockchangelog);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stockchangelog);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_changelog_show', array('id' => $stockchangelog->getId())));
}
return array(
'stockchangelog' => $stockchangelog,
'form' => $form->createView(),
);
}
|
php
|
public function createAction(Request $request)
{
$stockchangelog = new StockChangeLog();
$form = $this->createForm(new StockChangeLogType(), $stockchangelog);
if ($form->handleRequest($request)->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($stockchangelog);
$em->flush();
return $this->redirect($this->generateUrl('admin_shop_changelog_show', array('id' => $stockchangelog->getId())));
}
return array(
'stockchangelog' => $stockchangelog,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"stockchangelog",
"=",
"new",
"StockChangeLog",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockChangeLogType",
"(",
")",
",",
"$",
"stockchangelog",
")",
";",
"if",
"(",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"stockchangelog",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_changelog_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stockchangelog",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'stockchangelog'",
"=>",
"$",
"stockchangelog",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new StockChangeLog entity.
@Route("/create", name="admin_shop_changelog_create")
@Method("POST")
@Template("FlowerStockBundle:StockChangeLog:new.html.twig")
|
[
"Creates",
"a",
"new",
"StockChangeLog",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php#L89-L105
|
238,841
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php
|
AdminStockChangeLogController.updateAction
|
public function updateAction(StockChangeLog $stockchangelog, Request $request)
{
$editForm = $this->createForm(new StockChangeLogType(), $stockchangelog, array(
'action' => $this->generateUrl('admin_shop_changelog_update', array('id' => $stockchangelog->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_changelog_show', array('id' => $stockchangelog->getId())));
}
$deleteForm = $this->createDeleteForm($stockchangelog->getId(), 'admin_shop_changelog_delete');
return array(
'stockchangelog' => $stockchangelog,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
php
|
public function updateAction(StockChangeLog $stockchangelog, Request $request)
{
$editForm = $this->createForm(new StockChangeLogType(), $stockchangelog, array(
'action' => $this->generateUrl('admin_shop_changelog_update', array('id' => $stockchangelog->getid())),
'method' => 'PUT',
));
if ($editForm->handleRequest($request)->isValid()) {
$this->getDoctrine()->getManager()->flush();
return $this->redirect($this->generateUrl('admin_shop_changelog_show', array('id' => $stockchangelog->getId())));
}
$deleteForm = $this->createDeleteForm($stockchangelog->getId(), 'admin_shop_changelog_delete');
return array(
'stockchangelog' => $stockchangelog,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
);
}
|
[
"public",
"function",
"updateAction",
"(",
"StockChangeLog",
"$",
"stockchangelog",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"editForm",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"StockChangeLogType",
"(",
")",
",",
"$",
"stockchangelog",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_changelog_update'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stockchangelog",
"->",
"getid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'PUT'",
",",
")",
")",
";",
"if",
"(",
"$",
"editForm",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'admin_shop_changelog_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"stockchangelog",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"stockchangelog",
"->",
"getId",
"(",
")",
",",
"'admin_shop_changelog_delete'",
")",
";",
"return",
"array",
"(",
"'stockchangelog'",
"=>",
"$",
"stockchangelog",
",",
"'edit_form'",
"=>",
"$",
"editForm",
"->",
"createView",
"(",
")",
",",
"'delete_form'",
"=>",
"$",
"deleteForm",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Edits an existing StockChangeLog entity.
@Route("/{id}/update", name="admin_shop_changelog_update", requirements={"id"="\d+"})
@Method("PUT")
@Template("FlowerStockBundle:StockChangeLog:edit.html.twig")
|
[
"Edits",
"an",
"existing",
"StockChangeLog",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminStockChangeLogController.php#L136-L154
|
238,842
|
marando/phpSOFA
|
src/Marando/IAU/iauAtciqn.php
|
iauAtciqn.Atciqn
|
public static function Atciqn($rc, $dc, $pr, $pd, $px, $rv,
iauASTROM &$astrom, $n, array $b, &$ri, &$di) {
foreach ($b as $i)
if ($i instanceof iauLDBODY == false)
throw new \InvalidArgumentException("All \$b elements must be iauLDBODY type");
$pco = [];
$pnat = [];
$ppr = [];
$pi = [];
$w;
/* Proper motion and parallax, giving BCRS coordinate direction. */
IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco);
/* Light deflection, giving BCRS natural direction. */
IAU::Ldn($n, $b, $astrom->eb, $pco, $pnat);
/* Aberration, giving GCRS proper direction. */
IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr);
/* Bias-precession-nutation, giving CIRS proper direction. */
IAU::Rxp($astrom->bpn, $ppr, $pi);
/* CIRS RA,Dec. */
IAU::C2s($pi, $w, $di);
$ri = IAU::Anp($w);
/* Finished. */
}
|
php
|
public static function Atciqn($rc, $dc, $pr, $pd, $px, $rv,
iauASTROM &$astrom, $n, array $b, &$ri, &$di) {
foreach ($b as $i)
if ($i instanceof iauLDBODY == false)
throw new \InvalidArgumentException("All \$b elements must be iauLDBODY type");
$pco = [];
$pnat = [];
$ppr = [];
$pi = [];
$w;
/* Proper motion and parallax, giving BCRS coordinate direction. */
IAU::Pmpx($rc, $dc, $pr, $pd, $px, $rv, $astrom->pmt, $astrom->eb, $pco);
/* Light deflection, giving BCRS natural direction. */
IAU::Ldn($n, $b, $astrom->eb, $pco, $pnat);
/* Aberration, giving GCRS proper direction. */
IAU::Ab($pnat, $astrom->v, $astrom->em, $astrom->bm1, $ppr);
/* Bias-precession-nutation, giving CIRS proper direction. */
IAU::Rxp($astrom->bpn, $ppr, $pi);
/* CIRS RA,Dec. */
IAU::C2s($pi, $w, $di);
$ri = IAU::Anp($w);
/* Finished. */
}
|
[
"public",
"static",
"function",
"Atciqn",
"(",
"$",
"rc",
",",
"$",
"dc",
",",
"$",
"pr",
",",
"$",
"pd",
",",
"$",
"px",
",",
"$",
"rv",
",",
"iauASTROM",
"&",
"$",
"astrom",
",",
"$",
"n",
",",
"array",
"$",
"b",
",",
"&",
"$",
"ri",
",",
"&",
"$",
"di",
")",
"{",
"foreach",
"(",
"$",
"b",
"as",
"$",
"i",
")",
"if",
"(",
"$",
"i",
"instanceof",
"iauLDBODY",
"==",
"false",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"All \\$b elements must be iauLDBODY type\"",
")",
";",
"$",
"pco",
"=",
"[",
"]",
";",
"$",
"pnat",
"=",
"[",
"]",
";",
"$",
"ppr",
"=",
"[",
"]",
";",
"$",
"pi",
"=",
"[",
"]",
";",
"$",
"w",
";",
"/* Proper motion and parallax, giving BCRS coordinate direction. */",
"IAU",
"::",
"Pmpx",
"(",
"$",
"rc",
",",
"$",
"dc",
",",
"$",
"pr",
",",
"$",
"pd",
",",
"$",
"px",
",",
"$",
"rv",
",",
"$",
"astrom",
"->",
"pmt",
",",
"$",
"astrom",
"->",
"eb",
",",
"$",
"pco",
")",
";",
"/* Light deflection, giving BCRS natural direction. */",
"IAU",
"::",
"Ldn",
"(",
"$",
"n",
",",
"$",
"b",
",",
"$",
"astrom",
"->",
"eb",
",",
"$",
"pco",
",",
"$",
"pnat",
")",
";",
"/* Aberration, giving GCRS proper direction. */",
"IAU",
"::",
"Ab",
"(",
"$",
"pnat",
",",
"$",
"astrom",
"->",
"v",
",",
"$",
"astrom",
"->",
"em",
",",
"$",
"astrom",
"->",
"bm1",
",",
"$",
"ppr",
")",
";",
"/* Bias-precession-nutation, giving CIRS proper direction. */",
"IAU",
"::",
"Rxp",
"(",
"$",
"astrom",
"->",
"bpn",
",",
"$",
"ppr",
",",
"$",
"pi",
")",
";",
"/* CIRS RA,Dec. */",
"IAU",
"::",
"C2s",
"(",
"$",
"pi",
",",
"$",
"w",
",",
"$",
"di",
")",
";",
"$",
"ri",
"=",
"IAU",
"::",
"Anp",
"(",
"$",
"w",
")",
";",
"/* Finished. */",
"}"
] |
- - - - - - - - - -
i a u A t c i q n
- - - - - - - - - -
Quick ICRS, epoch J2000.0, to CIRS transformation, given precomputed
star-independent astrometry parameters plus a list of light-
deflecting bodies.
Use of this function is appropriate when efficiency is important and
where many star positions are to be transformed for one date. The
star-independent parameters can be obtained by calling one of the
functions iauApci[13], iauApcg[13], iauApco[13] or iauApcs[13].
If the only light-deflecting body to be taken into account is the
Sun, the iauAtciq function can be used instead. If in addition the
parallax and proper motions are zero, the iauAtciqz function can be
used.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
rc,dc double ICRS RA,Dec at J2000.0 (radians)
pr double RA proper motion (radians/year; Note 3)
pd double Dec proper motion (radians/year)
px double parallax (arcsec)
rv double radial velocity (km/s, +ve if receding)
astrom iauASTROM* star-independent astrometry parameters:
pmt double PM time interval (SSB, Julian years)
eb double[3] SSB to observer (vector, au)
eh double[3] Sun to observer (unit vector)
em double distance from Sun to observer (au)
v double[3] barycentric observer velocity (vector, c)
bm1 double sqrt(1-|v|^2): reciprocal of Lorenz factor
bpn double[3][3] bias-precession-nutation matrix
along double longitude + s' (radians)
xpl double polar motion xp wrt local meridian (radians)
ypl double polar motion yp wrt local meridian (radians)
sphi double sine of geodetic latitude
cphi double cosine of geodetic latitude
diurab double magnitude of diurnal aberration vector
eral double "local" Earth rotation angle (radians)
refa double refraction constant A (radians)
refb double refraction constant B (radians)
n int number of bodies (Note 3)
b iauLDBODY[n] data for each of the n bodies (Notes 3,4):
bm double mass of the body (solar masses, Note 5)
dl double deflection limiter (Note 6)
pv [2][3] barycentric PV of the body (au, au/day)
Returned:
ri,di double CIRS RA,Dec (radians)
Notes:
1) Star data for an epoch other than J2000.0 (for example from the
Hipparcos catalog, which has an epoch of J1991.25) will require a
preliminary call to iauPmsafe before use.
2) The proper motion in RA is dRA/dt rather than cos(Dec)*dRA/dt.
3) The struct b contains n entries, one for each body to be
considered. If n = 0, no gravitational light deflection will be
applied, not even for the Sun.
4) The struct b should include an entry for the Sun as well as for
any planet or other body to be taken into account. The entries
should be in the order in which the light passes the body.
5) In the entry in the b struct for body i, the mass parameter
b[i].bm can, as required, be adjusted in order to allow for such
effects as quadrupole field.
6) The deflection limiter parameter b[i].dl is phi^2/2, where phi is
the angular separation (in radians) between star and body at
which limiting is applied. As phi shrinks below the chosen
threshold, the deflection is artificially reduced, reaching zero
for phi = 0. Example values suitable for a terrestrial
observer, together with masses, are as follows:
body i b[i].bm b[i].dl
Sun 1.0 6e-6
Jupiter 0.00095435 3e-9
Saturn 0.00028574 3e-10
7) For efficiency, validation of the contents of the b array is
omitted. The supplied masses must be greater than zero, the
position and velocity vectors must be right, and the deflection
limiter greater than zero.
Called:
iauPmpx proper motion and parallax
iauLdn light deflection by n bodies
iauAb stellar aberration
iauRxp product of r-matrix and pv-vector
iauC2s p-vector to spherical
iauAnp normalize angle into range 0 to 2pi
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"A",
"t",
"c",
"i",
"q",
"n",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAtciqn.php#L115-L145
|
238,843
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.getTag
|
public function getTag($tag)
{
return isset($this->tags[$tag]) ? $this->tags[$tag] : null;
}
|
php
|
public function getTag($tag)
{
return isset($this->tags[$tag]) ? $this->tags[$tag] : null;
}
|
[
"public",
"function",
"getTag",
"(",
"$",
"tag",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"null",
";",
"}"
] |
Get the value of a tag, or null if it doesn't exist.
@param string $tag The name of the tag
@return mixed The value of the tag or null
|
[
"Get",
"the",
"value",
"of",
"a",
"tag",
"or",
"null",
"if",
"it",
"doesn",
"t",
"exist",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L260-L263
|
238,844
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.setHeader
|
public function setHeader($action, $method = 'POST', array $attributes = array())
{
$this->setAction($action);
$this->setMethod($method);
$this->setAttributes($attributes);
return $this;
}
|
php
|
public function setHeader($action, $method = 'POST', array $attributes = array())
{
$this->setAction($action);
$this->setMethod($method);
$this->setAttributes($attributes);
return $this;
}
|
[
"public",
"function",
"setHeader",
"(",
"$",
"action",
",",
"$",
"method",
"=",
"'POST'",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setAction",
"(",
"$",
"action",
")",
";",
"$",
"this",
"->",
"setMethod",
"(",
"$",
"method",
")",
";",
"$",
"this",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the action, method and any additional attributes of the Form.
@param string $action The action.
@param string $method The method.
@param array $attributes The attributes.
|
[
"Set",
"the",
"action",
"method",
"and",
"any",
"additional",
"attributes",
"of",
"the",
"Form",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L282-L289
|
238,845
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.header
|
public function header()
{
$attributes = array('action' => $this->action, 'method' => $this->method);
$attributes = array_merge($attributes, $this->attributes);
return Html::openTag('form', $attributes);
}
|
php
|
public function header()
{
$attributes = array('action' => $this->action, 'method' => $this->method);
$attributes = array_merge($attributes, $this->attributes);
return Html::openTag('form', $attributes);
}
|
[
"public",
"function",
"header",
"(",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"action",
",",
"'method'",
"=>",
"$",
"this",
"->",
"method",
")",
";",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"attributes",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"return",
"Html",
"::",
"openTag",
"(",
"'form'",
",",
"$",
"attributes",
")",
";",
"}"
] |
Render the header of this Form as Html.
|
[
"Render",
"the",
"header",
"of",
"this",
"Form",
"as",
"Html",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L294-L300
|
238,846
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.render
|
public function render(RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
$form = $this->header();
foreach ($this->rows as $row) {
$form .= $row->render($renderer);
}
$form .= '</form>';
return $form;
}
|
php
|
public function render(RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
$form = $this->header();
foreach ($this->rows as $row) {
$form .= $row->render($renderer);
}
$form .= '</form>';
return $form;
}
|
[
"public",
"function",
"render",
"(",
"RendererInterface",
"$",
"renderer",
"=",
"null",
")",
"{",
"$",
"renderer",
"=",
"$",
"renderer",
"?",
":",
"$",
"this",
"->",
"getDefaultRenderer",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"header",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"row",
")",
"{",
"$",
"form",
".=",
"$",
"row",
"->",
"render",
"(",
"$",
"renderer",
")",
";",
"}",
"$",
"form",
".=",
"'</form>'",
";",
"return",
"$",
"form",
";",
"}"
] |
Render the entire Form.
|
[
"Render",
"the",
"entire",
"Form",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L305-L315
|
238,847
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.row
|
public function row($name, RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
return $this->getRow($name)->render($renderer);
}
|
php
|
public function row($name, RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
return $this->getRow($name)->render($renderer);
}
|
[
"public",
"function",
"row",
"(",
"$",
"name",
",",
"RendererInterface",
"$",
"renderer",
"=",
"null",
")",
"{",
"$",
"renderer",
"=",
"$",
"renderer",
"?",
":",
"$",
"this",
"->",
"getDefaultRenderer",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getRow",
"(",
"$",
"name",
")",
"->",
"render",
"(",
"$",
"renderer",
")",
";",
"}"
] |
Render a row. If no renderer is supplied, the default renderer on this
form will be used.
@param string $name The name of the row
@param RendererInterface $renderer The renderer to use
|
[
"Render",
"a",
"row",
".",
"If",
"no",
"renderer",
"is",
"supplied",
"the",
"default",
"renderer",
"on",
"this",
"form",
"will",
"be",
"used",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L324-L329
|
238,848
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.input
|
public function input($name, RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
return $this->getRow($name)->input($renderer);
}
|
php
|
public function input($name, RendererInterface $renderer = null)
{
$renderer = $renderer ?: $this->getDefaultRenderer();
return $this->getRow($name)->input($renderer);
}
|
[
"public",
"function",
"input",
"(",
"$",
"name",
",",
"RendererInterface",
"$",
"renderer",
"=",
"null",
")",
"{",
"$",
"renderer",
"=",
"$",
"renderer",
"?",
":",
"$",
"this",
"->",
"getDefaultRenderer",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getRow",
"(",
"$",
"name",
")",
"->",
"input",
"(",
"$",
"renderer",
")",
";",
"}"
] |
Render the input of a row. If no renderer is supplied, the default
renderer on this form will be used.
@param string $name The name of the row
@param RendererInterface $renderer The renderer to use
|
[
"Render",
"the",
"input",
"of",
"a",
"row",
".",
"If",
"no",
"renderer",
"is",
"supplied",
"the",
"default",
"renderer",
"on",
"this",
"form",
"will",
"be",
"used",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L338-L343
|
238,849
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.setValues
|
public function setValues(array $values = array(), $ignore_unknown = false)
{
foreach ($values as $name => $value) {
try {
$this->getRow($name)->setValue($value);
} catch (\InvalidArgumentException $e) {
if (!$ignore_unknown) {
throw $e;
}
}
}
return $this;
}
|
php
|
public function setValues(array $values = array(), $ignore_unknown = false)
{
foreach ($values as $name => $value) {
try {
$this->getRow($name)->setValue($value);
} catch (\InvalidArgumentException $e) {
if (!$ignore_unknown) {
throw $e;
}
}
}
return $this;
}
|
[
"public",
"function",
"setValues",
"(",
"array",
"$",
"values",
"=",
"array",
"(",
")",
",",
"$",
"ignore_unknown",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getRow",
"(",
"$",
"name",
")",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"ignore_unknown",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of multiple rows.
@param array $values The array of values
@param bool $ignore_unknown Whether to ignore any unknown form rows
|
[
"Set",
"the",
"value",
"of",
"multiple",
"rows",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L425-L438
|
238,850
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.getValues
|
public function getValues()
{
$values = array();
foreach ($this->rows as $name => $row) {
$values[$name] = $row->getValue();
}
return $values;
}
|
php
|
public function getValues()
{
$values = array();
foreach ($this->rows as $name => $row) {
$values[$name] = $row->getValue();
}
return $values;
}
|
[
"public",
"function",
"getValues",
"(",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"name",
"=>",
"$",
"row",
")",
"{",
"$",
"values",
"[",
"$",
"name",
"]",
"=",
"$",
"row",
"->",
"getValue",
"(",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Get the values of all rows.
|
[
"Get",
"the",
"values",
"of",
"all",
"rows",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L455-L463
|
238,851
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.buildValidator
|
public function buildValidator()
{
if ($this->validator_built) {
return $this->validator;
}
foreach ($this->rows as $name => $row) {
foreach ($row->getRules() as $rule) {
$this->validator->addRule($name, $rule);
}
$row->disableRules();
}
$this->validator_built = true;
return $this->validator;
}
|
php
|
public function buildValidator()
{
if ($this->validator_built) {
return $this->validator;
}
foreach ($this->rows as $name => $row) {
foreach ($row->getRules() as $rule) {
$this->validator->addRule($name, $rule);
}
$row->disableRules();
}
$this->validator_built = true;
return $this->validator;
}
|
[
"public",
"function",
"buildValidator",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validator_built",
")",
"{",
"return",
"$",
"this",
"->",
"validator",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"rows",
"as",
"$",
"name",
"=>",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"row",
"->",
"getRules",
"(",
")",
"as",
"$",
"rule",
")",
"{",
"$",
"this",
"->",
"validator",
"->",
"addRule",
"(",
"$",
"name",
",",
"$",
"rule",
")",
";",
"}",
"$",
"row",
"->",
"disableRules",
"(",
")",
";",
"}",
"$",
"this",
"->",
"validator_built",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"validator",
";",
"}"
] |
Add the rules from all rows to form a complete Validator for
this form. The Validator can only be built once - no additional
rules may be added after building.
|
[
"Add",
"the",
"rules",
"from",
"all",
"rows",
"to",
"form",
"a",
"complete",
"Validator",
"for",
"this",
"form",
".",
"The",
"Validator",
"can",
"only",
"be",
"built",
"once",
"-",
"no",
"additional",
"rules",
"may",
"be",
"added",
"after",
"building",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L514-L529
|
238,852
|
glynnforrest/reform
|
src/Reform/Form/Form.php
|
Form.flattenArray
|
protected function flattenArray(array $values, $previous = '')
{
$result = array();
foreach ($values as $key => $value) {
if ($previous) {
$key = $previous.'['.$key.']';
}
if (is_array($value)) {
$result = $result + $this->flattenArray($value, $key);
} else {
$result[$key] = $value;
}
}
return $result;
}
|
php
|
protected function flattenArray(array $values, $previous = '')
{
$result = array();
foreach ($values as $key => $value) {
if ($previous) {
$key = $previous.'['.$key.']';
}
if (is_array($value)) {
$result = $result + $this->flattenArray($value, $key);
} else {
$result[$key] = $value;
}
}
return $result;
}
|
[
"protected",
"function",
"flattenArray",
"(",
"array",
"$",
"values",
",",
"$",
"previous",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"previous",
")",
"{",
"$",
"key",
"=",
"$",
"previous",
".",
"'['",
".",
"$",
"key",
".",
"']'",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"+",
"$",
"this",
"->",
"flattenArray",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Flatten a multidimensional array into a one-dimensional array, using
square brackets to show the structure of the original array.
|
[
"Flatten",
"a",
"multidimensional",
"array",
"into",
"a",
"one",
"-",
"dimensional",
"array",
"using",
"square",
"brackets",
"to",
"show",
"the",
"structure",
"of",
"the",
"original",
"array",
"."
] |
a2a33dfa73933875f9c1dd0691b21e678a541a9e
|
https://github.com/glynnforrest/reform/blob/a2a33dfa73933875f9c1dd0691b21e678a541a9e/src/Reform/Form/Form.php#L535-L550
|
238,853
|
cityware/city-monitoring
|
src/Jobs/Services/Snmp/PhpFpm.php
|
PhpFpm.getServiceData
|
public function getServiceData($snmpConnection) {
$phpFpmData = $snmpConnection->realWalkToArray('NET-SNMP-EXTEND-MIB::nsExtendOutLine."Php-Fpm"', true);
$return = Array();
$return['num_listen_queue'] = $phpFpmData[1];
$return['num_accepted_connections'] = $phpFpmData[2];
$return['num_idle_processes'] = $phpFpmData[3];
$return['num_max_listen_queue'] = $phpFpmData[4];
$return['num_slow_requests'] = $phpFpmData[5];
$return['num_max_active_processes'] = $phpFpmData[6];
$return['num_active_processes'] = $phpFpmData[7];
$return['num_start_since'] = $phpFpmData[8];
$return['des_start_time'] = "$phpFpmData[9]";
$return['num_listen_queue_len'] = $phpFpmData[10];
$return['des_pool'] = "$phpFpmData[11]";
$return['num_max_children_reached'] = $phpFpmData[12];
$return['num_total_processes'] = $phpFpmData[13];
$return['des_process_manager'] = "$phpFpmData[14]";
return $return;
}
|
php
|
public function getServiceData($snmpConnection) {
$phpFpmData = $snmpConnection->realWalkToArray('NET-SNMP-EXTEND-MIB::nsExtendOutLine."Php-Fpm"', true);
$return = Array();
$return['num_listen_queue'] = $phpFpmData[1];
$return['num_accepted_connections'] = $phpFpmData[2];
$return['num_idle_processes'] = $phpFpmData[3];
$return['num_max_listen_queue'] = $phpFpmData[4];
$return['num_slow_requests'] = $phpFpmData[5];
$return['num_max_active_processes'] = $phpFpmData[6];
$return['num_active_processes'] = $phpFpmData[7];
$return['num_start_since'] = $phpFpmData[8];
$return['des_start_time'] = "$phpFpmData[9]";
$return['num_listen_queue_len'] = $phpFpmData[10];
$return['des_pool'] = "$phpFpmData[11]";
$return['num_max_children_reached'] = $phpFpmData[12];
$return['num_total_processes'] = $phpFpmData[13];
$return['des_process_manager'] = "$phpFpmData[14]";
return $return;
}
|
[
"public",
"function",
"getServiceData",
"(",
"$",
"snmpConnection",
")",
"{",
"$",
"phpFpmData",
"=",
"$",
"snmpConnection",
"->",
"realWalkToArray",
"(",
"'NET-SNMP-EXTEND-MIB::nsExtendOutLine.\"Php-Fpm\"'",
",",
"true",
")",
";",
"$",
"return",
"=",
"Array",
"(",
")",
";",
"$",
"return",
"[",
"'num_listen_queue'",
"]",
"=",
"$",
"phpFpmData",
"[",
"1",
"]",
";",
"$",
"return",
"[",
"'num_accepted_connections'",
"]",
"=",
"$",
"phpFpmData",
"[",
"2",
"]",
";",
"$",
"return",
"[",
"'num_idle_processes'",
"]",
"=",
"$",
"phpFpmData",
"[",
"3",
"]",
";",
"$",
"return",
"[",
"'num_max_listen_queue'",
"]",
"=",
"$",
"phpFpmData",
"[",
"4",
"]",
";",
"$",
"return",
"[",
"'num_slow_requests'",
"]",
"=",
"$",
"phpFpmData",
"[",
"5",
"]",
";",
"$",
"return",
"[",
"'num_max_active_processes'",
"]",
"=",
"$",
"phpFpmData",
"[",
"6",
"]",
";",
"$",
"return",
"[",
"'num_active_processes'",
"]",
"=",
"$",
"phpFpmData",
"[",
"7",
"]",
";",
"$",
"return",
"[",
"'num_start_since'",
"]",
"=",
"$",
"phpFpmData",
"[",
"8",
"]",
";",
"$",
"return",
"[",
"'des_start_time'",
"]",
"=",
"\"$phpFpmData[9]\"",
";",
"$",
"return",
"[",
"'num_listen_queue_len'",
"]",
"=",
"$",
"phpFpmData",
"[",
"10",
"]",
";",
"$",
"return",
"[",
"'des_pool'",
"]",
"=",
"\"$phpFpmData[11]\"",
";",
"$",
"return",
"[",
"'num_max_children_reached'",
"]",
"=",
"$",
"phpFpmData",
"[",
"12",
"]",
";",
"$",
"return",
"[",
"'num_total_processes'",
"]",
"=",
"$",
"phpFpmData",
"[",
"13",
"]",
";",
"$",
"return",
"[",
"'des_process_manager'",
"]",
"=",
"\"$phpFpmData[14]\"",
";",
"return",
"$",
"return",
";",
"}"
] |
Return PHP-FPM service Data
@param object $snmpConnection
@return array
|
[
"Return",
"PHP",
"-",
"FPM",
"service",
"Data"
] |
0eb4e7ade7e2028093109856e67a317743b2e048
|
https://github.com/cityware/city-monitoring/blob/0eb4e7ade7e2028093109856e67a317743b2e048/src/Jobs/Services/Snmp/PhpFpm.php#L23-L45
|
238,854
|
Silvestra/Silvestra
|
src/Silvestra/Component/Banner/Form/Factory/BannerFormFactory.php
|
BannerFormFactory.create
|
public function create(BannerInterface $banner)
{
return $this->formFactory->create(
'silvestra_banner',
$banner,
array('action' => $this->router->getContext()->getPathInfo())
);
}
|
php
|
public function create(BannerInterface $banner)
{
return $this->formFactory->create(
'silvestra_banner',
$banner,
array('action' => $this->router->getContext()->getPathInfo())
);
}
|
[
"public",
"function",
"create",
"(",
"BannerInterface",
"$",
"banner",
")",
"{",
"return",
"$",
"this",
"->",
"formFactory",
"->",
"create",
"(",
"'silvestra_banner'",
",",
"$",
"banner",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"router",
"->",
"getContext",
"(",
")",
"->",
"getPathInfo",
"(",
")",
")",
")",
";",
"}"
] |
Create banner form.
@param BannerInterface $banner
@return FormInterface
|
[
"Create",
"banner",
"form",
"."
] |
b7367601b01495ae3c492b42042f804dee13ab06
|
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Banner/Form/Factory/BannerFormFactory.php#L55-L62
|
238,855
|
jelix/BuildTools
|
lib/Cli/Environment.php
|
Environment.init
|
public static function init($build_options)
{
self::$variables_def = $build_options;
foreach ($build_options as $name => $def) {
// if there isn't a defined default value,
// let's defining an empty string as default value
if (!isset($def[1])) {
self::$variables_def[$name][1] = '';
}
// if the default value is not a boolean, and if there isn't a third
// parameter in the array, let's define a third parameter
if (!isset($def[2]) && !is_bool(self::$variables_def[$name][1])) {
self::$variables_def[$name][2] = '';
}
self::storeValue($name, self::$variables_def[$name][1]);
}
}
|
php
|
public static function init($build_options)
{
self::$variables_def = $build_options;
foreach ($build_options as $name => $def) {
// if there isn't a defined default value,
// let's defining an empty string as default value
if (!isset($def[1])) {
self::$variables_def[$name][1] = '';
}
// if the default value is not a boolean, and if there isn't a third
// parameter in the array, let's define a third parameter
if (!isset($def[2]) && !is_bool(self::$variables_def[$name][1])) {
self::$variables_def[$name][2] = '';
}
self::storeValue($name, self::$variables_def[$name][1]);
}
}
|
[
"public",
"static",
"function",
"init",
"(",
"$",
"build_options",
")",
"{",
"self",
"::",
"$",
"variables_def",
"=",
"$",
"build_options",
";",
"foreach",
"(",
"$",
"build_options",
"as",
"$",
"name",
"=>",
"$",
"def",
")",
"{",
"// if there isn't a defined default value,",
"// let's defining an empty string as default value",
"if",
"(",
"!",
"isset",
"(",
"$",
"def",
"[",
"1",
"]",
")",
")",
"{",
"self",
"::",
"$",
"variables_def",
"[",
"$",
"name",
"]",
"[",
"1",
"]",
"=",
"''",
";",
"}",
"// if the default value is not a boolean, and if there isn't a third",
"// parameter in the array, let's define a third parameter",
"if",
"(",
"!",
"isset",
"(",
"$",
"def",
"[",
"2",
"]",
")",
"&&",
"!",
"is_bool",
"(",
"self",
"::",
"$",
"variables_def",
"[",
"$",
"name",
"]",
"[",
"1",
"]",
")",
")",
"{",
"self",
"::",
"$",
"variables_def",
"[",
"$",
"name",
"]",
"[",
"2",
"]",
"=",
"''",
";",
"}",
"self",
"::",
"storeValue",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"variables_def",
"[",
"$",
"name",
"]",
"[",
"1",
"]",
")",
";",
"}",
"}"
] |
init the globals variables, by reading the given
array which describes all this variables.
each build options item should be an array
0: help (or false for hidden options)
1: the default value (string)
2: a preg expression to verify the given value
or
1: a boolean, which indicates that the option is a boolean value
the value of this boolean is the default value
2: no value
@param array $build_options the options to create as globals variables
|
[
"init",
"the",
"globals",
"variables",
"by",
"reading",
"the",
"given",
"array",
"which",
"describes",
"all",
"this",
"variables",
"."
] |
432050708c72107f959614f53696384aa92b9e1b
|
https://github.com/jelix/BuildTools/blob/432050708c72107f959614f53696384aa92b9e1b/lib/Cli/Environment.php#L39-L56
|
238,856
|
stubbles/stubbles-values
|
src/main/php/Value.php
|
Value.isEmpty
|
public function isEmpty(): bool
{
return $this->isNull()
|| (is_array($this->value) && count($this->value) === 0)
|| (is_string($this->value) && strlen($this->value) === 0);
}
|
php
|
public function isEmpty(): bool
{
return $this->isNull()
|| (is_array($this->value) && count($this->value) === 0)
|| (is_string($this->value) && strlen($this->value) === 0);
}
|
[
"public",
"function",
"isEmpty",
"(",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"isNull",
"(",
")",
"||",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"0",
")",
"||",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"strlen",
"(",
"$",
"this",
"->",
"value",
")",
"===",
"0",
")",
";",
"}"
] |
checks if value is empty
Value is empty if its value is null, an empty string or an empty array.
@return bool
@since 8.1.0
|
[
"checks",
"if",
"value",
"is",
"empty"
] |
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
|
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Value.php#L87-L92
|
238,857
|
stubbles/stubbles-values
|
src/main/php/Value.php
|
Value.containsAnyOf
|
public function containsAnyOf(array $elements): bool
{
if (!is_scalar($this->value) || null === $this->value) {
return false;
}
foreach ($elements as $needle) {
if (is_bool($needle) && $this->value === $needle) {
return true;
} elseif (!is_bool($needle) && ($this->value === $needle || (is_string($this->value) && false !== strpos($this->value, (string) $needle)))) {
return true;
}
}
return false;
}
|
php
|
public function containsAnyOf(array $elements): bool
{
if (!is_scalar($this->value) || null === $this->value) {
return false;
}
foreach ($elements as $needle) {
if (is_bool($needle) && $this->value === $needle) {
return true;
} elseif (!is_bool($needle) && ($this->value === $needle || (is_string($this->value) && false !== strpos($this->value, (string) $needle)))) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"containsAnyOf",
"(",
"array",
"$",
"elements",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"this",
"->",
"value",
")",
"||",
"null",
"===",
"$",
"this",
"->",
"value",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"needle",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"needle",
")",
"&&",
"$",
"this",
"->",
"value",
"===",
"$",
"needle",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"!",
"is_bool",
"(",
"$",
"needle",
")",
"&&",
"(",
"$",
"this",
"->",
"value",
"===",
"$",
"needle",
"||",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"this",
"->",
"value",
",",
"(",
"string",
")",
"$",
"needle",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
checks that value contains any of the given elements
@param array $elements
@return bool
|
[
"checks",
"that",
"value",
"contains",
"any",
"of",
"the",
"given",
"elements"
] |
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
|
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Value.php#L139-L154
|
238,858
|
stubbles/stubbles-values
|
src/main/php/Value.php
|
Value.isOneOf
|
public function isOneOf(array $allowedValues, bool $strict = false): bool
{
if (!is_array($this->value)) {
return in_array($this->value, $allowedValues, $strict);
}
foreach ($this->value as $value) {
if (!in_array($value, $allowedValues, $strict)) {
return false;
}
}
return true;
}
|
php
|
public function isOneOf(array $allowedValues, bool $strict = false): bool
{
if (!is_array($this->value)) {
return in_array($this->value, $allowedValues, $strict);
}
foreach ($this->value as $value) {
if (!in_array($value, $allowedValues, $strict)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"isOneOf",
"(",
"array",
"$",
"allowedValues",
",",
"bool",
"$",
"strict",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"return",
"in_array",
"(",
"$",
"this",
"->",
"value",
",",
"$",
"allowedValues",
",",
"$",
"strict",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"value",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"allowedValues",
",",
"$",
"strict",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
checks that value is one of the allowed values
@param array $allowedValues
@param bool $strict optional whether type must match as well
@return bool
|
[
"checks",
"that",
"value",
"is",
"one",
"of",
"the",
"allowed",
"values"
] |
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
|
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Value.php#L181-L194
|
238,859
|
stubbles/stubbles-values
|
src/main/php/Value.php
|
Value.defineCheck
|
public static function defineCheck(string $method, callable $function)
{
if (function_exists($method)) {
throw new \InvalidArgumentException('Can not overwrite internal PHP function ' . $method . '().');
}
self::$checks[$method] = $function;
}
|
php
|
public static function defineCheck(string $method, callable $function)
{
if (function_exists($method)) {
throw new \InvalidArgumentException('Can not overwrite internal PHP function ' . $method . '().');
}
self::$checks[$method] = $function;
}
|
[
"public",
"static",
"function",
"defineCheck",
"(",
"string",
"$",
"method",
",",
"callable",
"$",
"function",
")",
"{",
"if",
"(",
"function_exists",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Can not overwrite internal PHP function '",
".",
"$",
"method",
".",
"'().'",
")",
";",
"}",
"self",
"::",
"$",
"checks",
"[",
"$",
"method",
"]",
"=",
"$",
"function",
";",
"}"
] |
adds a check method
The $method must be an allowed method name which can be called on an
instance of stubbles\values\Value. The given callable function must
accept the value to check as first parameter and any additional
parameters after that. It must either return true or false.
<code>
Value::addCheck('isHttpUri', [stubbles\peer\http\HttpUri::class, 'isValid']);
if (value('http://example.net')->isHttpUri()) {
// yes, do something with it
}
</code>
Self-defined checks can be overwritten by passing another callable with
the same method name. PHP internal functions like is_int() must not be
defined as check, they are available by default. Please note that it is
not allowed to overwrite existing functions, e.g. you can not redefine
is_int().
@param string $method
@param callable $function
@throws \InvalidArgumentException
|
[
"adds",
"a",
"check",
"method"
] |
505e016715f7d7f96e180f2e8a1d711a12a3c4c2
|
https://github.com/stubbles/stubbles-values/blob/505e016715f7d7f96e180f2e8a1d711a12a3c4c2/src/main/php/Value.php#L247-L254
|
238,860
|
marando/phpSOFA
|
src/Marando/IAU/iauObl06.php
|
iauObl06.Obl06
|
public static function Obl06($date1, $date2) {
$t;
$eps0;
/* Interval between fundamental date J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Mean obliquity. */
$eps0 = (84381.406 +
(-46.836769 +
( -0.0001831 +
( 0.00200340 +
( -0.000000576 +
( -0.0000000434) * $t) * $t) * $t) * $t) * $t) * DAS2R;
return $eps0;
}
|
php
|
public static function Obl06($date1, $date2) {
$t;
$eps0;
/* Interval between fundamental date J2000.0 and given date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Mean obliquity. */
$eps0 = (84381.406 +
(-46.836769 +
( -0.0001831 +
( 0.00200340 +
( -0.000000576 +
( -0.0000000434) * $t) * $t) * $t) * $t) * $t) * DAS2R;
return $eps0;
}
|
[
"public",
"static",
"function",
"Obl06",
"(",
"$",
"date1",
",",
"$",
"date2",
")",
"{",
"$",
"t",
";",
"$",
"eps0",
";",
"/* Interval between fundamental date J2000.0 and given date (JC). */",
"$",
"t",
"=",
"(",
"(",
"$",
"date1",
"-",
"DJ00",
")",
"+",
"$",
"date2",
")",
"/",
"DJC",
";",
"/* Mean obliquity. */",
"$",
"eps0",
"=",
"(",
"84381.406",
"+",
"(",
"-",
"46.836769",
"+",
"(",
"-",
"0.0001831",
"+",
"(",
"0.00200340",
"+",
"(",
"-",
"0.000000576",
"+",
"(",
"-",
"0.0000000434",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"DAS2R",
";",
"return",
"$",
"eps0",
";",
"}"
] |
- - - - - - - - -
i a u O b l 0 6
- - - - - - - - -
Mean obliquity of the ecliptic, IAU 2006 precession model.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
date1,date2 double TT as a 2-part Julian Date (Note 1)
Returned (function value):
double obliquity of the ecliptic (radians, Note 2)
Notes:
1) The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways,
among others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable. The J2000 method is best matched to the way
the argument is handled internally and will deliver the
optimum resolution. The MJD method and the date & time methods
are both good compromises between resolution and convenience.
2) The result is the angle between the ecliptic and mean equator of
date date1+date2.
Reference:
Hilton, J. et al., 2006, Celest.Mech.Dyn.Astron. 94, 351
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"O",
"b",
"l",
"0",
"6",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauObl06.php#L59-L75
|
238,861
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createService
|
protected function createService($name)
{
$name = $this->configureName('service', $name);
if($this->serviceNameExists($name) === true) {
return $this->error('Service already exists');
}
$this->createServiceDirectory();
$this->createBaseServiceAbstract();
$this->createServiceFile($name, $this->option('i') || $this->option('interface') ? true : false);
}
|
php
|
protected function createService($name)
{
$name = $this->configureName('service', $name);
if($this->serviceNameExists($name) === true) {
return $this->error('Service already exists');
}
$this->createServiceDirectory();
$this->createBaseServiceAbstract();
$this->createServiceFile($name, $this->option('i') || $this->option('interface') ? true : false);
}
|
[
"protected",
"function",
"createService",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"configureName",
"(",
"'service'",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"serviceNameExists",
"(",
"$",
"name",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"'Service already exists'",
")",
";",
"}",
"$",
"this",
"->",
"createServiceDirectory",
"(",
")",
";",
"$",
"this",
"->",
"createBaseServiceAbstract",
"(",
")",
";",
"$",
"this",
"->",
"createServiceFile",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"option",
"(",
"'i'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'interface'",
")",
"?",
"true",
":",
"false",
")",
";",
"}"
] |
Create the service
@param string $name
@return void
|
[
"Create",
"the",
"service"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L90-L103
|
238,862
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createBaseServiceAbstract
|
protected function createBaseServiceAbstract()
{
if( ! $this->files->exists($this->getServiceDirectory() . 'BaseServiceAbstract.php')) {
$stub = str_replace(
['{{ServiceDirectory}}'],
$this->getServiceDirectoryFromConfig(),
$this->files->get(__DIR__ . '/../stubs/base-abstract.stub')
);
$this->files->put(base_path() . '/' . $this->getServiceDirectory() . 'BaseServiceAbstract.php', $stub);
}
}
|
php
|
protected function createBaseServiceAbstract()
{
if( ! $this->files->exists($this->getServiceDirectory() . 'BaseServiceAbstract.php')) {
$stub = str_replace(
['{{ServiceDirectory}}'],
$this->getServiceDirectoryFromConfig(),
$this->files->get(__DIR__ . '/../stubs/base-abstract.stub')
);
$this->files->put(base_path() . '/' . $this->getServiceDirectory() . 'BaseServiceAbstract.php', $stub);
}
}
|
[
"protected",
"function",
"createBaseServiceAbstract",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
".",
"'BaseServiceAbstract.php'",
")",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{ServiceDirectory}}'",
"]",
",",
"$",
"this",
"->",
"getServiceDirectoryFromConfig",
"(",
")",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/base-abstract.stub'",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"base_path",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
".",
"'BaseServiceAbstract.php'",
",",
"$",
"stub",
")",
";",
"}",
"}"
] |
Create base service abstract class file
@return void
|
[
"Create",
"base",
"service",
"abstract",
"class",
"file"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L146-L157
|
238,863
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createBaseInterfaceFile
|
protected function createBaseInterfaceFile()
{
if( ! $this->files->exists($this->getRepositoryDirectory() . 'BaseRepositoryInterface.php')) {
$stub = str_replace(
['{{Namespace}}'],
$this->getRepositoryDirectoryFromConfig(),
$this->files->get(__DIR__ . '/../stubs/base-interface.stub')
);
$this->files->put(base_path() . '/' . $this->getRepositoryDirectory() . 'BaseRepositoryInterface.php', $stub);
}
}
|
php
|
protected function createBaseInterfaceFile()
{
if( ! $this->files->exists($this->getRepositoryDirectory() . 'BaseRepositoryInterface.php')) {
$stub = str_replace(
['{{Namespace}}'],
$this->getRepositoryDirectoryFromConfig(),
$this->files->get(__DIR__ . '/../stubs/base-interface.stub')
);
$this->files->put(base_path() . '/' . $this->getRepositoryDirectory() . 'BaseRepositoryInterface.php', $stub);
}
}
|
[
"protected",
"function",
"createBaseInterfaceFile",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
".",
"'BaseRepositoryInterface.php'",
")",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{Namespace}}'",
"]",
",",
"$",
"this",
"->",
"getRepositoryDirectoryFromConfig",
"(",
")",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/base-interface.stub'",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"base_path",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
".",
"'BaseRepositoryInterface.php'",
",",
"$",
"stub",
")",
";",
"}",
"}"
] |
Create base interface file
@return void
|
[
"Create",
"base",
"interface",
"file"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L164-L175
|
238,864
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createServiceFile
|
protected function createServiceFile($name, $with_interface)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$classname = $this->configureName('service', $name);
if($with_interface === true) {
$interface = trim($this->option('interface'));
$interface = $this->configureName('repository', $interface ?: $name);
$stub = str_replace(
['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{InterfaceDirectory}}', '{{InterfaceName}}', '{{ClassName}}'],
[$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(),
$this->getRepositoryDirectoryFromConfig() . $dir_option, $interface, $classname],
$this->files->get($this->getServiceImplementsInterfaceStub())
);
} else {
$stub = str_replace(
['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{ClassName}}'],
[$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(), $classname],
$this->files->get($this->getServiceStub())
);
}
$this->files->put(base_path() . '/' . $this->getServiceDirectory() . $this->getDirOption() . $classname . '.php', $stub);
}
|
php
|
protected function createServiceFile($name, $with_interface)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$classname = $this->configureName('service', $name);
if($with_interface === true) {
$interface = trim($this->option('interface'));
$interface = $this->configureName('repository', $interface ?: $name);
$stub = str_replace(
['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{InterfaceDirectory}}', '{{InterfaceName}}', '{{ClassName}}'],
[$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(),
$this->getRepositoryDirectoryFromConfig() . $dir_option, $interface, $classname],
$this->files->get($this->getServiceImplementsInterfaceStub())
);
} else {
$stub = str_replace(
['{{Namespace}}', '{{BaseServiceAbstractDirectory}}', '{{ClassName}}'],
[$this->getServiceDirectoryFromConfig() . $dir_option, $this->getServiceDirectoryFromConfig(), $classname],
$this->files->get($this->getServiceStub())
);
}
$this->files->put(base_path() . '/' . $this->getServiceDirectory() . $this->getDirOption() . $classname . '.php', $stub);
}
|
[
"protected",
"function",
"createServiceFile",
"(",
"$",
"name",
",",
"$",
"with_interface",
")",
"{",
"$",
"dir_option",
"=",
"rtrim",
"(",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"this",
"->",
"getDirOption",
"(",
")",
")",
",",
"'/\\\\'",
")",
";",
"$",
"dir_option",
"=",
"$",
"dir_option",
"?",
"'\\\\'",
".",
"$",
"dir_option",
":",
"''",
";",
"$",
"classname",
"=",
"$",
"this",
"->",
"configureName",
"(",
"'service'",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"with_interface",
"===",
"true",
")",
"{",
"$",
"interface",
"=",
"trim",
"(",
"$",
"this",
"->",
"option",
"(",
"'interface'",
")",
")",
";",
"$",
"interface",
"=",
"$",
"this",
"->",
"configureName",
"(",
"'repository'",
",",
"$",
"interface",
"?",
":",
"$",
"name",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{Namespace}}'",
",",
"'{{BaseServiceAbstractDirectory}}'",
",",
"'{{InterfaceDirectory}}'",
",",
"'{{InterfaceName}}'",
",",
"'{{ClassName}}'",
"]",
",",
"[",
"$",
"this",
"->",
"getServiceDirectoryFromConfig",
"(",
")",
".",
"$",
"dir_option",
",",
"$",
"this",
"->",
"getServiceDirectoryFromConfig",
"(",
")",
",",
"$",
"this",
"->",
"getRepositoryDirectoryFromConfig",
"(",
")",
".",
"$",
"dir_option",
",",
"$",
"interface",
",",
"$",
"classname",
"]",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"this",
"->",
"getServiceImplementsInterfaceStub",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{Namespace}}'",
",",
"'{{BaseServiceAbstractDirectory}}'",
",",
"'{{ClassName}}'",
"]",
",",
"[",
"$",
"this",
"->",
"getServiceDirectoryFromConfig",
"(",
")",
".",
"$",
"dir_option",
",",
"$",
"this",
"->",
"getServiceDirectoryFromConfig",
"(",
")",
",",
"$",
"classname",
"]",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"this",
"->",
"getServiceStub",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"base_path",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"classname",
".",
"'.php'",
",",
"$",
"stub",
")",
";",
"}"
] |
Create the service class file
@return void
|
[
"Create",
"the",
"service",
"class",
"file"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L182-L207
|
238,865
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createInterfaceFile
|
protected function createInterfaceFile($interface)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$interface = $this->configureName('repository', $interface);
dd($interface);
$stub = str_replace(
['{{Namespace}}', '{{BaseInterfaceDirectory}}', '{{InterfaceClassName}}'],
[$this->getRepositoryDirectoryFromConfig() . $dir_option, $this->getRepositoryDirectoryFromConfig(), $interface],
$this->files->get(__DIR__ . '/../stubs/interface.stub')
);
$this->files->put(base_path() . '/' . $this->getRepositoryDirectory() . $this->getDirOption() . $interface . '.php', $stub);
}
|
php
|
protected function createInterfaceFile($interface)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$interface = $this->configureName('repository', $interface);
dd($interface);
$stub = str_replace(
['{{Namespace}}', '{{BaseInterfaceDirectory}}', '{{InterfaceClassName}}'],
[$this->getRepositoryDirectoryFromConfig() . $dir_option, $this->getRepositoryDirectoryFromConfig(), $interface],
$this->files->get(__DIR__ . '/../stubs/interface.stub')
);
$this->files->put(base_path() . '/' . $this->getRepositoryDirectory() . $this->getDirOption() . $interface . '.php', $stub);
}
|
[
"protected",
"function",
"createInterfaceFile",
"(",
"$",
"interface",
")",
"{",
"$",
"dir_option",
"=",
"rtrim",
"(",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"this",
"->",
"getDirOption",
"(",
")",
")",
",",
"'/\\\\'",
")",
";",
"$",
"dir_option",
"=",
"$",
"dir_option",
"?",
"'\\\\'",
".",
"$",
"dir_option",
":",
"''",
";",
"$",
"interface",
"=",
"$",
"this",
"->",
"configureName",
"(",
"'repository'",
",",
"$",
"interface",
")",
";",
"dd",
"(",
"$",
"interface",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{Namespace}}'",
",",
"'{{BaseInterfaceDirectory}}'",
",",
"'{{InterfaceClassName}}'",
"]",
",",
"[",
"$",
"this",
"->",
"getRepositoryDirectoryFromConfig",
"(",
")",
".",
"$",
"dir_option",
",",
"$",
"this",
"->",
"getRepositoryDirectoryFromConfig",
"(",
")",
",",
"$",
"interface",
"]",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/interface.stub'",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"base_path",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"interface",
".",
"'.php'",
",",
"$",
"stub",
")",
";",
"}"
] |
Create the interface file
@param string $interface
@return void
|
[
"Create",
"the",
"interface",
"file"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L215-L229
|
238,866
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createTraitFile
|
protected function createTraitFile($trait)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$trait = $this->configureName('trait', $trait);
$stub = str_replace(
['{{Namespace}}', '{{TraitName}}'],
[$this->getTraitDirectoryFromConfig() . $dir_option, $trait],
$this->files->get(__DIR__ . '/../stubs/trait.stub')
);
$this->files->put(base_path() . '/' . $this->getTraitDirectory() . $this->getDirOption() . $trait . '.php', $stub);
}
|
php
|
protected function createTraitFile($trait)
{
$dir_option = rtrim(str_replace('/', '\\', $this->getDirOption()), '/\\');
$dir_option = $dir_option ? '\\' . $dir_option : '';
$trait = $this->configureName('trait', $trait);
$stub = str_replace(
['{{Namespace}}', '{{TraitName}}'],
[$this->getTraitDirectoryFromConfig() . $dir_option, $trait],
$this->files->get(__DIR__ . '/../stubs/trait.stub')
);
$this->files->put(base_path() . '/' . $this->getTraitDirectory() . $this->getDirOption() . $trait . '.php', $stub);
}
|
[
"protected",
"function",
"createTraitFile",
"(",
"$",
"trait",
")",
"{",
"$",
"dir_option",
"=",
"rtrim",
"(",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"this",
"->",
"getDirOption",
"(",
")",
")",
",",
"'/\\\\'",
")",
";",
"$",
"dir_option",
"=",
"$",
"dir_option",
"?",
"'\\\\'",
".",
"$",
"dir_option",
":",
"''",
";",
"$",
"trait",
"=",
"$",
"this",
"->",
"configureName",
"(",
"'trait'",
",",
"$",
"trait",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"[",
"'{{Namespace}}'",
",",
"'{{TraitName}}'",
"]",
",",
"[",
"$",
"this",
"->",
"getTraitDirectoryFromConfig",
"(",
")",
".",
"$",
"dir_option",
",",
"$",
"trait",
"]",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/trait.stub'",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"base_path",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getTraitDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"trait",
".",
"'.php'",
",",
"$",
"stub",
")",
";",
"}"
] |
Create the trait file
@param string $trait
@return void
|
[
"Create",
"the",
"trait",
"file"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L237-L250
|
238,867
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.serviceNameExists
|
protected function serviceNameExists($name)
{
if($this->files->exists($this->getServiceDirectory() . $this->getDirOption() . $name . '.php')) {
return true;
}
return false;
}
|
php
|
protected function serviceNameExists($name)
{
if($this->files->exists($this->getServiceDirectory() . $this->getDirOption() . $name . '.php')) {
return true;
}
return false;
}
|
[
"protected",
"function",
"serviceNameExists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"name",
".",
"'.php'",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validate if service already exists
@param string $name
@return bool
|
[
"Validate",
"if",
"service",
"already",
"exists"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L258-L265
|
238,868
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.repositoryNameExists
|
protected function repositoryNameExists($interface)
{
if($this->files->exists($this->getRepositoryDirectory() . $this->getDirOption() . $interface . 'php')) {
return true;
}
return false;
}
|
php
|
protected function repositoryNameExists($interface)
{
if($this->files->exists($this->getRepositoryDirectory() . $this->getDirOption() . $interface . 'php')) {
return true;
}
return false;
}
|
[
"protected",
"function",
"repositoryNameExists",
"(",
"$",
"interface",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"interface",
".",
"'php'",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validate if repository interface already exists
@param string $interface
@return bool
|
[
"Validate",
"if",
"repository",
"interface",
"already",
"exists"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L273-L280
|
238,869
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.traitNameExists
|
protected function traitNameExists($trait)
{
if($this->files->exists($this->getTraitDirectory() . $this->getDirOption() . $trait . '.php')) {
return true;
}
return false;
}
|
php
|
protected function traitNameExists($trait)
{
if($this->files->exists($this->getTraitDirectory() . $this->getDirOption() . $trait . '.php')) {
return true;
}
return false;
}
|
[
"protected",
"function",
"traitNameExists",
"(",
"$",
"trait",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"getTraitDirectory",
"(",
")",
".",
"$",
"this",
"->",
"getDirOption",
"(",
")",
".",
"$",
"trait",
".",
"'.php'",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Validate if trait already exists
@param string $trait
@return bool
|
[
"Validate",
"if",
"trait",
"already",
"exists"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L288-L295
|
238,870
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.getServiceDirectory
|
protected function getServiceDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigServiceDirectory(), '/\\') . '/';
}
|
php
|
protected function getServiceDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigServiceDirectory(), '/\\') . '/';
}
|
[
"protected",
"function",
"getServiceDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"config",
"=",
"$",
"this",
"->",
"configFileMissing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"$",
"config",
")",
";",
"}",
"return",
"'app/'",
".",
"rtrim",
"(",
"$",
"this",
"->",
"getConfigServiceDirectory",
"(",
")",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}"
] |
Return the full service directory
@return string
|
[
"Return",
"the",
"full",
"service",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L302-L309
|
238,871
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.getRepositoryDirectory
|
protected function getRepositoryDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigRepositoryDirectory(), '/\\') . '/';
}
|
php
|
protected function getRepositoryDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigRepositoryDirectory(), '/\\') . '/';
}
|
[
"protected",
"function",
"getRepositoryDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"config",
"=",
"$",
"this",
"->",
"configFileMissing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"$",
"config",
")",
";",
"}",
"return",
"'app/'",
".",
"rtrim",
"(",
"$",
"this",
"->",
"getConfigRepositoryDirectory",
"(",
")",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}"
] |
Return the full repository directory
@return string
|
[
"Return",
"the",
"full",
"repository",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L316-L323
|
238,872
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.getTraitDirectory
|
protected function getTraitDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigTraitDirectory(), '/\\') . '/';
}
|
php
|
protected function getTraitDirectory()
{
if($config = $this->configFileMissing()) {
return $this->error($config);
}
return 'app/' . rtrim($this->getConfigTraitDirectory(), '/\\') . '/';
}
|
[
"protected",
"function",
"getTraitDirectory",
"(",
")",
"{",
"if",
"(",
"$",
"config",
"=",
"$",
"this",
"->",
"configFileMissing",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"$",
"config",
")",
";",
"}",
"return",
"'app/'",
".",
"rtrim",
"(",
"$",
"this",
"->",
"getConfigTraitDirectory",
"(",
")",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}"
] |
Return the full trait directory
@return string
|
[
"Return",
"the",
"full",
"trait",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L330-L337
|
238,873
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.getDirOption
|
protected function getDirOption($return_array = false)
{
if($dir = $this->option('dir')) {
$directories = explode('/', $dir);
if(is_array($directories) && $directories) {
$directories = array_map(function($directory) {
return ucfirst(str::plural(strtolower($directory)));
}, $directories);
return $return_array === true ? $directories : rtrim(implode('/', $directories), '/\\') . '/';
}
}
}
|
php
|
protected function getDirOption($return_array = false)
{
if($dir = $this->option('dir')) {
$directories = explode('/', $dir);
if(is_array($directories) && $directories) {
$directories = array_map(function($directory) {
return ucfirst(str::plural(strtolower($directory)));
}, $directories);
return $return_array === true ? $directories : rtrim(implode('/', $directories), '/\\') . '/';
}
}
}
|
[
"protected",
"function",
"getDirOption",
"(",
"$",
"return_array",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"option",
"(",
"'dir'",
")",
")",
"{",
"$",
"directories",
"=",
"explode",
"(",
"'/'",
",",
"$",
"dir",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"directories",
")",
"&&",
"$",
"directories",
")",
"{",
"$",
"directories",
"=",
"array_map",
"(",
"function",
"(",
"$",
"directory",
")",
"{",
"return",
"ucfirst",
"(",
"str",
"::",
"plural",
"(",
"strtolower",
"(",
"$",
"directory",
")",
")",
")",
";",
"}",
",",
"$",
"directories",
")",
";",
"return",
"$",
"return_array",
"===",
"true",
"?",
"$",
"directories",
":",
"rtrim",
"(",
"implode",
"(",
"'/'",
",",
"$",
"directories",
")",
",",
"'/\\\\'",
")",
".",
"'/'",
";",
"}",
"}",
"}"
] |
Return the directory option
@return string|null
|
[
"Return",
"the",
"directory",
"option"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L374-L386
|
238,874
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.configureName
|
protected function configureName($type, $name)
{
$config = $this->laravel['config']['repository'];
if($config["{$type}_to_plural"] === true) {
$name = Str::plural($name);
}
if($config["case_sensitive"] === false) {
$name = Str::studly(strtolower($name));
}
return $name . $config["{$type}_append"];
}
|
php
|
protected function configureName($type, $name)
{
$config = $this->laravel['config']['repository'];
if($config["{$type}_to_plural"] === true) {
$name = Str::plural($name);
}
if($config["case_sensitive"] === false) {
$name = Str::studly(strtolower($name));
}
return $name . $config["{$type}_append"];
}
|
[
"protected",
"function",
"configureName",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'config'",
"]",
"[",
"'repository'",
"]",
";",
"if",
"(",
"$",
"config",
"[",
"\"{$type}_to_plural\"",
"]",
"===",
"true",
")",
"{",
"$",
"name",
"=",
"Str",
"::",
"plural",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"\"case_sensitive\"",
"]",
"===",
"false",
")",
"{",
"$",
"name",
"=",
"Str",
"::",
"studly",
"(",
"strtolower",
"(",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"name",
".",
"$",
"config",
"[",
"\"{$type}_append\"",
"]",
";",
"}"
] |
Configure the name according to user preferred settings
@param string $type
@param string $name
@return string
|
[
"Configure",
"the",
"name",
"according",
"to",
"user",
"preferred",
"settings"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L407-L420
|
238,875
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createTraitDirectory
|
protected function createTraitDirectory()
{
if( ! $this->files->isDirectory($this->getTraitDirectory())) {
$this->files->makeDirectory($this->getTraitDirectory());
}
$this->createDirectory('trait');
}
|
php
|
protected function createTraitDirectory()
{
if( ! $this->files->isDirectory($this->getTraitDirectory())) {
$this->files->makeDirectory($this->getTraitDirectory());
}
$this->createDirectory('trait');
}
|
[
"protected",
"function",
"createTraitDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"getTraitDirectory",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"this",
"->",
"getTraitDirectory",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"createDirectory",
"(",
"'trait'",
")",
";",
"}"
] |
Create trait directory
@return void
|
[
"Create",
"trait",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L427-L434
|
238,876
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createInterfaceDirectory
|
protected function createInterfaceDirectory()
{
if( ! $this->files->isDirectory($this->getRepositoryDirectory())) {
$this->files->makeDirectory($this->getRepositoryDirectory());
}
$this->createDirectory('repository');
}
|
php
|
protected function createInterfaceDirectory()
{
if( ! $this->files->isDirectory($this->getRepositoryDirectory())) {
$this->files->makeDirectory($this->getRepositoryDirectory());
}
$this->createDirectory('repository');
}
|
[
"protected",
"function",
"createInterfaceDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"this",
"->",
"getRepositoryDirectory",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"createDirectory",
"(",
"'repository'",
")",
";",
"}"
] |
Create interface directory
@return void
|
[
"Create",
"interface",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L441-L448
|
238,877
|
nwjeffm/nw-service-generator
|
src/Commands/MakeRepositoryCommand.php
|
MakeRepositoryCommand.createServiceDirectory
|
protected function createServiceDirectory()
{
if( ! $this->files->isDirectory($this->getServiceDirectory())) {
$this->files->makeDirectory($this->getServiceDirectory());
}
$this->createDirectory('service');
}
|
php
|
protected function createServiceDirectory()
{
if( ! $this->files->isDirectory($this->getServiceDirectory())) {
$this->files->makeDirectory($this->getServiceDirectory());
}
$this->createDirectory('service');
}
|
[
"protected",
"function",
"createServiceDirectory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"this",
"->",
"getServiceDirectory",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"createDirectory",
"(",
"'service'",
")",
";",
"}"
] |
Create service directory
@return void
|
[
"Create",
"service",
"directory"
] |
39125f0bdf5275edb429e032c1c1ae581765fedd
|
https://github.com/nwjeffm/nw-service-generator/blob/39125f0bdf5275edb429e032c1c1ae581765fedd/src/Commands/MakeRepositoryCommand.php#L455-L462
|
238,878
|
Xannn94/support
|
src/Bases/RouteRegister.php
|
RouteRegister.getAttributes
|
protected function getAttributes(array $merge = [])
{
return array_merge([
'prefix' => $this->prefix,
'as' => $this->routeName,
'middleware' => $this->middlewares,
'namespace' => $this->namespace,
], $merge);
}
|
php
|
protected function getAttributes(array $merge = [])
{
return array_merge([
'prefix' => $this->prefix,
'as' => $this->routeName,
'middleware' => $this->middlewares,
'namespace' => $this->namespace,
], $merge);
}
|
[
"protected",
"function",
"getAttributes",
"(",
"array",
"$",
"merge",
"=",
"[",
"]",
")",
"{",
"return",
"array_merge",
"(",
"[",
"'prefix'",
"=>",
"$",
"this",
"->",
"prefix",
",",
"'as'",
"=>",
"$",
"this",
"->",
"routeName",
",",
"'middleware'",
"=>",
"$",
"this",
"->",
"middlewares",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"namespace",
",",
"]",
",",
"$",
"merge",
")",
";",
"}"
] |
Get route attributes.
@param array $merge
@return array
|
[
"Get",
"route",
"attributes",
"."
] |
92f4da1b0d47b769af3c65cd1d672b68809262c8
|
https://github.com/Xannn94/support/blob/92f4da1b0d47b769af3c65cd1d672b68809262c8/src/Bases/RouteRegister.php#L182-L190
|
238,879
|
Xannn94/support
|
src/Bases/RouteRegister.php
|
RouteRegister.loadAttributes
|
protected function loadAttributes($key, array $default = [])
{
$attributes = config($key, $default);
if (isset($attributes['prefix']))
$this->addPrefix($attributes['prefix']);
if (isset($attributes['namespace']))
$this->setNamespace($attributes['namespace']);
if (isset($attributes['as']))
$this->setRouteName($attributes['as']);
if (isset($attributes['middleware']))
$this->setMiddlewares($attributes['middleware']);
}
|
php
|
protected function loadAttributes($key, array $default = [])
{
$attributes = config($key, $default);
if (isset($attributes['prefix']))
$this->addPrefix($attributes['prefix']);
if (isset($attributes['namespace']))
$this->setNamespace($attributes['namespace']);
if (isset($attributes['as']))
$this->setRouteName($attributes['as']);
if (isset($attributes['middleware']))
$this->setMiddlewares($attributes['middleware']);
}
|
[
"protected",
"function",
"loadAttributes",
"(",
"$",
"key",
",",
"array",
"$",
"default",
"=",
"[",
"]",
")",
"{",
"$",
"attributes",
"=",
"config",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'prefix'",
"]",
")",
")",
"$",
"this",
"->",
"addPrefix",
"(",
"$",
"attributes",
"[",
"'prefix'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'namespace'",
"]",
")",
")",
"$",
"this",
"->",
"setNamespace",
"(",
"$",
"attributes",
"[",
"'namespace'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'as'",
"]",
")",
")",
"$",
"this",
"->",
"setRouteName",
"(",
"$",
"attributes",
"[",
"'as'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'middleware'",
"]",
")",
")",
"$",
"this",
"->",
"setMiddlewares",
"(",
"$",
"attributes",
"[",
"'middleware'",
"]",
")",
";",
"}"
] |
Load attributes from config file.
@param string $key
@param array $default
|
[
"Load",
"attributes",
"from",
"config",
"file",
"."
] |
92f4da1b0d47b769af3c65cd1d672b68809262c8
|
https://github.com/Xannn94/support/blob/92f4da1b0d47b769af3c65cd1d672b68809262c8/src/Bases/RouteRegister.php#L223-L238
|
238,880
|
docit/core
|
src/Http/Controllers/DocitController.php
|
DocitController.document
|
public function document($projectSlug, $ref = null, $path = '')
{
$project = $this->factory->getProject($projectSlug);
if (is_null($ref)) {
$ref = $project->getDefaultRef();
}
$project->setRef($ref);
$document = $project->getDocument($path);
$content = $document->render();
$breadcrumb = $document->getBreadcrumb();
$this->view->composer($document->attr('view'), $this->factory->config('projects_menus_view_composer'));
return $this->view->make($document->attr('view'), compact('project', 'document', 'content', 'breadcrumb'));
}
|
php
|
public function document($projectSlug, $ref = null, $path = '')
{
$project = $this->factory->getProject($projectSlug);
if (is_null($ref)) {
$ref = $project->getDefaultRef();
}
$project->setRef($ref);
$document = $project->getDocument($path);
$content = $document->render();
$breadcrumb = $document->getBreadcrumb();
$this->view->composer($document->attr('view'), $this->factory->config('projects_menus_view_composer'));
return $this->view->make($document->attr('view'), compact('project', 'document', 'content', 'breadcrumb'));
}
|
[
"public",
"function",
"document",
"(",
"$",
"projectSlug",
",",
"$",
"ref",
"=",
"null",
",",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"project",
"=",
"$",
"this",
"->",
"factory",
"->",
"getProject",
"(",
"$",
"projectSlug",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"ref",
")",
")",
"{",
"$",
"ref",
"=",
"$",
"project",
"->",
"getDefaultRef",
"(",
")",
";",
"}",
"$",
"project",
"->",
"setRef",
"(",
"$",
"ref",
")",
";",
"$",
"document",
"=",
"$",
"project",
"->",
"getDocument",
"(",
"$",
"path",
")",
";",
"$",
"content",
"=",
"$",
"document",
"->",
"render",
"(",
")",
";",
"$",
"breadcrumb",
"=",
"$",
"document",
"->",
"getBreadcrumb",
"(",
")",
";",
"$",
"this",
"->",
"view",
"->",
"composer",
"(",
"$",
"document",
"->",
"attr",
"(",
"'view'",
")",
",",
"$",
"this",
"->",
"factory",
"->",
"config",
"(",
"'projects_menus_view_composer'",
")",
")",
";",
"return",
"$",
"this",
"->",
"view",
"->",
"make",
"(",
"$",
"document",
"->",
"attr",
"(",
"'view'",
")",
",",
"compact",
"(",
"'project'",
",",
"'document'",
",",
"'content'",
",",
"'breadcrumb'",
")",
")",
";",
"}"
] |
Render the documentation page for the given project and version.
@param string $projectSlug
@param string|null $ref
@param string $path
@return $this
|
[
"Render",
"the",
"documentation",
"page",
"for",
"the",
"given",
"project",
"and",
"version",
"."
] |
448e1cdca18a8ffb6c08430cad8d22162171ac35
|
https://github.com/docit/core/blob/448e1cdca18a8ffb6c08430cad8d22162171ac35/src/Http/Controllers/DocitController.php#L34-L51
|
238,881
|
easy-system/es-http
|
src/Factory/InputFactory.php
|
InputFactory.setSource
|
public static function setSource($source = null)
{
if (! is_resource($source) && ! is_null($source)) {
throw new InvalidArgumentException(sprintf(
'Invalid source provided; must be a null or an resource, "%s" given.',
is_object($source) ? get_class($source) : gettype($source)
));
}
static::$source = $source;
}
|
php
|
public static function setSource($source = null)
{
if (! is_resource($source) && ! is_null($source)) {
throw new InvalidArgumentException(sprintf(
'Invalid source provided; must be a null or an resource, "%s" given.',
is_object($source) ? get_class($source) : gettype($source)
));
}
static::$source = $source;
}
|
[
"public",
"static",
"function",
"setSource",
"(",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"source",
")",
"&&",
"!",
"is_null",
"(",
"$",
"source",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid source provided; must be a null or an resource, \"%s\" given.'",
",",
"is_object",
"(",
"$",
"source",
")",
"?",
"get_class",
"(",
"$",
"source",
")",
":",
"gettype",
"(",
"$",
"source",
")",
")",
")",
";",
"}",
"static",
"::",
"$",
"source",
"=",
"$",
"source",
";",
"}"
] |
Sets data source.
@param null|resource $source
@throws \InvalidArgumentException If invalid source provided
|
[
"Sets",
"data",
"source",
"."
] |
dd5852e94901e147a7546a8715133408ece767a1
|
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/InputFactory.php#L34-L43
|
238,882
|
easy-system/es-http
|
src/Factory/InputFactory.php
|
InputFactory.make
|
public static function make()
{
$stream = new Stream();
$source = static::getSource();
$stream->copy($source);
if (! static::$source) {
fclose($source);
}
return $stream;
}
|
php
|
public static function make()
{
$stream = new Stream();
$source = static::getSource();
$stream->copy($source);
if (! static::$source) {
fclose($source);
}
return $stream;
}
|
[
"public",
"static",
"function",
"make",
"(",
")",
"{",
"$",
"stream",
"=",
"new",
"Stream",
"(",
")",
";",
"$",
"source",
"=",
"static",
"::",
"getSource",
"(",
")",
";",
"$",
"stream",
"->",
"copy",
"(",
"$",
"source",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"source",
")",
"{",
"fclose",
"(",
"$",
"source",
")",
";",
"}",
"return",
"$",
"stream",
";",
"}"
] |
Makes a stream and and fills it with input data.
@return \Es\Http\Stream The stream
|
[
"Makes",
"a",
"stream",
"and",
"and",
"fills",
"it",
"with",
"input",
"data",
"."
] |
dd5852e94901e147a7546a8715133408ece767a1
|
https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Factory/InputFactory.php#L65-L76
|
238,883
|
magdev/php-assimp
|
src/Command/Result.php
|
Result.getOutput
|
public function getOutput(string $glue = null)
{
if (!is_null($glue)) {
return implode($glue, $this->output);
}
return $this->output;
}
|
php
|
public function getOutput(string $glue = null)
{
if (!is_null($glue)) {
return implode($glue, $this->output);
}
return $this->output;
}
|
[
"public",
"function",
"getOutput",
"(",
"string",
"$",
"glue",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"glue",
")",
")",
"{",
"return",
"implode",
"(",
"$",
"glue",
",",
"$",
"this",
"->",
"output",
")",
";",
"}",
"return",
"$",
"this",
"->",
"output",
";",
"}"
] |
Get the full output array
@param string|null $glue
@return string|array
|
[
"Get",
"the",
"full",
"output",
"array"
] |
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
|
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Result.php#L171-L177
|
238,884
|
magdev/php-assimp
|
src/Command/Result.php
|
Result.getOutputLine
|
public function getOutputLine(int $line): string
{
return array_key_exists($line, $this->output) ? $this->output[$line] : null;
}
|
php
|
public function getOutputLine(int $line): string
{
return array_key_exists($line, $this->output) ? $this->output[$line] : null;
}
|
[
"public",
"function",
"getOutputLine",
"(",
"int",
"$",
"line",
")",
":",
"string",
"{",
"return",
"array_key_exists",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"output",
")",
"?",
"$",
"this",
"->",
"output",
"[",
"$",
"line",
"]",
":",
"null",
";",
"}"
] |
Get a specific line from the output array
@param int $line
@return string|null
|
[
"Get",
"a",
"specific",
"line",
"from",
"the",
"output",
"array"
] |
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
|
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Result.php#L186-L189
|
238,885
|
magdev/php-assimp
|
src/Command/Result.php
|
Result.setParsed
|
public function setParsed(bool $parsed = true): Result
{
$this->parsed = (boolean) $parsed;
return $this;
}
|
php
|
public function setParsed(bool $parsed = true): Result
{
$this->parsed = (boolean) $parsed;
return $this;
}
|
[
"public",
"function",
"setParsed",
"(",
"bool",
"$",
"parsed",
"=",
"true",
")",
":",
"Result",
"{",
"$",
"this",
"->",
"parsed",
"=",
"(",
"boolean",
")",
"$",
"parsed",
";",
"return",
"$",
"this",
";",
"}"
] |
Mark the output as parsed
@param boolean $parsed
@return \Assimp\Command\Result
|
[
"Mark",
"the",
"output",
"as",
"parsed"
] |
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
|
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Result.php#L271-L275
|
238,886
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/request.php
|
Request.forge
|
public static function forge($uri = null, $options = true, $method = null)
{
is_bool($options) and $options = array('route' => $options);
is_string($options) and $options = array('driver' => $options);
if ( ! empty($options['driver']))
{
$class = \Inflector::words_to_upper('Request_'.$options['driver']);
return $class::forge($uri, $options, $method);
}
$request = new static($uri, isset($options['route']) ? $options['route'] : true, $method);
if (static::$active)
{
$request->parent = static::$active;
static::$active->children[] = $request;
}
// fire any request created events
\Event::instance()->has_events('request_created') and \Event::instance()->trigger('request_created', '', 'none');
return $request;
}
|
php
|
public static function forge($uri = null, $options = true, $method = null)
{
is_bool($options) and $options = array('route' => $options);
is_string($options) and $options = array('driver' => $options);
if ( ! empty($options['driver']))
{
$class = \Inflector::words_to_upper('Request_'.$options['driver']);
return $class::forge($uri, $options, $method);
}
$request = new static($uri, isset($options['route']) ? $options['route'] : true, $method);
if (static::$active)
{
$request->parent = static::$active;
static::$active->children[] = $request;
}
// fire any request created events
\Event::instance()->has_events('request_created') and \Event::instance()->trigger('request_created', '', 'none');
return $request;
}
|
[
"public",
"static",
"function",
"forge",
"(",
"$",
"uri",
"=",
"null",
",",
"$",
"options",
"=",
"true",
",",
"$",
"method",
"=",
"null",
")",
"{",
"is_bool",
"(",
"$",
"options",
")",
"and",
"$",
"options",
"=",
"array",
"(",
"'route'",
"=>",
"$",
"options",
")",
";",
"is_string",
"(",
"$",
"options",
")",
"and",
"$",
"options",
"=",
"array",
"(",
"'driver'",
"=>",
"$",
"options",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'driver'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"\\",
"Inflector",
"::",
"words_to_upper",
"(",
"'Request_'",
".",
"$",
"options",
"[",
"'driver'",
"]",
")",
";",
"return",
"$",
"class",
"::",
"forge",
"(",
"$",
"uri",
",",
"$",
"options",
",",
"$",
"method",
")",
";",
"}",
"$",
"request",
"=",
"new",
"static",
"(",
"$",
"uri",
",",
"isset",
"(",
"$",
"options",
"[",
"'route'",
"]",
")",
"?",
"$",
"options",
"[",
"'route'",
"]",
":",
"true",
",",
"$",
"method",
")",
";",
"if",
"(",
"static",
"::",
"$",
"active",
")",
"{",
"$",
"request",
"->",
"parent",
"=",
"static",
"::",
"$",
"active",
";",
"static",
"::",
"$",
"active",
"->",
"children",
"[",
"]",
"=",
"$",
"request",
";",
"}",
"// fire any request created events",
"\\",
"Event",
"::",
"instance",
"(",
")",
"->",
"has_events",
"(",
"'request_created'",
")",
"and",
"\\",
"Event",
"::",
"instance",
"(",
")",
"->",
"trigger",
"(",
"'request_created'",
",",
"''",
",",
"'none'",
")",
";",
"return",
"$",
"request",
";",
"}"
] |
Generates a new request. The request is then set to be the active
request. If this is the first request, then save that as the main
request for the app.
Usage:
Request::forge('hello/world');
@param string The URI of the request
@param mixed Internal: whether to use the routes; external: driver type or array with settings (driver key must be set)
@param string request method
@return Request The new request object
|
[
"Generates",
"a",
"new",
"request",
".",
"The",
"request",
"is",
"then",
"set",
"to",
"be",
"the",
"active",
"request",
".",
"If",
"this",
"is",
"the",
"first",
"request",
"then",
"save",
"that",
"as",
"the",
"main",
"request",
"for",
"the",
"app",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L59-L81
|
238,887
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/request.php
|
Request.reset_request
|
public static function reset_request($full = false)
{
// Let's make the previous Request active since we are done executing this one.
static::$active and static::$active = static::$active->parent();
if ($full)
{
static::$main = null;
}
}
|
php
|
public static function reset_request($full = false)
{
// Let's make the previous Request active since we are done executing this one.
static::$active and static::$active = static::$active->parent();
if ($full)
{
static::$main = null;
}
}
|
[
"public",
"static",
"function",
"reset_request",
"(",
"$",
"full",
"=",
"false",
")",
"{",
"// Let's make the previous Request active since we are done executing this one.",
"static",
"::",
"$",
"active",
"and",
"static",
"::",
"$",
"active",
"=",
"static",
"::",
"$",
"active",
"->",
"parent",
"(",
")",
";",
"if",
"(",
"$",
"full",
")",
"{",
"static",
"::",
"$",
"main",
"=",
"null",
";",
"}",
"}"
] |
Reset's the active request with the previous one. This is needed after
the active request is finished.
Usage:
Request::reset_request();
@return void
|
[
"Reset",
"s",
"the",
"active",
"request",
"with",
"the",
"previous",
"one",
".",
"This",
"is",
"needed",
"after",
"the",
"active",
"request",
"is",
"finished",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L146-L155
|
238,888
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/core/classes/request.php
|
Request.param
|
public function param($param, $default = null)
{
if ( ! isset($this->named_params[$param]))
{
return \Fuel::value($default);
}
return $this->named_params[$param];
}
|
php
|
public function param($param, $default = null)
{
if ( ! isset($this->named_params[$param]))
{
return \Fuel::value($default);
}
return $this->named_params[$param];
}
|
[
"public",
"function",
"param",
"(",
"$",
"param",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"named_params",
"[",
"$",
"param",
"]",
")",
")",
"{",
"return",
"\\",
"Fuel",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}",
"return",
"$",
"this",
"->",
"named_params",
"[",
"$",
"param",
"]",
";",
"}"
] |
Gets a specific named parameter
@param string $param Name of the parameter
@param mixed $default Default value
@return mixed
|
[
"Gets",
"a",
"specific",
"named",
"parameter"
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/request.php#L587-L595
|
238,889
|
canis-io/yii2-canis-lib
|
lib/web/grid/Cell.php
|
Cell.getClasses
|
public function getClasses()
{
$classes = [];
$sizes = $this->sizes;
if (isset($sizes['phone'])) {
$classes[] = 'col-xs-' . $sizes['phone'];
}
if (isset($sizes['tablet'])) {
$classes[] = 'col-sm-' . $sizes['tablet'];
}
if (isset($sizes['mediumDesktop'])) {
$classes[] = 'col-md-' . $sizes['mediumDesktop'];
}
if (isset($sizes['largeDesktop'])) {
$classes[] = 'col-lg-' . $sizes['largeDesktop'];
}
return implode(' ', $classes);
}
|
php
|
public function getClasses()
{
$classes = [];
$sizes = $this->sizes;
if (isset($sizes['phone'])) {
$classes[] = 'col-xs-' . $sizes['phone'];
}
if (isset($sizes['tablet'])) {
$classes[] = 'col-sm-' . $sizes['tablet'];
}
if (isset($sizes['mediumDesktop'])) {
$classes[] = 'col-md-' . $sizes['mediumDesktop'];
}
if (isset($sizes['largeDesktop'])) {
$classes[] = 'col-lg-' . $sizes['largeDesktop'];
}
return implode(' ', $classes);
}
|
[
"public",
"function",
"getClasses",
"(",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"sizes",
"=",
"$",
"this",
"->",
"sizes",
";",
"if",
"(",
"isset",
"(",
"$",
"sizes",
"[",
"'phone'",
"]",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'col-xs-'",
".",
"$",
"sizes",
"[",
"'phone'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"sizes",
"[",
"'tablet'",
"]",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'col-sm-'",
".",
"$",
"sizes",
"[",
"'tablet'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"sizes",
"[",
"'mediumDesktop'",
"]",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'col-md-'",
".",
"$",
"sizes",
"[",
"'mediumDesktop'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"sizes",
"[",
"'largeDesktop'",
"]",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'col-lg-'",
".",
"$",
"sizes",
"[",
"'largeDesktop'",
"]",
";",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}"
] |
Get classes.
@return [[@doctodo return_type:getClasses]] [[@doctodo return_description:getClasses]]
|
[
"Get",
"classes",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L203-L221
|
238,890
|
canis-io/yii2-canis-lib
|
lib/web/grid/Cell.php
|
Cell.getSizes
|
public function getSizes()
{
$sizes = [];
if ($this->phoneSize === 'auto') {
$sizes['phone'] = $this->generatePhoneSize();
} elseif ($this->phoneSize === true && $this->hasPhoneColumns) {
$sizes['phone'] = $this->phoneColumns;
}
if ($this->tabletSize === 'auto') {
$sizes['tablet'] = $this->generateTabletSize();
} elseif ($this->tabletSize === true && $this->hasTabletColumns) {
$sizes['tablet'] = $this->tabletColumns;
}
if ($this->mediumDesktopSize === 'auto') {
$sizes['mediumDesktop'] = $this->generateMediumDesktopSize();
} elseif ($this->mediumDesktopSize === true && $this->hasMediumDesktopColumns) {
$sizes['mediumDesktop'] = $this->mediumDesktopColumns;
}
if ($this->largeDesktopSize === 'auto') {
$sizes['largeDesktop'] = $this->generateLargeDesktopSize();
} elseif ($this->largeDesktopSize === true && $this->hasLargeDesktopColumns) {
$sizes['largeDesktop'] = $this->largeDesktopColumns;
}
return $sizes;
}
|
php
|
public function getSizes()
{
$sizes = [];
if ($this->phoneSize === 'auto') {
$sizes['phone'] = $this->generatePhoneSize();
} elseif ($this->phoneSize === true && $this->hasPhoneColumns) {
$sizes['phone'] = $this->phoneColumns;
}
if ($this->tabletSize === 'auto') {
$sizes['tablet'] = $this->generateTabletSize();
} elseif ($this->tabletSize === true && $this->hasTabletColumns) {
$sizes['tablet'] = $this->tabletColumns;
}
if ($this->mediumDesktopSize === 'auto') {
$sizes['mediumDesktop'] = $this->generateMediumDesktopSize();
} elseif ($this->mediumDesktopSize === true && $this->hasMediumDesktopColumns) {
$sizes['mediumDesktop'] = $this->mediumDesktopColumns;
}
if ($this->largeDesktopSize === 'auto') {
$sizes['largeDesktop'] = $this->generateLargeDesktopSize();
} elseif ($this->largeDesktopSize === true && $this->hasLargeDesktopColumns) {
$sizes['largeDesktop'] = $this->largeDesktopColumns;
}
return $sizes;
}
|
[
"public",
"function",
"getSizes",
"(",
")",
"{",
"$",
"sizes",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"phoneSize",
"===",
"'auto'",
")",
"{",
"$",
"sizes",
"[",
"'phone'",
"]",
"=",
"$",
"this",
"->",
"generatePhoneSize",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"phoneSize",
"===",
"true",
"&&",
"$",
"this",
"->",
"hasPhoneColumns",
")",
"{",
"$",
"sizes",
"[",
"'phone'",
"]",
"=",
"$",
"this",
"->",
"phoneColumns",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tabletSize",
"===",
"'auto'",
")",
"{",
"$",
"sizes",
"[",
"'tablet'",
"]",
"=",
"$",
"this",
"->",
"generateTabletSize",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"tabletSize",
"===",
"true",
"&&",
"$",
"this",
"->",
"hasTabletColumns",
")",
"{",
"$",
"sizes",
"[",
"'tablet'",
"]",
"=",
"$",
"this",
"->",
"tabletColumns",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"mediumDesktopSize",
"===",
"'auto'",
")",
"{",
"$",
"sizes",
"[",
"'mediumDesktop'",
"]",
"=",
"$",
"this",
"->",
"generateMediumDesktopSize",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"mediumDesktopSize",
"===",
"true",
"&&",
"$",
"this",
"->",
"hasMediumDesktopColumns",
")",
"{",
"$",
"sizes",
"[",
"'mediumDesktop'",
"]",
"=",
"$",
"this",
"->",
"mediumDesktopColumns",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"largeDesktopSize",
"===",
"'auto'",
")",
"{",
"$",
"sizes",
"[",
"'largeDesktop'",
"]",
"=",
"$",
"this",
"->",
"generateLargeDesktopSize",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"largeDesktopSize",
"===",
"true",
"&&",
"$",
"this",
"->",
"hasLargeDesktopColumns",
")",
"{",
"$",
"sizes",
"[",
"'largeDesktop'",
"]",
"=",
"$",
"this",
"->",
"largeDesktopColumns",
";",
"}",
"return",
"$",
"sizes",
";",
"}"
] |
Get sizes.
@return [[@doctodo return_type:getSizes]] [[@doctodo return_description:getSizes]]
|
[
"Get",
"sizes",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L228-L253
|
238,891
|
canis-io/yii2-canis-lib
|
lib/web/grid/Cell.php
|
Cell.getMaxColumns
|
public function getMaxColumns($size = null)
{
if (is_object($this->content) && property_exists($this->content, 'maxColumns') && !is_null($this->content->maxColumns)) {
return $this->content->maxColumns;
}
if (is_null($size)) {
$size = $this->baseSize;
}
$columnAttribute = 'max' . ucfirst($size) . 'Columns';
return $this->{$columnAttribute};
}
|
php
|
public function getMaxColumns($size = null)
{
if (is_object($this->content) && property_exists($this->content, 'maxColumns') && !is_null($this->content->maxColumns)) {
return $this->content->maxColumns;
}
if (is_null($size)) {
$size = $this->baseSize;
}
$columnAttribute = 'max' . ucfirst($size) . 'Columns';
return $this->{$columnAttribute};
}
|
[
"public",
"function",
"getMaxColumns",
"(",
"$",
"size",
"=",
"null",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"content",
")",
"&&",
"property_exists",
"(",
"$",
"this",
"->",
"content",
",",
"'maxColumns'",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"content",
"->",
"maxColumns",
")",
")",
"{",
"return",
"$",
"this",
"->",
"content",
"->",
"maxColumns",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"size",
")",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"baseSize",
";",
"}",
"$",
"columnAttribute",
"=",
"'max'",
".",
"ucfirst",
"(",
"$",
"size",
")",
".",
"'Columns'",
";",
"return",
"$",
"this",
"->",
"{",
"$",
"columnAttribute",
"}",
";",
"}"
] |
Get max columns.
@param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional]
@return [[@doctodo return_type:getMaxColumns]] [[@doctodo return_description:getMaxColumns]]
|
[
"Get",
"max",
"columns",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L318-L329
|
238,892
|
canis-io/yii2-canis-lib
|
lib/web/grid/Cell.php
|
Cell.setMaxColumns
|
public function setMaxColumns($columns, $size = null)
{
if (is_null($size)) {
$size = $this->baseSize;
}
$columnAttribute = 'max' . ucfirst($size) . 'Columns';
$this->{$columnAttribute} = $columns;
}
|
php
|
public function setMaxColumns($columns, $size = null)
{
if (is_null($size)) {
$size = $this->baseSize;
}
$columnAttribute = 'max' . ucfirst($size) . 'Columns';
$this->{$columnAttribute} = $columns;
}
|
[
"public",
"function",
"setMaxColumns",
"(",
"$",
"columns",
",",
"$",
"size",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"size",
")",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"baseSize",
";",
"}",
"$",
"columnAttribute",
"=",
"'max'",
".",
"ucfirst",
"(",
"$",
"size",
")",
".",
"'Columns'",
";",
"$",
"this",
"->",
"{",
"$",
"columnAttribute",
"}",
"=",
"$",
"columns",
";",
"}"
] |
Set max columns.
@param [[@doctodo param_type:columns]] $columns [[@doctodo param_description:columns]]
@param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional]
|
[
"Set",
"max",
"columns",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L337-L344
|
238,893
|
canis-io/yii2-canis-lib
|
lib/web/grid/Cell.php
|
Cell.getFlex
|
public function getFlex($size = null)
{
if (is_null($size)) {
$size = $this->baseSize;
}
$getter = $size . 'Columns';
$flex = $this->getMaxColumns($size) - $this->{$getter};
if ($flex < 0) {
return 0;
}
return $flex;
}
|
php
|
public function getFlex($size = null)
{
if (is_null($size)) {
$size = $this->baseSize;
}
$getter = $size . 'Columns';
$flex = $this->getMaxColumns($size) - $this->{$getter};
if ($flex < 0) {
return 0;
}
return $flex;
}
|
[
"public",
"function",
"getFlex",
"(",
"$",
"size",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"size",
")",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"baseSize",
";",
"}",
"$",
"getter",
"=",
"$",
"size",
".",
"'Columns'",
";",
"$",
"flex",
"=",
"$",
"this",
"->",
"getMaxColumns",
"(",
"$",
"size",
")",
"-",
"$",
"this",
"->",
"{",
"$",
"getter",
"}",
";",
"if",
"(",
"$",
"flex",
"<",
"0",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"flex",
";",
"}"
] |
Get flex.
@param [[@doctodo param_type:size]] $size [[@doctodo param_description:size]] [optional]
@return [[@doctodo return_type:getFlex]] [[@doctodo return_description:getFlex]]
|
[
"Get",
"flex",
"."
] |
97d533521f65b084dc805c5f312c364b469142d2
|
https://github.com/canis-io/yii2-canis-lib/blob/97d533521f65b084dc805c5f312c364b469142d2/lib/web/grid/Cell.php#L625-L637
|
238,894
|
vinala/kernel
|
src/Html/Html.php
|
Html.open
|
public static function open($tag, array $options = [], $self = false)
{
$attributes = self::attributes($options);
//add the opened tag to $opened array
if (!$self || is_null($self)) {
self::$opened[] = $tag;
//
return '<'.$tag.$attributes.'>';
} else {
return '<'.$tag.$attributes.' />';
}
}
|
php
|
public static function open($tag, array $options = [], $self = false)
{
$attributes = self::attributes($options);
//add the opened tag to $opened array
if (!$self || is_null($self)) {
self::$opened[] = $tag;
//
return '<'.$tag.$attributes.'>';
} else {
return '<'.$tag.$attributes.' />';
}
}
|
[
"public",
"static",
"function",
"open",
"(",
"$",
"tag",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"self",
"=",
"false",
")",
"{",
"$",
"attributes",
"=",
"self",
"::",
"attributes",
"(",
"$",
"options",
")",
";",
"//add the opened tag to $opened array",
"if",
"(",
"!",
"$",
"self",
"||",
"is_null",
"(",
"$",
"self",
")",
")",
"{",
"self",
"::",
"$",
"opened",
"[",
"]",
"=",
"$",
"tag",
";",
"//",
"return",
"'<'",
".",
"$",
"tag",
".",
"$",
"attributes",
".",
"'>'",
";",
"}",
"else",
"{",
"return",
"'<'",
".",
"$",
"tag",
".",
"$",
"attributes",
".",
"' />'",
";",
"}",
"}"
] |
open html tag.
@param string $tag
@param array $options
@return string
|
[
"open",
"html",
"tag",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L25-L37
|
238,895
|
vinala/kernel
|
src/Html/Html.php
|
Html.close
|
public static function close()
{
//get the last opened tag
$tag = self::$opened[count(self::$opened) - 1];
//remove the last opened tag
array_pop(self::$opened);
return '</'.$tag.'>';
}
|
php
|
public static function close()
{
//get the last opened tag
$tag = self::$opened[count(self::$opened) - 1];
//remove the last opened tag
array_pop(self::$opened);
return '</'.$tag.'>';
}
|
[
"public",
"static",
"function",
"close",
"(",
")",
"{",
"//get the last opened tag",
"$",
"tag",
"=",
"self",
"::",
"$",
"opened",
"[",
"count",
"(",
"self",
"::",
"$",
"opened",
")",
"-",
"1",
"]",
";",
"//remove the last opened tag",
"array_pop",
"(",
"self",
"::",
"$",
"opened",
")",
";",
"return",
"'</'",
".",
"$",
"tag",
".",
"'>'",
";",
"}"
] |
close the last open html tag.
@return string
|
[
"close",
"the",
"last",
"open",
"html",
"tag",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L44-L53
|
238,896
|
vinala/kernel
|
src/Html/Html.php
|
Html.title
|
public static function title($title = null)
{
if (is_null($title)) {
$title = config('app.title');
}
$tag = static::open('title');
$tag .= $title;
$tag .= static::close();
return $tag;
}
|
php
|
public static function title($title = null)
{
if (is_null($title)) {
$title = config('app.title');
}
$tag = static::open('title');
$tag .= $title;
$tag .= static::close();
return $tag;
}
|
[
"public",
"static",
"function",
"title",
"(",
"$",
"title",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",
"=",
"config",
"(",
"'app.title'",
")",
";",
"}",
"$",
"tag",
"=",
"static",
"::",
"open",
"(",
"'title'",
")",
";",
"$",
"tag",
".=",
"$",
"title",
";",
"$",
"tag",
".=",
"static",
"::",
"close",
"(",
")",
";",
"return",
"$",
"tag",
";",
"}"
] |
The HTML title tag.
@param string $title
@return string
|
[
"The",
"HTML",
"title",
"tag",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Html/Html.php#L132-L143
|
238,897
|
AlcyZ/Alcys-ORM
|
src/Core/Db/QueryBuilder/MySql/InsertBuilder.php
|
InsertBuilder._prepareColumns
|
private function _prepareColumns(array $columnArray)
{
if(count($columnArray) === 0)
{
throw new \Exception('The column method of the statement must called before!');
}
foreach($columnArray as $column)
{
$this->columns .= $column->getColumnName() . ', ';
}
$this->columns = rtrim($this->columns);
$this->columns = rtrim($this->columns, ',');
return $this;
}
|
php
|
private function _prepareColumns(array $columnArray)
{
if(count($columnArray) === 0)
{
throw new \Exception('The column method of the statement must called before!');
}
foreach($columnArray as $column)
{
$this->columns .= $column->getColumnName() . ', ';
}
$this->columns = rtrim($this->columns);
$this->columns = rtrim($this->columns, ',');
return $this;
}
|
[
"private",
"function",
"_prepareColumns",
"(",
"array",
"$",
"columnArray",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"columnArray",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The column method of the statement must called before!'",
")",
";",
"}",
"foreach",
"(",
"$",
"columnArray",
"as",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"columns",
".=",
"$",
"column",
"->",
"getColumnName",
"(",
")",
".",
"', '",
";",
"}",
"$",
"this",
"->",
"columns",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"columns",
")",
";",
"$",
"this",
"->",
"columns",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"columns",
",",
"','",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Validate and prepare the columns property to set it to the query.
@param ColumnInterface[] $columnArray An array with ColumnInterface objects as elements.
@return $this The same instance to concatenate methods.
@throws \Exception When column method of statement was not invoked.
|
[
"Validate",
"and",
"prepare",
"the",
"columns",
"property",
"to",
"set",
"it",
"to",
"the",
"query",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/QueryBuilder/MySql/InsertBuilder.php#L96-L110
|
238,898
|
AlcyZ/Alcys-ORM
|
src/Core/Db/QueryBuilder/MySql/InsertBuilder.php
|
InsertBuilder._prepareValues
|
private function _prepareValues(array $valueArrays)
{
if(count($valueArrays) === 0)
{
throw new \Exception('The value method of the statement must called before!');
}
foreach($valueArrays as $valueArray)
{
$valueString = '(';
foreach($valueArray as $value)
{
$valueString .= $value->getValue() . ', ';
}
$valueString = rtrim($valueString);
$valueString = rtrim($valueString, ',') . ')';
$this->values .= $valueString . ', ';
}
$this->values = rtrim($this->values);
$this->values = rtrim($this->values, ',');
return $this;
}
|
php
|
private function _prepareValues(array $valueArrays)
{
if(count($valueArrays) === 0)
{
throw new \Exception('The value method of the statement must called before!');
}
foreach($valueArrays as $valueArray)
{
$valueString = '(';
foreach($valueArray as $value)
{
$valueString .= $value->getValue() . ', ';
}
$valueString = rtrim($valueString);
$valueString = rtrim($valueString, ',') . ')';
$this->values .= $valueString . ', ';
}
$this->values = rtrim($this->values);
$this->values = rtrim($this->values, ',');
return $this;
}
|
[
"private",
"function",
"_prepareValues",
"(",
"array",
"$",
"valueArrays",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"valueArrays",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The value method of the statement must called before!'",
")",
";",
"}",
"foreach",
"(",
"$",
"valueArrays",
"as",
"$",
"valueArray",
")",
"{",
"$",
"valueString",
"=",
"'('",
";",
"foreach",
"(",
"$",
"valueArray",
"as",
"$",
"value",
")",
"{",
"$",
"valueString",
".=",
"$",
"value",
"->",
"getValue",
"(",
")",
".",
"', '",
";",
"}",
"$",
"valueString",
"=",
"rtrim",
"(",
"$",
"valueString",
")",
";",
"$",
"valueString",
"=",
"rtrim",
"(",
"$",
"valueString",
",",
"','",
")",
".",
"')'",
";",
"$",
"this",
"->",
"values",
".=",
"$",
"valueString",
".",
"', '",
";",
"}",
"$",
"this",
"->",
"values",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"values",
")",
";",
"$",
"this",
"->",
"values",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"values",
",",
"','",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Validate and prepare the values property to set it to the query.
@param ReferencesInterface[][] $valueArrays An array with arrays that contain ReferenceInterface objects.
@return $this The same instance to concatenate methods.
@throws \Exception When statements values method was not called.
|
[
"Validate",
"and",
"prepare",
"the",
"values",
"property",
"to",
"set",
"it",
"to",
"the",
"query",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/QueryBuilder/MySql/InsertBuilder.php#L121-L142
|
238,899
|
wucdbm/menu-builder-bundle
|
Composer/ScriptHandler.php
|
ScriptHandler.importRoutes
|
public static function importRoutes(Event $event) {
$options = self::getOptions($event);
$appDir = $options['symfony-app-dir'];
$webDir = $options['symfony-web-dir'];
if (!is_dir($webDir)) {
echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;
return;
}
static::executeCommand($event, $appDir, 'wucdbm_menu_builder:import_routes');
}
|
php
|
public static function importRoutes(Event $event) {
$options = self::getOptions($event);
$appDir = $options['symfony-app-dir'];
$webDir = $options['symfony-web-dir'];
if (!is_dir($webDir)) {
echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;
return;
}
static::executeCommand($event, $appDir, 'wucdbm_menu_builder:import_routes');
}
|
[
"public",
"static",
"function",
"importRoutes",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"options",
"=",
"self",
"::",
"getOptions",
"(",
"$",
"event",
")",
";",
"$",
"appDir",
"=",
"$",
"options",
"[",
"'symfony-app-dir'",
"]",
";",
"$",
"webDir",
"=",
"$",
"options",
"[",
"'symfony-web-dir'",
"]",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"webDir",
")",
")",
"{",
"echo",
"'The symfony-web-dir ('",
".",
"$",
"webDir",
".",
"') specified in composer.json was not found in '",
".",
"getcwd",
"(",
")",
".",
"', can not install assets.'",
".",
"PHP_EOL",
";",
"return",
";",
"}",
"static",
"::",
"executeCommand",
"(",
"$",
"event",
",",
"$",
"appDir",
",",
"'wucdbm_menu_builder:import_routes'",
")",
";",
"}"
] |
Imports routes into the database.
@param $event Event A instance
|
[
"Imports",
"routes",
"into",
"the",
"database",
"."
] |
85bbb0760701eda4eb7c624f743abcc63a320168
|
https://github.com/wucdbm/menu-builder-bundle/blob/85bbb0760701eda4eb7c624f743abcc63a320168/Composer/ScriptHandler.php#L30-L42
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.