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
|
---|---|---|---|---|---|---|---|---|---|---|---|
14,400 | cornernote/yii-return-url | return-url/components/EReturnUrl.php | EReturnUrl.getFormValue | public function getFormValue($currentPage = false, $encode = false)
{
if ($currentPage)
$url = $encode ? $this->urlEncode(Yii::app()->getRequest()->getUrl()) : Yii::app()->getRequest()->getUrl();
else
$url = $this->getUrlFromSubmitFields();
return $url;
} | php | public function getFormValue($currentPage = false, $encode = false)
{
if ($currentPage)
$url = $encode ? $this->urlEncode(Yii::app()->getRequest()->getUrl()) : Yii::app()->getRequest()->getUrl();
else
$url = $this->getUrlFromSubmitFields();
return $url;
} | [
"public",
"function",
"getFormValue",
"(",
"$",
"currentPage",
"=",
"false",
",",
"$",
"encode",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"currentPage",
")",
"$",
"url",
"=",
"$",
"encode",
"?",
"$",
"this",
"->",
"urlEncode",
"(",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getUrl",
"(",
")",
")",
":",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
"->",
"getUrl",
"(",
")",
";",
"else",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrlFromSubmitFields",
"(",
")",
";",
"return",
"$",
"url",
";",
"}"
]
| Get url from submitted data or the current page url
for usage in a hidden form element
@usage
in views/your_page.php
<pre>
CHtml::hiddenField('returnUrl', Yii::app()->returnUrl->getFormValue());
</pre>
@param bool $currentPage
@param bool $encode
@return null|string | [
"Get",
"url",
"from",
"submitted",
"data",
"or",
"the",
"current",
"page",
"url",
"for",
"usage",
"in",
"a",
"hidden",
"form",
"element"
]
| 9dc2dac5a3957ab193a1e8c80224c9f77479d3f0 | https://github.com/cornernote/yii-return-url/blob/9dc2dac5a3957ab193a1e8c80224c9f77479d3f0/return-url/components/EReturnUrl.php#L36-L43 |
14,401 | cornernote/yii-return-url | return-url/components/EReturnUrl.php | EReturnUrl.getLinkValue | public function getLinkValue($currentPage = false)
{
return $this->encodeLinkValue($currentPage ? Yii::app()->request->getUrl() : $this->getUrlFromSubmitFields());
} | php | public function getLinkValue($currentPage = false)
{
return $this->encodeLinkValue($currentPage ? Yii::app()->request->getUrl() : $this->getUrlFromSubmitFields());
} | [
"public",
"function",
"getLinkValue",
"(",
"$",
"currentPage",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"encodeLinkValue",
"(",
"$",
"currentPage",
"?",
"Yii",
"::",
"app",
"(",
")",
"->",
"request",
"->",
"getUrl",
"(",
")",
":",
"$",
"this",
"->",
"getUrlFromSubmitFields",
"(",
")",
")",
";",
"}"
]
| Get url from submitted data or the current page url
for usage in a link
@usage
in views/your_page.php
<pre>
CHtml::link('my link', array('test/form', 'returnUrl' => Yii::app()->returnUrl->getLinkValue(true)));
</pre>
@param bool $currentPage
@return string | [
"Get",
"url",
"from",
"submitted",
"data",
"or",
"the",
"current",
"page",
"url",
"for",
"usage",
"in",
"a",
"link"
]
| 9dc2dac5a3957ab193a1e8c80224c9f77479d3f0 | https://github.com/cornernote/yii-return-url/blob/9dc2dac5a3957ab193a1e8c80224c9f77479d3f0/return-url/components/EReturnUrl.php#L58-L61 |
14,402 | cornernote/yii-return-url | return-url/components/EReturnUrl.php | EReturnUrl.getUrl | public function getUrl($altUrl = false)
{
$url = $this->getUrlFromSubmitFields();
// alt url or current page
if (!$url && $altUrl)
$url = $altUrl;
return $url ? $url : Yii::app()->homeUrl;
} | php | public function getUrl($altUrl = false)
{
$url = $this->getUrlFromSubmitFields();
// alt url or current page
if (!$url && $altUrl)
$url = $altUrl;
return $url ? $url : Yii::app()->homeUrl;
} | [
"public",
"function",
"getUrl",
"(",
"$",
"altUrl",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrlFromSubmitFields",
"(",
")",
";",
"// alt url or current page",
"if",
"(",
"!",
"$",
"url",
"&&",
"$",
"altUrl",
")",
"$",
"url",
"=",
"$",
"altUrl",
";",
"return",
"$",
"url",
"?",
"$",
"url",
":",
"Yii",
"::",
"app",
"(",
")",
"->",
"homeUrl",
";",
"}"
]
| Get url from submitted data or session
@usage
in YourController::actionYourAction()
<pre>
$this->redirect(Yii::app()->returnUrl->getUrl());
</pre>
@param bool|mixed $altUrl
@return mixed|null | [
"Get",
"url",
"from",
"submitted",
"data",
"or",
"session"
]
| 9dc2dac5a3957ab193a1e8c80224c9f77479d3f0 | https://github.com/cornernote/yii-return-url/blob/9dc2dac5a3957ab193a1e8c80224c9f77479d3f0/return-url/components/EReturnUrl.php#L93-L100 |
14,403 | cornernote/yii-return-url | return-url/components/EReturnUrl.php | EReturnUrl.getUrlFromSubmitFields | private function getUrlFromSubmitFields()
{
$requestKey = $this->requestKey;
$url = isset($_GET[$requestKey]) && is_scalar($_GET[$requestKey]) ? $_GET[$requestKey] : (isset($_POST[$requestKey]) && is_scalar($_POST[$requestKey]) ? $_POST[$requestKey] : false);
$url = str_replace(chr(0), '', $url); // strip nul byte
$url = preg_replace('/\s+/', '', $url); // strip whitespace
return isset($_GET[$requestKey]) && is_scalar($_GET[$requestKey]) ? $this->urlDecode($url) : $url;
} | php | private function getUrlFromSubmitFields()
{
$requestKey = $this->requestKey;
$url = isset($_GET[$requestKey]) && is_scalar($_GET[$requestKey]) ? $_GET[$requestKey] : (isset($_POST[$requestKey]) && is_scalar($_POST[$requestKey]) ? $_POST[$requestKey] : false);
$url = str_replace(chr(0), '', $url); // strip nul byte
$url = preg_replace('/\s+/', '', $url); // strip whitespace
return isset($_GET[$requestKey]) && is_scalar($_GET[$requestKey]) ? $this->urlDecode($url) : $url;
} | [
"private",
"function",
"getUrlFromSubmitFields",
"(",
")",
"{",
"$",
"requestKey",
"=",
"$",
"this",
"->",
"requestKey",
";",
"$",
"url",
"=",
"isset",
"(",
"$",
"_GET",
"[",
"$",
"requestKey",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"_GET",
"[",
"$",
"requestKey",
"]",
")",
"?",
"$",
"_GET",
"[",
"$",
"requestKey",
"]",
":",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"$",
"requestKey",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"_POST",
"[",
"$",
"requestKey",
"]",
")",
"?",
"$",
"_POST",
"[",
"$",
"requestKey",
"]",
":",
"false",
")",
";",
"$",
"url",
"=",
"str_replace",
"(",
"chr",
"(",
"0",
")",
",",
"''",
",",
"$",
"url",
")",
";",
"// strip nul byte",
"$",
"url",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"''",
",",
"$",
"url",
")",
";",
"// strip whitespace",
"return",
"isset",
"(",
"$",
"_GET",
"[",
"$",
"requestKey",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"_GET",
"[",
"$",
"requestKey",
"]",
")",
"?",
"$",
"this",
"->",
"urlDecode",
"(",
"$",
"url",
")",
":",
"$",
"url",
";",
"}"
]
| Get the url from the request, decodes if needed
@return null|string | [
"Get",
"the",
"url",
"from",
"the",
"request",
"decodes",
"if",
"needed"
]
| 9dc2dac5a3957ab193a1e8c80224c9f77479d3f0 | https://github.com/cornernote/yii-return-url/blob/9dc2dac5a3957ab193a1e8c80224c9f77479d3f0/return-url/components/EReturnUrl.php#L107-L114 |
14,404 | acasademont/wurfl | WURFL/UserAgentHandlerChain.php | WURFL_UserAgentHandlerChain.addUserAgentHandler | public function addUserAgentHandler(WURFL_Handlers_Handler $handler)
{
$size = count($this->_userAgentHandlers);
if ($size > 0) {
$this->_userAgentHandlers[$size-1]->setNextHandler($handler);
}
$this->_userAgentHandlers[] = $handler;
return $this;
} | php | public function addUserAgentHandler(WURFL_Handlers_Handler $handler)
{
$size = count($this->_userAgentHandlers);
if ($size > 0) {
$this->_userAgentHandlers[$size-1]->setNextHandler($handler);
}
$this->_userAgentHandlers[] = $handler;
return $this;
} | [
"public",
"function",
"addUserAgentHandler",
"(",
"WURFL_Handlers_Handler",
"$",
"handler",
")",
"{",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"_userAgentHandlers",
")",
";",
"if",
"(",
"$",
"size",
">",
"0",
")",
"{",
"$",
"this",
"->",
"_userAgentHandlers",
"[",
"$",
"size",
"-",
"1",
"]",
"->",
"setNextHandler",
"(",
"$",
"handler",
")",
";",
"}",
"$",
"this",
"->",
"_userAgentHandlers",
"[",
"]",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
]
| Adds a WURFL_Handlers_Handler to the chain
@param WURFL_Handlers_Handler $handler
@return WURFL_UserAgentHandlerChain $this | [
"Adds",
"a",
"WURFL_Handlers_Handler",
"to",
"the",
"chain"
]
| 0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2 | https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/UserAgentHandlerChain.php#L37-L45 |
14,405 | axelitus/php-base | src/Arr.php | Arr.set | public function set($key, $value = null)
{
DotArr::set($this->data, $key, $value);
} | php | public function set($key, $value = null)
{
DotArr::set($this->data, $key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"DotArr",
"::",
"set",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
]
| Sets a value to the dot-notated internal array.
@param int|string|array $key The key of the item to be set or an array of key=>value pairs.
@param mixed $value The value to be set to the item.
@see DotArr::set | [
"Sets",
"a",
"value",
"to",
"the",
"dot",
"-",
"notated",
"internal",
"array",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Arr.php#L75-L78 |
14,406 | FrenchFrogs/framework | src/Modal/Renderer/Bootstrap.php | Bootstrap.modal | public function modal(Modal\Modal $modal)
{
$html = '';
// header
if ($modal->hasCloseButton()) {
$html .= html('button', ['type' => 'button', 'class' => 'close', 'data-dismiss' => 'modal', 'aria-label' => $modal->getCloseButtonLabel()], '<span aria-hidden="true">×</span>');
}
if ($modal->hasTitle()) {
$html .= html('h4', ['class' => Style::MODAL_HEADER_TITLE_CLASS], $modal->getTitle());
$html = html('div', ['class' => Style::MODAL_HEADER_CLASS], $html);
}
// body
$html .= html('div', ['class' => Style::MODAL_BODY_CLASS], $modal->getBody());
// footer
if ($modal->hasActions()) {
$actions = '';
if ($modal->hasCloseButton()) {
$actions .= html('button', ['type' => 'button', 'class' => 'btn btn-default', 'data-dismiss' => 'modal'], $modal->getCloseButtonLabel());
}
foreach ($modal->getActions() as $action) {
/** @var Element\Button $action */
$actions .= $this->render('action', $action);
}
$html .= html('div', ['class' => Style::MODAL_FOOTER_CLASS], $actions);
}
// container
if (!$modal->isRemote()) {
$html = html('div', ['class' => Style::MODAL_CONTENT_CLASS, ], $html);
$html = html('div', ['class' => Style::MODAL_DIALOG_CLASS, 'role' => 'document'], $html);
$html = html('div', ['class' => Style::MODAL_CLASS,'role' => 'dialog'], $html);
}
$html .= html('script', ['type' => 'text/javascript'],js('onload'));
return $html;
} | php | public function modal(Modal\Modal $modal)
{
$html = '';
// header
if ($modal->hasCloseButton()) {
$html .= html('button', ['type' => 'button', 'class' => 'close', 'data-dismiss' => 'modal', 'aria-label' => $modal->getCloseButtonLabel()], '<span aria-hidden="true">×</span>');
}
if ($modal->hasTitle()) {
$html .= html('h4', ['class' => Style::MODAL_HEADER_TITLE_CLASS], $modal->getTitle());
$html = html('div', ['class' => Style::MODAL_HEADER_CLASS], $html);
}
// body
$html .= html('div', ['class' => Style::MODAL_BODY_CLASS], $modal->getBody());
// footer
if ($modal->hasActions()) {
$actions = '';
if ($modal->hasCloseButton()) {
$actions .= html('button', ['type' => 'button', 'class' => 'btn btn-default', 'data-dismiss' => 'modal'], $modal->getCloseButtonLabel());
}
foreach ($modal->getActions() as $action) {
/** @var Element\Button $action */
$actions .= $this->render('action', $action);
}
$html .= html('div', ['class' => Style::MODAL_FOOTER_CLASS], $actions);
}
// container
if (!$modal->isRemote()) {
$html = html('div', ['class' => Style::MODAL_CONTENT_CLASS, ], $html);
$html = html('div', ['class' => Style::MODAL_DIALOG_CLASS, 'role' => 'document'], $html);
$html = html('div', ['class' => Style::MODAL_CLASS,'role' => 'dialog'], $html);
}
$html .= html('script', ['type' => 'text/javascript'],js('onload'));
return $html;
} | [
"public",
"function",
"modal",
"(",
"Modal",
"\\",
"Modal",
"$",
"modal",
")",
"{",
"$",
"html",
"=",
"''",
";",
"// header",
"if",
"(",
"$",
"modal",
"->",
"hasCloseButton",
"(",
")",
")",
"{",
"$",
"html",
".=",
"html",
"(",
"'button'",
",",
"[",
"'type'",
"=>",
"'button'",
",",
"'class'",
"=>",
"'close'",
",",
"'data-dismiss'",
"=>",
"'modal'",
",",
"'aria-label'",
"=>",
"$",
"modal",
"->",
"getCloseButtonLabel",
"(",
")",
"]",
",",
"'<span aria-hidden=\"true\">×</span>'",
")",
";",
"}",
"if",
"(",
"$",
"modal",
"->",
"hasTitle",
"(",
")",
")",
"{",
"$",
"html",
".=",
"html",
"(",
"'h4'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_HEADER_TITLE_CLASS",
"]",
",",
"$",
"modal",
"->",
"getTitle",
"(",
")",
")",
";",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_HEADER_CLASS",
"]",
",",
"$",
"html",
")",
";",
"}",
"// body",
"$",
"html",
".=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_BODY_CLASS",
"]",
",",
"$",
"modal",
"->",
"getBody",
"(",
")",
")",
";",
"// footer",
"if",
"(",
"$",
"modal",
"->",
"hasActions",
"(",
")",
")",
"{",
"$",
"actions",
"=",
"''",
";",
"if",
"(",
"$",
"modal",
"->",
"hasCloseButton",
"(",
")",
")",
"{",
"$",
"actions",
".=",
"html",
"(",
"'button'",
",",
"[",
"'type'",
"=>",
"'button'",
",",
"'class'",
"=>",
"'btn btn-default'",
",",
"'data-dismiss'",
"=>",
"'modal'",
"]",
",",
"$",
"modal",
"->",
"getCloseButtonLabel",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"modal",
"->",
"getActions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"/** @var Element\\Button $action */",
"$",
"actions",
".=",
"$",
"this",
"->",
"render",
"(",
"'action'",
",",
"$",
"action",
")",
";",
"}",
"$",
"html",
".=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_FOOTER_CLASS",
"]",
",",
"$",
"actions",
")",
";",
"}",
"// container",
"if",
"(",
"!",
"$",
"modal",
"->",
"isRemote",
"(",
")",
")",
"{",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_CONTENT_CLASS",
",",
"]",
",",
"$",
"html",
")",
";",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_DIALOG_CLASS",
",",
"'role'",
"=>",
"'document'",
"]",
",",
"$",
"html",
")",
";",
"$",
"html",
"=",
"html",
"(",
"'div'",
",",
"[",
"'class'",
"=>",
"Style",
"::",
"MODAL_CLASS",
",",
"'role'",
"=>",
"'dialog'",
"]",
",",
"$",
"html",
")",
";",
"}",
"$",
"html",
".=",
"html",
"(",
"'script'",
",",
"[",
"'type'",
"=>",
"'text/javascript'",
"]",
",",
"js",
"(",
"'onload'",
")",
")",
";",
"return",
"$",
"html",
";",
"}"
]
| Render a modal
@param \FrenchFrogs\Modal\Modal\Modal $modal
@return string | [
"Render",
"a",
"modal"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Modal/Renderer/Bootstrap.php#L33-L78 |
14,407 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.normalizeRelationsData | protected function normalizeRelationsData()
{
if (is_null($this->data['relationships'])) {
$this->data['relationships'] = [];
}
foreach ([ 'normal', 'reverse', 'image', 'file', 'checkbox', 'category' ] as $key) {
if ( ! array_key_exists($key, $this->data['relationships'])
|| ! is_array($this->data['relationships'][ $key ])
) {
$this->data->relationships[ $key ] = [];
}
}
return $this;
} | php | protected function normalizeRelationsData()
{
if (is_null($this->data['relationships'])) {
$this->data['relationships'] = [];
}
foreach ([ 'normal', 'reverse', 'image', 'file', 'checkbox', 'category' ] as $key) {
if ( ! array_key_exists($key, $this->data['relationships'])
|| ! is_array($this->data['relationships'][ $key ])
) {
$this->data->relationships[ $key ] = [];
}
}
return $this;
} | [
"protected",
"function",
"normalizeRelationsData",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"[",
"'normal'",
",",
"'reverse'",
",",
"'image'",
",",
"'file'",
",",
"'checkbox'",
",",
"'category'",
"]",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"->",
"relationships",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Makes sure that expected relations data is traversable
@return $this | [
"Makes",
"sure",
"that",
"expected",
"relations",
"data",
"is",
"traversable"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L34-L50 |
14,408 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.getRelationsConfigReplace | protected function getRelationsConfigReplace()
{
$relationships = $this->collectRelationshipDataForConfig();
if ( ! count($relationships)) return '';
$replace = $this->tab() . "protected \$relationsConfig = [\n";
foreach ($relationships as $name => $relationship) {
$replace .= $this->tab(2) . "'" . $name . "' => [\n";
$rows = [];
if (array_get($relationship, 'field')) {
$rows['field'] = $relationship['field'];
}
if (array_get($relationship, 'special')) {
$rows['type'] = $relationship['specialString'];
} else {
$rows['parent'] = ($relationship['reverse'] ? 'false' : 'true');
}
if (array_get($relationship, 'translated') === true) {
$rows['translated'] = 'true';
}
$longestPropertyLength = $this->getLongestKey($rows);
foreach ($rows as $property => $value) {
$replace .= $this->tab(3) . "'"
. str_pad($property . "'", $longestPropertyLength + 1)
. " => {$value},\n";
}
$replace .= $this->tab(2) . "],\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
} | php | protected function getRelationsConfigReplace()
{
$relationships = $this->collectRelationshipDataForConfig();
if ( ! count($relationships)) return '';
$replace = $this->tab() . "protected \$relationsConfig = [\n";
foreach ($relationships as $name => $relationship) {
$replace .= $this->tab(2) . "'" . $name . "' => [\n";
$rows = [];
if (array_get($relationship, 'field')) {
$rows['field'] = $relationship['field'];
}
if (array_get($relationship, 'special')) {
$rows['type'] = $relationship['specialString'];
} else {
$rows['parent'] = ($relationship['reverse'] ? 'false' : 'true');
}
if (array_get($relationship, 'translated') === true) {
$rows['translated'] = 'true';
}
$longestPropertyLength = $this->getLongestKey($rows);
foreach ($rows as $property => $value) {
$replace .= $this->tab(3) . "'"
. str_pad($property . "'", $longestPropertyLength + 1)
. " => {$value},\n";
}
$replace .= $this->tab(2) . "],\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
} | [
"protected",
"function",
"getRelationsConfigReplace",
"(",
")",
"{",
"$",
"relationships",
"=",
"$",
"this",
"->",
"collectRelationshipDataForConfig",
"(",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"relationships",
")",
")",
"return",
"''",
";",
"$",
"replace",
"=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"protected \\$relationsConfig = [\\n\"",
";",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"name",
"=>",
"$",
"relationship",
")",
"{",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"'\"",
".",
"$",
"name",
".",
"\"' => [\\n\"",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"if",
"(",
"array_get",
"(",
"$",
"relationship",
",",
"'field'",
")",
")",
"{",
"$",
"rows",
"[",
"'field'",
"]",
"=",
"$",
"relationship",
"[",
"'field'",
"]",
";",
"}",
"if",
"(",
"array_get",
"(",
"$",
"relationship",
",",
"'special'",
")",
")",
"{",
"$",
"rows",
"[",
"'type'",
"]",
"=",
"$",
"relationship",
"[",
"'specialString'",
"]",
";",
"}",
"else",
"{",
"$",
"rows",
"[",
"'parent'",
"]",
"=",
"(",
"$",
"relationship",
"[",
"'reverse'",
"]",
"?",
"'false'",
":",
"'true'",
")",
";",
"}",
"if",
"(",
"array_get",
"(",
"$",
"relationship",
",",
"'translated'",
")",
"===",
"true",
")",
"{",
"$",
"rows",
"[",
"'translated'",
"]",
"=",
"'true'",
";",
"}",
"$",
"longestPropertyLength",
"=",
"$",
"this",
"->",
"getLongestKey",
"(",
"$",
"rows",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
"3",
")",
".",
"\"'\"",
".",
"str_pad",
"(",
"$",
"property",
".",
"\"'\"",
",",
"$",
"longestPropertyLength",
"+",
"1",
")",
".",
"\" => {$value},\\n\"",
";",
"}",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"],\\n\"",
";",
"}",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"];\\n\\n\"",
";",
"return",
"$",
"replace",
";",
"}"
]
| Returns the replacement for the relations config placeholder
@return string | [
"Returns",
"the",
"replacement",
"for",
"the",
"relations",
"config",
"placeholder"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L82-L127 |
14,409 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.getRelationshipsReplace | protected function getRelationshipsReplace()
{
$totalCount = $this->getTotalRelevantRelationshipCount();
if ( ! $totalCount) return '';
$replace = "\n" . $this->getRelationshipsIntro();
$replace .= $this->getReplaceForNormalRelationships()
. $this->getReplaceForSpecialRelationships();
return $replace;
} | php | protected function getRelationshipsReplace()
{
$totalCount = $this->getTotalRelevantRelationshipCount();
if ( ! $totalCount) return '';
$replace = "\n" . $this->getRelationshipsIntro();
$replace .= $this->getReplaceForNormalRelationships()
. $this->getReplaceForSpecialRelationships();
return $replace;
} | [
"protected",
"function",
"getRelationshipsReplace",
"(",
")",
"{",
"$",
"totalCount",
"=",
"$",
"this",
"->",
"getTotalRelevantRelationshipCount",
"(",
")",
";",
"if",
"(",
"!",
"$",
"totalCount",
")",
"return",
"''",
";",
"$",
"replace",
"=",
"\"\\n\"",
".",
"$",
"this",
"->",
"getRelationshipsIntro",
"(",
")",
";",
"$",
"replace",
".=",
"$",
"this",
"->",
"getReplaceForNormalRelationships",
"(",
")",
".",
"$",
"this",
"->",
"getReplaceForSpecialRelationships",
"(",
")",
";",
"return",
"$",
"replace",
";",
"}"
]
| Returns the replacement for the relationships placeholder
@return string | [
"Returns",
"the",
"replacement",
"for",
"the",
"relationships",
"placeholder"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L183-L196 |
14,410 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.getTotalRelevantRelationshipCount | protected function getTotalRelevantRelationshipCount()
{
return count($this->getCombinedRelationships())
+ count( $this->data['relationships']['image'] )
+ count( $this->data['relationships']['file'] )
+ count( $this->data['relationships']['checkbox'] )
+ count( $this->data['relationships']['category'] );
} | php | protected function getTotalRelevantRelationshipCount()
{
return count($this->getCombinedRelationships())
+ count( $this->data['relationships']['image'] )
+ count( $this->data['relationships']['file'] )
+ count( $this->data['relationships']['checkbox'] )
+ count( $this->data['relationships']['category'] );
} | [
"protected",
"function",
"getTotalRelevantRelationshipCount",
"(",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getCombinedRelationships",
"(",
")",
")",
"+",
"count",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'image'",
"]",
")",
"+",
"count",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'file'",
"]",
")",
"+",
"count",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'checkbox'",
"]",
")",
"+",
"count",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'category'",
"]",
")",
";",
"}"
]
| Returns the number of relationships to be considered
for building up the stub replacement.
@return mixed | [
"Returns",
"the",
"number",
"of",
"relationships",
"to",
"be",
"considered",
"for",
"building",
"up",
"the",
"stub",
"replacement",
"."
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L215-L222 |
14,411 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.determineCategoryRelationName | protected function determineCategoryRelationName()
{
// pick a name and see if it conflicts with anything
$tryNames = config('pxlcms.generator.standard_models.category_relation_names', []);
$this->categoryRelationName = null;
foreach ($tryNames as $tryName) {
$tryName = trim($tryName);
if ( ! $this->doesRelationNameConflict($tryName)) {
$this->categoryRelationName = $tryName;
break;
}
}
if (empty($this->categoryRelationName)) {
$this->context->log(
"Unable to find a non-conflicting category relation name for model #{$this->data->module}. "
. "Relation omitted.",
Generator::LOG_LEVEL_ERROR
);
}
return $this->categoryRelationName;
} | php | protected function determineCategoryRelationName()
{
// pick a name and see if it conflicts with anything
$tryNames = config('pxlcms.generator.standard_models.category_relation_names', []);
$this->categoryRelationName = null;
foreach ($tryNames as $tryName) {
$tryName = trim($tryName);
if ( ! $this->doesRelationNameConflict($tryName)) {
$this->categoryRelationName = $tryName;
break;
}
}
if (empty($this->categoryRelationName)) {
$this->context->log(
"Unable to find a non-conflicting category relation name for model #{$this->data->module}. "
. "Relation omitted.",
Generator::LOG_LEVEL_ERROR
);
}
return $this->categoryRelationName;
} | [
"protected",
"function",
"determineCategoryRelationName",
"(",
")",
"{",
"// pick a name and see if it conflicts with anything",
"$",
"tryNames",
"=",
"config",
"(",
"'pxlcms.generator.standard_models.category_relation_names'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"categoryRelationName",
"=",
"null",
";",
"foreach",
"(",
"$",
"tryNames",
"as",
"$",
"tryName",
")",
"{",
"$",
"tryName",
"=",
"trim",
"(",
"$",
"tryName",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"doesRelationNameConflict",
"(",
"$",
"tryName",
")",
")",
"{",
"$",
"this",
"->",
"categoryRelationName",
"=",
"$",
"tryName",
";",
"break",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"categoryRelationName",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Unable to find a non-conflicting category relation name for model #{$this->data->module}. \"",
".",
"\"Relation omitted.\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"}",
"return",
"$",
"this",
"->",
"categoryRelationName",
";",
"}"
]
| Attempts to determine a non-conflicting name for the relationship to the Category model
@return string|false | [
"Attempts",
"to",
"determine",
"a",
"non",
"-",
"conflicting",
"name",
"for",
"the",
"relationship",
"to",
"the",
"Category",
"model"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L351-L378 |
14,412 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.doesRelationNameConflict | protected function doesRelationNameConflict($name)
{
// relationships
$relationships = array_merge(
$this->data['relationships']['normal'],
$this->data['relationships']['reverse'],
$this->data['relationships']['image'],
$this->data['relationships']['file'],
$this->data['relationships']['checkbox']
);
if (array_key_exists($name, $relationships)) return true;
// attributes
$attributes = array_merge(
$this->data->normal_attributes,
$this->data->translated_attributes
);
if (in_array(snake_case($name), $attributes)) return true;
return false;
} | php | protected function doesRelationNameConflict($name)
{
// relationships
$relationships = array_merge(
$this->data['relationships']['normal'],
$this->data['relationships']['reverse'],
$this->data['relationships']['image'],
$this->data['relationships']['file'],
$this->data['relationships']['checkbox']
);
if (array_key_exists($name, $relationships)) return true;
// attributes
$attributes = array_merge(
$this->data->normal_attributes,
$this->data->translated_attributes
);
if (in_array(snake_case($name), $attributes)) return true;
return false;
} | [
"protected",
"function",
"doesRelationNameConflict",
"(",
"$",
"name",
")",
"{",
"// relationships",
"$",
"relationships",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'normal'",
"]",
",",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'reverse'",
"]",
",",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'image'",
"]",
",",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'file'",
"]",
",",
"$",
"this",
"->",
"data",
"[",
"'relationships'",
"]",
"[",
"'checkbox'",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"relationships",
")",
")",
"return",
"true",
";",
"// attributes",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"data",
"->",
"normal_attributes",
",",
"$",
"this",
"->",
"data",
"->",
"translated_attributes",
")",
";",
"if",
"(",
"in_array",
"(",
"snake_case",
"(",
"$",
"name",
")",
",",
"$",
"attributes",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
]
| Returns whether a given name is already in use by anything that it would conflict with
for this model
@param string $name
@return bool | [
"Returns",
"whether",
"a",
"given",
"name",
"is",
"already",
"in",
"use",
"by",
"anything",
"that",
"it",
"would",
"conflict",
"with",
"for",
"this",
"model"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L387-L409 |
14,413 | czim/laravel-pxlcms | src/Generator/Writer/Model/Steps/StubReplaceRelationData.php | StubReplaceRelationData.getRelationMethodSection | protected function getRelationMethodSection(array $relationships, $type = CmsModel::RELATION_TYPE_MODEL)
{
$replace = '';
$relatedClassName = $this->context->getModelNamespaceForSpecialModel($type);
foreach ($relationships as $name => $relationship) {
$relationParameters = '';
$relationMethodParameters = '';
if ($relationKey = array_get($relationship, 'key')) {
$relationParameters = ", '{$relationKey}'";
}
if ( array_get($relationship, 'translated')
&& $type !== CmsModel::RELATION_TYPE_MODEL
&& config('pxlcms.generator.models.allow_locale_override_on_translated_model_relation')
) {
$relationMethodParameters = '$locale = null';
// skip parameters not entered, pass on the optional locale key
$relationParameters = (substr_count($relationParameters, ',') ? null : ', null')
. ', null'
. ', $locale';
}
$replace .= $this->tab() . "public function {$name}({$relationMethodParameters})\n"
. $this->tab() . "{\n"
. $this->tab(2) . "return \$this->{$relationship['type']}({$relatedClassName}::class"
. $relationParameters
. ");\n"
. $this->tab() . "}\n"
. "\n";
if ($type == CmsModel::RELATION_TYPE_IMAGE) {
// since images require special attention for resize enrichment,
// add an accessor method that will take care of it (through some magic)
$replace .= $this->tab() . "public function get" . studly_case($name) . "Attribute()\n"
. $this->tab() . "{\n"
. $this->tab(2) . "return \$this->getImagesWithResizes();\n"
. $this->tab() . "}\n"
. "\n";
}
}
return $replace;
} | php | protected function getRelationMethodSection(array $relationships, $type = CmsModel::RELATION_TYPE_MODEL)
{
$replace = '';
$relatedClassName = $this->context->getModelNamespaceForSpecialModel($type);
foreach ($relationships as $name => $relationship) {
$relationParameters = '';
$relationMethodParameters = '';
if ($relationKey = array_get($relationship, 'key')) {
$relationParameters = ", '{$relationKey}'";
}
if ( array_get($relationship, 'translated')
&& $type !== CmsModel::RELATION_TYPE_MODEL
&& config('pxlcms.generator.models.allow_locale_override_on_translated_model_relation')
) {
$relationMethodParameters = '$locale = null';
// skip parameters not entered, pass on the optional locale key
$relationParameters = (substr_count($relationParameters, ',') ? null : ', null')
. ', null'
. ', $locale';
}
$replace .= $this->tab() . "public function {$name}({$relationMethodParameters})\n"
. $this->tab() . "{\n"
. $this->tab(2) . "return \$this->{$relationship['type']}({$relatedClassName}::class"
. $relationParameters
. ");\n"
. $this->tab() . "}\n"
. "\n";
if ($type == CmsModel::RELATION_TYPE_IMAGE) {
// since images require special attention for resize enrichment,
// add an accessor method that will take care of it (through some magic)
$replace .= $this->tab() . "public function get" . studly_case($name) . "Attribute()\n"
. $this->tab() . "{\n"
. $this->tab(2) . "return \$this->getImagesWithResizes();\n"
. $this->tab() . "}\n"
. "\n";
}
}
return $replace;
} | [
"protected",
"function",
"getRelationMethodSection",
"(",
"array",
"$",
"relationships",
",",
"$",
"type",
"=",
"CmsModel",
"::",
"RELATION_TYPE_MODEL",
")",
"{",
"$",
"replace",
"=",
"''",
";",
"$",
"relatedClassName",
"=",
"$",
"this",
"->",
"context",
"->",
"getModelNamespaceForSpecialModel",
"(",
"$",
"type",
")",
";",
"foreach",
"(",
"$",
"relationships",
"as",
"$",
"name",
"=>",
"$",
"relationship",
")",
"{",
"$",
"relationParameters",
"=",
"''",
";",
"$",
"relationMethodParameters",
"=",
"''",
";",
"if",
"(",
"$",
"relationKey",
"=",
"array_get",
"(",
"$",
"relationship",
",",
"'key'",
")",
")",
"{",
"$",
"relationParameters",
"=",
"\", '{$relationKey}'\"",
";",
"}",
"if",
"(",
"array_get",
"(",
"$",
"relationship",
",",
"'translated'",
")",
"&&",
"$",
"type",
"!==",
"CmsModel",
"::",
"RELATION_TYPE_MODEL",
"&&",
"config",
"(",
"'pxlcms.generator.models.allow_locale_override_on_translated_model_relation'",
")",
")",
"{",
"$",
"relationMethodParameters",
"=",
"'$locale = null'",
";",
"// skip parameters not entered, pass on the optional locale key",
"$",
"relationParameters",
"=",
"(",
"substr_count",
"(",
"$",
"relationParameters",
",",
"','",
")",
"?",
"null",
":",
"', null'",
")",
".",
"', null'",
".",
"', $locale'",
";",
"}",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"public function {$name}({$relationMethodParameters})\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"{\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"return \\$this->{$relationship['type']}({$relatedClassName}::class\"",
".",
"$",
"relationParameters",
".",
"\");\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"}\\n\"",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"type",
"==",
"CmsModel",
"::",
"RELATION_TYPE_IMAGE",
")",
"{",
"// since images require special attention for resize enrichment,",
"// add an accessor method that will take care of it (through some magic)",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"public function get\"",
".",
"studly_case",
"(",
"$",
"name",
")",
".",
"\"Attribute()\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"{\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"return \\$this->getImagesWithResizes();\\n\"",
".",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"}\\n\"",
".",
"\"\\n\"",
";",
"}",
"}",
"return",
"$",
"replace",
";",
"}"
]
| Returns stub section for relation method
@param array $relationships
@param int|null $type CmsModel::RELATION_TYPE_...
@return string | [
"Returns",
"stub",
"section",
"for",
"relation",
"method"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceRelationData.php#L418-L467 |
14,414 | Teamsisu/contao-mm-frontendInput | src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/MMAttributeField.php | MMAttributeField.setDefaultValue | public function setDefaultValue($value)
{
$value = $this->mmAttribute->valueToWidget($value);
$this->set('value', $value);
} | php | public function setDefaultValue($value)
{
$value = $this->mmAttribute->valueToWidget($value);
$this->set('value', $value);
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"mmAttribute",
"->",
"valueToWidget",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'value'",
",",
"$",
"value",
")",
";",
"}"
]
| Set the default value of the Attribute
@param mixed $value | [
"Set",
"the",
"default",
"value",
"of",
"the",
"Attribute"
]
| ab92e61c24644f1e61265304b6a35e505007d021 | https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/DataContainer/Field/MMAttributeField.php#L153-L159 |
14,415 | phramework/validate | src/ObjectValidator.php | ObjectValidator.addProperties | public function addProperties($properties)
{
if (empty($properties) || !count((array)$properties)) {
throw new \Exception('Empty properties given');
}
if (!is_array($properties) && !is_object($properties)) {
throw new \Exception('Expected array or object');
}
foreach ($properties as $key => $property) {
$this->addProperty($key, $property);
}
return $this;
} | php | public function addProperties($properties)
{
if (empty($properties) || !count((array)$properties)) {
throw new \Exception('Empty properties given');
}
if (!is_array($properties) && !is_object($properties)) {
throw new \Exception('Expected array or object');
}
foreach ($properties as $key => $property) {
$this->addProperty($key, $property);
}
return $this;
} | [
"public",
"function",
"addProperties",
"(",
"$",
"properties",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"properties",
")",
"||",
"!",
"count",
"(",
"(",
"array",
")",
"$",
"properties",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Empty properties given'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"properties",
")",
"&&",
"!",
"is_object",
"(",
"$",
"properties",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Expected array or object'",
")",
";",
"}",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"key",
"=>",
"$",
"property",
")",
"{",
"$",
"this",
"->",
"addProperty",
"(",
"$",
"key",
",",
"$",
"property",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add properties to this object validator
@param array||object $properties [description]
@throws \Exception If properties is not an array | [
"Add",
"properties",
"to",
"this",
"object",
"validator"
]
| 22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc | https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/ObjectValidator.php#L495-L510 |
14,416 | phramework/validate | src/ObjectValidator.php | ObjectValidator.addProperty | public function addProperty($key, BaseValidator $property)
{
if (property_exists($this->properties, $key)) {
throw new \Exception('Property key exists');
}
//Add this key, value to
$this->properties->{$key} = $property;
return $this;
} | php | public function addProperty($key, BaseValidator $property)
{
if (property_exists($this->properties, $key)) {
throw new \Exception('Property key exists');
}
//Add this key, value to
$this->properties->{$key} = $property;
return $this;
} | [
"public",
"function",
"addProperty",
"(",
"$",
"key",
",",
"BaseValidator",
"$",
"property",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
"->",
"properties",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Property key exists'",
")",
";",
"}",
"//Add this key, value to",
"$",
"this",
"->",
"properties",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"property",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a property to this object validator
@param BaseValidator $property
@throws \Exception If property key exists | [
"Add",
"a",
"property",
"to",
"this",
"object",
"validator"
]
| 22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc | https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/ObjectValidator.php#L517-L527 |
14,417 | stubbles/stubbles-webapp-core | src/main/php/routing/CalledUri.php | CalledUri.castFrom | public static function castFrom($requestUri, string $requestMethod = null)
{
if ($requestUri instanceof self) {
return $requestUri;
}
return new self($requestUri, (string) $requestMethod);
} | php | public static function castFrom($requestUri, string $requestMethod = null)
{
if ($requestUri instanceof self) {
return $requestUri;
}
return new self($requestUri, (string) $requestMethod);
} | [
"public",
"static",
"function",
"castFrom",
"(",
"$",
"requestUri",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"requestUri",
"instanceof",
"self",
")",
"{",
"return",
"$",
"requestUri",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"requestUri",
",",
"(",
"string",
")",
"$",
"requestMethod",
")",
";",
"}"
]
| casts given values to an instance of UriRequest
@param string|\stubbles\webapp\routing\CalledUri $requestUri
@param string $requestMethod
@return \stubbles\webapp\routing\CalledUri
@since 4.0.0 | [
"casts",
"given",
"values",
"to",
"an",
"instance",
"of",
"UriRequest"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/CalledUri.php#L59-L66 |
14,418 | stubbles/stubbles-webapp-core | src/main/php/routing/CalledUri.php | CalledUri.methodEquals | public function methodEquals(string $method = null): bool
{
if (empty($method)) {
return true;
}
return $this->method === $method;
} | php | public function methodEquals(string $method = null): bool
{
if (empty($method)) {
return true;
}
return $this->method === $method;
} | [
"public",
"function",
"methodEquals",
"(",
"string",
"$",
"method",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"method",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"method",
"===",
"$",
"method",
";",
"}"
]
| checks if request method equals given method
@param string $method
@return bool | [
"checks",
"if",
"request",
"method",
"equals",
"given",
"method"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/CalledUri.php#L85-L92 |
14,419 | stubbles/stubbles-webapp-core | src/main/php/routing/CalledUri.php | CalledUri.satisfiesPath | public function satisfiesPath(string $expectedPath = null): bool
{
if (empty($expectedPath)) {
return true;
}
if (preg_match('/^' . UriPath::pattern($expectedPath) . '/', $this->uri->path()) >= 1) {
return true;
}
return false;
} | php | public function satisfiesPath(string $expectedPath = null): bool
{
if (empty($expectedPath)) {
return true;
}
if (preg_match('/^' . UriPath::pattern($expectedPath) . '/', $this->uri->path()) >= 1) {
return true;
}
return false;
} | [
"public",
"function",
"satisfiesPath",
"(",
"string",
"$",
"expectedPath",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"empty",
"(",
"$",
"expectedPath",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^'",
".",
"UriPath",
"::",
"pattern",
"(",
"$",
"expectedPath",
")",
".",
"'/'",
",",
"$",
"this",
"->",
"uri",
"->",
"path",
"(",
")",
")",
">=",
"1",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| checks if given path is satisfied by request path
@param string $expectedPath
@return bool | [
"checks",
"if",
"given",
"path",
"is",
"satisfied",
"by",
"request",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/CalledUri.php#L100-L111 |
14,420 | stubbles/stubbles-webapp-core | src/main/php/routing/CalledUri.php | CalledUri.satisfies | public function satisfies(string $method = null, string $expectedPath = null): bool
{
return $this->methodEquals($method) && $this->satisfiesPath($expectedPath);
} | php | public function satisfies(string $method = null, string $expectedPath = null): bool
{
return $this->methodEquals($method) && $this->satisfiesPath($expectedPath);
} | [
"public",
"function",
"satisfies",
"(",
"string",
"$",
"method",
"=",
"null",
",",
"string",
"$",
"expectedPath",
"=",
"null",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"methodEquals",
"(",
"$",
"method",
")",
"&&",
"$",
"this",
"->",
"satisfiesPath",
"(",
"$",
"expectedPath",
")",
";",
"}"
]
| checks if given method and path is satisfied by request
@param string $method
@param string $expectedPath
@return bool
@since 3.4.0 | [
"checks",
"if",
"given",
"method",
"and",
"path",
"is",
"satisfied",
"by",
"request"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/CalledUri.php#L121-L124 |
14,421 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ChildAware.php | ChildAware.eachChild | public function eachChild($callback)
{
foreach ($this->children as $child) {
call_user_func($callback, $child);
}
return $this;
} | php | public function eachChild($callback)
{
foreach ($this->children as $child) {
call_user_func($callback, $child);
}
return $this;
} | [
"public",
"function",
"eachChild",
"(",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"child",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Run a callback for each child.
@param \Callable $callback Callback which accepts the child as argument.
@return $this | [
"Run",
"a",
"callback",
"for",
"each",
"child",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ChildAware.php#L66-L73 |
14,422 | contao-bootstrap/buttons | src/Netzmacht/Bootstrap/Buttons/ChildAware.php | ChildAware.generateChildren | protected function generateChildren()
{
$buffer = '';
foreach ($this->children as $child) {
$buffer .= $child->generate();
}
return $buffer;
} | php | protected function generateChildren()
{
$buffer = '';
foreach ($this->children as $child) {
$buffer .= $child->generate();
}
return $buffer;
} | [
"protected",
"function",
"generateChildren",
"(",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"buffer",
".=",
"$",
"child",
"->",
"generate",
"(",
")",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
]
| Generate children.
@return string | [
"Generate",
"children",
"."
]
| f573a24c19ec059aae528a12ba46dfc993844201 | https://github.com/contao-bootstrap/buttons/blob/f573a24c19ec059aae528a12ba46dfc993844201/src/Netzmacht/Bootstrap/Buttons/ChildAware.php#L107-L116 |
14,423 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bind | protected function bind($vars, ServerRequestInterface $request, array $parts)
{
$type = is_array($vars) && array_keys($vars) === array_keys(array_keys($vars)) ? 'numeric' : 'assoc';
$values = $this->bindParts($vars, $type, $request, $parts);
if ($vars instanceof Route) {
$class = get_class($vars);
$values = new $class($values);
} elseif (is_object($vars) && $type === 'assoc') {
$values = (object)$values;
}
return $values;
} | php | protected function bind($vars, ServerRequestInterface $request, array $parts)
{
$type = is_array($vars) && array_keys($vars) === array_keys(array_keys($vars)) ? 'numeric' : 'assoc';
$values = $this->bindParts($vars, $type, $request, $parts);
if ($vars instanceof Route) {
$class = get_class($vars);
$values = new $class($values);
} elseif (is_object($vars) && $type === 'assoc') {
$values = (object)$values;
}
return $values;
} | [
"protected",
"function",
"bind",
"(",
"$",
"vars",
",",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"parts",
")",
"{",
"$",
"type",
"=",
"is_array",
"(",
"$",
"vars",
")",
"&&",
"array_keys",
"(",
"$",
"vars",
")",
"===",
"array_keys",
"(",
"array_keys",
"(",
"$",
"vars",
")",
")",
"?",
"'numeric'",
":",
"'assoc'",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"bindParts",
"(",
"$",
"vars",
",",
"$",
"type",
",",
"$",
"request",
",",
"$",
"parts",
")",
";",
"if",
"(",
"$",
"vars",
"instanceof",
"Route",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"vars",
")",
";",
"$",
"values",
"=",
"new",
"$",
"class",
"(",
"$",
"values",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"vars",
")",
"&&",
"$",
"type",
"===",
"'assoc'",
")",
"{",
"$",
"values",
"=",
"(",
"object",
")",
"$",
"values",
";",
"}",
"return",
"$",
"values",
";",
"}"
]
| Fill out the routes variables based on the url parts.
@param array|\stdClass $vars Route variables
@param ServerRequestInterface $request
@param array $parts URL parts
@return array | [
"Fill",
"out",
"the",
"routes",
"variables",
"based",
"on",
"the",
"url",
"parts",
"."
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L21-L35 |
14,424 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindParts | protected function bindParts($vars, $type, ServerRequestInterface $request, array $parts)
{
$values = [];
foreach ($vars as $key => $var) {
$part = null;
$bound =
$this->bindPartObject($var, $part) ||
$this->bindPartArray($var, $request, $parts, $part) ||
$this->bindPartVar($var, $type, $request, $parts, $part) ||
$this->bindPartConcat($var, $request, $parts, $part) ||
$this->bindPartValue($var, $part);
if (!$bound) continue;
if ($type === 'assoc') {
$values[$key] = $part[0];
} else {
$values = array_merge($values, $part);
}
}
return $values;
} | php | protected function bindParts($vars, $type, ServerRequestInterface $request, array $parts)
{
$values = [];
foreach ($vars as $key => $var) {
$part = null;
$bound =
$this->bindPartObject($var, $part) ||
$this->bindPartArray($var, $request, $parts, $part) ||
$this->bindPartVar($var, $type, $request, $parts, $part) ||
$this->bindPartConcat($var, $request, $parts, $part) ||
$this->bindPartValue($var, $part);
if (!$bound) continue;
if ($type === 'assoc') {
$values[$key] = $part[0];
} else {
$values = array_merge($values, $part);
}
}
return $values;
} | [
"protected",
"function",
"bindParts",
"(",
"$",
"vars",
",",
"$",
"type",
",",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"parts",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"var",
")",
"{",
"$",
"part",
"=",
"null",
";",
"$",
"bound",
"=",
"$",
"this",
"->",
"bindPartObject",
"(",
"$",
"var",
",",
"$",
"part",
")",
"||",
"$",
"this",
"->",
"bindPartArray",
"(",
"$",
"var",
",",
"$",
"request",
",",
"$",
"parts",
",",
"$",
"part",
")",
"||",
"$",
"this",
"->",
"bindPartVar",
"(",
"$",
"var",
",",
"$",
"type",
",",
"$",
"request",
",",
"$",
"parts",
",",
"$",
"part",
")",
"||",
"$",
"this",
"->",
"bindPartConcat",
"(",
"$",
"var",
",",
"$",
"request",
",",
"$",
"parts",
",",
"$",
"part",
")",
"||",
"$",
"this",
"->",
"bindPartValue",
"(",
"$",
"var",
",",
"$",
"part",
")",
";",
"if",
"(",
"!",
"$",
"bound",
")",
"continue",
";",
"if",
"(",
"$",
"type",
"===",
"'assoc'",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"part",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"values",
",",
"$",
"part",
")",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
]
| Fill out the values based on the url parts.
@param array|\stdClass $vars Route variables
@param string $type
@param ServerRequestInterface $request
@param array $parts URL parts
@return array | [
"Fill",
"out",
"the",
"values",
"based",
"on",
"the",
"url",
"parts",
"."
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L47-L71 |
14,425 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindPartArray | protected function bindPartArray($var, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_array($var) && !$var instanceof \stdClass) {
return false;
}
$part = [$this->bind($var, $request, $parts)];
return true;
} | php | protected function bindPartArray($var, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_array($var) && !$var instanceof \stdClass) {
return false;
}
$part = [$this->bind($var, $request, $parts)];
return true;
} | [
"protected",
"function",
"bindPartArray",
"(",
"$",
"var",
",",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"parts",
",",
"&",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"var",
")",
"&&",
"!",
"$",
"var",
"instanceof",
"\\",
"stdClass",
")",
"{",
"return",
"false",
";",
"}",
"$",
"part",
"=",
"[",
"$",
"this",
"->",
"bind",
"(",
"$",
"var",
",",
"$",
"request",
",",
"$",
"parts",
")",
"]",
";",
"return",
"true",
";",
"}"
]
| Bind part if it's an array
@param mixed $var
@param ServerRequestInterface $request
@param array $parts
@param array $part OUTPUT
@return boolean | [
"Bind",
"part",
"if",
"it",
"s",
"an",
"array"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L99-L107 |
14,426 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindPartVar | protected function bindPartVar($var, $type, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_string($var) || $var[0] !== '$') {
return false;
}
$options = array_map('trim', explode('|', $var));
$part = $this->bindVar($type, $request, $parts, $options);
return true;
} | php | protected function bindPartVar($var, $type, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_string($var) || $var[0] !== '$') {
return false;
}
$options = array_map('trim', explode('|', $var));
$part = $this->bindVar($type, $request, $parts, $options);
return true;
} | [
"protected",
"function",
"bindPartVar",
"(",
"$",
"var",
",",
"$",
"type",
",",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"parts",
",",
"&",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"var",
")",
"||",
"$",
"var",
"[",
"0",
"]",
"!==",
"'$'",
")",
"{",
"return",
"false",
";",
"}",
"$",
"options",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"'|'",
",",
"$",
"var",
")",
")",
";",
"$",
"part",
"=",
"$",
"this",
"->",
"bindVar",
"(",
"$",
"type",
",",
"$",
"request",
",",
"$",
"parts",
",",
"$",
"options",
")",
";",
"return",
"true",
";",
"}"
]
| Bind part if it's an variable
@param mixed $var
@param string $type
@param ServerRequestInterface $request
@param array $parts
@param array $part OUTPUT
@return boolean | [
"Bind",
"part",
"if",
"it",
"s",
"an",
"variable"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L119-L128 |
14,427 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindPartConcat | protected function bindPartConcat($var, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_string($var) || $var[0] !== '~' || substr($var, -1) !== '~') {
return false;
}
$pieces = array_map('trim', explode('~', substr($var, 1, -1)));
$bound = array_filter($this->bind($pieces, $request, $parts));
$part = [join('', $bound)];
return true;
} | php | protected function bindPartConcat($var, ServerRequestInterface $request, array $parts, &$part)
{
if (!is_string($var) || $var[0] !== '~' || substr($var, -1) !== '~') {
return false;
}
$pieces = array_map('trim', explode('~', substr($var, 1, -1)));
$bound = array_filter($this->bind($pieces, $request, $parts));
$part = [join('', $bound)];
return true;
} | [
"protected",
"function",
"bindPartConcat",
"(",
"$",
"var",
",",
"ServerRequestInterface",
"$",
"request",
",",
"array",
"$",
"parts",
",",
"&",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"var",
")",
"||",
"$",
"var",
"[",
"0",
"]",
"!==",
"'~'",
"||",
"substr",
"(",
"$",
"var",
",",
"-",
"1",
")",
"!==",
"'~'",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pieces",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"'~'",
",",
"substr",
"(",
"$",
"var",
",",
"1",
",",
"-",
"1",
")",
")",
")",
";",
"$",
"bound",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"bind",
"(",
"$",
"pieces",
",",
"$",
"request",
",",
"$",
"parts",
")",
")",
";",
"$",
"part",
"=",
"[",
"join",
"(",
"''",
",",
"$",
"bound",
")",
"]",
";",
"return",
"true",
";",
"}"
]
| Bind part if it's an concatenation
@param mixed $var
@param ServerRequestInterface $request
@param array $parts
@param array $part OUTPUT
@return boolean | [
"Bind",
"part",
"if",
"it",
"s",
"an",
"concatenation"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L139-L150 |
14,428 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindVarSuperGlobal | protected function bindVarSuperGlobal($option, ServerRequestInterface $request, &$value)
{
if (preg_match('/^\$_(GET|POST|COOKIE)\[([^\[]*)\]$/i', $option, $matches)) {
list(, $var, $key) = $matches;
$var = strtolower($var);
$data = null;
if ($var === 'get') {
$data = $request->getQueryParams();
} elseif ($var === 'post') {
$data = $request->getParsedBody();
} elseif ($var === 'cookie') {
$data = $request->getCookieParams();
}
$value = isset($data[$key]) ? [$data[$key]] : null;
return true;
}
return false;
} | php | protected function bindVarSuperGlobal($option, ServerRequestInterface $request, &$value)
{
if (preg_match('/^\$_(GET|POST|COOKIE)\[([^\[]*)\]$/i', $option, $matches)) {
list(, $var, $key) = $matches;
$var = strtolower($var);
$data = null;
if ($var === 'get') {
$data = $request->getQueryParams();
} elseif ($var === 'post') {
$data = $request->getParsedBody();
} elseif ($var === 'cookie') {
$data = $request->getCookieParams();
}
$value = isset($data[$key]) ? [$data[$key]] : null;
return true;
}
return false;
} | [
"protected",
"function",
"bindVarSuperGlobal",
"(",
"$",
"option",
",",
"ServerRequestInterface",
"$",
"request",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\$_(GET|POST|COOKIE)\\[([^\\[]*)\\]$/i'",
",",
"$",
"option",
",",
"$",
"matches",
")",
")",
"{",
"list",
"(",
",",
"$",
"var",
",",
"$",
"key",
")",
"=",
"$",
"matches",
";",
"$",
"var",
"=",
"strtolower",
"(",
"$",
"var",
")",
";",
"$",
"data",
"=",
"null",
";",
"if",
"(",
"$",
"var",
"===",
"'get'",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"getQueryParams",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"var",
"===",
"'post'",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"getParsedBody",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"var",
"===",
"'cookie'",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"getCookieParams",
"(",
")",
";",
"}",
"$",
"value",
"=",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"?",
"[",
"$",
"data",
"[",
"$",
"key",
"]",
"]",
":",
"null",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Bind variable when option is a super global
@param string $option
@param mixed $value OUTPUT
@return boolean | [
"Bind",
"variable",
"when",
"option",
"is",
"a",
"super",
"global"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L222-L243 |
14,429 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindVarRequestHeader | protected function bindVarRequestHeader($option, ServerRequestInterface $request, &$value)
{
if (preg_match('/^\$(?:HTTP_)?([A-Z_]+)$/', $option, $matches)) {
$sentence = preg_replace('/[\W_]+/', ' ', $matches[1]);
$name = str_replace(' ', '-', ucwords($sentence));
$value = [$request->getHeaderLine($name)];
return true;
}
return false;
} | php | protected function bindVarRequestHeader($option, ServerRequestInterface $request, &$value)
{
if (preg_match('/^\$(?:HTTP_)?([A-Z_]+)$/', $option, $matches)) {
$sentence = preg_replace('/[\W_]+/', ' ', $matches[1]);
$name = str_replace(' ', '-', ucwords($sentence));
$value = [$request->getHeaderLine($name)];
return true;
}
return false;
} | [
"protected",
"function",
"bindVarRequestHeader",
"(",
"$",
"option",
",",
"ServerRequestInterface",
"$",
"request",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^\\$(?:HTTP_)?([A-Z_]+)$/'",
",",
"$",
"option",
",",
"$",
"matches",
")",
")",
"{",
"$",
"sentence",
"=",
"preg_replace",
"(",
"'/[\\W_]+/'",
",",
"' '",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"' '",
",",
"'-'",
",",
"ucwords",
"(",
"$",
"sentence",
")",
")",
";",
"$",
"value",
"=",
"[",
"$",
"request",
"->",
"getHeaderLine",
"(",
"$",
"name",
")",
"]",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Bind variable when option is a request header
@param string $option
@param ServerRequestInterface $request
@param mixed $value OUTPUT
@return boolean | [
"Bind",
"variable",
"when",
"option",
"is",
"a",
"request",
"header"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L253-L264 |
14,430 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindVarMultipleUrlParts | protected function bindVarMultipleUrlParts($option, $type, array $parts, &$value)
{
if (substr($option, -3) === '...' && ctype_digit(substr($option, 1, -3))) {
$i = (int)substr($option, 1, -3);
if ($type === 'assoc') {
throw new \InvalidArgumentException("Binding multiple parts using '$option' is only allowed in numeric arrays");
} else {
$value = array_slice($parts, $i - 1);
}
return true;
}
return false;
} | php | protected function bindVarMultipleUrlParts($option, $type, array $parts, &$value)
{
if (substr($option, -3) === '...' && ctype_digit(substr($option, 1, -3))) {
$i = (int)substr($option, 1, -3);
if ($type === 'assoc') {
throw new \InvalidArgumentException("Binding multiple parts using '$option' is only allowed in numeric arrays");
} else {
$value = array_slice($parts, $i - 1);
}
return true;
}
return false;
} | [
"protected",
"function",
"bindVarMultipleUrlParts",
"(",
"$",
"option",
",",
"$",
"type",
",",
"array",
"$",
"parts",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"option",
",",
"-",
"3",
")",
"===",
"'...'",
"&&",
"ctype_digit",
"(",
"substr",
"(",
"$",
"option",
",",
"1",
",",
"-",
"3",
")",
")",
")",
"{",
"$",
"i",
"=",
"(",
"int",
")",
"substr",
"(",
"$",
"option",
",",
"1",
",",
"-",
"3",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'assoc'",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Binding multiple parts using '$option' is only allowed in numeric arrays\"",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"array_slice",
"(",
"$",
"parts",
",",
"$",
"i",
"-",
"1",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Bind variable when option contains multiple URL parts
@param string $option
@param string $type 'assoc' or 'numeric'
@param array $parts Url parts
@param mixed $value OUTPUT
@return boolean | [
"Bind",
"variable",
"when",
"option",
"contains",
"multiple",
"URL",
"parts"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L275-L290 |
14,431 | jasny/router | src/Router/Routes/RouteBinding.php | RouteBinding.bindVarSingleUrlPart | protected function bindVarSingleUrlPart($option, array $parts, &$value)
{
if (ctype_digit(substr($option, 1))) {
$i = (int)substr($option, 1);
$part = array_slice($parts, $i - 1, 1);
if (!empty($part)) {
$value = $part;
return true;
}
}
return false;
} | php | protected function bindVarSingleUrlPart($option, array $parts, &$value)
{
if (ctype_digit(substr($option, 1))) {
$i = (int)substr($option, 1);
$part = array_slice($parts, $i - 1, 1);
if (!empty($part)) {
$value = $part;
return true;
}
}
return false;
} | [
"protected",
"function",
"bindVarSingleUrlPart",
"(",
"$",
"option",
",",
"array",
"$",
"parts",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"ctype_digit",
"(",
"substr",
"(",
"$",
"option",
",",
"1",
")",
")",
")",
"{",
"$",
"i",
"=",
"(",
"int",
")",
"substr",
"(",
"$",
"option",
",",
"1",
")",
";",
"$",
"part",
"=",
"array_slice",
"(",
"$",
"parts",
",",
"$",
"i",
"-",
"1",
",",
"1",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"part",
")",
")",
"{",
"$",
"value",
"=",
"$",
"part",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Bind variable when option contains a single URL part
@param string $option
@param array $parts Url parts
@param mixed $value OUTPUT
@return boolean | [
"Bind",
"variable",
"when",
"option",
"contains",
"a",
"single",
"URL",
"part"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Routes/RouteBinding.php#L300-L313 |
14,432 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtSupports/SupportsRule.php | SupportsRule.addCondition | public function addCondition(ConditionAbstract $condition)
{
if ($condition instanceof SupportsCondition) {
$this->conditions[] = $condition;
} else {
throw new \InvalidArgumentException(
"Invalid condition instance. Instance of 'SupportsCondition' expected."
);
}
return $this;
} | php | public function addCondition(ConditionAbstract $condition)
{
if ($condition instanceof SupportsCondition) {
$this->conditions[] = $condition;
} else {
throw new \InvalidArgumentException(
"Invalid condition instance. Instance of 'SupportsCondition' expected."
);
}
return $this;
} | [
"public",
"function",
"addCondition",
"(",
"ConditionAbstract",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"condition",
"instanceof",
"SupportsCondition",
")",
"{",
"$",
"this",
"->",
"conditions",
"[",
"]",
"=",
"$",
"condition",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid condition instance. Instance of 'SupportsCondition' expected.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds a supports condition.
@param SupportsCondition $condition
@return $this | [
"Adds",
"a",
"supports",
"condition",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtSupports/SupportsRule.php#L38-L49 |
14,433 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtSupports/SupportsRule.php | SupportsRule.parseRuleString | protected function parseRuleString($ruleString)
{
// Remove at-rule name and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@supports[ \r\n\t\f]*/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
$charset = $this->getCharset();
$conditions = [];
foreach (Condition::splitNestedConditions($ruleString, $this->getCharset()) as $normalizedConditionList) {
$normalizedConditions = [];
$currentCondition = "";
if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) {
$isAscii = false;
$strLen = mb_strlen($normalizedConditionList, $charset);
$getAnd = function($i) use ($normalizedConditionList){
return strtolower(substr($normalizedConditionList, $i, 5));
};
} else {
$isAscii = true;
$strLen = strlen($normalizedConditionList);
$getAnd = function($i) use ($charset, $normalizedConditionList){
return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);
};
}
for ($i = 0, $j = $strLen; $i < $j; $i++) {
if ($isAscii === true) {
$char = $normalizedConditionList[$i];
} else {
$char = mb_substr($normalizedConditionList, $i, 1, $charset);
}
if ($char === " " && $getAnd($i) === " and ") {
$normalizedConditions[] = new SupportsCondition(trim($currentCondition, " \r\n\t\f"));
$currentCondition = "";
$i += (5 - 1);
} else {
$currentCondition .= $char;
}
}
$currentCondition = trim($currentCondition, " \r\n\t\f");
if ($currentCondition !== "") {
$normalizedConditions[] = new SupportsCondition(trim($currentCondition, " \r\n\t\f"));
}
foreach ($normalizedConditions as $normalizedCondition) {
$conditions[] = $normalizedCondition;
}
}
$this->setConditions($conditions);
} | php | protected function parseRuleString($ruleString)
{
// Remove at-rule name and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@supports[ \r\n\t\f]*/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
$charset = $this->getCharset();
$conditions = [];
foreach (Condition::splitNestedConditions($ruleString, $this->getCharset()) as $normalizedConditionList) {
$normalizedConditions = [];
$currentCondition = "";
if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) {
$isAscii = false;
$strLen = mb_strlen($normalizedConditionList, $charset);
$getAnd = function($i) use ($normalizedConditionList){
return strtolower(substr($normalizedConditionList, $i, 5));
};
} else {
$isAscii = true;
$strLen = strlen($normalizedConditionList);
$getAnd = function($i) use ($charset, $normalizedConditionList){
return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);
};
}
for ($i = 0, $j = $strLen; $i < $j; $i++) {
if ($isAscii === true) {
$char = $normalizedConditionList[$i];
} else {
$char = mb_substr($normalizedConditionList, $i, 1, $charset);
}
if ($char === " " && $getAnd($i) === " and ") {
$normalizedConditions[] = new SupportsCondition(trim($currentCondition, " \r\n\t\f"));
$currentCondition = "";
$i += (5 - 1);
} else {
$currentCondition .= $char;
}
}
$currentCondition = trim($currentCondition, " \r\n\t\f");
if ($currentCondition !== "") {
$normalizedConditions[] = new SupportsCondition(trim($currentCondition, " \r\n\t\f"));
}
foreach ($normalizedConditions as $normalizedCondition) {
$conditions[] = $normalizedCondition;
}
}
$this->setConditions($conditions);
} | [
"protected",
"function",
"parseRuleString",
"(",
"$",
"ruleString",
")",
"{",
"// Remove at-rule name and unnecessary white-spaces",
"$",
"ruleString",
"=",
"preg_replace",
"(",
"'/^[ \\r\\n\\t\\f]*@supports[ \\r\\n\\t\\f]*/i'",
",",
"''",
",",
"$",
"ruleString",
")",
";",
"$",
"ruleString",
"=",
"trim",
"(",
"$",
"ruleString",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"$",
"charset",
"=",
"$",
"this",
"->",
"getCharset",
"(",
")",
";",
"$",
"conditions",
"=",
"[",
"]",
";",
"foreach",
"(",
"Condition",
"::",
"splitNestedConditions",
"(",
"$",
"ruleString",
",",
"$",
"this",
"->",
"getCharset",
"(",
")",
")",
"as",
"$",
"normalizedConditionList",
")",
"{",
"$",
"normalizedConditions",
"=",
"[",
"]",
";",
"$",
"currentCondition",
"=",
"\"\"",
";",
"if",
"(",
"preg_match",
"(",
"'/[^\\x00-\\x7f]/'",
",",
"$",
"normalizedConditionList",
")",
")",
"{",
"$",
"isAscii",
"=",
"false",
";",
"$",
"strLen",
"=",
"mb_strlen",
"(",
"$",
"normalizedConditionList",
",",
"$",
"charset",
")",
";",
"$",
"getAnd",
"=",
"function",
"(",
"$",
"i",
")",
"use",
"(",
"$",
"normalizedConditionList",
")",
"{",
"return",
"strtolower",
"(",
"substr",
"(",
"$",
"normalizedConditionList",
",",
"$",
"i",
",",
"5",
")",
")",
";",
"}",
";",
"}",
"else",
"{",
"$",
"isAscii",
"=",
"true",
";",
"$",
"strLen",
"=",
"strlen",
"(",
"$",
"normalizedConditionList",
")",
";",
"$",
"getAnd",
"=",
"function",
"(",
"$",
"i",
")",
"use",
"(",
"$",
"charset",
",",
"$",
"normalizedConditionList",
")",
"{",
"return",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"normalizedConditionList",
",",
"$",
"i",
",",
"5",
",",
"$",
"charset",
")",
",",
"$",
"charset",
")",
";",
"}",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"j",
"=",
"$",
"strLen",
";",
"$",
"i",
"<",
"$",
"j",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"isAscii",
"===",
"true",
")",
"{",
"$",
"char",
"=",
"$",
"normalizedConditionList",
"[",
"$",
"i",
"]",
";",
"}",
"else",
"{",
"$",
"char",
"=",
"mb_substr",
"(",
"$",
"normalizedConditionList",
",",
"$",
"i",
",",
"1",
",",
"$",
"charset",
")",
";",
"}",
"if",
"(",
"$",
"char",
"===",
"\" \"",
"&&",
"$",
"getAnd",
"(",
"$",
"i",
")",
"===",
"\" and \"",
")",
"{",
"$",
"normalizedConditions",
"[",
"]",
"=",
"new",
"SupportsCondition",
"(",
"trim",
"(",
"$",
"currentCondition",
",",
"\" \\r\\n\\t\\f\"",
")",
")",
";",
"$",
"currentCondition",
"=",
"\"\"",
";",
"$",
"i",
"+=",
"(",
"5",
"-",
"1",
")",
";",
"}",
"else",
"{",
"$",
"currentCondition",
".=",
"$",
"char",
";",
"}",
"}",
"$",
"currentCondition",
"=",
"trim",
"(",
"$",
"currentCondition",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"if",
"(",
"$",
"currentCondition",
"!==",
"\"\"",
")",
"{",
"$",
"normalizedConditions",
"[",
"]",
"=",
"new",
"SupportsCondition",
"(",
"trim",
"(",
"$",
"currentCondition",
",",
"\" \\r\\n\\t\\f\"",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"normalizedConditions",
"as",
"$",
"normalizedCondition",
")",
"{",
"$",
"conditions",
"[",
"]",
"=",
"$",
"normalizedCondition",
";",
"}",
"}",
"$",
"this",
"->",
"setConditions",
"(",
"$",
"conditions",
")",
";",
"}"
]
| Parses the supports rule.
@param $ruleString | [
"Parses",
"the",
"supports",
"rule",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtSupports/SupportsRule.php#L56-L110 |
14,434 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.getUserRoles | public function getUserRoles(Criteria $criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
// return empty collection
$this->initUserRoles();
} else {
$collUserRoles = ChildUserRoleQuery::create(null, $criteria)
->filterByUser($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collUserRolesPartial && count($collUserRoles)) {
$this->initUserRoles(false);
foreach ($collUserRoles as $obj) {
if (false == $this->collUserRoles->contains($obj)) {
$this->collUserRoles->append($obj);
}
}
$this->collUserRolesPartial = true;
}
return $collUserRoles;
}
if ($partial && $this->collUserRoles) {
foreach ($this->collUserRoles as $obj) {
if ($obj->isNew()) {
$collUserRoles[] = $obj;
}
}
}
$this->collUserRoles = $collUserRoles;
$this->collUserRolesPartial = false;
}
}
return $this->collUserRoles;
} | php | public function getUserRoles(Criteria $criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collUserRolesPartial && !$this->isNew();
if (null === $this->collUserRoles || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collUserRoles) {
// return empty collection
$this->initUserRoles();
} else {
$collUserRoles = ChildUserRoleQuery::create(null, $criteria)
->filterByUser($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collUserRolesPartial && count($collUserRoles)) {
$this->initUserRoles(false);
foreach ($collUserRoles as $obj) {
if (false == $this->collUserRoles->contains($obj)) {
$this->collUserRoles->append($obj);
}
}
$this->collUserRolesPartial = true;
}
return $collUserRoles;
}
if ($partial && $this->collUserRoles) {
foreach ($this->collUserRoles as $obj) {
if ($obj->isNew()) {
$collUserRoles[] = $obj;
}
}
}
$this->collUserRoles = $collUserRoles;
$this->collUserRolesPartial = false;
}
}
return $this->collUserRoles;
} | [
"public",
"function",
"getUserRoles",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"$",
"partial",
"=",
"$",
"this",
"->",
"collUserRolesPartial",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
"||",
"null",
"!==",
"$",
"criteria",
"||",
"$",
"partial",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
"&&",
"null",
"===",
"$",
"this",
"->",
"collUserRoles",
")",
"{",
"// return empty collection",
"$",
"this",
"->",
"initUserRoles",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collUserRoles",
"=",
"ChildUserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
"->",
"filterByUser",
"(",
"$",
"this",
")",
"->",
"find",
"(",
"$",
"con",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"criteria",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"collUserRolesPartial",
"&&",
"count",
"(",
"$",
"collUserRoles",
")",
")",
"{",
"$",
"this",
"->",
"initUserRoles",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"collUserRoles",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"collUserRoles",
"->",
"contains",
"(",
"$",
"obj",
")",
")",
"{",
"$",
"this",
"->",
"collUserRoles",
"->",
"append",
"(",
"$",
"obj",
")",
";",
"}",
"}",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"true",
";",
"}",
"return",
"$",
"collUserRoles",
";",
"}",
"if",
"(",
"$",
"partial",
"&&",
"$",
"this",
"->",
"collUserRoles",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collUserRoles",
"as",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"collUserRoles",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"collUserRoles",
"=",
"$",
"collUserRoles",
";",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"collUserRoles",
";",
"}"
]
| Gets an array of ChildUserRole objects which contain a foreign key that references this object.
If the $criteria is not null, it is used to always fetch the results from the database.
Otherwise the results are fetched from the database the first time, then cached.
Next time the same method is called without $criteria, the cached collection is returned.
If this ChildUser is new, it will return
an empty collection or the current collection; the criteria is ignored on a new object.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@return ObjectCollection|ChildUserRole[] List of ChildUserRole objects
@throws PropelException | [
"Gets",
"an",
"array",
"of",
"ChildUserRole",
"objects",
"which",
"contain",
"a",
"foreign",
"key",
"that",
"references",
"this",
"object",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1528-L1570 |
14,435 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.addUserRole | public function addUserRole(ChildUserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!$this->collUserRoles->contains($l)) {
$this->doAddUserRole($l);
}
return $this;
} | php | public function addUserRole(ChildUserRole $l)
{
if ($this->collUserRoles === null) {
$this->initUserRoles();
$this->collUserRolesPartial = true;
}
if (!$this->collUserRoles->contains($l)) {
$this->doAddUserRole($l);
}
return $this;
} | [
"public",
"function",
"addUserRole",
"(",
"ChildUserRole",
"$",
"l",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collUserRoles",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initUserRoles",
"(",
")",
";",
"$",
"this",
"->",
"collUserRolesPartial",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"collUserRoles",
"->",
"contains",
"(",
"$",
"l",
")",
")",
"{",
"$",
"this",
"->",
"doAddUserRole",
"(",
"$",
"l",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Method called to associate a ChildUserRole object to this object
through the ChildUserRole foreign key attribute.
@param ChildUserRole $l ChildUserRole
@return $this|\Alchemy\Component\Cerberus\Model\User The current object (for fluent API support) | [
"Method",
"called",
"to",
"associate",
"a",
"ChildUserRole",
"object",
"to",
"this",
"object",
"through",
"the",
"ChildUserRole",
"foreign",
"key",
"attribute",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1649-L1661 |
14,436 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.getUserRolesJoinRole | public function getUserRolesJoinRole(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildUserRoleQuery::create(null, $criteria);
$query->joinWith('Role', $joinBehavior);
return $this->getUserRoles($query, $con);
} | php | public function getUserRolesJoinRole(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildUserRoleQuery::create(null, $criteria);
$query->joinWith('Role', $joinBehavior);
return $this->getUserRoles($query, $con);
} | [
"public",
"function",
"getUserRolesJoinRole",
"(",
"Criteria",
"$",
"criteria",
"=",
"null",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
",",
"$",
"joinBehavior",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"$",
"query",
"=",
"ChildUserRoleQuery",
"::",
"create",
"(",
"null",
",",
"$",
"criteria",
")",
";",
"$",
"query",
"->",
"joinWith",
"(",
"'Role'",
",",
"$",
"joinBehavior",
")",
";",
"return",
"$",
"this",
"->",
"getUserRoles",
"(",
"$",
"query",
",",
"$",
"con",
")",
";",
"}"
]
| If this collection has already been initialized with
an identical criteria, it returns the collection.
Otherwise if this User is new, it will return
an empty collection; or if this User has previously
been saved, it will retrieve related UserRoles from storage.
This method is protected by default in order to keep the public
api reasonable. You can provide public methods for those you
actually need in User.
@param Criteria $criteria optional Criteria object to narrow the query
@param ConnectionInterface $con optional connection object
@param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN)
@return ObjectCollection|ChildUserRole[] List of ChildUserRole objects | [
"If",
"this",
"collection",
"has",
"already",
"been",
"initialized",
"with",
"an",
"identical",
"criteria",
"it",
"returns",
"the",
"collection",
".",
"Otherwise",
"if",
"this",
"User",
"is",
"new",
"it",
"will",
"return",
"an",
"empty",
"collection",
";",
"or",
"if",
"this",
"User",
"has",
"previously",
"been",
"saved",
"it",
"will",
"retrieve",
"related",
"UserRoles",
"from",
"storage",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1709-L1715 |
14,437 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.initRoles | public function initRoles()
{
$this->collRoles = new ObjectCollection();
$this->collRolesPartial = true;
$this->collRoles->setModel('\Alchemy\Component\Cerberus\Model\Role');
} | php | public function initRoles()
{
$this->collRoles = new ObjectCollection();
$this->collRolesPartial = true;
$this->collRoles->setModel('\Alchemy\Component\Cerberus\Model\Role');
} | [
"public",
"function",
"initRoles",
"(",
")",
"{",
"$",
"this",
"->",
"collRoles",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collRolesPartial",
"=",
"true",
";",
"$",
"this",
"->",
"collRoles",
"->",
"setModel",
"(",
"'\\Alchemy\\Component\\Cerberus\\Model\\Role'",
")",
";",
"}"
]
| Initializes the collRoles collection.
By default this just sets the collRoles collection to an empty collection (like clearRoles());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@return void | [
"Initializes",
"the",
"collRoles",
"collection",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1740-L1746 |
14,438 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.addRole | public function addRole(ChildRole $role)
{
if ($this->collRoles === null) {
$this->initRoles();
}
if (!$this->getRoles()->contains($role)) {
// only add it if the **same** object is not already associated
$this->collRoles->push($role);
$this->doAddRole($role);
}
return $this;
} | php | public function addRole(ChildRole $role)
{
if ($this->collRoles === null) {
$this->initRoles();
}
if (!$this->getRoles()->contains($role)) {
// only add it if the **same** object is not already associated
$this->collRoles->push($role);
$this->doAddRole($role);
}
return $this;
} | [
"public",
"function",
"addRole",
"(",
"ChildRole",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"collRoles",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"initRoles",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"getRoles",
"(",
")",
"->",
"contains",
"(",
"$",
"role",
")",
")",
"{",
"// only add it if the **same** object is not already associated",
"$",
"this",
"->",
"collRoles",
"->",
"push",
"(",
"$",
"role",
")",
";",
"$",
"this",
"->",
"doAddRole",
"(",
"$",
"role",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Associate a ChildRole to this object
through the user_role cross reference table.
@param ChildRole $role
@return ChildUser The current object (for fluent API support) | [
"Associate",
"a",
"ChildRole",
"to",
"this",
"object",
"through",
"the",
"user_role",
"cross",
"reference",
"table",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1884-L1897 |
14,439 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/User.php | User.removeRole | public function removeRole(ChildRole $role)
{
if ($this->getRoles()->contains($role)) { $userRole = new ChildUserRole();
$userRole->setRole($role);
if ($role->isUsersLoaded()) {
//remove the back reference if available
$role->getUsers()->removeObject($this);
}
$userRole->setUser($this);
$this->removeUserRole(clone $userRole);
$userRole->clear();
$this->collRoles->remove($this->collRoles->search($role));
if (null === $this->rolesScheduledForDeletion) {
$this->rolesScheduledForDeletion = clone $this->collRoles;
$this->rolesScheduledForDeletion->clear();
}
$this->rolesScheduledForDeletion->push($role);
}
return $this;
} | php | public function removeRole(ChildRole $role)
{
if ($this->getRoles()->contains($role)) { $userRole = new ChildUserRole();
$userRole->setRole($role);
if ($role->isUsersLoaded()) {
//remove the back reference if available
$role->getUsers()->removeObject($this);
}
$userRole->setUser($this);
$this->removeUserRole(clone $userRole);
$userRole->clear();
$this->collRoles->remove($this->collRoles->search($role));
if (null === $this->rolesScheduledForDeletion) {
$this->rolesScheduledForDeletion = clone $this->collRoles;
$this->rolesScheduledForDeletion->clear();
}
$this->rolesScheduledForDeletion->push($role);
}
return $this;
} | [
"public",
"function",
"removeRole",
"(",
"ChildRole",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getRoles",
"(",
")",
"->",
"contains",
"(",
"$",
"role",
")",
")",
"{",
"$",
"userRole",
"=",
"new",
"ChildUserRole",
"(",
")",
";",
"$",
"userRole",
"->",
"setRole",
"(",
"$",
"role",
")",
";",
"if",
"(",
"$",
"role",
"->",
"isUsersLoaded",
"(",
")",
")",
"{",
"//remove the back reference if available",
"$",
"role",
"->",
"getUsers",
"(",
")",
"->",
"removeObject",
"(",
"$",
"this",
")",
";",
"}",
"$",
"userRole",
"->",
"setUser",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"removeUserRole",
"(",
"clone",
"$",
"userRole",
")",
";",
"$",
"userRole",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"collRoles",
"->",
"remove",
"(",
"$",
"this",
"->",
"collRoles",
"->",
"search",
"(",
"$",
"role",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"rolesScheduledForDeletion",
")",
"{",
"$",
"this",
"->",
"rolesScheduledForDeletion",
"=",
"clone",
"$",
"this",
"->",
"collRoles",
";",
"$",
"this",
"->",
"rolesScheduledForDeletion",
"->",
"clear",
"(",
")",
";",
"}",
"$",
"this",
"->",
"rolesScheduledForDeletion",
"->",
"push",
"(",
"$",
"role",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Remove role of this object
through the user_role cross reference table.
@param ChildRole $role
@return ChildUser The current object (for fluent API support) | [
"Remove",
"role",
"of",
"this",
"object",
"through",
"the",
"user_role",
"cross",
"reference",
"table",
"."
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/User.php#L1931-L1957 |
14,440 | darkwebdesign/doctrine-unit-testing | src/Mocks/ConcurrentRegionMock.php | ConcurrentRegionMock.throwException | private function throwException($method)
{
if (isset($this->exceptions[$method]) && ! empty($this->exceptions[$method])) {
$exception = array_shift($this->exceptions[$method]);
if ($exception != null) {
throw $exception;
}
}
} | php | private function throwException($method)
{
if (isset($this->exceptions[$method]) && ! empty($this->exceptions[$method])) {
$exception = array_shift($this->exceptions[$method]);
if ($exception != null) {
throw $exception;
}
}
} | [
"private",
"function",
"throwException",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"method",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"method",
"]",
")",
")",
"{",
"$",
"exception",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"method",
"]",
")",
";",
"if",
"(",
"$",
"exception",
"!=",
"null",
")",
"{",
"throw",
"$",
"exception",
";",
"}",
"}",
"}"
]
| Dequeue an exception for a specific method invocation
@param string $method
@param mixed $default
@return mixed | [
"Dequeue",
"an",
"exception",
"for",
"a",
"specific",
"method",
"invocation"
]
| 0daf50359563bc0679925e573a7105d6cd57168a | https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/ConcurrentRegionMock.php#L45-L54 |
14,441 | darkwebdesign/doctrine-unit-testing | src/Mocks/ConcurrentRegionMock.php | ConcurrentRegionMock.setLock | public function setLock(CacheKey $key, Lock $lock)
{
$this->locks[$key->hash] = $lock;
} | php | public function setLock(CacheKey $key, Lock $lock)
{
$this->locks[$key->hash] = $lock;
} | [
"public",
"function",
"setLock",
"(",
"CacheKey",
"$",
"key",
",",
"Lock",
"$",
"lock",
")",
"{",
"$",
"this",
"->",
"locks",
"[",
"$",
"key",
"->",
"hash",
"]",
"=",
"$",
"lock",
";",
"}"
]
| Locks a specific cache entry
@param \Doctrine\ORM\Cache\CacheKey $key
@param \Doctrine\ORM\Cache\Lock $lock | [
"Locks",
"a",
"specific",
"cache",
"entry"
]
| 0daf50359563bc0679925e573a7105d6cd57168a | https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/ConcurrentRegionMock.php#L73-L76 |
14,442 | mythteam/yii2-schedule | src/Event.php | Event.emailOutput | public function emailOutput($address)
{
if (is_null($this->_output)
|| $this->_output == $this->getDefaultOutput()
) {
throw new InvalidCallException('Must direct output to file in order to email results.');
}
$address = is_array($address) ? $address : func_get_args();
return $this->then(function (Application $app) use ($address) {
$this->sendEmail($app->mailer, $address);
});
} | php | public function emailOutput($address)
{
if (is_null($this->_output)
|| $this->_output == $this->getDefaultOutput()
) {
throw new InvalidCallException('Must direct output to file in order to email results.');
}
$address = is_array($address) ? $address : func_get_args();
return $this->then(function (Application $app) use ($address) {
$this->sendEmail($app->mailer, $address);
});
} | [
"public",
"function",
"emailOutput",
"(",
"$",
"address",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_output",
")",
"||",
"$",
"this",
"->",
"_output",
"==",
"$",
"this",
"->",
"getDefaultOutput",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidCallException",
"(",
"'Must direct output to file in order to email results.'",
")",
";",
"}",
"$",
"address",
"=",
"is_array",
"(",
"$",
"address",
")",
"?",
"$",
"address",
":",
"func_get_args",
"(",
")",
";",
"return",
"$",
"this",
"->",
"then",
"(",
"function",
"(",
"Application",
"$",
"app",
")",
"use",
"(",
"$",
"address",
")",
"{",
"$",
"this",
"->",
"sendEmail",
"(",
"$",
"app",
"->",
"mailer",
",",
"$",
"address",
")",
";",
"}",
")",
";",
"}"
]
| Register the send email logic.
@param array $address
@return $this | [
"Register",
"the",
"send",
"email",
"logic",
"."
]
| 259db00e4f2a02619545166774081c60957c5faf | https://github.com/mythteam/yii2-schedule/blob/259db00e4f2a02619545166774081c60957c5faf/src/Event.php#L228-L240 |
14,443 | mythteam/yii2-schedule | src/Event.php | Event.buildCommand | public function buildCommand()
{
$command = $this->command . ' >> ' . $this->_output . ' 2>&1 &';
return $this->_user ? 'sudo -u ' . $this->_user . ' ' . $command : $command;
} | php | public function buildCommand()
{
$command = $this->command . ' >> ' . $this->_output . ' 2>&1 &';
return $this->_user ? 'sudo -u ' . $this->_user . ' ' . $command : $command;
} | [
"public",
"function",
"buildCommand",
"(",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"command",
".",
"' >> '",
".",
"$",
"this",
"->",
"_output",
".",
"' 2>&1 &'",
";",
"return",
"$",
"this",
"->",
"_user",
"?",
"'sudo -u '",
".",
"$",
"this",
"->",
"_user",
".",
"' '",
".",
"$",
"command",
":",
"$",
"command",
";",
"}"
]
| Build the execute command.
@return string | [
"Build",
"the",
"execute",
"command",
"."
]
| 259db00e4f2a02619545166774081c60957c5faf | https://github.com/mythteam/yii2-schedule/blob/259db00e4f2a02619545166774081c60957c5faf/src/Event.php#L620-L625 |
14,444 | mythteam/yii2-schedule | src/Event.php | Event.sendEmail | protected function sendEmail(MailerInterface $mailer, $address)
{
$message = $mailer->compose();
$message->setTextBody(file_get_contents($this->_output))
->setSubject($this->getEmailSubject())
->setTo($address);
$message->send();
} | php | protected function sendEmail(MailerInterface $mailer, $address)
{
$message = $mailer->compose();
$message->setTextBody(file_get_contents($this->_output))
->setSubject($this->getEmailSubject())
->setTo($address);
$message->send();
} | [
"protected",
"function",
"sendEmail",
"(",
"MailerInterface",
"$",
"mailer",
",",
"$",
"address",
")",
"{",
"$",
"message",
"=",
"$",
"mailer",
"->",
"compose",
"(",
")",
";",
"$",
"message",
"->",
"setTextBody",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"_output",
")",
")",
"->",
"setSubject",
"(",
"$",
"this",
"->",
"getEmailSubject",
"(",
")",
")",
"->",
"setTo",
"(",
"$",
"address",
")",
";",
"$",
"message",
"->",
"send",
"(",
")",
";",
"}"
]
| Send email logic.
@param MailerInterface $mailer
@param array $address | [
"Send",
"email",
"logic",
"."
]
| 259db00e4f2a02619545166774081c60957c5faf | https://github.com/mythteam/yii2-schedule/blob/259db00e4f2a02619545166774081c60957c5faf/src/Event.php#L633-L641 |
14,445 | activecollab/databasemigrations | src/Migrations.php | Migrations.getMigrationInstances | private function getMigrationInstances(array $migration_class_file_path_map)
{
$result = [];
foreach ($migration_class_file_path_map as $migration_class => $migration_file_path) {
if (is_file($migration_file_path)) {
require_once $migration_file_path;
if (class_exists($migration_class, false)) {
$reflection = new ReflectionClass($migration_class);
if ($reflection->implementsInterface(MigrationInterface::class) && !$reflection->isAbstract()) {
$result[$migration_class] = new $migration_class($this->connection, $this->log);
}
} else {
throw new RuntimeException("Migration class '$migration_class' not found");
}
} else {
throw new RuntimeException("File '$migration_file_path' not found");
}
}
return $result;
} | php | private function getMigrationInstances(array $migration_class_file_path_map)
{
$result = [];
foreach ($migration_class_file_path_map as $migration_class => $migration_file_path) {
if (is_file($migration_file_path)) {
require_once $migration_file_path;
if (class_exists($migration_class, false)) {
$reflection = new ReflectionClass($migration_class);
if ($reflection->implementsInterface(MigrationInterface::class) && !$reflection->isAbstract()) {
$result[$migration_class] = new $migration_class($this->connection, $this->log);
}
} else {
throw new RuntimeException("Migration class '$migration_class' not found");
}
} else {
throw new RuntimeException("File '$migration_file_path' not found");
}
}
return $result;
} | [
"private",
"function",
"getMigrationInstances",
"(",
"array",
"$",
"migration_class_file_path_map",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"migration_class_file_path_map",
"as",
"$",
"migration_class",
"=>",
"$",
"migration_file_path",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"migration_file_path",
")",
")",
"{",
"require_once",
"$",
"migration_file_path",
";",
"if",
"(",
"class_exists",
"(",
"$",
"migration_class",
",",
"false",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"migration_class",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"implementsInterface",
"(",
"MigrationInterface",
"::",
"class",
")",
"&&",
"!",
"$",
"reflection",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"result",
"[",
"$",
"migration_class",
"]",
"=",
"new",
"$",
"migration_class",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"log",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Migration class '$migration_class' not found\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"File '$migration_file_path' not found\"",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Return an array of MigrationInterface instances indexed by class name.
@param array $migration_class_file_path_map
@return MigrationInterface[] | [
"Return",
"an",
"array",
"of",
"MigrationInterface",
"instances",
"indexed",
"by",
"class",
"name",
"."
]
| ef91d5b5f74d79b4a75695393eb25c7c47dad093 | https://github.com/activecollab/databasemigrations/blob/ef91d5b5f74d79b4a75695393eb25c7c47dad093/src/Migrations.php#L123-L146 |
14,446 | activecollab/databasemigrations | src/Migrations.php | Migrations.getTableName | public function getTableName()
{
if ($this->table_exists === null && !in_array($this->table_name, $this->connection->getTableNames())) {
$this->connection->execute('CREATE TABLE ' . $this->connection->escapeTableName($this->table_name) . ' (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`executed_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `migration` (`migration`),
KEY `executed_on` (`executed_at`)
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;');
$this->table_exists = true;
}
return $this->table_name;
} | php | public function getTableName()
{
if ($this->table_exists === null && !in_array($this->table_name, $this->connection->getTableNames())) {
$this->connection->execute('CREATE TABLE ' . $this->connection->escapeTableName($this->table_name) . ' (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`executed_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `migration` (`migration`),
KEY `executed_on` (`executed_at`)
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;');
$this->table_exists = true;
}
return $this->table_name;
} | [
"public",
"function",
"getTableName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"table_exists",
"===",
"null",
"&&",
"!",
"in_array",
"(",
"$",
"this",
"->",
"table_name",
",",
"$",
"this",
"->",
"connection",
"->",
"getTableNames",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"execute",
"(",
"'CREATE TABLE '",
".",
"$",
"this",
"->",
"connection",
"->",
"escapeTableName",
"(",
"$",
"this",
"->",
"table_name",
")",
".",
"' (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,\n `executed_at` datetime NOT NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY `migration` (`migration`),\n KEY `executed_on` (`executed_at`)\n ) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;'",
")",
";",
"$",
"this",
"->",
"table_exists",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"table_name",
";",
"}"
]
| Return name of the table where we store info about executed migrations.
@return string | [
"Return",
"name",
"of",
"the",
"table",
"where",
"we",
"store",
"info",
"about",
"executed",
"migrations",
"."
]
| ef91d5b5f74d79b4a75695393eb25c7c47dad093 | https://github.com/activecollab/databasemigrations/blob/ef91d5b5f74d79b4a75695393eb25c7c47dad093/src/Migrations.php#L208-L224 |
14,447 | bfitech/zapcore | src/Logger.php | Logger.format | protected function format(
string $timestamp, string $levelstr, string $msg
) {
$fmt = "[%s] %s: %s\n";
return sprintf($fmt, $timestamp, $levelstr, $msg);
} | php | protected function format(
string $timestamp, string $levelstr, string $msg
) {
$fmt = "[%s] %s: %s\n";
return sprintf($fmt, $timestamp, $levelstr, $msg);
} | [
"protected",
"function",
"format",
"(",
"string",
"$",
"timestamp",
",",
"string",
"$",
"levelstr",
",",
"string",
"$",
"msg",
")",
"{",
"$",
"fmt",
"=",
"\"[%s] %s: %s\\n\"",
";",
"return",
"sprintf",
"(",
"$",
"fmt",
",",
"$",
"timestamp",
",",
"$",
"levelstr",
",",
"$",
"msg",
")",
";",
"}"
]
| Log line formatter.
Patch this to customize line format or add additional
information.
@param string $timestamp Timestamp, always in UTC ISO-8601.
@param string $levelstr String representation of current log
level, e.g. `DEB` for debug.
@param string $msg Error message.
@return string Formatted line. | [
"Log",
"line",
"formatter",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Logger.php#L64-L69 |
14,448 | bfitech/zapcore | src/Logger.php | Logger.one_line | private function one_line(string $msg) {
$msg = trim($msg);
$msg = str_replace([
"\t", "\n", "\r",
], [
'\t', '\n', '\r',
], $msg);
return preg_replace('! +!', ' ', $msg);
} | php | private function one_line(string $msg) {
$msg = trim($msg);
$msg = str_replace([
"\t", "\n", "\r",
], [
'\t', '\n', '\r',
], $msg);
return preg_replace('! +!', ' ', $msg);
} | [
"private",
"function",
"one_line",
"(",
"string",
"$",
"msg",
")",
"{",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"msg",
"=",
"str_replace",
"(",
"[",
"\"\\t\"",
",",
"\"\\n\"",
",",
"\"\\r\"",
",",
"]",
",",
"[",
"'\\t'",
",",
"'\\n'",
",",
"'\\r'",
",",
"]",
",",
"$",
"msg",
")",
";",
"return",
"preg_replace",
"(",
"'! +!'",
",",
"' '",
",",
"$",
"msg",
")",
";",
"}"
]
| Write lines as single line, with tab, CR and LF written
symbolically. | [
"Write",
"lines",
"as",
"single",
"line",
"with",
"tab",
"CR",
"and",
"LF",
"written",
"symbolically",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Logger.php#L75-L83 |
14,449 | bfitech/zapcore | src/Logger.php | Logger.write | private function write(string $levelstr, string $msg) {
$timestamp = gmdate(\DateTime::ATOM);
// @codeCoverageIgnoreStart
try {
// @codeCoverageIgnoreEnd
$msg = $this->one_line($msg);
$line = $this->format($timestamp, $levelstr, $msg);
fwrite($this->handle, $line);
// @codeCoverageIgnoreStart
} catch(\Exception $e) {
}
// @codeCoverageIgnoreEnd
} | php | private function write(string $levelstr, string $msg) {
$timestamp = gmdate(\DateTime::ATOM);
// @codeCoverageIgnoreStart
try {
// @codeCoverageIgnoreEnd
$msg = $this->one_line($msg);
$line = $this->format($timestamp, $levelstr, $msg);
fwrite($this->handle, $line);
// @codeCoverageIgnoreStart
} catch(\Exception $e) {
}
// @codeCoverageIgnoreEnd
} | [
"private",
"function",
"write",
"(",
"string",
"$",
"levelstr",
",",
"string",
"$",
"msg",
")",
"{",
"$",
"timestamp",
"=",
"gmdate",
"(",
"\\",
"DateTime",
"::",
"ATOM",
")",
";",
"// @codeCoverageIgnoreStart",
"try",
"{",
"// @codeCoverageIgnoreEnd",
"$",
"msg",
"=",
"$",
"this",
"->",
"one_line",
"(",
"$",
"msg",
")",
";",
"$",
"line",
"=",
"$",
"this",
"->",
"format",
"(",
"$",
"timestamp",
",",
"$",
"levelstr",
",",
"$",
"msg",
")",
";",
"fwrite",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"line",
")",
";",
"// @codeCoverageIgnoreStart",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"// @codeCoverageIgnoreEnd",
"}"
]
| Write to handle. | [
"Write",
"to",
"handle",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Logger.php#L88-L100 |
14,450 | phizzl/deployee | src/Bootstrap/Bootstrap.php | Bootstrap.bootstrap | public function bootstrap()
{
$this->registerBootstrapArguments();
$this->registerEventDispatcher();
$this->registerConfigLoader();
$this->registerConfig();
$this->registerPlugins();
$this->registerTaskDispatcherCollection();
$this->registerLogger();
// phs: Ensure plugin container is build an all plugins are initialized
$this->getContainer()->plugins();
$this->getContainer()
->events()
->dispatch(
BootstrapFinishedEvent::EVENT_NAME,
new BootstrapFinishedEvent($this->getContainer())
);
return $this->getContainer();
} | php | public function bootstrap()
{
$this->registerBootstrapArguments();
$this->registerEventDispatcher();
$this->registerConfigLoader();
$this->registerConfig();
$this->registerPlugins();
$this->registerTaskDispatcherCollection();
$this->registerLogger();
// phs: Ensure plugin container is build an all plugins are initialized
$this->getContainer()->plugins();
$this->getContainer()
->events()
->dispatch(
BootstrapFinishedEvent::EVENT_NAME,
new BootstrapFinishedEvent($this->getContainer())
);
return $this->getContainer();
} | [
"public",
"function",
"bootstrap",
"(",
")",
"{",
"$",
"this",
"->",
"registerBootstrapArguments",
"(",
")",
";",
"$",
"this",
"->",
"registerEventDispatcher",
"(",
")",
";",
"$",
"this",
"->",
"registerConfigLoader",
"(",
")",
";",
"$",
"this",
"->",
"registerConfig",
"(",
")",
";",
"$",
"this",
"->",
"registerPlugins",
"(",
")",
";",
"$",
"this",
"->",
"registerTaskDispatcherCollection",
"(",
")",
";",
"$",
"this",
"->",
"registerLogger",
"(",
")",
";",
"// phs: Ensure plugin container is build an all plugins are initialized",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"plugins",
"(",
")",
";",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"events",
"(",
")",
"->",
"dispatch",
"(",
"BootstrapFinishedEvent",
"::",
"EVENT_NAME",
",",
"new",
"BootstrapFinishedEvent",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"getContainer",
"(",
")",
";",
"}"
]
| Run bootstrap an register services to the DI container
@return Container | [
"Run",
"bootstrap",
"an",
"register",
"services",
"to",
"the",
"DI",
"container"
]
| def884e49608589d9594b8d538f3ec9aa0e25add | https://github.com/phizzl/deployee/blob/def884e49608589d9594b8d538f3ec9aa0e25add/src/Bootstrap/Bootstrap.php#L44-L65 |
14,451 | axelitus/php-base | src/BoolOr.php | BoolOr.val | public static function val($value1, $value2, $_ = null)
{
if (!static::is($value1) || !static::is($value2)) {
throw new \InvalidArgumentException("All parameters must be of type bool.");
}
$ret = ($value1 || $value2);
$args = array_slice(func_get_args(), 2);
while (!$ret && ($bool = array_shift($args)) !== null) {
if (!static::is($bool)) {
throw new \InvalidArgumentException("All parameters must be of type bool.");
}
$ret = ($ret || $bool);
}
return $ret;
} | php | public static function val($value1, $value2, $_ = null)
{
if (!static::is($value1) || !static::is($value2)) {
throw new \InvalidArgumentException("All parameters must be of type bool.");
}
$ret = ($value1 || $value2);
$args = array_slice(func_get_args(), 2);
while (!$ret && ($bool = array_shift($args)) !== null) {
if (!static::is($bool)) {
throw new \InvalidArgumentException("All parameters must be of type bool.");
}
$ret = ($ret || $bool);
}
return $ret;
} | [
"public",
"static",
"function",
"val",
"(",
"$",
"value1",
",",
"$",
"value2",
",",
"$",
"_",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value1",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"value2",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"All parameters must be of type bool.\"",
")",
";",
"}",
"$",
"ret",
"=",
"(",
"$",
"value1",
"||",
"$",
"value2",
")",
";",
"$",
"args",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"2",
")",
";",
"while",
"(",
"!",
"$",
"ret",
"&&",
"(",
"$",
"bool",
"=",
"array_shift",
"(",
"$",
"args",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"bool",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"All parameters must be of type bool.\"",
")",
";",
"}",
"$",
"ret",
"=",
"(",
"$",
"ret",
"||",
"$",
"bool",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Applies the OR operation to the given values.
The function is optimized to return early (if a true is found the function returns true immediately),
therefore we can't assume that all values had been tested for validity.
@param bool $value1 The left operand to apply the operation to.
@param bool $value2 The right operand to apply the operation to.
@param null $_ More values to apply the operation in cascade.
@return bool The result of applying the operation to the given values.
@throws \InvalidArgumentException
@SuppressWarnings(PHPMD.CamelCaseParameterName)
@SuppressWarnings(PHPMD.ShortVariable)
@SuppressWarnings(PHPMD.UnusedFormalParameter) | [
"Applies",
"the",
"OR",
"operation",
"to",
"the",
"given",
"values",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BoolOr.php#L43-L60 |
14,452 | pencepay/pencepay-php | lib/Pencepay/User.php | Pencepay_User.enable2FA | public static function enable2FA($userUid, $authenticationKey, $verificationCode) {
$request = array(
'authenticationKey' => $authenticationKey,
'verificationCode' => $verificationCode
);
return Pencepay_Util_HttpClient::postArray("/user/$userUid/tfa_enable", $request);
} | php | public static function enable2FA($userUid, $authenticationKey, $verificationCode) {
$request = array(
'authenticationKey' => $authenticationKey,
'verificationCode' => $verificationCode
);
return Pencepay_Util_HttpClient::postArray("/user/$userUid/tfa_enable", $request);
} | [
"public",
"static",
"function",
"enable2FA",
"(",
"$",
"userUid",
",",
"$",
"authenticationKey",
",",
"$",
"verificationCode",
")",
"{",
"$",
"request",
"=",
"array",
"(",
"'authenticationKey'",
"=>",
"$",
"authenticationKey",
",",
"'verificationCode'",
"=>",
"$",
"verificationCode",
")",
";",
"return",
"Pencepay_Util_HttpClient",
"::",
"postArray",
"(",
"\"/user/$userUid/tfa_enable\"",
",",
"$",
"request",
")",
";",
"}"
]
| Enables the two-factor authentication for this user.
@param string $userUid
@param string $authenticationKey
@param string $verificationCode
@return array | [
"Enables",
"the",
"two",
"-",
"factor",
"authentication",
"for",
"this",
"user",
"."
]
| fad91d56f3a39640ff6cb7e9d137d03a65cdd1cd | https://github.com/pencepay/pencepay-php/blob/fad91d56f3a39640ff6cb7e9d137d03a65cdd1cd/lib/Pencepay/User.php#L96-L102 |
14,453 | huasituo/hstcms | src/Providers/LibrariesServiceProvider.php | LibrariesServiceProvider.register | public function register()
{
$file = $this->app->make(Filesystem::class);
$path = realpath(__DIR__.'/../Libraries');
$libraries = $file->glob($path.'/*.php');
foreach ($libraries as $librarie) {
require_once($librarie);
}
$libraries2 = $file->glob($path.'/HuasituoApi/*.php');
foreach ($libraries2 as $librarie) {
require_once($librarie);
}
$libraries3 = $file->glob($path.'/HuasituoApi/Request/*.php');
foreach ($libraries3 as $librarie) {
require_once($librarie);
}
$fields = $file->glob($path.'/Fields/*.php');
foreach ($fields as $field) {
require_once($field);
}
$alipays = $file->glob($path.'/Alipay/*.php');
foreach ($alipays as $librarie) {
require_once($librarie);
}
} | php | public function register()
{
$file = $this->app->make(Filesystem::class);
$path = realpath(__DIR__.'/../Libraries');
$libraries = $file->glob($path.'/*.php');
foreach ($libraries as $librarie) {
require_once($librarie);
}
$libraries2 = $file->glob($path.'/HuasituoApi/*.php');
foreach ($libraries2 as $librarie) {
require_once($librarie);
}
$libraries3 = $file->glob($path.'/HuasituoApi/Request/*.php');
foreach ($libraries3 as $librarie) {
require_once($librarie);
}
$fields = $file->glob($path.'/Fields/*.php');
foreach ($fields as $field) {
require_once($field);
}
$alipays = $file->glob($path.'/Alipay/*.php');
foreach ($alipays as $librarie) {
require_once($librarie);
}
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Filesystem",
"::",
"class",
")",
";",
"$",
"path",
"=",
"realpath",
"(",
"__DIR__",
".",
"'/../Libraries'",
")",
";",
"$",
"libraries",
"=",
"$",
"file",
"->",
"glob",
"(",
"$",
"path",
".",
"'/*.php'",
")",
";",
"foreach",
"(",
"$",
"libraries",
"as",
"$",
"librarie",
")",
"{",
"require_once",
"(",
"$",
"librarie",
")",
";",
"}",
"$",
"libraries2",
"=",
"$",
"file",
"->",
"glob",
"(",
"$",
"path",
".",
"'/HuasituoApi/*.php'",
")",
";",
"foreach",
"(",
"$",
"libraries2",
"as",
"$",
"librarie",
")",
"{",
"require_once",
"(",
"$",
"librarie",
")",
";",
"}",
"$",
"libraries3",
"=",
"$",
"file",
"->",
"glob",
"(",
"$",
"path",
".",
"'/HuasituoApi/Request/*.php'",
")",
";",
"foreach",
"(",
"$",
"libraries3",
"as",
"$",
"librarie",
")",
"{",
"require_once",
"(",
"$",
"librarie",
")",
";",
"}",
"$",
"fields",
"=",
"$",
"file",
"->",
"glob",
"(",
"$",
"path",
".",
"'/Fields/*.php'",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"require_once",
"(",
"$",
"field",
")",
";",
"}",
"$",
"alipays",
"=",
"$",
"file",
"->",
"glob",
"(",
"$",
"path",
".",
"'/Alipay/*.php'",
")",
";",
"foreach",
"(",
"$",
"alipays",
"as",
"$",
"librarie",
")",
"{",
"require_once",
"(",
"$",
"librarie",
")",
";",
"}",
"}"
]
| Register the libraries services.
@return void | [
"Register",
"the",
"libraries",
"services",
"."
]
| 12819979289e58ce38e3e92540aeeb16e205e525 | https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/LibrariesServiceProvider.php#L29-L58 |
14,454 | e0ipso/drupal-unit-autoload | src/Discovery/PathFinderContrib.php | PathFinderContrib.isWantedContrib | protected function isWantedContrib(\SplFileInfo $dir) {
$info_file = $this->cleanDirPath($dir->getPathName()) . DIRECTORY_SEPARATOR . $this->moduleName . '.info';
return file_exists($info_file);
} | php | protected function isWantedContrib(\SplFileInfo $dir) {
$info_file = $this->cleanDirPath($dir->getPathName()) . DIRECTORY_SEPARATOR . $this->moduleName . '.info';
return file_exists($info_file);
} | [
"protected",
"function",
"isWantedContrib",
"(",
"\\",
"SplFileInfo",
"$",
"dir",
")",
"{",
"$",
"info_file",
"=",
"$",
"this",
"->",
"cleanDirPath",
"(",
"$",
"dir",
"->",
"getPathName",
"(",
")",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"moduleName",
".",
"'.info'",
";",
"return",
"file_exists",
"(",
"$",
"info_file",
")",
";",
"}"
]
| Checks if the passed directory is the contrib module we are looking for.
@param \SplFileInfo $dir
The info object about the directory.
@return bool
TRUE if the contrib is detected. FALSE otherwise. | [
"Checks",
"if",
"the",
"passed",
"directory",
"is",
"the",
"contrib",
"module",
"we",
"are",
"looking",
"for",
"."
]
| 7ce147b269c7333eca31e2cd04b736d6274b9cbf | https://github.com/e0ipso/drupal-unit-autoload/blob/7ce147b269c7333eca31e2cd04b736d6274b9cbf/src/Discovery/PathFinderContrib.php#L82-L85 |
14,455 | dantleech/glob | lib/DTL/Glob/GlobHelper.php | GlobHelper.isGlobbed | public function isGlobbed($string)
{
$segments = $this->parser->parse($string);
foreach ($segments as $segment) {
// if bitmask contains pattern
if ($segment[1] & SelectorParser::T_PATTERN) {
return true;
}
}
return false;
} | php | public function isGlobbed($string)
{
$segments = $this->parser->parse($string);
foreach ($segments as $segment) {
// if bitmask contains pattern
if ($segment[1] & SelectorParser::T_PATTERN) {
return true;
}
}
return false;
} | [
"public",
"function",
"isGlobbed",
"(",
"$",
"string",
")",
"{",
"$",
"segments",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"string",
")",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"segment",
")",
"{",
"// if bitmask contains pattern",
"if",
"(",
"$",
"segment",
"[",
"1",
"]",
"&",
"SelectorParser",
"::",
"T_PATTERN",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Return true if the given string is contains a glob pattern
@param string $string
@return boolean | [
"Return",
"true",
"if",
"the",
"given",
"string",
"is",
"contains",
"a",
"glob",
"pattern"
]
| 1f618e6b77a5de4c6b0538d82572fe19cbb1c446 | https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/GlobHelper.php#L31-L42 |
14,456 | mayoturis/properties-ini | src/FileLoader.php | FileLoader.load | public function load($fileName) {
if (!file_exists($fileName)) {
throw new \InvalidArgumentException('File ' . $fileName . ' does not exist');
}
$lines = $this->readLinesFromFile($fileName);
return $this->getArrayFromLines($lines);
} | php | public function load($fileName) {
if (!file_exists($fileName)) {
throw new \InvalidArgumentException('File ' . $fileName . ' does not exist');
}
$lines = $this->readLinesFromFile($fileName);
return $this->getArrayFromLines($lines);
} | [
"public",
"function",
"load",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'File '",
".",
"$",
"fileName",
".",
"' does not exist'",
")",
";",
"}",
"$",
"lines",
"=",
"$",
"this",
"->",
"readLinesFromFile",
"(",
"$",
"fileName",
")",
";",
"return",
"$",
"this",
"->",
"getArrayFromLines",
"(",
"$",
"lines",
")",
";",
"}"
]
| Returns array which consists of value array and map
@param string $fileName
@return array
@throws \Exception | [
"Returns",
"array",
"which",
"consists",
"of",
"value",
"array",
"and",
"map"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileLoader.php#L24-L32 |
14,457 | mayoturis/properties-ini | src/FileLoader.php | FileLoader.getArrayFromLines | public function getArrayFromLines(array $lines) {
$array = [];
$map = [];
$i = 1;
foreach ($lines as $line) {
if ($this->processor->isEmptyLine($line)) {
$map[$i] = ['type' => 'empty'];
} elseif ($this->processor->isCommentLine($line)) {
$map[$i] = ['type' => 'comment', 'value' => $line];
} else {
$keyValue = explode('=', $line, 2);
if (count($keyValue) < 2) {
throw new InvalidLineException('Invalid line in configuration file');
}
list($key, $value) = $keyValue;
$key = trim($key);
$array[$key] = $this->processValue($value);
$map[$i] = ['type' => 'value', 'key' => $key];
$map[$i]['info'] = $this->mapInfoForValue($value);
}
$i++;
}
return [$array,$map];
} | php | public function getArrayFromLines(array $lines) {
$array = [];
$map = [];
$i = 1;
foreach ($lines as $line) {
if ($this->processor->isEmptyLine($line)) {
$map[$i] = ['type' => 'empty'];
} elseif ($this->processor->isCommentLine($line)) {
$map[$i] = ['type' => 'comment', 'value' => $line];
} else {
$keyValue = explode('=', $line, 2);
if (count($keyValue) < 2) {
throw new InvalidLineException('Invalid line in configuration file');
}
list($key, $value) = $keyValue;
$key = trim($key);
$array[$key] = $this->processValue($value);
$map[$i] = ['type' => 'value', 'key' => $key];
$map[$i]['info'] = $this->mapInfoForValue($value);
}
$i++;
}
return [$array,$map];
} | [
"public",
"function",
"getArrayFromLines",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"$",
"map",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"1",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"processor",
"->",
"isEmptyLine",
"(",
"$",
"line",
")",
")",
"{",
"$",
"map",
"[",
"$",
"i",
"]",
"=",
"[",
"'type'",
"=>",
"'empty'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"processor",
"->",
"isCommentLine",
"(",
"$",
"line",
")",
")",
"{",
"$",
"map",
"[",
"$",
"i",
"]",
"=",
"[",
"'type'",
"=>",
"'comment'",
",",
"'value'",
"=>",
"$",
"line",
"]",
";",
"}",
"else",
"{",
"$",
"keyValue",
"=",
"explode",
"(",
"'='",
",",
"$",
"line",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keyValue",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"InvalidLineException",
"(",
"'Invalid line in configuration file'",
")",
";",
"}",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"$",
"keyValue",
";",
"$",
"key",
"=",
"trim",
"(",
"$",
"key",
")",
";",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"processValue",
"(",
"$",
"value",
")",
";",
"$",
"map",
"[",
"$",
"i",
"]",
"=",
"[",
"'type'",
"=>",
"'value'",
",",
"'key'",
"=>",
"$",
"key",
"]",
";",
"$",
"map",
"[",
"$",
"i",
"]",
"[",
"'info'",
"]",
"=",
"$",
"this",
"->",
"mapInfoForValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"i",
"++",
";",
"}",
"return",
"[",
"$",
"array",
",",
"$",
"map",
"]",
";",
"}"
]
| Creates value and map array from string lines
@param array $lines
@return array
@throws InvalidLineException | [
"Creates",
"value",
"and",
"map",
"array",
"from",
"string",
"lines"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileLoader.php#L41-L69 |
14,458 | mayoturis/properties-ini | src/FileLoader.php | FileLoader.processValue | public function processValue($value) {
$value = ltrim(rtrim($value));
if ($this->processor->isBool($value)) {
return $this->processor->getBool($value);
}
if ($this->processor->isNumber($value)) {
return $this->processor->getNumber($value);
}
if ($this->processor->isNull($value)) {
return null;
}
return $this->processor->getString($value);
} | php | public function processValue($value) {
$value = ltrim(rtrim($value));
if ($this->processor->isBool($value)) {
return $this->processor->getBool($value);
}
if ($this->processor->isNumber($value)) {
return $this->processor->getNumber($value);
}
if ($this->processor->isNull($value)) {
return null;
}
return $this->processor->getString($value);
} | [
"public",
"function",
"processValue",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"ltrim",
"(",
"rtrim",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"processor",
"->",
"isBool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processor",
"->",
"getBool",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"processor",
"->",
"isNumber",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"processor",
"->",
"getNumber",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"processor",
"->",
"isNull",
"(",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"processor",
"->",
"getString",
"(",
"$",
"value",
")",
";",
"}"
]
| Creates value from string
@param string $value
@return bool|number|null|string | [
"Creates",
"value",
"from",
"string"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileLoader.php#L77-L93 |
14,459 | andyvenus/form | src/FormHandler.php | FormHandler.getDefaultOptions | protected function getDefaultOptions(array $fields)
{
$fieldsUpdated = array();
foreach ($fields as $fieldName => $field) {
$fieldsUpdated[$fieldName] = $this->typeHandler->getDefaultOptions($field);
}
return $fieldsUpdated;
} | php | protected function getDefaultOptions(array $fields)
{
$fieldsUpdated = array();
foreach ($fields as $fieldName => $field) {
$fieldsUpdated[$fieldName] = $this->typeHandler->getDefaultOptions($field);
}
return $fieldsUpdated;
} | [
"protected",
"function",
"getDefaultOptions",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"fieldsUpdated",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"$",
"fieldsUpdated",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"typeHandler",
"->",
"getDefaultOptions",
"(",
"$",
"field",
")",
";",
"}",
"return",
"$",
"fieldsUpdated",
";",
"}"
]
| Get the default options for the fields for their type
@param $fields array An array of field data
@return array The fields, updated with default data | [
"Get",
"the",
"default",
"options",
"for",
"the",
"fields",
"for",
"their",
"type"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L197-L205 |
14,460 | andyvenus/form | src/FormHandler.php | FormHandler.setDefaultValues | public function setDefaultValues(array $defaultValues)
{
foreach ($defaultValues as $name => $value) {
if (isset($this->fields[$name])) {
$this->data[$name] = $value;
}
}
} | php | public function setDefaultValues(array $defaultValues)
{
foreach ($defaultValues as $name => $value) {
if (isset($this->fields[$name])) {
$this->data[$name] = $value;
}
}
} | [
"public",
"function",
"setDefaultValues",
"(",
"array",
"$",
"defaultValues",
")",
"{",
"foreach",
"(",
"$",
"defaultValues",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}"
]
| Set the default values of matching fields
@param array $defaultValues | [
"Set",
"the",
"default",
"values",
"of",
"matching",
"fields"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L222-L229 |
14,461 | andyvenus/form | src/FormHandler.php | FormHandler.bindEntity | public function bindEntity($entity, $fields = null, $validatable = true)
{
if ($this->submitted) {
throw new BadMethodCallException("Entities cannot be assigned after FormHandler::handleRequest has been called");
}
$this->entities[] = array('entity' => $entity, 'fields' => $fields, 'validatable' => $validatable);
if ($entity instanceof EntityInterface) {
$entityData = $entity->getFormData(array_keys($this->fields), $fields);
} else {
$entityData = $this->entityProcessor->getFromEntity($entity, array_keys($this->fields), $fields);
}
$entityData = $this->transformToFormData($entityData);
$this->data = array_replace_recursive($this->data, $entityData);
} | php | public function bindEntity($entity, $fields = null, $validatable = true)
{
if ($this->submitted) {
throw new BadMethodCallException("Entities cannot be assigned after FormHandler::handleRequest has been called");
}
$this->entities[] = array('entity' => $entity, 'fields' => $fields, 'validatable' => $validatable);
if ($entity instanceof EntityInterface) {
$entityData = $entity->getFormData(array_keys($this->fields), $fields);
} else {
$entityData = $this->entityProcessor->getFromEntity($entity, array_keys($this->fields), $fields);
}
$entityData = $this->transformToFormData($entityData);
$this->data = array_replace_recursive($this->data, $entityData);
} | [
"public",
"function",
"bindEntity",
"(",
"$",
"entity",
",",
"$",
"fields",
"=",
"null",
",",
"$",
"validatable",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"submitted",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"\"Entities cannot be assigned after FormHandler::handleRequest has been called\"",
")",
";",
"}",
"$",
"this",
"->",
"entities",
"[",
"]",
"=",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'fields'",
"=>",
"$",
"fields",
",",
"'validatable'",
"=>",
"$",
"validatable",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"entityData",
"=",
"$",
"entity",
"->",
"getFormData",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"fields",
")",
",",
"$",
"fields",
")",
";",
"}",
"else",
"{",
"$",
"entityData",
"=",
"$",
"this",
"->",
"entityProcessor",
"->",
"getFromEntity",
"(",
"$",
"entity",
",",
"array_keys",
"(",
"$",
"this",
"->",
"fields",
")",
",",
"$",
"fields",
")",
";",
"}",
"$",
"entityData",
"=",
"$",
"this",
"->",
"transformToFormData",
"(",
"$",
"entityData",
")",
";",
"$",
"this",
"->",
"data",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"entityData",
")",
";",
"}"
]
| Add an entity to the form. The entities values will be used to fill the form and the forms data
will be assigned to the entity when saveToEntities is called
@param $entity
@param null $fields
@param bool $validatable
@throws \Exception | [
"Add",
"an",
"entity",
"to",
"the",
"form",
".",
"The",
"entities",
"values",
"will",
"be",
"used",
"to",
"fill",
"the",
"form",
"and",
"the",
"forms",
"data",
"will",
"be",
"assigned",
"to",
"the",
"entity",
"when",
"saveToEntities",
"is",
"called"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L240-L257 |
14,462 | andyvenus/form | src/FormHandler.php | FormHandler.handleRequest | public function handleRequest($request = null)
{
$this->submitted = true;
$requestData = $this->requestHandler->handleRequest($this, $request);
$validRequestData = $this->checkFieldsSubmitted($this->fields, $requestData);
if ($this->submitted === true && !empty($validRequestData)) {
$this->data = $validRequestData;
$this->setRequiredFieldErrors();
}
else {
$this->submitted = false;
}
if (isset($this->restoreDataHandler)) {
if ($this->isSubmitted()) {
$this->restoreDataHandler->setRestorableData($this, $this->data, $request);
}
else {
$restoredData = $this->restoreDataHandler->restoreData($this, $request);
if (is_array($restoredData) && !empty($restoredData)) {
$this->data = $restoredData;
}
}
}
if (isset($this->eventDispatcher)) {
$event = new FormHandlerRequestEvent($this, $request, $this->data);
$this->eventDispatcher->dispatch('form_handler.request', $event);
$this->data = $event->getFormData();
}
} | php | public function handleRequest($request = null)
{
$this->submitted = true;
$requestData = $this->requestHandler->handleRequest($this, $request);
$validRequestData = $this->checkFieldsSubmitted($this->fields, $requestData);
if ($this->submitted === true && !empty($validRequestData)) {
$this->data = $validRequestData;
$this->setRequiredFieldErrors();
}
else {
$this->submitted = false;
}
if (isset($this->restoreDataHandler)) {
if ($this->isSubmitted()) {
$this->restoreDataHandler->setRestorableData($this, $this->data, $request);
}
else {
$restoredData = $this->restoreDataHandler->restoreData($this, $request);
if (is_array($restoredData) && !empty($restoredData)) {
$this->data = $restoredData;
}
}
}
if (isset($this->eventDispatcher)) {
$event = new FormHandlerRequestEvent($this, $request, $this->data);
$this->eventDispatcher->dispatch('form_handler.request', $event);
$this->data = $event->getFormData();
}
} | [
"public",
"function",
"handleRequest",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"submitted",
"=",
"true",
";",
"$",
"requestData",
"=",
"$",
"this",
"->",
"requestHandler",
"->",
"handleRequest",
"(",
"$",
"this",
",",
"$",
"request",
")",
";",
"$",
"validRequestData",
"=",
"$",
"this",
"->",
"checkFieldsSubmitted",
"(",
"$",
"this",
"->",
"fields",
",",
"$",
"requestData",
")",
";",
"if",
"(",
"$",
"this",
"->",
"submitted",
"===",
"true",
"&&",
"!",
"empty",
"(",
"$",
"validRequestData",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"validRequestData",
";",
"$",
"this",
"->",
"setRequiredFieldErrors",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"submitted",
"=",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"restoreDataHandler",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"setRestorableData",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"data",
",",
"$",
"request",
")",
";",
"}",
"else",
"{",
"$",
"restoredData",
"=",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"restoreData",
"(",
"$",
"this",
",",
"$",
"request",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"restoredData",
")",
"&&",
"!",
"empty",
"(",
"$",
"restoredData",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"restoredData",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"eventDispatcher",
")",
")",
"{",
"$",
"event",
"=",
"new",
"FormHandlerRequestEvent",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"this",
"->",
"data",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"'form_handler.request'",
",",
"$",
"event",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"event",
"->",
"getFormData",
"(",
")",
";",
"}",
"}"
]
| Use a request handler to get data from a request and store the values that match fields
in the form blueprint
@param null $request | [
"Use",
"a",
"request",
"handler",
"to",
"get",
"data",
"from",
"a",
"request",
"and",
"store",
"the",
"values",
"that",
"match",
"fields",
"in",
"the",
"form",
"blueprint"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L273-L307 |
14,463 | andyvenus/form | src/FormHandler.php | FormHandler.saveToEntities | public function saveToEntities()
{
$data = $this->transformFromFormData($this->data);
foreach ($this->entities as $entity) {
if ($entity['entity'] instanceof EntityInterface) {
$entity['entity']->setFormData($data, $entity['fields']);
} else {
$this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
}
}
} | php | public function saveToEntities()
{
$data = $this->transformFromFormData($this->data);
foreach ($this->entities as $entity) {
if ($entity['entity'] instanceof EntityInterface) {
$entity['entity']->setFormData($data, $entity['fields']);
} else {
$this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
}
}
} | [
"public",
"function",
"saveToEntities",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"transformFromFormData",
"(",
"$",
"this",
"->",
"data",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"[",
"'entity'",
"]",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"entity",
"[",
"'entity'",
"]",
"->",
"setFormData",
"(",
"$",
"data",
",",
"$",
"entity",
"[",
"'fields'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"entityProcessor",
"->",
"saveToEntity",
"(",
"$",
"entity",
"[",
"'entity'",
"]",
",",
"$",
"data",
",",
"$",
"entity",
"[",
"'fields'",
"]",
")",
";",
"}",
"}",
"}"
]
| Save the current form data to the assigned entities | [
"Save",
"the",
"current",
"form",
"data",
"to",
"the",
"assigned",
"entities"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L356-L367 |
14,464 | andyvenus/form | src/FormHandler.php | FormHandler.saveToAndGetClonedEntities | public function saveToAndGetClonedEntities()
{
$data = $this->transformFromFormData($this->data);
$cloned_entities = array();
foreach ($this->entities as $entity) {
$entity['entity'] = clone $entity['entity'];
$cloned_entities[] = $entity;
if ($entity['entity'] instanceof EntityInterface) {
$entity['entity']->setFormData($data, $entity['fields']);
} else {
$this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
}
}
return $cloned_entities;
} | php | public function saveToAndGetClonedEntities()
{
$data = $this->transformFromFormData($this->data);
$cloned_entities = array();
foreach ($this->entities as $entity) {
$entity['entity'] = clone $entity['entity'];
$cloned_entities[] = $entity;
if ($entity['entity'] instanceof EntityInterface) {
$entity['entity']->setFormData($data, $entity['fields']);
} else {
$this->entityProcessor->saveToEntity($entity['entity'], $data, $entity['fields']);
}
}
return $cloned_entities;
} | [
"public",
"function",
"saveToAndGetClonedEntities",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"transformFromFormData",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"cloned_entities",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"entity",
"[",
"'entity'",
"]",
"=",
"clone",
"$",
"entity",
"[",
"'entity'",
"]",
";",
"$",
"cloned_entities",
"[",
"]",
"=",
"$",
"entity",
";",
"if",
"(",
"$",
"entity",
"[",
"'entity'",
"]",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"entity",
"[",
"'entity'",
"]",
"->",
"setFormData",
"(",
"$",
"data",
",",
"$",
"entity",
"[",
"'fields'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"entityProcessor",
"->",
"saveToEntity",
"(",
"$",
"entity",
"[",
"'entity'",
"]",
",",
"$",
"data",
",",
"$",
"entity",
"[",
"'fields'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"cloned_entities",
";",
"}"
]
| Save the form data to cloned entities and retrieve them.
Useful for getting entities with the data assigned without affecting
the original entities
@return array | [
"Save",
"the",
"form",
"data",
"to",
"cloned",
"entities",
"and",
"retrieve",
"them",
"."
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L377-L394 |
14,465 | andyvenus/form | src/FormHandler.php | FormHandler.getProcessedFields | public function getProcessedFields()
{
$fields = array();
foreach ($this->fields as $fieldName => $field) {
$fields[$fieldName] = $this->getProcessedField($fieldName);
}
return $fields;
} | php | public function getProcessedFields()
{
$fields = array();
foreach ($this->fields as $fieldName => $field) {
$fields[$fieldName] = $this->getProcessedField($fieldName);
}
return $fields;
} | [
"public",
"function",
"getProcessedFields",
"(",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"field",
")",
"{",
"$",
"fields",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"this",
"->",
"getProcessedField",
"(",
"$",
"fieldName",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Process all fields and return them
@return array | [
"Process",
"all",
"fields",
"and",
"return",
"them"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L422-L430 |
14,466 | andyvenus/form | src/FormHandler.php | FormHandler.getProcessedField | public function getProcessedField($fieldName)
{
if (!isset($this->fields[$fieldName])) {
return false;
}
$field = $this->fields[$fieldName];
$field['has_error'] = $this->fieldHasError($fieldName);
return $this->typeHandler->makeView($field, $this->data, $this);
} | php | public function getProcessedField($fieldName)
{
if (!isset($this->fields[$fieldName])) {
return false;
}
$field = $this->fields[$fieldName];
$field['has_error'] = $this->fieldHasError($fieldName);
return $this->typeHandler->makeView($field, $this->data, $this);
} | [
"public",
"function",
"getProcessedField",
"(",
"$",
"fieldName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"field",
"=",
"$",
"this",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
";",
"$",
"field",
"[",
"'has_error'",
"]",
"=",
"$",
"this",
"->",
"fieldHasError",
"(",
"$",
"fieldName",
")",
";",
"return",
"$",
"this",
"->",
"typeHandler",
"->",
"makeView",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"data",
",",
"$",
"this",
")",
";",
"}"
]
| Process a field and return it
@param $fieldName
@return bool | [
"Process",
"a",
"field",
"and",
"return",
"it"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L438-L449 |
14,467 | andyvenus/form | src/FormHandler.php | FormHandler.fieldHasError | public function fieldHasError($fieldName)
{
foreach ($this->errors as $error) {
if ($error->getParam() == $fieldName) {
return true;
}
}
if (!$this->isSubmitted()) {
return false;
}
if (isset($this->validator) && $this->validator->fieldHasError($fieldName)) {
return true;
}
} | php | public function fieldHasError($fieldName)
{
foreach ($this->errors as $error) {
if ($error->getParam() == $fieldName) {
return true;
}
}
if (!$this->isSubmitted()) {
return false;
}
if (isset($this->validator) && $this->validator->fieldHasError($fieldName)) {
return true;
}
} | [
"public",
"function",
"fieldHasError",
"(",
"$",
"fieldName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"errors",
"as",
"$",
"error",
")",
"{",
"if",
"(",
"$",
"error",
"->",
"getParam",
"(",
")",
"==",
"$",
"fieldName",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"validator",
")",
"&&",
"$",
"this",
"->",
"validator",
"->",
"fieldHasError",
"(",
"$",
"fieldName",
")",
")",
"{",
"return",
"true",
";",
"}",
"}"
]
| Check if a field has an error
@param $fieldName
@return bool | [
"Check",
"if",
"a",
"field",
"has",
"an",
"error"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L457-L472 |
14,468 | andyvenus/form | src/FormHandler.php | FormHandler.hasFieldOfType | public function hasFieldOfType($fieldType)
{
foreach ($this->fields as $field) {
if ($field['type'] == $fieldType) {
return true;
}
}
return false;
} | php | public function hasFieldOfType($fieldType)
{
foreach ($this->fields as $field) {
if ($field['type'] == $fieldType) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFieldOfType",
"(",
"$",
"fieldType",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"[",
"'type'",
"]",
"==",
"$",
"fieldType",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Check if the form contains any fields of a certain type like "select" or "textarea"
@param $fieldType
@return bool | [
"Check",
"if",
"the",
"form",
"contains",
"any",
"fields",
"of",
"a",
"certain",
"type",
"like",
"select",
"or",
"textarea"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L480-L489 |
14,469 | andyvenus/form | src/FormHandler.php | FormHandler.getData | public function getData($name = null, $transform = true)
{
$data = $this->data;
if ($transform === true) {
$data = $this->transformFromFormData($this->data);
}
if ($name === null) {
return $data;
}
else {
if (isset($data[$name])) {
return $data[$name];
}
else {
return null;
}
}
} | php | public function getData($name = null, $transform = true)
{
$data = $this->data;
if ($transform === true) {
$data = $this->transformFromFormData($this->data);
}
if ($name === null) {
return $data;
}
else {
if (isset($data[$name])) {
return $data[$name];
}
else {
return null;
}
}
} | [
"public",
"function",
"getData",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"transform",
"=",
"true",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
";",
"if",
"(",
"$",
"transform",
"===",
"true",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"transformFromFormData",
"(",
"$",
"this",
"->",
"data",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"data",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}"
]
| Get the values of all the form fields or a single form field
@param null|string|int $name
@param bool $transform
@return mixed | [
"Get",
"the",
"values",
"of",
"all",
"the",
"form",
"fields",
"or",
"a",
"single",
"form",
"field"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L503-L521 |
14,470 | andyvenus/form | src/FormHandler.php | FormHandler.createView | public function createView()
{
if (!$this->formView) {
$this->formView = new FormView();
}
$this->formView->setFormBlueprint($this->form);
$this->formView->setFields($this->getProcessedFields());
$this->formView->setSections($this->form->getSections());
$this->formView->setMethod($this->getMethod());
$this->formView->setName($this->getName());
$this->formView->setEncoding($this->getEncoding());
$this->formView->setAction($this->getAction());
$this->formView->setSubmitted($this->isSubmitted());
$this->formView->setValid($this->isValid());
$this->formView->setErrors($this->getValidationErrors());
$this->formView->setShouldShowSuccessMessage($this->shouldShowSuccessMessage());
$this->formView->setSubmitButtonLabel($this->form->getSubmitButtonLabel());
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->cancelRestore($this);
}
return $this->formView;
} | php | public function createView()
{
if (!$this->formView) {
$this->formView = new FormView();
}
$this->formView->setFormBlueprint($this->form);
$this->formView->setFields($this->getProcessedFields());
$this->formView->setSections($this->form->getSections());
$this->formView->setMethod($this->getMethod());
$this->formView->setName($this->getName());
$this->formView->setEncoding($this->getEncoding());
$this->formView->setAction($this->getAction());
$this->formView->setSubmitted($this->isSubmitted());
$this->formView->setValid($this->isValid());
$this->formView->setErrors($this->getValidationErrors());
$this->formView->setShouldShowSuccessMessage($this->shouldShowSuccessMessage());
$this->formView->setSubmitButtonLabel($this->form->getSubmitButtonLabel());
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->cancelRestore($this);
}
return $this->formView;
} | [
"public",
"function",
"createView",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"formView",
")",
"{",
"$",
"this",
"->",
"formView",
"=",
"new",
"FormView",
"(",
")",
";",
"}",
"$",
"this",
"->",
"formView",
"->",
"setFormBlueprint",
"(",
"$",
"this",
"->",
"form",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setFields",
"(",
"$",
"this",
"->",
"getProcessedFields",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setSections",
"(",
"$",
"this",
"->",
"form",
"->",
"getSections",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setMethod",
"(",
"$",
"this",
"->",
"getMethod",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setEncoding",
"(",
"$",
"this",
"->",
"getEncoding",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setAction",
"(",
"$",
"this",
"->",
"getAction",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setSubmitted",
"(",
"$",
"this",
"->",
"isSubmitted",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setValid",
"(",
"$",
"this",
"->",
"isValid",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setErrors",
"(",
"$",
"this",
"->",
"getValidationErrors",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setShouldShowSuccessMessage",
"(",
"$",
"this",
"->",
"shouldShowSuccessMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"formView",
"->",
"setSubmitButtonLabel",
"(",
"$",
"this",
"->",
"form",
"->",
"getSubmitButtonLabel",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"restoreDataHandler",
")",
")",
"{",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"cancelRestore",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"formView",
";",
"}"
]
| Assign the form data to the view
@return FormViewInterface | [
"Assign",
"the",
"form",
"data",
"to",
"the",
"view"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L652-L676 |
14,471 | andyvenus/form | src/FormHandler.php | FormHandler.setValidator | public function setValidator(ValidatorExtensionInterface $validator)
{
$this->validator = $validator;
$this->validator->setFormHandler($this);
} | php | public function setValidator(ValidatorExtensionInterface $validator)
{
$this->validator = $validator;
$this->validator->setFormHandler($this);
} | [
"public",
"function",
"setValidator",
"(",
"ValidatorExtensionInterface",
"$",
"validator",
")",
"{",
"$",
"this",
"->",
"validator",
"=",
"$",
"validator",
";",
"$",
"this",
"->",
"validator",
"->",
"setFormHandler",
"(",
"$",
"this",
")",
";",
"}"
]
| Set a validator wrapped in a ValidatorExtension class
@param ValidatorExtensionInterface $validator | [
"Set",
"a",
"validator",
"wrapped",
"in",
"a",
"ValidatorExtension",
"class"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L683-L687 |
14,472 | andyvenus/form | src/FormHandler.php | FormHandler.isValid | public function isValid($scope = null, $options = null)
{
if (!$this->isSubmitted()) {
return false;
}
// Check for internal errors & validator errors
if ((isset($this->validator) && $this->validator->isValid($scope, $options) && empty($this->errors)) || (!isset($this->validator) && empty($this->errors))) {
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setValid($this);
}
return true;
}
else {
// There were errors, save them for the next request
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setRestorableErrors($this, $this->getValidationErrors());
}
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setInvalid($this);
}
return false;
}
} | php | public function isValid($scope = null, $options = null)
{
if (!$this->isSubmitted()) {
return false;
}
// Check for internal errors & validator errors
if ((isset($this->validator) && $this->validator->isValid($scope, $options) && empty($this->errors)) || (!isset($this->validator) && empty($this->errors))) {
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setValid($this);
}
return true;
}
else {
// There were errors, save them for the next request
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setRestorableErrors($this, $this->getValidationErrors());
}
if (isset($this->restoreDataHandler)) {
$this->restoreDataHandler->setInvalid($this);
}
return false;
}
} | [
"public",
"function",
"isValid",
"(",
"$",
"scope",
"=",
"null",
",",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Check for internal errors & validator errors",
"if",
"(",
"(",
"isset",
"(",
"$",
"this",
"->",
"validator",
")",
"&&",
"$",
"this",
"->",
"validator",
"->",
"isValid",
"(",
"$",
"scope",
",",
"$",
"options",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
")",
"||",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"validator",
")",
"&&",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"restoreDataHandler",
")",
")",
"{",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"setValid",
"(",
"$",
"this",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"// There were errors, save them for the next request",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"restoreDataHandler",
")",
")",
"{",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"setRestorableErrors",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"getValidationErrors",
"(",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"restoreDataHandler",
")",
")",
"{",
"$",
"this",
"->",
"restoreDataHandler",
"->",
"setInvalid",
"(",
"$",
"this",
")",
";",
"}",
"return",
"false",
";",
"}",
"}"
]
| Check if the form is valid using the validator if it is set and checking for any
custom errors. Will save data to entities.
@param null $scope
@param null $options
@return bool | [
"Check",
"if",
"the",
"form",
"is",
"valid",
"using",
"the",
"validator",
"if",
"it",
"is",
"set",
"and",
"checking",
"for",
"any",
"custom",
"errors",
".",
"Will",
"save",
"data",
"to",
"entities",
"."
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L713-L739 |
14,473 | andyvenus/form | src/FormHandler.php | FormHandler.setRequiredFieldErrors | protected function setRequiredFieldErrors($fields = null, $data = null)
{
if ($fields === null) {
$fields =& $this->fields;
}
if ($data === null) {
$data =& $this->data;
}
foreach ($fields as $field) {
if (isset($field['options']['required']) && $field['options']['required'] === true) {
if (!isset($data[ $field['name'] ]) || $data[ $field['name'] ] == null) {
if (isset($field['options']['label'])) {
$label = $field['options']['label'];
}
else {
$label = $field['name'];
}
$this->errors[] = new FormError($field['name'], "Field '{field_label}' must be set", true, array('field_label' => $label));
}
}
if (isset($field['fields'])) {
$this->setRequiredFieldErrors($field['fields'], $data[ $field['name'] ]);
}
}
} | php | protected function setRequiredFieldErrors($fields = null, $data = null)
{
if ($fields === null) {
$fields =& $this->fields;
}
if ($data === null) {
$data =& $this->data;
}
foreach ($fields as $field) {
if (isset($field['options']['required']) && $field['options']['required'] === true) {
if (!isset($data[ $field['name'] ]) || $data[ $field['name'] ] == null) {
if (isset($field['options']['label'])) {
$label = $field['options']['label'];
}
else {
$label = $field['name'];
}
$this->errors[] = new FormError($field['name'], "Field '{field_label}' must be set", true, array('field_label' => $label));
}
}
if (isset($field['fields'])) {
$this->setRequiredFieldErrors($field['fields'], $data[ $field['name'] ]);
}
}
} | [
"protected",
"function",
"setRequiredFieldErrors",
"(",
"$",
"fields",
"=",
"null",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fields",
"===",
"null",
")",
"{",
"$",
"fields",
"=",
"&",
"$",
"this",
"->",
"fields",
";",
"}",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"$",
"data",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"}",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'options'",
"]",
"[",
"'required'",
"]",
")",
"&&",
"$",
"field",
"[",
"'options'",
"]",
"[",
"'required'",
"]",
"===",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"[",
"'name'",
"]",
"]",
")",
"||",
"$",
"data",
"[",
"$",
"field",
"[",
"'name'",
"]",
"]",
"==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
")",
")",
"{",
"$",
"label",
"=",
"$",
"field",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
";",
"}",
"else",
"{",
"$",
"label",
"=",
"$",
"field",
"[",
"'name'",
"]",
";",
"}",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"new",
"FormError",
"(",
"$",
"field",
"[",
"'name'",
"]",
",",
"\"Field '{field_label}' must be set\"",
",",
"true",
",",
"array",
"(",
"'field_label'",
"=>",
"$",
"label",
")",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setRequiredFieldErrors",
"(",
"$",
"field",
"[",
"'fields'",
"]",
",",
"$",
"data",
"[",
"$",
"field",
"[",
"'name'",
"]",
"]",
")",
";",
"}",
"}",
"}"
]
| Check each field to see if they're required. If they have no data set, assign the error
@param null $fields
@param null $data | [
"Check",
"each",
"field",
"to",
"see",
"if",
"they",
"re",
"required",
".",
"If",
"they",
"have",
"no",
"data",
"set",
"assign",
"the",
"error"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L758-L785 |
14,474 | andyvenus/form | src/FormHandler.php | FormHandler.setError | public function setError($param, $message, $translate = false, $translationParams = array())
{
$this->errors[] = new FormError($param, $message, $translate, $translationParams);
// Call isValid to update valid status in restore data handlers
$this->isValid();
} | php | public function setError($param, $message, $translate = false, $translationParams = array())
{
$this->errors[] = new FormError($param, $message, $translate, $translationParams);
// Call isValid to update valid status in restore data handlers
$this->isValid();
} | [
"public",
"function",
"setError",
"(",
"$",
"param",
",",
"$",
"message",
",",
"$",
"translate",
"=",
"false",
",",
"$",
"translationParams",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"new",
"FormError",
"(",
"$",
"param",
",",
"$",
"message",
",",
"$",
"translate",
",",
"$",
"translationParams",
")",
";",
"// Call isValid to update valid status in restore data handlers",
"$",
"this",
"->",
"isValid",
"(",
")",
";",
"}"
]
| Set a custom error on the form
@param $param
@param $message
@param bool|false $translate
@param array $translationParams | [
"Set",
"a",
"custom",
"error",
"on",
"the",
"form"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L795-L801 |
14,475 | andyvenus/form | src/FormHandler.php | FormHandler.addCustomErrors | public function addCustomErrors($errors)
{
if ($errors) {
foreach ($errors as $error) {
if (!is_a($error, 'AV\Form\FormError')) {
throw new InvalidArgumentException('Custom errors must be AV\Form\FormError objects');
}
else {
$this->errors[] = $error;
}
}
}
// Call isValid to update valid status in restore data handlers
$this->isValid();
} | php | public function addCustomErrors($errors)
{
if ($errors) {
foreach ($errors as $error) {
if (!is_a($error, 'AV\Form\FormError')) {
throw new InvalidArgumentException('Custom errors must be AV\Form\FormError objects');
}
else {
$this->errors[] = $error;
}
}
}
// Call isValid to update valid status in restore data handlers
$this->isValid();
} | [
"public",
"function",
"addCustomErrors",
"(",
"$",
"errors",
")",
"{",
"if",
"(",
"$",
"errors",
")",
"{",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"error",
",",
"'AV\\Form\\FormError'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Custom errors must be AV\\Form\\FormError objects'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errors",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"}",
"}",
"// Call isValid to update valid status in restore data handlers",
"$",
"this",
"->",
"isValid",
"(",
")",
";",
"}"
]
| Add custom errors to the form. Must be an array of FormError objects
@param $errors FormError[]
@throws InvalidArgumentException | [
"Add",
"custom",
"errors",
"to",
"the",
"form",
".",
"Must",
"be",
"an",
"array",
"of",
"FormError",
"objects"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L809-L824 |
14,476 | andyvenus/form | src/FormHandler.php | FormHandler.getValidationErrors | public function getValidationErrors()
{
$errors = $this->errors;
if (isset($this->validator)) {
$validator_errors = $this->validator->getErrors();
$errors = array_merge($errors, $validator_errors);
}
return $errors;
} | php | public function getValidationErrors()
{
$errors = $this->errors;
if (isset($this->validator)) {
$validator_errors = $this->validator->getErrors();
$errors = array_merge($errors, $validator_errors);
}
return $errors;
} | [
"public",
"function",
"getValidationErrors",
"(",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"errors",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"validator",
")",
")",
"{",
"$",
"validator_errors",
"=",
"$",
"this",
"->",
"validator",
"->",
"getErrors",
"(",
")",
";",
"$",
"errors",
"=",
"array_merge",
"(",
"$",
"errors",
",",
"$",
"validator_errors",
")",
";",
"}",
"return",
"$",
"errors",
";",
"}"
]
| Get the errors from the validator
@return mixed | [
"Get",
"the",
"errors",
"from",
"the",
"validator"
]
| fde9d7e1741a707028aec4fd55c3568802df3708 | https://github.com/andyvenus/form/blob/fde9d7e1741a707028aec4fd55c3568802df3708/src/FormHandler.php#L831-L841 |
14,477 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtMedia/MediaQuery.php | MediaQuery.setType | public function setType($type)
{
if (is_string($type)) {
if (in_array($type, [
self::TYPE_ALL, self::TYPE_PRINT, self::TYPE_SCREEN, self::TYPE_SPEECH,
self::TYPE_AURAL, self::TYPE_BRAILLE, self::TYPE_EMBOSSED, self::TYPE_HANDHELD,
self::TYPE_PROJECTION, self::TYPE_TTY, self::TYPE_TV
])) {
$this->type = $type;
return $this;
} else {
// Invalid type values have to be handled as "not all"
// @see: http://dev.w3.org/csswg/mediaqueries-4/#error-handling
$this->type = self::TYPE_ALL;
$this->setIsNot(true);
$this->setIsOnly(false);
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($type). "' for argument 'type' given."
);
}
} | php | public function setType($type)
{
if (is_string($type)) {
if (in_array($type, [
self::TYPE_ALL, self::TYPE_PRINT, self::TYPE_SCREEN, self::TYPE_SPEECH,
self::TYPE_AURAL, self::TYPE_BRAILLE, self::TYPE_EMBOSSED, self::TYPE_HANDHELD,
self::TYPE_PROJECTION, self::TYPE_TTY, self::TYPE_TV
])) {
$this->type = $type;
return $this;
} else {
// Invalid type values have to be handled as "not all"
// @see: http://dev.w3.org/csswg/mediaqueries-4/#error-handling
$this->type = self::TYPE_ALL;
$this->setIsNot(true);
$this->setIsOnly(false);
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($type). "' for argument 'type' given."
);
}
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"[",
"self",
"::",
"TYPE_ALL",
",",
"self",
"::",
"TYPE_PRINT",
",",
"self",
"::",
"TYPE_SCREEN",
",",
"self",
"::",
"TYPE_SPEECH",
",",
"self",
"::",
"TYPE_AURAL",
",",
"self",
"::",
"TYPE_BRAILLE",
",",
"self",
"::",
"TYPE_EMBOSSED",
",",
"self",
"::",
"TYPE_HANDHELD",
",",
"self",
"::",
"TYPE_PROJECTION",
",",
"self",
"::",
"TYPE_TTY",
",",
"self",
"::",
"TYPE_TV",
"]",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}",
"else",
"{",
"// Invalid type values have to be handled as \"not all\"",
"// @see: http://dev.w3.org/csswg/mediaqueries-4/#error-handling",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"TYPE_ALL",
";",
"$",
"this",
"->",
"setIsNot",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setIsOnly",
"(",
"false",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"type",
")",
".",
"\"' for argument 'type' given.\"",
")",
";",
"}",
"}"
]
| Sets the media type.
@param string $type
@return $this | [
"Sets",
"the",
"media",
"type",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtMedia/MediaQuery.php#L55-L78 |
14,478 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtMedia/MediaQuery.php | MediaQuery.addCondition | public function addCondition(ConditionAbstract $condition)
{
if ($condition instanceof MediaCondition) {
$this->conditions[] = $condition;
} else {
throw new \InvalidArgumentException(
"Invalid condition instance. Instance of 'MediaCondition' expected."
);
}
return $this;
} | php | public function addCondition(ConditionAbstract $condition)
{
if ($condition instanceof MediaCondition) {
$this->conditions[] = $condition;
} else {
throw new \InvalidArgumentException(
"Invalid condition instance. Instance of 'MediaCondition' expected."
);
}
return $this;
} | [
"public",
"function",
"addCondition",
"(",
"ConditionAbstract",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"condition",
"instanceof",
"MediaCondition",
")",
"{",
"$",
"this",
"->",
"conditions",
"[",
"]",
"=",
"$",
"condition",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid condition instance. Instance of 'MediaCondition' expected.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds a media rule condition.
@param MediaCondition $condition
@return $this | [
"Adds",
"a",
"media",
"rule",
"condition",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtMedia/MediaQuery.php#L96-L107 |
14,479 | vcn/enum | src/Enum.php | Enum.byName | final public static function byName($name)
{
$instances = &static::getInstances();
if (!array_key_exists($name, $instances)) {
$instances[$name] = new static($name);
}
return $instances[$name];
} | php | final public static function byName($name)
{
$instances = &static::getInstances();
if (!array_key_exists($name, $instances)) {
$instances[$name] = new static($name);
}
return $instances[$name];
} | [
"final",
"public",
"static",
"function",
"byName",
"(",
"$",
"name",
")",
"{",
"$",
"instances",
"=",
"&",
"static",
"::",
"getInstances",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"instances",
")",
")",
"{",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"static",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
]
| Attempts to instantiate an Enum from a label name.
For example:
```
Fruit::byName('APPLE'); // Fruit::APPLE()
Fruit::byName('BANANA'); // Fruit::BANANA()
Fruit::byName('UNKNOWN'); // exception
```
@param string $name
@return static
@throws Enum\Exception\InvalidInstance | [
"Attempts",
"to",
"instantiate",
"an",
"Enum",
"from",
"a",
"label",
"name",
"."
]
| ced38687b6140858956778140915d5d5a6397f23 | https://github.com/vcn/enum/blob/ced38687b6140858956778140915d5d5a6397f23/src/Enum.php#L67-L76 |
14,480 | vcn/enum | src/Enum.php | Enum.getAllInstances | public static function getAllInstances()
{
try {
$instances = array();
foreach (static::getAllNames() as $name) {
$instances[] = static::byName($name);
}
return $instances;
} catch (Enum\Exception\InvalidInstance $e) {
throw new LogicException("All valid names should produce valid instances?");
}
} | php | public static function getAllInstances()
{
try {
$instances = array();
foreach (static::getAllNames() as $name) {
$instances[] = static::byName($name);
}
return $instances;
} catch (Enum\Exception\InvalidInstance $e) {
throw new LogicException("All valid names should produce valid instances?");
}
} | [
"public",
"static",
"function",
"getAllInstances",
"(",
")",
"{",
"try",
"{",
"$",
"instances",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"static",
"::",
"getAllNames",
"(",
")",
"as",
"$",
"name",
")",
"{",
"$",
"instances",
"[",
"]",
"=",
"static",
"::",
"byName",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"instances",
";",
"}",
"catch",
"(",
"Enum",
"\\",
"Exception",
"\\",
"InvalidInstance",
"$",
"e",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"All valid names should produce valid instances?\"",
")",
";",
"}",
"}"
]
| Gets an array of all possible instances.
<br/>
For example:
<br/>
```
Fruit::getAllInstances(); // [Fruit::APPLE(), Fruit::BANANA()]
```
@return static[] | [
"Gets",
"an",
"array",
"of",
"all",
"possible",
"instances",
"."
]
| ced38687b6140858956778140915d5d5a6397f23 | https://github.com/vcn/enum/blob/ced38687b6140858956778140915d5d5a6397f23/src/Enum.php#L114-L127 |
14,481 | vcn/enum | src/Enum.php | Enum.getAllNames | public static function getAllNames()
{
$className = get_called_class();
if (!array_key_exists($className, self::$constantsArray)) {
try {
$class = new ReflectionClass($className);
} catch (ReflectionException $e) {
throw new RuntimeException($e->getMessage(), (int)$e->getCode(), $e);
}
self::$constantsArray[$className] = array_keys($class->getConstants());
}
return self::$constantsArray[$className];
} | php | public static function getAllNames()
{
$className = get_called_class();
if (!array_key_exists($className, self::$constantsArray)) {
try {
$class = new ReflectionClass($className);
} catch (ReflectionException $e) {
throw new RuntimeException($e->getMessage(), (int)$e->getCode(), $e);
}
self::$constantsArray[$className] = array_keys($class->getConstants());
}
return self::$constantsArray[$className];
} | [
"public",
"static",
"function",
"getAllNames",
"(",
")",
"{",
"$",
"className",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"className",
",",
"self",
"::",
"$",
"constantsArray",
")",
")",
"{",
"try",
"{",
"$",
"class",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"}",
"catch",
"(",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"(",
"int",
")",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"self",
"::",
"$",
"constantsArray",
"[",
"$",
"className",
"]",
"=",
"array_keys",
"(",
"$",
"class",
"->",
"getConstants",
"(",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"constantsArray",
"[",
"$",
"className",
"]",
";",
"}"
]
| Gets an array of all possible instances' label names.
<br/>
For example:
<br/>
```
Fruit::getAllNames(); // ['APPLE', 'BANANA']
```
@return string[] | [
"Gets",
"an",
"array",
"of",
"all",
"possible",
"instances",
"label",
"names",
"."
]
| ced38687b6140858956778140915d5d5a6397f23 | https://github.com/vcn/enum/blob/ced38687b6140858956778140915d5d5a6397f23/src/Enum.php#L158-L173 |
14,482 | vcn/enum | src/Enum.php | Enum.equals | final public function equals(Enum $b)
{
$aClass = get_class($this);
$bClass = get_class($b);
if ($aClass !== $bClass) {
throw new InvalidArgumentException("Unexpected type {$bClass} is not of type {$aClass}.");
}
return $b->getName() === $this->getName();
} | php | final public function equals(Enum $b)
{
$aClass = get_class($this);
$bClass = get_class($b);
if ($aClass !== $bClass) {
throw new InvalidArgumentException("Unexpected type {$bClass} is not of type {$aClass}.");
}
return $b->getName() === $this->getName();
} | [
"final",
"public",
"function",
"equals",
"(",
"Enum",
"$",
"b",
")",
"{",
"$",
"aClass",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"bClass",
"=",
"get_class",
"(",
"$",
"b",
")",
";",
"if",
"(",
"$",
"aClass",
"!==",
"$",
"bClass",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexpected type {$bClass} is not of type {$aClass}.\"",
")",
";",
"}",
"return",
"$",
"b",
"->",
"getName",
"(",
")",
"===",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"}"
]
| Only two Enums of the same type can be compared.
They are equal if their label is the same.
<br/>
For example:
<br/>
```
Fruit::APPLE()->equals(Fruit::BANANA()); // false
Fruit::APPLE()->equals(Fruit::APPLE()); // true
Fruit::APPLE()->equals(VEGETABLE::SPINACH()); // exception
```
@param Enum $b
@return bool
@throws InvalidArgumentException If $b is not of the same type as this Enum. | [
"Only",
"two",
"Enums",
"of",
"the",
"same",
"type",
"can",
"be",
"compared",
".",
"They",
"are",
"equal",
"if",
"their",
"label",
"is",
"the",
"same",
"."
]
| ced38687b6140858956778140915d5d5a6397f23 | https://github.com/vcn/enum/blob/ced38687b6140858956778140915d5d5a6397f23/src/Enum.php#L320-L330 |
14,483 | fuzz-productions/laravel-api-data | src/Transformations/TransformationFactory.php | TransformationFactory.resourceWith | public function resourceWith($entity, $transformer, $key = null): TransformationFactory
{
// if collection, paginator, or array with first value being an array use collection resource.
if ((is_array($entity) && isset($entity[0]) && is_array($entity[0])) || $entity instanceof LaravelCollection || $entity instanceof LengthAwarePaginator) {
return $this->collectionWith($entity, $transformer, $key);
}
return $this->itemWith($entity, $transformer, $key);
} | php | public function resourceWith($entity, $transformer, $key = null): TransformationFactory
{
// if collection, paginator, or array with first value being an array use collection resource.
if ((is_array($entity) && isset($entity[0]) && is_array($entity[0])) || $entity instanceof LaravelCollection || $entity instanceof LengthAwarePaginator) {
return $this->collectionWith($entity, $transformer, $key);
}
return $this->itemWith($entity, $transformer, $key);
} | [
"public",
"function",
"resourceWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
"=",
"null",
")",
":",
"TransformationFactory",
"{",
"// if collection, paginator, or array with first value being an array use collection resource.",
"if",
"(",
"(",
"is_array",
"(",
"$",
"entity",
")",
"&&",
"isset",
"(",
"$",
"entity",
"[",
"0",
"]",
")",
"&&",
"is_array",
"(",
"$",
"entity",
"[",
"0",
"]",
")",
")",
"||",
"$",
"entity",
"instanceof",
"LaravelCollection",
"||",
"$",
"entity",
"instanceof",
"LengthAwarePaginator",
")",
"{",
"return",
"$",
"this",
"->",
"collectionWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"itemWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
")",
";",
"}"
]
| Adds data and transformer, and chooses whether to use the Item or Collection Resource
based on what's most suitable for the data passed in.
@param mixed $entity
@param TransformerAbstract|callable $transformer
@param null|mixed $key
@return \Fuzz\Data\Transformations\TransformationFactory | [
"Adds",
"data",
"and",
"transformer",
"and",
"chooses",
"whether",
"to",
"use",
"the",
"Item",
"or",
"Collection",
"Resource",
"based",
"on",
"what",
"s",
"most",
"suitable",
"for",
"the",
"data",
"passed",
"in",
"."
]
| 25e181860d2f269b3b212195944c2bca95b411bb | https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/TransformationFactory.php#L101-L109 |
14,484 | fuzz-productions/laravel-api-data | src/Transformations/TransformationFactory.php | TransformationFactory.collectionWith | public function collectionWith($entity, $transformer, $key = null): TransformationFactory
{
$this->entity = $entity;
$this->transformer = $transformer;
$this->resource = new Collection($entity, $transformer, $key);
return $this;
} | php | public function collectionWith($entity, $transformer, $key = null): TransformationFactory
{
$this->entity = $entity;
$this->transformer = $transformer;
$this->resource = new Collection($entity, $transformer, $key);
return $this;
} | [
"public",
"function",
"collectionWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
"=",
"null",
")",
":",
"TransformationFactory",
"{",
"$",
"this",
"->",
"entity",
"=",
"$",
"entity",
";",
"$",
"this",
"->",
"transformer",
"=",
"$",
"transformer",
";",
"$",
"this",
"->",
"resource",
"=",
"new",
"Collection",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Uses a Collection resource on the data and transformer passed in.
@param mixed $entity
@param TransformerAbstract|callable $transformer
@param null|mixed $key
@return \Fuzz\Data\Transformations\TransformationFactory | [
"Uses",
"a",
"Collection",
"resource",
"on",
"the",
"data",
"and",
"transformer",
"passed",
"in",
"."
]
| 25e181860d2f269b3b212195944c2bca95b411bb | https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/TransformationFactory.php#L120-L127 |
14,485 | fuzz-productions/laravel-api-data | src/Transformations/TransformationFactory.php | TransformationFactory.itemWith | public function itemWith($entity, $transformer, $key = null): TransformationFactory
{
$this->entity = $entity;
$this->transformer = $transformer;
$this->resource = new Item($entity, $transformer, $key);
return $this;
} | php | public function itemWith($entity, $transformer, $key = null): TransformationFactory
{
$this->entity = $entity;
$this->transformer = $transformer;
$this->resource = new Item($entity, $transformer, $key);
return $this;
} | [
"public",
"function",
"itemWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
"=",
"null",
")",
":",
"TransformationFactory",
"{",
"$",
"this",
"->",
"entity",
"=",
"$",
"entity",
";",
"$",
"this",
"->",
"transformer",
"=",
"$",
"transformer",
";",
"$",
"this",
"->",
"resource",
"=",
"new",
"Item",
"(",
"$",
"entity",
",",
"$",
"transformer",
",",
"$",
"key",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Uses an Item resource on the data and transformer passed in.
@param mixed $entity
@param TransformerAbstract|callable $transformer
@param null|mixed $key
@return \Fuzz\Data\Transformations\TransformationFactory | [
"Uses",
"an",
"Item",
"resource",
"on",
"the",
"data",
"and",
"transformer",
"passed",
"in",
"."
]
| 25e181860d2f269b3b212195944c2bca95b411bb | https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/TransformationFactory.php#L138-L145 |
14,486 | fuzz-productions/laravel-api-data | src/Transformations/TransformationFactory.php | TransformationFactory.serialize | public function serialize($serializer = ApiDataSerializer::class): array
{
if (! is_a($serializer, SerializerAbstract::class, true)) {
throw new \InvalidArgumentException(
sprintf('The serializer must either be an instance,
or string representation of %s. The passed value %s is neither.',
SerializerAbstract::class,
$serializer
)
);
}
$this->serializer = is_string($serializer) ? new $serializer : $serializer;
$this->manager->setSerializer($this->serializer);
return $this->manager->createData($this->resource)->toArray();
} | php | public function serialize($serializer = ApiDataSerializer::class): array
{
if (! is_a($serializer, SerializerAbstract::class, true)) {
throw new \InvalidArgumentException(
sprintf('The serializer must either be an instance,
or string representation of %s. The passed value %s is neither.',
SerializerAbstract::class,
$serializer
)
);
}
$this->serializer = is_string($serializer) ? new $serializer : $serializer;
$this->manager->setSerializer($this->serializer);
return $this->manager->createData($this->resource)->toArray();
} | [
"public",
"function",
"serialize",
"(",
"$",
"serializer",
"=",
"ApiDataSerializer",
"::",
"class",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"serializer",
",",
"SerializerAbstract",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The serializer must either be an instance,\n\t\t\t\tor string representation of %s. The passed value %s is neither.'",
",",
"SerializerAbstract",
"::",
"class",
",",
"$",
"serializer",
")",
")",
";",
"}",
"$",
"this",
"->",
"serializer",
"=",
"is_string",
"(",
"$",
"serializer",
")",
"?",
"new",
"$",
"serializer",
":",
"$",
"serializer",
";",
"$",
"this",
"->",
"manager",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"serializer",
")",
";",
"return",
"$",
"this",
"->",
"manager",
"->",
"createData",
"(",
"$",
"this",
"->",
"resource",
")",
"->",
"toArray",
"(",
")",
";",
"}"
]
| Completes the the transformation and serialization flow, returning the data.
This could be thought of as a `flush` method.
// @TODO it does too much currently. toArray is really the `flush` method and should be moved into it's own
method.
@param \League\Fractal\Serializer\SerializerAbstract|string $serializer
@return array | [
"Completes",
"the",
"the",
"transformation",
"and",
"serialization",
"flow",
"returning",
"the",
"data",
"."
]
| 25e181860d2f269b3b212195944c2bca95b411bb | https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/TransformationFactory.php#L159-L176 |
14,487 | fuzz-productions/laravel-api-data | src/Transformations/TransformationFactory.php | TransformationFactory.usingPaginator | public function usingPaginator($paginator = null): TransformationFactory
{
if (! ($this->resource instanceof Collection) || ! ($this->entity instanceof LengthAwarePaginator)) {
throw new \InvalidArgumentException('Bad Request Issued');
}
$this->resource->setPaginator(new IlluminatePaginatorAdapter($this->entity));
return $this;
} | php | public function usingPaginator($paginator = null): TransformationFactory
{
if (! ($this->resource instanceof Collection) || ! ($this->entity instanceof LengthAwarePaginator)) {
throw new \InvalidArgumentException('Bad Request Issued');
}
$this->resource->setPaginator(new IlluminatePaginatorAdapter($this->entity));
return $this;
} | [
"public",
"function",
"usingPaginator",
"(",
"$",
"paginator",
"=",
"null",
")",
":",
"TransformationFactory",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"resource",
"instanceof",
"Collection",
")",
"||",
"!",
"(",
"$",
"this",
"->",
"entity",
"instanceof",
"LengthAwarePaginator",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Bad Request Issued'",
")",
";",
"}",
"$",
"this",
"->",
"resource",
"->",
"setPaginator",
"(",
"new",
"IlluminatePaginatorAdapter",
"(",
"$",
"this",
"->",
"entity",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Applies a LengthAwarePaginator for paged resources.
@param null $paginator
@throws \InvalidArgumentException
@return \Fuzz\Data\Transformations\TransformationFactory | [
"Applies",
"a",
"LengthAwarePaginator",
"for",
"paged",
"resources",
"."
]
| 25e181860d2f269b3b212195944c2bca95b411bb | https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Transformations/TransformationFactory.php#L202-L211 |
14,488 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/LoadRawData.php | LoadRawData.parseFieldOptionsJson | protected function parseFieldOptionsJson()
{
foreach ($this->data->rawData['fields'] as $fieldId => &$fieldData) {
$optionsJson = trim( $fieldData['options'] );
if (empty($optionsJson)) continue;
$fieldData['options'] = json_decode($optionsJson, true);
}
unset($fieldData);
} | php | protected function parseFieldOptionsJson()
{
foreach ($this->data->rawData['fields'] as $fieldId => &$fieldData) {
$optionsJson = trim( $fieldData['options'] );
if (empty($optionsJson)) continue;
$fieldData['options'] = json_decode($optionsJson, true);
}
unset($fieldData);
} | [
"protected",
"function",
"parseFieldOptionsJson",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"->",
"rawData",
"[",
"'fields'",
"]",
"as",
"$",
"fieldId",
"=>",
"&",
"$",
"fieldData",
")",
"{",
"$",
"optionsJson",
"=",
"trim",
"(",
"$",
"fieldData",
"[",
"'options'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"optionsJson",
")",
")",
"continue",
";",
"$",
"fieldData",
"[",
"'options'",
"]",
"=",
"json_decode",
"(",
"$",
"optionsJson",
",",
"true",
")",
";",
"}",
"unset",
"(",
"$",
"fieldData",
")",
";",
"}"
]
| Parses json to array for fields with 'options' set | [
"Parses",
"json",
"to",
"array",
"for",
"fields",
"with",
"options",
"set"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/LoadRawData.php#L272-L284 |
14,489 | harp-orm/query | src/Compiler/Columns.php | Columns.renderItem | public static function renderItem(SQL\Columns $item)
{
return Compiler::braced(
Arr::join(', ', Arr::map(__NAMESPACE__.'\Compiler::name', $item->all()))
);
} | php | public static function renderItem(SQL\Columns $item)
{
return Compiler::braced(
Arr::join(', ', Arr::map(__NAMESPACE__.'\Compiler::name', $item->all()))
);
} | [
"public",
"static",
"function",
"renderItem",
"(",
"SQL",
"\\",
"Columns",
"$",
"item",
")",
"{",
"return",
"Compiler",
"::",
"braced",
"(",
"Arr",
"::",
"join",
"(",
"', '",
",",
"Arr",
"::",
"map",
"(",
"__NAMESPACE__",
".",
"'\\Compiler::name'",
",",
"$",
"item",
"->",
"all",
"(",
")",
")",
")",
")",
";",
"}"
]
| Render Columns object
@param SQL\Columns $item
@return string | [
"Render",
"Columns",
"object"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Columns.php#L30-L35 |
14,490 | harp-orm/query | src/Compiler/Select.php | Select.render | public static function render(Query\Select $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'SELECT',
$query->getType(),
Aliased::combine($query->getColumns()) ?: '*',
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('GROUP BY', Direction::combine($query->getGroup())),
Compiler::word('HAVING', Condition::combine($query->getHaving())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
Compiler::word('OFFSET', $query->getOffset()),
));
});
} | php | public static function render(Query\Select $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'SELECT',
$query->getType(),
Aliased::combine($query->getColumns()) ?: '*',
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('GROUP BY', Direction::combine($query->getGroup())),
Compiler::word('HAVING', Condition::combine($query->getHaving())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
Compiler::word('OFFSET', $query->getOffset()),
));
});
} | [
"public",
"static",
"function",
"render",
"(",
"Query",
"\\",
"Select",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"withDb",
"(",
"$",
"query",
"->",
"getDb",
"(",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"'SELECT'",
",",
"$",
"query",
"->",
"getType",
"(",
")",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getColumns",
"(",
")",
")",
"?",
":",
"'*'",
",",
"Compiler",
"::",
"word",
"(",
"'FROM'",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getFrom",
"(",
")",
")",
")",
",",
"Join",
"::",
"combine",
"(",
"$",
"query",
"->",
"getJoin",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'WHERE'",
",",
"Condition",
"::",
"combine",
"(",
"$",
"query",
"->",
"getWhere",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'GROUP BY'",
",",
"Direction",
"::",
"combine",
"(",
"$",
"query",
"->",
"getGroup",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'HAVING'",
",",
"Condition",
"::",
"combine",
"(",
"$",
"query",
"->",
"getHaving",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'ORDER BY'",
",",
"Direction",
"::",
"combine",
"(",
"$",
"query",
"->",
"getOrder",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'LIMIT'",
",",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'OFFSET'",
",",
"$",
"query",
"->",
"getOffset",
"(",
")",
")",
",",
")",
")",
";",
"}",
")",
";",
"}"
]
| Render a Select object
@param Query\Select $query
@return string | [
"Render",
"a",
"Select",
"object"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Select.php#L19-L36 |
14,491 | siriusphp/html | src/Builder.php | Builder.with | public function with($options)
{
$clone = clone $this;
foreach ($options as $name => $value) {
$clone->setOption($name, $value);
}
return $clone;
} | php | public function with($options)
{
$clone = clone $this;
foreach ($options as $name => $value) {
$clone->setOption($name, $value);
}
return $clone;
} | [
"public",
"function",
"with",
"(",
"$",
"options",
")",
"{",
"$",
"clone",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"clone",
"->",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"clone",
";",
"}"
]
| Clones the instance and applies new set of options
@param $options
@return Builder | [
"Clones",
"the",
"instance",
"and",
"applies",
"new",
"set",
"of",
"options"
]
| bc3e0cb98e80780e2ca01d88c3181605b7136f59 | https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Builder.php#L72-L80 |
14,492 | JoffreyPoreeCoding/MongoDB-ODM | src/Tools/QueryCaster.php | QueryCaster.getCastedQuery | public function getCastedQuery()
{
$newQuery = $this->castArray($this->query, $this->initialMetadata);
ArrayModifier::aggregate($newQuery, self::$mongoDbQueryOperators);
return $newQuery;
} | php | public function getCastedQuery()
{
$newQuery = $this->castArray($this->query, $this->initialMetadata);
ArrayModifier::aggregate($newQuery, self::$mongoDbQueryOperators);
return $newQuery;
} | [
"public",
"function",
"getCastedQuery",
"(",
")",
"{",
"$",
"newQuery",
"=",
"$",
"this",
"->",
"castArray",
"(",
"$",
"this",
"->",
"query",
",",
"$",
"this",
"->",
"initialMetadata",
")",
";",
"ArrayModifier",
"::",
"aggregate",
"(",
"$",
"newQuery",
",",
"self",
"::",
"$",
"mongoDbQueryOperators",
")",
";",
"return",
"$",
"newQuery",
";",
"}"
]
| Get the caster query
@return array | [
"Get",
"the",
"caster",
"query"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Tools/QueryCaster.php#L75-L80 |
14,493 | heyday/heystack | src/Console/Command/GenerateDataObjects.php | GenerateDataObjects.execute | protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
{
$this->generatorService->process($input->getOption('force'));
$output->writeln('Completed');
} | php | protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
{
$this->generatorService->process($input->getOption('force'));
$output->writeln('Completed');
} | [
"protected",
"function",
"execute",
"(",
"Input",
"\\",
"InputInterface",
"$",
"input",
",",
"Output",
"\\",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"generatorService",
"->",
"process",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'force'",
")",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'Completed'",
")",
";",
"}"
]
| Generate the container
@param Input\InputInterface $input The commands input
@param Output\OutputInterface $output The commands output
@return null | [
"Generate",
"the",
"container"
]
| 2c051933f8c532d0a9a23be6ee1ff5c619e47dfe | https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Console/Command/GenerateDataObjects.php#L67-L71 |
14,494 | comelyio/comely | src/Comely/IO/Session/ComelySession/Bag.php | Bag.has | public function has(string ...$props): bool
{
foreach ($props as $prop) {
if (!array_key_exists(strtolower($prop), $this->props)) {
return false;
}
}
return true;
} | php | public function has(string ...$props): bool
{
foreach ($props as $prop) {
if (!array_key_exists(strtolower($prop), $this->props)) {
return false;
}
}
return true;
} | [
"public",
"function",
"has",
"(",
"string",
"...",
"$",
"props",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"props",
"as",
"$",
"prop",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"prop",
")",
",",
"$",
"this",
"->",
"props",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| Checks if 1 or all the keys exist in Bag
@param string[] ...$props
@return bool | [
"Checks",
"if",
"1",
"or",
"all",
"the",
"keys",
"exist",
"in",
"Bag"
]
| 561ea7aef36fea347a1a79d3ee5597d4057ddf82 | https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Session/ComelySession/Bag.php#L88-L97 |
14,495 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/ModelDefaults.php | ModelDefaults.setModelDefaults | public function setModelDefaults($attr, $value = null)
{
if (is_array($attr))
$this->modelDefaults = array_merge($this->modelDefaults, $attr);
else
$this->modelDefaults[$attr] = $value;
return $this;
} | php | public function setModelDefaults($attr, $value = null)
{
if (is_array($attr))
$this->modelDefaults = array_merge($this->modelDefaults, $attr);
else
$this->modelDefaults[$attr] = $value;
return $this;
} | [
"public",
"function",
"setModelDefaults",
"(",
"$",
"attr",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attr",
")",
")",
"$",
"this",
"->",
"modelDefaults",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"modelDefaults",
",",
"$",
"attr",
")",
";",
"else",
"$",
"this",
"->",
"modelDefaults",
"[",
"$",
"attr",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the Model default values.
@param string|array $attr
@param array $value
@return self | [
"Sets",
"the",
"Model",
"default",
"values",
"."
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/ModelDefaults.php#L32-L40 |
14,496 | okvpn/fixture-bundle | src/Migration/Sorter/DataFixturesSorter.php | DataFixturesSorter.orderFixturesByNumber | protected function orderFixturesByNumber()
{
$this->orderedFixtures = $this->fixtures;
usort(
$this->orderedFixtures,
function ($a, $b) {
if ($a instanceof OrderedFixtureInterface && $b instanceof OrderedFixtureInterface) {
if ($a->getOrder() === $b->getOrder()) {
return 0;
}
return $a->getOrder() < $b->getOrder() ? -1 : 1;
} elseif ($a instanceof OrderedFixtureInterface) {
return $a->getOrder() === 0 ? 0 : 1;
} elseif ($b instanceof OrderedFixtureInterface) {
return $b->getOrder() === 0 ? 0 : -1;
}
return 0;
}
);
} | php | protected function orderFixturesByNumber()
{
$this->orderedFixtures = $this->fixtures;
usort(
$this->orderedFixtures,
function ($a, $b) {
if ($a instanceof OrderedFixtureInterface && $b instanceof OrderedFixtureInterface) {
if ($a->getOrder() === $b->getOrder()) {
return 0;
}
return $a->getOrder() < $b->getOrder() ? -1 : 1;
} elseif ($a instanceof OrderedFixtureInterface) {
return $a->getOrder() === 0 ? 0 : 1;
} elseif ($b instanceof OrderedFixtureInterface) {
return $b->getOrder() === 0 ? 0 : -1;
}
return 0;
}
);
} | [
"protected",
"function",
"orderFixturesByNumber",
"(",
")",
"{",
"$",
"this",
"->",
"orderedFixtures",
"=",
"$",
"this",
"->",
"fixtures",
";",
"usort",
"(",
"$",
"this",
"->",
"orderedFixtures",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"a",
"instanceof",
"OrderedFixtureInterface",
"&&",
"$",
"b",
"instanceof",
"OrderedFixtureInterface",
")",
"{",
"if",
"(",
"$",
"a",
"->",
"getOrder",
"(",
")",
"===",
"$",
"b",
"->",
"getOrder",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"a",
"->",
"getOrder",
"(",
")",
"<",
"$",
"b",
"->",
"getOrder",
"(",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
"elseif",
"(",
"$",
"a",
"instanceof",
"OrderedFixtureInterface",
")",
"{",
"return",
"$",
"a",
"->",
"getOrder",
"(",
")",
"===",
"0",
"?",
"0",
":",
"1",
";",
"}",
"elseif",
"(",
"$",
"b",
"instanceof",
"OrderedFixtureInterface",
")",
"{",
"return",
"$",
"b",
"->",
"getOrder",
"(",
")",
"===",
"0",
"?",
"0",
":",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"}"
]
| Order fixtures by priority
@return array | [
"Order",
"fixtures",
"by",
"priority"
]
| 243b5e4dff9773e97fa447280e929c936a5d66ae | https://github.com/okvpn/fixture-bundle/blob/243b5e4dff9773e97fa447280e929c936a5d66ae/src/Migration/Sorter/DataFixturesSorter.php#L59-L80 |
14,497 | heyday/heystack | src/DataObjectSchema/JsonDataObjectSchema.php | JsonDataObjectSchema.getLastJsonError | protected function getLastJsonError()
{
$error = json_last_error();
return array_key_exists($error, self::$errors) ? self::$errors[$error] : "Unknown error ({$error})";
} | php | protected function getLastJsonError()
{
$error = json_last_error();
return array_key_exists($error, self::$errors) ? self::$errors[$error] : "Unknown error ({$error})";
} | [
"protected",
"function",
"getLastJsonError",
"(",
")",
"{",
"$",
"error",
"=",
"json_last_error",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"error",
",",
"self",
"::",
"$",
"errors",
")",
"?",
"self",
"::",
"$",
"errors",
"[",
"$",
"error",
"]",
":",
"\"Unknown error ({$error})\"",
";",
"}"
]
| Get the last error
@return string | [
"Get",
"the",
"last",
"error"
]
| 2c051933f8c532d0a9a23be6ee1ff5c619e47dfe | https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/DataObjectSchema/JsonDataObjectSchema.php#L63-L67 |
14,498 | drpdigital/json-api-parser | src/Concerns/ChecksTypes.php | ChecksTypes.isTypeWithinArray | protected function isTypeWithinArray($type, array $haystackTypes)
{
$iterator = new \ArrayIterator($haystackTypes);
while($iterator->valid()) {
$seenValue = $iterator->current();
if ($seenValue === $type) {
return true;
}
$parts = explode('.', $seenValue);
if (count($parts) > 1) {
array_shift($parts);
$newKey = implode('.', $parts);
$iterator->append($newKey);
}
$iterator->next();
}
return false;
} | php | protected function isTypeWithinArray($type, array $haystackTypes)
{
$iterator = new \ArrayIterator($haystackTypes);
while($iterator->valid()) {
$seenValue = $iterator->current();
if ($seenValue === $type) {
return true;
}
$parts = explode('.', $seenValue);
if (count($parts) > 1) {
array_shift($parts);
$newKey = implode('.', $parts);
$iterator->append($newKey);
}
$iterator->next();
}
return false;
} | [
"protected",
"function",
"isTypeWithinArray",
"(",
"$",
"type",
",",
"array",
"$",
"haystackTypes",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"haystackTypes",
")",
";",
"while",
"(",
"$",
"iterator",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"seenValue",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"seenValue",
"===",
"$",
"type",
")",
"{",
"return",
"true",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"seenValue",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
")",
"{",
"array_shift",
"(",
"$",
"parts",
")",
";",
"$",
"newKey",
"=",
"implode",
"(",
"'.'",
",",
"$",
"parts",
")",
";",
"$",
"iterator",
"->",
"append",
"(",
"$",
"newKey",
")",
";",
"}",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks if the given type exists within the array of types.
@param string $type
@param array $haystackTypes
@return boolean | [
"Checks",
"if",
"the",
"given",
"type",
"exists",
"within",
"the",
"array",
"of",
"types",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/Concerns/ChecksTypes.php#L14-L37 |
14,499 | jasny/router | src/Router/Middleware/ErrorPage.php | ErrorPage.reviveRequest | protected function reviveRequest(ServerRequestInterface $request)
{
$isStale = interface_exists('Jasny\HttpMessage\GlobalEnvironmentInterface') &&
$request instanceof GlobalEnvironmentInterface &&
$request->isStale();
return $isStale ? $request->revive() : $request;
} | php | protected function reviveRequest(ServerRequestInterface $request)
{
$isStale = interface_exists('Jasny\HttpMessage\GlobalEnvironmentInterface') &&
$request instanceof GlobalEnvironmentInterface &&
$request->isStale();
return $isStale ? $request->revive() : $request;
} | [
"protected",
"function",
"reviveRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"isStale",
"=",
"interface_exists",
"(",
"'Jasny\\HttpMessage\\GlobalEnvironmentInterface'",
")",
"&&",
"$",
"request",
"instanceof",
"GlobalEnvironmentInterface",
"&&",
"$",
"request",
"->",
"isStale",
"(",
")",
";",
"return",
"$",
"isStale",
"?",
"$",
"request",
"->",
"revive",
"(",
")",
":",
"$",
"request",
";",
"}"
]
| Revive a stale request
@param ServerRequestInterface $request
@return ServerRequestInterface | [
"Revive",
"a",
"stale",
"request"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Middleware/ErrorPage.php#L68-L75 |
Subsets and Splits