id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
234,500
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifiable.php
|
CommentNotifiable.notificationTemplate
|
public function notificationTemplate($comment, $recipient)
{
$template = $this->owner->config()->default_notification_template;
$this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
return $template;
}
|
php
|
public function notificationTemplate($comment, $recipient)
{
$template = $this->owner->config()->default_notification_template;
$this->owner->invokeWithExtensions('updateNotificationTemplate', $template, $comment, $recipient);
return $template;
}
|
[
"public",
"function",
"notificationTemplate",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_template",
";",
"$",
"this",
"->",
"owner",
"->",
"invokeWithExtensions",
"(",
"'updateNotificationTemplate'",
",",
"$",
"template",
",",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"return",
"$",
"template",
";",
"}"
] |
Determine the template to use for this email
@param Comment $comment
@param Member|string $recipient
@return string Template name (excluding .ss extension)
|
[
"Determine",
"the",
"template",
"to",
"use",
"for",
"this",
"email"
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L102-L109
|
234,501
|
oxygen-cms/core
|
src/Html/Editor/Editor.php
|
Editor.getCreateScript
|
public function getCreateScript() {
static::$includeScripts = true;
$text = '<script>';
$text .= 'editors = ( typeof editors != "undefined" && editors instanceof Array ) ? editors : [];';
$text .= 'editors.push({';
$text .= 'name: "' . $this->name . '",';
$text .= 'stylesheets: ' . json_encode($this->stylesheets) . ',';
foreach($this->options as $key => $value) {
$text .= $key . ': "' . $value . '",';
}
$text .= '});</script>';
return $text;
}
|
php
|
public function getCreateScript() {
static::$includeScripts = true;
$text = '<script>';
$text .= 'editors = ( typeof editors != "undefined" && editors instanceof Array ) ? editors : [];';
$text .= 'editors.push({';
$text .= 'name: "' . $this->name . '",';
$text .= 'stylesheets: ' . json_encode($this->stylesheets) . ',';
foreach($this->options as $key => $value) {
$text .= $key . ': "' . $value . '",';
}
$text .= '});</script>';
return $text;
}
|
[
"public",
"function",
"getCreateScript",
"(",
")",
"{",
"static",
"::",
"$",
"includeScripts",
"=",
"true",
";",
"$",
"text",
"=",
"'<script>'",
";",
"$",
"text",
".=",
"'editors = ( typeof editors != \"undefined\" && editors instanceof Array ) ? editors : [];'",
";",
"$",
"text",
".=",
"'editors.push({'",
";",
"$",
"text",
".=",
"'name: \"'",
".",
"$",
"this",
"->",
"name",
".",
"'\",'",
";",
"$",
"text",
".=",
"'stylesheets: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"stylesheets",
")",
".",
"','",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"text",
".=",
"$",
"key",
".",
"': \"'",
".",
"$",
"value",
".",
"'\",'",
";",
"}",
"$",
"text",
".=",
"'});</script>'",
";",
"return",
"$",
"text",
";",
"}"
] |
Returns the JavaScript code used to
initialise a Editor for the given information.
@return string
|
[
"Returns",
"the",
"JavaScript",
"code",
"used",
"to",
"initialise",
"a",
"Editor",
"for",
"the",
"given",
"information",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Editor/Editor.php#L161-L177
|
234,502
|
Superbalist/php-pubsub-http
|
src/HTTPPubSubAdapter.php
|
HTTPPubSubAdapter.post
|
public function post($endpoint, array $data = [])
{
$body = json_encode($data);
$request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
return $this->sendRequest($request);
}
|
php
|
public function post($endpoint, array $data = [])
{
$body = json_encode($data);
$request = $this->createRequest('POST', $endpoint, $body, ['Content-Type' => 'application/json']);
return $this->sendRequest($request);
}
|
[
"public",
"function",
"post",
"(",
"$",
"endpoint",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"body",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'POST'",
",",
"$",
"endpoint",
",",
"$",
"body",
",",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"request",
")",
";",
"}"
] |
Make an HTTP POST request.
@param string $endpoint
@param array $data
@return mixed
|
[
"Make",
"an",
"HTTP",
"POST",
"request",
"."
] |
fd7e7d7a3b2bc858b79117a9fc3af2cb2e9e83f1
|
https://github.com/Superbalist/php-pubsub-http/blob/fd7e7d7a3b2bc858b79117a9fc3af2cb2e9e83f1/src/HTTPPubSubAdapter.php#L154-L159
|
234,503
|
netzmacht/contao-icon-wizard
|
src/WizardController.php
|
WizardController.run
|
public function run()
{
$table = \Input::get('table');
$field = \Input::get('field');
$name = \Input::get('name');
$rowId = \Input::get('id');
$dataContainer = $this->initializeDataContainer($table, $field);
$this->loadRow($table, $rowId, $dataContainer);
$template = $this->prepareTemplate();
$template->table = $table;
$template->field = $field;
$template->name = $name;
$template->icon = $dataContainer->activeRecord->$field;
$template->icons = $this->generateIcons($field);
$template->output();
}
|
php
|
public function run()
{
$table = \Input::get('table');
$field = \Input::get('field');
$name = \Input::get('name');
$rowId = \Input::get('id');
$dataContainer = $this->initializeDataContainer($table, $field);
$this->loadRow($table, $rowId, $dataContainer);
$template = $this->prepareTemplate();
$template->table = $table;
$template->field = $field;
$template->name = $name;
$template->icon = $dataContainer->activeRecord->$field;
$template->icons = $this->generateIcons($field);
$template->output();
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"table",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'table'",
")",
";",
"$",
"field",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'field'",
")",
";",
"$",
"name",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'name'",
")",
";",
"$",
"rowId",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'id'",
")",
";",
"$",
"dataContainer",
"=",
"$",
"this",
"->",
"initializeDataContainer",
"(",
"$",
"table",
",",
"$",
"field",
")",
";",
"$",
"this",
"->",
"loadRow",
"(",
"$",
"table",
",",
"$",
"rowId",
",",
"$",
"dataContainer",
")",
";",
"$",
"template",
"=",
"$",
"this",
"->",
"prepareTemplate",
"(",
")",
";",
"$",
"template",
"->",
"table",
"=",
"$",
"table",
";",
"$",
"template",
"->",
"field",
"=",
"$",
"field",
";",
"$",
"template",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"template",
"->",
"icon",
"=",
"$",
"dataContainer",
"->",
"activeRecord",
"->",
"$",
"field",
";",
"$",
"template",
"->",
"icons",
"=",
"$",
"this",
"->",
"generateIcons",
"(",
"$",
"field",
")",
";",
"$",
"template",
"->",
"output",
"(",
")",
";",
"}"
] |
Run the controller.
@throws \RuntimeException If an invalid call is made.
@return void
@SuppressWarnings(PHPMD.Superglobals)
|
[
"Run",
"the",
"controller",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L51-L70
|
234,504
|
netzmacht/contao-icon-wizard
|
src/WizardController.php
|
WizardController.initializeDataContainer
|
private function initializeDataContainer($table, $field)
{
// Define the current ID
if (!defined('CURRENT_ID')) {
define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
}
static::loadDataContainer($table);
$this->dca = &$GLOBALS['TL_DCA'][$table];
$driverClass = 'DC_' . $this->dca['config']['dataContainer'];
$dataContainer = new $driverClass($table);
$dataContainer->field = $field;
if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
}
$values = $dataContainer->activeRecord->$field;
// Call the load_callback
if (is_array($this->dca['fields'][$field]['load_callback'])) {
foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
$values = $this->triggerCallback($callback, array($values, $dataContainer));
}
}
// support options callback
if (isset($this->dca['fields'][$field]['options_callback'])) {
$this->dca['fields'][$field]['options'] = $this->triggerCallback(
$this->dca['fields'][$field]['options_callback'],
array($dataContainer)
);
}
return $dataContainer;
}
|
php
|
private function initializeDataContainer($table, $field)
{
// Define the current ID
if (!defined('CURRENT_ID')) {
define('CURRENT_ID', $table ? \Session::getInstance()->get('CURRENT_ID') : $field);
}
static::loadDataContainer($table);
$this->dca = &$GLOBALS['TL_DCA'][$table];
$driverClass = 'DC_' . $this->dca['config']['dataContainer'];
$dataContainer = new $driverClass($table);
$dataContainer->field = $field;
if (!isset($this->dca['fields'][$field]) || $this->dca['fields'][$field]['inputType'] != 'icon') {
throw new \RuntimeException('Invalid call. Field does not exists or is not an icon wizard');
}
$values = $dataContainer->activeRecord->$field;
// Call the load_callback
if (is_array($this->dca['fields'][$field]['load_callback'])) {
foreach ($this->dca['fields'][$field]['load_callback'] as $callback) {
$values = $this->triggerCallback($callback, array($values, $dataContainer));
}
}
// support options callback
if (isset($this->dca['fields'][$field]['options_callback'])) {
$this->dca['fields'][$field]['options'] = $this->triggerCallback(
$this->dca['fields'][$field]['options_callback'],
array($dataContainer)
);
}
return $dataContainer;
}
|
[
"private",
"function",
"initializeDataContainer",
"(",
"$",
"table",
",",
"$",
"field",
")",
"{",
"// Define the current ID",
"if",
"(",
"!",
"defined",
"(",
"'CURRENT_ID'",
")",
")",
"{",
"define",
"(",
"'CURRENT_ID'",
",",
"$",
"table",
"?",
"\\",
"Session",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"'CURRENT_ID'",
")",
":",
"$",
"field",
")",
";",
"}",
"static",
"::",
"loadDataContainer",
"(",
"$",
"table",
")",
";",
"$",
"this",
"->",
"dca",
"=",
"&",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"$",
"table",
"]",
";",
"$",
"driverClass",
"=",
"'DC_'",
".",
"$",
"this",
"->",
"dca",
"[",
"'config'",
"]",
"[",
"'dataContainer'",
"]",
";",
"$",
"dataContainer",
"=",
"new",
"$",
"driverClass",
"(",
"$",
"table",
")",
";",
"$",
"dataContainer",
"->",
"field",
"=",
"$",
"field",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
")",
"||",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'inputType'",
"]",
"!=",
"'icon'",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Invalid call. Field does not exists or is not an icon wizard'",
")",
";",
"}",
"$",
"values",
"=",
"$",
"dataContainer",
"->",
"activeRecord",
"->",
"$",
"field",
";",
"// Call the load_callback",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'load_callback'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'load_callback'",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"triggerCallback",
"(",
"$",
"callback",
",",
"array",
"(",
"$",
"values",
",",
"$",
"dataContainer",
")",
")",
";",
"}",
"}",
"// support options callback",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'options_callback'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'options'",
"]",
"=",
"$",
"this",
"->",
"triggerCallback",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'options_callback'",
"]",
",",
"array",
"(",
"$",
"dataContainer",
")",
")",
";",
"}",
"return",
"$",
"dataContainer",
";",
"}"
] |
Initialize the data container driver.
@param string $table The table name.
@param string $field The field name.
@return \DataContainer
@throws \RuntimeException If the field does not exists.
@SuppressWarnings(PHPMD.Superglobals)
|
[
"Initialize",
"the",
"data",
"container",
"driver",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L113-L150
|
234,505
|
netzmacht/contao-icon-wizard
|
src/WizardController.php
|
WizardController.loadRow
|
private function loadRow($table, $rowId, $dataContainer)
{
$dataContainer->activeRecord = $this->Database
->prepare(sprintf('SELECT * FROM %s WHERE id=?', $table))
->limit(1)
->execute($rowId);
if ($dataContainer->activeRecord->numRows != 1) {
throw new \RuntimeException('Selected entry does not exists');
}
}
|
php
|
private function loadRow($table, $rowId, $dataContainer)
{
$dataContainer->activeRecord = $this->Database
->prepare(sprintf('SELECT * FROM %s WHERE id=?', $table))
->limit(1)
->execute($rowId);
if ($dataContainer->activeRecord->numRows != 1) {
throw new \RuntimeException('Selected entry does not exists');
}
}
|
[
"private",
"function",
"loadRow",
"(",
"$",
"table",
",",
"$",
"rowId",
",",
"$",
"dataContainer",
")",
"{",
"$",
"dataContainer",
"->",
"activeRecord",
"=",
"$",
"this",
"->",
"Database",
"->",
"prepare",
"(",
"sprintf",
"(",
"'SELECT * FROM %s WHERE id=?'",
",",
"$",
"table",
")",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"execute",
"(",
"$",
"rowId",
")",
";",
"if",
"(",
"$",
"dataContainer",
"->",
"activeRecord",
"->",
"numRows",
"!=",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Selected entry does not exists'",
")",
";",
"}",
"}"
] |
Load the data row.
@param string $table The table name.
@param int $rowId The row id.
@param \DataContainer $dataContainer The data container.
@return void
@throws \RuntimeException If no data row is found.
|
[
"Load",
"the",
"data",
"row",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L162-L172
|
234,506
|
netzmacht/contao-icon-wizard
|
src/WizardController.php
|
WizardController.generateIcons
|
private function generateIcons($field)
{
$icons = array();
$iconTemplate = isset($this->dca['fields'][$field]['eval']['iconTemplate']) ?
$this->dca['fields'][$field]['eval']['iconTemplate'] :
$GLOBALS['TL_CONFIG']['iconWizardIconTemplate'];
foreach ((array) $this->dca['fields'][$field]['options'] as $groupName => $groupIcons) {
foreach ($groupIcons as $icon) {
$icons[$groupName][] = array(
'title' => $icon,
'generated' => sprintf($iconTemplate, $icon),
);
}
}
return $icons;
}
|
php
|
private function generateIcons($field)
{
$icons = array();
$iconTemplate = isset($this->dca['fields'][$field]['eval']['iconTemplate']) ?
$this->dca['fields'][$field]['eval']['iconTemplate'] :
$GLOBALS['TL_CONFIG']['iconWizardIconTemplate'];
foreach ((array) $this->dca['fields'][$field]['options'] as $groupName => $groupIcons) {
foreach ($groupIcons as $icon) {
$icons[$groupName][] = array(
'title' => $icon,
'generated' => sprintf($iconTemplate, $icon),
);
}
}
return $icons;
}
|
[
"private",
"function",
"generateIcons",
"(",
"$",
"field",
")",
"{",
"$",
"icons",
"=",
"array",
"(",
")",
";",
"$",
"iconTemplate",
"=",
"isset",
"(",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'eval'",
"]",
"[",
"'iconTemplate'",
"]",
")",
"?",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'eval'",
"]",
"[",
"'iconTemplate'",
"]",
":",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'iconWizardIconTemplate'",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"dca",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'options'",
"]",
"as",
"$",
"groupName",
"=>",
"$",
"groupIcons",
")",
"{",
"foreach",
"(",
"$",
"groupIcons",
"as",
"$",
"icon",
")",
"{",
"$",
"icons",
"[",
"$",
"groupName",
"]",
"[",
"]",
"=",
"array",
"(",
"'title'",
"=>",
"$",
"icon",
",",
"'generated'",
"=>",
"sprintf",
"(",
"$",
"iconTemplate",
",",
"$",
"icon",
")",
",",
")",
";",
"}",
"}",
"return",
"$",
"icons",
";",
"}"
] |
Generate the icons.
@param string $field The icons.
@return array
@SuppressWarnings(PHPMD.Superglobals)
|
[
"Generate",
"the",
"icons",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L182-L200
|
234,507
|
netzmacht/contao-icon-wizard
|
src/WizardController.php
|
WizardController.triggerCallback
|
private function triggerCallback($callback, $arguments)
{
if (is_array($callback)) {
$this->import($callback[0]);
return call_user_func_array(array($this->{$callback[0]}, $callback[1]), $arguments);
} elseif (is_callable($callback)) {
return call_user_func_array($callback, $arguments);
}
return null;
}
|
php
|
private function triggerCallback($callback, $arguments)
{
if (is_array($callback)) {
$this->import($callback[0]);
return call_user_func_array(array($this->{$callback[0]}, $callback[1]), $arguments);
} elseif (is_callable($callback)) {
return call_user_func_array($callback, $arguments);
}
return null;
}
|
[
"private",
"function",
"triggerCallback",
"(",
"$",
"callback",
",",
"$",
"arguments",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"this",
"->",
"import",
"(",
"$",
"callback",
"[",
"0",
"]",
")",
";",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
"->",
"{",
"$",
"callback",
"[",
"0",
"]",
"}",
",",
"$",
"callback",
"[",
"1",
"]",
")",
",",
"$",
"arguments",
")",
";",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"arguments",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Trigger callback.
@param array|callable $callback Callback to trigger.
@param array $arguments Callback arguments.
@return mixed
|
[
"Trigger",
"callback",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/WizardController.php#L210-L220
|
234,508
|
FbF/Laravel-Comments
|
src/models/Comment.php
|
Comment.getRules
|
public function getRules($commentableType)
{
$commentableObj = new $commentableType;
$table = $commentableObj->getTable();
$key = $commentableObj->getKeyName();
$rules = array(
'commentable_type' => 'required|in:'.implode(',', Config::get('laravel-comments::commentables')),
'commentable_id' => 'required|exists:'.$table.','.$key,
'comment' => 'required',
);
return $rules;
}
|
php
|
public function getRules($commentableType)
{
$commentableObj = new $commentableType;
$table = $commentableObj->getTable();
$key = $commentableObj->getKeyName();
$rules = array(
'commentable_type' => 'required|in:'.implode(',', Config::get('laravel-comments::commentables')),
'commentable_id' => 'required|exists:'.$table.','.$key,
'comment' => 'required',
);
return $rules;
}
|
[
"public",
"function",
"getRules",
"(",
"$",
"commentableType",
")",
"{",
"$",
"commentableObj",
"=",
"new",
"$",
"commentableType",
";",
"$",
"table",
"=",
"$",
"commentableObj",
"->",
"getTable",
"(",
")",
";",
"$",
"key",
"=",
"$",
"commentableObj",
"->",
"getKeyName",
"(",
")",
";",
"$",
"rules",
"=",
"array",
"(",
"'commentable_type'",
"=>",
"'required|in:'",
".",
"implode",
"(",
"','",
",",
"Config",
"::",
"get",
"(",
"'laravel-comments::commentables'",
")",
")",
",",
"'commentable_id'",
"=>",
"'required|exists:'",
".",
"$",
"table",
".",
"','",
".",
"$",
"key",
",",
"'comment'",
"=>",
"'required'",
",",
")",
";",
"return",
"$",
"rules",
";",
"}"
] |
Returns the validation rules for the comment
@param string $commentableType The namespaced model that is being commented on
@return array
|
[
"Returns",
"the",
"validation",
"rules",
"for",
"the",
"comment"
] |
bbf35cdf7f30199757da6bde009d6ccd700e9ccb
|
https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L105-L116
|
234,509
|
FbF/Laravel-Comments
|
src/models/Comment.php
|
Comment.getUrl
|
public function getUrl()
{
$commentable = $this->commentable;
$url = false;
if (method_exists($commentable, 'getUrl'))
{
$url = $commentable->getUrl();
}
return \URL::to($url.'#C'.$this->id);
}
|
php
|
public function getUrl()
{
$commentable = $this->commentable;
$url = false;
if (method_exists($commentable, 'getUrl'))
{
$url = $commentable->getUrl();
}
return \URL::to($url.'#C'.$this->id);
}
|
[
"public",
"function",
"getUrl",
"(",
")",
"{",
"$",
"commentable",
"=",
"$",
"this",
"->",
"commentable",
";",
"$",
"url",
"=",
"false",
";",
"if",
"(",
"method_exists",
"(",
"$",
"commentable",
",",
"'getUrl'",
")",
")",
"{",
"$",
"url",
"=",
"$",
"commentable",
"->",
"getUrl",
"(",
")",
";",
"}",
"return",
"\\",
"URL",
"::",
"to",
"(",
"$",
"url",
".",
"'#C'",
".",
"$",
"this",
"->",
"id",
")",
";",
"}"
] |
Returns the URL of the comment constructed based on the URL of the commentable object, plus the anchor of the
comment
@return string
|
[
"Returns",
"the",
"URL",
"of",
"the",
"comment",
"constructed",
"based",
"on",
"the",
"URL",
"of",
"the",
"commentable",
"object",
"plus",
"the",
"anchor",
"of",
"the",
"comment"
] |
bbf35cdf7f30199757da6bde009d6ccd700e9ccb
|
https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L124-L135
|
234,510
|
FbF/Laravel-Comments
|
src/models/Comment.php
|
Comment.getDate
|
public function getDate()
{
$date = $this->created_at;
if (Lang::has('laravel-comments::messages.date_timezone'))
{
$oldTimezone = date_default_timezone_get();
$newTimezone = Lang::get('laravel-comments::messages.date_timezone');
$date->setTimezone($newTimezone);
date_default_timezone_set($newTimezone);
}
$locale = \App::getLocale();
if (Lang::has('laravel-comments::messages.date_locale'))
{
$locale = Lang::get('laravel-comments::messages.date_locale');
}
setlocale(LC_TIME, $locale);
$dateFormat = trans('laravel-comments::messages.date_format');
if ($dateFormat == 'laravel-comments::messages.date_format')
{
$dateFormat = '%e %B %Y at %H:%M';
}
$date = $date->formatLocalized($dateFormat);
if (Lang::has('laravel-comments::messages.date_timezone'))
{
date_default_timezone_set($oldTimezone);
}
return $date;
}
|
php
|
public function getDate()
{
$date = $this->created_at;
if (Lang::has('laravel-comments::messages.date_timezone'))
{
$oldTimezone = date_default_timezone_get();
$newTimezone = Lang::get('laravel-comments::messages.date_timezone');
$date->setTimezone($newTimezone);
date_default_timezone_set($newTimezone);
}
$locale = \App::getLocale();
if (Lang::has('laravel-comments::messages.date_locale'))
{
$locale = Lang::get('laravel-comments::messages.date_locale');
}
setlocale(LC_TIME, $locale);
$dateFormat = trans('laravel-comments::messages.date_format');
if ($dateFormat == 'laravel-comments::messages.date_format')
{
$dateFormat = '%e %B %Y at %H:%M';
}
$date = $date->formatLocalized($dateFormat);
if (Lang::has('laravel-comments::messages.date_timezone'))
{
date_default_timezone_set($oldTimezone);
}
return $date;
}
|
[
"public",
"function",
"getDate",
"(",
")",
"{",
"$",
"date",
"=",
"$",
"this",
"->",
"created_at",
";",
"if",
"(",
"Lang",
"::",
"has",
"(",
"'laravel-comments::messages.date_timezone'",
")",
")",
"{",
"$",
"oldTimezone",
"=",
"date_default_timezone_get",
"(",
")",
";",
"$",
"newTimezone",
"=",
"Lang",
"::",
"get",
"(",
"'laravel-comments::messages.date_timezone'",
")",
";",
"$",
"date",
"->",
"setTimezone",
"(",
"$",
"newTimezone",
")",
";",
"date_default_timezone_set",
"(",
"$",
"newTimezone",
")",
";",
"}",
"$",
"locale",
"=",
"\\",
"App",
"::",
"getLocale",
"(",
")",
";",
"if",
"(",
"Lang",
"::",
"has",
"(",
"'laravel-comments::messages.date_locale'",
")",
")",
"{",
"$",
"locale",
"=",
"Lang",
"::",
"get",
"(",
"'laravel-comments::messages.date_locale'",
")",
";",
"}",
"setlocale",
"(",
"LC_TIME",
",",
"$",
"locale",
")",
";",
"$",
"dateFormat",
"=",
"trans",
"(",
"'laravel-comments::messages.date_format'",
")",
";",
"if",
"(",
"$",
"dateFormat",
"==",
"'laravel-comments::messages.date_format'",
")",
"{",
"$",
"dateFormat",
"=",
"'%e %B %Y at %H:%M'",
";",
"}",
"$",
"date",
"=",
"$",
"date",
"->",
"formatLocalized",
"(",
"$",
"dateFormat",
")",
";",
"if",
"(",
"Lang",
"::",
"has",
"(",
"'laravel-comments::messages.date_timezone'",
")",
")",
"{",
"date_default_timezone_set",
"(",
"$",
"oldTimezone",
")",
";",
"}",
"return",
"$",
"date",
";",
"}"
] |
Returns the locale formatted date, in the locale's timezone, both of which can be overridden in the language file
@return string
|
[
"Returns",
"the",
"locale",
"formatted",
"date",
"in",
"the",
"locale",
"s",
"timezone",
"both",
"of",
"which",
"can",
"be",
"overridden",
"in",
"the",
"language",
"file"
] |
bbf35cdf7f30199757da6bde009d6ccd700e9ccb
|
https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/models/Comment.php#L142-L169
|
234,511
|
oxygen-cms/core
|
src/Action/Factory/ActionFactory.php
|
ActionFactory.create
|
public function create(array $parameters, $controller = null) {
$parameters = $this->parseParameters($parameters, $controller);
$action = new Action(
$parameters['name'],
$parameters['pattern'],
$parameters['uses'],
$parameters['group']
);
$this->setProperties($action, $parameters);
return $action;
}
|
php
|
public function create(array $parameters, $controller = null) {
$parameters = $this->parseParameters($parameters, $controller);
$action = new Action(
$parameters['name'],
$parameters['pattern'],
$parameters['uses'],
$parameters['group']
);
$this->setProperties($action, $parameters);
return $action;
}
|
[
"public",
"function",
"create",
"(",
"array",
"$",
"parameters",
",",
"$",
"controller",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"parseParameters",
"(",
"$",
"parameters",
",",
"$",
"controller",
")",
";",
"$",
"action",
"=",
"new",
"Action",
"(",
"$",
"parameters",
"[",
"'name'",
"]",
",",
"$",
"parameters",
"[",
"'pattern'",
"]",
",",
"$",
"parameters",
"[",
"'uses'",
"]",
",",
"$",
"parameters",
"[",
"'group'",
"]",
")",
";",
"$",
"this",
"->",
"setProperties",
"(",
"$",
"action",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"action",
";",
"}"
] |
Creates a new Action using the passed parameters.
@param array $parameters Passed parameters
@param string $controller Default controller to use if none is provided
@return mixed
|
[
"Creates",
"a",
"new",
"Action",
"using",
"the",
"passed",
"parameters",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Factory/ActionFactory.php#L18-L31
|
234,512
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.assert
|
public static function assert($value, $name = 'value')
{
if (is_object($value)) {
throw new InvalidNotObjectException($name);
}
if (!is_string($name)) {
throw new InvalidStringException('name', $name);
}
if (empty(self::$validator)) {
self::$validator = new static;
}
self::$validator->name = $name;
self::$validator->value = $value;
return self::$validator;
}
|
php
|
public static function assert($value, $name = 'value')
{
if (is_object($value)) {
throw new InvalidNotObjectException($name);
}
if (!is_string($name)) {
throw new InvalidStringException('name', $name);
}
if (empty(self::$validator)) {
self::$validator = new static;
}
self::$validator->name = $name;
self::$validator->value = $value;
return self::$validator;
}
|
[
"public",
"static",
"function",
"assert",
"(",
"$",
"value",
",",
"$",
"name",
"=",
"'value'",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNotObjectException",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"validator",
")",
")",
"{",
"self",
"::",
"$",
"validator",
"=",
"new",
"static",
";",
"}",
"self",
"::",
"$",
"validator",
"->",
"name",
"=",
"$",
"name",
";",
"self",
"::",
"$",
"validator",
"->",
"value",
"=",
"$",
"value",
";",
"return",
"self",
"::",
"$",
"validator",
";",
"}"
] |
Creates validator instance for variable, first fail check will throw an exception
@param int|float|string|resource|array|null $value
@param string $name
@return static
@throws InvalidNotObjectException
@throws InvalidStringException
|
[
"Creates",
"validator",
"instance",
"for",
"variable",
"first",
"fail",
"check",
"will",
"throw",
"an",
"exception"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L68-L86
|
234,513
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.isArray
|
public function isArray()
{
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
return $this;
}
|
php
|
public function isArray()
{
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
return $this;
}
|
[
"public",
"function",
"isArray",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArrayException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value is array
@return $this
@throws InvalidArrayException
|
[
"Check",
"if",
"value",
"is",
"array"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L304-L311
|
234,514
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.hasKey
|
public function hasKey($key)
{
if (!is_string($key) && !is_int($key)) {
throw new InvalidIntOrStringException('key', $key);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (!array_key_exists($key, $this->value)) {
throw new ArrayKeyNotExistsException($this->name, $key);
}
return $this;
}
|
php
|
public function hasKey($key)
{
if (!is_string($key) && !is_int($key)) {
throw new InvalidIntOrStringException('key', $key);
}
if (!is_array($this->value)) {
throw new InvalidArrayException($this->name, $this->value);
}
if (!array_key_exists($key, $this->value)) {
throw new ArrayKeyNotExistsException($this->name, $key);
}
return $this;
}
|
[
"public",
"function",
"hasKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
"&&",
"!",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrStringException",
"(",
"'key'",
",",
"$",
"key",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArrayException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"ArrayKeyNotExistsException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if array key exists
@param string|int $key
@return $this
@throws ArrayKeyNotExistsException
@throws InvalidArrayException
@throws InvalidIntOrStringException
|
[
"Check",
"if",
"array",
"key",
"exists"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L322-L337
|
234,515
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.match
|
public function match($pattern)
{
if (!is_string($pattern)) {
throw new InvalidStringException('pattern', $pattern);
} elseif (empty($pattern)) {
throw new InvalidNotEmptyException('pattern');
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
}
// God please sorry for this @
$checkResult = @preg_match($pattern, $this->value);
if ((preg_last_error() !== PREG_NO_ERROR) || ($checkResult === false)) {
throw new InvalidRegExpPatternException('pattern', $pattern);
}
if ($checkResult === 0) {
throw new StringNotMatchRegExpException($this->name, $this->value, $pattern);
}
return $this;
}
|
php
|
public function match($pattern)
{
if (!is_string($pattern)) {
throw new InvalidStringException('pattern', $pattern);
} elseif (empty($pattern)) {
throw new InvalidNotEmptyException('pattern');
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
}
// God please sorry for this @
$checkResult = @preg_match($pattern, $this->value);
if ((preg_last_error() !== PREG_NO_ERROR) || ($checkResult === false)) {
throw new InvalidRegExpPatternException('pattern', $pattern);
}
if ($checkResult === 0) {
throw new StringNotMatchRegExpException($this->name, $this->value, $pattern);
}
return $this;
}
|
[
"public",
"function",
"match",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"'pattern'",
",",
"$",
"pattern",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"InvalidNotEmptyException",
"(",
"'pattern'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"// God please sorry for this @",
"$",
"checkResult",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"value",
")",
";",
"if",
"(",
"(",
"preg_last_error",
"(",
")",
"!==",
"PREG_NO_ERROR",
")",
"||",
"(",
"$",
"checkResult",
"===",
"false",
")",
")",
"{",
"throw",
"new",
"InvalidRegExpPatternException",
"(",
"'pattern'",
",",
"$",
"pattern",
")",
";",
"}",
"if",
"(",
"$",
"checkResult",
"===",
"0",
")",
"{",
"throw",
"new",
"StringNotMatchRegExpException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"$",
"pattern",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value match regexp pattern
@param string $pattern
@return $this
@throws InvalidNotEmptyException
@throws InvalidRegexpPatternException
@throws InvalidStringException
@throws StringNotMatchRegExpException
|
[
"Check",
"if",
"value",
"match",
"regexp",
"pattern"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L621-L645
|
234,516
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.glob
|
public function glob($pattern)
{
if (!is_string($pattern)) {
throw new InvalidStringException('pattern', $pattern);
} elseif (empty($pattern)) {
throw new InvalidNotEmptyException('pattern');
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (!fnmatch($pattern, $this->value)) {
throw new StringNotMatchGlobException($this->name, $this->value, $pattern);
}
return $this;
}
|
php
|
public function glob($pattern)
{
if (!is_string($pattern)) {
throw new InvalidStringException('pattern', $pattern);
} elseif (empty($pattern)) {
throw new InvalidNotEmptyException('pattern');
}
if (!is_string($this->value)) {
throw new InvalidStringException($this->name, $this->value);
} elseif (!fnmatch($pattern, $this->value)) {
throw new StringNotMatchGlobException($this->name, $this->value, $pattern);
}
return $this;
}
|
[
"public",
"function",
"glob",
"(",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"'pattern'",
",",
"$",
"pattern",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"pattern",
")",
")",
"{",
"throw",
"new",
"InvalidNotEmptyException",
"(",
"'pattern'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidStringException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"elseif",
"(",
"!",
"fnmatch",
"(",
"$",
"pattern",
",",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"StringNotMatchGlobException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"$",
"pattern",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value match glob pattern
@param string $pattern
@return $this
@throws InvalidNotEmptyException
@throws InvalidStringException
@throws StringNotMatchGlobException
|
[
"Check",
"if",
"value",
"match",
"glob",
"pattern"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L656-L671
|
234,517
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.negative
|
public function negative()
{
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value >= 0) {
throw new NumberNotNegativeException($this->name, $this->value);
}
return $this;
}
|
php
|
public function negative()
{
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value >= 0) {
throw new NumberNotNegativeException($this->name, $this->value);
}
return $this;
}
|
[
"public",
"function",
"negative",
"(",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"!",
"is_float",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"value",
">=",
"0",
")",
"{",
"throw",
"new",
"NumberNotNegativeException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value < 0
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotNegativeException
|
[
"Check",
"if",
"value",
"<",
"0"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L680-L689
|
234,518
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.positive
|
public function positive()
{
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= 0) {
throw new NumberNotPositiveException($this->name, $this->value);
}
return $this;
}
|
php
|
public function positive()
{
if (!is_int($this->value) && !is_float($this->value)) {
throw new InvalidIntOrFloatException($this->name, $this->value);
} elseif ($this->value <= 0) {
throw new NumberNotPositiveException($this->name, $this->value);
}
return $this;
}
|
[
"public",
"function",
"positive",
"(",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"!",
"is_float",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidIntOrFloatException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"value",
"<=",
"0",
")",
"{",
"throw",
"new",
"NumberNotPositiveException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value > 0
@return $this
@throws InvalidIntOrFloatException
@throws NumberNotPositiveException
|
[
"Check",
"if",
"value",
">",
"0"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L698-L707
|
234,519
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.isNull
|
public function isNull()
{
if (!is_null($this->value)) {
throw new InvalidNullException($this->name, $this->value);
}
return $this;
}
|
php
|
public function isNull()
{
if (!is_null($this->value)) {
throw new InvalidNullException($this->name, $this->value);
}
return $this;
}
|
[
"public",
"function",
"isNull",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNullException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check if value is null
@return $this
@throws InvalidNullException
|
[
"Check",
"if",
"value",
"is",
"null"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L757-L764
|
234,520
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.toFloat
|
public function toFloat()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
} elseif (!empty($this->value) && !is_numeric($this->value)) {
throw new InvalidNumericException($this->name, $this->value);
}
$this->value = (float) $this->value;
return $this;
}
|
php
|
public function toFloat()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
} elseif (!empty($this->value) && !is_numeric($this->value)) {
throw new InvalidNumericException($this->name, $this->value);
}
$this->value = (float) $this->value;
return $this;
}
|
[
"public",
"function",
"toFloat",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNotArrayException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNumericException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"(",
"float",
")",
"$",
"this",
"->",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Cast value to float. If it's not numeric - there will be fail cast
@return $this
@throws InvalidNotArrayException
@throws InvalidNumericException
|
[
"Cast",
"value",
"to",
"float",
".",
"If",
"it",
"s",
"not",
"numeric",
"-",
"there",
"will",
"be",
"fail",
"cast"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L848-L859
|
234,521
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.toInt
|
public function toInt()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
} elseif (!empty($this->value) && !is_numeric($this->value)) {
throw new InvalidNumericException($this->name, $this->value);
}
$this->value = (int) $this->value;
return $this;
}
|
php
|
public function toInt()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
} elseif (!empty($this->value) && !is_numeric($this->value)) {
throw new InvalidNumericException($this->name, $this->value);
}
$this->value = (int) $this->value;
return $this;
}
|
[
"public",
"function",
"toInt",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNotArrayException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNumericException",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
")",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Cast value to int. If it's not numeric - there will be fail cast
@return $this
@throws InvalidNotArrayException
@throws InvalidNumericException
|
[
"Cast",
"value",
"to",
"int",
".",
"If",
"it",
"s",
"not",
"numeric",
"-",
"there",
"will",
"be",
"fail",
"cast"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L868-L879
|
234,522
|
ko-ko-ko/php-assert
|
src/Assert.php
|
Assert.toString
|
public function toString()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
}
$this->value = (string) $this->value;
return $this;
}
|
php
|
public function toString()
{
if (is_array($this->value)) {
throw new InvalidNotArrayException($this->name);
}
$this->value = (string) $this->value;
return $this;
}
|
[
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidNotArrayException",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"$",
"this",
"->",
"value",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Cast value to string. If it's array - there will be fail cast
@return $this
@throws InvalidNotArrayException
|
[
"Cast",
"value",
"to",
"string",
".",
"If",
"it",
"s",
"array",
"-",
"there",
"will",
"be",
"fail",
"cast"
] |
e4968588fd3f42c95a763ca3c36cfb846b24ab81
|
https://github.com/ko-ko-ko/php-assert/blob/e4968588fd3f42c95a763ca3c36cfb846b24ab81/src/Assert.php#L887-L896
|
234,523
|
dave-redfern/laravel-doctrine-tenancy
|
src/Repositories/TenantAwareRepository.php
|
TenantAwareRepository.applySecurityModel
|
protected function applySecurityModel(QueryBuilder $qb, $alias)
{
$model = $this->tenant->getTenantSecurityModel();
$method = 'apply' . ucfirst($model) . 'SecurityModel';
if ( method_exists($this, $method) ) {
$this->$method($qb, $alias);
} else {
throw new \RuntimeException(
sprintf('Security model "%s" has not been implemented by "%s"', $model, $method)
);
}
}
|
php
|
protected function applySecurityModel(QueryBuilder $qb, $alias)
{
$model = $this->tenant->getTenantSecurityModel();
$method = 'apply' . ucfirst($model) . 'SecurityModel';
if ( method_exists($this, $method) ) {
$this->$method($qb, $alias);
} else {
throw new \RuntimeException(
sprintf('Security model "%s" has not been implemented by "%s"', $model, $method)
);
}
}
|
[
"protected",
"function",
"applySecurityModel",
"(",
"QueryBuilder",
"$",
"qb",
",",
"$",
"alias",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"tenant",
"->",
"getTenantSecurityModel",
"(",
")",
";",
"$",
"method",
"=",
"'apply'",
".",
"ucfirst",
"(",
"$",
"model",
")",
".",
"'SecurityModel'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"qb",
",",
"$",
"alias",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Security model \"%s\" has not been implemented by \"%s\"'",
",",
"$",
"model",
",",
"$",
"method",
")",
")",
";",
"}",
"}"
] |
Applies the rules for the selected Security Model
The security model name is capitalised, and then turned into a method prefixed with
apply and suffixed with SecurityModel e.g.: shared -> applySharedSecurityModel.
@param QueryBuilder $qb
@param string $alias
|
[
"Applies",
"the",
"rules",
"for",
"the",
"selected",
"Security",
"Model"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Repositories/TenantAwareRepository.php#L137-L149
|
234,524
|
txj123/zilf
|
src/Zilf/Cache/CacheManager.php
|
CacheManager.get
|
protected function get($name)
{
return isset($this->stores[$name]) ? $this->stores[$name] : $this->resolve($name);
}
|
php
|
protected function get($name)
{
return isset($this->stores[$name]) ? $this->stores[$name] : $this->resolve($name);
}
|
[
"protected",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"stores",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"stores",
"[",
"$",
"name",
"]",
":",
"$",
"this",
"->",
"resolve",
"(",
"$",
"name",
")",
";",
"}"
] |
Attempt to get the store from the local cache.
@param string $name
@return \Zilf\Cache\Repository
|
[
"Attempt",
"to",
"get",
"the",
"store",
"from",
"the",
"local",
"cache",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/CacheManager.php#L76-L79
|
234,525
|
oxygen-cms/core
|
src/Console/Command.php
|
Command.heading
|
public function heading($text) {
$this->info('');
$this->info('===================');
$this->info($text);
$this->info('===================');
$this->info('');
}
|
php
|
public function heading($text) {
$this->info('');
$this->info('===================');
$this->info($text);
$this->info('===================');
$this->info('');
}
|
[
"public",
"function",
"heading",
"(",
"$",
"text",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'==================='",
")",
";",
"$",
"this",
"->",
"info",
"(",
"$",
"text",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'==================='",
")",
";",
"$",
"this",
"->",
"info",
"(",
"''",
")",
";",
"}"
] |
Prints a heading.
@param string $text
|
[
"Prints",
"a",
"heading",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/Command.php#L14-L20
|
234,526
|
hfcorriez/pagon
|
app/src/Api/Api.php
|
Api.dump
|
protected function dump(array $data, $code = 200)
{
$this->output->status($code);
switch ($this->_format) {
case 'xml':
$this->output->xml($data, $this->_xml_option);
break;
case 'jsonp':
$this->output->jsonp($data, $this->_jsonp_callback);
break;
default:
$this->output->json($data);
}
$this->output->end();
}
|
php
|
protected function dump(array $data, $code = 200)
{
$this->output->status($code);
switch ($this->_format) {
case 'xml':
$this->output->xml($data, $this->_xml_option);
break;
case 'jsonp':
$this->output->jsonp($data, $this->_jsonp_callback);
break;
default:
$this->output->json($data);
}
$this->output->end();
}
|
[
"protected",
"function",
"dump",
"(",
"array",
"$",
"data",
",",
"$",
"code",
"=",
"200",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"status",
"(",
"$",
"code",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"_format",
")",
"{",
"case",
"'xml'",
":",
"$",
"this",
"->",
"output",
"->",
"xml",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"_xml_option",
")",
";",
"break",
";",
"case",
"'jsonp'",
":",
"$",
"this",
"->",
"output",
"->",
"jsonp",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"_jsonp_callback",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"output",
"->",
"json",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"end",
"(",
")",
";",
"}"
] |
Dump API data
@param array $data
@param int $code
|
[
"Dump",
"API",
"data"
] |
c847a59c4ce4876887c65d35880ded8bb559cc48
|
https://github.com/hfcorriez/pagon/blob/c847a59c4ce4876887c65d35880ded8bb559cc48/app/src/Api/Api.php#L64-L80
|
234,527
|
kharanenka/oc-pagination
|
src/Kharanenka/Helper/Pagination.php
|
Pagination.get
|
public static function get($iCurrentPage, $iTotalCount, $arSettings = []) {
if(!empty($arSettings) && isset($arSettings['button_list']) && !empty($arSettings['button_list'])) {
$arSettings['button_list'] = explode(',', $arSettings['button_list']);
}
return parent::get($iCurrentPage, $iTotalCount, $arSettings);
}
|
php
|
public static function get($iCurrentPage, $iTotalCount, $arSettings = []) {
if(!empty($arSettings) && isset($arSettings['button_list']) && !empty($arSettings['button_list'])) {
$arSettings['button_list'] = explode(',', $arSettings['button_list']);
}
return parent::get($iCurrentPage, $iTotalCount, $arSettings);
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"iCurrentPage",
",",
"$",
"iTotalCount",
",",
"$",
"arSettings",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"arSettings",
")",
"&&",
"isset",
"(",
"$",
"arSettings",
"[",
"'button_list'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"arSettings",
"[",
"'button_list'",
"]",
")",
")",
"{",
"$",
"arSettings",
"[",
"'button_list'",
"]",
"=",
"explode",
"(",
"','",
",",
"$",
"arSettings",
"[",
"'button_list'",
"]",
")",
";",
"}",
"return",
"parent",
"::",
"get",
"(",
"$",
"iCurrentPage",
",",
"$",
"iTotalCount",
",",
"$",
"arSettings",
")",
";",
"}"
] |
Get pagination elements
@param int $iCurrentPage - current page number
@param int $iTotalCount - total count elements
@param array $arSettings - settings array
@return array
|
[
"Get",
"pagination",
"elements"
] |
0a26015df60c7a3194dbdabe1f882efa287affd3
|
https://github.com/kharanenka/oc-pagination/blob/0a26015df60c7a3194dbdabe1f882efa287affd3/src/Kharanenka/Helper/Pagination.php#L261-L269
|
234,528
|
mikelgoig/laravel-spotify-wrapper
|
src/SpotifyWrapper.php
|
SpotifyWrapper.requestAccessToken
|
public function requestAccessToken()
{
try {
$this->session->requestAccessToken($_GET['code']);
return $this;
} catch (Exception $e) {
$this->redirectToSpotifyAuthorizeUrl();
}
}
|
php
|
public function requestAccessToken()
{
try {
$this->session->requestAccessToken($_GET['code']);
return $this;
} catch (Exception $e) {
$this->redirectToSpotifyAuthorizeUrl();
}
}
|
[
"public",
"function",
"requestAccessToken",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"session",
"->",
"requestAccessToken",
"(",
"$",
"_GET",
"[",
"'code'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"redirectToSpotifyAuthorizeUrl",
"(",
")",
";",
"}",
"}"
] |
Request an access token.
@return void
|
[
"Request",
"an",
"access",
"token",
"."
] |
0f93b561ec1a590c3568c47f901f5f7ac4e61cf1
|
https://github.com/mikelgoig/laravel-spotify-wrapper/blob/0f93b561ec1a590c3568c47f901f5f7ac4e61cf1/src/SpotifyWrapper.php#L68-L76
|
234,529
|
txj123/zilf
|
src/Zilf/Queue/InteractsWithQueue.php
|
InteractsWithQueue.fail
|
public function fail($exception = null)
{
if ($this->job) {
FailingJob::handle($this->job->getConnectionName(), $this->job, $exception);
}
}
|
php
|
public function fail($exception = null)
{
if ($this->job) {
FailingJob::handle($this->job->getConnectionName(), $this->job, $exception);
}
}
|
[
"public",
"function",
"fail",
"(",
"$",
"exception",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"job",
")",
"{",
"FailingJob",
"::",
"handle",
"(",
"$",
"this",
"->",
"job",
"->",
"getConnectionName",
"(",
")",
",",
"$",
"this",
"->",
"job",
",",
"$",
"exception",
")",
";",
"}",
"}"
] |
Fail the job from the queue.
@param \Throwable $exception
@return void
|
[
"Fail",
"the",
"job",
"from",
"the",
"queue",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Queue/InteractsWithQueue.php#L42-L47
|
234,530
|
kiwiz/esquery
|
src/Util.php
|
Util.escapeString
|
public static function escapeString($str, $allow_wildcards=false) {
$needles = [
'\\', '+', '-', '=', '&&', '||', '>', '<', '!', '(', ')',
'{', '}', '[', ']', '^', '"', '~', ':', '/', ' '
];
$replacements = [
'\\\\', '\\+', '\\-', '\\=', '\\&&', '\\||', '\\>', '\\<', '\\!', '\\(', '\\)',
'\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\:', '\\/', '\\ '
];
if(!$allow_wildcards) {
$needles = array_merge($needles, ['*', '?']);
$replacements = array_merge($replacements, ['\\*', '\\?']);
}
return str_replace($needles, $replacements, $str);
}
|
php
|
public static function escapeString($str, $allow_wildcards=false) {
$needles = [
'\\', '+', '-', '=', '&&', '||', '>', '<', '!', '(', ')',
'{', '}', '[', ']', '^', '"', '~', ':', '/', ' '
];
$replacements = [
'\\\\', '\\+', '\\-', '\\=', '\\&&', '\\||', '\\>', '\\<', '\\!', '\\(', '\\)',
'\\{', '\\}', '\\[', '\\]', '\\^', '\\"', '\\~', '\\:', '\\/', '\\ '
];
if(!$allow_wildcards) {
$needles = array_merge($needles, ['*', '?']);
$replacements = array_merge($replacements, ['\\*', '\\?']);
}
return str_replace($needles, $replacements, $str);
}
|
[
"public",
"static",
"function",
"escapeString",
"(",
"$",
"str",
",",
"$",
"allow_wildcards",
"=",
"false",
")",
"{",
"$",
"needles",
"=",
"[",
"'\\\\'",
",",
"'+'",
",",
"'-'",
",",
"'='",
",",
"'&&'",
",",
"'||'",
",",
"'>'",
",",
"'<'",
",",
"'!'",
",",
"'('",
",",
"')'",
",",
"'{'",
",",
"'}'",
",",
"'['",
",",
"']'",
",",
"'^'",
",",
"'\"'",
",",
"'~'",
",",
"':'",
",",
"'/'",
",",
"' '",
"]",
";",
"$",
"replacements",
"=",
"[",
"'\\\\\\\\'",
",",
"'\\\\+'",
",",
"'\\\\-'",
",",
"'\\\\='",
",",
"'\\\\&&'",
",",
"'\\\\||'",
",",
"'\\\\>'",
",",
"'\\\\<'",
",",
"'\\\\!'",
",",
"'\\\\('",
",",
"'\\\\)'",
",",
"'\\\\{'",
",",
"'\\\\}'",
",",
"'\\\\['",
",",
"'\\\\]'",
",",
"'\\\\^'",
",",
"'\\\\\"'",
",",
"'\\\\~'",
",",
"'\\\\:'",
",",
"'\\\\/'",
",",
"'\\\\ '",
"]",
";",
"if",
"(",
"!",
"$",
"allow_wildcards",
")",
"{",
"$",
"needles",
"=",
"array_merge",
"(",
"$",
"needles",
",",
"[",
"'*'",
",",
"'?'",
"]",
")",
";",
"$",
"replacements",
"=",
"array_merge",
"(",
"$",
"replacements",
",",
"[",
"'\\\\*'",
",",
"'\\\\?'",
"]",
")",
";",
"}",
"return",
"str_replace",
"(",
"$",
"needles",
",",
"$",
"replacements",
",",
"$",
"str",
")",
";",
"}"
] |
Escape special characters in a query.
|
[
"Escape",
"special",
"characters",
"in",
"a",
"query",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Util.php#L15-L29
|
234,531
|
kiwiz/esquery
|
src/Util.php
|
Util.escapeGroup
|
public static function escapeGroup($arr, $wildcard=false) {
return implode('', array_map(function($x) use ($wildcard) {
if(is_string($x)) {
if($wildcard) {
return Util::escapeString($x);
} else {
return '"' . str_replace('"', '\\"', $x) . '"';
}
} else if($x == Token::W_STAR) {
return '*';
} else if ($x == Token::W_QMARK) {
return '?';
}
}, $arr));
}
|
php
|
public static function escapeGroup($arr, $wildcard=false) {
return implode('', array_map(function($x) use ($wildcard) {
if(is_string($x)) {
if($wildcard) {
return Util::escapeString($x);
} else {
return '"' . str_replace('"', '\\"', $x) . '"';
}
} else if($x == Token::W_STAR) {
return '*';
} else if ($x == Token::W_QMARK) {
return '?';
}
}, $arr));
}
|
[
"public",
"static",
"function",
"escapeGroup",
"(",
"$",
"arr",
",",
"$",
"wildcard",
"=",
"false",
")",
"{",
"return",
"implode",
"(",
"''",
",",
"array_map",
"(",
"function",
"(",
"$",
"x",
")",
"use",
"(",
"$",
"wildcard",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"x",
")",
")",
"{",
"if",
"(",
"$",
"wildcard",
")",
"{",
"return",
"Util",
"::",
"escapeString",
"(",
"$",
"x",
")",
";",
"}",
"else",
"{",
"return",
"'\"'",
".",
"str_replace",
"(",
"'\"'",
",",
"'\\\\\"'",
",",
"$",
"x",
")",
".",
"'\"'",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"x",
"==",
"Token",
"::",
"W_STAR",
")",
"{",
"return",
"'*'",
";",
"}",
"else",
"if",
"(",
"$",
"x",
"==",
"Token",
"::",
"W_QMARK",
")",
"{",
"return",
"'?'",
";",
"}",
"}",
",",
"$",
"arr",
")",
")",
";",
"}"
] |
Escape special characters in an array of query chunks.
|
[
"Escape",
"special",
"characters",
"in",
"an",
"array",
"of",
"query",
"chunks",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Util.php#L32-L46
|
234,532
|
kiwiz/esquery
|
src/Util.php
|
Util.combine
|
public static function combine($first, $rest, $idx) {
$ret = [];
$ret[] = $first;
foreach($rest as $val) {
$ret[] = $val[$idx];
}
return $ret;
}
|
php
|
public static function combine($first, $rest, $idx) {
$ret = [];
$ret[] = $first;
foreach($rest as $val) {
$ret[] = $val[$idx];
}
return $ret;
}
|
[
"public",
"static",
"function",
"combine",
"(",
"$",
"first",
",",
"$",
"rest",
",",
"$",
"idx",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"ret",
"[",
"]",
"=",
"$",
"first",
";",
"foreach",
"(",
"$",
"rest",
"as",
"$",
"val",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"val",
"[",
"$",
"idx",
"]",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Parser helper. Flatten results into an array.
|
[
"Parser",
"helper",
".",
"Flatten",
"results",
"into",
"an",
"array",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Util.php#L49-L57
|
234,533
|
kiwiz/esquery
|
src/Util.php
|
Util.assoc
|
public static function assoc($first, $rest, $idx) {
$ret = [];
$ret[$first[0]] = $first[1];
foreach($rest as $val) {
$ret[$val[$idx][0]] = $val[$idx][1];
}
return $ret;
}
|
php
|
public static function assoc($first, $rest, $idx) {
$ret = [];
$ret[$first[0]] = $first[1];
foreach($rest as $val) {
$ret[$val[$idx][0]] = $val[$idx][1];
}
return $ret;
}
|
[
"public",
"static",
"function",
"assoc",
"(",
"$",
"first",
",",
"$",
"rest",
",",
"$",
"idx",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"ret",
"[",
"$",
"first",
"[",
"0",
"]",
"]",
"=",
"$",
"first",
"[",
"1",
"]",
";",
"foreach",
"(",
"$",
"rest",
"as",
"$",
"val",
")",
"{",
"$",
"ret",
"[",
"$",
"val",
"[",
"$",
"idx",
"]",
"[",
"0",
"]",
"]",
"=",
"$",
"val",
"[",
"$",
"idx",
"]",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Parser helper. Turn results into an associative array.
|
[
"Parser",
"helper",
".",
"Turn",
"results",
"into",
"an",
"associative",
"array",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Util.php#L60-L68
|
234,534
|
kiwiz/esquery
|
src/Util.php
|
Util.generateDateIndices
|
public static function generateDateIndices($format, $interval, $from_ts, $to_ts) {
$fmt_arr = [];
$escaped = false;
foreach(str_split($format) as $chr) {
switch($chr) {
case '[':
$escaped = true;
break;
case ']':
$escaped = false;
break;
default:
$fmt_arr[] = $escaped ? "\\$chr":$chr;
break;
}
}
$fmt_str = implode('', $fmt_arr);
$ret = [];
$current = new \DateTime("@$from_ts");
$to = new \DateTime("@$to_ts");
$interval_map = [
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
];
$interval_str = Util::get($interval_map, $interval, 'day');
// Zero out the time component.
$current->setTime($interval == 'h' ? $current->format('H'):0, 0);
while ($current <= $to) {
$ret[] = $current->format($fmt_str);
$current = $current->modify("+1$interval_str");
}
return $ret;
}
|
php
|
public static function generateDateIndices($format, $interval, $from_ts, $to_ts) {
$fmt_arr = [];
$escaped = false;
foreach(str_split($format) as $chr) {
switch($chr) {
case '[':
$escaped = true;
break;
case ']':
$escaped = false;
break;
default:
$fmt_arr[] = $escaped ? "\\$chr":$chr;
break;
}
}
$fmt_str = implode('', $fmt_arr);
$ret = [];
$current = new \DateTime("@$from_ts");
$to = new \DateTime("@$to_ts");
$interval_map = [
'y' => 'year',
'm' => 'month',
'w' => 'week',
'd' => 'day',
'h' => 'hour',
];
$interval_str = Util::get($interval_map, $interval, 'day');
// Zero out the time component.
$current->setTime($interval == 'h' ? $current->format('H'):0, 0);
while ($current <= $to) {
$ret[] = $current->format($fmt_str);
$current = $current->modify("+1$interval_str");
}
return $ret;
}
|
[
"public",
"static",
"function",
"generateDateIndices",
"(",
"$",
"format",
",",
"$",
"interval",
",",
"$",
"from_ts",
",",
"$",
"to_ts",
")",
"{",
"$",
"fmt_arr",
"=",
"[",
"]",
";",
"$",
"escaped",
"=",
"false",
";",
"foreach",
"(",
"str_split",
"(",
"$",
"format",
")",
"as",
"$",
"chr",
")",
"{",
"switch",
"(",
"$",
"chr",
")",
"{",
"case",
"'['",
":",
"$",
"escaped",
"=",
"true",
";",
"break",
";",
"case",
"']'",
":",
"$",
"escaped",
"=",
"false",
";",
"break",
";",
"default",
":",
"$",
"fmt_arr",
"[",
"]",
"=",
"$",
"escaped",
"?",
"\"\\\\$chr\"",
":",
"$",
"chr",
";",
"break",
";",
"}",
"}",
"$",
"fmt_str",
"=",
"implode",
"(",
"''",
",",
"$",
"fmt_arr",
")",
";",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"current",
"=",
"new",
"\\",
"DateTime",
"(",
"\"@$from_ts\"",
")",
";",
"$",
"to",
"=",
"new",
"\\",
"DateTime",
"(",
"\"@$to_ts\"",
")",
";",
"$",
"interval_map",
"=",
"[",
"'y'",
"=>",
"'year'",
",",
"'m'",
"=>",
"'month'",
",",
"'w'",
"=>",
"'week'",
",",
"'d'",
"=>",
"'day'",
",",
"'h'",
"=>",
"'hour'",
",",
"]",
";",
"$",
"interval_str",
"=",
"Util",
"::",
"get",
"(",
"$",
"interval_map",
",",
"$",
"interval",
",",
"'day'",
")",
";",
"// Zero out the time component.",
"$",
"current",
"->",
"setTime",
"(",
"$",
"interval",
"==",
"'h'",
"?",
"$",
"current",
"->",
"format",
"(",
"'H'",
")",
":",
"0",
",",
"0",
")",
";",
"while",
"(",
"$",
"current",
"<=",
"$",
"to",
")",
"{",
"$",
"ret",
"[",
"]",
"=",
"$",
"current",
"->",
"format",
"(",
"$",
"fmt_str",
")",
";",
"$",
"current",
"=",
"$",
"current",
"->",
"modify",
"(",
"\"+1$interval_str\"",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Generate a list of date-based indices.
@param string $format The index format.
@param string $interval The interval size (h,d,w,m,y).
@param int $from_ts Start timestamp.
@param int $to_ts End timestamp.
@return string[] List of indices.
|
[
"Generate",
"a",
"list",
"of",
"date",
"-",
"based",
"indices",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Util.php#L78-L119
|
234,535
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Export/Builder.php
|
Builder.export
|
public function export($type)
{
$format = sprintf('\\KraftHaus\\Bauhaus\\Export\\Format\\%sFormat', ucfirst($type));
return (new $format)
->setListBuilder($this->getListBuilder())
->export();
}
|
php
|
public function export($type)
{
$format = sprintf('\\KraftHaus\\Bauhaus\\Export\\Format\\%sFormat', ucfirst($type));
return (new $format)
->setListBuilder($this->getListBuilder())
->export();
}
|
[
"public",
"function",
"export",
"(",
"$",
"type",
")",
"{",
"$",
"format",
"=",
"sprintf",
"(",
"'\\\\KraftHaus\\\\Bauhaus\\\\Export\\\\Format\\\\%sFormat'",
",",
"ucfirst",
"(",
"$",
"type",
")",
")",
";",
"return",
"(",
"new",
"$",
"format",
")",
"->",
"setListBuilder",
"(",
"$",
"this",
"->",
"getListBuilder",
"(",
")",
")",
"->",
"export",
"(",
")",
";",
"}"
] |
Create a new export based on the ListBuilder output.
@param string $type
@access public
@return mixed
|
[
"Create",
"a",
"new",
"export",
"based",
"on",
"the",
"ListBuilder",
"output",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Builder.php#L60-L66
|
234,536
|
netzmacht/contao-icon-wizard
|
src/IconWidget.php
|
IconWidget.validator
|
protected function validator($value)
{
$value = parent::validator($value);
if ($this->hasErrors()) {
return null;
} elseif ($value == '') {
if ($this->mandatory) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
}
} elseif (!$this->iconExists($value)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['iconNotFound'], $this->strLabel));
}
return $value;
}
|
php
|
protected function validator($value)
{
$value = parent::validator($value);
if ($this->hasErrors()) {
return null;
} elseif ($value == '') {
if ($this->mandatory) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['mandatory'], $this->strLabel));
}
} elseif (!$this->iconExists($value)) {
$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['iconNotFound'], $this->strLabel));
}
return $value;
}
|
[
"protected",
"function",
"validator",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"parent",
"::",
"validator",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"$",
"value",
"==",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mandatory",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'ERR'",
"]",
"[",
"'mandatory'",
"]",
",",
"$",
"this",
"->",
"strLabel",
")",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"iconExists",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"sprintf",
"(",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'ERR'",
"]",
"[",
"'iconNotFound'",
"]",
",",
"$",
"this",
"->",
"strLabel",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Call the validator.
@param mixed $value The value.
@return mixed
@SuppressWarnings(PHPMD.Superglobals)
|
[
"Call",
"the",
"validator",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/IconWidget.php#L121-L136
|
234,537
|
netzmacht/contao-icon-wizard
|
src/IconWidget.php
|
IconWidget.iconExists
|
protected function iconExists($icon)
{
foreach ($this->icons as $group) {
foreach ($group as $entry) {
if (!is_array($entry)) {
continue;
}
if ($entry['value'] === $icon) {
return true;
}
}
}
return false;
}
|
php
|
protected function iconExists($icon)
{
foreach ($this->icons as $group) {
foreach ($group as $entry) {
if (!is_array($entry)) {
continue;
}
if ($entry['value'] === $icon) {
return true;
}
}
}
return false;
}
|
[
"protected",
"function",
"iconExists",
"(",
"$",
"icon",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"icons",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"group",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"entry",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"entry",
"[",
"'value'",
"]",
"===",
"$",
"icon",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if icon exists.
@param string $icon The icon name.
@return bool
|
[
"Check",
"if",
"icon",
"exists",
"."
] |
d0b5dba08d8167740f5828d0ee49b11f3eb0b946
|
https://github.com/netzmacht/contao-icon-wizard/blob/d0b5dba08d8167740f5828d0ee49b11f3eb0b946/src/IconWidget.php#L186-L201
|
234,538
|
ivopetkov/lock
|
src/Lock.php
|
Lock.acquire
|
static public function acquire($key, $options = [])
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
$timeout = isset($options['timeout']) ? (float) $options['timeout'] : self::$defaultLockTimeout;
$retryInterval = 0.5;
$maxRetriesCount = floor($timeout / $retryInterval);
$lock = function() use ($keyMD5) {
if (!isset(self::$data[$keyMD5])) {
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
$dir = self::getLocksDir();
if (!is_dir($dir)) {
try {
mkdir($dir, 0777, true);
} catch (\Exception $e) {
if ($e->getMessage() !== 'mkdir(): File exists') { // The directory may be just created in other process.
restore_error_handler();
return false;
}
}
}
$filename = $dir . $keyMD5 . '.lock';
try {
$filePointer = fopen($filename, "w");
if ($filePointer !== false && flock($filePointer, LOCK_EX | LOCK_NB) !== false) {
self::$data[$keyMD5] = $filePointer;
restore_error_handler();
return true;
}
} catch (\Exception $e) {
}
restore_error_handler();
return false;
}
return false;
};
$startTime = microtime(true);
for ($i = 0; $i < $maxRetriesCount + 1; $i++) {
if ($lock()) {
return;
}
if (microtime(true) - $startTime > $timeout) {
break;
}
usleep($retryInterval * 1000000);
}
throw new \Exception('Cannot acquire lock for "' . $key . '"');
}
|
php
|
static public function acquire($key, $options = [])
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
$timeout = isset($options['timeout']) ? (float) $options['timeout'] : self::$defaultLockTimeout;
$retryInterval = 0.5;
$maxRetriesCount = floor($timeout / $retryInterval);
$lock = function() use ($keyMD5) {
if (!isset(self::$data[$keyMD5])) {
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
$dir = self::getLocksDir();
if (!is_dir($dir)) {
try {
mkdir($dir, 0777, true);
} catch (\Exception $e) {
if ($e->getMessage() !== 'mkdir(): File exists') { // The directory may be just created in other process.
restore_error_handler();
return false;
}
}
}
$filename = $dir . $keyMD5 . '.lock';
try {
$filePointer = fopen($filename, "w");
if ($filePointer !== false && flock($filePointer, LOCK_EX | LOCK_NB) !== false) {
self::$data[$keyMD5] = $filePointer;
restore_error_handler();
return true;
}
} catch (\Exception $e) {
}
restore_error_handler();
return false;
}
return false;
};
$startTime = microtime(true);
for ($i = 0; $i < $maxRetriesCount + 1; $i++) {
if ($lock()) {
return;
}
if (microtime(true) - $startTime > $timeout) {
break;
}
usleep($retryInterval * 1000000);
}
throw new \Exception('Cannot acquire lock for "' . $key . '"');
}
|
[
"static",
"public",
"function",
"acquire",
"(",
"$",
"key",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"keyMD5",
"=",
"md5",
"(",
"self",
"::",
"$",
"keyPrefix",
".",
"serialize",
"(",
"$",
"key",
")",
")",
";",
"$",
"timeout",
"=",
"isset",
"(",
"$",
"options",
"[",
"'timeout'",
"]",
")",
"?",
"(",
"float",
")",
"$",
"options",
"[",
"'timeout'",
"]",
":",
"self",
"::",
"$",
"defaultLockTimeout",
";",
"$",
"retryInterval",
"=",
"0.5",
";",
"$",
"maxRetriesCount",
"=",
"floor",
"(",
"$",
"timeout",
"/",
"$",
"retryInterval",
")",
";",
"$",
"lock",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"keyMD5",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
")",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"errstr",
")",
";",
"}",
")",
";",
"$",
"dir",
"=",
"self",
"::",
"getLocksDir",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"try",
"{",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
"!==",
"'mkdir(): File exists'",
")",
"{",
"// The directory may be just created in other process.",
"restore_error_handler",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"$",
"filename",
"=",
"$",
"dir",
".",
"$",
"keyMD5",
".",
"'.lock'",
";",
"try",
"{",
"$",
"filePointer",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"w\"",
")",
";",
"if",
"(",
"$",
"filePointer",
"!==",
"false",
"&&",
"flock",
"(",
"$",
"filePointer",
",",
"LOCK_EX",
"|",
"LOCK_NB",
")",
"!==",
"false",
")",
"{",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
"=",
"$",
"filePointer",
";",
"restore_error_handler",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"restore_error_handler",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}",
";",
"$",
"startTime",
"=",
"microtime",
"(",
"true",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"maxRetriesCount",
"+",
"1",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"lock",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"startTime",
">",
"$",
"timeout",
")",
"{",
"break",
";",
"}",
"usleep",
"(",
"$",
"retryInterval",
"*",
"1000000",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot acquire lock for \"'",
".",
"$",
"key",
".",
"'\"'",
")",
";",
"}"
] |
Acquires a new lock for the key specified.
@param mixed $key The key of the lock.
@param array $options Lock options. Available values:
- timeout - A time (in seconds) to retry acquiring the lock.
@throws \Exception
|
[
"Acquires",
"a",
"new",
"lock",
"for",
"the",
"key",
"specified",
"."
] |
8b2a5f6dd3f1431c643d4eda2f647141a8811b50
|
https://github.com/ivopetkov/lock/blob/8b2a5f6dd3f1431c643d4eda2f647141a8811b50/src/Lock.php#L91-L140
|
234,539
|
ivopetkov/lock
|
src/Lock.php
|
Lock.exists
|
static public function exists($key)
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
$dir = self::getLocksDir();
if (!is_dir($dir)) {
return false;
}
$filename = $dir . $keyMD5 . '.lock';
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
try {
$filePointer = fopen($filename, "w");
if ($filePointer !== false) {
$wouldBlock = null;
if (flock($filePointer, LOCK_EX | LOCK_NB, $wouldBlock)) {
restore_error_handler();
return false;
} else {
restore_error_handler();
return $wouldBlock === 1;
}
}
} catch (\Exception $e) {
}
restore_error_handler();
throw new \Exception('Cannot check if lock named "' . $key . '" exists.');
}
|
php
|
static public function exists($key)
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
$dir = self::getLocksDir();
if (!is_dir($dir)) {
return false;
}
$filename = $dir . $keyMD5 . '.lock';
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
try {
$filePointer = fopen($filename, "w");
if ($filePointer !== false) {
$wouldBlock = null;
if (flock($filePointer, LOCK_EX | LOCK_NB, $wouldBlock)) {
restore_error_handler();
return false;
} else {
restore_error_handler();
return $wouldBlock === 1;
}
}
} catch (\Exception $e) {
}
restore_error_handler();
throw new \Exception('Cannot check if lock named "' . $key . '" exists.');
}
|
[
"static",
"public",
"function",
"exists",
"(",
"$",
"key",
")",
"{",
"$",
"keyMD5",
"=",
"md5",
"(",
"self",
"::",
"$",
"keyPrefix",
".",
"serialize",
"(",
"$",
"key",
")",
")",
";",
"$",
"dir",
"=",
"self",
"::",
"getLocksDir",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"filename",
"=",
"$",
"dir",
".",
"$",
"keyMD5",
".",
"'.lock'",
";",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"errstr",
")",
";",
"}",
")",
";",
"try",
"{",
"$",
"filePointer",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"w\"",
")",
";",
"if",
"(",
"$",
"filePointer",
"!==",
"false",
")",
"{",
"$",
"wouldBlock",
"=",
"null",
";",
"if",
"(",
"flock",
"(",
"$",
"filePointer",
",",
"LOCK_EX",
"|",
"LOCK_NB",
",",
"$",
"wouldBlock",
")",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"restore_error_handler",
"(",
")",
";",
"return",
"$",
"wouldBlock",
"===",
"1",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot check if lock named \"'",
".",
"$",
"key",
".",
"'\" exists.'",
")",
";",
"}"
] |
Checks if a lock exists.
@param mixed $key The key of the lock.
@throws \Exception
@return boolean Returns TRUE if the lock exists, FALSE otherwise.
|
[
"Checks",
"if",
"a",
"lock",
"exists",
"."
] |
8b2a5f6dd3f1431c643d4eda2f647141a8811b50
|
https://github.com/ivopetkov/lock/blob/8b2a5f6dd3f1431c643d4eda2f647141a8811b50/src/Lock.php#L149-L177
|
234,540
|
ivopetkov/lock
|
src/Lock.php
|
Lock.release
|
static public function release($key)
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
if (!isset(self::$data[$keyMD5])) {
throw new \Exception('A lock name "' . $key . '" does not exists in current process!');
}
$dir = self::getLocksDir();
if (!is_dir($dir)) {
return;
}
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
try {
if (flock(self::$data[$keyMD5], LOCK_UN) && fclose(self::$data[$keyMD5])) {
try {
$filename = $dir . $keyMD5 . '.lock';
$tempFilename = $filename . '.' . md5(uniqid() . rand(0, 999999));
$renameResult = rename($filename, $tempFilename);
if ($renameResult) {
unlink($tempFilename);
}
} catch (\Exception $e) {
// Don't care whether the rename is successful
}
unset(self::$data[$keyMD5]);
restore_error_handler();
return;
}
} catch (\Exception $e) {
restore_error_handler();
throw new \Exception('Cannot release the lock named "' . $key . '". Reason: ' . $e->getMessage());
}
restore_error_handler();
throw new \Exception('Cannot release the lock named "' . $key . '"');
}
|
php
|
static public function release($key)
{
$keyMD5 = md5(self::$keyPrefix . serialize($key));
if (!isset(self::$data[$keyMD5])) {
throw new \Exception('A lock name "' . $key . '" does not exists in current process!');
}
$dir = self::getLocksDir();
if (!is_dir($dir)) {
return;
}
set_error_handler(function($errno, $errstr) {
throw new \Exception($errstr);
});
try {
if (flock(self::$data[$keyMD5], LOCK_UN) && fclose(self::$data[$keyMD5])) {
try {
$filename = $dir . $keyMD5 . '.lock';
$tempFilename = $filename . '.' . md5(uniqid() . rand(0, 999999));
$renameResult = rename($filename, $tempFilename);
if ($renameResult) {
unlink($tempFilename);
}
} catch (\Exception $e) {
// Don't care whether the rename is successful
}
unset(self::$data[$keyMD5]);
restore_error_handler();
return;
}
} catch (\Exception $e) {
restore_error_handler();
throw new \Exception('Cannot release the lock named "' . $key . '". Reason: ' . $e->getMessage());
}
restore_error_handler();
throw new \Exception('Cannot release the lock named "' . $key . '"');
}
|
[
"static",
"public",
"function",
"release",
"(",
"$",
"key",
")",
"{",
"$",
"keyMD5",
"=",
"md5",
"(",
"self",
"::",
"$",
"keyPrefix",
".",
"serialize",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'A lock name \"'",
".",
"$",
"key",
".",
"'\" does not exists in current process!'",
")",
";",
"}",
"$",
"dir",
"=",
"self",
"::",
"getLocksDir",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"return",
";",
"}",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"errstr",
")",
";",
"}",
")",
";",
"try",
"{",
"if",
"(",
"flock",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
",",
"LOCK_UN",
")",
"&&",
"fclose",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
")",
")",
"{",
"try",
"{",
"$",
"filename",
"=",
"$",
"dir",
".",
"$",
"keyMD5",
".",
"'.lock'",
";",
"$",
"tempFilename",
"=",
"$",
"filename",
".",
"'.'",
".",
"md5",
"(",
"uniqid",
"(",
")",
".",
"rand",
"(",
"0",
",",
"999999",
")",
")",
";",
"$",
"renameResult",
"=",
"rename",
"(",
"$",
"filename",
",",
"$",
"tempFilename",
")",
";",
"if",
"(",
"$",
"renameResult",
")",
"{",
"unlink",
"(",
"$",
"tempFilename",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Don't care whether the rename is successful",
"}",
"unset",
"(",
"self",
"::",
"$",
"data",
"[",
"$",
"keyMD5",
"]",
")",
";",
"restore_error_handler",
"(",
")",
";",
"return",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot release the lock named \"'",
".",
"$",
"key",
".",
"'\". Reason: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cannot release the lock named \"'",
".",
"$",
"key",
".",
"'\"'",
")",
";",
"}"
] |
Releases a lock.
@param mixed $key The key of the lock.
@throws \Exception
|
[
"Releases",
"a",
"lock",
"."
] |
8b2a5f6dd3f1431c643d4eda2f647141a8811b50
|
https://github.com/ivopetkov/lock/blob/8b2a5f6dd3f1431c643d4eda2f647141a8811b50/src/Lock.php#L185-L220
|
234,541
|
czukowski/markdown-toc
|
classes/TOCTrait.php
|
TOCTrait.findHeadlines
|
protected function findHeadlines($markdown, $fromLevel = 1, $toLevel = 6) {
$headlines = [];
foreach ($this->parseBlocks($this->splitLines($markdown)) as $block) {
if ($this->isItemOfType($block, 'headline') && isset($block['level'])
&& $block['level'] >= $fromLevel && $block['level'] <= $toLevel
) {
$headlines[] = $block;
}
}
return $headlines;
}
|
php
|
protected function findHeadlines($markdown, $fromLevel = 1, $toLevel = 6) {
$headlines = [];
foreach ($this->parseBlocks($this->splitLines($markdown)) as $block) {
if ($this->isItemOfType($block, 'headline') && isset($block['level'])
&& $block['level'] >= $fromLevel && $block['level'] <= $toLevel
) {
$headlines[] = $block;
}
}
return $headlines;
}
|
[
"protected",
"function",
"findHeadlines",
"(",
"$",
"markdown",
",",
"$",
"fromLevel",
"=",
"1",
",",
"$",
"toLevel",
"=",
"6",
")",
"{",
"$",
"headlines",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parseBlocks",
"(",
"$",
"this",
"->",
"splitLines",
"(",
"$",
"markdown",
")",
")",
"as",
"$",
"block",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isItemOfType",
"(",
"$",
"block",
",",
"'headline'",
")",
"&&",
"isset",
"(",
"$",
"block",
"[",
"'level'",
"]",
")",
"&&",
"$",
"block",
"[",
"'level'",
"]",
">=",
"$",
"fromLevel",
"&&",
"$",
"block",
"[",
"'level'",
"]",
"<=",
"$",
"toLevel",
")",
"{",
"$",
"headlines",
"[",
"]",
"=",
"$",
"block",
";",
"}",
"}",
"return",
"$",
"headlines",
";",
"}"
] |
Finds headlines in a markdown content.
@param string $markdown source markdown.
@param integer $fromLevel find headlines starting with this level
@param integer $toLevel find headlines up to this level
@return array
|
[
"Finds",
"headlines",
"in",
"a",
"markdown",
"content",
"."
] |
eb1682acf9515afa19ee710666011937dcb4a2fc
|
https://github.com/czukowski/markdown-toc/blob/eb1682acf9515afa19ee710666011937dcb4a2fc/classes/TOCTrait.php#L58-L68
|
234,542
|
czukowski/markdown-toc
|
classes/TOCTrait.php
|
TOCTrait.toAscii
|
protected static function toAscii($s) {
static $transliterator = NULL;
if ($transliterator === NULL && class_exists('Transliterator', FALSE)) {
$transliterator = \Transliterator::create('Any-Latin; Latin-ASCII');
}
$s = preg_replace('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u', '', $s);
$s = strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06");
$s = str_replace(
["\xE2\x80\x9E", "\xE2\x80\x9C", "\xE2\x80\x9D", "\xE2\x80\x9A", "\xE2\x80\x98", "\xE2\x80\x99", "\xC2\xB0"],
["\x03", "\x03", "\x03", "\x02", "\x02", "\x02", "\x04"], $s
);
if ($transliterator !== NULL) {
$s = $transliterator->transliterate($s);
}
if (ICONV_IMPL === 'glibc') {
$s = str_replace(
["\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"],
['>>', '<<', '...', 'TM', '(c)', '(R)'], $s
);
$s = @iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); // intentionally @
$s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e"
."\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
."\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
."\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe"
."\x96\xa0\x8b\x97\x9b\xa6\xad\xb7",
'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.');
$s = preg_replace('#[^\x00-\x7F]++#', '', $s);
} else {
$s = @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); // intentionally @
}
$s = str_replace(['`', "'", '"', '^', '~', '?'], '', $s);
return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?');
}
|
php
|
protected static function toAscii($s) {
static $transliterator = NULL;
if ($transliterator === NULL && class_exists('Transliterator', FALSE)) {
$transliterator = \Transliterator::create('Any-Latin; Latin-ASCII');
}
$s = preg_replace('#[^\x09\x0A\x0D\x20-\x7E\xA0-\x{2FF}\x{370}-\x{10FFFF}]#u', '', $s);
$s = strtr($s, '`\'"^~?', "\x01\x02\x03\x04\x05\x06");
$s = str_replace(
["\xE2\x80\x9E", "\xE2\x80\x9C", "\xE2\x80\x9D", "\xE2\x80\x9A", "\xE2\x80\x98", "\xE2\x80\x99", "\xC2\xB0"],
["\x03", "\x03", "\x03", "\x02", "\x02", "\x02", "\x04"], $s
);
if ($transliterator !== NULL) {
$s = $transliterator->transliterate($s);
}
if (ICONV_IMPL === 'glibc') {
$s = str_replace(
["\xC2\xBB", "\xC2\xAB", "\xE2\x80\xA6", "\xE2\x84\xA2", "\xC2\xA9", "\xC2\xAE"],
['>>', '<<', '...', 'TM', '(c)', '(R)'], $s
);
$s = @iconv('UTF-8', 'WINDOWS-1250//TRANSLIT//IGNORE', $s); // intentionally @
$s = strtr($s, "\xa5\xa3\xbc\x8c\xa7\x8a\xaa\x8d\x8f\x8e\xaf\xb9\xb3\xbe\x9c\x9a\xba\x9d\x9f\x9e"
."\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
."\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8"
."\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf8\xf9\xfa\xfb\xfc\xfd\xfe"
."\x96\xa0\x8b\x97\x9b\xa6\xad\xb7",
'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.');
$s = preg_replace('#[^\x00-\x7F]++#', '', $s);
} else {
$s = @iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $s); // intentionally @
}
$s = str_replace(['`', "'", '"', '^', '~', '?'], '', $s);
return strtr($s, "\x01\x02\x03\x04\x05\x06", '`\'"^~?');
}
|
[
"protected",
"static",
"function",
"toAscii",
"(",
"$",
"s",
")",
"{",
"static",
"$",
"transliterator",
"=",
"NULL",
";",
"if",
"(",
"$",
"transliterator",
"===",
"NULL",
"&&",
"class_exists",
"(",
"'Transliterator'",
",",
"FALSE",
")",
")",
"{",
"$",
"transliterator",
"=",
"\\",
"Transliterator",
"::",
"create",
"(",
"'Any-Latin; Latin-ASCII'",
")",
";",
"}",
"$",
"s",
"=",
"preg_replace",
"(",
"'#[^\\x09\\x0A\\x0D\\x20-\\x7E\\xA0-\\x{2FF}\\x{370}-\\x{10FFFF}]#u'",
",",
"''",
",",
"$",
"s",
")",
";",
"$",
"s",
"=",
"strtr",
"(",
"$",
"s",
",",
"'`\\'\"^~?'",
",",
"\"\\x01\\x02\\x03\\x04\\x05\\x06\"",
")",
";",
"$",
"s",
"=",
"str_replace",
"(",
"[",
"\"\\xE2\\x80\\x9E\"",
",",
"\"\\xE2\\x80\\x9C\"",
",",
"\"\\xE2\\x80\\x9D\"",
",",
"\"\\xE2\\x80\\x9A\"",
",",
"\"\\xE2\\x80\\x98\"",
",",
"\"\\xE2\\x80\\x99\"",
",",
"\"\\xC2\\xB0\"",
"]",
",",
"[",
"\"\\x03\"",
",",
"\"\\x03\"",
",",
"\"\\x03\"",
",",
"\"\\x02\"",
",",
"\"\\x02\"",
",",
"\"\\x02\"",
",",
"\"\\x04\"",
"]",
",",
"$",
"s",
")",
";",
"if",
"(",
"$",
"transliterator",
"!==",
"NULL",
")",
"{",
"$",
"s",
"=",
"$",
"transliterator",
"->",
"transliterate",
"(",
"$",
"s",
")",
";",
"}",
"if",
"(",
"ICONV_IMPL",
"===",
"'glibc'",
")",
"{",
"$",
"s",
"=",
"str_replace",
"(",
"[",
"\"\\xC2\\xBB\"",
",",
"\"\\xC2\\xAB\"",
",",
"\"\\xE2\\x80\\xA6\"",
",",
"\"\\xE2\\x84\\xA2\"",
",",
"\"\\xC2\\xA9\"",
",",
"\"\\xC2\\xAE\"",
"]",
",",
"[",
"'>>'",
",",
"'<<'",
",",
"'...'",
",",
"'TM'",
",",
"'(c)'",
",",
"'(R)'",
"]",
",",
"$",
"s",
")",
";",
"$",
"s",
"=",
"@",
"iconv",
"(",
"'UTF-8'",
",",
"'WINDOWS-1250//TRANSLIT//IGNORE'",
",",
"$",
"s",
")",
";",
"// intentionally @",
"$",
"s",
"=",
"strtr",
"(",
"$",
"s",
",",
"\"\\xa5\\xa3\\xbc\\x8c\\xa7\\x8a\\xaa\\x8d\\x8f\\x8e\\xaf\\xb9\\xb3\\xbe\\x9c\\x9a\\xba\\x9d\\x9f\\x9e\"",
".",
"\"\\xbf\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\\xd0\\xd1\\xd2\\xd3\"",
".",
"\"\\xd4\\xd5\\xd6\\xd7\\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\"",
".",
"\"\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\"",
".",
"\"\\x96\\xa0\\x8b\\x97\\x9b\\xa6\\xad\\xb7\"",
",",
"'ALLSSSSTZZZallssstzzzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTsraaaalccceeeeiiddnnooooruuuuyt- <->|-.'",
")",
";",
"$",
"s",
"=",
"preg_replace",
"(",
"'#[^\\x00-\\x7F]++#'",
",",
"''",
",",
"$",
"s",
")",
";",
"}",
"else",
"{",
"$",
"s",
"=",
"@",
"iconv",
"(",
"'UTF-8'",
",",
"'ASCII//TRANSLIT//IGNORE'",
",",
"$",
"s",
")",
";",
"// intentionally @",
"}",
"$",
"s",
"=",
"str_replace",
"(",
"[",
"'`'",
",",
"\"'\"",
",",
"'\"'",
",",
"'^'",
",",
"'~'",
",",
"'?'",
"]",
",",
"''",
",",
"$",
"s",
")",
";",
"return",
"strtr",
"(",
"$",
"s",
",",
"\"\\x01\\x02\\x03\\x04\\x05\\x06\"",
",",
"'`\\'\"^~?'",
")",
";",
"}"
] |
Converts string to ASCII.
This function is taken from `nette/utils` package.
@author David Grudl <https://davidgrudl.com>
@see https://github.com/nette/utils
@license https://github.com/nette/utils/blob/master/license.md
@param string $s UTF-8 encoding
@return string ASCII
|
[
"Converts",
"string",
"to",
"ASCII",
"."
] |
eb1682acf9515afa19ee710666011937dcb4a2fc
|
https://github.com/czukowski/markdown-toc/blob/eb1682acf9515afa19ee710666011937dcb4a2fc/classes/TOCTrait.php#L229-L262
|
234,543
|
webbuilders-group/silverstripe-frontendgridfield
|
code/forms/FrontEndGridFieldDetailForm.php
|
FrontEndGridFieldDetailForm_ItemRequest.view
|
public function view($request) {
if(!$this->record->canView()) {
$this->httpError(403);
}
$controller=$this->getToplevelController();
$form=$this->ItemEditForm($this->gridField, $request);
$form->makeReadonly();
return $controller->customise(array(
'Title'=>($this->record && $this->record->ID ? $this->record->Title:sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->i18n_singular_name())),
'ItemEditForm'=>$form
))->renderWith($this->template);
}
|
php
|
public function view($request) {
if(!$this->record->canView()) {
$this->httpError(403);
}
$controller=$this->getToplevelController();
$form=$this->ItemEditForm($this->gridField, $request);
$form->makeReadonly();
return $controller->customise(array(
'Title'=>($this->record && $this->record->ID ? $this->record->Title:sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->i18n_singular_name())),
'ItemEditForm'=>$form
))->renderWith($this->template);
}
|
[
"public",
"function",
"view",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"record",
"->",
"canView",
"(",
")",
")",
"{",
"$",
"this",
"->",
"httpError",
"(",
"403",
")",
";",
"}",
"$",
"controller",
"=",
"$",
"this",
"->",
"getToplevelController",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"ItemEditForm",
"(",
"$",
"this",
"->",
"gridField",
",",
"$",
"request",
")",
";",
"$",
"form",
"->",
"makeReadonly",
"(",
")",
";",
"return",
"$",
"controller",
"->",
"customise",
"(",
"array",
"(",
"'Title'",
"=>",
"(",
"$",
"this",
"->",
"record",
"&&",
"$",
"this",
"->",
"record",
"->",
"ID",
"?",
"$",
"this",
"->",
"record",
"->",
"Title",
":",
"sprintf",
"(",
"_t",
"(",
"'GridField.NewRecord'",
",",
"'New %s'",
")",
",",
"$",
"this",
"->",
"record",
"->",
"i18n_singular_name",
"(",
")",
")",
")",
",",
"'ItemEditForm'",
"=>",
"$",
"form",
")",
")",
"->",
"renderWith",
"(",
"$",
"this",
"->",
"template",
")",
";",
"}"
] |
Renders the view form
@param {SS_HTTPRequest} $request Request data
@return {string} Rendered view form
|
[
"Renders",
"the",
"view",
"form"
] |
e3ff8d3208c279e9af6e15a750af02632876b914
|
https://github.com/webbuilders-group/silverstripe-frontendgridfield/blob/e3ff8d3208c279e9af6e15a750af02632876b914/code/forms/FrontEndGridFieldDetailForm.php#L154-L168
|
234,544
|
webbuilders-group/silverstripe-frontendgridfield
|
code/forms/FrontEndGridFieldDetailForm.php
|
FrontEndGridFieldDetailForm_ItemRequest.edit
|
public function edit($request) {
$controller=$this->getToplevelController();
$form=$this->ItemEditForm($this->gridField, $request);
return $controller->customise(array(
'Title'=>($this->record && $this->record->ID ? $this->record->Title:sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->i18n_singular_name())),
'ItemEditForm'=>$form,
))->renderWith($this->template);
}
|
php
|
public function edit($request) {
$controller=$this->getToplevelController();
$form=$this->ItemEditForm($this->gridField, $request);
return $controller->customise(array(
'Title'=>($this->record && $this->record->ID ? $this->record->Title:sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->i18n_singular_name())),
'ItemEditForm'=>$form,
))->renderWith($this->template);
}
|
[
"public",
"function",
"edit",
"(",
"$",
"request",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"getToplevelController",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"ItemEditForm",
"(",
"$",
"this",
"->",
"gridField",
",",
"$",
"request",
")",
";",
"return",
"$",
"controller",
"->",
"customise",
"(",
"array",
"(",
"'Title'",
"=>",
"(",
"$",
"this",
"->",
"record",
"&&",
"$",
"this",
"->",
"record",
"->",
"ID",
"?",
"$",
"this",
"->",
"record",
"->",
"Title",
":",
"sprintf",
"(",
"_t",
"(",
"'GridField.NewRecord'",
",",
"'New %s'",
")",
",",
"$",
"this",
"->",
"record",
"->",
"i18n_singular_name",
"(",
")",
")",
")",
",",
"'ItemEditForm'",
"=>",
"$",
"form",
",",
")",
")",
"->",
"renderWith",
"(",
"$",
"this",
"->",
"template",
")",
";",
"}"
] |
Renders the edit form
@param {SS_HTTPRequest} $request Request data
@return {string} Rendered edit form
|
[
"Renders",
"the",
"edit",
"form"
] |
e3ff8d3208c279e9af6e15a750af02632876b914
|
https://github.com/webbuilders-group/silverstripe-frontendgridfield/blob/e3ff8d3208c279e9af6e15a750af02632876b914/code/forms/FrontEndGridFieldDetailForm.php#L175-L184
|
234,545
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Abstract.php
|
Zend_Validate_Abstract._createMessage
|
protected function _createMessage($messageKey, $value)
{
if (!isset($this->_messageTemplates[$messageKey])) {
return null;
}
$message = $this->_messageTemplates[$messageKey];
if (null !== ($translator = $this->getTranslator())) {
if ($translator->isTranslated($message)) {
$message = $translator->translate($message);
} elseif ($translator->isTranslated($messageKey)) {
$message = $translator->translate($messageKey);
}
}
if ($this->getObscureValue()) {
$value = str_repeat('*', strlen($value));
}
$message = str_replace('%value%', (string) $value, $message);
foreach ($this->_messageVariables as $ident => $property) {
$message = str_replace("%$ident%", $this->$property, $message);
}
return $message;
}
|
php
|
protected function _createMessage($messageKey, $value)
{
if (!isset($this->_messageTemplates[$messageKey])) {
return null;
}
$message = $this->_messageTemplates[$messageKey];
if (null !== ($translator = $this->getTranslator())) {
if ($translator->isTranslated($message)) {
$message = $translator->translate($message);
} elseif ($translator->isTranslated($messageKey)) {
$message = $translator->translate($messageKey);
}
}
if ($this->getObscureValue()) {
$value = str_repeat('*', strlen($value));
}
$message = str_replace('%value%', (string) $value, $message);
foreach ($this->_messageVariables as $ident => $property) {
$message = str_replace("%$ident%", $this->$property, $message);
}
return $message;
}
|
[
"protected",
"function",
"_createMessage",
"(",
"$",
"messageKey",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_messageTemplates",
"[",
"$",
"messageKey",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"message",
"=",
"$",
"this",
"->",
"_messageTemplates",
"[",
"$",
"messageKey",
"]",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"translator",
"=",
"$",
"this",
"->",
"getTranslator",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"translator",
"->",
"isTranslated",
"(",
"$",
"message",
")",
")",
"{",
"$",
"message",
"=",
"$",
"translator",
"->",
"translate",
"(",
"$",
"message",
")",
";",
"}",
"elseif",
"(",
"$",
"translator",
"->",
"isTranslated",
"(",
"$",
"messageKey",
")",
")",
"{",
"$",
"message",
"=",
"$",
"translator",
"->",
"translate",
"(",
"$",
"messageKey",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getObscureValue",
"(",
")",
")",
"{",
"$",
"value",
"=",
"str_repeat",
"(",
"'*'",
",",
"strlen",
"(",
"$",
"value",
")",
")",
";",
"}",
"$",
"message",
"=",
"str_replace",
"(",
"'%value%'",
",",
"(",
"string",
")",
"$",
"value",
",",
"$",
"message",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_messageVariables",
"as",
"$",
"ident",
"=>",
"$",
"property",
")",
"{",
"$",
"message",
"=",
"str_replace",
"(",
"\"%$ident%\"",
",",
"$",
"this",
"->",
"$",
"property",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] |
Constructs and returns a validation failure message with the given message key and value.
Returns null if and only if $messageKey does not correspond to an existing template.
If a translator is available and a translation exists for $messageKey,
the translation will be used.
@param string $messageKey
@param string $value
@return string
|
[
"Constructs",
"and",
"returns",
"a",
"validation",
"failure",
"message",
"with",
"the",
"given",
"message",
"key",
"and",
"value",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Abstract.php#L188-L213
|
234,546
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.make
|
public static function make(string $path, FormatInterface $format): Directory
{
return new static(new Filesystem(new Local($path)), '', $format);
}
|
php
|
public static function make(string $path, FormatInterface $format): Directory
{
return new static(new Filesystem(new Local($path)), '', $format);
}
|
[
"public",
"static",
"function",
"make",
"(",
"string",
"$",
"path",
",",
"FormatInterface",
"$",
"format",
")",
":",
"Directory",
"{",
"return",
"new",
"static",
"(",
"new",
"Filesystem",
"(",
"new",
"Local",
"(",
"$",
"path",
")",
")",
",",
"''",
",",
"$",
"format",
")",
";",
"}"
] |
Creates a new directory instance.
|
[
"Creates",
"a",
"new",
"directory",
"instance",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L23-L26
|
234,547
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.getDocument
|
public function getDocument(string $id): Document
{
if (isset($this->documents[$id])) {
return $this->documents[$id];
}
if ($this->hasDocument($id)) {
$path = $this->getDocumentPath($id);
$source = $this->filesystem->read($path);
if (is_string($source)) {
return $this->documents[$id] = new Document($this->format->parse($source));
}
throw new RuntimeException(sprintf('Format error in the file "%s"', $path));
}
throw new RuntimeException(sprintf('File "%s" not found', $id));
}
|
php
|
public function getDocument(string $id): Document
{
if (isset($this->documents[$id])) {
return $this->documents[$id];
}
if ($this->hasDocument($id)) {
$path = $this->getDocumentPath($id);
$source = $this->filesystem->read($path);
if (is_string($source)) {
return $this->documents[$id] = new Document($this->format->parse($source));
}
throw new RuntimeException(sprintf('Format error in the file "%s"', $path));
}
throw new RuntimeException(sprintf('File "%s" not found', $id));
}
|
[
"public",
"function",
"getDocument",
"(",
"string",
"$",
"id",
")",
":",
"Document",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"documents",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"documents",
"[",
"$",
"id",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasDocument",
"(",
"$",
"id",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getDocumentPath",
"(",
"$",
"id",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"read",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"return",
"$",
"this",
"->",
"documents",
"[",
"$",
"id",
"]",
"=",
"new",
"Document",
"(",
"$",
"this",
"->",
"format",
"->",
"parse",
"(",
"$",
"source",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Format error in the file \"%s\"'",
",",
"$",
"path",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'File \"%s\" not found'",
",",
"$",
"id",
")",
")",
";",
"}"
] |
Read and return a document.
|
[
"Read",
"and",
"return",
"a",
"document",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L38-L56
|
234,548
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.getDirectory
|
public function getDirectory(string $id): Directory
{
if (isset($this->directories[$id])) {
return $this->directories[$id];
}
if ($this->hasDirectory($id)) {
return $this->directories[$id] = new static($this->filesystem, $this->getDirectoryPath($id), $this->format);
}
throw new RuntimeException(sprintf('Directory "%s" not found', $id));
}
|
php
|
public function getDirectory(string $id): Directory
{
if (isset($this->directories[$id])) {
return $this->directories[$id];
}
if ($this->hasDirectory($id)) {
return $this->directories[$id] = new static($this->filesystem, $this->getDirectoryPath($id), $this->format);
}
throw new RuntimeException(sprintf('Directory "%s" not found', $id));
}
|
[
"public",
"function",
"getDirectory",
"(",
"string",
"$",
"id",
")",
":",
"Directory",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"directories",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"directories",
"[",
"$",
"id",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"hasDirectory",
"(",
"$",
"id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"directories",
"[",
"$",
"id",
"]",
"=",
"new",
"static",
"(",
"$",
"this",
"->",
"filesystem",
",",
"$",
"this",
"->",
"getDirectoryPath",
"(",
"$",
"id",
")",
",",
"$",
"this",
"->",
"format",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Directory \"%s\" not found'",
",",
"$",
"id",
")",
")",
";",
"}"
] |
Read and return a directory.
|
[
"Read",
"and",
"return",
"a",
"directory",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L61-L72
|
234,549
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.hasDocument
|
public function hasDocument(string $id): bool
{
if (isset($this->documents[$id])) {
return true;
}
$path = $this->getDocumentPath($id);
if ($this->filesystem->has($path)) {
$info = $this->filesystem->getMetadata($path);
return $info['type'] === 'file';
}
return false;
}
|
php
|
public function hasDocument(string $id): bool
{
if (isset($this->documents[$id])) {
return true;
}
$path = $this->getDocumentPath($id);
if ($this->filesystem->has($path)) {
$info = $this->filesystem->getMetadata($path);
return $info['type'] === 'file';
}
return false;
}
|
[
"public",
"function",
"hasDocument",
"(",
"string",
"$",
"id",
")",
":",
"bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"documents",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getDocumentPath",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"has",
"(",
"$",
"path",
")",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"getMetadata",
"(",
"$",
"path",
")",
";",
"return",
"$",
"info",
"[",
"'type'",
"]",
"===",
"'file'",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether a document exists.
|
[
"Check",
"whether",
"a",
"document",
"exists",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L77-L92
|
234,550
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.hasDirectory
|
public function hasDirectory(string $id): bool
{
if (isset($this->directories[$id])) {
return true;
}
$path = $this->getDirectoryPath($id);
if ($this->filesystem->has($path)) {
$info = $this->filesystem->getMetadata($path);
return $info['type'] === 'dir';
}
return false;
}
|
php
|
public function hasDirectory(string $id): bool
{
if (isset($this->directories[$id])) {
return true;
}
$path = $this->getDirectoryPath($id);
if ($this->filesystem->has($path)) {
$info = $this->filesystem->getMetadata($path);
return $info['type'] === 'dir';
}
return false;
}
|
[
"public",
"function",
"hasDirectory",
"(",
"string",
"$",
"id",
")",
":",
"bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"directories",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getDirectoryPath",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"has",
"(",
"$",
"path",
")",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"getMetadata",
"(",
"$",
"path",
")",
";",
"return",
"$",
"info",
"[",
"'type'",
"]",
"===",
"'dir'",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether a document or directory exists.
|
[
"Check",
"whether",
"a",
"document",
"or",
"directory",
"exists",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L97-L112
|
234,551
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.saveDocument
|
public function saveDocument(string $id, Document $document): self
{
$this->documents[$id] = $document;
$this->filesystem->put($this->getDocumentPath($id), $this->format->stringify($document->getArrayCopy()));
return $this;
}
|
php
|
public function saveDocument(string $id, Document $document): self
{
$this->documents[$id] = $document;
$this->filesystem->put($this->getDocumentPath($id), $this->format->stringify($document->getArrayCopy()));
return $this;
}
|
[
"public",
"function",
"saveDocument",
"(",
"string",
"$",
"id",
",",
"Document",
"$",
"document",
")",
":",
"self",
"{",
"$",
"this",
"->",
"documents",
"[",
"$",
"id",
"]",
"=",
"$",
"document",
";",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"$",
"this",
"->",
"getDocumentPath",
"(",
"$",
"id",
")",
",",
"$",
"this",
"->",
"format",
"->",
"stringify",
"(",
"$",
"document",
"->",
"getArrayCopy",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Saves a document.
|
[
"Saves",
"a",
"document",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L117-L123
|
234,552
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.getAllDocuments
|
public function getAllDocuments(): array
{
$documents = [];
foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
$id = $info['filename'];
if ($this->hasDocument($id)) {
$documents[$id] = $this->getDocument($id);
}
}
return $documents;
}
|
php
|
public function getAllDocuments(): array
{
$documents = [];
foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
$id = $info['filename'];
if ($this->hasDocument($id)) {
$documents[$id] = $this->getDocument($id);
}
}
return $documents;
}
|
[
"public",
"function",
"getAllDocuments",
"(",
")",
":",
"array",
"{",
"$",
"documents",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"listContents",
"(",
"'/'",
".",
"$",
"this",
"->",
"path",
")",
"as",
"$",
"info",
")",
"{",
"$",
"id",
"=",
"$",
"info",
"[",
"'filename'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasDocument",
"(",
"$",
"id",
")",
")",
"{",
"$",
"documents",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"getDocument",
"(",
"$",
"id",
")",
";",
"}",
"}",
"return",
"$",
"documents",
";",
"}"
] |
Returns all documents.
|
[
"Returns",
"all",
"documents",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L161-L174
|
234,553
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.getAllDirectories
|
public function getAllDirectories(): array
{
$directories = [];
foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
$id = $info['filename'];
if ($this->hasDirectory($id)) {
$directories[$id] = $this->getDirectory($id);
}
}
return $directories;
}
|
php
|
public function getAllDirectories(): array
{
$directories = [];
foreach ($this->filesystem->listContents('/'.$this->path) as $info) {
$id = $info['filename'];
if ($this->hasDirectory($id)) {
$directories[$id] = $this->getDirectory($id);
}
}
return $directories;
}
|
[
"public",
"function",
"getAllDirectories",
"(",
")",
":",
"array",
"{",
"$",
"directories",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"filesystem",
"->",
"listContents",
"(",
"'/'",
".",
"$",
"this",
"->",
"path",
")",
"as",
"$",
"info",
")",
"{",
"$",
"id",
"=",
"$",
"info",
"[",
"'filename'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasDirectory",
"(",
"$",
"id",
")",
")",
"{",
"$",
"directories",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"getDirectory",
"(",
"$",
"id",
")",
";",
"}",
"}",
"return",
"$",
"directories",
";",
"}"
] |
Returns all directories.
|
[
"Returns",
"all",
"directories",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L179-L192
|
234,554
|
oscarotero/fly-crud
|
src/Directory.php
|
Directory.getDocumentPath
|
private function getDocumentPath(string $id): string
{
return $this->getDirectoryPath($id).'.'.$this->format->getExtension();
}
|
php
|
private function getDocumentPath(string $id): string
{
return $this->getDirectoryPath($id).'.'.$this->format->getExtension();
}
|
[
"private",
"function",
"getDocumentPath",
"(",
"string",
"$",
"id",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"getDirectoryPath",
"(",
"$",
"id",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"format",
"->",
"getExtension",
"(",
")",
";",
"}"
] |
Returns a file path.
|
[
"Returns",
"a",
"file",
"path",
"."
] |
df826e4db5df954d3cace9c12762ec0309b050bf
|
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Directory.php#L197-L200
|
234,555
|
damonjones/Vebra-PHP-API-Wrapper
|
lib/YDD/Vebra/Model/Branch.php
|
Branch.fromArray
|
public function fromArray(array $arr)
{
foreach ($arr as $key => $value) {
$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
}
}
|
php
|
public function fromArray(array $arr)
{
foreach ($arr as $key => $value) {
$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
}
}
|
[
"public",
"function",
"fromArray",
"(",
"array",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"$",
"key",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] |
Import object properties from an associative array
@param array $arr An associative array
|
[
"Import",
"object",
"properties",
"from",
"an",
"associative",
"array"
] |
9de0fb5181a6e4b90700027ffaa6b2e658d279c2
|
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/Model/Branch.php#L309-L317
|
234,556
|
damonjones/Vebra-PHP-API-Wrapper
|
lib/YDD/Vebra/Model/Branch.php
|
Branch.toArray
|
public function toArray()
{
$arr = array();
foreach ($this as $key => $value) {
$method = 'get' . $key;
if (method_exists($this, $method)) {
$arr[$key] = $this->$method();
}
}
return $arr;
}
|
php
|
public function toArray()
{
$arr = array();
foreach ($this as $key => $value) {
$method = 'get' . $key;
if (method_exists($this, $method)) {
$arr[$key] = $this->$method();
}
}
return $arr;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"$",
"key",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"arr",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"}",
"return",
"$",
"arr",
";",
"}"
] |
Export the object properties to an associative array
@return array An associative array
|
[
"Export",
"the",
"object",
"properties",
"to",
"an",
"associative",
"array"
] |
9de0fb5181a6e4b90700027ffaa6b2e658d279c2
|
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/Model/Branch.php#L324-L335
|
234,557
|
crysalead/sql-dialect
|
src/Statement/Update.php
|
Update._buildSet
|
protected function _buildSet()
{
$values = [];
$states = $this->_schema ? ['schema' => $this->_schema] : [];
foreach ($this->_parts['values'] as $key => $value) {
$states['name'] = $key;
$values[] = $this->dialect()->name($key) . ' = ' . $this->dialect()->value($value, $states);
}
return $values ? ' SET ' . join(', ', $values) : '';
}
|
php
|
protected function _buildSet()
{
$values = [];
$states = $this->_schema ? ['schema' => $this->_schema] : [];
foreach ($this->_parts['values'] as $key => $value) {
$states['name'] = $key;
$values[] = $this->dialect()->name($key) . ' = ' . $this->dialect()->value($value, $states);
}
return $values ? ' SET ' . join(', ', $values) : '';
}
|
[
"protected",
"function",
"_buildSet",
"(",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"states",
"=",
"$",
"this",
"->",
"_schema",
"?",
"[",
"'schema'",
"=>",
"$",
"this",
"->",
"_schema",
"]",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'values'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"states",
"[",
"'name'",
"]",
"=",
"$",
"key",
";",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"name",
"(",
"$",
"key",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"value",
"(",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"return",
"$",
"values",
"?",
"' SET '",
".",
"join",
"(",
"', '",
",",
"$",
"values",
")",
":",
"''",
";",
"}"
] |
Build `SET` clause.
@return string Returns the `SET` clause.
|
[
"Build",
"SET",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Update.php#L110-L119
|
234,558
|
opis/orm
|
src/Core/DataMapper.php
|
DataMapper.executePendingLinkage
|
public function executePendingLinkage()
{
foreach ($this->pendingLinks as $item) {
/** @var ShareOneOrMany $rel */
$rel = $item['relation'];
if ($item['link']) {
$rel->link($this, $item['entity']);
} else {
$rel->unlink($this, $item['entity']);
}
}
$this->pendingLinks = [];
}
|
php
|
public function executePendingLinkage()
{
foreach ($this->pendingLinks as $item) {
/** @var ShareOneOrMany $rel */
$rel = $item['relation'];
if ($item['link']) {
$rel->link($this, $item['entity']);
} else {
$rel->unlink($this, $item['entity']);
}
}
$this->pendingLinks = [];
}
|
[
"public",
"function",
"executePendingLinkage",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pendingLinks",
"as",
"$",
"item",
")",
"{",
"/** @var ShareOneOrMany $rel */",
"$",
"rel",
"=",
"$",
"item",
"[",
"'relation'",
"]",
";",
"if",
"(",
"$",
"item",
"[",
"'link'",
"]",
")",
"{",
"$",
"rel",
"->",
"link",
"(",
"$",
"this",
",",
"$",
"item",
"[",
"'entity'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"rel",
"->",
"unlink",
"(",
"$",
"this",
",",
"$",
"item",
"[",
"'entity'",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"pendingLinks",
"=",
"[",
"]",
";",
"}"
] |
Execute pending linkage
|
[
"Execute",
"pending",
"linkage"
] |
2723235be55242cd20452b8c9648d4823b7ce8b5
|
https://github.com/opis/orm/blob/2723235be55242cd20452b8c9648d4823b7ce8b5/src/Core/DataMapper.php#L436-L449
|
234,559
|
railken/search-query
|
src/Languages/BoomTree/Resolvers/ComparisonOperatorResolver.php
|
ComparisonOperatorResolver.resolve
|
public function resolve(NodeContract $node)
{
$children = $node->getChildren();
if (count($children) > 0) {
$this->resolve($node->getChildByIndex(0));
$value = '';
$positions = [];
foreach ($node->getChildren() as $child) {
if ($child instanceof Nodes\TextNode || $child instanceof Nodes\KeyNode) {
$value .= ' '.$child->getValue();
$p = array_fill(0, strlen(' '.$child->getValue()), $child->getIndex());
$positions = array_merge($positions, $p);
}
}
foreach ($this->regex as $regex) {
preg_match($regex, $value, $match, PREG_OFFSET_CAPTURE);
if ($match) {
$new_node = new $this->node();
$start = $match[0][1];
$length = strlen($match[0][0]);
$this->groupNode($node, $new_node, $start, $start + $length, $positions);
$this->resolveRelationsNode($node, $new_node);
// Search for another match in this node.
return $this->resolve($node->getParent());
}
}
}
return $node->next() !== null ? $this->resolve($node->next()) : null;
}
|
php
|
public function resolve(NodeContract $node)
{
$children = $node->getChildren();
if (count($children) > 0) {
$this->resolve($node->getChildByIndex(0));
$value = '';
$positions = [];
foreach ($node->getChildren() as $child) {
if ($child instanceof Nodes\TextNode || $child instanceof Nodes\KeyNode) {
$value .= ' '.$child->getValue();
$p = array_fill(0, strlen(' '.$child->getValue()), $child->getIndex());
$positions = array_merge($positions, $p);
}
}
foreach ($this->regex as $regex) {
preg_match($regex, $value, $match, PREG_OFFSET_CAPTURE);
if ($match) {
$new_node = new $this->node();
$start = $match[0][1];
$length = strlen($match[0][0]);
$this->groupNode($node, $new_node, $start, $start + $length, $positions);
$this->resolveRelationsNode($node, $new_node);
// Search for another match in this node.
return $this->resolve($node->getParent());
}
}
}
return $node->next() !== null ? $this->resolve($node->next()) : null;
}
|
[
"public",
"function",
"resolve",
"(",
"NodeContract",
"$",
"node",
")",
"{",
"$",
"children",
"=",
"$",
"node",
"->",
"getChildren",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"children",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"resolve",
"(",
"$",
"node",
"->",
"getChildByIndex",
"(",
"0",
")",
")",
";",
"$",
"value",
"=",
"''",
";",
"$",
"positions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"Nodes",
"\\",
"TextNode",
"||",
"$",
"child",
"instanceof",
"Nodes",
"\\",
"KeyNode",
")",
"{",
"$",
"value",
".=",
"' '",
".",
"$",
"child",
"->",
"getValue",
"(",
")",
";",
"$",
"p",
"=",
"array_fill",
"(",
"0",
",",
"strlen",
"(",
"' '",
".",
"$",
"child",
"->",
"getValue",
"(",
")",
")",
",",
"$",
"child",
"->",
"getIndex",
"(",
")",
")",
";",
"$",
"positions",
"=",
"array_merge",
"(",
"$",
"positions",
",",
"$",
"p",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"regex",
"as",
"$",
"regex",
")",
"{",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"value",
",",
"$",
"match",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"new_node",
"=",
"new",
"$",
"this",
"->",
"node",
"(",
")",
";",
"$",
"start",
"=",
"$",
"match",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"groupNode",
"(",
"$",
"node",
",",
"$",
"new_node",
",",
"$",
"start",
",",
"$",
"start",
"+",
"$",
"length",
",",
"$",
"positions",
")",
";",
"$",
"this",
"->",
"resolveRelationsNode",
"(",
"$",
"node",
",",
"$",
"new_node",
")",
";",
"// Search for another match in this node.",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"node",
"->",
"next",
"(",
")",
"!==",
"null",
"?",
"$",
"this",
"->",
"resolve",
"(",
"$",
"node",
"->",
"next",
"(",
")",
")",
":",
"null",
";",
"}"
] |
Resolve token eq node.
@param NodeContract $node
@return NodeContract|null
|
[
"Resolve",
"token",
"eq",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/ComparisonOperatorResolver.php#L37-L73
|
234,560
|
txj123/zilf
|
src/Zilf/Db/Transaction.php
|
Transaction.setIsolationLevel
|
public function setIsolationLevel($level)
{
if (!$this->getIsActive()) {
throw new Exception('Failed to set isolation level: transaction was inactive.');
}
Log::debug('Setting transaction isolation level to ' . $level . __METHOD__);
$this->db->getSchema()->setTransactionIsolationLevel($level);
}
|
php
|
public function setIsolationLevel($level)
{
if (!$this->getIsActive()) {
throw new Exception('Failed to set isolation level: transaction was inactive.');
}
Log::debug('Setting transaction isolation level to ' . $level . __METHOD__);
$this->db->getSchema()->setTransactionIsolationLevel($level);
}
|
[
"public",
"function",
"setIsolationLevel",
"(",
"$",
"level",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getIsActive",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to set isolation level: transaction was inactive.'",
")",
";",
"}",
"Log",
"::",
"debug",
"(",
"'Setting transaction isolation level to '",
".",
"$",
"level",
".",
"__METHOD__",
")",
";",
"$",
"this",
"->",
"db",
"->",
"getSchema",
"(",
")",
"->",
"setTransactionIsolationLevel",
"(",
"$",
"level",
")",
";",
"}"
] |
Sets the transaction isolation level for this transaction.
This method can be used to set the isolation level while the transaction is already active.
However this is not supported by all DBMS so you might rather specify the isolation level directly
when calling [[begin()]].
@param string $level The transaction isolation level to use for this transaction.
This can be one of [[READ_UNCOMMITTED]], [[READ_COMMITTED]], [[REPEATABLE_READ]] and [[SERIALIZABLE]] but
also a string containing DBMS specific syntax to be used after `SET TRANSACTION ISOLATION LEVEL`.
@throws Exception if the transaction is not active
@see http://en.wikipedia.org/wiki/Isolation_%28database_systems%29#Isolation_levels
|
[
"Sets",
"the",
"transaction",
"isolation",
"level",
"for",
"this",
"transaction",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/Transaction.php#L231-L238
|
234,561
|
oxygen-cms/core
|
src/Html/Toolbar/FormToolbarItem.php
|
FormToolbarItem.render
|
public function render(array $arguments = [], $renderer = null) {
$this->runDynamicCallbacks($arguments);
return $this->baseRender($arguments, $renderer);
}
|
php
|
public function render(array $arguments = [], $renderer = null) {
$this->runDynamicCallbacks($arguments);
return $this->baseRender($arguments, $renderer);
}
|
[
"public",
"function",
"render",
"(",
"array",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"renderer",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"runDynamicCallbacks",
"(",
"$",
"arguments",
")",
";",
"return",
"$",
"this",
"->",
"baseRender",
"(",
"$",
"arguments",
",",
"$",
"renderer",
")",
";",
"}"
] |
Renders the object.
Before rendering all 'dynamic callbacks' will be excecuted.
@param array $arguments
@param RendererInterface|callable $renderer
@throws Exception
@return string the rendered object
|
[
"Renders",
"the",
"object",
".",
"Before",
"rendering",
"all",
"dynamic",
"callbacks",
"will",
"be",
"excecuted",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/FormToolbarItem.php#L52-L56
|
234,562
|
oxygen-cms/core
|
src/Html/Header/Header.php
|
Header.fromBlueprint
|
public static function fromBlueprint(Blueprint $blueprint, $title, array $arguments = [], $type = self::TYPE_MAIN, $fillFromToolbar = 'section') {
if($title instanceof FieldSet) {
$title = $arguments['model']->getAttribute($title->getTitleFieldName());
} else {
if(!is_string($title)) {
throw new \InvalidArgumentException('$title must be either a string or an instance of \Oxygen\Core\Form\FieldSet');
}
}
$object = new static(
$title,
$arguments,
$type
);
// sets a prefix to all the routes in the toolbar
$object->getToolbar()->setPrefix($blueprint->getRouteName());
// fills the toolbar with buttons from the blueprint
$object->getToolbar()->fillFromBlueprint($blueprint, $fillFromToolbar);
return $object;
}
|
php
|
public static function fromBlueprint(Blueprint $blueprint, $title, array $arguments = [], $type = self::TYPE_MAIN, $fillFromToolbar = 'section') {
if($title instanceof FieldSet) {
$title = $arguments['model']->getAttribute($title->getTitleFieldName());
} else {
if(!is_string($title)) {
throw new \InvalidArgumentException('$title must be either a string or an instance of \Oxygen\Core\Form\FieldSet');
}
}
$object = new static(
$title,
$arguments,
$type
);
// sets a prefix to all the routes in the toolbar
$object->getToolbar()->setPrefix($blueprint->getRouteName());
// fills the toolbar with buttons from the blueprint
$object->getToolbar()->fillFromBlueprint($blueprint, $fillFromToolbar);
return $object;
}
|
[
"public",
"static",
"function",
"fromBlueprint",
"(",
"Blueprint",
"$",
"blueprint",
",",
"$",
"title",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_MAIN",
",",
"$",
"fillFromToolbar",
"=",
"'section'",
")",
"{",
"if",
"(",
"$",
"title",
"instanceof",
"FieldSet",
")",
"{",
"$",
"title",
"=",
"$",
"arguments",
"[",
"'model'",
"]",
"->",
"getAttribute",
"(",
"$",
"title",
"->",
"getTitleFieldName",
"(",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"title",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$title must be either a string or an instance of \\Oxygen\\Core\\Form\\FieldSet'",
")",
";",
"}",
"}",
"$",
"object",
"=",
"new",
"static",
"(",
"$",
"title",
",",
"$",
"arguments",
",",
"$",
"type",
")",
";",
"// sets a prefix to all the routes in the toolbar",
"$",
"object",
"->",
"getToolbar",
"(",
")",
"->",
"setPrefix",
"(",
"$",
"blueprint",
"->",
"getRouteName",
"(",
")",
")",
";",
"// fills the toolbar with buttons from the blueprint",
"$",
"object",
"->",
"getToolbar",
"(",
")",
"->",
"fillFromBlueprint",
"(",
"$",
"blueprint",
",",
"$",
"fillFromToolbar",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Constructs a Header from a Blueprint.
@param Blueprint $blueprint
@param FieldSet|string $title
@param array $arguments
@param integer $type
@param string $fillFromToolbar
@return Header
|
[
"Constructs",
"a",
"Header",
"from",
"a",
"Blueprint",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Header/Header.php#L303-L325
|
234,563
|
flashwave/whois-php
|
src/Whois/Client.php
|
Client.lookupIP
|
private function lookupIP($address)
{
// Create the responses storage array
$responses = [];
// Query every server in the IP list
foreach ($this->servers->ip as $server) {
// Check if we haven't queried this server yet
if (array_key_exists($server, $responses)) {
continue;
}
// Query the server
$responses[$server] = $this->query($address, $server);
}
// Create a result object
$result = new Result();
// Set target
$result->target = $address;
// Set the type
$result->type = 'ip';
// Set response count
$result->count = count($responses);
// Set responses
$result->responses = array_reverse($responses);
// Return the Result object
return $result;
}
|
php
|
private function lookupIP($address)
{
// Create the responses storage array
$responses = [];
// Query every server in the IP list
foreach ($this->servers->ip as $server) {
// Check if we haven't queried this server yet
if (array_key_exists($server, $responses)) {
continue;
}
// Query the server
$responses[$server] = $this->query($address, $server);
}
// Create a result object
$result = new Result();
// Set target
$result->target = $address;
// Set the type
$result->type = 'ip';
// Set response count
$result->count = count($responses);
// Set responses
$result->responses = array_reverse($responses);
// Return the Result object
return $result;
}
|
[
"private",
"function",
"lookupIP",
"(",
"$",
"address",
")",
"{",
"// Create the responses storage array",
"$",
"responses",
"=",
"[",
"]",
";",
"// Query every server in the IP list",
"foreach",
"(",
"$",
"this",
"->",
"servers",
"->",
"ip",
"as",
"$",
"server",
")",
"{",
"// Check if we haven't queried this server yet",
"if",
"(",
"array_key_exists",
"(",
"$",
"server",
",",
"$",
"responses",
")",
")",
"{",
"continue",
";",
"}",
"// Query the server",
"$",
"responses",
"[",
"$",
"server",
"]",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"address",
",",
"$",
"server",
")",
";",
"}",
"// Create a result object",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"// Set target",
"$",
"result",
"->",
"target",
"=",
"$",
"address",
";",
"// Set the type",
"$",
"result",
"->",
"type",
"=",
"'ip'",
";",
"// Set response count",
"$",
"result",
"->",
"count",
"=",
"count",
"(",
"$",
"responses",
")",
";",
"// Set responses",
"$",
"result",
"->",
"responses",
"=",
"array_reverse",
"(",
"$",
"responses",
")",
";",
"// Return the Result object",
"return",
"$",
"result",
";",
"}"
] |
Whois an IP address.
@param string $address The IP address to query.
@return Result The whois results.
|
[
"Whois",
"an",
"IP",
"address",
"."
] |
0eae1b4c863f8cfaee88bf3abdf2dd6d3d490bf8
|
https://github.com/flashwave/whois-php/blob/0eae1b4c863f8cfaee88bf3abdf2dd6d3d490bf8/src/Whois/Client.php#L145-L178
|
234,564
|
flashwave/whois-php
|
src/Whois/Client.php
|
Client.query
|
private function query($target, $server, $port = 43, $timeout = 5)
{
// Create the socket
$sock = @fsockopen($server, $port, $errno, $errstr, $timeout);
// Check for errors
if (!$sock) {
// Throw an exception with the error string
throw new WhoisException($errstr);
}
// Write the target to the socket
fwrite($sock, $target . "\r\n");
// Create storage variable
$response = '';
// Await output
while ($line = fgets($sock)) {
$response .= $line;
}
// Close the socket
fclose($sock);
// Return the response
return $response;
}
|
php
|
private function query($target, $server, $port = 43, $timeout = 5)
{
// Create the socket
$sock = @fsockopen($server, $port, $errno, $errstr, $timeout);
// Check for errors
if (!$sock) {
// Throw an exception with the error string
throw new WhoisException($errstr);
}
// Write the target to the socket
fwrite($sock, $target . "\r\n");
// Create storage variable
$response = '';
// Await output
while ($line = fgets($sock)) {
$response .= $line;
}
// Close the socket
fclose($sock);
// Return the response
return $response;
}
|
[
"private",
"function",
"query",
"(",
"$",
"target",
",",
"$",
"server",
",",
"$",
"port",
"=",
"43",
",",
"$",
"timeout",
"=",
"5",
")",
"{",
"// Create the socket",
"$",
"sock",
"=",
"@",
"fsockopen",
"(",
"$",
"server",
",",
"$",
"port",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"timeout",
")",
";",
"// Check for errors",
"if",
"(",
"!",
"$",
"sock",
")",
"{",
"// Throw an exception with the error string",
"throw",
"new",
"WhoisException",
"(",
"$",
"errstr",
")",
";",
"}",
"// Write the target to the socket",
"fwrite",
"(",
"$",
"sock",
",",
"$",
"target",
".",
"\"\\r\\n\"",
")",
";",
"// Create storage variable",
"$",
"response",
"=",
"''",
";",
"// Await output",
"while",
"(",
"$",
"line",
"=",
"fgets",
"(",
"$",
"sock",
")",
")",
"{",
"$",
"response",
".=",
"$",
"line",
";",
"}",
"// Close the socket",
"fclose",
"(",
"$",
"sock",
")",
";",
"// Return the response",
"return",
"$",
"response",
";",
"}"
] |
Query the whois server.
@param string $target The target IP/domain.
@param string $server The server to be queried.
@param int $port The port for the whois server.
@param int $timeout The timeout.
@throws WhoisException if the socket failed to open.
@return string The response from the whois server.
|
[
"Query",
"the",
"whois",
"server",
"."
] |
0eae1b4c863f8cfaee88bf3abdf2dd6d3d490bf8
|
https://github.com/flashwave/whois-php/blob/0eae1b4c863f8cfaee88bf3abdf2dd6d3d490bf8/src/Whois/Client.php#L206-L233
|
234,565
|
oxygen-cms/core
|
src/Html/Toolbar/ActionToolbarItem.php
|
ActionToolbarItem.shouldRenderBasic
|
public function shouldRenderBasic(array $arguments) {
if(isset($arguments['evenOnSamePage']) && $arguments['evenOnSamePage'] === true) {
return $this->hasPermissions();
} else {
return $this->hasPermissions() && !$this->linksToCurrentPage($arguments);
}
}
|
php
|
public function shouldRenderBasic(array $arguments) {
if(isset($arguments['evenOnSamePage']) && $arguments['evenOnSamePage'] === true) {
return $this->hasPermissions();
} else {
return $this->hasPermissions() && !$this->linksToCurrentPage($arguments);
}
}
|
[
"public",
"function",
"shouldRenderBasic",
"(",
"array",
"$",
"arguments",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"'evenOnSamePage'",
"]",
")",
"&&",
"$",
"arguments",
"[",
"'evenOnSamePage'",
"]",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"hasPermissions",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"hasPermissions",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"linksToCurrentPage",
"(",
"$",
"arguments",
")",
";",
"}",
"}"
] |
Provides simple shouldRender check, that checks.
@return boolean
|
[
"Provides",
"simple",
"shouldRender",
"check",
"that",
"checks",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/ActionToolbarItem.php#L107-L113
|
234,566
|
oxygen-cms/core
|
src/Html/Toolbar/ActionToolbarItem.php
|
ActionToolbarItem.hasPermissions
|
public function hasPermissions() {
return $this->action->usesPermissions()
? Auth::user()->hasPermissions($this->action->getPermissions())
: true;
}
|
php
|
public function hasPermissions() {
return $this->action->usesPermissions()
? Auth::user()->hasPermissions($this->action->getPermissions())
: true;
}
|
[
"public",
"function",
"hasPermissions",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"action",
"->",
"usesPermissions",
"(",
")",
"?",
"Auth",
"::",
"user",
"(",
")",
"->",
"hasPermissions",
"(",
"$",
"this",
"->",
"action",
"->",
"getPermissions",
"(",
")",
")",
":",
"true",
";",
"}"
] |
Determines if the user has the required permissions for the toolbar item.
@return boolean
|
[
"Determines",
"if",
"the",
"user",
"has",
"the",
"required",
"permissions",
"for",
"the",
"toolbar",
"item",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/ActionToolbarItem.php#L120-L124
|
234,567
|
oxygen-cms/core
|
src/Html/Toolbar/ActionToolbarItem.php
|
ActionToolbarItem.linksToCurrentPage
|
public function linksToCurrentPage(array $arguments) {
return
URL::current() == URL::route($this->action->getName(), $this->action->getRouteParameters($arguments)) &&
Request::method() == $this->action->getMethod();
}
|
php
|
public function linksToCurrentPage(array $arguments) {
return
URL::current() == URL::route($this->action->getName(), $this->action->getRouteParameters($arguments)) &&
Request::method() == $this->action->getMethod();
}
|
[
"public",
"function",
"linksToCurrentPage",
"(",
"array",
"$",
"arguments",
")",
"{",
"return",
"URL",
"::",
"current",
"(",
")",
"==",
"URL",
"::",
"route",
"(",
"$",
"this",
"->",
"action",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"action",
"->",
"getRouteParameters",
"(",
"$",
"arguments",
")",
")",
"&&",
"Request",
"::",
"method",
"(",
")",
"==",
"$",
"this",
"->",
"action",
"->",
"getMethod",
"(",
")",
";",
"}"
] |
Determines if the ActionToolbarItem will link to the current page.
@param array $arguments
@return boolean
|
[
"Determines",
"if",
"the",
"ActionToolbarItem",
"will",
"link",
"to",
"the",
"current",
"page",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Html/Toolbar/ActionToolbarItem.php#L132-L136
|
234,568
|
crysalead/sql-dialect
|
src/Statement/PostgreSql/Select.php
|
Select.lock
|
public function lock($mode = 'update')
{
switch (strtolower($mode)) {
case 'update':
$lock = 'FOR UPDATE';
break;
case 'share':
$lock = 'FOR SHARE';
break;
case 'no key update':
$lock = 'FOR NO KEY UPDATE';
break;
case 'key share':
$lock = 'FOR KEY SHARE';
break;
case false:
$lock = false;
break;
default:
throw new SqlException("Invalid PostgreSQL lock mode `'{$mode}'`.");
break;
}
$this->_parts['lock'] = $lock;
return $this;
}
|
php
|
public function lock($mode = 'update')
{
switch (strtolower($mode)) {
case 'update':
$lock = 'FOR UPDATE';
break;
case 'share':
$lock = 'FOR SHARE';
break;
case 'no key update':
$lock = 'FOR NO KEY UPDATE';
break;
case 'key share':
$lock = 'FOR KEY SHARE';
break;
case false:
$lock = false;
break;
default:
throw new SqlException("Invalid PostgreSQL lock mode `'{$mode}'`.");
break;
}
$this->_parts['lock'] = $lock;
return $this;
}
|
[
"public",
"function",
"lock",
"(",
"$",
"mode",
"=",
"'update'",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"mode",
")",
")",
"{",
"case",
"'update'",
":",
"$",
"lock",
"=",
"'FOR UPDATE'",
";",
"break",
";",
"case",
"'share'",
":",
"$",
"lock",
"=",
"'FOR SHARE'",
";",
"break",
";",
"case",
"'no key update'",
":",
"$",
"lock",
"=",
"'FOR NO KEY UPDATE'",
";",
"break",
";",
"case",
"'key share'",
":",
"$",
"lock",
"=",
"'FOR KEY SHARE'",
";",
"break",
";",
"case",
"false",
":",
"$",
"lock",
"=",
"false",
";",
"break",
";",
"default",
":",
"throw",
"new",
"SqlException",
"(",
"\"Invalid PostgreSQL lock mode `'{$mode}'`.\"",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"_parts",
"[",
"'lock'",
"]",
"=",
"$",
"lock",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the lock mode.
@param boolean $mode The lock mode.
@return object Returns `$this`.
|
[
"Set",
"the",
"lock",
"mode",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/PostgreSql/Select.php#L17-L41
|
234,569
|
awurth/SlimHelpers
|
Controller/SecurityTrait.php
|
SecurityTrait.accessDeniedException
|
protected function accessDeniedException(Request $request, Response $response, $message = 'Access denied.')
{
return new AccessDeniedException($request, $response, $message);
}
|
php
|
protected function accessDeniedException(Request $request, Response $response, $message = 'Access denied.')
{
return new AccessDeniedException($request, $response, $message);
}
|
[
"protected",
"function",
"accessDeniedException",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"$",
"message",
"=",
"'Access denied.'",
")",
"{",
"return",
"new",
"AccessDeniedException",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"message",
")",
";",
"}"
] |
Creates a new AccessDeniedException.
@param Request $request
@param Response $response
@param string $message
@return AccessDeniedException
|
[
"Creates",
"a",
"new",
"AccessDeniedException",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/SecurityTrait.php#L21-L24
|
234,570
|
awurth/SlimHelpers
|
Controller/SecurityTrait.php
|
SecurityTrait.unauthorizedException
|
protected function unauthorizedException(Request $request, Response $response, $message = 'Unauthorized.')
{
return new UnauthorizedException($request, $response, $message);
}
|
php
|
protected function unauthorizedException(Request $request, Response $response, $message = 'Unauthorized.')
{
return new UnauthorizedException($request, $response, $message);
}
|
[
"protected",
"function",
"unauthorizedException",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"$",
"message",
"=",
"'Unauthorized.'",
")",
"{",
"return",
"new",
"UnauthorizedException",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"message",
")",
";",
"}"
] |
Creates a new UnauthorizedException.
@param Request $request
@param Response $response
@param string $message
@return UnauthorizedException
|
[
"Creates",
"a",
"new",
"UnauthorizedException",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/SecurityTrait.php#L35-L38
|
234,571
|
omnilight/yii2-phonenumbers
|
PhoneNumber.php
|
PhoneNumber.format
|
public static function format($phone, $format = PhoneNumberFormat::E164, $region = 'RU')
{
return self::phoneUtil()->format(self::phoneUtil()->parse($phone, $region), $format);
}
|
php
|
public static function format($phone, $format = PhoneNumberFormat::E164, $region = 'RU')
{
return self::phoneUtil()->format(self::phoneUtil()->parse($phone, $region), $format);
}
|
[
"public",
"static",
"function",
"format",
"(",
"$",
"phone",
",",
"$",
"format",
"=",
"PhoneNumberFormat",
"::",
"E164",
",",
"$",
"region",
"=",
"'RU'",
")",
"{",
"return",
"self",
"::",
"phoneUtil",
"(",
")",
"->",
"format",
"(",
"self",
"::",
"phoneUtil",
"(",
")",
"->",
"parse",
"(",
"$",
"phone",
",",
"$",
"region",
")",
",",
"$",
"format",
")",
";",
"}"
] |
Formats number to the desired format
@param $phone
@param int $format
@param string $region
@return string
|
[
"Formats",
"number",
"to",
"the",
"desired",
"format"
] |
01444ef39803b05321f75379198d88af9307f72f
|
https://github.com/omnilight/yii2-phonenumbers/blob/01444ef39803b05321f75379198d88af9307f72f/PhoneNumber.php#L22-L25
|
234,572
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php
|
Zend_Http_Client.getUri
|
public function getUri($as_string = false)
{
if ($as_string && $this->uri instanceof Zend_Uri_Http) {
return $this->uri->__toString();
} else {
return $this->uri;
}
}
|
php
|
public function getUri($as_string = false)
{
if ($as_string && $this->uri instanceof Zend_Uri_Http) {
return $this->uri->__toString();
} else {
return $this->uri;
}
}
|
[
"public",
"function",
"getUri",
"(",
"$",
"as_string",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"as_string",
"&&",
"$",
"this",
"->",
"uri",
"instanceof",
"Zend_Uri_Http",
")",
"{",
"return",
"$",
"this",
"->",
"uri",
"->",
"__toString",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"uri",
";",
"}",
"}"
] |
Get the URI for the next request
@param boolean $as_string If true, will return the URI as a string
@return Zend_Uri_Http|string
|
[
"Get",
"the",
"URI",
"for",
"the",
"next",
"request"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php#L280-L287
|
234,573
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php
|
Zend_Http_Client.setMethod
|
public function setMethod($method = self::GET)
{
$regex = '/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/';
if (! preg_match($regex, $method)) {
/**
* @see Zend_Http_Client_Exception
*/
include_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception("'{$method}' is not a valid HTTP request method.");
}
if ($method == self::POST && $this->enctype === null) {
$this->setEncType(self::ENC_URLENCODED);
}
$this->method = $method;
return $this;
}
|
php
|
public function setMethod($method = self::GET)
{
$regex = '/^[^\x00-\x1f\x7f-\xff\(\)<>@,;:\\\\"\/\[\]\?={}\s]+$/';
if (! preg_match($regex, $method)) {
/**
* @see Zend_Http_Client_Exception
*/
include_once 'Zend/Http/Client/Exception.php';
throw new Zend_Http_Client_Exception("'{$method}' is not a valid HTTP request method.");
}
if ($method == self::POST && $this->enctype === null) {
$this->setEncType(self::ENC_URLENCODED);
}
$this->method = $method;
return $this;
}
|
[
"public",
"function",
"setMethod",
"(",
"$",
"method",
"=",
"self",
"::",
"GET",
")",
"{",
"$",
"regex",
"=",
"'/^[^\\x00-\\x1f\\x7f-\\xff\\(\\)<>@,;:\\\\\\\\\"\\/\\[\\]\\?={}\\s]+$/'",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"method",
")",
")",
"{",
"/**\n * @see Zend_Http_Client_Exception \n*/",
"include_once",
"'Zend/Http/Client/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Client_Exception",
"(",
"\"'{$method}' is not a valid HTTP request method.\"",
")",
";",
"}",
"if",
"(",
"$",
"method",
"==",
"self",
"::",
"POST",
"&&",
"$",
"this",
"->",
"enctype",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setEncType",
"(",
"self",
"::",
"ENC_URLENCODED",
")",
";",
"}",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the next request's method
Validated the passed method and sets it. If we have files set for
POST requests, and the new method is not POST, the files are silently
dropped.
@param string $method
@return Zend_Http_Client
@throws Zend_Http_Client_Exception
|
[
"Set",
"the",
"next",
"request",
"s",
"method"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php#L324-L342
|
234,574
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php
|
Zend_Http_Client.setParameterGet
|
public function setParameterGet($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->_setParameter('GET', $k, $v);
}
} else {
$this->_setParameter('GET', $name, $value);
}
return $this;
}
|
php
|
public function setParameterGet($name, $value = null)
{
if (is_array($name)) {
foreach ($name as $k => $v) {
$this->_setParameter('GET', $k, $v);
}
} else {
$this->_setParameter('GET', $name, $value);
}
return $this;
}
|
[
"public",
"function",
"setParameterGet",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"_setParameter",
"(",
"'GET'",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_setParameter",
"(",
"'GET'",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set a GET parameter for the request. Wrapper around _setParameter
@param string|array $name
@param string $value
@return Zend_Http_Client
|
[
"Set",
"a",
"GET",
"parameter",
"for",
"the",
"request",
".",
"Wrapper",
"around",
"_setParameter"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php#L433-L444
|
234,575
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php
|
Zend_Http_Client._detectFileMimeType
|
protected function _detectFileMimeType($file)
{
$type = null;
// First try with fileinfo functions
if (function_exists('finfo_open')) {
if (self::$_fileInfoDb === null) {
self::$_fileInfoDb = @finfo_open(FILEINFO_MIME);
}
if (self::$_fileInfoDb) {
$type = finfo_file(self::$_fileInfoDb, $file);
}
} elseif (function_exists('mime_content_type')) {
$type = mime_content_type($file);
}
// Fallback to the default application/octet-stream
if (! $type) {
$type = 'application/octet-stream';
}
return $type;
}
|
php
|
protected function _detectFileMimeType($file)
{
$type = null;
// First try with fileinfo functions
if (function_exists('finfo_open')) {
if (self::$_fileInfoDb === null) {
self::$_fileInfoDb = @finfo_open(FILEINFO_MIME);
}
if (self::$_fileInfoDb) {
$type = finfo_file(self::$_fileInfoDb, $file);
}
} elseif (function_exists('mime_content_type')) {
$type = mime_content_type($file);
}
// Fallback to the default application/octet-stream
if (! $type) {
$type = 'application/octet-stream';
}
return $type;
}
|
[
"protected",
"function",
"_detectFileMimeType",
"(",
"$",
"file",
")",
"{",
"$",
"type",
"=",
"null",
";",
"// First try with fileinfo functions",
"if",
"(",
"function_exists",
"(",
"'finfo_open'",
")",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_fileInfoDb",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"_fileInfoDb",
"=",
"@",
"finfo_open",
"(",
"FILEINFO_MIME",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"_fileInfoDb",
")",
"{",
"$",
"type",
"=",
"finfo_file",
"(",
"self",
"::",
"$",
"_fileInfoDb",
",",
"$",
"file",
")",
";",
"}",
"}",
"elseif",
"(",
"function_exists",
"(",
"'mime_content_type'",
")",
")",
"{",
"$",
"type",
"=",
"mime_content_type",
"(",
"$",
"file",
")",
";",
"}",
"// Fallback to the default application/octet-stream",
"if",
"(",
"!",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"'application/octet-stream'",
";",
"}",
"return",
"$",
"type",
";",
"}"
] |
Attempt to detect the MIME type of a file using available extensions
This method will try to detect the MIME type of a file. If the fileinfo
extension is available, it will be used. If not, the mime_magic
extension which is deprected but is still available in many PHP setups
will be tried.
If neither extension is available, the default application/octet-stream
MIME type will be returned
@param string $file File path
@return string MIME type
|
[
"Attempt",
"to",
"detect",
"the",
"MIME",
"type",
"of",
"a",
"file",
"using",
"available",
"extensions"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Client.php#L1158-L1182
|
234,576
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.getLines
|
public function getLines($limit = null, $offset = 0, $filter = null)
{
$lines = clone $this->lines;
if ($filter !== null) {
$logger = isset($filter['logger']) ? $filter['logger'] : null;
$minLevel = isset($filter['level']) ? $filter['level'] : 0;
$text = (isset($filter['text']) && $filter['text'] != '') ? $filter['text'] : null;
$searchMeta = isset($filter['search_meta']) ? ($filter['search_meta']) : true;
foreach ($lines as $line) {
if (
!static::logLineHasLogger($logger, $line)
|| !static::logLineHasMinLevel($minLevel, $line)
|| !static::logLineHasText($text, $line, $searchMeta)
) {
$lines->removeElement($line);
}
}
}
if (null !== $limit) {
return array_values($lines->slice($offset, $limit));
}
return array_values($lines->toArray());
}
|
php
|
public function getLines($limit = null, $offset = 0, $filter = null)
{
$lines = clone $this->lines;
if ($filter !== null) {
$logger = isset($filter['logger']) ? $filter['logger'] : null;
$minLevel = isset($filter['level']) ? $filter['level'] : 0;
$text = (isset($filter['text']) && $filter['text'] != '') ? $filter['text'] : null;
$searchMeta = isset($filter['search_meta']) ? ($filter['search_meta']) : true;
foreach ($lines as $line) {
if (
!static::logLineHasLogger($logger, $line)
|| !static::logLineHasMinLevel($minLevel, $line)
|| !static::logLineHasText($text, $line, $searchMeta)
) {
$lines->removeElement($line);
}
}
}
if (null !== $limit) {
return array_values($lines->slice($offset, $limit));
}
return array_values($lines->toArray());
}
|
[
"public",
"function",
"getLines",
"(",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"lines",
"=",
"clone",
"$",
"this",
"->",
"lines",
";",
"if",
"(",
"$",
"filter",
"!==",
"null",
")",
"{",
"$",
"logger",
"=",
"isset",
"(",
"$",
"filter",
"[",
"'logger'",
"]",
")",
"?",
"$",
"filter",
"[",
"'logger'",
"]",
":",
"null",
";",
"$",
"minLevel",
"=",
"isset",
"(",
"$",
"filter",
"[",
"'level'",
"]",
")",
"?",
"$",
"filter",
"[",
"'level'",
"]",
":",
"0",
";",
"$",
"text",
"=",
"(",
"isset",
"(",
"$",
"filter",
"[",
"'text'",
"]",
")",
"&&",
"$",
"filter",
"[",
"'text'",
"]",
"!=",
"''",
")",
"?",
"$",
"filter",
"[",
"'text'",
"]",
":",
"null",
";",
"$",
"searchMeta",
"=",
"isset",
"(",
"$",
"filter",
"[",
"'search_meta'",
"]",
")",
"?",
"(",
"$",
"filter",
"[",
"'search_meta'",
"]",
")",
":",
"true",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"logLineHasLogger",
"(",
"$",
"logger",
",",
"$",
"line",
")",
"||",
"!",
"static",
"::",
"logLineHasMinLevel",
"(",
"$",
"minLevel",
",",
"$",
"line",
")",
"||",
"!",
"static",
"::",
"logLineHasText",
"(",
"$",
"text",
",",
"$",
"line",
",",
"$",
"searchMeta",
")",
")",
"{",
"$",
"lines",
"->",
"removeElement",
"(",
"$",
"line",
")",
";",
"}",
"}",
"}",
"if",
"(",
"null",
"!==",
"$",
"limit",
")",
"{",
"return",
"array_values",
"(",
"$",
"lines",
"->",
"slice",
"(",
"$",
"offset",
",",
"$",
"limit",
")",
")",
";",
"}",
"return",
"array_values",
"(",
"$",
"lines",
"->",
"toArray",
"(",
")",
")",
";",
"}"
] |
Returns log lines, either all or paginated and or filtered.
@param int|null $limit Defines how many lines are returned.
@param int $offset Defines the offset for returning lines. Offset 0 starts at the first line.
@param array|null $filter Filter the log lines before returning and applying pagination. Can contain keys logger,
level, text and searchMeta (should context and extra fields also be searched)
@return array
|
[
"Returns",
"log",
"lines",
"either",
"all",
"or",
"paginated",
"and",
"or",
"filtered",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L95-L119
|
234,577
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.logLineHasLogger
|
private static function logLineHasLogger($logger, $line)
{
if ($logger === null) {
return true;
}
return array_key_exists('logger', $line) && $line['logger'] == $logger;
}
|
php
|
private static function logLineHasLogger($logger, $line)
{
if ($logger === null) {
return true;
}
return array_key_exists('logger', $line) && $line['logger'] == $logger;
}
|
[
"private",
"static",
"function",
"logLineHasLogger",
"(",
"$",
"logger",
",",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"logger",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"array_key_exists",
"(",
"'logger'",
",",
"$",
"line",
")",
"&&",
"$",
"line",
"[",
"'logger'",
"]",
"==",
"$",
"logger",
";",
"}"
] |
Internal filtering method for determining whether a log line belongs to a specific logger.
@param string $logger
@param array $line
@return bool
|
[
"Internal",
"filtering",
"method",
"for",
"determining",
"whether",
"a",
"log",
"line",
"belongs",
"to",
"a",
"specific",
"logger",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L129-L136
|
234,578
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.logLineHasMinLevel
|
private static function logLineHasMinLevel($minLevel, $line)
{
if ($minLevel == 0) {
return true;
}
return array_key_exists('level', $line) && static::getLevelNumber($line['level']) >= $minLevel;
}
|
php
|
private static function logLineHasMinLevel($minLevel, $line)
{
if ($minLevel == 0) {
return true;
}
return array_key_exists('level', $line) && static::getLevelNumber($line['level']) >= $minLevel;
}
|
[
"private",
"static",
"function",
"logLineHasMinLevel",
"(",
"$",
"minLevel",
",",
"$",
"line",
")",
"{",
"if",
"(",
"$",
"minLevel",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"array_key_exists",
"(",
"'level'",
",",
"$",
"line",
")",
"&&",
"static",
"::",
"getLevelNumber",
"(",
"$",
"line",
"[",
"'level'",
"]",
")",
">=",
"$",
"minLevel",
";",
"}"
] |
Internal filtering method for determining whether a log line has a specific minimal log level.
@param int $minLevel
@param array $line
@return bool
|
[
"Internal",
"filtering",
"method",
"for",
"determining",
"whether",
"a",
"log",
"line",
"has",
"a",
"specific",
"minimal",
"log",
"level",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L146-L153
|
234,579
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.logLineHasText
|
private static function logLineHasText($keyword, $line, $searchMeta = true)
{
if ($keyword === null) {
return true;
}
if (array_key_exists('message', $line) && strpos(strtolower($line['message']), strtolower($keyword)) !== false) {
return true;
}
if (array_key_exists('date', $line) && strpos(strtolower($line['date']), strtolower($keyword)) !== false) {
return true;
}
if ($searchMeta) {
if (array_key_exists('context', $line)) {
$context = $line['context'];
if (array_key_exists(strtolower($keyword), $context)) {
return true;
}
foreach ($context as $content) {
if (strpos(strtolower($content), strtolower($keyword)) !== false) {
return true;
}
}
}
if (array_key_exists('extra', $line)) {
$extra = $line['extra'];
if (array_key_exists($keyword, $extra)) {
return true;
}
foreach ($extra as $content) {
if (strpos(strtolower($content), strtolower($keyword)) !== false) {
return true;
}
}
}
}
return false;
}
|
php
|
private static function logLineHasText($keyword, $line, $searchMeta = true)
{
if ($keyword === null) {
return true;
}
if (array_key_exists('message', $line) && strpos(strtolower($line['message']), strtolower($keyword)) !== false) {
return true;
}
if (array_key_exists('date', $line) && strpos(strtolower($line['date']), strtolower($keyword)) !== false) {
return true;
}
if ($searchMeta) {
if (array_key_exists('context', $line)) {
$context = $line['context'];
if (array_key_exists(strtolower($keyword), $context)) {
return true;
}
foreach ($context as $content) {
if (strpos(strtolower($content), strtolower($keyword)) !== false) {
return true;
}
}
}
if (array_key_exists('extra', $line)) {
$extra = $line['extra'];
if (array_key_exists($keyword, $extra)) {
return true;
}
foreach ($extra as $content) {
if (strpos(strtolower($content), strtolower($keyword)) !== false) {
return true;
}
}
}
}
return false;
}
|
[
"private",
"static",
"function",
"logLineHasText",
"(",
"$",
"keyword",
",",
"$",
"line",
",",
"$",
"searchMeta",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"keyword",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'message'",
",",
"$",
"line",
")",
"&&",
"strpos",
"(",
"strtolower",
"(",
"$",
"line",
"[",
"'message'",
"]",
")",
",",
"strtolower",
"(",
"$",
"keyword",
")",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'date'",
",",
"$",
"line",
")",
"&&",
"strpos",
"(",
"strtolower",
"(",
"$",
"line",
"[",
"'date'",
"]",
")",
",",
"strtolower",
"(",
"$",
"keyword",
")",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"searchMeta",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'context'",
",",
"$",
"line",
")",
")",
"{",
"$",
"context",
"=",
"$",
"line",
"[",
"'context'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"strtolower",
"(",
"$",
"keyword",
")",
",",
"$",
"context",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"context",
"as",
"$",
"content",
")",
"{",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"content",
")",
",",
"strtolower",
"(",
"$",
"keyword",
")",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"array_key_exists",
"(",
"'extra'",
",",
"$",
"line",
")",
")",
"{",
"$",
"extra",
"=",
"$",
"line",
"[",
"'extra'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keyword",
",",
"$",
"extra",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"extra",
"as",
"$",
"content",
")",
"{",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"content",
")",
",",
"strtolower",
"(",
"$",
"keyword",
")",
")",
"!==",
"false",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Internal filtering method for determining whether a log line contains a specific string.
@param string $keyword
@param array $line
@param bool $searchMeta
@return bool
|
[
"Internal",
"filtering",
"method",
"for",
"determining",
"whether",
"a",
"log",
"line",
"contains",
"a",
"specific",
"string",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L164-L201
|
234,580
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.countLines
|
public function countLines($filter = null)
{
if ($filter !== null) {
return count($this->getLines(null, 0, $filter));
}
return $this->lines->count();
}
|
php
|
public function countLines($filter = null)
{
if ($filter !== null) {
return count($this->getLines(null, 0, $filter));
}
return $this->lines->count();
}
|
[
"public",
"function",
"countLines",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"filter",
"!==",
"null",
")",
"{",
"return",
"count",
"(",
"$",
"this",
"->",
"getLines",
"(",
"null",
",",
"0",
",",
"$",
"filter",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"lines",
"->",
"count",
"(",
")",
";",
"}"
] |
Returns the number of lines in the log file.
@param array|null $filter
@return int
|
[
"Returns",
"the",
"number",
"of",
"lines",
"in",
"the",
"log",
"file",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L218-L225
|
234,581
|
Syonix/log-viewer-lib
|
lib/LogFile.php
|
LogFile.getLevelNumber
|
public static function getLevelNumber($level)
{
$levels = Logger::getLevels();
if (!isset($levels[$level])) {
throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', $levels));
}
return $levels[$level];
}
|
php
|
public static function getLevelNumber($level)
{
$levels = Logger::getLevels();
if (!isset($levels[$level])) {
throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', $levels));
}
return $levels[$level];
}
|
[
"public",
"static",
"function",
"getLevelNumber",
"(",
"$",
"level",
")",
"{",
"$",
"levels",
"=",
"Logger",
"::",
"getLevels",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"levels",
"[",
"$",
"level",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Level \"'",
".",
"$",
"level",
".",
"'\" is not defined, use one of: '",
".",
"implode",
"(",
"', '",
",",
"$",
"levels",
")",
")",
";",
"}",
"return",
"$",
"levels",
"[",
"$",
"level",
"]",
";",
"}"
] |
Returns the associated number for a log level string.
@param string $level
@return int
|
[
"Returns",
"the",
"associated",
"number",
"for",
"a",
"log",
"level",
"string",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/LogFile.php#L264-L273
|
234,582
|
damonjones/Vebra-PHP-API-Wrapper
|
lib/YDD/Vebra/TokenStorage/File.php
|
File.load
|
protected function load()
{
if (false !== ($token = @file_get_contents($this->getFilename()))) {
$this->token = trim($token);
} else {
throw new \Exception(sprintf('Token could not be loaded from "%s"', $this->getFilename()));
}
}
|
php
|
protected function load()
{
if (false !== ($token = @file_get_contents($this->getFilename()))) {
$this->token = trim($token);
} else {
throw new \Exception(sprintf('Token could not be loaded from "%s"', $this->getFilename()));
}
}
|
[
"protected",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"token",
"=",
"@",
"file_get_contents",
"(",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
")",
")",
"{",
"$",
"this",
"->",
"token",
"=",
"trim",
"(",
"$",
"token",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Token could not be loaded from \"%s\"'",
",",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Load the token from a file
|
[
"Load",
"the",
"token",
"from",
"a",
"file"
] |
9de0fb5181a6e4b90700027ffaa6b2e658d279c2
|
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/TokenStorage/File.php#L65-L72
|
234,583
|
damonjones/Vebra-PHP-API-Wrapper
|
lib/YDD/Vebra/TokenStorage/File.php
|
File.save
|
protected function save()
{
if (false === ($result = @file_put_contents($this->getFilename(), $this->token))) {
throw new \Exception(sprintf('Token could not be saved to "%s"', $this->getFilename()));
}
}
|
php
|
protected function save()
{
if (false === ($result = @file_put_contents($this->getFilename(), $this->token))) {
throw new \Exception(sprintf('Token could not be saved to "%s"', $this->getFilename()));
}
}
|
[
"protected",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"result",
"=",
"@",
"file_put_contents",
"(",
"$",
"this",
"->",
"getFilename",
"(",
")",
",",
"$",
"this",
"->",
"token",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Token could not be saved to \"%s\"'",
",",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Save the token to a file
|
[
"Save",
"the",
"token",
"to",
"a",
"file"
] |
9de0fb5181a6e4b90700027ffaa6b2e658d279c2
|
https://github.com/damonjones/Vebra-PHP-API-Wrapper/blob/9de0fb5181a6e4b90700027ffaa6b2e658d279c2/lib/YDD/Vebra/TokenStorage/File.php#L77-L82
|
234,584
|
BusinessMastery/omnipay-mobilpay
|
src/BusinessMastery/Mobilpay/Message/PurchaseRequest.php
|
PurchaseRequest.getData
|
public function getData()
{
$this->validate('amount', 'currency', 'orderId', 'confirmUrl', 'returnUrl', 'details');
$envKey = $envData = null;
$publicKey = $this->getParameter('publicKey');
if (! $publicKey) {
throw new MissingKeyException("Missing public key path parameter");
}
$request = new Card();
$request->signature = $this->getMerchantId();
$request->orderId = $this->getParameter('orderId');
$request->confirmUrl = $this->getParameter('confirmUrl');
$request->returnUrl = $this->getParameter('returnUrl');
$request->params = $this->getParameter('params') ?: [];
if ($this->getParameter('recurrence')) {
$request->recurrence = new Recurrence();
$request->recurrence->payments_no = $this->getParameter('paymentNo');
$request->recurrence->interval_day = $this->getParameter('intervalDay');
}
$request->invoice = new Invoice();
$request->invoice->currency = $this->getParameter('currency');
$request->invoice->amount = $this->getParameter('amount');
$request->invoice->details = $this->getParameter('details');
if ($getBillingAddress = $this->getBillingAddress()) {
$request->invoice->setBillingAddress($this->makeBillingAddress($getBillingAddress));
}
$request->encrypt($this->getParameter('publicKey'));
$data = [
'env_key' => $request->getEnvKey(),
'data' => $request->getEncData()
];
return $data;
}
|
php
|
public function getData()
{
$this->validate('amount', 'currency', 'orderId', 'confirmUrl', 'returnUrl', 'details');
$envKey = $envData = null;
$publicKey = $this->getParameter('publicKey');
if (! $publicKey) {
throw new MissingKeyException("Missing public key path parameter");
}
$request = new Card();
$request->signature = $this->getMerchantId();
$request->orderId = $this->getParameter('orderId');
$request->confirmUrl = $this->getParameter('confirmUrl');
$request->returnUrl = $this->getParameter('returnUrl');
$request->params = $this->getParameter('params') ?: [];
if ($this->getParameter('recurrence')) {
$request->recurrence = new Recurrence();
$request->recurrence->payments_no = $this->getParameter('paymentNo');
$request->recurrence->interval_day = $this->getParameter('intervalDay');
}
$request->invoice = new Invoice();
$request->invoice->currency = $this->getParameter('currency');
$request->invoice->amount = $this->getParameter('amount');
$request->invoice->details = $this->getParameter('details');
if ($getBillingAddress = $this->getBillingAddress()) {
$request->invoice->setBillingAddress($this->makeBillingAddress($getBillingAddress));
}
$request->encrypt($this->getParameter('publicKey'));
$data = [
'env_key' => $request->getEnvKey(),
'data' => $request->getEncData()
];
return $data;
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"'amount'",
",",
"'currency'",
",",
"'orderId'",
",",
"'confirmUrl'",
",",
"'returnUrl'",
",",
"'details'",
")",
";",
"$",
"envKey",
"=",
"$",
"envData",
"=",
"null",
";",
"$",
"publicKey",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'publicKey'",
")",
";",
"if",
"(",
"!",
"$",
"publicKey",
")",
"{",
"throw",
"new",
"MissingKeyException",
"(",
"\"Missing public key path parameter\"",
")",
";",
"}",
"$",
"request",
"=",
"new",
"Card",
"(",
")",
";",
"$",
"request",
"->",
"signature",
"=",
"$",
"this",
"->",
"getMerchantId",
"(",
")",
";",
"$",
"request",
"->",
"orderId",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'orderId'",
")",
";",
"$",
"request",
"->",
"confirmUrl",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'confirmUrl'",
")",
";",
"$",
"request",
"->",
"returnUrl",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'returnUrl'",
")",
";",
"$",
"request",
"->",
"params",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'params'",
")",
"?",
":",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'recurrence'",
")",
")",
"{",
"$",
"request",
"->",
"recurrence",
"=",
"new",
"Recurrence",
"(",
")",
";",
"$",
"request",
"->",
"recurrence",
"->",
"payments_no",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'paymentNo'",
")",
";",
"$",
"request",
"->",
"recurrence",
"->",
"interval_day",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'intervalDay'",
")",
";",
"}",
"$",
"request",
"->",
"invoice",
"=",
"new",
"Invoice",
"(",
")",
";",
"$",
"request",
"->",
"invoice",
"->",
"currency",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'currency'",
")",
";",
"$",
"request",
"->",
"invoice",
"->",
"amount",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'amount'",
")",
";",
"$",
"request",
"->",
"invoice",
"->",
"details",
"=",
"$",
"this",
"->",
"getParameter",
"(",
"'details'",
")",
";",
"if",
"(",
"$",
"getBillingAddress",
"=",
"$",
"this",
"->",
"getBillingAddress",
"(",
")",
")",
"{",
"$",
"request",
"->",
"invoice",
"->",
"setBillingAddress",
"(",
"$",
"this",
"->",
"makeBillingAddress",
"(",
"$",
"getBillingAddress",
")",
")",
";",
"}",
"$",
"request",
"->",
"encrypt",
"(",
"$",
"this",
"->",
"getParameter",
"(",
"'publicKey'",
")",
")",
";",
"$",
"data",
"=",
"[",
"'env_key'",
"=>",
"$",
"request",
"->",
"getEnvKey",
"(",
")",
",",
"'data'",
"=>",
"$",
"request",
"->",
"getEncData",
"(",
")",
"]",
";",
"return",
"$",
"data",
";",
"}"
] |
Build encrypted request data
@return array
@throws MissingKeyException
@throws \Exception
@throws \Omnipay\Common\Exception\InvalidRequestException
|
[
"Build",
"encrypted",
"request",
"data"
] |
e9013933e8d12bd69c7def4c88b293f9561ab6e1
|
https://github.com/BusinessMastery/omnipay-mobilpay/blob/e9013933e8d12bd69c7def4c88b293f9561ab6e1/src/BusinessMastery/Mobilpay/Message/PurchaseRequest.php#L224-L265
|
234,585
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Builder/FormBuilder.php
|
FormBuilder.create
|
public function create($input)
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$primaryKey = (new $model)->getKeyName();
$this->setInput($input);
// Field pre update
foreach ($mapper->getFields() as $field) {
$field->preUpdate();
$input = $this->getInput();
// Is this a multiple field?
if ($field->isMultiple()) {
$value = Value::encode(Config::get('bauhaus::admin.multiple-serializer'), $input[$field->getName()]);
$this->setInputVariable($field->getName(), $value);
}
if ($field->hasSaving()) {
$saving = $field->getSaving();
$this->setInputVariable($field->getName(), $saving($input[$field->getName()]));
}
}
// Model before create hook
if (method_exists($admin, 'beforeCreate')) {
$admin->beforeCreate($input);
}
// Validate
if (property_exists($model, 'rules')) {
$validator = Validator::make($this->getInput(), $model::$rules);
if ($validator->fails()) {
return $validator;
}
}
// Model create hook
if (method_exists($admin, 'create')) {
$model = $admin->create($this->getInput());
} else {
$model = $model::create($this->getInput());
}
// Set the primary id from the `new` model
$this->setIdentifier($model->{$primaryKey});
// Field post update
foreach ($mapper->getFields() as $field) {
$field->postUpdate($this->getInput());
}
// Model after create hook
if (method_exists($admin, 'afterCreate')) {
$result = $admin->afterCreate($this->getInput());
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
php
|
public function create($input)
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$primaryKey = (new $model)->getKeyName();
$this->setInput($input);
// Field pre update
foreach ($mapper->getFields() as $field) {
$field->preUpdate();
$input = $this->getInput();
// Is this a multiple field?
if ($field->isMultiple()) {
$value = Value::encode(Config::get('bauhaus::admin.multiple-serializer'), $input[$field->getName()]);
$this->setInputVariable($field->getName(), $value);
}
if ($field->hasSaving()) {
$saving = $field->getSaving();
$this->setInputVariable($field->getName(), $saving($input[$field->getName()]));
}
}
// Model before create hook
if (method_exists($admin, 'beforeCreate')) {
$admin->beforeCreate($input);
}
// Validate
if (property_exists($model, 'rules')) {
$validator = Validator::make($this->getInput(), $model::$rules);
if ($validator->fails()) {
return $validator;
}
}
// Model create hook
if (method_exists($admin, 'create')) {
$model = $admin->create($this->getInput());
} else {
$model = $model::create($this->getInput());
}
// Set the primary id from the `new` model
$this->setIdentifier($model->{$primaryKey});
// Field post update
foreach ($mapper->getFields() as $field) {
$field->postUpdate($this->getInput());
}
// Model after create hook
if (method_exists($admin, 'afterCreate')) {
$result = $admin->afterCreate($this->getInput());
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
[
"public",
"function",
"create",
"(",
"$",
"input",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"$",
"admin",
"=",
"$",
"mapper",
"->",
"getAdmin",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"primaryKey",
"=",
"(",
"new",
"$",
"model",
")",
"->",
"getKeyName",
"(",
")",
";",
"$",
"this",
"->",
"setInput",
"(",
"$",
"input",
")",
";",
"// Field pre update",
"foreach",
"(",
"$",
"mapper",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"preUpdate",
"(",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"getInput",
"(",
")",
";",
"// Is this a multiple field?",
"if",
"(",
"$",
"field",
"->",
"isMultiple",
"(",
")",
")",
"{",
"$",
"value",
"=",
"Value",
"::",
"encode",
"(",
"Config",
"::",
"get",
"(",
"'bauhaus::admin.multiple-serializer'",
")",
",",
"$",
"input",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"setInputVariable",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"field",
"->",
"hasSaving",
"(",
")",
")",
"{",
"$",
"saving",
"=",
"$",
"field",
"->",
"getSaving",
"(",
")",
";",
"$",
"this",
"->",
"setInputVariable",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"saving",
"(",
"$",
"input",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
")",
")",
";",
"}",
"}",
"// Model before create hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'beforeCreate'",
")",
")",
"{",
"$",
"admin",
"->",
"beforeCreate",
"(",
"$",
"input",
")",
";",
"}",
"// Validate",
"if",
"(",
"property_exists",
"(",
"$",
"model",
",",
"'rules'",
")",
")",
"{",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
",",
"$",
"model",
"::",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"$",
"validator",
";",
"}",
"}",
"// Model create hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'create'",
")",
")",
"{",
"$",
"model",
"=",
"$",
"admin",
"->",
"create",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"model",
"::",
"create",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"// Set the primary id from the `new` model",
"$",
"this",
"->",
"setIdentifier",
"(",
"$",
"model",
"->",
"{",
"$",
"primaryKey",
"}",
")",
";",
"// Field post update",
"foreach",
"(",
"$",
"mapper",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"postUpdate",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"// Model after create hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'afterCreate'",
")",
")",
"{",
"$",
"result",
"=",
"$",
"admin",
"->",
"afterCreate",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"RedirectResponse",
")",
"{",
"$",
"result",
"->",
"send",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Create a new model from input.
@param Input $input
@access public
@return FormBuilder
|
[
"Create",
"a",
"new",
"model",
"from",
"input",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Builder/FormBuilder.php#L203-L268
|
234,586
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Builder/FormBuilder.php
|
FormBuilder.update
|
public function update($input)
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$this->setInput($input);
// Field pre update
foreach ($this->getMapper()->getFields() as $field) {
$field->preUpdate();
// Is this a multiple field?
if ($field->isMultiple()) {
$value = Value::encode(Config::get('bauhaus::admin.multiple-serializer'), $input[$field->getName()]);
$this->setInputVariable($field->getName(), $value);
}
if ($field->hasSaving()) {
$saving = $field->getSaving();
$this->setInputVariable($field->getName(), $saving($input[$field->getName()]));
}
}
// Model before update hook
if (method_exists($admin, 'beforeUpdate')) {
$admin->beforeUpdate($input);
}
// Validate
if (property_exists($model, 'rules')) {
$validator = Validator::make($this->getInput(), $model::$rules);
if ($validator->fails()) {
return $validator;
}
}
// Model update hook
if (method_exists($this->getMapper()->getAdmin(), 'update')) {
$this->getMapper()->getAdmin()->update($this->getInput());
} else {
$model::find($this->getIdentifier())
->update($this->getInput());
}
// Field post update
foreach ($this->getMapper()->getFields() as $field) {
$field->postUpdate($this->getInput());
}
// Model after update hook
if (method_exists($admin, 'afterCreate')) {
$result = $admin->afterUpdate($this->getInput());
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
php
|
public function update($input)
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$this->setInput($input);
// Field pre update
foreach ($this->getMapper()->getFields() as $field) {
$field->preUpdate();
// Is this a multiple field?
if ($field->isMultiple()) {
$value = Value::encode(Config::get('bauhaus::admin.multiple-serializer'), $input[$field->getName()]);
$this->setInputVariable($field->getName(), $value);
}
if ($field->hasSaving()) {
$saving = $field->getSaving();
$this->setInputVariable($field->getName(), $saving($input[$field->getName()]));
}
}
// Model before update hook
if (method_exists($admin, 'beforeUpdate')) {
$admin->beforeUpdate($input);
}
// Validate
if (property_exists($model, 'rules')) {
$validator = Validator::make($this->getInput(), $model::$rules);
if ($validator->fails()) {
return $validator;
}
}
// Model update hook
if (method_exists($this->getMapper()->getAdmin(), 'update')) {
$this->getMapper()->getAdmin()->update($this->getInput());
} else {
$model::find($this->getIdentifier())
->update($this->getInput());
}
// Field post update
foreach ($this->getMapper()->getFields() as $field) {
$field->postUpdate($this->getInput());
}
// Model after update hook
if (method_exists($admin, 'afterCreate')) {
$result = $admin->afterUpdate($this->getInput());
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
[
"public",
"function",
"update",
"(",
"$",
"input",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"$",
"admin",
"=",
"$",
"mapper",
"->",
"getAdmin",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"this",
"->",
"setInput",
"(",
"$",
"input",
")",
";",
"// Field pre update",
"foreach",
"(",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"preUpdate",
"(",
")",
";",
"// Is this a multiple field?",
"if",
"(",
"$",
"field",
"->",
"isMultiple",
"(",
")",
")",
"{",
"$",
"value",
"=",
"Value",
"::",
"encode",
"(",
"Config",
"::",
"get",
"(",
"'bauhaus::admin.multiple-serializer'",
")",
",",
"$",
"input",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"setInputVariable",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"field",
"->",
"hasSaving",
"(",
")",
")",
"{",
"$",
"saving",
"=",
"$",
"field",
"->",
"getSaving",
"(",
")",
";",
"$",
"this",
"->",
"setInputVariable",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"saving",
"(",
"$",
"input",
"[",
"$",
"field",
"->",
"getName",
"(",
")",
"]",
")",
")",
";",
"}",
"}",
"// Model before update hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'beforeUpdate'",
")",
")",
"{",
"$",
"admin",
"->",
"beforeUpdate",
"(",
"$",
"input",
")",
";",
"}",
"// Validate",
"if",
"(",
"property_exists",
"(",
"$",
"model",
",",
"'rules'",
")",
")",
"{",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
",",
"$",
"model",
"::",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"$",
"validator",
";",
"}",
"}",
"// Model update hook",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getAdmin",
"(",
")",
",",
"'update'",
")",
")",
"{",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getAdmin",
"(",
")",
"->",
"update",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"model",
"::",
"find",
"(",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
")",
"->",
"update",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"// Field post update",
"foreach",
"(",
"$",
"this",
"->",
"getMapper",
"(",
")",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"postUpdate",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"}",
"// Model after update hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'afterCreate'",
")",
")",
"{",
"$",
"result",
"=",
"$",
"admin",
"->",
"afterUpdate",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"RedirectResponse",
")",
"{",
"$",
"result",
"->",
"send",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Update a model from input.
@param Input $input
@access public
@return FormBuilder
|
[
"Update",
"a",
"model",
"from",
"input",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Builder/FormBuilder.php#L278-L338
|
234,587
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Builder/FormBuilder.php
|
FormBuilder.destroy
|
public function destroy()
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$model = $model::find($this->getIdentifier());
// Model before delete hook
if (method_exists($admin, 'beforeDelete')) {
$admin->beforeDelete($model);
}
// Model delete hook
if (method_exists($admin, 'deleting')) {
$admin->deleting($model);
} else {
$model->delete();
}
// Model after delete hook
if (method_exists($admin, 'afterDelete')) {
$result = $admin->afterDelete($model);
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
php
|
public function destroy()
{
$mapper = $this->getMapper();
$admin = $mapper->getAdmin();
$model = $this->getModel();
$model = $model::find($this->getIdentifier());
// Model before delete hook
if (method_exists($admin, 'beforeDelete')) {
$admin->beforeDelete($model);
}
// Model delete hook
if (method_exists($admin, 'deleting')) {
$admin->deleting($model);
} else {
$model->delete();
}
// Model after delete hook
if (method_exists($admin, 'afterDelete')) {
$result = $admin->afterDelete($model);
if ($result instanceof \Illuminate\Http\RedirectResponse) {
$result->send();
}
}
return $this;
}
|
[
"public",
"function",
"destroy",
"(",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"$",
"admin",
"=",
"$",
"mapper",
"->",
"getAdmin",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
";",
"$",
"model",
"=",
"$",
"model",
"::",
"find",
"(",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
")",
";",
"// Model before delete hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'beforeDelete'",
")",
")",
"{",
"$",
"admin",
"->",
"beforeDelete",
"(",
"$",
"model",
")",
";",
"}",
"// Model delete hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'deleting'",
")",
")",
"{",
"$",
"admin",
"->",
"deleting",
"(",
"$",
"model",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"delete",
"(",
")",
";",
"}",
"// Model after delete hook",
"if",
"(",
"method_exists",
"(",
"$",
"admin",
",",
"'afterDelete'",
")",
")",
"{",
"$",
"result",
"=",
"$",
"admin",
"->",
"afterDelete",
"(",
"$",
"model",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"RedirectResponse",
")",
"{",
"$",
"result",
"->",
"send",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Destroy a specific item.
@access public
@return FormBuilder
|
[
"Destroy",
"a",
"specific",
"item",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Builder/FormBuilder.php#L346-L376
|
234,588
|
txj123/zilf
|
src/Zilf/Queue/DatabaseQueue.php
|
DatabaseQueue.marshalJob
|
protected function marshalJob($queue, $job)
{
$job = $this->markJobAsReserved($job);
return new DatabaseJob(
$this, $job, $this->connectionName, $queue
);
}
|
php
|
protected function marshalJob($queue, $job)
{
$job = $this->markJobAsReserved($job);
return new DatabaseJob(
$this, $job, $this->connectionName, $queue
);
}
|
[
"protected",
"function",
"marshalJob",
"(",
"$",
"queue",
",",
"$",
"job",
")",
"{",
"$",
"job",
"=",
"$",
"this",
"->",
"markJobAsReserved",
"(",
"$",
"job",
")",
";",
"return",
"new",
"DatabaseJob",
"(",
"$",
"this",
",",
"$",
"job",
",",
"$",
"this",
"->",
"connectionName",
",",
"$",
"queue",
")",
";",
"}"
] |
Marshal the reserved job into a DatabaseJob instance.
@param string $queue
@param \Illuminate\Queue\Jobs\DatabaseJobRecord $job
@return \Illuminate\Queue\Jobs\DatabaseJob
|
[
"Marshal",
"the",
"reserved",
"job",
"into",
"a",
"DatabaseJob",
"instance",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Queue/DatabaseQueue.php#L271-L278
|
234,589
|
quai10/quai10-template
|
lib/ContactForm.php
|
ContactForm.getClass
|
private static function getClass(FormTag $tag, $validation_error)
{
$class = wpcf7_form_controls_class($tag->getType(), 'wpcf7-text');
if (in_array($tag->getBaseType(), ['email', 'url', 'tel'])) {
$class .= ' wpcf7-validates-as-'.$tag->getBaseType();
}
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
return $class;
}
|
php
|
private static function getClass(FormTag $tag, $validation_error)
{
$class = wpcf7_form_controls_class($tag->getType(), 'wpcf7-text');
if (in_array($tag->getBaseType(), ['email', 'url', 'tel'])) {
$class .= ' wpcf7-validates-as-'.$tag->getBaseType();
}
if ($validation_error) {
$class .= ' wpcf7-not-valid';
}
return $class;
}
|
[
"private",
"static",
"function",
"getClass",
"(",
"FormTag",
"$",
"tag",
",",
"$",
"validation_error",
")",
"{",
"$",
"class",
"=",
"wpcf7_form_controls_class",
"(",
"$",
"tag",
"->",
"getType",
"(",
")",
",",
"'wpcf7-text'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"tag",
"->",
"getBaseType",
"(",
")",
",",
"[",
"'email'",
",",
"'url'",
",",
"'tel'",
"]",
")",
")",
"{",
"$",
"class",
".=",
"' wpcf7-validates-as-'",
".",
"$",
"tag",
"->",
"getBaseType",
"(",
")",
";",
"}",
"if",
"(",
"$",
"validation_error",
")",
"{",
"$",
"class",
".=",
"' wpcf7-not-valid'",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Get input class.
@param FormTag $tag Input tag
@param string $validation_error Validation error
@return string Class
|
[
"Get",
"input",
"class",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/ContactForm.php#L21-L34
|
234,590
|
quai10/quai10-template
|
lib/ContactForm.php
|
ContactForm.getAtts
|
private static function getAtts(FormTag $tag, $validation_error, $class)
{
$atts = [];
$atts['size'] = $tag->get_size_option('40');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
$atts['required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$values = $tag->getValues();
$value = (string) reset($values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->getName(), $value);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->getBaseType();
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->getName();
return wpcf7_format_atts($atts);
}
|
php
|
private static function getAtts(FormTag $tag, $validation_error, $class)
{
$atts = [];
$atts['size'] = $tag->get_size_option('40');
$atts['maxlength'] = $tag->get_maxlength_option();
$atts['minlength'] = $tag->get_minlength_option();
if ($atts['maxlength'] && $atts['minlength'] && $atts['maxlength'] < $atts['minlength']) {
unset($atts['maxlength'], $atts['minlength']);
}
$atts['class'] = $tag->get_class_option($class);
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
if ($tag->has_option('readonly')) {
$atts['readonly'] = 'readonly';
}
if ($tag->is_required()) {
$atts['aria-required'] = 'true';
$atts['required'] = 'true';
}
$atts['aria-invalid'] = $validation_error ? 'true' : 'false';
$values = $tag->getValues();
$value = (string) reset($values);
if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
$atts['placeholder'] = $value;
$value = '';
}
$value = $tag->get_default_option($value);
$value = wpcf7_get_hangover($tag->getName(), $value);
$atts['value'] = $value;
if (wpcf7_support_html5()) {
$atts['type'] = $tag->getBaseType();
} else {
$atts['type'] = 'text';
}
$atts['name'] = $tag->getName();
return wpcf7_format_atts($atts);
}
|
[
"private",
"static",
"function",
"getAtts",
"(",
"FormTag",
"$",
"tag",
",",
"$",
"validation_error",
",",
"$",
"class",
")",
"{",
"$",
"atts",
"=",
"[",
"]",
";",
"$",
"atts",
"[",
"'size'",
"]",
"=",
"$",
"tag",
"->",
"get_size_option",
"(",
"'40'",
")",
";",
"$",
"atts",
"[",
"'maxlength'",
"]",
"=",
"$",
"tag",
"->",
"get_maxlength_option",
"(",
")",
";",
"$",
"atts",
"[",
"'minlength'",
"]",
"=",
"$",
"tag",
"->",
"get_minlength_option",
"(",
")",
";",
"if",
"(",
"$",
"atts",
"[",
"'maxlength'",
"]",
"&&",
"$",
"atts",
"[",
"'minlength'",
"]",
"&&",
"$",
"atts",
"[",
"'maxlength'",
"]",
"<",
"$",
"atts",
"[",
"'minlength'",
"]",
")",
"{",
"unset",
"(",
"$",
"atts",
"[",
"'maxlength'",
"]",
",",
"$",
"atts",
"[",
"'minlength'",
"]",
")",
";",
"}",
"$",
"atts",
"[",
"'class'",
"]",
"=",
"$",
"tag",
"->",
"get_class_option",
"(",
"$",
"class",
")",
";",
"$",
"atts",
"[",
"'id'",
"]",
"=",
"$",
"tag",
"->",
"get_id_option",
"(",
")",
";",
"$",
"atts",
"[",
"'tabindex'",
"]",
"=",
"$",
"tag",
"->",
"get_option",
"(",
"'tabindex'",
",",
"'int'",
",",
"true",
")",
";",
"if",
"(",
"$",
"tag",
"->",
"has_option",
"(",
"'readonly'",
")",
")",
"{",
"$",
"atts",
"[",
"'readonly'",
"]",
"=",
"'readonly'",
";",
"}",
"if",
"(",
"$",
"tag",
"->",
"is_required",
"(",
")",
")",
"{",
"$",
"atts",
"[",
"'aria-required'",
"]",
"=",
"'true'",
";",
"$",
"atts",
"[",
"'required'",
"]",
"=",
"'true'",
";",
"}",
"$",
"atts",
"[",
"'aria-invalid'",
"]",
"=",
"$",
"validation_error",
"?",
"'true'",
":",
"'false'",
";",
"$",
"values",
"=",
"$",
"tag",
"->",
"getValues",
"(",
")",
";",
"$",
"value",
"=",
"(",
"string",
")",
"reset",
"(",
"$",
"values",
")",
";",
"if",
"(",
"$",
"tag",
"->",
"has_option",
"(",
"'placeholder'",
")",
"||",
"$",
"tag",
"->",
"has_option",
"(",
"'watermark'",
")",
")",
"{",
"$",
"atts",
"[",
"'placeholder'",
"]",
"=",
"$",
"value",
";",
"$",
"value",
"=",
"''",
";",
"}",
"$",
"value",
"=",
"$",
"tag",
"->",
"get_default_option",
"(",
"$",
"value",
")",
";",
"$",
"value",
"=",
"wpcf7_get_hangover",
"(",
"$",
"tag",
"->",
"getName",
"(",
")",
",",
"$",
"value",
")",
";",
"$",
"atts",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"wpcf7_support_html5",
"(",
")",
")",
"{",
"$",
"atts",
"[",
"'type'",
"]",
"=",
"$",
"tag",
"->",
"getBaseType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"atts",
"[",
"'type'",
"]",
"=",
"'text'",
";",
"}",
"$",
"atts",
"[",
"'name'",
"]",
"=",
"$",
"tag",
"->",
"getName",
"(",
")",
";",
"return",
"wpcf7_format_atts",
"(",
"$",
"atts",
")",
";",
"}"
] |
Get input attributes.
@param FormTag $tag Input tag
@param string $validation_error Validation error
@param string $class Class
@return string Attributes
|
[
"Get",
"input",
"attributes",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/ContactForm.php#L45-L95
|
234,591
|
quai10/quai10-template
|
lib/ContactForm.php
|
ContactForm.addCustomFields
|
public static function addCustomFields($tag)
{
$tag = new FormTag($tag);
if (empty($tag->getType())) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->getName());
$class = self::getClass($tag, $validation_error);
$atts = self::getAtts($tag, $validation_error, $class);
$html = sprintf(
'<input class="%1$s" %2$s />%3$s',
sanitize_html_class($tag->getName()),
$atts,
$validation_error
);
return $html;
}
|
php
|
public static function addCustomFields($tag)
{
$tag = new FormTag($tag);
if (empty($tag->getType())) {
return '';
}
$validation_error = wpcf7_get_validation_error($tag->getName());
$class = self::getClass($tag, $validation_error);
$atts = self::getAtts($tag, $validation_error, $class);
$html = sprintf(
'<input class="%1$s" %2$s />%3$s',
sanitize_html_class($tag->getName()),
$atts,
$validation_error
);
return $html;
}
|
[
"public",
"static",
"function",
"addCustomFields",
"(",
"$",
"tag",
")",
"{",
"$",
"tag",
"=",
"new",
"FormTag",
"(",
"$",
"tag",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"tag",
"->",
"getType",
"(",
")",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"validation_error",
"=",
"wpcf7_get_validation_error",
"(",
"$",
"tag",
"->",
"getName",
"(",
")",
")",
";",
"$",
"class",
"=",
"self",
"::",
"getClass",
"(",
"$",
"tag",
",",
"$",
"validation_error",
")",
";",
"$",
"atts",
"=",
"self",
"::",
"getAtts",
"(",
"$",
"tag",
",",
"$",
"validation_error",
",",
"$",
"class",
")",
";",
"$",
"html",
"=",
"sprintf",
"(",
"'<input class=\"%1$s\" %2$s />%3$s'",
",",
"sanitize_html_class",
"(",
"$",
"tag",
"->",
"getName",
"(",
")",
")",
",",
"$",
"atts",
",",
"$",
"validation_error",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Declare custom field types.
@param array|string $tag Tag
|
[
"Declare",
"custom",
"field",
"types",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/ContactForm.php#L102-L123
|
234,592
|
quai10/quai10-template
|
lib/ContactForm.php
|
ContactForm.addFields
|
public static function addFields()
{
$tags = ['text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*'];
foreach ($tags as $tag) {
//We have to remove tags before replacing them.
wpcf7_remove_form_tag($tag);
}
wpcf7_add_form_tag($tags, [self::class, 'addCustomFields'], true);
}
|
php
|
public static function addFields()
{
$tags = ['text', 'text*', 'email', 'email*', 'url', 'url*', 'tel', 'tel*'];
foreach ($tags as $tag) {
//We have to remove tags before replacing them.
wpcf7_remove_form_tag($tag);
}
wpcf7_add_form_tag($tags, [self::class, 'addCustomFields'], true);
}
|
[
"public",
"static",
"function",
"addFields",
"(",
")",
"{",
"$",
"tags",
"=",
"[",
"'text'",
",",
"'text*'",
",",
"'email'",
",",
"'email*'",
",",
"'url'",
",",
"'url*'",
",",
"'tel'",
",",
"'tel*'",
"]",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"//We have to remove tags before replacing them.",
"wpcf7_remove_form_tag",
"(",
"$",
"tag",
")",
";",
"}",
"wpcf7_add_form_tag",
"(",
"$",
"tags",
",",
"[",
"self",
"::",
"class",
",",
"'addCustomFields'",
"]",
",",
"true",
")",
";",
"}"
] |
Customize form fields.
|
[
"Customize",
"form",
"fields",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/ContactForm.php#L128-L136
|
234,593
|
quai10/quai10-template
|
lib/ContactForm.php
|
ContactForm.addCustomSubmitBtn
|
public static function addCustomSubmitBtn($tag)
{
$tag = new FormTag($tag);
$class = wpcf7_form_controls_class($tag->getType());
$atts = [];
$atts['class'] = $tag->get_class_option($class).' btn';
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
$atts['type'] = 'submit';
$atts['value'] = $value;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<button type="submit" %1$s>%2$s</button>', $atts, $value);
return $html;
}
|
php
|
public static function addCustomSubmitBtn($tag)
{
$tag = new FormTag($tag);
$class = wpcf7_form_controls_class($tag->getType());
$atts = [];
$atts['class'] = $tag->get_class_option($class).' btn';
$atts['id'] = $tag->get_id_option();
$atts['tabindex'] = $tag->get_option('tabindex', 'int', true);
$value = isset($tag->values[0]) ? $tag->values[0] : '';
if (empty($value)) {
$value = __('Send', 'contact-form-7');
}
$atts['type'] = 'submit';
$atts['value'] = $value;
$atts = wpcf7_format_atts($atts);
$html = sprintf('<button type="submit" %1$s>%2$s</button>', $atts, $value);
return $html;
}
|
[
"public",
"static",
"function",
"addCustomSubmitBtn",
"(",
"$",
"tag",
")",
"{",
"$",
"tag",
"=",
"new",
"FormTag",
"(",
"$",
"tag",
")",
";",
"$",
"class",
"=",
"wpcf7_form_controls_class",
"(",
"$",
"tag",
"->",
"getType",
"(",
")",
")",
";",
"$",
"atts",
"=",
"[",
"]",
";",
"$",
"atts",
"[",
"'class'",
"]",
"=",
"$",
"tag",
"->",
"get_class_option",
"(",
"$",
"class",
")",
".",
"' btn'",
";",
"$",
"atts",
"[",
"'id'",
"]",
"=",
"$",
"tag",
"->",
"get_id_option",
"(",
")",
";",
"$",
"atts",
"[",
"'tabindex'",
"]",
"=",
"$",
"tag",
"->",
"get_option",
"(",
"'tabindex'",
",",
"'int'",
",",
"true",
")",
";",
"$",
"value",
"=",
"isset",
"(",
"$",
"tag",
"->",
"values",
"[",
"0",
"]",
")",
"?",
"$",
"tag",
"->",
"values",
"[",
"0",
"]",
":",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"__",
"(",
"'Send'",
",",
"'contact-form-7'",
")",
";",
"}",
"$",
"atts",
"[",
"'type'",
"]",
"=",
"'submit'",
";",
"$",
"atts",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"$",
"atts",
"=",
"wpcf7_format_atts",
"(",
"$",
"atts",
")",
";",
"$",
"html",
"=",
"sprintf",
"(",
"'<button type=\"submit\" %1$s>%2$s</button>'",
",",
"$",
"atts",
",",
"$",
"value",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Declare custom submit button.
@param array|string $tag Tag
|
[
"Declare",
"custom",
"submit",
"button",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/ContactForm.php#L143-L169
|
234,594
|
Syonix/log-viewer-lib
|
lib/Config.php
|
Config.lint
|
public static function lint($config, $verifyLogFiles = false)
{
$valid = true;
$checks = [];
// Valid YAML
$checks['valid_yaml'] = [
'message' => 'Is a valid YAML file',
];
try {
$config = self::parse($config);
$checks['valid_yaml']['status'] = 'ok';
} catch (\Exception $e) {
$valid = false;
$checks['valid_yaml']['status'] = 'fail';
$checks['valid_yaml']['error'] = $e->getMessage();
}
try {
// Valid structure
$checks['valid_structure'] = self::lintValidProperties($config);
if ($checks['valid_structure']['status'] == 'fail') {
throw new \Exception();
}
// Valid config values
$checks['valid_settings'] = self::lintValidSettingsValues($config);
if ($checks['valid_settings']['status'] == 'fail') {
throw new \Exception();
}
// Validate log collections (each)
$checks['log_collections'] = [
'message' => 'Checking log collections',
];
try {
foreach ($config['logs'] as $logCollectionName => $logCollection) {
$checks['log_collections']['sub_checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection);
if ($checks['log_collections']['sub_checks'][$logCollectionName]['status'] == 'fail') {
throw new \Exception();
}
}
foreach ($config['logs'] as $logCollectionName => $logCollection) {
$checks['log_collections']['checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection, $verifyLogFiles);
if ($checks['log_collections']['checks'][$logCollectionName]['status'] == 'fail') {
throw new \Exception();
}
}
$checks['log_collections']['status'] = 'ok';
} catch (\Exception $e) {
$checks['log_collections']['status'] = 'fail';
$checks['log_collections']['error'] = $e->getMessage();
$valid = false;
}
} catch (\Exception $e) {
$valid = false;
}
return [
'valid' => $valid,
'checks' => $checks,
];
}
|
php
|
public static function lint($config, $verifyLogFiles = false)
{
$valid = true;
$checks = [];
// Valid YAML
$checks['valid_yaml'] = [
'message' => 'Is a valid YAML file',
];
try {
$config = self::parse($config);
$checks['valid_yaml']['status'] = 'ok';
} catch (\Exception $e) {
$valid = false;
$checks['valid_yaml']['status'] = 'fail';
$checks['valid_yaml']['error'] = $e->getMessage();
}
try {
// Valid structure
$checks['valid_structure'] = self::lintValidProperties($config);
if ($checks['valid_structure']['status'] == 'fail') {
throw new \Exception();
}
// Valid config values
$checks['valid_settings'] = self::lintValidSettingsValues($config);
if ($checks['valid_settings']['status'] == 'fail') {
throw new \Exception();
}
// Validate log collections (each)
$checks['log_collections'] = [
'message' => 'Checking log collections',
];
try {
foreach ($config['logs'] as $logCollectionName => $logCollection) {
$checks['log_collections']['sub_checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection);
if ($checks['log_collections']['sub_checks'][$logCollectionName]['status'] == 'fail') {
throw new \Exception();
}
}
foreach ($config['logs'] as $logCollectionName => $logCollection) {
$checks['log_collections']['checks'][$logCollectionName] = self::lintLogCollection($logCollectionName, $logCollection, $verifyLogFiles);
if ($checks['log_collections']['checks'][$logCollectionName]['status'] == 'fail') {
throw new \Exception();
}
}
$checks['log_collections']['status'] = 'ok';
} catch (\Exception $e) {
$checks['log_collections']['status'] = 'fail';
$checks['log_collections']['error'] = $e->getMessage();
$valid = false;
}
} catch (\Exception $e) {
$valid = false;
}
return [
'valid' => $valid,
'checks' => $checks,
];
}
|
[
"public",
"static",
"function",
"lint",
"(",
"$",
"config",
",",
"$",
"verifyLogFiles",
"=",
"false",
")",
"{",
"$",
"valid",
"=",
"true",
";",
"$",
"checks",
"=",
"[",
"]",
";",
"// Valid YAML",
"$",
"checks",
"[",
"'valid_yaml'",
"]",
"=",
"[",
"'message'",
"=>",
"'Is a valid YAML file'",
",",
"]",
";",
"try",
"{",
"$",
"config",
"=",
"self",
"::",
"parse",
"(",
"$",
"config",
")",
";",
"$",
"checks",
"[",
"'valid_yaml'",
"]",
"[",
"'status'",
"]",
"=",
"'ok'",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"$",
"checks",
"[",
"'valid_yaml'",
"]",
"[",
"'status'",
"]",
"=",
"'fail'",
";",
"$",
"checks",
"[",
"'valid_yaml'",
"]",
"[",
"'error'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"try",
"{",
"// Valid structure",
"$",
"checks",
"[",
"'valid_structure'",
"]",
"=",
"self",
"::",
"lintValidProperties",
"(",
"$",
"config",
")",
";",
"if",
"(",
"$",
"checks",
"[",
"'valid_structure'",
"]",
"[",
"'status'",
"]",
"==",
"'fail'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"// Valid config values",
"$",
"checks",
"[",
"'valid_settings'",
"]",
"=",
"self",
"::",
"lintValidSettingsValues",
"(",
"$",
"config",
")",
";",
"if",
"(",
"$",
"checks",
"[",
"'valid_settings'",
"]",
"[",
"'status'",
"]",
"==",
"'fail'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"// Validate log collections (each)",
"$",
"checks",
"[",
"'log_collections'",
"]",
"=",
"[",
"'message'",
"=>",
"'Checking log collections'",
",",
"]",
";",
"try",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'logs'",
"]",
"as",
"$",
"logCollectionName",
"=>",
"$",
"logCollection",
")",
"{",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'sub_checks'",
"]",
"[",
"$",
"logCollectionName",
"]",
"=",
"self",
"::",
"lintLogCollection",
"(",
"$",
"logCollectionName",
",",
"$",
"logCollection",
")",
";",
"if",
"(",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'sub_checks'",
"]",
"[",
"$",
"logCollectionName",
"]",
"[",
"'status'",
"]",
"==",
"'fail'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"config",
"[",
"'logs'",
"]",
"as",
"$",
"logCollectionName",
"=>",
"$",
"logCollection",
")",
"{",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'checks'",
"]",
"[",
"$",
"logCollectionName",
"]",
"=",
"self",
"::",
"lintLogCollection",
"(",
"$",
"logCollectionName",
",",
"$",
"logCollection",
",",
"$",
"verifyLogFiles",
")",
";",
"if",
"(",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'checks'",
"]",
"[",
"$",
"logCollectionName",
"]",
"[",
"'status'",
"]",
"==",
"'fail'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"}",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'status'",
"]",
"=",
"'ok'",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'status'",
"]",
"=",
"'fail'",
";",
"$",
"checks",
"[",
"'log_collections'",
"]",
"[",
"'error'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"valid",
"=",
"false",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"}",
"return",
"[",
"'valid'",
"=>",
"$",
"valid",
",",
"'checks'",
"=>",
"$",
"checks",
",",
"]",
";",
"}"
] |
Lints a config file for syntactical and semantical correctness.
@param array $config The parsed configuration to lint
@param bool $verifyLogFiles Also verfy whether the log files are accessible
@return array
|
[
"Lints",
"a",
"config",
"file",
"for",
"syntactical",
"and",
"semantical",
"correctness",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/Config.php#L37-L99
|
234,595
|
Syonix/log-viewer-lib
|
lib/Config.php
|
Config.get
|
public function get($property = null)
{
if ($property === null || $property == '') {
return $this->config;
}
$tree = explode('.', $property);
$node = $this->config;
foreach ($tree as $workingNode) {
if (!array_key_exists($workingNode, $node)) {
$actualNode = null;
foreach ($node as $testNodeKey => $testNode) {
if (\URLify::filter($testNodeKey) == $workingNode) {
$actualNode = $testNodeKey;
}
}
if ($actualNode === null) {
throw new \InvalidArgumentException('The property "'.$property
.'" was not found. Failed while getting node "'.$workingNode.'"');
}
$workingNode = $actualNode;
}
$node = $node[$workingNode];
}
return $node;
}
|
php
|
public function get($property = null)
{
if ($property === null || $property == '') {
return $this->config;
}
$tree = explode('.', $property);
$node = $this->config;
foreach ($tree as $workingNode) {
if (!array_key_exists($workingNode, $node)) {
$actualNode = null;
foreach ($node as $testNodeKey => $testNode) {
if (\URLify::filter($testNodeKey) == $workingNode) {
$actualNode = $testNodeKey;
}
}
if ($actualNode === null) {
throw new \InvalidArgumentException('The property "'.$property
.'" was not found. Failed while getting node "'.$workingNode.'"');
}
$workingNode = $actualNode;
}
$node = $node[$workingNode];
}
return $node;
}
|
[
"public",
"function",
"get",
"(",
"$",
"property",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"property",
"===",
"null",
"||",
"$",
"property",
"==",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"config",
";",
"}",
"$",
"tree",
"=",
"explode",
"(",
"'.'",
",",
"$",
"property",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"config",
";",
"foreach",
"(",
"$",
"tree",
"as",
"$",
"workingNode",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"workingNode",
",",
"$",
"node",
")",
")",
"{",
"$",
"actualNode",
"=",
"null",
";",
"foreach",
"(",
"$",
"node",
"as",
"$",
"testNodeKey",
"=>",
"$",
"testNode",
")",
"{",
"if",
"(",
"\\",
"URLify",
"::",
"filter",
"(",
"$",
"testNodeKey",
")",
"==",
"$",
"workingNode",
")",
"{",
"$",
"actualNode",
"=",
"$",
"testNodeKey",
";",
"}",
"}",
"if",
"(",
"$",
"actualNode",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The property \"'",
".",
"$",
"property",
".",
"'\" was not found. Failed while getting node \"'",
".",
"$",
"workingNode",
".",
"'\"'",
")",
";",
"}",
"$",
"workingNode",
"=",
"$",
"actualNode",
";",
"}",
"$",
"node",
"=",
"$",
"node",
"[",
"$",
"workingNode",
"]",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Returns a config property if it exists and throws an exception if not.
@param string|null $property Dot-separated property (e.g. "date_format" or "logs.collection.log_file")
@throws \InvalidArgumentException
@return mixed
|
[
"Returns",
"a",
"config",
"property",
"if",
"it",
"exists",
"and",
"throws",
"an",
"exception",
"if",
"not",
"."
] |
5212208bf2f0174eb5d0408d2d3028db4d478a74
|
https://github.com/Syonix/log-viewer-lib/blob/5212208bf2f0174eb5d0408d2d3028db4d478a74/lib/Config.php#L352-L378
|
234,596
|
oscarotero/uploader
|
src/Uploader.php
|
Uploader.setDestination
|
public function setDestination($destination)
{
if ($destination instanceof Closure) {
$this->callbacks['destination'] = $destination;
} else {
$this->options = self::parsePath($destination) + $this->options;
}
return $this;
}
|
php
|
public function setDestination($destination)
{
if ($destination instanceof Closure) {
$this->callbacks['destination'] = $destination;
} else {
$this->options = self::parsePath($destination) + $this->options;
}
return $this;
}
|
[
"public",
"function",
"setDestination",
"(",
"$",
"destination",
")",
"{",
"if",
"(",
"$",
"destination",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"'destination'",
"]",
"=",
"$",
"destination",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"=",
"self",
"::",
"parsePath",
"(",
"$",
"destination",
")",
"+",
"$",
"this",
"->",
"options",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the destination of the file. It includes the directory, filename and extension.
@param string|Closure $destination
@return $this
|
[
"Set",
"the",
"destination",
"of",
"the",
"file",
".",
"It",
"includes",
"the",
"directory",
"filename",
"and",
"extension",
"."
] |
94f1461d324b467e2047568fcc5d88d53ab9ac8f
|
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Uploader.php#L161-L170
|
234,597
|
oscarotero/uploader
|
src/Uploader.php
|
Uploader.getDestination
|
public function getDestination($absolute = false)
{
return self::fixPath(($absolute ? '/'.$this->cwd : ''), $this->getDirectory(), $this->getPrefix().$this->getFilename().'.'.$this->getExtension());
}
|
php
|
public function getDestination($absolute = false)
{
return self::fixPath(($absolute ? '/'.$this->cwd : ''), $this->getDirectory(), $this->getPrefix().$this->getFilename().'.'.$this->getExtension());
}
|
[
"public",
"function",
"getDestination",
"(",
"$",
"absolute",
"=",
"false",
")",
"{",
"return",
"self",
"::",
"fixPath",
"(",
"(",
"$",
"absolute",
"?",
"'/'",
".",
"$",
"this",
"->",
"cwd",
":",
"''",
")",
",",
"$",
"this",
"->",
"getDirectory",
"(",
")",
",",
"$",
"this",
"->",
"getPrefix",
"(",
")",
".",
"$",
"this",
"->",
"getFilename",
"(",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"getExtension",
"(",
")",
")",
";",
"}"
] |
Returns the file destination.
@param bool $absolute Whether or not returns the cwd
@return string
|
[
"Returns",
"the",
"file",
"destination",
"."
] |
94f1461d324b467e2047568fcc5d88d53ab9ac8f
|
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Uploader.php#L179-L182
|
234,598
|
oscarotero/uploader
|
src/Uploader.php
|
Uploader.with
|
public function with($original, $adapter = null)
{
$new = clone $this;
$new->original = $original;
$new->adapter = $adapter;
if ($new->adapter === null) {
foreach ($new->adapters as $each) {
if ($each::check($original)) {
$new->adapter = $each;
break;
}
}
}
if ($new->adapter === null || !class_exists($new->adapter)) {
throw new \InvalidArgumentException('No valid adapter found');
}
return $new;
}
|
php
|
public function with($original, $adapter = null)
{
$new = clone $this;
$new->original = $original;
$new->adapter = $adapter;
if ($new->adapter === null) {
foreach ($new->adapters as $each) {
if ($each::check($original)) {
$new->adapter = $each;
break;
}
}
}
if ($new->adapter === null || !class_exists($new->adapter)) {
throw new \InvalidArgumentException('No valid adapter found');
}
return $new;
}
|
[
"public",
"function",
"with",
"(",
"$",
"original",
",",
"$",
"adapter",
"=",
"null",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"original",
"=",
"$",
"original",
";",
"$",
"new",
"->",
"adapter",
"=",
"$",
"adapter",
";",
"if",
"(",
"$",
"new",
"->",
"adapter",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"new",
"->",
"adapters",
"as",
"$",
"each",
")",
"{",
"if",
"(",
"$",
"each",
"::",
"check",
"(",
"$",
"original",
")",
")",
"{",
"$",
"new",
"->",
"adapter",
"=",
"$",
"each",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"new",
"->",
"adapter",
"===",
"null",
"||",
"!",
"class_exists",
"(",
"$",
"new",
"->",
"adapter",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'No valid adapter found'",
")",
";",
"}",
"return",
"$",
"new",
";",
"}"
] |
Set the original source.
@param mixed $original
@param null|string $adapter
@throws \InvalidArgumentException On error
@return Uploader A new cloned copy with the source and adapter configured
|
[
"Set",
"the",
"original",
"source",
"."
] |
94f1461d324b467e2047568fcc5d88d53ab9ac8f
|
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Uploader.php#L260-L280
|
234,599
|
oscarotero/uploader
|
src/Uploader.php
|
Uploader.setOption
|
protected function setOption($name, $value)
{
if ($value instanceof Closure) {
$this->callbacks[$name] = $value;
} else {
$this->options[$name] = $value;
}
return $this;
}
|
php
|
protected function setOption($name, $value)
{
if ($value instanceof Closure) {
$this->callbacks[$name] = $value;
} else {
$this->options[$name] = $value;
}
return $this;
}
|
[
"protected",
"function",
"setOption",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Saves an option.
@param string $name
@param mixed $value
@return $this
|
[
"Saves",
"an",
"option",
"."
] |
94f1461d324b467e2047568fcc5d88d53ab9ac8f
|
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Uploader.php#L333-L342
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.