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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,200 | theluckyteam/php-jira | src/jira/Provider/IssueLinksProvider.php | IssueLinksProvider.getIssuesFromRepositoryByKeys | private function getIssuesFromRepositoryByKeys(array $keys)
{
$issues = [];
if ($keys) {
$query = $this->issueQuery;
$query['jql'] = 'key IN (' . implode(',', $keys) . ')';
$issues = $this->dispatcher->getIssues($query);
}
return $issues;
} | php | private function getIssuesFromRepositoryByKeys(array $keys)
{
$issues = [];
if ($keys) {
$query = $this->issueQuery;
$query['jql'] = 'key IN (' . implode(',', $keys) . ')';
$issues = $this->dispatcher->getIssues($query);
}
return $issues;
} | [
"private",
"function",
"getIssuesFromRepositoryByKeys",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"issues",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"keys",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"issueQuery",
";",
"$",
"query",
"[",
"'jql'",
"]",
"=",
"'key IN ('",
".",
"implode",
"(",
"','",
",",
"$",
"keys",
")",
".",
"')'",
";",
"$",
"issues",
"=",
"$",
"this",
"->",
"dispatcher",
"->",
"getIssues",
"(",
"$",
"query",
")",
";",
"}",
"return",
"$",
"issues",
";",
"}"
] | Returns issues by keys from repository
@param string[] $keys Issue keys
@return Issue[] | [
"Returns",
"issues",
"by",
"keys",
"from",
"repository"
] | 5a50ab4fc57dd77239f1b7e9c87738318c258c38 | https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Provider/IssueLinksProvider.php#L119-L129 |
4,201 | theluckyteam/php-jira | src/jira/Provider/IssueLinksProvider.php | IssueLinksProvider.getIssueByKey | public function getIssueByKey($key)
{
if (array_key_exists($key, $this->issues) && isset($this->issues[$key])) {
return $this->issues[$key];
}
return null;
} | php | public function getIssueByKey($key)
{
if (array_key_exists($key, $this->issues) && isset($this->issues[$key])) {
return $this->issues[$key];
}
return null;
} | [
"public",
"function",
"getIssueByKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"issues",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"issues",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"issues",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns issue by keys from memory
@param string $key Issue keys
@return Issue | [
"Returns",
"issue",
"by",
"keys",
"from",
"memory"
] | 5a50ab4fc57dd77239f1b7e9c87738318c258c38 | https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Provider/IssueLinksProvider.php#L138-L145 |
4,202 | alevilar/account | Model/Egreso.php | Egreso.gastos_pagos | function gastos_pagos(){
$gastosDeuda = $this->Gasto->enDeuda();
$gastosSeleccionados = $this->data['Gasto']['Gasto'];
foreach ($gastosSeleccionados as $gs){
if (in_array($gs, $gastosDeuda)){
return false;
}
}
return true;
} | php | function gastos_pagos(){
$gastosDeuda = $this->Gasto->enDeuda();
$gastosSeleccionados = $this->data['Gasto']['Gasto'];
foreach ($gastosSeleccionados as $gs){
if (in_array($gs, $gastosDeuda)){
return false;
}
}
return true;
} | [
"function",
"gastos_pagos",
"(",
")",
"{",
"$",
"gastosDeuda",
"=",
"$",
"this",
"->",
"Gasto",
"->",
"enDeuda",
"(",
")",
";",
"$",
"gastosSeleccionados",
"=",
"$",
"this",
"->",
"data",
"[",
"'Gasto'",
"]",
"[",
"'Gasto'",
"]",
";",
"foreach",
"(",
"$",
"gastosSeleccionados",
"as",
"$",
"gs",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"gs",
",",
"$",
"gastosDeuda",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Verifica que el egreso no se realizara sobre un gasto que ya esta marcado como pagado
@return boolean | [
"Verifica",
"que",
"el",
"egreso",
"no",
"se",
"realizara",
"sobre",
"un",
"gasto",
"que",
"ya",
"esta",
"marcado",
"como",
"pagado"
] | dfb3744d2c5db2875bc49ba39132fec6946d0cca | https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Egreso.php#L243-L253 |
4,203 | bishopb/vanilla | applications/vanilla/modules/class.categoryfollowtogglemodule.php | CategoryFollowToggleModule.SetToggle | public function SetToggle() {
$Session = Gdn::Session();
if (!$Session->IsValid())
return;
$ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
if ($ShowAllCategories != '') {
$ShowAllCategories = $ShowAllCategories == 'true' ? TRUE : FALSE;
$ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
if ($ShowAllCategories != $ShowAllCategoriesPref)
$Session->SetPreference('ShowAllCategories', $ShowAllCategories);
Redirect('/'.ltrim(Gdn::Request()->Path(), '/'));
}
} | php | public function SetToggle() {
$Session = Gdn::Session();
if (!$Session->IsValid())
return;
$ShowAllCategories = GetIncomingValue('ShowAllCategories', '');
if ($ShowAllCategories != '') {
$ShowAllCategories = $ShowAllCategories == 'true' ? TRUE : FALSE;
$ShowAllCategoriesPref = $Session->GetPreference('ShowAllCategories');
if ($ShowAllCategories != $ShowAllCategoriesPref)
$Session->SetPreference('ShowAllCategories', $ShowAllCategories);
Redirect('/'.ltrim(Gdn::Request()->Path(), '/'));
}
} | [
"public",
"function",
"SetToggle",
"(",
")",
"{",
"$",
"Session",
"=",
"Gdn",
"::",
"Session",
"(",
")",
";",
"if",
"(",
"!",
"$",
"Session",
"->",
"IsValid",
"(",
")",
")",
"return",
";",
"$",
"ShowAllCategories",
"=",
"GetIncomingValue",
"(",
"'ShowAllCategories'",
",",
"''",
")",
";",
"if",
"(",
"$",
"ShowAllCategories",
"!=",
"''",
")",
"{",
"$",
"ShowAllCategories",
"=",
"$",
"ShowAllCategories",
"==",
"'true'",
"?",
"TRUE",
":",
"FALSE",
";",
"$",
"ShowAllCategoriesPref",
"=",
"$",
"Session",
"->",
"GetPreference",
"(",
"'ShowAllCategories'",
")",
";",
"if",
"(",
"$",
"ShowAllCategories",
"!=",
"$",
"ShowAllCategoriesPref",
")",
"$",
"Session",
"->",
"SetPreference",
"(",
"'ShowAllCategories'",
",",
"$",
"ShowAllCategories",
")",
";",
"Redirect",
"(",
"'/'",
".",
"ltrim",
"(",
"Gdn",
"::",
"Request",
"(",
")",
"->",
"Path",
"(",
")",
",",
"'/'",
")",
")",
";",
"}",
"}"
] | Set the preference in the user's session. | [
"Set",
"the",
"preference",
"in",
"the",
"user",
"s",
"session",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/vanilla/modules/class.categoryfollowtogglemodule.php#L19-L33 |
4,204 | easy-system/es-events | src/Events.php | Events.attachTrigger | public function attachTrigger(TriggerInterface $trigger, $eventNameOrClass, $priority = 1)
{
$event = ltrim((string) $eventNameOrClass, '\\');
$this->events[$event][(int) $priority . '.0'][] = $trigger;
return $this;
} | php | public function attachTrigger(TriggerInterface $trigger, $eventNameOrClass, $priority = 1)
{
$event = ltrim((string) $eventNameOrClass, '\\');
$this->events[$event][(int) $priority . '.0'][] = $trigger;
return $this;
} | [
"public",
"function",
"attachTrigger",
"(",
"TriggerInterface",
"$",
"trigger",
",",
"$",
"eventNameOrClass",
",",
"$",
"priority",
"=",
"1",
")",
"{",
"$",
"event",
"=",
"ltrim",
"(",
"(",
"string",
")",
"$",
"eventNameOrClass",
",",
"'\\\\'",
")",
";",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
"[",
"(",
"int",
")",
"$",
"priority",
".",
"'.0'",
"]",
"[",
"]",
"=",
"$",
"trigger",
";",
"return",
"$",
"this",
";",
"}"
] | Attachs an trigger to the specified event.
@param TriggerInterface $trigger The event trigger
@param string $eventNameOrClass The event name or class of event
@param int $priority Optional; by default 1. The event priority
@return Events | [
"Attachs",
"an",
"trigger",
"to",
"the",
"specified",
"event",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L35-L42 |
4,205 | easy-system/es-events | src/Events.php | Events.attach | public function attach($eventNameOrClass, $listenerName, $listenerMethod, $priority = 1)
{
$trigger = new Trigger($listenerName, $listenerMethod);
$this->attachTrigger($trigger, $eventNameOrClass, $priority);
return $this;
} | php | public function attach($eventNameOrClass, $listenerName, $listenerMethod, $priority = 1)
{
$trigger = new Trigger($listenerName, $listenerMethod);
$this->attachTrigger($trigger, $eventNameOrClass, $priority);
return $this;
} | [
"public",
"function",
"attach",
"(",
"$",
"eventNameOrClass",
",",
"$",
"listenerName",
",",
"$",
"listenerMethod",
",",
"$",
"priority",
"=",
"1",
")",
"{",
"$",
"trigger",
"=",
"new",
"Trigger",
"(",
"$",
"listenerName",
",",
"$",
"listenerMethod",
")",
";",
"$",
"this",
"->",
"attachTrigger",
"(",
"$",
"trigger",
",",
"$",
"eventNameOrClass",
",",
"$",
"priority",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Attachs an listener to the specified event.
@param string $eventNameOrClass The event name or class of event
@param string $listenerName The name of listener
@param string $listenerMethod The listener method name
@param int $priority Optional; by default 1. The event priority
@return Events | [
"Attachs",
"an",
"listener",
"to",
"the",
"specified",
"event",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L54-L60 |
4,206 | easy-system/es-events | src/Events.php | Events.detachTrigger | public function detachTrigger(TriggerInterface $trigger, $eventNameOrClass)
{
$event = (string) $eventNameOrClass;
if (isset($this->events[$event])) {
foreach ($this->events[$event] as $priority => $triggers) {
if (false !== ($key = array_search($trigger, $triggers, false))) {
unset($this->events[$event][$priority][$key]);
}
}
}
return $this;
} | php | public function detachTrigger(TriggerInterface $trigger, $eventNameOrClass)
{
$event = (string) $eventNameOrClass;
if (isset($this->events[$event])) {
foreach ($this->events[$event] as $priority => $triggers) {
if (false !== ($key = array_search($trigger, $triggers, false))) {
unset($this->events[$event][$priority][$key]);
}
}
}
return $this;
} | [
"public",
"function",
"detachTrigger",
"(",
"TriggerInterface",
"$",
"trigger",
",",
"$",
"eventNameOrClass",
")",
"{",
"$",
"event",
"=",
"(",
"string",
")",
"$",
"eventNameOrClass",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
"as",
"$",
"priority",
"=>",
"$",
"triggers",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"trigger",
",",
"$",
"triggers",
",",
"false",
")",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"event",
"]",
"[",
"$",
"priority",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Detaches trigger from the specified event.
@param TriggerInterface $trigger The event trigger
@param string $eventNameOrClass The event name or class of event
@return Events | [
"Detaches",
"trigger",
"from",
"the",
"specified",
"event",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L70-L83 |
4,207 | easy-system/es-events | src/Events.php | Events.clearTriggers | public function clearTriggers($eventNameOrClass)
{
if (isset($this->events[$eventNameOrClass])) {
unset($this->events[$eventNameOrClass]);
}
return $this;
} | php | public function clearTriggers($eventNameOrClass)
{
if (isset($this->events[$eventNameOrClass])) {
unset($this->events[$eventNameOrClass]);
}
return $this;
} | [
"public",
"function",
"clearTriggers",
"(",
"$",
"eventNameOrClass",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"eventNameOrClass",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"eventNameOrClass",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Clears all triggers for a given event.
@param string $eventNameOrClass The event name or class of event
@return Events | [
"Clears",
"all",
"triggers",
"for",
"a",
"given",
"event",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L92-L99 |
4,208 | easy-system/es-events | src/Events.php | Events.merge | public function merge(EventsInterface $source = null)
{
if (null === $source) {
return $this->events;
}
$this->events = array_merge($this->events, $source->merge());
} | php | public function merge(EventsInterface $source = null)
{
if (null === $source) {
return $this->events;
}
$this->events = array_merge($this->events, $source->merge());
} | [
"public",
"function",
"merge",
"(",
"EventsInterface",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"source",
")",
"{",
"return",
"$",
"this",
"->",
"events",
";",
"}",
"$",
"this",
"->",
"events",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"events",
",",
"$",
"source",
"->",
"merge",
"(",
")",
")",
";",
"}"
] | Merges with other events.
@param EventsInterface $source The data source
@return null|array If the source was passed returns
null, source data otherwise | [
"Merges",
"with",
"other",
"events",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L123-L129 |
4,209 | easy-system/es-events | src/Events.php | Events.pullTriggers | protected function pullTriggers(EventInterface $event)
{
$event->stopPropagation(false);
foreach ($this->getTriggers($event) as $trigger) {
$trigger($event);
if ($event->propagationIsStopped()) {
break;
}
}
return $event;
} | php | protected function pullTriggers(EventInterface $event)
{
$event->stopPropagation(false);
foreach ($this->getTriggers($event) as $trigger) {
$trigger($event);
if ($event->propagationIsStopped()) {
break;
}
}
return $event;
} | [
"protected",
"function",
"pullTriggers",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"stopPropagation",
"(",
"false",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTriggers",
"(",
"$",
"event",
")",
"as",
"$",
"trigger",
")",
"{",
"$",
"trigger",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"propagationIsStopped",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"event",
";",
"}"
] | Pull the triggers.
@param EventInterface $event The event
@return EventInterface | [
"Pull",
"the",
"triggers",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L191-L204 |
4,210 | easy-system/es-events | src/Events.php | Events.getTriggers | protected function getTriggers(EventInterface $event)
{
$eventName = $event->getName();
$eventClass = get_class($event);
$search = [];
if (isset($this->events[$eventName])) {
$search[] = $this->events[$eventName];
}
if (isset($this->events[$eventClass])) {
$search[] = $this->events[$eventClass];
}
$parent = $event;
while ($parent = get_parent_class($parent)) {
if (isset($this->events[$parent])) {
$search[] = $this->events[$parent];
}
}
if (empty($search)) {
return $search;
}
$triggers = call_user_func_array('array_merge_recursive', $search);
krsort($triggers);
return call_user_func_array('array_merge', $triggers);
} | php | protected function getTriggers(EventInterface $event)
{
$eventName = $event->getName();
$eventClass = get_class($event);
$search = [];
if (isset($this->events[$eventName])) {
$search[] = $this->events[$eventName];
}
if (isset($this->events[$eventClass])) {
$search[] = $this->events[$eventClass];
}
$parent = $event;
while ($parent = get_parent_class($parent)) {
if (isset($this->events[$parent])) {
$search[] = $this->events[$parent];
}
}
if (empty($search)) {
return $search;
}
$triggers = call_user_func_array('array_merge_recursive', $search);
krsort($triggers);
return call_user_func_array('array_merge', $triggers);
} | [
"protected",
"function",
"getTriggers",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"$",
"eventName",
"=",
"$",
"event",
"->",
"getName",
"(",
")",
";",
"$",
"eventClass",
"=",
"get_class",
"(",
"$",
"event",
")",
";",
"$",
"search",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"eventName",
"]",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"$",
"this",
"->",
"events",
"[",
"$",
"eventName",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"eventClass",
"]",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"$",
"this",
"->",
"events",
"[",
"$",
"eventClass",
"]",
";",
"}",
"$",
"parent",
"=",
"$",
"event",
";",
"while",
"(",
"$",
"parent",
"=",
"get_parent_class",
"(",
"$",
"parent",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"parent",
"]",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"$",
"this",
"->",
"events",
"[",
"$",
"parent",
"]",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"search",
")",
")",
"{",
"return",
"$",
"search",
";",
"}",
"$",
"triggers",
"=",
"call_user_func_array",
"(",
"'array_merge_recursive'",
",",
"$",
"search",
")",
";",
"krsort",
"(",
"$",
"triggers",
")",
";",
"return",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"triggers",
")",
";",
"}"
] | Gets the triggers for the currently event.
@param EventInterface $event The event
@return array | [
"Gets",
"the",
"triggers",
"for",
"the",
"currently",
"event",
"."
] | f6a86f71d78dad7af4765db69fcd0ab6004924a3 | https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/Events.php#L213-L243 |
4,211 | leedave/infinitescroll | src/Traits/TableTrait.php | TableTrait.renderTable | public function renderTable()
{
$header = $this->tableHeaders();
$content = H::table($header, $this->getTableAttributes());
return $content;
} | php | public function renderTable()
{
$header = $this->tableHeaders();
$content = H::table($header, $this->getTableAttributes());
return $content;
} | [
"public",
"function",
"renderTable",
"(",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"tableHeaders",
"(",
")",
";",
"$",
"content",
"=",
"H",
"::",
"table",
"(",
"$",
"header",
",",
"$",
"this",
"->",
"getTableAttributes",
"(",
")",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Draws the entire Table
@return string | [
"Draws",
"the",
"entire",
"Table"
] | 64ce4638408d51195249b92fc4f6f05f19ef7f7b | https://github.com/leedave/infinitescroll/blob/64ce4638408d51195249b92fc4f6f05f19ef7f7b/src/Traits/TableTrait.php#L22-L28 |
4,212 | leedave/infinitescroll | src/Traits/TableTrait.php | TableTrait.tableHeaders | protected function tableHeaders() : string
{
$arrCells = [];
foreach ($this->getHeaderColumns() as $key => $val) {
$arrCells[] = $this->renderHeaderColumn($key, $val);
}
$arrCells[] = "";
$content = H::renderTableHeaderRow($arrCells);
$full = H::thead($content)
. H::tbody('');
return $full;
} | php | protected function tableHeaders() : string
{
$arrCells = [];
foreach ($this->getHeaderColumns() as $key => $val) {
$arrCells[] = $this->renderHeaderColumn($key, $val);
}
$arrCells[] = "";
$content = H::renderTableHeaderRow($arrCells);
$full = H::thead($content)
. H::tbody('');
return $full;
} | [
"protected",
"function",
"tableHeaders",
"(",
")",
":",
"string",
"{",
"$",
"arrCells",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getHeaderColumns",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"arrCells",
"[",
"]",
"=",
"$",
"this",
"->",
"renderHeaderColumn",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"$",
"arrCells",
"[",
"]",
"=",
"\"\"",
";",
"$",
"content",
"=",
"H",
"::",
"renderTableHeaderRow",
"(",
"$",
"arrCells",
")",
";",
"$",
"full",
"=",
"H",
"::",
"thead",
"(",
"$",
"content",
")",
".",
"H",
"::",
"tbody",
"(",
"''",
")",
";",
"return",
"$",
"full",
";",
"}"
] | Render the Header of the overview Table
@return string | [
"Render",
"the",
"Header",
"of",
"the",
"overview",
"Table"
] | 64ce4638408d51195249b92fc4f6f05f19ef7f7b | https://github.com/leedave/infinitescroll/blob/64ce4638408d51195249b92fc4f6f05f19ef7f7b/src/Traits/TableTrait.php#L34-L46 |
4,213 | leedave/infinitescroll | src/Traits/TableTrait.php | TableTrait.renderHeaderColumn | protected function renderHeaderColumn(string $label, string $attributeName, string $dataType = "text") : string
{
$this->getTableAttributes();
$inputAttr = [
"data-parent" => $this->tableAttributes['id'], //"traktCollectionTable",
"data-attribute" => $attributeName,
"data-sort" => "ASC",
"data-type" => $dataType,
"class" => "infiniteScrollTableHeaderLink",
];
$inputField = "";
if ($dataType !== null) {
$fieldAttr = [
"size" => strlen($label),
];
$inputField = H::input($attributeName, $dataType, null, $fieldAttr);
}
return H::span($label, $inputAttr).$inputField;
} | php | protected function renderHeaderColumn(string $label, string $attributeName, string $dataType = "text") : string
{
$this->getTableAttributes();
$inputAttr = [
"data-parent" => $this->tableAttributes['id'], //"traktCollectionTable",
"data-attribute" => $attributeName,
"data-sort" => "ASC",
"data-type" => $dataType,
"class" => "infiniteScrollTableHeaderLink",
];
$inputField = "";
if ($dataType !== null) {
$fieldAttr = [
"size" => strlen($label),
];
$inputField = H::input($attributeName, $dataType, null, $fieldAttr);
}
return H::span($label, $inputAttr).$inputField;
} | [
"protected",
"function",
"renderHeaderColumn",
"(",
"string",
"$",
"label",
",",
"string",
"$",
"attributeName",
",",
"string",
"$",
"dataType",
"=",
"\"text\"",
")",
":",
"string",
"{",
"$",
"this",
"->",
"getTableAttributes",
"(",
")",
";",
"$",
"inputAttr",
"=",
"[",
"\"data-parent\"",
"=>",
"$",
"this",
"->",
"tableAttributes",
"[",
"'id'",
"]",
",",
"//\"traktCollectionTable\",",
"\"data-attribute\"",
"=>",
"$",
"attributeName",
",",
"\"data-sort\"",
"=>",
"\"ASC\"",
",",
"\"data-type\"",
"=>",
"$",
"dataType",
",",
"\"class\"",
"=>",
"\"infiniteScrollTableHeaderLink\"",
",",
"]",
";",
"$",
"inputField",
"=",
"\"\"",
";",
"if",
"(",
"$",
"dataType",
"!==",
"null",
")",
"{",
"$",
"fieldAttr",
"=",
"[",
"\"size\"",
"=>",
"strlen",
"(",
"$",
"label",
")",
",",
"]",
";",
"$",
"inputField",
"=",
"H",
"::",
"input",
"(",
"$",
"attributeName",
",",
"$",
"dataType",
",",
"null",
",",
"$",
"fieldAttr",
")",
";",
"}",
"return",
"H",
"::",
"span",
"(",
"$",
"label",
",",
"$",
"inputAttr",
")",
".",
"$",
"inputField",
";",
"}"
] | Render a single Header Column
@param string $label
@param string $attributeName
@param string $dataType set to null for no input, text for input
@return string | [
"Render",
"a",
"single",
"Header",
"Column"
] | 64ce4638408d51195249b92fc4f6f05f19ef7f7b | https://github.com/leedave/infinitescroll/blob/64ce4638408d51195249b92fc4f6f05f19ef7f7b/src/Traits/TableTrait.php#L55-L75 |
4,214 | leedave/infinitescroll | src/Traits/TableTrait.php | TableTrait.jsonRows | public function jsonRows()
{
$arrWhat = array_values($this->getHeaderColumns());
$arrWhere = [];
$arrOrder = ['`id` DESC'];
$start = 0;
$pageSize = 15;
if (isset($_POST['page']) && isset($_POST['pageSize'])) {
$page = (int) $_POST['page'];
$pageSize = (int) $_POST['pageSize'];
$start = $page * $pageSize;
}
if (isset($_POST['sort']) && isset($_POST['sortDir'])) {
$sort = (string) $_POST['sort'];
$sortDir = (string) $_POST['sortDir'];
if (!in_array($sortDir, ['ASC', 'DESC'])) {
throw new Exception('Someone is doing something evil here :(');
}
if (!in_array($sort, $this->getAllowedPostColumns())) {
throw new Exception('Someone is doing something evil here :(');
}
$arrOrder = ['`'.$sort.'` '.$sortDir];
}
foreach ($arrWhat as $filter) {
if (in_array($filter, $arrWhat) && isset($_POST['filter_'.$filter])) {
$arrWhere[$filter] = [
"operator" => "like",
"value" => '%'.$_POST['filter_'.$filter].'%'
];
}
}
$arrLimit = [$start, $pageSize];
$rows = $this->loadByPrepStmt($arrWhat, $arrWhere, $arrOrder, $arrLimit);
if (count($rows) < 1) {
return "[]";
}
foreach ($rows as $key => $columns) {
foreach ($columns as $cKey => $column) {
if ($cKey == "createDate") {
$rows[$key][$cKey] = strftime("%d.%m.%Y %H:%M:%S", strtotime($column));
}
}
$rows[$key]['actions'] = $this->renderActionLinks();
}
$json = json_encode($rows, JSON_UNESCAPED_UNICODE);
return $json;
} | php | public function jsonRows()
{
$arrWhat = array_values($this->getHeaderColumns());
$arrWhere = [];
$arrOrder = ['`id` DESC'];
$start = 0;
$pageSize = 15;
if (isset($_POST['page']) && isset($_POST['pageSize'])) {
$page = (int) $_POST['page'];
$pageSize = (int) $_POST['pageSize'];
$start = $page * $pageSize;
}
if (isset($_POST['sort']) && isset($_POST['sortDir'])) {
$sort = (string) $_POST['sort'];
$sortDir = (string) $_POST['sortDir'];
if (!in_array($sortDir, ['ASC', 'DESC'])) {
throw new Exception('Someone is doing something evil here :(');
}
if (!in_array($sort, $this->getAllowedPostColumns())) {
throw new Exception('Someone is doing something evil here :(');
}
$arrOrder = ['`'.$sort.'` '.$sortDir];
}
foreach ($arrWhat as $filter) {
if (in_array($filter, $arrWhat) && isset($_POST['filter_'.$filter])) {
$arrWhere[$filter] = [
"operator" => "like",
"value" => '%'.$_POST['filter_'.$filter].'%'
];
}
}
$arrLimit = [$start, $pageSize];
$rows = $this->loadByPrepStmt($arrWhat, $arrWhere, $arrOrder, $arrLimit);
if (count($rows) < 1) {
return "[]";
}
foreach ($rows as $key => $columns) {
foreach ($columns as $cKey => $column) {
if ($cKey == "createDate") {
$rows[$key][$cKey] = strftime("%d.%m.%Y %H:%M:%S", strtotime($column));
}
}
$rows[$key]['actions'] = $this->renderActionLinks();
}
$json = json_encode($rows, JSON_UNESCAPED_UNICODE);
return $json;
} | [
"public",
"function",
"jsonRows",
"(",
")",
"{",
"$",
"arrWhat",
"=",
"array_values",
"(",
"$",
"this",
"->",
"getHeaderColumns",
"(",
")",
")",
";",
"$",
"arrWhere",
"=",
"[",
"]",
";",
"$",
"arrOrder",
"=",
"[",
"'`id` DESC'",
"]",
";",
"$",
"start",
"=",
"0",
";",
"$",
"pageSize",
"=",
"15",
";",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'page'",
"]",
")",
"&&",
"isset",
"(",
"$",
"_POST",
"[",
"'pageSize'",
"]",
")",
")",
"{",
"$",
"page",
"=",
"(",
"int",
")",
"$",
"_POST",
"[",
"'page'",
"]",
";",
"$",
"pageSize",
"=",
"(",
"int",
")",
"$",
"_POST",
"[",
"'pageSize'",
"]",
";",
"$",
"start",
"=",
"$",
"page",
"*",
"$",
"pageSize",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'sort'",
"]",
")",
"&&",
"isset",
"(",
"$",
"_POST",
"[",
"'sortDir'",
"]",
")",
")",
"{",
"$",
"sort",
"=",
"(",
"string",
")",
"$",
"_POST",
"[",
"'sort'",
"]",
";",
"$",
"sortDir",
"=",
"(",
"string",
")",
"$",
"_POST",
"[",
"'sortDir'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"sortDir",
",",
"[",
"'ASC'",
",",
"'DESC'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Someone is doing something evil here :('",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"sort",
",",
"$",
"this",
"->",
"getAllowedPostColumns",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Someone is doing something evil here :('",
")",
";",
"}",
"$",
"arrOrder",
"=",
"[",
"'`'",
".",
"$",
"sort",
".",
"'` '",
".",
"$",
"sortDir",
"]",
";",
"}",
"foreach",
"(",
"$",
"arrWhat",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"filter",
",",
"$",
"arrWhat",
")",
"&&",
"isset",
"(",
"$",
"_POST",
"[",
"'filter_'",
".",
"$",
"filter",
"]",
")",
")",
"{",
"$",
"arrWhere",
"[",
"$",
"filter",
"]",
"=",
"[",
"\"operator\"",
"=>",
"\"like\"",
",",
"\"value\"",
"=>",
"'%'",
".",
"$",
"_POST",
"[",
"'filter_'",
".",
"$",
"filter",
"]",
".",
"'%'",
"]",
";",
"}",
"}",
"$",
"arrLimit",
"=",
"[",
"$",
"start",
",",
"$",
"pageSize",
"]",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"loadByPrepStmt",
"(",
"$",
"arrWhat",
",",
"$",
"arrWhere",
",",
"$",
"arrOrder",
",",
"$",
"arrLimit",
")",
";",
"if",
"(",
"count",
"(",
"$",
"rows",
")",
"<",
"1",
")",
"{",
"return",
"\"[]\"",
";",
"}",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"key",
"=>",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"cKey",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"cKey",
"==",
"\"createDate\"",
")",
"{",
"$",
"rows",
"[",
"$",
"key",
"]",
"[",
"$",
"cKey",
"]",
"=",
"strftime",
"(",
"\"%d.%m.%Y %H:%M:%S\"",
",",
"strtotime",
"(",
"$",
"column",
")",
")",
";",
"}",
"}",
"$",
"rows",
"[",
"$",
"key",
"]",
"[",
"'actions'",
"]",
"=",
"$",
"this",
"->",
"renderActionLinks",
"(",
")",
";",
"}",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"rows",
",",
"JSON_UNESCAPED_UNICODE",
")",
";",
"return",
"$",
"json",
";",
"}"
] | Fetches Data for Table Rows and returns as json
uses POST vars page, pageSize, sort, sortDir
@return string JSON Data
@throws Exception | [
"Fetches",
"Data",
"for",
"Table",
"Rows",
"and",
"returns",
"as",
"json",
"uses",
"POST",
"vars",
"page",
"pageSize",
"sort",
"sortDir"
] | 64ce4638408d51195249b92fc4f6f05f19ef7f7b | https://github.com/leedave/infinitescroll/blob/64ce4638408d51195249b92fc4f6f05f19ef7f7b/src/Traits/TableTrait.php#L83-L130 |
4,215 | leedave/infinitescroll | src/Traits/TableTrait.php | TableTrait.getAllowedPostColumns | protected function getAllowedPostColumns() : array
{
$arrColumns = $this->getTableColumns();
$arrColumnNames = [];
//$arrColumnTypes = [];
foreach ($arrColumns as $column) {
$arrColumnNames[] = $column['Field'];
//$arrColumnTypes[] = $column['Type'];
}
return $arrColumnNames;
} | php | protected function getAllowedPostColumns() : array
{
$arrColumns = $this->getTableColumns();
$arrColumnNames = [];
//$arrColumnTypes = [];
foreach ($arrColumns as $column) {
$arrColumnNames[] = $column['Field'];
//$arrColumnTypes[] = $column['Type'];
}
return $arrColumnNames;
} | [
"protected",
"function",
"getAllowedPostColumns",
"(",
")",
":",
"array",
"{",
"$",
"arrColumns",
"=",
"$",
"this",
"->",
"getTableColumns",
"(",
")",
";",
"$",
"arrColumnNames",
"=",
"[",
"]",
";",
"//$arrColumnTypes = [];",
"foreach",
"(",
"$",
"arrColumns",
"as",
"$",
"column",
")",
"{",
"$",
"arrColumnNames",
"[",
"]",
"=",
"$",
"column",
"[",
"'Field'",
"]",
";",
"//$arrColumnTypes[] = $column['Type'];",
"}",
"return",
"$",
"arrColumnNames",
";",
"}"
] | Gets all columns of the db table, use them for security checks
@return array | [
"Gets",
"all",
"columns",
"of",
"the",
"db",
"table",
"use",
"them",
"for",
"security",
"checks"
] | 64ce4638408d51195249b92fc4f6f05f19ef7f7b | https://github.com/leedave/infinitescroll/blob/64ce4638408d51195249b92fc4f6f05f19ef7f7b/src/Traits/TableTrait.php#L149-L160 |
4,216 | fuzz-productions/rest-tester | src/AuthTraits/OAuthTrait.php | OAuthTrait.oauthClientClass | public function oauthClientClass($instance = false)
{
if (! isset($this->oauth_client_class)) {
throw new \InvalidArgumentException(static::class . ' does not implement an OAuth Client class definition.');
}
return $instance ? new $this->oauth_client_class : $this->oauth_client_class;
} | php | public function oauthClientClass($instance = false)
{
if (! isset($this->oauth_client_class)) {
throw new \InvalidArgumentException(static::class . ' does not implement an OAuth Client class definition.');
}
return $instance ? new $this->oauth_client_class : $this->oauth_client_class;
} | [
"public",
"function",
"oauthClientClass",
"(",
"$",
"instance",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"oauth_client_class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"static",
"::",
"class",
".",
"' does not implement an OAuth Client class definition.'",
")",
";",
"}",
"return",
"$",
"instance",
"?",
"new",
"$",
"this",
"->",
"oauth_client_class",
":",
"$",
"this",
"->",
"oauth_client_class",
";",
"}"
] | Get the applications OAuth client class
@param bool $instance
@return string
@throws \InvalidArgumentException | [
"Get",
"the",
"applications",
"OAuth",
"client",
"class"
] | 12dd89ad2617fb62f8acd3ec760a77e1992c6643 | https://github.com/fuzz-productions/rest-tester/blob/12dd89ad2617fb62f8acd3ec760a77e1992c6643/src/AuthTraits/OAuthTrait.php#L97-L104 |
4,217 | fuzz-productions/rest-tester | src/AuthTraits/OAuthTrait.php | OAuthTrait.getToken | public function getToken($username)
{
return isset($this->access_tokens[$username]) ? $this->access_tokens[$username] : null;
} | php | public function getToken($username)
{
return isset($this->access_tokens[$username]) ? $this->access_tokens[$username] : null;
} | [
"public",
"function",
"getToken",
"(",
"$",
"username",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"access_tokens",
"[",
"$",
"username",
"]",
")",
"?",
"$",
"this",
"->",
"access_tokens",
"[",
"$",
"username",
"]",
":",
"null",
";",
"}"
] | Retrieve an access token
@param $username
@return string | [
"Retrieve",
"an",
"access",
"token"
] | 12dd89ad2617fb62f8acd3ec760a77e1992c6643 | https://github.com/fuzz-productions/rest-tester/blob/12dd89ad2617fb62f8acd3ec760a77e1992c6643/src/AuthTraits/OAuthTrait.php#L126-L129 |
4,218 | fuzz-productions/rest-tester | src/AuthTraits/OAuthTrait.php | OAuthTrait.applyScopesToUser | public function applyScopesToUser($user, array $scopes)
{
if (! is_a($user, Model::class)) {
$this->fail('User is not a model.');
}
$scopes = array_map(
function ($scope) {
return ['oauth_scope_id' => $scope];
}, $scopes
);
$user->scopes()->attach($scopes);
return $user->fresh(['scopes']);
} | php | public function applyScopesToUser($user, array $scopes)
{
if (! is_a($user, Model::class)) {
$this->fail('User is not a model.');
}
$scopes = array_map(
function ($scope) {
return ['oauth_scope_id' => $scope];
}, $scopes
);
$user->scopes()->attach($scopes);
return $user->fresh(['scopes']);
} | [
"public",
"function",
"applyScopesToUser",
"(",
"$",
"user",
",",
"array",
"$",
"scopes",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"user",
",",
"Model",
"::",
"class",
")",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"'User is not a model.'",
")",
";",
"}",
"$",
"scopes",
"=",
"array_map",
"(",
"function",
"(",
"$",
"scope",
")",
"{",
"return",
"[",
"'oauth_scope_id'",
"=>",
"$",
"scope",
"]",
";",
"}",
",",
"$",
"scopes",
")",
";",
"$",
"user",
"->",
"scopes",
"(",
")",
"->",
"attach",
"(",
"$",
"scopes",
")",
";",
"return",
"$",
"user",
"->",
"fresh",
"(",
"[",
"'scopes'",
"]",
")",
";",
"}"
] | Attach scopes to a user
@param object $user
@param array $scopes | [
"Attach",
"scopes",
"to",
"a",
"user"
] | 12dd89ad2617fb62f8acd3ec760a77e1992c6643 | https://github.com/fuzz-productions/rest-tester/blob/12dd89ad2617fb62f8acd3ec760a77e1992c6643/src/AuthTraits/OAuthTrait.php#L159-L174 |
4,219 | fuzz-productions/rest-tester | src/AuthTraits/OAuthTrait.php | OAuthTrait.createClientWithScopes | public function createClientWithScopes($id, $secret, array $scopes)
{
$client = $this->oauthClientClass(true);
$client->id = $id;
$client->secret = $secret;
$client->name = $id;
$client->save();
$apply_scopes = [];
foreach ($scopes as $scope) {
$apply_scopes[] = [
'client_id' => $id,
'scope_id' => $scope,
];
}
DB::table('oauth_client_scopes')->insert($apply_scopes);
return $client;
} | php | public function createClientWithScopes($id, $secret, array $scopes)
{
$client = $this->oauthClientClass(true);
$client->id = $id;
$client->secret = $secret;
$client->name = $id;
$client->save();
$apply_scopes = [];
foreach ($scopes as $scope) {
$apply_scopes[] = [
'client_id' => $id,
'scope_id' => $scope,
];
}
DB::table('oauth_client_scopes')->insert($apply_scopes);
return $client;
} | [
"public",
"function",
"createClientWithScopes",
"(",
"$",
"id",
",",
"$",
"secret",
",",
"array",
"$",
"scopes",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"oauthClientClass",
"(",
"true",
")",
";",
"$",
"client",
"->",
"id",
"=",
"$",
"id",
";",
"$",
"client",
"->",
"secret",
"=",
"$",
"secret",
";",
"$",
"client",
"->",
"name",
"=",
"$",
"id",
";",
"$",
"client",
"->",
"save",
"(",
")",
";",
"$",
"apply_scopes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"scopes",
"as",
"$",
"scope",
")",
"{",
"$",
"apply_scopes",
"[",
"]",
"=",
"[",
"'client_id'",
"=>",
"$",
"id",
",",
"'scope_id'",
"=>",
"$",
"scope",
",",
"]",
";",
"}",
"DB",
"::",
"table",
"(",
"'oauth_client_scopes'",
")",
"->",
"insert",
"(",
"$",
"apply_scopes",
")",
";",
"return",
"$",
"client",
";",
"}"
] | Create a client and give it some scopes
@param string $id
@param string $secret
@param array $scopes
@return object | [
"Create",
"a",
"client",
"and",
"give",
"it",
"some",
"scopes"
] | 12dd89ad2617fb62f8acd3ec760a77e1992c6643 | https://github.com/fuzz-productions/rest-tester/blob/12dd89ad2617fb62f8acd3ec760a77e1992c6643/src/AuthTraits/OAuthTrait.php#L185-L204 |
4,220 | mszewcz/php-light-framework | src/Db/MySQL/Query/Utilities/Condition.php | Condition.parseExpression | private function parseExpression(string $variable = '', array $expression = [], string $logicalOp = ' AND '): string
{
$ret = [];
foreach ($expression as $operator => $value) {
if (\in_array($operator, $this->operatorsFrom)) {
$operator = \str_replace($this->operatorsFrom, $this->operatorsTo, $operator);
$ret[] = \sprintf('%s%s%s', $variable, $operator, $this->escapeClass->escape($value));
} elseif ($operator == '$in' && \is_array($value)) {
$value = \array_map([$this->escapeClass, 'escape'], $value);
$ret[] = \sprintf('%s IN (%s)', $variable, \implode(',', $value));
} elseif ($operator == '$in' && \is_string($value)) {
$value = $this->escapeClass->escape($value);
$ret[] = \sprintf('%s IN (%s)', $variable, $value);
} elseif ($operator == '$nin' && \is_array($value)) {
$value = \array_map([$this->escapeClass, 'escape'], $value);
$ret[] = \sprintf('%s NOT IN (%s)', $variable, \implode(',', $value));
} elseif ($operator == '$nin' && \is_string($value)) {
$value = $this->escapeClass->escape($value);
$ret[] = \sprintf('%s NOT IN (%s)', $variable, $value);
} elseif ($operator == '$like') {
$ret[] = \sprintf('%s LIKE %s', $variable, $this->escapeClass->escape($value));
}
}
return \implode($logicalOp, $ret);
} | php | private function parseExpression(string $variable = '', array $expression = [], string $logicalOp = ' AND '): string
{
$ret = [];
foreach ($expression as $operator => $value) {
if (\in_array($operator, $this->operatorsFrom)) {
$operator = \str_replace($this->operatorsFrom, $this->operatorsTo, $operator);
$ret[] = \sprintf('%s%s%s', $variable, $operator, $this->escapeClass->escape($value));
} elseif ($operator == '$in' && \is_array($value)) {
$value = \array_map([$this->escapeClass, 'escape'], $value);
$ret[] = \sprintf('%s IN (%s)', $variable, \implode(',', $value));
} elseif ($operator == '$in' && \is_string($value)) {
$value = $this->escapeClass->escape($value);
$ret[] = \sprintf('%s IN (%s)', $variable, $value);
} elseif ($operator == '$nin' && \is_array($value)) {
$value = \array_map([$this->escapeClass, 'escape'], $value);
$ret[] = \sprintf('%s NOT IN (%s)', $variable, \implode(',', $value));
} elseif ($operator == '$nin' && \is_string($value)) {
$value = $this->escapeClass->escape($value);
$ret[] = \sprintf('%s NOT IN (%s)', $variable, $value);
} elseif ($operator == '$like') {
$ret[] = \sprintf('%s LIKE %s', $variable, $this->escapeClass->escape($value));
}
}
return \implode($logicalOp, $ret);
} | [
"private",
"function",
"parseExpression",
"(",
"string",
"$",
"variable",
"=",
"''",
",",
"array",
"$",
"expression",
"=",
"[",
"]",
",",
"string",
"$",
"logicalOp",
"=",
"' AND '",
")",
":",
"string",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"expression",
"as",
"$",
"operator",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"operator",
",",
"$",
"this",
"->",
"operatorsFrom",
")",
")",
"{",
"$",
"operator",
"=",
"\\",
"str_replace",
"(",
"$",
"this",
"->",
"operatorsFrom",
",",
"$",
"this",
"->",
"operatorsTo",
",",
"$",
"operator",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s%s%s'",
",",
"$",
"variable",
",",
"$",
"operator",
",",
"$",
"this",
"->",
"escapeClass",
"->",
"escape",
"(",
"$",
"value",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"operator",
"==",
"'$in'",
"&&",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"\\",
"array_map",
"(",
"[",
"$",
"this",
"->",
"escapeClass",
",",
"'escape'",
"]",
",",
"$",
"value",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s IN (%s)'",
",",
"$",
"variable",
",",
"\\",
"implode",
"(",
"','",
",",
"$",
"value",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"operator",
"==",
"'$in'",
"&&",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"escapeClass",
"->",
"escape",
"(",
"$",
"value",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s IN (%s)'",
",",
"$",
"variable",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"operator",
"==",
"'$nin'",
"&&",
"\\",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"\\",
"array_map",
"(",
"[",
"$",
"this",
"->",
"escapeClass",
",",
"'escape'",
"]",
",",
"$",
"value",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s NOT IN (%s)'",
",",
"$",
"variable",
",",
"\\",
"implode",
"(",
"','",
",",
"$",
"value",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"operator",
"==",
"'$nin'",
"&&",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"escapeClass",
"->",
"escape",
"(",
"$",
"value",
")",
";",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s NOT IN (%s)'",
",",
"$",
"variable",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"operator",
"==",
"'$like'",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"\\",
"sprintf",
"(",
"'%s LIKE %s'",
",",
"$",
"variable",
",",
"$",
"this",
"->",
"escapeClass",
"->",
"escape",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"return",
"\\",
"implode",
"(",
"$",
"logicalOp",
",",
"$",
"ret",
")",
";",
"}"
] | Parses logical expression
@param string $variable
@param array $expression
@param string $logicalOp
@return string | [
"Parses",
"logical",
"expression"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Db/MySQL/Query/Utilities/Condition.php#L43-L67 |
4,221 | demisang/longlog-php-sdk | src/LongLogClientWrapper.php | LongLogClientWrapper.create | public static function create($client, $jobName, $payload = null)
{
$longLog = new self($client, $jobName, $payload);
return $longLog;
} | php | public static function create($client, $jobName, $payload = null)
{
$longLog = new self($client, $jobName, $payload);
return $longLog;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"client",
",",
"$",
"jobName",
",",
"$",
"payload",
"=",
"null",
")",
"{",
"$",
"longLog",
"=",
"new",
"self",
"(",
"$",
"client",
",",
"$",
"jobName",
",",
"$",
"payload",
")",
";",
"return",
"$",
"longLog",
";",
"}"
] | Create new LongLog object with client variable
@param \longlog\Client $client
@param string $jobName
@param mixed $payload
@return static | [
"Create",
"new",
"LongLog",
"object",
"with",
"client",
"variable"
] | f6b2944acaf195954b52bf5b89b09c8096fd597f | https://github.com/demisang/longlog-php-sdk/blob/f6b2944acaf195954b52bf5b89b09c8096fd597f/src/LongLogClientWrapper.php#L45-L50 |
4,222 | fond-of/spryker-brand-product | src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php | BrandProductEntityManager.deleteByProductAbstractId | public function deleteByProductAbstractId(int $idProductAbstract): void
{
$this->getFactory()
->getBrandProductQuery()
->filterByFkProductAbstract_In([$idProductAbstract])
->delete();
} | php | public function deleteByProductAbstractId(int $idProductAbstract): void
{
$this->getFactory()
->getBrandProductQuery()
->filterByFkProductAbstract_In([$idProductAbstract])
->delete();
} | [
"public",
"function",
"deleteByProductAbstractId",
"(",
"int",
"$",
"idProductAbstract",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"getBrandProductQuery",
"(",
")",
"->",
"filterByFkProductAbstract_In",
"(",
"[",
"$",
"idProductAbstract",
"]",
")",
"->",
"delete",
"(",
")",
";",
"}"
] | Delete brand relation by product abstract id
@param int $idProductAbstract
@return void | [
"Delete",
"brand",
"relation",
"by",
"product",
"abstract",
"id"
] | e8cf5a7b6c8cae566c0e279e7927b39a30df0982 | https://github.com/fond-of/spryker-brand-product/blob/e8cf5a7b6c8cae566c0e279e7927b39a30df0982/src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php#L20-L26 |
4,223 | fond-of/spryker-brand-product | src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php | BrandProductEntityManager.addBrandProductRelations | public function addBrandProductRelations(int $idProductAbstract, array $brandIds): void
{
if (count($brandIds) === 0) {
return;
}
foreach ($brandIds as $brandId) {
$entity = new FosBrandProduct();
$entity->setFkProductAbstract($idProductAbstract)
->setFkBrand($brandId)
->save();
}
} | php | public function addBrandProductRelations(int $idProductAbstract, array $brandIds): void
{
if (count($brandIds) === 0) {
return;
}
foreach ($brandIds as $brandId) {
$entity = new FosBrandProduct();
$entity->setFkProductAbstract($idProductAbstract)
->setFkBrand($brandId)
->save();
}
} | [
"public",
"function",
"addBrandProductRelations",
"(",
"int",
"$",
"idProductAbstract",
",",
"array",
"$",
"brandIds",
")",
":",
"void",
"{",
"if",
"(",
"count",
"(",
"$",
"brandIds",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"brandIds",
"as",
"$",
"brandId",
")",
"{",
"$",
"entity",
"=",
"new",
"FosBrandProduct",
"(",
")",
";",
"$",
"entity",
"->",
"setFkProductAbstract",
"(",
"$",
"idProductAbstract",
")",
"->",
"setFkBrand",
"(",
"$",
"brandId",
")",
"->",
"save",
"(",
")",
";",
"}",
"}"
] | Add brand product relation
@param int $idProductAbstract
@param array $brandIds
@return void | [
"Add",
"brand",
"product",
"relation"
] | e8cf5a7b6c8cae566c0e279e7927b39a30df0982 | https://github.com/fond-of/spryker-brand-product/blob/e8cf5a7b6c8cae566c0e279e7927b39a30df0982/src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php#L36-L48 |
4,224 | fond-of/spryker-brand-product | src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php | BrandProductEntityManager.deleteBrandProductRelations | public function deleteBrandProductRelations(int $idProductAbstract, array $brandIds): void
{
if (count($brandIds) === 0) {
return;
}
$this->getFactory()
->getBrandProductQuery()
->filterByFkProductAbstract($idProductAbstract)
->filterByFkBrand_In($brandIds)
->delete();
} | php | public function deleteBrandProductRelations(int $idProductAbstract, array $brandIds): void
{
if (count($brandIds) === 0) {
return;
}
$this->getFactory()
->getBrandProductQuery()
->filterByFkProductAbstract($idProductAbstract)
->filterByFkBrand_In($brandIds)
->delete();
} | [
"public",
"function",
"deleteBrandProductRelations",
"(",
"int",
"$",
"idProductAbstract",
",",
"array",
"$",
"brandIds",
")",
":",
"void",
"{",
"if",
"(",
"count",
"(",
"$",
"brandIds",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"getBrandProductQuery",
"(",
")",
"->",
"filterByFkProductAbstract",
"(",
"$",
"idProductAbstract",
")",
"->",
"filterByFkBrand_In",
"(",
"$",
"brandIds",
")",
"->",
"delete",
"(",
")",
";",
"}"
] | Delete brand product relation
@param int $idProductAbstract
@param array $brandIds
@return void | [
"Delete",
"brand",
"product",
"relation"
] | e8cf5a7b6c8cae566c0e279e7927b39a30df0982 | https://github.com/fond-of/spryker-brand-product/blob/e8cf5a7b6c8cae566c0e279e7927b39a30df0982/src/FondOfSpryker/Zed/BrandProduct/Persistence/BrandProductEntityManager.php#L58-L69 |
4,225 | asbsoft/yii2-common_2_170212 | web/BaseWebFile.php | BaseWebFile.getFileBody | public function getFileBody()
{
if (!isset($this->_fileBody)) {
if (is_file($this->_srcFilePath)) {
$this->_fileBody = file_get_contents($this->_srcFilePath);
} else {
$this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
return false;
}
}
return $this->_fileBody;
} | php | public function getFileBody()
{
if (!isset($this->_fileBody)) {
if (is_file($this->_srcFilePath)) {
$this->_fileBody = file_get_contents($this->_srcFilePath);
} else {
$this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
return false;
}
}
return $this->_fileBody;
} | [
"public",
"function",
"getFileBody",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_fileBody",
")",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"_srcFilePath",
")",
")",
"{",
"$",
"this",
"->",
"_fileBody",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"_srcFilePath",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"errmsg",
"=",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"Source file '{file}' not found\"",
",",
"[",
"'file'",
"=>",
"$",
"this",
"->",
"_srcFilePath",
"]",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_fileBody",
";",
"}"
] | Get file body
@return string|false and get $this->errmsg | [
"Get",
"file",
"body"
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/BaseWebFile.php#L105-L116 |
4,226 | asbsoft/yii2-common_2_170212 | web/BaseWebFile.php | BaseWebFile.synchronize | public function synchronize()
{
if (empty($this->_fileSubpath)) {
$file = empty($this->_destFilePath) ? $this->fileUrl : $this->_destFilePath;
$this->errmsg = __METHOD__ . "({$this->fileUrl}): "
. Yii::t($this->tc, "File '{file}' is not from upload mirror area", ['file' => $file]);
return false;
}
$ext = $this->isAllowedExtension();
if ($ext !== true) {
$this->errmsg = Yii::t($this->tc, "File has not allowed type '{ext}'", ['ext' => $ext]);
return false;
}
if (!is_file($this->_srcFilePath)) {
$this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
return false;
}
$needUpdate = $this->needUpdate($this->_srcFilePath, $this->_destFilePath);
if (is_file($this->_destFilePath)) {
if ($needUpdate && !@unlink($this->_destFilePath)) {
$this->errmsg = Yii::t($this->tc, "Can't delete file '{file}'", ['file' => $this->_destFilePath]);
return false;
}
}
$result = $this->copyFile($this->_srcFilePath, $this->_destFilePath);
if ($result === false) {
$this->errmsg = $this->errmsg ?: Yii::t($this->tc, "Can't copy file");
return false;
}
$this->_fileBody = file_get_contents($this->_destFilePath); // new content
return true;
} | php | public function synchronize()
{
if (empty($this->_fileSubpath)) {
$file = empty($this->_destFilePath) ? $this->fileUrl : $this->_destFilePath;
$this->errmsg = __METHOD__ . "({$this->fileUrl}): "
. Yii::t($this->tc, "File '{file}' is not from upload mirror area", ['file' => $file]);
return false;
}
$ext = $this->isAllowedExtension();
if ($ext !== true) {
$this->errmsg = Yii::t($this->tc, "File has not allowed type '{ext}'", ['ext' => $ext]);
return false;
}
if (!is_file($this->_srcFilePath)) {
$this->errmsg = Yii::t($this->tc, "Source file '{file}' not found", ['file' => $this->_srcFilePath]);
return false;
}
$needUpdate = $this->needUpdate($this->_srcFilePath, $this->_destFilePath);
if (is_file($this->_destFilePath)) {
if ($needUpdate && !@unlink($this->_destFilePath)) {
$this->errmsg = Yii::t($this->tc, "Can't delete file '{file}'", ['file' => $this->_destFilePath]);
return false;
}
}
$result = $this->copyFile($this->_srcFilePath, $this->_destFilePath);
if ($result === false) {
$this->errmsg = $this->errmsg ?: Yii::t($this->tc, "Can't copy file");
return false;
}
$this->_fileBody = file_get_contents($this->_destFilePath); // new content
return true;
} | [
"public",
"function",
"synchronize",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_fileSubpath",
")",
")",
"{",
"$",
"file",
"=",
"empty",
"(",
"$",
"this",
"->",
"_destFilePath",
")",
"?",
"$",
"this",
"->",
"fileUrl",
":",
"$",
"this",
"->",
"_destFilePath",
";",
"$",
"this",
"->",
"errmsg",
"=",
"__METHOD__",
".",
"\"({$this->fileUrl}): \"",
".",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"File '{file}' is not from upload mirror area\"",
",",
"[",
"'file'",
"=>",
"$",
"file",
"]",
")",
";",
"return",
"false",
";",
"}",
"$",
"ext",
"=",
"$",
"this",
"->",
"isAllowedExtension",
"(",
")",
";",
"if",
"(",
"$",
"ext",
"!==",
"true",
")",
"{",
"$",
"this",
"->",
"errmsg",
"=",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"File has not allowed type '{ext}'\"",
",",
"[",
"'ext'",
"=>",
"$",
"ext",
"]",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"_srcFilePath",
")",
")",
"{",
"$",
"this",
"->",
"errmsg",
"=",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"Source file '{file}' not found\"",
",",
"[",
"'file'",
"=>",
"$",
"this",
"->",
"_srcFilePath",
"]",
")",
";",
"return",
"false",
";",
"}",
"$",
"needUpdate",
"=",
"$",
"this",
"->",
"needUpdate",
"(",
"$",
"this",
"->",
"_srcFilePath",
",",
"$",
"this",
"->",
"_destFilePath",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"_destFilePath",
")",
")",
"{",
"if",
"(",
"$",
"needUpdate",
"&&",
"!",
"@",
"unlink",
"(",
"$",
"this",
"->",
"_destFilePath",
")",
")",
"{",
"$",
"this",
"->",
"errmsg",
"=",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"Can't delete file '{file}'\"",
",",
"[",
"'file'",
"=>",
"$",
"this",
"->",
"_destFilePath",
"]",
")",
";",
"return",
"false",
";",
"}",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"copyFile",
"(",
"$",
"this",
"->",
"_srcFilePath",
",",
"$",
"this",
"->",
"_destFilePath",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"errmsg",
"=",
"$",
"this",
"->",
"errmsg",
"?",
":",
"Yii",
"::",
"t",
"(",
"$",
"this",
"->",
"tc",
",",
"\"Can't copy file\"",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"_fileBody",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"_destFilePath",
")",
";",
"// new content",
"return",
"true",
";",
"}"
] | Synchronize file from uploads area to web root files area.
@return boolean return true if | [
"Synchronize",
"file",
"from",
"uploads",
"area",
"to",
"web",
"root",
"files",
"area",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/BaseWebFile.php#L122-L158 |
4,227 | digit-soft/re-action-clients-pool | src/Pool.php | Pool.bindClientEvents | protected function bindClientEvents(PoolClientInterface $client)
{
$clientId = $client->getClientId();
$this->_clientsStates[$clientId] = PoolClientInterface::CLIENT_POOL_STATE_READY;
$this->_clientsQueueCounters[$clientId] = 0;
//Remove client from pool on close
$client->once(PoolClientInterface::CLIENT_POOL_EVENT_CLOSE, function() use ($client, $clientId) {
unset($this->_clients[$clientId]);
unset($this->_clientsStates[$clientId]);
unset($this->_clientsQueueCounters[$clientId]);
$client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE);
$client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE);
});
//Change client state
$client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, function($state) use ($client, $clientId) {
$this->_clientsStates[$clientId] = $state;
});
//Change client queue count
$client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, function($queueCount) use ($client, $clientId) {
$this->_clientsQueueCounters[$clientId] = $queueCount;
});
} | php | protected function bindClientEvents(PoolClientInterface $client)
{
$clientId = $client->getClientId();
$this->_clientsStates[$clientId] = PoolClientInterface::CLIENT_POOL_STATE_READY;
$this->_clientsQueueCounters[$clientId] = 0;
//Remove client from pool on close
$client->once(PoolClientInterface::CLIENT_POOL_EVENT_CLOSE, function() use ($client, $clientId) {
unset($this->_clients[$clientId]);
unset($this->_clientsStates[$clientId]);
unset($this->_clientsQueueCounters[$clientId]);
$client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE);
$client->removeAllListeners(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE);
});
//Change client state
$client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_STATE, function($state) use ($client, $clientId) {
$this->_clientsStates[$clientId] = $state;
});
//Change client queue count
$client->on(PoolClientInterface::CLIENT_POOL_EVENT_CHANGE_QUEUE, function($queueCount) use ($client, $clientId) {
$this->_clientsQueueCounters[$clientId] = $queueCount;
});
} | [
"protected",
"function",
"bindClientEvents",
"(",
"PoolClientInterface",
"$",
"client",
")",
"{",
"$",
"clientId",
"=",
"$",
"client",
"->",
"getClientId",
"(",
")",
";",
"$",
"this",
"->",
"_clientsStates",
"[",
"$",
"clientId",
"]",
"=",
"PoolClientInterface",
"::",
"CLIENT_POOL_STATE_READY",
";",
"$",
"this",
"->",
"_clientsQueueCounters",
"[",
"$",
"clientId",
"]",
"=",
"0",
";",
"//Remove client from pool on close",
"$",
"client",
"->",
"once",
"(",
"PoolClientInterface",
"::",
"CLIENT_POOL_EVENT_CLOSE",
",",
"function",
"(",
")",
"use",
"(",
"$",
"client",
",",
"$",
"clientId",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_clients",
"[",
"$",
"clientId",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_clientsStates",
"[",
"$",
"clientId",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_clientsQueueCounters",
"[",
"$",
"clientId",
"]",
")",
";",
"$",
"client",
"->",
"removeAllListeners",
"(",
"PoolClientInterface",
"::",
"CLIENT_POOL_EVENT_CHANGE_STATE",
")",
";",
"$",
"client",
"->",
"removeAllListeners",
"(",
"PoolClientInterface",
"::",
"CLIENT_POOL_EVENT_CHANGE_QUEUE",
")",
";",
"}",
")",
";",
"//Change client state",
"$",
"client",
"->",
"on",
"(",
"PoolClientInterface",
"::",
"CLIENT_POOL_EVENT_CHANGE_STATE",
",",
"function",
"(",
"$",
"state",
")",
"use",
"(",
"$",
"client",
",",
"$",
"clientId",
")",
"{",
"$",
"this",
"->",
"_clientsStates",
"[",
"$",
"clientId",
"]",
"=",
"$",
"state",
";",
"}",
")",
";",
"//Change client queue count",
"$",
"client",
"->",
"on",
"(",
"PoolClientInterface",
"::",
"CLIENT_POOL_EVENT_CHANGE_QUEUE",
",",
"function",
"(",
"$",
"queueCount",
")",
"use",
"(",
"$",
"client",
",",
"$",
"clientId",
")",
"{",
"$",
"this",
"->",
"_clientsQueueCounters",
"[",
"$",
"clientId",
"]",
"=",
"$",
"queueCount",
";",
"}",
")",
";",
"}"
] | Bind event handlers to client instance
@param PoolClientInterface $client | [
"Bind",
"event",
"handlers",
"to",
"client",
"instance"
] | f1ac06550320ab0456df16b3e1e3f49da1aa4b98 | https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/Pool.php#L185-L207 |
4,228 | digit-soft/re-action-clients-pool | src/Pool.php | Pool.createCleanupTimer | protected function createCleanupTimer()
{
if (!isset($this->clientTtl)) {
return;
}
$this->_clientsCleanupTimer = $this->loop->addPeriodicTimer(3, function($timer) {
$expireTime = time() - $this->clientTtl;
foreach ($this->_clients as $client) {
if ($client->createdAt < $expireTime) {
$client->clientClose();
}
}
});
} | php | protected function createCleanupTimer()
{
if (!isset($this->clientTtl)) {
return;
}
$this->_clientsCleanupTimer = $this->loop->addPeriodicTimer(3, function($timer) {
$expireTime = time() - $this->clientTtl;
foreach ($this->_clients as $client) {
if ($client->createdAt < $expireTime) {
$client->clientClose();
}
}
});
} | [
"protected",
"function",
"createCleanupTimer",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"clientTtl",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_clientsCleanupTimer",
"=",
"$",
"this",
"->",
"loop",
"->",
"addPeriodicTimer",
"(",
"3",
",",
"function",
"(",
"$",
"timer",
")",
"{",
"$",
"expireTime",
"=",
"time",
"(",
")",
"-",
"$",
"this",
"->",
"clientTtl",
";",
"foreach",
"(",
"$",
"this",
"->",
"_clients",
"as",
"$",
"client",
")",
"{",
"if",
"(",
"$",
"client",
"->",
"createdAt",
"<",
"$",
"expireTime",
")",
"{",
"$",
"client",
"->",
"clientClose",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Create cleanup timer if Client TTL is configured | [
"Create",
"cleanup",
"timer",
"if",
"Client",
"TTL",
"is",
"configured"
] | f1ac06550320ab0456df16b3e1e3f49da1aa4b98 | https://github.com/digit-soft/re-action-clients-pool/blob/f1ac06550320ab0456df16b3e1e3f49da1aa4b98/src/Pool.php#L212-L225 |
4,229 | open-orchestra/open-orchestra-media-admin-bundle | MediaAdmin/Security/Authorization/Voter/AbstractMediaFolderVoter.php | AbstractMediaFolderVoter.voteForReadAction | protected function voteForReadAction($folder, TokenInterface $token)
{
return $this->isSubjectInPerimeter($this->getPath($folder), $token->getUser(), MediaFolderInterface::ENTITY_TYPE);
} | php | protected function voteForReadAction($folder, TokenInterface $token)
{
return $this->isSubjectInPerimeter($this->getPath($folder), $token->getUser(), MediaFolderInterface::ENTITY_TYPE);
} | [
"protected",
"function",
"voteForReadAction",
"(",
"$",
"folder",
",",
"TokenInterface",
"$",
"token",
")",
"{",
"return",
"$",
"this",
"->",
"isSubjectInPerimeter",
"(",
"$",
"this",
"->",
"getPath",
"(",
"$",
"folder",
")",
",",
"$",
"token",
"->",
"getUser",
"(",
")",
",",
"MediaFolderInterface",
"::",
"ENTITY_TYPE",
")",
";",
"}"
] | Vote for Read action
A user can read a folder if it is in his perimeter
@param mixed $folder
@param TokenInterface $token
@return bool | [
"Vote",
"for",
"Read",
"action",
"A",
"user",
"can",
"read",
"a",
"folder",
"if",
"it",
"is",
"in",
"his",
"perimeter"
] | 743fa00a6491b84d67221e215a806d8b210bf773 | https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdmin/Security/Authorization/Voter/AbstractMediaFolderVoter.php#L77-L80 |
4,230 | ouranoshong/phmessage | libs/StreamWrapper.php | StreamWrapper.getResource | public static function getResource(StreamInterface $stream)
{
self::register();
if ($stream->isReadable()) {
$mode = $stream->isWritable() ? 'r+' : 'r';
} elseif ($stream->isWritable()) {
$mode = 'w';
} else {
throw new \InvalidArgumentException('The stream must be readable, '
.'writable, or both.');
}
return fopen('phmessage://stream', $mode, null, stream_context_create([
'phmessage' => ['stream' => $stream],
]));
} | php | public static function getResource(StreamInterface $stream)
{
self::register();
if ($stream->isReadable()) {
$mode = $stream->isWritable() ? 'r+' : 'r';
} elseif ($stream->isWritable()) {
$mode = 'w';
} else {
throw new \InvalidArgumentException('The stream must be readable, '
.'writable, or both.');
}
return fopen('phmessage://stream', $mode, null, stream_context_create([
'phmessage' => ['stream' => $stream],
]));
} | [
"public",
"static",
"function",
"getResource",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"self",
"::",
"register",
"(",
")",
";",
"if",
"(",
"$",
"stream",
"->",
"isReadable",
"(",
")",
")",
"{",
"$",
"mode",
"=",
"$",
"stream",
"->",
"isWritable",
"(",
")",
"?",
"'r+'",
":",
"'r'",
";",
"}",
"elseif",
"(",
"$",
"stream",
"->",
"isWritable",
"(",
")",
")",
"{",
"$",
"mode",
"=",
"'w'",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The stream must be readable, '",
".",
"'writable, or both.'",
")",
";",
"}",
"return",
"fopen",
"(",
"'phmessage://stream'",
",",
"$",
"mode",
",",
"null",
",",
"stream_context_create",
"(",
"[",
"'phmessage'",
"=>",
"[",
"'stream'",
"=>",
"$",
"stream",
"]",
",",
"]",
")",
")",
";",
"}"
] | Returns a resource representing the stream.
@param StreamInterface $stream The stream to get a resource for
@return resource
@throws \InvalidArgumentException if stream is not readable or writable | [
"Returns",
"a",
"resource",
"representing",
"the",
"stream",
"."
] | be973017e7070f78e3041cf9c64c7cbf2dd500a2 | https://github.com/ouranoshong/phmessage/blob/be973017e7070f78e3041cf9c64c7cbf2dd500a2/libs/StreamWrapper.php#L35-L51 |
4,231 | yadakhov/tor | src/Tor.php | Tor.command | public function command($command)
{
if (!in_array($command, ['start', 'stop', 'restart', 'reload', 'force-reload', 'status'])) {
throw new \InvalidArgumentException($command);
}
$command = 'sudo /etc/init.d/tor '.$command;
$command = new Command($command);
$command->execute();
return $command;
} | php | public function command($command)
{
if (!in_array($command, ['start', 'stop', 'restart', 'reload', 'force-reload', 'status'])) {
throw new \InvalidArgumentException($command);
}
$command = 'sudo /etc/init.d/tor '.$command;
$command = new Command($command);
$command->execute();
return $command;
} | [
"public",
"function",
"command",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"command",
",",
"[",
"'start'",
",",
"'stop'",
",",
"'restart'",
",",
"'reload'",
",",
"'force-reload'",
",",
"'status'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"command",
")",
";",
"}",
"$",
"command",
"=",
"'sudo /etc/init.d/tor '",
".",
"$",
"command",
";",
"$",
"command",
"=",
"new",
"Command",
"(",
"$",
"command",
")",
";",
"$",
"command",
"->",
"execute",
"(",
")",
";",
"return",
"$",
"command",
";",
"}"
] | Execute tor command
@param $command
@return Command|string | [
"Execute",
"tor",
"command"
] | 1f6d3ab59b81847e188d3889fe909ffce4f64eed | https://github.com/yadakhov/tor/blob/1f6d3ab59b81847e188d3889fe909ffce4f64eed/src/Tor.php#L26-L37 |
4,232 | yadakhov/tor | src/Tor.php | Tor.curl | public function curl($url)
{
$ip = '127.0.0.1';
$port = '9051';
$auth = 'PASSWORD';
$command = 'signal NEWNYM';
$fp = fsockopen($ip, $port, $error_number, $err_string, 2);
if (!$fp) {
echo "ERROR: $error_number : $err_string";
return false;
} else {
fwrite($fp, "AUTHENTICATE \"".$auth."\"\n");
fread($fp, 512);
fwrite($fp, $command."\n");
fread($fp, 512);
}
fclose($fp);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent()); // $this->getUserAgent(true) for random);
curl_setopt($ch, CURLOPT_ENCODING , 'gzip');
$response = curl_exec($ch);
return [$response, $ch];
} | php | public function curl($url)
{
$ip = '127.0.0.1';
$port = '9051';
$auth = 'PASSWORD';
$command = 'signal NEWNYM';
$fp = fsockopen($ip, $port, $error_number, $err_string, 2);
if (!$fp) {
echo "ERROR: $error_number : $err_string";
return false;
} else {
fwrite($fp, "AUTHENTICATE \"".$auth."\"\n");
fread($fp, 512);
fwrite($fp, $command."\n");
fread($fp, 512);
}
fclose($fp);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:9050');
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent()); // $this->getUserAgent(true) for random);
curl_setopt($ch, CURLOPT_ENCODING , 'gzip');
$response = curl_exec($ch);
return [$response, $ch];
} | [
"public",
"function",
"curl",
"(",
"$",
"url",
")",
"{",
"$",
"ip",
"=",
"'127.0.0.1'",
";",
"$",
"port",
"=",
"'9051'",
";",
"$",
"auth",
"=",
"'PASSWORD'",
";",
"$",
"command",
"=",
"'signal NEWNYM'",
";",
"$",
"fp",
"=",
"fsockopen",
"(",
"$",
"ip",
",",
"$",
"port",
",",
"$",
"error_number",
",",
"$",
"err_string",
",",
"2",
")",
";",
"if",
"(",
"!",
"$",
"fp",
")",
"{",
"echo",
"\"ERROR: $error_number : $err_string\"",
";",
"return",
"false",
";",
"}",
"else",
"{",
"fwrite",
"(",
"$",
"fp",
",",
"\"AUTHENTICATE \\\"\"",
".",
"$",
"auth",
".",
"\"\\\"\\n\"",
")",
";",
"fread",
"(",
"$",
"fp",
",",
"512",
")",
";",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"command",
".",
"\"\\n\"",
")",
";",
"fread",
"(",
"$",
"fp",
",",
"512",
")",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_PROXY",
",",
"'127.0.0.1:9050'",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_PROXYTYPE",
",",
"CURLPROXY_SOCKS5",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_VERBOSE",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_USERAGENT",
",",
"$",
"this",
"->",
"getUserAgent",
"(",
")",
")",
";",
"// $this->getUserAgent(true) for random);",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_ENCODING",
",",
"'gzip'",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"return",
"[",
"$",
"response",
",",
"$",
"ch",
"]",
";",
"}"
] | Tor curl wrapper
@param $url
@return bool|mixed | [
"Tor",
"curl",
"wrapper"
] | 1f6d3ab59b81847e188d3889fe909ffce4f64eed | https://github.com/yadakhov/tor/blob/1f6d3ab59b81847e188d3889fe909ffce4f64eed/src/Tor.php#L138-L172 |
4,233 | yadakhov/tor | src/Tor.php | Tor.getUserAgent | public function getUserAgent($random = false)
{
if ($random === false) {
return 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0';
}
$headers = [
'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0',
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0',
];
$randomKey = array_rand($headers);
return $headers[$randomKey];
} | php | public function getUserAgent($random = false)
{
if ($random === false) {
return 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0';
}
$headers = [
'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0',
'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0',
];
$randomKey = array_rand($headers);
return $headers[$randomKey];
} | [
"public",
"function",
"getUserAgent",
"(",
"$",
"random",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"random",
"===",
"false",
")",
"{",
"return",
"'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0'",
";",
"}",
"$",
"headers",
"=",
"[",
"'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0'",
",",
"'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'",
",",
"'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36'",
",",
"'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36'",
",",
"'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'",
",",
"'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36'",
",",
"'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0'",
",",
"]",
";",
"$",
"randomKey",
"=",
"array_rand",
"(",
"$",
"headers",
")",
";",
"return",
"$",
"headers",
"[",
"$",
"randomKey",
"]",
";",
"}"
] | Get a user agent
@param bool $random
@return string | [
"Get",
"a",
"user",
"agent"
] | 1f6d3ab59b81847e188d3889fe909ffce4f64eed | https://github.com/yadakhov/tor/blob/1f6d3ab59b81847e188d3889fe909ffce4f64eed/src/Tor.php#L180-L199 |
4,234 | samurai-fw/samurai | src/Samurai/Component/Request/HttpRequest.php | HttpRequest.getAsBool | public function getAsBool($key, $default = 0)
{
$value = $this->get($key, $default);
if ($value === 'false') return false;
return (bool) $value;
} | php | public function getAsBool($key, $default = 0)
{
$value = $this->get($key, $default);
if ($value === 'false') return false;
return (bool) $value;
} | [
"public",
"function",
"getAsBool",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"0",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"if",
"(",
"$",
"value",
"===",
"'false'",
")",
"return",
"false",
";",
"return",
"(",
"bool",
")",
"$",
"value",
";",
"}"
] | get as bool
@param string $key
@param mixed $default
@return int | [
"get",
"as",
"bool"
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Request/HttpRequest.php#L156-L162 |
4,235 | aedart/model | src/Traits/Strings/MiddleNameTrait.php | MiddleNameTrait.getMiddleName | public function getMiddleName() : ?string
{
if ( ! $this->hasMiddleName()) {
$this->setMiddleName($this->getDefaultMiddleName());
}
return $this->middleName;
} | php | public function getMiddleName() : ?string
{
if ( ! $this->hasMiddleName()) {
$this->setMiddleName($this->getDefaultMiddleName());
}
return $this->middleName;
} | [
"public",
"function",
"getMiddleName",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMiddleName",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setMiddleName",
"(",
"$",
"this",
"->",
"getDefaultMiddleName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"middleName",
";",
"}"
] | Get middle name
If no "middle name" value has been set, this method will
set and return a default "middle name" value,
if any such value is available
@see getDefaultMiddleName()
@return string|null middle name or null if no middle name has been set | [
"Get",
"middle",
"name"
] | 9a562c1c53a276d01ace0ab71f5305458bea542f | https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/MiddleNameTrait.php#L48-L54 |
4,236 | crater-framework/crater-php-framework | FlashMessage.php | FlashMessage.getFlashMessage | public function getFlashMessage()
{
if (Session::get('FMess') === true) {
$response = array(
'type' => Session::get('FMessType'),
'message' => Session::get('FMessMsg')
);
Session::destroy('FMess');
Session::destroy('FMessType');
Session::destroy('FMessMsg');
return $response;
}
return false;
} | php | public function getFlashMessage()
{
if (Session::get('FMess') === true) {
$response = array(
'type' => Session::get('FMessType'),
'message' => Session::get('FMessMsg')
);
Session::destroy('FMess');
Session::destroy('FMessType');
Session::destroy('FMessMsg');
return $response;
}
return false;
} | [
"public",
"function",
"getFlashMessage",
"(",
")",
"{",
"if",
"(",
"Session",
"::",
"get",
"(",
"'FMess'",
")",
"===",
"true",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"'type'",
"=>",
"Session",
"::",
"get",
"(",
"'FMessType'",
")",
",",
"'message'",
"=>",
"Session",
"::",
"get",
"(",
"'FMessMsg'",
")",
")",
";",
"Session",
"::",
"destroy",
"(",
"'FMess'",
")",
";",
"Session",
"::",
"destroy",
"(",
"'FMessType'",
")",
";",
"Session",
"::",
"destroy",
"(",
"'FMessMsg'",
")",
";",
"return",
"$",
"response",
";",
"}",
"return",
"false",
";",
"}"
] | Create info flash message
@return array|bool | [
"Create",
"info",
"flash",
"message"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/FlashMessage.php#L60-L75 |
4,237 | leedave/translate | src/Translate.php | Translate.__ | public static function __(string $code) : string
{
$t = self::getInstance();
if (!isset($t->translations[$code])) {
return $code;
}
return $t->translations[$code];
} | php | public static function __(string $code) : string
{
$t = self::getInstance();
if (!isset($t->translations[$code])) {
return $code;
}
return $t->translations[$code];
} | [
"public",
"static",
"function",
"__",
"(",
"string",
"$",
"code",
")",
":",
"string",
"{",
"$",
"t",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"t",
"->",
"translations",
"[",
"$",
"code",
"]",
")",
")",
"{",
"return",
"$",
"code",
";",
"}",
"return",
"$",
"t",
"->",
"translations",
"[",
"$",
"code",
"]",
";",
"}"
] | Get the current Translation
@param string $code
@return string | [
"Get",
"the",
"current",
"Translation"
] | 7a1996f4b313b9fb6559a97e0e60e83ac060c2ff | https://github.com/leedave/translate/blob/7a1996f4b313b9fb6559a97e0e60e83ac060c2ff/src/Translate.php#L53-L60 |
4,238 | glendmaatita/Tolkien | src/Tolkien/BuildSite.php | BuildSite.build | public function build()
{
$this->site = new Site($this->config['config']['url'], $this->config['config']['title'], $this->config['config']['tagline'], $this->getPosts(), $this->getPages(), $this->getCategories(), $this->getAssets(), $this->getPaginations(), $this->getAuthors() );
} | php | public function build()
{
$this->site = new Site($this->config['config']['url'], $this->config['config']['title'], $this->config['config']['tagline'], $this->getPosts(), $this->getPages(), $this->getCategories(), $this->getAssets(), $this->getPaginations(), $this->getAuthors() );
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"site",
"=",
"new",
"Site",
"(",
"$",
"this",
"->",
"config",
"[",
"'config'",
"]",
"[",
"'url'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'config'",
"]",
"[",
"'title'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'config'",
"]",
"[",
"'tagline'",
"]",
",",
"$",
"this",
"->",
"getPosts",
"(",
")",
",",
"$",
"this",
"->",
"getPages",
"(",
")",
",",
"$",
"this",
"->",
"getCategories",
"(",
")",
",",
"$",
"this",
"->",
"getAssets",
"(",
")",
",",
"$",
"this",
"->",
"getPaginations",
"(",
")",
",",
"$",
"this",
"->",
"getAuthors",
"(",
")",
")",
";",
"}"
] | Main method to site
@return Model\Site | [
"Main",
"method",
"to",
"site"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildSite.php#L77-L80 |
4,239 | open-orchestra/open-orchestra-media-bundle | Media/BBcode/MediaCodeDefinition.php | MediaCodeDefinition.getFormat | protected function getFormat(BBcodeElementNodeInterface $el)
{
$options = $el->getAttribute();
$options = json_decode($options['media'], true);
return is_array($options) && array_key_exists('format', $options) ? $options['format'] : MediaInterface::MEDIA_ORIGINAL;
} | php | protected function getFormat(BBcodeElementNodeInterface $el)
{
$options = $el->getAttribute();
$options = json_decode($options['media'], true);
return is_array($options) && array_key_exists('format', $options) ? $options['format'] : MediaInterface::MEDIA_ORIGINAL;
} | [
"protected",
"function",
"getFormat",
"(",
"BBcodeElementNodeInterface",
"$",
"el",
")",
"{",
"$",
"options",
"=",
"$",
"el",
"->",
"getAttribute",
"(",
")",
";",
"$",
"options",
"=",
"json_decode",
"(",
"$",
"options",
"[",
"'media'",
"]",
",",
"true",
")",
";",
"return",
"is_array",
"(",
"$",
"options",
")",
"&&",
"array_key_exists",
"(",
"'format'",
",",
"$",
"options",
")",
"?",
"$",
"options",
"[",
"'format'",
"]",
":",
"MediaInterface",
"::",
"MEDIA_ORIGINAL",
";",
"}"
] | Get requested media format
@param BBcodeElementNodeInterface $el
@return string | [
"Get",
"requested",
"media",
"format"
] | 702121d1329c70c3a93dc216a1b47917e186365c | https://github.com/open-orchestra/open-orchestra-media-bundle/blob/702121d1329c70c3a93dc216a1b47917e186365c/Media/BBcode/MediaCodeDefinition.php#L34-L40 |
4,240 | open-orchestra/open-orchestra-media-bundle | Media/BBcode/MediaCodeDefinition.php | MediaCodeDefinition.getStyle | protected function getStyle(BBcodeElementNodeInterface $el)
{
$options = $el->getAttribute();
$options = json_decode($options['media'], true);
return is_array($options) && array_key_exists('style', $options) ? $options['style'] : '';
} | php | protected function getStyle(BBcodeElementNodeInterface $el)
{
$options = $el->getAttribute();
$options = json_decode($options['media'], true);
return is_array($options) && array_key_exists('style', $options) ? $options['style'] : '';
} | [
"protected",
"function",
"getStyle",
"(",
"BBcodeElementNodeInterface",
"$",
"el",
")",
"{",
"$",
"options",
"=",
"$",
"el",
"->",
"getAttribute",
"(",
")",
";",
"$",
"options",
"=",
"json_decode",
"(",
"$",
"options",
"[",
"'media'",
"]",
",",
"true",
")",
";",
"return",
"is_array",
"(",
"$",
"options",
")",
"&&",
"array_key_exists",
"(",
"'style'",
",",
"$",
"options",
")",
"?",
"$",
"options",
"[",
"'style'",
"]",
":",
"''",
";",
"}"
] | Get requested media style
@param BBcodeElementNodeInterface $el
@return string | [
"Get",
"requested",
"media",
"style"
] | 702121d1329c70c3a93dc216a1b47917e186365c | https://github.com/open-orchestra/open-orchestra-media-bundle/blob/702121d1329c70c3a93dc216a1b47917e186365c/Media/BBcode/MediaCodeDefinition.php#L49-L55 |
4,241 | las93/attila | Attila/Orm.php | Orm._prepareWhere | private function _prepareWhere()
{
$sQuery = '';
if (is_array($this->_mWhere) && count($this->_mWhere) > 0) {
$sQuery .= ' WHERE ';
foreach ($this->_mWhere as $sKey => $sValue) {
$sQuery .= "".$sKey." = '".str_replace("'", "\'", $sValue)."' && ";
}
$sQuery = substr($sQuery, 0, -3);
}
else if ($this->_mWhere instanceof Where) {
$sQuery .= ' WHERE 1 '.$this->_mWhere->get();
}
$sQuery = str_replace('1 &&', '', $sQuery);
return $sQuery;
} | php | private function _prepareWhere()
{
$sQuery = '';
if (is_array($this->_mWhere) && count($this->_mWhere) > 0) {
$sQuery .= ' WHERE ';
foreach ($this->_mWhere as $sKey => $sValue) {
$sQuery .= "".$sKey." = '".str_replace("'", "\'", $sValue)."' && ";
}
$sQuery = substr($sQuery, 0, -3);
}
else if ($this->_mWhere instanceof Where) {
$sQuery .= ' WHERE 1 '.$this->_mWhere->get();
}
$sQuery = str_replace('1 &&', '', $sQuery);
return $sQuery;
} | [
"private",
"function",
"_prepareWhere",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_mWhere",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_mWhere",
")",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"' WHERE '",
";",
"foreach",
"(",
"$",
"this",
"->",
"_mWhere",
"as",
"$",
"sKey",
"=>",
"$",
"sValue",
")",
"{",
"$",
"sQuery",
".=",
"\"\"",
".",
"$",
"sKey",
".",
"\" = '\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"sValue",
")",
".",
"\"' && \"",
";",
"}",
"$",
"sQuery",
"=",
"substr",
"(",
"$",
"sQuery",
",",
"0",
",",
"-",
"3",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"_mWhere",
"instanceof",
"Where",
")",
"{",
"$",
"sQuery",
".=",
"' WHERE 1 '",
".",
"$",
"this",
"->",
"_mWhere",
"->",
"get",
"(",
")",
";",
"}",
"$",
"sQuery",
"=",
"str_replace",
"(",
"'1 &&'",
",",
"''",
",",
"$",
"sQuery",
")",
";",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the where
@access private
@return string | [
"prepare",
"the",
"where"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L684-L707 |
4,242 | las93/attila | Attila/Orm.php | Orm._prepareHaving | private function _prepareHaving()
{
$sQuery = '';
if (is_array($this->_aHaving) && count($this->_aHaving) > 0) {
$sQuery .= ' HAVING ';
foreach ($this->_aHaving as $sKey => $sValue) {
$sQuery .= "".$sKey." = '".str_replace("'", "\'", $sValue)."' && ";
}
$sQuery = substr($sQuery, 0, -3);
}
else if ($this->_aHaving instanceof Where) {
$sQuery .= ' HAVING 1 '.$this->_aHaving->get();
}
return $sQuery;
} | php | private function _prepareHaving()
{
$sQuery = '';
if (is_array($this->_aHaving) && count($this->_aHaving) > 0) {
$sQuery .= ' HAVING ';
foreach ($this->_aHaving as $sKey => $sValue) {
$sQuery .= "".$sKey." = '".str_replace("'", "\'", $sValue)."' && ";
}
$sQuery = substr($sQuery, 0, -3);
}
else if ($this->_aHaving instanceof Where) {
$sQuery .= ' HAVING 1 '.$this->_aHaving->get();
}
return $sQuery;
} | [
"private",
"function",
"_prepareHaving",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_aHaving",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_aHaving",
")",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"' HAVING '",
";",
"foreach",
"(",
"$",
"this",
"->",
"_aHaving",
"as",
"$",
"sKey",
"=>",
"$",
"sValue",
")",
"{",
"$",
"sQuery",
".=",
"\"\"",
".",
"$",
"sKey",
".",
"\" = '\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"sValue",
")",
".",
"\"' && \"",
";",
"}",
"$",
"sQuery",
"=",
"substr",
"(",
"$",
"sQuery",
",",
"0",
",",
"-",
"3",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"_aHaving",
"instanceof",
"Where",
")",
"{",
"$",
"sQuery",
".=",
"' HAVING 1 '",
".",
"$",
"this",
"->",
"_aHaving",
"->",
"get",
"(",
")",
";",
"}",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the having
@access private
@return string | [
"prepare",
"the",
"having"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L715-L736 |
4,243 | las93/attila | Attila/Orm.php | Orm._prepareJoin | private function _prepareJoin()
{
$sQuery = '';
if (is_array($this->_aJoin) && count($this->_aJoin) > 0) {
foreach ($this->_aJoin as $sKey => $aValue) {
if (isset($aValue['type']) && $aValue['type'] == 'left') {
$sQuery .= " LEFT JOIN `".$aValue['table']."` ";
}
else {
$sQuery .= " INNER JOIN `".$aValue['table']."` ";
}
if (isset($aValue['as']) && $aValue['as']) {
$sQuery .= " AS ".$aValue['as']." ";
}
else {
$sQuery .= " AS t".$this->_iAlias." ";
$this->_iAlias++;
}
$sQuery .= " ON ".$aValue['left_field']." = ".$aValue['right_field']." ";
}
}
return $sQuery;
} | php | private function _prepareJoin()
{
$sQuery = '';
if (is_array($this->_aJoin) && count($this->_aJoin) > 0) {
foreach ($this->_aJoin as $sKey => $aValue) {
if (isset($aValue['type']) && $aValue['type'] == 'left') {
$sQuery .= " LEFT JOIN `".$aValue['table']."` ";
}
else {
$sQuery .= " INNER JOIN `".$aValue['table']."` ";
}
if (isset($aValue['as']) && $aValue['as']) {
$sQuery .= " AS ".$aValue['as']." ";
}
else {
$sQuery .= " AS t".$this->_iAlias." ";
$this->_iAlias++;
}
$sQuery .= " ON ".$aValue['left_field']." = ".$aValue['right_field']." ";
}
}
return $sQuery;
} | [
"private",
"function",
"_prepareJoin",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_aJoin",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_aJoin",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_aJoin",
"as",
"$",
"sKey",
"=>",
"$",
"aValue",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"aValue",
"[",
"'type'",
"]",
")",
"&&",
"$",
"aValue",
"[",
"'type'",
"]",
"==",
"'left'",
")",
"{",
"$",
"sQuery",
".=",
"\" LEFT JOIN `\"",
".",
"$",
"aValue",
"[",
"'table'",
"]",
".",
"\"` \"",
";",
"}",
"else",
"{",
"$",
"sQuery",
".=",
"\" INNER JOIN `\"",
".",
"$",
"aValue",
"[",
"'table'",
"]",
".",
"\"` \"",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"aValue",
"[",
"'as'",
"]",
")",
"&&",
"$",
"aValue",
"[",
"'as'",
"]",
")",
"{",
"$",
"sQuery",
".=",
"\" AS \"",
".",
"$",
"aValue",
"[",
"'as'",
"]",
".",
"\" \"",
";",
"}",
"else",
"{",
"$",
"sQuery",
".=",
"\" AS t\"",
".",
"$",
"this",
"->",
"_iAlias",
".",
"\" \"",
";",
"$",
"this",
"->",
"_iAlias",
"++",
";",
"}",
"$",
"sQuery",
".=",
"\" ON \"",
".",
"$",
"aValue",
"[",
"'left_field'",
"]",
".",
"\" = \"",
".",
"$",
"aValue",
"[",
"'right_field'",
"]",
".",
"\" \"",
";",
"}",
"}",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the join
@access private
@return string | [
"prepare",
"the",
"join"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L744-L776 |
4,244 | las93/attila | Attila/Orm.php | Orm._prepareOrderBy | private function _prepareOrderBy()
{
$sQuery = '';
if (is_array($this->_aOrderBy) && count($this->_aOrderBy) > 0) {
$sQuery .= ' ORDER BY '.implode(',', $this->_aOrderBy).' ';
}
return $sQuery;
} | php | private function _prepareOrderBy()
{
$sQuery = '';
if (is_array($this->_aOrderBy) && count($this->_aOrderBy) > 0) {
$sQuery .= ' ORDER BY '.implode(',', $this->_aOrderBy).' ';
}
return $sQuery;
} | [
"private",
"function",
"_prepareOrderBy",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_aOrderBy",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_aOrderBy",
")",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"' ORDER BY '",
".",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"_aOrderBy",
")",
".",
"' '",
";",
"}",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the order by
@access private
@return string | [
"prepare",
"the",
"order",
"by"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L784-L794 |
4,245 | las93/attila | Attila/Orm.php | Orm._prepareGroupBy | private function _prepareGroupBy()
{
$sQuery = '';
if (is_array($this->_aGroupBy) && count($this->_aGroupBy) > 0) {
$sQuery .= ' GROUP BY '.implode(',', $this->_aGroupBy).' ';
}
return $sQuery;
} | php | private function _prepareGroupBy()
{
$sQuery = '';
if (is_array($this->_aGroupBy) && count($this->_aGroupBy) > 0) {
$sQuery .= ' GROUP BY '.implode(',', $this->_aGroupBy).' ';
}
return $sQuery;
} | [
"private",
"function",
"_prepareGroupBy",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"_aGroupBy",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"_aGroupBy",
")",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"' GROUP BY '",
".",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"_aGroupBy",
")",
".",
"' '",
";",
"}",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the group by
@access private
@return string | [
"prepare",
"the",
"group",
"by"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L802-L812 |
4,246 | las93/attila | Attila/Orm.php | Orm._prepareLimit | private function _prepareLimit()
{
$sQuery = '';
$limit = (int) $this->_iLimit;
$iOffset = $this->_iOffset;
if($limit != 0 || $iOffset > 0) { $sQuery .= ' LIMIT '; }
if($iOffset > 0) { $sQuery .= $iOffset.', '.$limit; }
else if($limit != 0) { $sQuery .= $limit.' '; }
return $sQuery;
} | php | private function _prepareLimit()
{
$sQuery = '';
$limit = (int) $this->_iLimit;
$iOffset = $this->_iOffset;
if($limit != 0 || $iOffset > 0) { $sQuery .= ' LIMIT '; }
if($iOffset > 0) { $sQuery .= $iOffset.', '.$limit; }
else if($limit != 0) { $sQuery .= $limit.' '; }
return $sQuery;
} | [
"private",
"function",
"_prepareLimit",
"(",
")",
"{",
"$",
"sQuery",
"=",
"''",
";",
"$",
"limit",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"_iLimit",
";",
"$",
"iOffset",
"=",
"$",
"this",
"->",
"_iOffset",
";",
"if",
"(",
"$",
"limit",
"!=",
"0",
"||",
"$",
"iOffset",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"' LIMIT '",
";",
"}",
"if",
"(",
"$",
"iOffset",
">",
"0",
")",
"{",
"$",
"sQuery",
".=",
"$",
"iOffset",
".",
"', '",
".",
"$",
"limit",
";",
"}",
"else",
"if",
"(",
"$",
"limit",
"!=",
"0",
")",
"{",
"$",
"sQuery",
".=",
"$",
"limit",
".",
"' '",
";",
"}",
"return",
"$",
"sQuery",
";",
"}"
] | prepare the limit
@access private
@return string | [
"prepare",
"the",
"limit"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L820-L832 |
4,247 | las93/attila | Attila/Orm.php | Orm.flush | public function flush()
{
$this->where = null;
$this->_aSelect = array();
$this->_sFrom = '';
$this->_sFromAs = '';
$this->_aJoin = array();
$this->_sUpdate = '';
$this->_mWhere = array();
$this->_aSet = array();
$this->_sInsertInto = '';
$this->_aValues = array();
$this->_sDelete = '';
$this->_aOrderBy = array();
$this->_aGroupBy = array();
$this->_iLimit = null;
return $this;
} | php | public function flush()
{
$this->where = null;
$this->_aSelect = array();
$this->_sFrom = '';
$this->_sFromAs = '';
$this->_aJoin = array();
$this->_sUpdate = '';
$this->_mWhere = array();
$this->_aSet = array();
$this->_sInsertInto = '';
$this->_aValues = array();
$this->_sDelete = '';
$this->_aOrderBy = array();
$this->_aGroupBy = array();
$this->_iLimit = null;
return $this;
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"this",
"->",
"where",
"=",
"null",
";",
"$",
"this",
"->",
"_aSelect",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_sFrom",
"=",
"''",
";",
"$",
"this",
"->",
"_sFromAs",
"=",
"''",
";",
"$",
"this",
"->",
"_aJoin",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_sUpdate",
"=",
"''",
";",
"$",
"this",
"->",
"_mWhere",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_aSet",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_sInsertInto",
"=",
"''",
";",
"$",
"this",
"->",
"_aValues",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_sDelete",
"=",
"''",
";",
"$",
"this",
"->",
"_aOrderBy",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_aGroupBy",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_iLimit",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] | flush the ORM
@access public
@return string | [
"flush",
"the",
"ORM"
] | ad73611956ee96a95170a6340f110a948cfe5965 | https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Orm.php#L851-L868 |
4,248 | codenamephp/platform.di | src/main/php/de/codenamephp/platform/di/definitionsProvider/dependency/handler/ClassNamesInArray.php | ClassNamesInArray.addDependencies | public function addDependencies(array $dependenciesToAdd) {
$this->setCollectedDependencies(array_merge(array_unique(array_merge($this->getCollectedDependencies(), $dependenciesToAdd))));
return $this;
} | php | public function addDependencies(array $dependenciesToAdd) {
$this->setCollectedDependencies(array_merge(array_unique(array_merge($this->getCollectedDependencies(), $dependenciesToAdd))));
return $this;
} | [
"public",
"function",
"addDependencies",
"(",
"array",
"$",
"dependenciesToAdd",
")",
"{",
"$",
"this",
"->",
"setCollectedDependencies",
"(",
"array_merge",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getCollectedDependencies",
"(",
")",
",",
"$",
"dependenciesToAdd",
")",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the given dependencies to the collectedDependencies without duplicating values and while maintining serial numerical index
@param string[] $dependenciesToAdd
@return $this | [
"Adds",
"the",
"given",
"dependencies",
"to",
"the",
"collectedDependencies",
"without",
"duplicating",
"values",
"and",
"while",
"maintining",
"serial",
"numerical",
"index"
] | bf8a191f2528218beee0a71b923e846a1046cfb7 | https://github.com/codenamephp/platform.di/blob/bf8a191f2528218beee0a71b923e846a1046cfb7/src/main/php/de/codenamephp/platform/di/definitionsProvider/dependency/handler/ClassNamesInArray.php#L66-L69 |
4,249 | mickrip/fwoot-core | src/Fw/Bundler.php | Bundler.find | static function find($file, $prefix_cdn_config = "cdn")
{
if (!$real_path = \Fw\Find::in("assets", $file)) throw new \Exception("$file not found");
$so = strlen(\Fw\Config::get("docroot")) - 1;
return \Fw\Config::get($prefix_cdn_config) . substr($real_path, $so);
} | php | static function find($file, $prefix_cdn_config = "cdn")
{
if (!$real_path = \Fw\Find::in("assets", $file)) throw new \Exception("$file not found");
$so = strlen(\Fw\Config::get("docroot")) - 1;
return \Fw\Config::get($prefix_cdn_config) . substr($real_path, $so);
} | [
"static",
"function",
"find",
"(",
"$",
"file",
",",
"$",
"prefix_cdn_config",
"=",
"\"cdn\"",
")",
"{",
"if",
"(",
"!",
"$",
"real_path",
"=",
"\\",
"Fw",
"\\",
"Find",
"::",
"in",
"(",
"\"assets\"",
",",
"$",
"file",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"\"$file not found\"",
")",
";",
"$",
"so",
"=",
"strlen",
"(",
"\\",
"Fw",
"\\",
"Config",
"::",
"get",
"(",
"\"docroot\"",
")",
")",
"-",
"1",
";",
"return",
"\\",
"Fw",
"\\",
"Config",
"::",
"get",
"(",
"$",
"prefix_cdn_config",
")",
".",
"substr",
"(",
"$",
"real_path",
",",
"$",
"so",
")",
";",
"}"
] | Searches for asset based on the asset resources defined in \Fw\Find
@param $file
@return string
@throws \Exception | [
"Searches",
"for",
"asset",
"based",
"on",
"the",
"asset",
"resources",
"defined",
"in",
"\\",
"Fw",
"\\",
"Find"
] | 10fae2ee4b2c85454bc91067f0f9adeef64fdd4d | https://github.com/mickrip/fwoot-core/blob/10fae2ee4b2c85454bc91067f0f9adeef64fdd4d/src/Fw/Bundler.php#L24-L29 |
4,250 | Moln/gzfextra | src/Gzfextra/EasyMvc/Http/Request.php | Request.getContent | public function getContent()
{
if (empty($this->content)) {
$requestBody = file_get_contents('php://input');
if (strlen($requestBody) > 0) {
$this->content = $requestBody;
}
}
return $this->content;
} | php | public function getContent()
{
if (empty($this->content)) {
$requestBody = file_get_contents('php://input');
if (strlen($requestBody) > 0) {
$this->content = $requestBody;
}
}
return $this->content;
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"$",
"requestBody",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"requestBody",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"$",
"requestBody",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"content",
";",
"}"
] | Get raw request body
@return string | [
"Get",
"raw",
"request",
"body"
] | be71ca935c9bd8f8d38c97190a36b901de5d2254 | https://github.com/Moln/gzfextra/blob/be71ca935c9bd8f8d38c97190a36b901de5d2254/src/Gzfextra/EasyMvc/Http/Request.php#L83-L93 |
4,251 | Moln/gzfextra | src/Gzfextra/EasyMvc/Http/Request.php | Request.getServer | public function getServer($name = null, $default = null)
{
if ($this->serverParams === null) {
$this->serverParams = new Parameters();
}
if ($name === null) {
return $this->serverParams;
}
return $this->serverParams->get($name, $default);
} | php | public function getServer($name = null, $default = null)
{
if ($this->serverParams === null) {
$this->serverParams = new Parameters();
}
if ($name === null) {
return $this->serverParams;
}
return $this->serverParams->get($name, $default);
} | [
"public",
"function",
"getServer",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"serverParams",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"serverParams",
"=",
"new",
"Parameters",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"serverParams",
";",
"}",
"return",
"$",
"this",
"->",
"serverParams",
"->",
"get",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"}"
] | Return the parameter container responsible for server parameters or a single parameter value.
@param string|null $name Parameter name to retrieve, or null to get the whole container.
@param mixed|null $default Default value to use when the parameter is missing.
@see http://www.faqs.org/rfcs/rfc3875.html
@return \Zend\Stdlib\ParametersInterface|mixed | [
"Return",
"the",
"parameter",
"container",
"responsible",
"for",
"server",
"parameters",
"or",
"a",
"single",
"parameter",
"value",
"."
] | be71ca935c9bd8f8d38c97190a36b901de5d2254 | https://github.com/Moln/gzfextra/blob/be71ca935c9bd8f8d38c97190a36b901de5d2254/src/Gzfextra/EasyMvc/Http/Request.php#L193-L204 |
4,252 | Moln/gzfextra | src/Gzfextra/EasyMvc/Http/Request.php | Request.getEnv | public function getEnv($name = null, $default = null)
{
if ($this->envParams === null) {
$this->envParams = new Parameters();
}
if ($name === null) {
return $this->envParams;
}
return $this->envParams->get($name, $default);
} | php | public function getEnv($name = null, $default = null)
{
if ($this->envParams === null) {
$this->envParams = new Parameters();
}
if ($name === null) {
return $this->envParams;
}
return $this->envParams->get($name, $default);
} | [
"public",
"function",
"getEnv",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"envParams",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"envParams",
"=",
"new",
"Parameters",
"(",
")",
";",
"}",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"envParams",
";",
"}",
"return",
"$",
"this",
"->",
"envParams",
"->",
"get",
"(",
"$",
"name",
",",
"$",
"default",
")",
";",
"}"
] | Return the parameter container responsible for env parameters or a single parameter value.
@param string|null $name Parameter name to retrieve, or null to get the whole container.
@param mixed|null $default Default value to use when the parameter is missing. * @return \Zend\Stdlib\ParametersInterface
@return \Zend\Stdlib\ParametersInterface|mixed | [
"Return",
"the",
"parameter",
"container",
"responsible",
"for",
"env",
"parameters",
"or",
"a",
"single",
"parameter",
"value",
"."
] | be71ca935c9bd8f8d38c97190a36b901de5d2254 | https://github.com/Moln/gzfextra/blob/be71ca935c9bd8f8d38c97190a36b901de5d2254/src/Gzfextra/EasyMvc/Http/Request.php#L226-L237 |
4,253 | Moln/gzfextra | src/Gzfextra/EasyMvc/Http/Request.php | Request.detectBasePath | protected function detectBasePath()
{
$filename = basename($this->getServer()->get('SCRIPT_FILENAME', ''));
$baseUrl = $this->getBaseUrl();
// Empty base url detected
if ($baseUrl === '') {
return '';
}
// basename() matches the script filename; return the directory
if (basename($baseUrl) === $filename) {
return str_replace('\\', '/', dirname($baseUrl));
}
// Base path is identical to base URL
return $baseUrl;
} | php | protected function detectBasePath()
{
$filename = basename($this->getServer()->get('SCRIPT_FILENAME', ''));
$baseUrl = $this->getBaseUrl();
// Empty base url detected
if ($baseUrl === '') {
return '';
}
// basename() matches the script filename; return the directory
if (basename($baseUrl) === $filename) {
return str_replace('\\', '/', dirname($baseUrl));
}
// Base path is identical to base URL
return $baseUrl;
} | [
"protected",
"function",
"detectBasePath",
"(",
")",
"{",
"$",
"filename",
"=",
"basename",
"(",
"$",
"this",
"->",
"getServer",
"(",
")",
"->",
"get",
"(",
"'SCRIPT_FILENAME'",
",",
"''",
")",
")",
";",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"getBaseUrl",
"(",
")",
";",
"// Empty base url detected",
"if",
"(",
"$",
"baseUrl",
"===",
"''",
")",
"{",
"return",
"''",
";",
"}",
"// basename() matches the script filename; return the directory",
"if",
"(",
"basename",
"(",
"$",
"baseUrl",
")",
"===",
"$",
"filename",
")",
"{",
"return",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"dirname",
"(",
"$",
"baseUrl",
")",
")",
";",
"}",
"// Base path is identical to base URL",
"return",
"$",
"baseUrl",
";",
"}"
] | Autodetect the base path of the request
Uses several criteria to determine the base path of the request.
@return string | [
"Autodetect",
"the",
"base",
"path",
"of",
"the",
"request"
] | be71ca935c9bd8f8d38c97190a36b901de5d2254 | https://github.com/Moln/gzfextra/blob/be71ca935c9bd8f8d38c97190a36b901de5d2254/src/Gzfextra/EasyMvc/Http/Request.php#L362-L379 |
4,254 | dschoenbauer/sql | src/Sql/Query.php | Query.select | public function select(
$table,
$fields = [],
WhereStatementInterface $where = null,
$fetchStyle = PDO::FETCH_ASSOC,
$fetchFlat = false,
$defaultValue = []
) {
return new Select($table, $fields, $where, $fetchStyle, $fetchFlat, $defaultValue);
} | php | public function select(
$table,
$fields = [],
WhereStatementInterface $where = null,
$fetchStyle = PDO::FETCH_ASSOC,
$fetchFlat = false,
$defaultValue = []
) {
return new Select($table, $fields, $where, $fetchStyle, $fetchFlat, $defaultValue);
} | [
"public",
"function",
"select",
"(",
"$",
"table",
",",
"$",
"fields",
"=",
"[",
"]",
",",
"WhereStatementInterface",
"$",
"where",
"=",
"null",
",",
"$",
"fetchStyle",
"=",
"PDO",
"::",
"FETCH_ASSOC",
",",
"$",
"fetchFlat",
"=",
"false",
",",
"$",
"defaultValue",
"=",
"[",
"]",
")",
"{",
"return",
"new",
"Select",
"(",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"where",
",",
"$",
"fetchStyle",
",",
"$",
"fetchFlat",
",",
"$",
"defaultValue",
")",
";",
"}"
] | retrieves data from a PDO connected resource
@param string $table name of the table that houses the data
@param array $fields optional default value: empty array - defines which
fields are returned if no fields defined a star will be used
@param null|WhereStatementInterface $where optional default value: null -
object used to limit the returned results
@param integer $fetchStyle optional default value: PDO::FETCH_ASSOC -
sets how the PDO statement will return records
@param boolean $fetchFlat optional default value: false - true will
return one record, false will return all records
@param mixed $defaultValue optional default value: empty array -
value to be returned on query failure
@return Select the select object responsible for retrieving records
@since v1.0.0 | [
"retrieves",
"data",
"from",
"a",
"PDO",
"connected",
"resource"
] | 1f97b5d53681df97ad9296cd89b584678e30d8b7 | https://github.com/dschoenbauer/sql/blob/1f97b5d53681df97ad9296cd89b584678e30d8b7/src/Sql/Query.php#L83-L92 |
4,255 | dschoenbauer/sql | src/Sql/Query.php | Query.update | public function update($table, array $data, WhereStatementInterface $where = null)
{
return new Update($table, $data, $where);
} | php | public function update($table, array $data, WhereStatementInterface $where = null)
{
return new Update($table, $data, $where);
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"array",
"$",
"data",
",",
"WhereStatementInterface",
"$",
"where",
"=",
"null",
")",
"{",
"return",
"new",
"Update",
"(",
"$",
"table",
",",
"$",
"data",
",",
"$",
"where",
")",
";",
"}"
] | changes values of existing data in a PDO connected resource
@param string $table table with which you wish to update
@param array $data a single level associative array containing keys that
represent the fields and values that represent new values to be updated
into the table
@param null|WhereStatementInterface $where an object that is designed to
return a where statement to limit the data that is affected by the update
@return Update the update object responsible to handling the update of
persistent records.
@since v1.0.0 | [
"changes",
"values",
"of",
"existing",
"data",
"in",
"a",
"PDO",
"connected",
"resource"
] | 1f97b5d53681df97ad9296cd89b584678e30d8b7 | https://github.com/dschoenbauer/sql/blob/1f97b5d53681df97ad9296cd89b584678e30d8b7/src/Sql/Query.php#L106-L109 |
4,256 | FlexPress/component-taxonomy | src/FlexPress/Components/Taxonomy/Helper.php | Helper.registerTaxonomies | public function registerTaxonomies()
{
if (!function_exists('register_taxonomy')) {
return;
}
$this->taxonomies->rewind();
while ($this->taxonomies->valid()) {
$taxonomy = $this->taxonomies->current();
register_taxonomy($taxonomy->getName(), $taxonomy->getSupportedPostTypes(), $taxonomy->getArgs());
$this->taxonomies->next();
}
} | php | public function registerTaxonomies()
{
if (!function_exists('register_taxonomy')) {
return;
}
$this->taxonomies->rewind();
while ($this->taxonomies->valid()) {
$taxonomy = $this->taxonomies->current();
register_taxonomy($taxonomy->getName(), $taxonomy->getSupportedPostTypes(), $taxonomy->getArgs());
$this->taxonomies->next();
}
} | [
"public",
"function",
"registerTaxonomies",
"(",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"'register_taxonomy'",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"taxonomies",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"taxonomies",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"taxonomy",
"=",
"$",
"this",
"->",
"taxonomies",
"->",
"current",
"(",
")",
";",
"register_taxonomy",
"(",
"$",
"taxonomy",
"->",
"getName",
"(",
")",
",",
"$",
"taxonomy",
"->",
"getSupportedPostTypes",
"(",
")",
",",
"$",
"taxonomy",
"->",
"getArgs",
"(",
")",
")",
";",
"$",
"this",
"->",
"taxonomies",
"->",
"next",
"(",
")",
";",
"}",
"}"
] | Registers all the taxonomies added | [
"Registers",
"all",
"the",
"taxonomies",
"added"
] | e917246c2b2837f5db2b8d0ec191d434e658d806 | https://github.com/FlexPress/component-taxonomy/blob/e917246c2b2837f5db2b8d0ec191d434e658d806/src/FlexPress/Components/Taxonomy/Helper.php#L42-L58 |
4,257 | xloit/xloit-bridge-zend-validator | src/Iban.php | Iban.allowBban | public function allowBban($allow = null)
{
if (null !== $allow) {
$this->allowBban = (bool) $allow;
return $this;
}
return $this->allowBban;
} | php | public function allowBban($allow = null)
{
if (null !== $allow) {
$this->allowBban = (bool) $allow;
return $this;
}
return $this->allowBban;
} | [
"public",
"function",
"allowBban",
"(",
"$",
"allow",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"allow",
")",
"{",
"$",
"this",
"->",
"allowBban",
"=",
"(",
"bool",
")",
"$",
"allow",
";",
"return",
"$",
"this",
";",
"}",
"return",
"$",
"this",
"->",
"allowBban",
";",
"}"
] | Allow Bban.
@param bool $allow
@return $this|bool | [
"Allow",
"Bban",
"."
] | 2e789986e6551f157d4e07cf4c27d027dd070324 | https://github.com/xloit/xloit-bridge-zend-validator/blob/2e789986e6551f157d4e07cf4c27d027dd070324/src/Iban.php#L368-L377 |
4,258 | rinvex/obsolete-tenantable | src/Tenantable.php | Tenantable.bootTenantable | public static function bootTenantable()
{
static::addGlobalScope('tenant', function (Builder $builder) {
if ($tenant = config('rinvex.tenantable.tenant')) {
$builder->whereHas('tenants', function (Builder $builder) use ($tenant) {
$key = $tenant instanceof Model ? $tenant->getKeyName() : (is_int($tenant) ? 'id' : 'slug');
$value = $tenant instanceof Model ? $tenant->$key : $tenant;
$builder->where($key, $value);
});
}
});
static::created(function (Model $tenantableModel) {
if ($tenantableModel->queuedTenants) {
$tenantableModel->attachTenants($tenantableModel->queuedTenants);
$tenantableModel->queuedTenants = [];
}
});
static::deleted(function (Model $tenantableModel) {
$tenantableModel->tenants()->detach();
});
} | php | public static function bootTenantable()
{
static::addGlobalScope('tenant', function (Builder $builder) {
if ($tenant = config('rinvex.tenantable.tenant')) {
$builder->whereHas('tenants', function (Builder $builder) use ($tenant) {
$key = $tenant instanceof Model ? $tenant->getKeyName() : (is_int($tenant) ? 'id' : 'slug');
$value = $tenant instanceof Model ? $tenant->$key : $tenant;
$builder->where($key, $value);
});
}
});
static::created(function (Model $tenantableModel) {
if ($tenantableModel->queuedTenants) {
$tenantableModel->attachTenants($tenantableModel->queuedTenants);
$tenantableModel->queuedTenants = [];
}
});
static::deleted(function (Model $tenantableModel) {
$tenantableModel->tenants()->detach();
});
} | [
"public",
"static",
"function",
"bootTenantable",
"(",
")",
"{",
"static",
"::",
"addGlobalScope",
"(",
"'tenant'",
",",
"function",
"(",
"Builder",
"$",
"builder",
")",
"{",
"if",
"(",
"$",
"tenant",
"=",
"config",
"(",
"'rinvex.tenantable.tenant'",
")",
")",
"{",
"$",
"builder",
"->",
"whereHas",
"(",
"'tenants'",
",",
"function",
"(",
"Builder",
"$",
"builder",
")",
"use",
"(",
"$",
"tenant",
")",
"{",
"$",
"key",
"=",
"$",
"tenant",
"instanceof",
"Model",
"?",
"$",
"tenant",
"->",
"getKeyName",
"(",
")",
":",
"(",
"is_int",
"(",
"$",
"tenant",
")",
"?",
"'id'",
":",
"'slug'",
")",
";",
"$",
"value",
"=",
"$",
"tenant",
"instanceof",
"Model",
"?",
"$",
"tenant",
"->",
"$",
"key",
":",
"$",
"tenant",
";",
"$",
"builder",
"->",
"where",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"static",
"::",
"created",
"(",
"function",
"(",
"Model",
"$",
"tenantableModel",
")",
"{",
"if",
"(",
"$",
"tenantableModel",
"->",
"queuedTenants",
")",
"{",
"$",
"tenantableModel",
"->",
"attachTenants",
"(",
"$",
"tenantableModel",
"->",
"queuedTenants",
")",
";",
"$",
"tenantableModel",
"->",
"queuedTenants",
"=",
"[",
"]",
";",
"}",
"}",
")",
";",
"static",
"::",
"deleted",
"(",
"function",
"(",
"Model",
"$",
"tenantableModel",
")",
"{",
"$",
"tenantableModel",
"->",
"tenants",
"(",
")",
"->",
"detach",
"(",
")",
";",
"}",
")",
";",
"}"
] | Boot the tenantable trait for a model.
@return void | [
"Boot",
"the",
"tenantable",
"trait",
"for",
"a",
"model",
"."
] | 211dee32ff22afcebdd79f34c10bd7c572ae0e83 | https://github.com/rinvex/obsolete-tenantable/blob/211dee32ff22afcebdd79f34c10bd7c572ae0e83/src/Tenantable.php#L98-L121 |
4,259 | rinvex/obsolete-tenantable | src/Tenantable.php | Tenantable.tenantsWithGroup | public function tenantsWithGroup(string $group = null): Collection
{
return $this->tenants->filter(function (Tenant $tenant) use ($group) {
return $tenant->group === $group;
});
} | php | public function tenantsWithGroup(string $group = null): Collection
{
return $this->tenants->filter(function (Tenant $tenant) use ($group) {
return $tenant->group === $group;
});
} | [
"public",
"function",
"tenantsWithGroup",
"(",
"string",
"$",
"group",
"=",
"null",
")",
":",
"Collection",
"{",
"return",
"$",
"this",
"->",
"tenants",
"->",
"filter",
"(",
"function",
"(",
"Tenant",
"$",
"tenant",
")",
"use",
"(",
"$",
"group",
")",
"{",
"return",
"$",
"tenant",
"->",
"group",
"===",
"$",
"group",
";",
"}",
")",
";",
"}"
] | Filter tenants with group.
@param string|null $group
@return \Illuminate\Database\Eloquent\Collection | [
"Filter",
"tenants",
"with",
"group",
"."
] | 211dee32ff22afcebdd79f34c10bd7c572ae0e83 | https://github.com/rinvex/obsolete-tenantable/blob/211dee32ff22afcebdd79f34c10bd7c572ae0e83/src/Tenantable.php#L166-L171 |
4,260 | pedrosancao/php-random-data | src/Random.php | Random.getRandomData | protected static function getRandomData($length, $packSize, $packFormat, $callback = null)
{
$data = '';
while(strlen($data) < $length) {
$randomBytes = self::getRandomBytes($packSize);
$value = unpack($packFormat, $randomBytes)[1];
if (is_callable($callback)) {
$value = call_user_func($callback, $value);
}
$data .= $value;
}
return substr($data, 0, $length);
} | php | protected static function getRandomData($length, $packSize, $packFormat, $callback = null)
{
$data = '';
while(strlen($data) < $length) {
$randomBytes = self::getRandomBytes($packSize);
$value = unpack($packFormat, $randomBytes)[1];
if (is_callable($callback)) {
$value = call_user_func($callback, $value);
}
$data .= $value;
}
return substr($data, 0, $length);
} | [
"protected",
"static",
"function",
"getRandomData",
"(",
"$",
"length",
",",
"$",
"packSize",
",",
"$",
"packFormat",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"''",
";",
"while",
"(",
"strlen",
"(",
"$",
"data",
")",
"<",
"$",
"length",
")",
"{",
"$",
"randomBytes",
"=",
"self",
"::",
"getRandomBytes",
"(",
"$",
"packSize",
")",
";",
"$",
"value",
"=",
"unpack",
"(",
"$",
"packFormat",
",",
"$",
"randomBytes",
")",
"[",
"1",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"value",
"=",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"value",
")",
";",
"}",
"$",
"data",
".=",
"$",
"value",
";",
"}",
"return",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"length",
")",
";",
"}"
] | Generate random data based on the provided parameters
@param int $length Amount of characters of generated data
@param int $packSize Amount of bytes for unpack function
@param string $packFormat Definition of format for unpack function
@param callable $callback a function to manipulated unpacked value
@return boolean|string The generated string | [
"Generate",
"random",
"data",
"based",
"on",
"the",
"provided",
"parameters"
] | 4d0e6f23b796de506e80242f2cb37cfbf5f549f3 | https://github.com/pedrosancao/php-random-data/blob/4d0e6f23b796de506e80242f2cb37cfbf5f549f3/src/Random.php#L41-L53 |
4,261 | pedrosancao/php-random-data | src/Random.php | Random.raw | public static function raw($length)
{
$data = '';
while(strlen($data) < $length) {
$data .= self::getRandomBytes($length);
}
return substr($data, 0, $length);
} | php | public static function raw($length)
{
$data = '';
while(strlen($data) < $length) {
$data .= self::getRandomBytes($length);
}
return substr($data, 0, $length);
} | [
"public",
"static",
"function",
"raw",
"(",
"$",
"length",
")",
"{",
"$",
"data",
"=",
"''",
";",
"while",
"(",
"strlen",
"(",
"$",
"data",
")",
"<",
"$",
"length",
")",
"{",
"$",
"data",
".=",
"self",
"::",
"getRandomBytes",
"(",
"$",
"length",
")",
";",
"}",
"return",
"substr",
"(",
"$",
"data",
",",
"0",
",",
"$",
"length",
")",
";",
"}"
] | Gerate a string of raw random bytes
@param int $length
@return string The strng containg random bytes | [
"Gerate",
"a",
"string",
"of",
"raw",
"random",
"bytes"
] | 4d0e6f23b796de506e80242f2cb37cfbf5f549f3 | https://github.com/pedrosancao/php-random-data/blob/4d0e6f23b796de506e80242f2cb37cfbf5f549f3/src/Random.php#L61-L68 |
4,262 | viktor-melnikov/requester | src/Abstracts/AbstractDefaultHandler.php | AbstractDefaultHandler.xmlToArray | public function xmlToArray( $string )
{
$doc = new DOMDocument();
$doc->loadXML( $string );
$root = $doc->documentElement;
return $this->DomNodeToArray( $root );
} | php | public function xmlToArray( $string )
{
$doc = new DOMDocument();
$doc->loadXML( $string );
$root = $doc->documentElement;
return $this->DomNodeToArray( $root );
} | [
"public",
"function",
"xmlToArray",
"(",
"$",
"string",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"string",
")",
";",
"$",
"root",
"=",
"$",
"doc",
"->",
"documentElement",
";",
"return",
"$",
"this",
"->",
"DomNodeToArray",
"(",
"$",
"root",
")",
";",
"}"
] | convert XML response to array
@param $string
@return mixed | [
"convert",
"XML",
"response",
"to",
"array"
] | e155bc422374ac4a9b32147bbe557f1b6d03e457 | https://github.com/viktor-melnikov/requester/blob/e155bc422374ac4a9b32147bbe557f1b6d03e457/src/Abstracts/AbstractDefaultHandler.php#L179-L187 |
4,263 | viktor-melnikov/requester | src/Abstracts/AbstractDefaultHandler.php | AbstractDefaultHandler.stripBom | public function stripBom( $body )
{
if ( substr( $body, 0, 3 ) === "\xef\xbb\xbf" ) // UTF-8
{
$body = substr( $body, 3 );
} else {
if ( substr( $body, 0, 4 ) === "\xff\xfe\x00\x00" || substr( $body, 0, 4 ) === "\x00\x00\xfe\xff" ) // UTF-32
{
$body = substr( $body, 4 );
} else {
if ( substr( $body, 0, 2 ) === "\xff\xfe" || substr( $body, 0, 2 ) === "\xfe\xff" ) // UTF-16
{
$body = substr( $body, 2 );
}
}
}
return $body;
} | php | public function stripBom( $body )
{
if ( substr( $body, 0, 3 ) === "\xef\xbb\xbf" ) // UTF-8
{
$body = substr( $body, 3 );
} else {
if ( substr( $body, 0, 4 ) === "\xff\xfe\x00\x00" || substr( $body, 0, 4 ) === "\x00\x00\xfe\xff" ) // UTF-32
{
$body = substr( $body, 4 );
} else {
if ( substr( $body, 0, 2 ) === "\xff\xfe" || substr( $body, 0, 2 ) === "\xfe\xff" ) // UTF-16
{
$body = substr( $body, 2 );
}
}
}
return $body;
} | [
"public",
"function",
"stripBom",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"3",
")",
"===",
"\"\\xef\\xbb\\xbf\"",
")",
"// UTF-8",
"{",
"$",
"body",
"=",
"substr",
"(",
"$",
"body",
",",
"3",
")",
";",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"4",
")",
"===",
"\"\\xff\\xfe\\x00\\x00\"",
"||",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"4",
")",
"===",
"\"\\x00\\x00\\xfe\\xff\"",
")",
"// UTF-32",
"{",
"$",
"body",
"=",
"substr",
"(",
"$",
"body",
",",
"4",
")",
";",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"2",
")",
"===",
"\"\\xff\\xfe\"",
"||",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"2",
")",
"===",
"\"\\xfe\\xff\"",
")",
"// UTF-16",
"{",
"$",
"body",
"=",
"substr",
"(",
"$",
"body",
",",
"2",
")",
";",
"}",
"}",
"}",
"return",
"$",
"body",
";",
"}"
] | Remove null byte from body
@param $body
@return string | [
"Remove",
"null",
"byte",
"from",
"body"
] | e155bc422374ac4a9b32147bbe557f1b6d03e457 | https://github.com/viktor-melnikov/requester/blob/e155bc422374ac4a9b32147bbe557f1b6d03e457/src/Abstracts/AbstractDefaultHandler.php#L323-L341 |
4,264 | brightantwiboasiako/money | src/Money/Money.php | Money.withSecure | public static function withSecure($amount, Currency $currency = null)
{
if(!is_long($amount))
throw new InvalidAmountException;
$money = self::withRaw(0, $currency);
$money->setFraction($amount / 100);
$money->setWhole($amount / 100);
return $money;
} | php | public static function withSecure($amount, Currency $currency = null)
{
if(!is_long($amount))
throw new InvalidAmountException;
$money = self::withRaw(0, $currency);
$money->setFraction($amount / 100);
$money->setWhole($amount / 100);
return $money;
} | [
"public",
"static",
"function",
"withSecure",
"(",
"$",
"amount",
",",
"Currency",
"$",
"currency",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_long",
"(",
"$",
"amount",
")",
")",
"throw",
"new",
"InvalidAmountException",
";",
"$",
"money",
"=",
"self",
"::",
"withRaw",
"(",
"0",
",",
"$",
"currency",
")",
";",
"$",
"money",
"->",
"setFraction",
"(",
"$",
"amount",
"/",
"100",
")",
";",
"$",
"money",
"->",
"setWhole",
"(",
"$",
"amount",
"/",
"100",
")",
";",
"return",
"$",
"money",
";",
"}"
] | Creates a money instance using a complete
integer value for both the whole part
and the fractional part
@param $amount
@param Currency|null $currency
@return Money
@throws InvalidAmountException | [
"Creates",
"a",
"money",
"instance",
"using",
"a",
"complete",
"integer",
"value",
"for",
"both",
"the",
"whole",
"part",
"and",
"the",
"fractional",
"part"
] | 032474cf1226107c313bca6e6503ecdcdd0f8537 | https://github.com/brightantwiboasiako/money/blob/032474cf1226107c313bca6e6503ecdcdd0f8537/src/Money/Money.php#L79-L87 |
4,265 | brightantwiboasiako/money | src/Money/Money.php | Money.setFraction | private function setFraction($amount)
{
$doubleFraction = $amount * 100;
$intFraction = ($this->round(abs($doubleFraction))) % 100;
if($intFraction < 0)
$intFraction = -$intFraction;
$this->fraction = $intFraction;
} | php | private function setFraction($amount)
{
$doubleFraction = $amount * 100;
$intFraction = ($this->round(abs($doubleFraction))) % 100;
if($intFraction < 0)
$intFraction = -$intFraction;
$this->fraction = $intFraction;
} | [
"private",
"function",
"setFraction",
"(",
"$",
"amount",
")",
"{",
"$",
"doubleFraction",
"=",
"$",
"amount",
"*",
"100",
";",
"$",
"intFraction",
"=",
"(",
"$",
"this",
"->",
"round",
"(",
"abs",
"(",
"$",
"doubleFraction",
")",
")",
")",
"%",
"100",
";",
"if",
"(",
"$",
"intFraction",
"<",
"0",
")",
"$",
"intFraction",
"=",
"-",
"$",
"intFraction",
";",
"$",
"this",
"->",
"fraction",
"=",
"$",
"intFraction",
";",
"}"
] | Sets the fractional part of the money
@param $amount
@return void | [
"Sets",
"the",
"fractional",
"part",
"of",
"the",
"money"
] | 032474cf1226107c313bca6e6503ecdcdd0f8537 | https://github.com/brightantwiboasiako/money/blob/032474cf1226107c313bca6e6503ecdcdd0f8537/src/Money/Money.php#L121-L128 |
4,266 | brightantwiboasiako/money | src/Money/Money.php | Money.add | public function add(Money $money)
{
$sum = $this->getAmount() + $money->getAmount();
$this->setWhole($sum);
$this->setFraction($sum);
return $this;
} | php | public function add(Money $money)
{
$sum = $this->getAmount() + $money->getAmount();
$this->setWhole($sum);
$this->setFraction($sum);
return $this;
} | [
"public",
"function",
"add",
"(",
"Money",
"$",
"money",
")",
"{",
"$",
"sum",
"=",
"$",
"this",
"->",
"getAmount",
"(",
")",
"+",
"$",
"money",
"->",
"getAmount",
"(",
")",
";",
"$",
"this",
"->",
"setWhole",
"(",
"$",
"sum",
")",
";",
"$",
"this",
"->",
"setFraction",
"(",
"$",
"sum",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds given money to this money
@param Money $money
@return Money | [
"Adds",
"given",
"money",
"to",
"this",
"money"
] | 032474cf1226107c313bca6e6503ecdcdd0f8537 | https://github.com/brightantwiboasiako/money/blob/032474cf1226107c313bca6e6503ecdcdd0f8537/src/Money/Money.php#L145-L151 |
4,267 | brightantwiboasiako/money | src/Money/Money.php | Money.subtract | public function subtract(Money $money)
{
$diff = new Money($this->getAmount() - $money->getAmount());
$this->setWhole($diff->getAmount());
$this->setFraction($diff->getAmount());
return $this;
} | php | public function subtract(Money $money)
{
$diff = new Money($this->getAmount() - $money->getAmount());
$this->setWhole($diff->getAmount());
$this->setFraction($diff->getAmount());
return $this;
} | [
"public",
"function",
"subtract",
"(",
"Money",
"$",
"money",
")",
"{",
"$",
"diff",
"=",
"new",
"Money",
"(",
"$",
"this",
"->",
"getAmount",
"(",
")",
"-",
"$",
"money",
"->",
"getAmount",
"(",
")",
")",
";",
"$",
"this",
"->",
"setWhole",
"(",
"$",
"diff",
"->",
"getAmount",
"(",
")",
")",
";",
"$",
"this",
"->",
"setFraction",
"(",
"$",
"diff",
"->",
"getAmount",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Subtracts the given money from this money
@param Money $money
@return Money | [
"Subtracts",
"the",
"given",
"money",
"from",
"this",
"money"
] | 032474cf1226107c313bca6e6503ecdcdd0f8537 | https://github.com/brightantwiboasiako/money/blob/032474cf1226107c313bca6e6503ecdcdd0f8537/src/Money/Money.php#L158-L164 |
4,268 | brightantwiboasiako/money | src/Money/Money.php | Money.times | public function times($factor)
{
$totalFactor = $factor * $this->getAmount();
$this->setWhole($totalFactor);
$this->setFraction($totalFactor);
return $this;
} | php | public function times($factor)
{
$totalFactor = $factor * $this->getAmount();
$this->setWhole($totalFactor);
$this->setFraction($totalFactor);
return $this;
} | [
"public",
"function",
"times",
"(",
"$",
"factor",
")",
"{",
"$",
"totalFactor",
"=",
"$",
"factor",
"*",
"$",
"this",
"->",
"getAmount",
"(",
")",
";",
"$",
"this",
"->",
"setWhole",
"(",
"$",
"totalFactor",
")",
";",
"$",
"this",
"->",
"setFraction",
"(",
"$",
"totalFactor",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Scales this money by the provided factor
@param $factor
@return Money | [
"Scales",
"this",
"money",
"by",
"the",
"provided",
"factor"
] | 032474cf1226107c313bca6e6503ecdcdd0f8537 | https://github.com/brightantwiboasiako/money/blob/032474cf1226107c313bca6e6503ecdcdd0f8537/src/Money/Money.php#L171-L177 |
4,269 | matteosister/PygmentsElephantBundle | PygmentsElephant/Pygmentize.php | Pygmentize.formatFile | public function formatFile($filename, $lexer = null, array $options = array())
{
if (!$this->fs->exists($filename)) {
throw new \InvalidArgumentException(sprintf('the file %s doesn\'t exists', $filename));
}
$this->subject = $filename;
$this->lexer = null === $lexer ? $this->binary->guessLexer($filename) : $lexer;
$this->format = 'html';
return $this->binary->execute($this, array_merge($this->options, $options));
} | php | public function formatFile($filename, $lexer = null, array $options = array())
{
if (!$this->fs->exists($filename)) {
throw new \InvalidArgumentException(sprintf('the file %s doesn\'t exists', $filename));
}
$this->subject = $filename;
$this->lexer = null === $lexer ? $this->binary->guessLexer($filename) : $lexer;
$this->format = 'html';
return $this->binary->execute($this, array_merge($this->options, $options));
} | [
"public",
"function",
"formatFile",
"(",
"$",
"filename",
",",
"$",
"lexer",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fs",
"->",
"exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'the file %s doesn\\'t exists'",
",",
"$",
"filename",
")",
")",
";",
"}",
"$",
"this",
"->",
"subject",
"=",
"$",
"filename",
";",
"$",
"this",
"->",
"lexer",
"=",
"null",
"===",
"$",
"lexer",
"?",
"$",
"this",
"->",
"binary",
"->",
"guessLexer",
"(",
"$",
"filename",
")",
":",
"$",
"lexer",
";",
"$",
"this",
"->",
"format",
"=",
"'html'",
";",
"return",
"$",
"this",
"->",
"binary",
"->",
"execute",
"(",
"$",
"this",
",",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
")",
";",
"}"
] | format a file by its name
@param string $filename file name
@param string $lexer lexer
@param array $options
@return string | [
"format",
"a",
"file",
"by",
"its",
"name"
] | 647cc00272126314f6d083d8b2350a9d6280bade | https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/Pygmentize.php#L72-L82 |
4,270 | matteosister/PygmentsElephantBundle | PygmentsElephant/Pygmentize.php | Pygmentize.format | public function format($content, $originalFilename)
{
$pathInfo = pathinfo($originalFilename);
$filename = sys_get_temp_dir().'/pygmentize_'.sha1(uniqid()).(isset($pathInfo['extension']) ? '.'. $pathInfo['extension'] : '');
$this->fs->touch($filename);
$h = fopen($filename, 'w');
fwrite($h, $content);
fclose($h);
return $this->formatFile($filename, $this->binary->guessLexer($filename));
} | php | public function format($content, $originalFilename)
{
$pathInfo = pathinfo($originalFilename);
$filename = sys_get_temp_dir().'/pygmentize_'.sha1(uniqid()).(isset($pathInfo['extension']) ? '.'. $pathInfo['extension'] : '');
$this->fs->touch($filename);
$h = fopen($filename, 'w');
fwrite($h, $content);
fclose($h);
return $this->formatFile($filename, $this->binary->guessLexer($filename));
} | [
"public",
"function",
"format",
"(",
"$",
"content",
",",
"$",
"originalFilename",
")",
"{",
"$",
"pathInfo",
"=",
"pathinfo",
"(",
"$",
"originalFilename",
")",
";",
"$",
"filename",
"=",
"sys_get_temp_dir",
"(",
")",
".",
"'/pygmentize_'",
".",
"sha1",
"(",
"uniqid",
"(",
")",
")",
".",
"(",
"isset",
"(",
"$",
"pathInfo",
"[",
"'extension'",
"]",
")",
"?",
"'.'",
".",
"$",
"pathInfo",
"[",
"'extension'",
"]",
":",
"''",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"touch",
"(",
"$",
"filename",
")",
";",
"$",
"h",
"=",
"fopen",
"(",
"$",
"filename",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"h",
",",
"$",
"content",
")",
";",
"fclose",
"(",
"$",
"h",
")",
";",
"return",
"$",
"this",
"->",
"formatFile",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"binary",
"->",
"guessLexer",
"(",
"$",
"filename",
")",
")",
";",
"}"
] | format a string of content
@param string $content content
@param string $originalFilename original filename for the lexer guesser
@internal param string $lexer lexer
@internal param string $format format
@internal param string $filename file name
@return string | [
"format",
"a",
"string",
"of",
"content"
] | 647cc00272126314f6d083d8b2350a9d6280bade | https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/PygmentsElephant/Pygmentize.php#L96-L106 |
4,271 | Laralum/Payments | src/Payment.php | Payment.pay | public function pay()
{
if (!Settings::first()->ready()) {
return false;
}
if ($this->ammount != 0) {
try {
Charge::create([
'amount' => $this->ammount,
'currency' => $this->currency,
'source' => $this->source,
'description' => $this->description,
]);
} catch (Exception $e) {
$this->error = $e;
return false;
}
}
return true;
} | php | public function pay()
{
if (!Settings::first()->ready()) {
return false;
}
if ($this->ammount != 0) {
try {
Charge::create([
'amount' => $this->ammount,
'currency' => $this->currency,
'source' => $this->source,
'description' => $this->description,
]);
} catch (Exception $e) {
$this->error = $e;
return false;
}
}
return true;
} | [
"public",
"function",
"pay",
"(",
")",
"{",
"if",
"(",
"!",
"Settings",
"::",
"first",
"(",
")",
"->",
"ready",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"ammount",
"!=",
"0",
")",
"{",
"try",
"{",
"Charge",
"::",
"create",
"(",
"[",
"'amount'",
"=>",
"$",
"this",
"->",
"ammount",
",",
"'currency'",
"=>",
"$",
"this",
"->",
"currency",
",",
"'source'",
"=>",
"$",
"this",
"->",
"source",
",",
"'description'",
"=>",
"$",
"this",
"->",
"description",
",",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"$",
"e",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Execute the payment and return true if succeeded.
@param string $description
@return \Laralum\Payments\Payment | [
"Execute",
"the",
"payment",
"and",
"return",
"true",
"if",
"succeeded",
"."
] | e9804fff9e839fa8d40fc698db2bfdb3c02ecd39 | https://github.com/Laralum/Payments/blob/e9804fff9e839fa8d40fc698db2bfdb3c02ecd39/src/Payment.php#L90-L112 |
4,272 | liftkit/core | src/Response/View.php | View.prepare | public function prepare ()
{
if (is_array($this->viewData)) {
foreach ($this->viewData as $_token => $_value) {
if (is_object($_value) && is_subclass_of($_value, __CLASS__)) {
$$_token = $_value->prepare();
} else {
$$_token = $_value;
}
}
}
if (is_file($this->filePath)) {
ob_start();
require($this->filePath);
return ob_get_clean();
} else {
throw new ViewFileNotFoundException('No such view: ' . $this->filePath);
}
} | php | public function prepare ()
{
if (is_array($this->viewData)) {
foreach ($this->viewData as $_token => $_value) {
if (is_object($_value) && is_subclass_of($_value, __CLASS__)) {
$$_token = $_value->prepare();
} else {
$$_token = $_value;
}
}
}
if (is_file($this->filePath)) {
ob_start();
require($this->filePath);
return ob_get_clean();
} else {
throw new ViewFileNotFoundException('No such view: ' . $this->filePath);
}
} | [
"public",
"function",
"prepare",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"viewData",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"viewData",
"as",
"$",
"_token",
"=>",
"$",
"_value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"_value",
")",
"&&",
"is_subclass_of",
"(",
"$",
"_value",
",",
"__CLASS__",
")",
")",
"{",
"$",
"$",
"_token",
"=",
"$",
"_value",
"->",
"prepare",
"(",
")",
";",
"}",
"else",
"{",
"$",
"$",
"_token",
"=",
"$",
"_value",
";",
"}",
"}",
"}",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",
"filePath",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"require",
"(",
"$",
"this",
"->",
"filePath",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ViewFileNotFoundException",
"(",
"'No such view: '",
".",
"$",
"this",
"->",
"filePath",
")",
";",
"}",
"}"
] | Returns string of template pointed to by file, with data passed to it.
@internal
@return string | [
"Returns",
"string",
"of",
"template",
"pointed",
"to",
"by",
"file",
"with",
"data",
"passed",
"to",
"it",
"."
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Response/View.php#L86-L107 |
4,273 | liftkit/core | src/Response/View.php | View.unsetData | public function unsetData ($field = null)
{
if ($field) {
unset($this->viewData[$field]);
} else {
$this->viewData = array();
}
return $this;
} | php | public function unsetData ($field = null)
{
if ($field) {
unset($this->viewData[$field]);
} else {
$this->viewData = array();
}
return $this;
} | [
"public",
"function",
"unsetData",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"field",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"viewData",
"[",
"$",
"field",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"viewData",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Unsets data either by field or all fields
@api
@param mixed $field If set, will unset only a single field's data
@return self | [
"Unsets",
"data",
"either",
"by",
"field",
"or",
"all",
"fields"
] | c98dcffa65450bd11332dbffe2064650c3a72aae | https://github.com/liftkit/core/blob/c98dcffa65450bd11332dbffe2064650c3a72aae/src/Response/View.php#L141-L150 |
4,274 | InnoGr/FivePercent-Cache | src/ChainCache.php | ChainCache.addCache | public function addCache(CacheInterface $cache, $priority = 0)
{
$this->caches[spl_object_hash($cache)] = array(
'cache' => $cache,
'priority' => $priority
);
$this->sortedCaches = null;
} | php | public function addCache(CacheInterface $cache, $priority = 0)
{
$this->caches[spl_object_hash($cache)] = array(
'cache' => $cache,
'priority' => $priority
);
$this->sortedCaches = null;
} | [
"public",
"function",
"addCache",
"(",
"CacheInterface",
"$",
"cache",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"caches",
"[",
"spl_object_hash",
"(",
"$",
"cache",
")",
"]",
"=",
"array",
"(",
"'cache'",
"=>",
"$",
"cache",
",",
"'priority'",
"=>",
"$",
"priority",
")",
";",
"$",
"this",
"->",
"sortedCaches",
"=",
"null",
";",
"}"
] | Add cache to storage
@param CacheInterface $cache
@param int $priority | [
"Add",
"cache",
"to",
"storage"
] | 0849e495bd440ce5faf0f8a5f6e66d93485f7627 | https://github.com/InnoGr/FivePercent-Cache/blob/0849e495bd440ce5faf0f8a5f6e66d93485f7627/src/ChainCache.php#L68-L76 |
4,275 | xloit/xloit-bridge-zend-mvc | src/Controller/ControllerTrait.php | ControllerTrait.getRouteMatch | public function getRouteMatch()
{
if (null === $this->routeMatch) {
/** @noinspection PhpUndefinedMethodInspection */
$this->routeMatch = $this->getEvent()->getRouteMatch();
}
return $this->routeMatch;
} | php | public function getRouteMatch()
{
if (null === $this->routeMatch) {
/** @noinspection PhpUndefinedMethodInspection */
$this->routeMatch = $this->getEvent()->getRouteMatch();
}
return $this->routeMatch;
} | [
"public",
"function",
"getRouteMatch",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"routeMatch",
")",
"{",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"this",
"->",
"routeMatch",
"=",
"$",
"this",
"->",
"getEvent",
"(",
")",
"->",
"getRouteMatch",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routeMatch",
";",
"}"
] | Return matched route.
@return \Zend\Router\RouteMatch | [
"Return",
"matched",
"route",
"."
] | 9991dc46f0b4b8831289ededc8ff0edaacffadd5 | https://github.com/xloit/xloit-bridge-zend-mvc/blob/9991dc46f0b4b8831289ededc8ff0edaacffadd5/src/Controller/ControllerTrait.php#L70-L78 |
4,276 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth.php | Auth.forge | public static function forge($custom = array())
{
// Driver is given as array key or just string in custom
$custom = ! is_array($custom) ? array('driver' => $custom) : $custom;
$config = \Config::get('auth.'.$custom['driver'].'_config', array());
$config = array_merge($config, $custom);
// Driver must be set
if (empty($config['driver']) || ! is_string($config['driver']))
{
throw new \AuthException('No auth driver given.');
}
// determine the driver to load
$driver = \Auth_Login_Driver::forge($config);
// get the driver's cookie name
$id = $driver->get_id();
// do we already have a driver instance for this cookie?
if (isset(static::$_instances[$id]))
{
// if so, they must be using the same driver class!
$class = get_class($driver);
if ( ! static::$_instances[$id] instanceof $class)
{
throw new \AuthException('You can not instantiate two different login drivers using the same id "'.$id.'"');
}
}
else
{
// store this instance
static::$_instances[$id] = $driver;
}
// If we have more then one driver instance, check if we need concurrency
if (count(static::$_instances) > 1)
{
// Whether to allow multiple drivers of any type, defaults to not allowed
static::$_verify_multiple = \Config::get('auth.verify_multiple_logins', false);
}
return static::$_instances[$id];
} | php | public static function forge($custom = array())
{
// Driver is given as array key or just string in custom
$custom = ! is_array($custom) ? array('driver' => $custom) : $custom;
$config = \Config::get('auth.'.$custom['driver'].'_config', array());
$config = array_merge($config, $custom);
// Driver must be set
if (empty($config['driver']) || ! is_string($config['driver']))
{
throw new \AuthException('No auth driver given.');
}
// determine the driver to load
$driver = \Auth_Login_Driver::forge($config);
// get the driver's cookie name
$id = $driver->get_id();
// do we already have a driver instance for this cookie?
if (isset(static::$_instances[$id]))
{
// if so, they must be using the same driver class!
$class = get_class($driver);
if ( ! static::$_instances[$id] instanceof $class)
{
throw new \AuthException('You can not instantiate two different login drivers using the same id "'.$id.'"');
}
}
else
{
// store this instance
static::$_instances[$id] = $driver;
}
// If we have more then one driver instance, check if we need concurrency
if (count(static::$_instances) > 1)
{
// Whether to allow multiple drivers of any type, defaults to not allowed
static::$_verify_multiple = \Config::get('auth.verify_multiple_logins', false);
}
return static::$_instances[$id];
} | [
"public",
"static",
"function",
"forge",
"(",
"$",
"custom",
"=",
"array",
"(",
")",
")",
"{",
"// Driver is given as array key or just string in custom",
"$",
"custom",
"=",
"!",
"is_array",
"(",
"$",
"custom",
")",
"?",
"array",
"(",
"'driver'",
"=>",
"$",
"custom",
")",
":",
"$",
"custom",
";",
"$",
"config",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'auth.'",
".",
"$",
"custom",
"[",
"'driver'",
"]",
".",
"'_config'",
",",
"array",
"(",
")",
")",
";",
"$",
"config",
"=",
"array_merge",
"(",
"$",
"config",
",",
"$",
"custom",
")",
";",
"// Driver must be set",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
"||",
"!",
"is_string",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"AuthException",
"(",
"'No auth driver given.'",
")",
";",
"}",
"// determine the driver to load",
"$",
"driver",
"=",
"\\",
"Auth_Login_Driver",
"::",
"forge",
"(",
"$",
"config",
")",
";",
"// get the driver's cookie name",
"$",
"id",
"=",
"$",
"driver",
"->",
"get_id",
"(",
")",
";",
"// do we already have a driver instance for this cookie?",
"if",
"(",
"isset",
"(",
"static",
"::",
"$",
"_instances",
"[",
"$",
"id",
"]",
")",
")",
"{",
"// if so, they must be using the same driver class!",
"$",
"class",
"=",
"get_class",
"(",
"$",
"driver",
")",
";",
"if",
"(",
"!",
"static",
"::",
"$",
"_instances",
"[",
"$",
"id",
"]",
"instanceof",
"$",
"class",
")",
"{",
"throw",
"new",
"\\",
"AuthException",
"(",
"'You can not instantiate two different login drivers using the same id \"'",
".",
"$",
"id",
".",
"'\"'",
")",
";",
"}",
"}",
"else",
"{",
"// store this instance",
"static",
"::",
"$",
"_instances",
"[",
"$",
"id",
"]",
"=",
"$",
"driver",
";",
"}",
"// If we have more then one driver instance, check if we need concurrency",
"if",
"(",
"count",
"(",
"static",
"::",
"$",
"_instances",
")",
">",
"1",
")",
"{",
"// Whether to allow multiple drivers of any type, defaults to not allowed",
"static",
"::",
"$",
"_verify_multiple",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'auth.verify_multiple_logins'",
",",
"false",
")",
";",
"}",
"return",
"static",
"::",
"$",
"_instances",
"[",
"$",
"id",
"]",
";",
"}"
] | Load a login driver to the array of loaded drivers
@param Array settings for the new driver
@throws AuthException on driver load failure | [
"Load",
"a",
"login",
"driver",
"to",
"the",
"array",
"of",
"loaded",
"drivers"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth.php#L84-L127 |
4,277 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth.php | Auth.check | public static function check($specific = null)
{
$drivers = $specific === null ? static::$_instances : (array) $specific;
foreach ($drivers as $i)
{
if ( ! static::$_verify_multiple && ! empty(static::$_verified))
{
return true;
}
$i = $i instanceof Auth_Login_Driver ? $i : static::instance($i);
if ( ! array_key_exists($i->get_id(), static::$_verified))
{
$i->check();
}
if ($specific)
{
if (array_key_exists($i->get_id(), static::$_verified))
{
return true;
}
}
}
return $specific === null && ! empty(static::$_verified);
} | php | public static function check($specific = null)
{
$drivers = $specific === null ? static::$_instances : (array) $specific;
foreach ($drivers as $i)
{
if ( ! static::$_verify_multiple && ! empty(static::$_verified))
{
return true;
}
$i = $i instanceof Auth_Login_Driver ? $i : static::instance($i);
if ( ! array_key_exists($i->get_id(), static::$_verified))
{
$i->check();
}
if ($specific)
{
if (array_key_exists($i->get_id(), static::$_verified))
{
return true;
}
}
}
return $specific === null && ! empty(static::$_verified);
} | [
"public",
"static",
"function",
"check",
"(",
"$",
"specific",
"=",
"null",
")",
"{",
"$",
"drivers",
"=",
"$",
"specific",
"===",
"null",
"?",
"static",
"::",
"$",
"_instances",
":",
"(",
"array",
")",
"$",
"specific",
";",
"foreach",
"(",
"$",
"drivers",
"as",
"$",
"i",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"$",
"_verify_multiple",
"&&",
"!",
"empty",
"(",
"static",
"::",
"$",
"_verified",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"i",
"=",
"$",
"i",
"instanceof",
"Auth_Login_Driver",
"?",
"$",
"i",
":",
"static",
"::",
"instance",
"(",
"$",
"i",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"i",
"->",
"get_id",
"(",
")",
",",
"static",
"::",
"$",
"_verified",
")",
")",
"{",
"$",
"i",
"->",
"check",
"(",
")",
";",
"}",
"if",
"(",
"$",
"specific",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"i",
"->",
"get_id",
"(",
")",
",",
"static",
"::",
"$",
"_verified",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"specific",
"===",
"null",
"&&",
"!",
"empty",
"(",
"static",
"::",
"$",
"_verified",
")",
";",
"}"
] | Check login drivers for validated login
@param string|Array specific driver or drivers, in this case it will always terminate after first success
@return bool | [
"Check",
"login",
"drivers",
"for",
"validated",
"login"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth.php#L189-L216 |
4,278 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth.php | Auth.verified | public static function verified($driver = null)
{
if ($driver === null)
{
return static::$_verified;
}
if ( ! array_key_exists($driver, static::$_verified))
{
return false;
}
return static::$_verified[$driver];
} | php | public static function verified($driver = null)
{
if ($driver === null)
{
return static::$_verified;
}
if ( ! array_key_exists($driver, static::$_verified))
{
return false;
}
return static::$_verified[$driver];
} | [
"public",
"static",
"function",
"verified",
"(",
"$",
"driver",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"driver",
"===",
"null",
")",
"{",
"return",
"static",
"::",
"$",
"_verified",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"driver",
",",
"static",
"::",
"$",
"_verified",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"$",
"_verified",
"[",
"$",
"driver",
"]",
";",
"}"
] | Get verified driver or all verified drivers
returns false when specific driver has not validated
when all were requested and none validated an empty array is returned
@param null|string driver id or null for all verified driver in an array
@return Array|Auth_Login_Driver|false | [
"Get",
"verified",
"driver",
"or",
"all",
"verified",
"drivers",
"returns",
"false",
"when",
"specific",
"driver",
"has",
"not",
"validated",
"when",
"all",
"were",
"requested",
"and",
"none",
"validated",
"an",
"empty",
"array",
"is",
"returned"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth.php#L226-L239 |
4,279 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth.php | Auth.register_driver_type | public static function register_driver_type($type, $check_method)
{
$driver_exists = ! is_string($type)
|| array_key_exists($type, static::$_drivers)
|| method_exists(get_called_class(), $check_method)
|| in_array($type, array('login', 'group', 'acl'));
$method_exists = ! is_string($type)
|| array_search($check_method, static::$_drivers)
|| method_exists(get_called_class(), $type);
if ($driver_exists && static::$_drivers[$type] == $check_method)
{
return true;
}
if ($driver_exists || $method_exists)
{
\Error::notice('Cannot add driver type, its name conflicts with another driver or method.');
return false;
}
static::$_drivers[$type] = $check_method;
return true;
} | php | public static function register_driver_type($type, $check_method)
{
$driver_exists = ! is_string($type)
|| array_key_exists($type, static::$_drivers)
|| method_exists(get_called_class(), $check_method)
|| in_array($type, array('login', 'group', 'acl'));
$method_exists = ! is_string($type)
|| array_search($check_method, static::$_drivers)
|| method_exists(get_called_class(), $type);
if ($driver_exists && static::$_drivers[$type] == $check_method)
{
return true;
}
if ($driver_exists || $method_exists)
{
\Error::notice('Cannot add driver type, its name conflicts with another driver or method.');
return false;
}
static::$_drivers[$type] = $check_method;
return true;
} | [
"public",
"static",
"function",
"register_driver_type",
"(",
"$",
"type",
",",
"$",
"check_method",
")",
"{",
"$",
"driver_exists",
"=",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"array_key_exists",
"(",
"$",
"type",
",",
"static",
"::",
"$",
"_drivers",
")",
"||",
"method_exists",
"(",
"get_called_class",
"(",
")",
",",
"$",
"check_method",
")",
"||",
"in_array",
"(",
"$",
"type",
",",
"array",
"(",
"'login'",
",",
"'group'",
",",
"'acl'",
")",
")",
";",
"$",
"method_exists",
"=",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"array_search",
"(",
"$",
"check_method",
",",
"static",
"::",
"$",
"_drivers",
")",
"||",
"method_exists",
"(",
"get_called_class",
"(",
")",
",",
"$",
"type",
")",
";",
"if",
"(",
"$",
"driver_exists",
"&&",
"static",
"::",
"$",
"_drivers",
"[",
"$",
"type",
"]",
"==",
"$",
"check_method",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"driver_exists",
"||",
"$",
"method_exists",
")",
"{",
"\\",
"Error",
"::",
"notice",
"(",
"'Cannot add driver type, its name conflicts with another driver or method.'",
")",
";",
"return",
"false",
";",
"}",
"static",
"::",
"$",
"_drivers",
"[",
"$",
"type",
"]",
"=",
"$",
"check_method",
";",
"return",
"true",
";",
"}"
] | Register a new driver type
@param string name of the driver type, may not conflict with class method name
@param string name of the method to use for checking this type of driver, also cannot conflict with method
@return bool | [
"Register",
"a",
"new",
"driver",
"type"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth.php#L281-L304 |
4,280 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth.php | Auth.unregister_driver_type | public static function unregister_driver_type($type)
{
if (in_array($type,array('login', 'group', 'acl')))
{
\Error::notice('Cannot remove driver type, included drivers login, group and acl cannot be removed.');
return false;
}
unset(static::$_drivers[$type]);
return true;
} | php | public static function unregister_driver_type($type)
{
if (in_array($type,array('login', 'group', 'acl')))
{
\Error::notice('Cannot remove driver type, included drivers login, group and acl cannot be removed.');
return false;
}
unset(static::$_drivers[$type]);
return true;
} | [
"public",
"static",
"function",
"unregister_driver_type",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"array",
"(",
"'login'",
",",
"'group'",
",",
"'acl'",
")",
")",
")",
"{",
"\\",
"Error",
"::",
"notice",
"(",
"'Cannot remove driver type, included drivers login, group and acl cannot be removed.'",
")",
";",
"return",
"false",
";",
"}",
"unset",
"(",
"static",
"::",
"$",
"_drivers",
"[",
"$",
"type",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Unregister a driver type
@param string name of the driver type
@return bool | [
"Unregister",
"a",
"driver",
"type"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth.php#L312-L322 |
4,281 | mtoolkit/mtoolkit-model | src/sql/MSqlQueryModel.php | MSqlQueryModel.setQuery | public function setQuery(string $query, ?PDO $db = null)
{
if ($db == null) {
$db = MDbConnection::getDbConnection();
}
if ($db instanceof \PDO) {
$this->query = new MPDOQuery($query, $db);
} else {
throw new \Exception("Database connection not supported.");
}
$this->query->exec();
} | php | public function setQuery(string $query, ?PDO $db = null)
{
if ($db == null) {
$db = MDbConnection::getDbConnection();
}
if ($db instanceof \PDO) {
$this->query = new MPDOQuery($query, $db);
} else {
throw new \Exception("Database connection not supported.");
}
$this->query->exec();
} | [
"public",
"function",
"setQuery",
"(",
"string",
"$",
"query",
",",
"?",
"PDO",
"$",
"db",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"db",
"==",
"null",
")",
"{",
"$",
"db",
"=",
"MDbConnection",
"::",
"getDbConnection",
"(",
")",
";",
"}",
"if",
"(",
"$",
"db",
"instanceof",
"\\",
"PDO",
")",
"{",
"$",
"this",
"->",
"query",
"=",
"new",
"MPDOQuery",
"(",
"$",
"query",
",",
"$",
"db",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Database connection not supported.\"",
")",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"exec",
"(",
")",
";",
"}"
] | Returns the QSqlQuery associated with this model.
@param string $query
@param \PDO|null $db
@throws \Exception | [
"Returns",
"the",
"QSqlQuery",
"associated",
"with",
"this",
"model",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlQueryModel.php#L52-L65 |
4,282 | dmitrymomot/php-auth | src/Auth.php | Auth.logout | public function logout($destroy = false)
{
if ($destroy === true) {
$this->_session->destroy();
} else {
$this->_session->delete($this->sessionKey());
$this->_session->regenerate();
}
return ( ! $this->loggedIn());
} | php | public function logout($destroy = false)
{
if ($destroy === true) {
$this->_session->destroy();
} else {
$this->_session->delete($this->sessionKey());
$this->_session->regenerate();
}
return ( ! $this->loggedIn());
} | [
"public",
"function",
"logout",
"(",
"$",
"destroy",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"destroy",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"_session",
"->",
"destroy",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_session",
"->",
"delete",
"(",
"$",
"this",
"->",
"sessionKey",
"(",
")",
")",
";",
"$",
"this",
"->",
"_session",
"->",
"regenerate",
"(",
")",
";",
"}",
"return",
"(",
"!",
"$",
"this",
"->",
"loggedIn",
"(",
")",
")",
";",
"}"
] | Log out a user by removing the related session variables.
@param boolean $destroy
@return boolean | [
"Log",
"out",
"a",
"user",
"by",
"removing",
"the",
"related",
"session",
"variables",
"."
] | 6b5354f449e14673eedb736ee2bbc029d8b7f906 | https://github.com/dmitrymomot/php-auth/blob/6b5354f449e14673eedb736ee2bbc029d8b7f906/src/Auth.php#L83-L92 |
4,283 | dmitrymomot/php-auth | src/Auth.php | Auth.comeBack | public function comeBack()
{
$initial_user = $this->_session->get($this->_sessionKeyInitUser);
if ($initial_user) {
$this->logout();
return $this->_completeLogin($initial_user);
}
return false;
} | php | public function comeBack()
{
$initial_user = $this->_session->get($this->_sessionKeyInitUser);
if ($initial_user) {
$this->logout();
return $this->_completeLogin($initial_user);
}
return false;
} | [
"public",
"function",
"comeBack",
"(",
")",
"{",
"$",
"initial_user",
"=",
"$",
"this",
"->",
"_session",
"->",
"get",
"(",
"$",
"this",
"->",
"_sessionKeyInitUser",
")",
";",
"if",
"(",
"$",
"initial_user",
")",
"{",
"$",
"this",
"->",
"logout",
"(",
")",
";",
"return",
"$",
"this",
"->",
"_completeLogin",
"(",
"$",
"initial_user",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Come back to initial user
@return boolean | [
"Come",
"back",
"to",
"initial",
"user"
] | 6b5354f449e14673eedb736ee2bbc029d8b7f906 | https://github.com/dmitrymomot/php-auth/blob/6b5354f449e14673eedb736ee2bbc029d8b7f906/src/Auth.php#L98-L108 |
4,284 | kaecyra/app-common | src/Log/AggregateLogger.php | AggregateLogger.addLogger | public function addLogger(LoggerInterface $logger, $level = null, $key = null) {
// Make a small attempt to prevent infinite cycles by disallowing all logger chaining.
if ($logger instanceof AggregateLogger) {
throw new \InvalidArgumentException("You cannot chain AggregateLoggers.", 500);
}
$level = $level ?? self::DEBUG;
$key = $key ?? spl_object_hash($logger);
$this->loggers[$key] = [
'logger' => $logger,
'priority' => static::levelPriority($level),
'key' => $key,
'enabled' => true
];
return $this;
} | php | public function addLogger(LoggerInterface $logger, $level = null, $key = null) {
// Make a small attempt to prevent infinite cycles by disallowing all logger chaining.
if ($logger instanceof AggregateLogger) {
throw new \InvalidArgumentException("You cannot chain AggregateLoggers.", 500);
}
$level = $level ?? self::DEBUG;
$key = $key ?? spl_object_hash($logger);
$this->loggers[$key] = [
'logger' => $logger,
'priority' => static::levelPriority($level),
'key' => $key,
'enabled' => true
];
return $this;
} | [
"public",
"function",
"addLogger",
"(",
"LoggerInterface",
"$",
"logger",
",",
"$",
"level",
"=",
"null",
",",
"$",
"key",
"=",
"null",
")",
"{",
"// Make a small attempt to prevent infinite cycles by disallowing all logger chaining.",
"if",
"(",
"$",
"logger",
"instanceof",
"AggregateLogger",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"You cannot chain AggregateLoggers.\"",
",",
"500",
")",
";",
"}",
"$",
"level",
"=",
"$",
"level",
"??",
"self",
"::",
"DEBUG",
";",
"$",
"key",
"=",
"$",
"key",
"??",
"spl_object_hash",
"(",
"$",
"logger",
")",
";",
"$",
"this",
"->",
"loggers",
"[",
"$",
"key",
"]",
"=",
"[",
"'logger'",
"=>",
"$",
"logger",
",",
"'priority'",
"=>",
"static",
"::",
"levelPriority",
"(",
"$",
"level",
")",
",",
"'key'",
"=>",
"$",
"key",
",",
"'enabled'",
"=>",
"true",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Add a new logger to observe messages.
@param LoggerInterface $logger
@param string $level
@return AggregateLogger | [
"Add",
"a",
"new",
"logger",
"to",
"observe",
"messages",
"."
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/AggregateLogger.php#L48-L63 |
4,285 | kaecyra/app-common | src/Log/AggregateLogger.php | AggregateLogger.removeLogger | public function removeLogger(string $key, $trigger = true) {
if ($trigger && !$this->has($key)) {
trigger_error("Logger $key was removed without being added.");
}
unset($this->loggers[$key]);
return $this;
} | php | public function removeLogger(string $key, $trigger = true) {
if ($trigger && !$this->has($key)) {
trigger_error("Logger $key was removed without being added.");
}
unset($this->loggers[$key]);
return $this;
} | [
"public",
"function",
"removeLogger",
"(",
"string",
"$",
"key",
",",
"$",
"trigger",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"trigger",
"&&",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"trigger_error",
"(",
"\"Logger $key was removed without being added.\"",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"loggers",
"[",
"$",
"key",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Remove a logger by passing in its key.
@param type $key
@param type $trigger
@return $this | [
"Remove",
"a",
"logger",
"by",
"passing",
"in",
"its",
"key",
"."
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/AggregateLogger.php#L72-L80 |
4,286 | kaecyra/app-common | src/Log/AggregateLogger.php | AggregateLogger.removeLoggerByInstance | public function removeLoggerByInstance($logger, $trigger = true) {
foreach ($this->loggers as $key => $addedLogger) {
if ($addedLogger[0] === $logger) {
unset($this->loggers[$key]);
return $this;
}
}
if ($trigger) {
$class = get_class($logger);
trigger_error("Logger $class was removed without being added.");
}
return $this;
} | php | public function removeLoggerByInstance($logger, $trigger = true) {
foreach ($this->loggers as $key => $addedLogger) {
if ($addedLogger[0] === $logger) {
unset($this->loggers[$key]);
return $this;
}
}
if ($trigger) {
$class = get_class($logger);
trigger_error("Logger $class was removed without being added.");
}
return $this;
} | [
"public",
"function",
"removeLoggerByInstance",
"(",
"$",
"logger",
",",
"$",
"trigger",
"=",
"true",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"key",
"=>",
"$",
"addedLogger",
")",
"{",
"if",
"(",
"$",
"addedLogger",
"[",
"0",
"]",
"===",
"$",
"logger",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"loggers",
"[",
"$",
"key",
"]",
")",
";",
"return",
"$",
"this",
";",
"}",
"}",
"if",
"(",
"$",
"trigger",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"logger",
")",
";",
"trigger_error",
"(",
"\"Logger $class was removed without being added.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove a logger by passing in its instance.
@param LoggerInterface $logger
@param bool $trigger
@return AggregateLogger | [
"Remove",
"a",
"logger",
"by",
"passing",
"in",
"its",
"instance",
"."
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/AggregateLogger.php#L89-L103 |
4,287 | kaecyra/app-common | src/Log/AggregateLogger.php | AggregateLogger.event | public function event($event, $level, $message, $context = []) {
$context['event'] = $event;
$this->log($level, $message, $context);
} | php | public function event($event, $level, $message, $context = []) {
$context['event'] = $event;
$this->log($level, $message, $context);
} | [
"public",
"function",
"event",
"(",
"$",
"event",
",",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"context",
"[",
"'event'",
"]",
"=",
"$",
"event",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"}"
] | Log an event.
@param string $event
@param mixed $level
@param string $message
@param array $context | [
"Log",
"an",
"event",
"."
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/AggregateLogger.php#L155-L158 |
4,288 | kaecyra/app-common | src/Log/AggregateLogger.php | AggregateLogger.log | public function log($level, $message, array $context = []) {
$levelPriority = self::levelPriority($level);
if ($levelPriority > LOG_DEBUG) {
throw new \Psr\Log\InvalidArgumentException("Invalid log level: $level.");
}
// Prevent an infinite cycle by setting an internal flag.
static $inCall = false;
if ($inCall) {
return;
}
$inCall = true;
foreach ($this->loggers as $logger) {
/* @var LoggerInterface $logger */
if (!$logger['enabled']) {
continue;
}
if ($logger['priority'] >= $levelPriority) {
try {
$logger['logger']->log($level, $message, $context);
} catch (\Exception $ex) {
$inCall = false;
throw $ex;
}
}
}
$inCall = false;
} | php | public function log($level, $message, array $context = []) {
$levelPriority = self::levelPriority($level);
if ($levelPriority > LOG_DEBUG) {
throw new \Psr\Log\InvalidArgumentException("Invalid log level: $level.");
}
// Prevent an infinite cycle by setting an internal flag.
static $inCall = false;
if ($inCall) {
return;
}
$inCall = true;
foreach ($this->loggers as $logger) {
/* @var LoggerInterface $logger */
if (!$logger['enabled']) {
continue;
}
if ($logger['priority'] >= $levelPriority) {
try {
$logger['logger']->log($level, $message, $context);
} catch (\Exception $ex) {
$inCall = false;
throw $ex;
}
}
}
$inCall = false;
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"$",
"levelPriority",
"=",
"self",
"::",
"levelPriority",
"(",
"$",
"level",
")",
";",
"if",
"(",
"$",
"levelPriority",
">",
"LOG_DEBUG",
")",
"{",
"throw",
"new",
"\\",
"Psr",
"\\",
"Log",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid log level: $level.\"",
")",
";",
"}",
"// Prevent an infinite cycle by setting an internal flag.",
"static",
"$",
"inCall",
"=",
"false",
";",
"if",
"(",
"$",
"inCall",
")",
"{",
"return",
";",
"}",
"$",
"inCall",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"/* @var LoggerInterface $logger */",
"if",
"(",
"!",
"$",
"logger",
"[",
"'enabled'",
"]",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"logger",
"[",
"'priority'",
"]",
">=",
"$",
"levelPriority",
")",
"{",
"try",
"{",
"$",
"logger",
"[",
"'logger'",
"]",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"inCall",
"=",
"false",
";",
"throw",
"$",
"ex",
";",
"}",
"}",
"}",
"$",
"inCall",
"=",
"false",
";",
"}"
] | Log with an arbitrary level.
@param mixed $level
@param string $message
@param array $context | [
"Log",
"with",
"an",
"arbitrary",
"level",
"."
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Log/AggregateLogger.php#L167-L197 |
4,289 | TechPromux/TechPromuxDynamicConfigurationBundle | Type/Variable/ImageVariableType.php | ImageVariableType.getMediaContext | public function getMediaContext($context_id = null)
{
if (is_null($context_id)) {
$context_id = $this->getMediaContextId();
}
$context = $this->getClassificationContextManager()->find($context_id);
if (is_null($context)) {
$context = $this->getClassificationContextManager()->create();
$context->setId($context_id);
$context->setName($context_id);
$context->setEnabled(true);
$context->setCreatedAt(new \Datetime());
$context->setUpdatedAt(new \Datetime());
$this->getEntityManager()->persist($context);
$this->getEntityManager()->flush($context);
$defaultCategory = $this->getClassificationCategoryManager()->create();
$defaultCategory->setContext($context);
$defaultCategory->setName($context->getId() . '_default');
$defaultCategory->setEnabled(true);
$defaultCategory->setCreatedAt(new \Datetime());
$defaultCategory->setUpdatedAt(new \Datetime());
$defaultCategory->setSlug($context->getId() . '_default');
$defaultCategory->setDescription($context->getId() . '_default');
$this->getEntityManager()->persist($defaultCategory);
$this->getEntityManager()->flush($defaultCategory);
}
return $context;
} | php | public function getMediaContext($context_id = null)
{
if (is_null($context_id)) {
$context_id = $this->getMediaContextId();
}
$context = $this->getClassificationContextManager()->find($context_id);
if (is_null($context)) {
$context = $this->getClassificationContextManager()->create();
$context->setId($context_id);
$context->setName($context_id);
$context->setEnabled(true);
$context->setCreatedAt(new \Datetime());
$context->setUpdatedAt(new \Datetime());
$this->getEntityManager()->persist($context);
$this->getEntityManager()->flush($context);
$defaultCategory = $this->getClassificationCategoryManager()->create();
$defaultCategory->setContext($context);
$defaultCategory->setName($context->getId() . '_default');
$defaultCategory->setEnabled(true);
$defaultCategory->setCreatedAt(new \Datetime());
$defaultCategory->setUpdatedAt(new \Datetime());
$defaultCategory->setSlug($context->getId() . '_default');
$defaultCategory->setDescription($context->getId() . '_default');
$this->getEntityManager()->persist($defaultCategory);
$this->getEntityManager()->flush($defaultCategory);
}
return $context;
} | [
"public",
"function",
"getMediaContext",
"(",
"$",
"context_id",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"context_id",
")",
")",
"{",
"$",
"context_id",
"=",
"$",
"this",
"->",
"getMediaContextId",
"(",
")",
";",
"}",
"$",
"context",
"=",
"$",
"this",
"->",
"getClassificationContextManager",
"(",
")",
"->",
"find",
"(",
"$",
"context_id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"context",
")",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"getClassificationContextManager",
"(",
")",
"->",
"create",
"(",
")",
";",
"$",
"context",
"->",
"setId",
"(",
"$",
"context_id",
")",
";",
"$",
"context",
"->",
"setName",
"(",
"$",
"context_id",
")",
";",
"$",
"context",
"->",
"setEnabled",
"(",
"true",
")",
";",
"$",
"context",
"->",
"setCreatedAt",
"(",
"new",
"\\",
"Datetime",
"(",
")",
")",
";",
"$",
"context",
"->",
"setUpdatedAt",
"(",
"new",
"\\",
"Datetime",
"(",
")",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"context",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
"$",
"context",
")",
";",
"$",
"defaultCategory",
"=",
"$",
"this",
"->",
"getClassificationCategoryManager",
"(",
")",
"->",
"create",
"(",
")",
";",
"$",
"defaultCategory",
"->",
"setContext",
"(",
"$",
"context",
")",
";",
"$",
"defaultCategory",
"->",
"setName",
"(",
"$",
"context",
"->",
"getId",
"(",
")",
".",
"'_default'",
")",
";",
"$",
"defaultCategory",
"->",
"setEnabled",
"(",
"true",
")",
";",
"$",
"defaultCategory",
"->",
"setCreatedAt",
"(",
"new",
"\\",
"Datetime",
"(",
")",
")",
";",
"$",
"defaultCategory",
"->",
"setUpdatedAt",
"(",
"new",
"\\",
"Datetime",
"(",
")",
")",
";",
"$",
"defaultCategory",
"->",
"setSlug",
"(",
"$",
"context",
"->",
"getId",
"(",
")",
".",
"'_default'",
")",
";",
"$",
"defaultCategory",
"->",
"setDescription",
"(",
"$",
"context",
"->",
"getId",
"(",
")",
".",
"'_default'",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"defaultCategory",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
"$",
"defaultCategory",
")",
";",
"}",
"return",
"$",
"context",
";",
"}"
] | Obtiene el contexto de medias
@return \Sonata\ClassificationBundle\Entity\BaseContext | [
"Obtiene",
"el",
"contexto",
"de",
"medias"
] | 0ddbe169de55f392a5e468008d3663f492b5aa25 | https://github.com/TechPromux/TechPromuxDynamicConfigurationBundle/blob/0ddbe169de55f392a5e468008d3663f492b5aa25/Type/Variable/ImageVariableType.php#L189-L221 |
4,290 | Cyberrebell/ZF2DoctrineCrudHandler | library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Handler/AbstractFormHandler.php | AbstractFormHandler.setSuccessRedirect | public function setSuccessRedirect(\Zend\Mvc\Controller\Plugin\Redirect $redirect, $route, $params = []) {
$this->redirect = $redirect;
$this->redirectRoute = $route;
$this->params = $params;
} | php | public function setSuccessRedirect(\Zend\Mvc\Controller\Plugin\Redirect $redirect, $route, $params = []) {
$this->redirect = $redirect;
$this->redirectRoute = $route;
$this->params = $params;
} | [
"public",
"function",
"setSuccessRedirect",
"(",
"\\",
"Zend",
"\\",
"Mvc",
"\\",
"Controller",
"\\",
"Plugin",
"\\",
"Redirect",
"$",
"redirect",
",",
"$",
"route",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"redirect",
"=",
"$",
"redirect",
";",
"$",
"this",
"->",
"redirectRoute",
"=",
"$",
"route",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"}"
] | Set the redirect that will be used if data is saved successfully
@param \Zend\Mvc\Controller\Plugin\Redirect $redirect
@param string $route | [
"Set",
"the",
"redirect",
"that",
"will",
"be",
"used",
"if",
"data",
"is",
"saved",
"successfully"
] | 9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb | https://github.com/Cyberrebell/ZF2DoctrineCrudHandler/blob/9ed9b1ae8d7a2a051a1f4638be1dfeefa150d8bb/library/ZF2DoctrineCrudHandler/src/ZF2DoctrineCrudHandler/Handler/AbstractFormHandler.php#L78-L82 |
4,291 | jmpantoja/planb-utils | src/Pattern/Factory/Factory.php | Factory.create | protected function create(...$arguments)
{
$response = null;
while ($method = $this->methods->next($response)) {
$response = call_user_func($method, ...$arguments);
}
return $response;
} | php | protected function create(...$arguments)
{
$response = null;
while ($method = $this->methods->next($response)) {
$response = call_user_func($method, ...$arguments);
}
return $response;
} | [
"protected",
"function",
"create",
"(",
"...",
"$",
"arguments",
")",
"{",
"$",
"response",
"=",
"null",
";",
"while",
"(",
"$",
"method",
"=",
"$",
"this",
"->",
"methods",
"->",
"next",
"(",
"$",
"response",
")",
")",
"{",
"$",
"response",
"=",
"call_user_func",
"(",
"$",
"method",
",",
"...",
"$",
"arguments",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Crea un valor para ser devuelto
@param mixed ...$arguments
@return mixed | [
"Crea",
"un",
"valor",
"para",
"ser",
"devuelto"
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Pattern/Factory/Factory.php#L85-L93 |
4,292 | bishopb/vanilla | library/core/class.plugin.php | Gdn_Plugin.GetPluginKey | public function GetPluginKey($Key, $Default = NULL) {
return GetValue($Key, Gdn::PluginManager()->GetPluginInfo(get_class($this), Gdn_PluginManager::ACCESS_CLASSNAME), $Default);
} | php | public function GetPluginKey($Key, $Default = NULL) {
return GetValue($Key, Gdn::PluginManager()->GetPluginInfo(get_class($this), Gdn_PluginManager::ACCESS_CLASSNAME), $Default);
} | [
"public",
"function",
"GetPluginKey",
"(",
"$",
"Key",
",",
"$",
"Default",
"=",
"NULL",
")",
"{",
"return",
"GetValue",
"(",
"$",
"Key",
",",
"Gdn",
"::",
"PluginManager",
"(",
")",
"->",
"GetPluginInfo",
"(",
"get_class",
"(",
"$",
"this",
")",
",",
"Gdn_PluginManager",
"::",
"ACCESS_CLASSNAME",
")",
",",
"$",
"Default",
")",
";",
"}"
] | Get a specific keyvalue from the plugin info array
@param string $Key Name of the key whose value you wish to retrieve
@param mixed $Default Optional value to return if the key cannot be found
@return mixed value of the provided key | [
"Get",
"a",
"specific",
"keyvalue",
"from",
"the",
"plugin",
"info",
"array"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.plugin.php#L60-L62 |
4,293 | bishopb/vanilla | library/core/class.plugin.php | Gdn_Plugin.TrimMetaKey | protected function TrimMetaKey($FullyQualifiedUserKey) {
$Key = explode('.', $FullyQualifiedUserKey);
if ($Key[0] == 'Plugin' && sizeof($Key) >= 3) {
return implode('.',array_slice($Key, 2));
}
return $FullyQualifiedUserKey;
} | php | protected function TrimMetaKey($FullyQualifiedUserKey) {
$Key = explode('.', $FullyQualifiedUserKey);
if ($Key[0] == 'Plugin' && sizeof($Key) >= 3) {
return implode('.',array_slice($Key, 2));
}
return $FullyQualifiedUserKey;
} | [
"protected",
"function",
"TrimMetaKey",
"(",
"$",
"FullyQualifiedUserKey",
")",
"{",
"$",
"Key",
"=",
"explode",
"(",
"'.'",
",",
"$",
"FullyQualifiedUserKey",
")",
";",
"if",
"(",
"$",
"Key",
"[",
"0",
"]",
"==",
"'Plugin'",
"&&",
"sizeof",
"(",
"$",
"Key",
")",
">=",
"3",
")",
"{",
"return",
"implode",
"(",
"'.'",
",",
"array_slice",
"(",
"$",
"Key",
",",
"2",
")",
")",
";",
"}",
"return",
"$",
"FullyQualifiedUserKey",
";",
"}"
] | This method trims the plugin prefix from a fully qualified MetaKey.
For example, Plugin.Signatures.Sig would become 'Sig'.
@param $UserMetaKey string fully qualified meta key
@return string relative meta key | [
"This",
"method",
"trims",
"the",
"plugin",
"prefix",
"from",
"a",
"fully",
"qualified",
"MetaKey",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.plugin.php#L175-L182 |
4,294 | bishopb/vanilla | library/core/class.plugin.php | Gdn_Plugin.AutoToggle | public function AutoToggle($Sender, $Redirect = NULL) {
$PluginName = $this->GetPluginIndex();
$EnabledKey = "Plugins.{$PluginName}.Enabled";
$CurrentConfig = C($EnabledKey, FALSE);
$PassedKey = GetValue(1, $Sender->RequestArgs);
if ($Sender->Form->AuthenticatedPostBack() || Gdn::Session()->ValidateTransientKey($PassedKey)) {
$CurrentConfig = !$CurrentConfig;
SaveToConfig($EnabledKey, $CurrentConfig);
}
if ($Sender->Form->AuthenticatedPostBack())
$this->Controller_Index($Sender);
else {
if ($Redirect === FALSE) return $CurrentConfig;
if (is_null($Redirect))
Redirect('plugin/'.strtolower($PluginName));
else
Redirect($Redirect);
}
return $CurrentConfig;
} | php | public function AutoToggle($Sender, $Redirect = NULL) {
$PluginName = $this->GetPluginIndex();
$EnabledKey = "Plugins.{$PluginName}.Enabled";
$CurrentConfig = C($EnabledKey, FALSE);
$PassedKey = GetValue(1, $Sender->RequestArgs);
if ($Sender->Form->AuthenticatedPostBack() || Gdn::Session()->ValidateTransientKey($PassedKey)) {
$CurrentConfig = !$CurrentConfig;
SaveToConfig($EnabledKey, $CurrentConfig);
}
if ($Sender->Form->AuthenticatedPostBack())
$this->Controller_Index($Sender);
else {
if ($Redirect === FALSE) return $CurrentConfig;
if (is_null($Redirect))
Redirect('plugin/'.strtolower($PluginName));
else
Redirect($Redirect);
}
return $CurrentConfig;
} | [
"public",
"function",
"AutoToggle",
"(",
"$",
"Sender",
",",
"$",
"Redirect",
"=",
"NULL",
")",
"{",
"$",
"PluginName",
"=",
"$",
"this",
"->",
"GetPluginIndex",
"(",
")",
";",
"$",
"EnabledKey",
"=",
"\"Plugins.{$PluginName}.Enabled\"",
";",
"$",
"CurrentConfig",
"=",
"C",
"(",
"$",
"EnabledKey",
",",
"FALSE",
")",
";",
"$",
"PassedKey",
"=",
"GetValue",
"(",
"1",
",",
"$",
"Sender",
"->",
"RequestArgs",
")",
";",
"if",
"(",
"$",
"Sender",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
"||",
"Gdn",
"::",
"Session",
"(",
")",
"->",
"ValidateTransientKey",
"(",
"$",
"PassedKey",
")",
")",
"{",
"$",
"CurrentConfig",
"=",
"!",
"$",
"CurrentConfig",
";",
"SaveToConfig",
"(",
"$",
"EnabledKey",
",",
"$",
"CurrentConfig",
")",
";",
"}",
"if",
"(",
"$",
"Sender",
"->",
"Form",
"->",
"AuthenticatedPostBack",
"(",
")",
")",
"$",
"this",
"->",
"Controller_Index",
"(",
"$",
"Sender",
")",
";",
"else",
"{",
"if",
"(",
"$",
"Redirect",
"===",
"FALSE",
")",
"return",
"$",
"CurrentConfig",
";",
"if",
"(",
"is_null",
"(",
"$",
"Redirect",
")",
")",
"Redirect",
"(",
"'plugin/'",
".",
"strtolower",
"(",
"$",
"PluginName",
")",
")",
";",
"else",
"Redirect",
"(",
"$",
"Redirect",
")",
";",
"}",
"return",
"$",
"CurrentConfig",
";",
"}"
] | Automatically handle the toggle effect
@param object $Sender Reference to the invoking controller
@param mixed $Redirect | [
"Automatically",
"handle",
"the",
"toggle",
"effect"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.plugin.php#L215-L236 |
4,295 | bishopb/vanilla | library/core/class.plugin.php | Gdn_Plugin.Render | public function Render($ViewName) {
$PluginFolder = $this->GetPluginFolder(FALSE);
$this->Sender->Render($ViewName, '', $PluginFolder);
} | php | public function Render($ViewName) {
$PluginFolder = $this->GetPluginFolder(FALSE);
$this->Sender->Render($ViewName, '', $PluginFolder);
} | [
"public",
"function",
"Render",
"(",
"$",
"ViewName",
")",
"{",
"$",
"PluginFolder",
"=",
"$",
"this",
"->",
"GetPluginFolder",
"(",
"FALSE",
")",
";",
"$",
"this",
"->",
"Sender",
"->",
"Render",
"(",
"$",
"ViewName",
",",
"''",
",",
"$",
"PluginFolder",
")",
";",
"}"
] | Passthru render request to sender
This render method automatically adds the correct ApplicationFolder parameter
so that $Sender->Render() will first check the plugin's views/ folder.
@param string $ViewName | [
"Passthru",
"render",
"request",
"to",
"sender"
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.plugin.php#L291-L294 |
4,296 | massimo-filippi/slack-module | src/Model/AttachmentAction.php | AttachmentAction.toArray | public function toArray()
{
$data = [
'name' => $this->getName(),
'text' => $this->getText(),
'type' => $this->getType(),
'style' => $this->getStyle(),
];
if($this->getUrl()) $data['url'] = $this->getUrl();
if($this->getValue()) $data['value'] = $this->getValue();
if($this->getConfirm()) $data['confirm'] = $this->getConfirm()->toArray();
if($this->getOptions()) $data['options'] = $this->getOptions();
if($this->getOptionGroups()) $data['option_groups'] = $this->getOptionGroups();
if($this->getDataSource()) $data['data_source'] = $this->getDataSource();
if($this->getSelectedOptions()) $data['selected_options'] = $this->getSelectedOptions();
if($this->getMinQueryLength()) $data['min_query_length'] = $this->getMinQueryLength();
return $data;
} | php | public function toArray()
{
$data = [
'name' => $this->getName(),
'text' => $this->getText(),
'type' => $this->getType(),
'style' => $this->getStyle(),
];
if($this->getUrl()) $data['url'] = $this->getUrl();
if($this->getValue()) $data['value'] = $this->getValue();
if($this->getConfirm()) $data['confirm'] = $this->getConfirm()->toArray();
if($this->getOptions()) $data['options'] = $this->getOptions();
if($this->getOptionGroups()) $data['option_groups'] = $this->getOptionGroups();
if($this->getDataSource()) $data['data_source'] = $this->getDataSource();
if($this->getSelectedOptions()) $data['selected_options'] = $this->getSelectedOptions();
if($this->getMinQueryLength()) $data['min_query_length'] = $this->getMinQueryLength();
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'text'",
"=>",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"'type'",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"'style'",
"=>",
"$",
"this",
"->",
"getStyle",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"getUrl",
"(",
")",
")",
"$",
"data",
"[",
"'url'",
"]",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
"$",
"data",
"[",
"'value'",
"]",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getConfirm",
"(",
")",
")",
"$",
"data",
"[",
"'confirm'",
"]",
"=",
"$",
"this",
"->",
"getConfirm",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
")",
"$",
"data",
"[",
"'options'",
"]",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOptionGroups",
"(",
")",
")",
"$",
"data",
"[",
"'option_groups'",
"]",
"=",
"$",
"this",
"->",
"getOptionGroups",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getDataSource",
"(",
")",
")",
"$",
"data",
"[",
"'data_source'",
"]",
"=",
"$",
"this",
"->",
"getDataSource",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getSelectedOptions",
"(",
")",
")",
"$",
"data",
"[",
"'selected_options'",
"]",
"=",
"$",
"this",
"->",
"getSelectedOptions",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getMinQueryLength",
"(",
")",
")",
"$",
"data",
"[",
"'min_query_length'",
"]",
"=",
"$",
"this",
"->",
"getMinQueryLength",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Get the array representation of this attachment action
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"this",
"attachment",
"action"
] | 76bf7e3adbb690c9b591170651730cc5f12d8800 | https://github.com/massimo-filippi/slack-module/blob/76bf7e3adbb690c9b591170651730cc5f12d8800/src/Model/AttachmentAction.php#L368-L387 |
4,297 | velkuns/eureka-package-user | src/User/Component/Authentication/User.php | User.checkAuthentication | public static function checkAuthentication($redirect = true)
{
if(static::isAuthenticated()) {
return;
}
if ($redirect) {
Http\Server::getInstance()->redirect(RouteCollection::getInstance()->get('login')->getUri());
} else {
throw new LoginException();
}
} | php | public static function checkAuthentication($redirect = true)
{
if(static::isAuthenticated()) {
return;
}
if ($redirect) {
Http\Server::getInstance()->redirect(RouteCollection::getInstance()->get('login')->getUri());
} else {
throw new LoginException();
}
} | [
"public",
"static",
"function",
"checkAuthentication",
"(",
"$",
"redirect",
"=",
"true",
")",
"{",
"if",
"(",
"static",
"::",
"isAuthenticated",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"redirect",
")",
"{",
"Http",
"\\",
"Server",
"::",
"getInstance",
"(",
")",
"->",
"redirect",
"(",
"RouteCollection",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"'login'",
")",
"->",
"getUri",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"LoginException",
"(",
")",
";",
"}",
"}"
] | Check for authentication & redirect if not logged in.
@param bool $redirect
@return void
@throws \Exception | [
"Check",
"for",
"authentication",
"&",
"redirect",
"if",
"not",
"logged",
"in",
"."
] | b5a60b5a234162558b390ee3d452e4254c790f2b | https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/Component/Authentication/User.php#L50-L61 |
4,298 | velkuns/eureka-package-user | src/User/Component/Authentication/User.php | User.restoreFromSession | protected static function restoreFromSession()
{
$session = Http\Session::getInstance();
try {
$mapper = new UserMapper(Database::get());
$user = $mapper->findFromSession($session);
} catch (\Exception $exception) {
$user = new Data\User\User();
}
static::$user = $user;
} | php | protected static function restoreFromSession()
{
$session = Http\Session::getInstance();
try {
$mapper = new UserMapper(Database::get());
$user = $mapper->findFromSession($session);
} catch (\Exception $exception) {
$user = new Data\User\User();
}
static::$user = $user;
} | [
"protected",
"static",
"function",
"restoreFromSession",
"(",
")",
"{",
"$",
"session",
"=",
"Http",
"\\",
"Session",
"::",
"getInstance",
"(",
")",
";",
"try",
"{",
"$",
"mapper",
"=",
"new",
"UserMapper",
"(",
"Database",
"::",
"get",
"(",
")",
")",
";",
"$",
"user",
"=",
"$",
"mapper",
"->",
"findFromSession",
"(",
"$",
"session",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"user",
"=",
"new",
"Data",
"\\",
"User",
"\\",
"User",
"(",
")",
";",
"}",
"static",
"::",
"$",
"user",
"=",
"$",
"user",
";",
"}"
] | Try to restore user from data in session.
@return void | [
"Try",
"to",
"restore",
"user",
"from",
"data",
"in",
"session",
"."
] | b5a60b5a234162558b390ee3d452e4254c790f2b | https://github.com/velkuns/eureka-package-user/blob/b5a60b5a234162558b390ee3d452e4254c790f2b/src/User/Component/Authentication/User.php#L82-L94 |
4,299 | IVIR3zaM/ObjectArrayTools | src/Traits/SerializableTrait.php | SerializableTrait.serialize | public function serialize()
{
$list = [];
foreach ($this as $index => $value) {
$list[$index] = $value;
}
return serialize($list);
} | php | public function serialize()
{
$list = [];
foreach ($this as $index => $value) {
$list[$index] = $value;
}
return serialize($list);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"$",
"list",
"[",
"$",
"index",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"serialize",
"(",
"$",
"list",
")",
";",
"}"
] | serializing the data fo current object
@return string serialized data | [
"serializing",
"the",
"data",
"fo",
"current",
"object"
] | 31c12fc6f8a40a36873c074409ae4299b35f9177 | https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/SerializableTrait.php#L19-L26 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.