repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent.make | public function make(Table $table, $action, array $ids = [], array $options = [])
{
$count = count($ids);
$options = $this->_getOptions($options, $count);
$redirectUrl = $options['redirect'];
$messages = new JSON($options['messages']);
$event = EventManager::trigger($this->_getEventName($action), $this->_controller, ['ids' => $ids]);
$ids = (array) $event->getData('ids');
$count = count($ids);
if (!$action) {
$this->Flash->error($messages->get('no_action'));
return $this->_controller->redirect($redirectUrl);
}
if ($count <= 0) {
$this->Flash->error($messages->get('no_choose'));
return $this->_controller->redirect($redirectUrl);
}
$this->_loadBehavior($table);
if ($table->process($action, $ids)) {
return $this->_process($action, $messages, $redirectUrl, $ids);
}
$this->Flash->error(__d('core', 'An error has occurred. Please try again.'));
return $this->_controller->redirect($redirectUrl);
} | php | public function make(Table $table, $action, array $ids = [], array $options = [])
{
$count = count($ids);
$options = $this->_getOptions($options, $count);
$redirectUrl = $options['redirect'];
$messages = new JSON($options['messages']);
$event = EventManager::trigger($this->_getEventName($action), $this->_controller, ['ids' => $ids]);
$ids = (array) $event->getData('ids');
$count = count($ids);
if (!$action) {
$this->Flash->error($messages->get('no_action'));
return $this->_controller->redirect($redirectUrl);
}
if ($count <= 0) {
$this->Flash->error($messages->get('no_choose'));
return $this->_controller->redirect($redirectUrl);
}
$this->_loadBehavior($table);
if ($table->process($action, $ids)) {
return $this->_process($action, $messages, $redirectUrl, $ids);
}
$this->Flash->error(__d('core', 'An error has occurred. Please try again.'));
return $this->_controller->redirect($redirectUrl);
} | [
"public",
"function",
"make",
"(",
"Table",
"$",
"table",
",",
"$",
"action",
",",
"array",
"$",
"ids",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"ids",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"_getOptions",
"(",
"$",
"options",
",",
"$",
"count",
")",
";",
"$",
"redirectUrl",
"=",
"$",
"options",
"[",
"'redirect'",
"]",
";",
"$",
"messages",
"=",
"new",
"JSON",
"(",
"$",
"options",
"[",
"'messages'",
"]",
")",
";",
"$",
"event",
"=",
"EventManager",
"::",
"trigger",
"(",
"$",
"this",
"->",
"_getEventName",
"(",
"$",
"action",
")",
",",
"$",
"this",
"->",
"_controller",
",",
"[",
"'ids'",
"=>",
"$",
"ids",
"]",
")",
";",
"$",
"ids",
"=",
"(",
"array",
")",
"$",
"event",
"->",
"getData",
"(",
"'ids'",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"ids",
")",
";",
"if",
"(",
"!",
"$",
"action",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"messages",
"->",
"get",
"(",
"'no_action'",
")",
")",
";",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"$",
"redirectUrl",
")",
";",
"}",
"if",
"(",
"$",
"count",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"messages",
"->",
"get",
"(",
"'no_choose'",
")",
")",
";",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"$",
"redirectUrl",
")",
";",
"}",
"$",
"this",
"->",
"_loadBehavior",
"(",
"$",
"table",
")",
";",
"if",
"(",
"$",
"table",
"->",
"process",
"(",
"$",
"action",
",",
"$",
"ids",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_process",
"(",
"$",
"action",
",",
"$",
"messages",
",",
"$",
"redirectUrl",
",",
"$",
"ids",
")",
";",
"}",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"__d",
"(",
"'core'",
",",
"'An error has occurred. Please try again.'",
")",
")",
";",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"$",
"redirectUrl",
")",
";",
"}"
]
| Make process.
@param Table $table
@param string $action
@param array $ids
@param array $options
@return \Cake\Http\Response|null
@throws \Aura\Intl\Exception | [
"Make",
"process",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L105-L133 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._getDefaultMessages | protected function _getDefaultMessages($count)
{
$context = $this->_configRead('context');
$contextPlural = Inflector::pluralize($context);
$countString = sprintf('<strong>%s</strong>', $count);
return [
'delete' => __dn(
'core',
'One ' . $context . ' success removed',
'{0} ' . $contextPlural . ' success removed',
$count,
$countString
),
'publish' => __dn(
'core',
'One ' . $context . ' success publish',
'{0} ' . $contextPlural . ' success published',
$count,
$countString
),
'unpublish' => __dn(
'core',
'One ' . $context . ' success unpublish',
'{0} ' . $contextPlural . ' success unpublished',
$count,
$countString
),
];
} | php | protected function _getDefaultMessages($count)
{
$context = $this->_configRead('context');
$contextPlural = Inflector::pluralize($context);
$countString = sprintf('<strong>%s</strong>', $count);
return [
'delete' => __dn(
'core',
'One ' . $context . ' success removed',
'{0} ' . $contextPlural . ' success removed',
$count,
$countString
),
'publish' => __dn(
'core',
'One ' . $context . ' success publish',
'{0} ' . $contextPlural . ' success published',
$count,
$countString
),
'unpublish' => __dn(
'core',
'One ' . $context . ' success unpublish',
'{0} ' . $contextPlural . ' success unpublished',
$count,
$countString
),
];
} | [
"protected",
"function",
"_getDefaultMessages",
"(",
"$",
"count",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"_configRead",
"(",
"'context'",
")",
";",
"$",
"contextPlural",
"=",
"Inflector",
"::",
"pluralize",
"(",
"$",
"context",
")",
";",
"$",
"countString",
"=",
"sprintf",
"(",
"'<strong>%s</strong>'",
",",
"$",
"count",
")",
";",
"return",
"[",
"'delete'",
"=>",
"__dn",
"(",
"'core'",
",",
"'One '",
".",
"$",
"context",
".",
"' success removed'",
",",
"'{0} '",
".",
"$",
"contextPlural",
".",
"' success removed'",
",",
"$",
"count",
",",
"$",
"countString",
")",
",",
"'publish'",
"=>",
"__dn",
"(",
"'core'",
",",
"'One '",
".",
"$",
"context",
".",
"' success publish'",
",",
"'{0} '",
".",
"$",
"contextPlural",
".",
"' success published'",
",",
"$",
"count",
",",
"$",
"countString",
")",
",",
"'unpublish'",
"=>",
"__dn",
"(",
"'core'",
",",
"'One '",
".",
"$",
"context",
".",
"' success unpublish'",
",",
"'{0} '",
".",
"$",
"contextPlural",
".",
"' success unpublished'",
",",
"$",
"count",
",",
"$",
"countString",
")",
",",
"]",
";",
"}"
]
| Setup default action messages.
@param int $count
@return array
@throws \Aura\Intl\Exception | [
"Setup",
"default",
"action",
"messages",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L143-L171 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._getEventName | protected function _getEventName($action, $event = self::EVENT_NAME_BEFORE)
{
$details = [];
if ($prefix = $this->_request->getParam('prefix')) {
$details[] = ucfirst($prefix);
}
$details = Hash::merge($details, [
'Controller',
$this->_controller->getName(),
$event . Inflector::camelize($action),
'Process',
]);
return implode('.', $details);
} | php | protected function _getEventName($action, $event = self::EVENT_NAME_BEFORE)
{
$details = [];
if ($prefix = $this->_request->getParam('prefix')) {
$details[] = ucfirst($prefix);
}
$details = Hash::merge($details, [
'Controller',
$this->_controller->getName(),
$event . Inflector::camelize($action),
'Process',
]);
return implode('.', $details);
} | [
"protected",
"function",
"_getEventName",
"(",
"$",
"action",
",",
"$",
"event",
"=",
"self",
"::",
"EVENT_NAME_BEFORE",
")",
"{",
"$",
"details",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"prefix",
"=",
"$",
"this",
"->",
"_request",
"->",
"getParam",
"(",
"'prefix'",
")",
")",
"{",
"$",
"details",
"[",
"]",
"=",
"ucfirst",
"(",
"$",
"prefix",
")",
";",
"}",
"$",
"details",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"details",
",",
"[",
"'Controller'",
",",
"$",
"this",
"->",
"_controller",
"->",
"getName",
"(",
")",
",",
"$",
"event",
".",
"Inflector",
"::",
"camelize",
"(",
"$",
"action",
")",
",",
"'Process'",
",",
"]",
")",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"details",
")",
";",
"}"
]
| Get event name by data.
@param string $action
@param string $event
@return string | [
"Get",
"event",
"name",
"by",
"data",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L180-L195 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._getIds | protected function _getIds(array $ids, $primaryKey = self::PRIMARY_KEY)
{
$return = [];
foreach ($ids as $id => $value) {
if (is_array($value) && is_int($id) && (int) $value[$primaryKey] === 1) {
$return[$id] = $id;
}
}
return $return;
} | php | protected function _getIds(array $ids, $primaryKey = self::PRIMARY_KEY)
{
$return = [];
foreach ($ids as $id => $value) {
if (is_array($value) && is_int($id) && (int) $value[$primaryKey] === 1) {
$return[$id] = $id;
}
}
return $return;
} | [
"protected",
"function",
"_getIds",
"(",
"array",
"$",
"ids",
",",
"$",
"primaryKey",
"=",
"self",
"::",
"PRIMARY_KEY",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"is_int",
"(",
"$",
"id",
")",
"&&",
"(",
"int",
")",
"$",
"value",
"[",
"$",
"primaryKey",
"]",
"===",
"1",
")",
"{",
"$",
"return",
"[",
"$",
"id",
"]",
"=",
"$",
"id",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
]
| Get ids by request.
@param array $ids
@param string $primaryKey
@return array | [
"Get",
"ids",
"by",
"request",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L204-L214 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._getOptions | protected function _getOptions(array $options, $count)
{
$options = Hash::merge($this->_config, $options);
return Hash::merge(['messages' => $this->_getDefaultMessages($count)], $options);
} | php | protected function _getOptions(array $options, $count)
{
$options = Hash::merge($this->_config, $options);
return Hash::merge(['messages' => $this->_getDefaultMessages($count)], $options);
} | [
"protected",
"function",
"_getOptions",
"(",
"array",
"$",
"options",
",",
"$",
"count",
")",
"{",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"this",
"->",
"_config",
",",
"$",
"options",
")",
";",
"return",
"Hash",
"::",
"merge",
"(",
"[",
"'messages'",
"=>",
"$",
"this",
"->",
"_getDefaultMessages",
"(",
"$",
"count",
")",
"]",
",",
"$",
"options",
")",
";",
"}"
]
| Create and merge actual process options.
@param array $options
@param int|string $count
@return array
@throws \Aura\Intl\Exception | [
"Create",
"and",
"merge",
"actual",
"process",
"options",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L225-L229 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._loadBehavior | protected function _loadBehavior(Table $table)
{
$behaviors = $table->behaviors();
if (!Arr::in('Process', $behaviors->loaded())) {
$behaviors->load('Core.Process');
}
} | php | protected function _loadBehavior(Table $table)
{
$behaviors = $table->behaviors();
if (!Arr::in('Process', $behaviors->loaded())) {
$behaviors->load('Core.Process');
}
} | [
"protected",
"function",
"_loadBehavior",
"(",
"Table",
"$",
"table",
")",
"{",
"$",
"behaviors",
"=",
"$",
"table",
"->",
"behaviors",
"(",
")",
";",
"if",
"(",
"!",
"Arr",
"::",
"in",
"(",
"'Process'",
",",
"$",
"behaviors",
"->",
"loaded",
"(",
")",
")",
")",
"{",
"$",
"behaviors",
"->",
"load",
"(",
"'Core.Process'",
")",
";",
"}",
"}"
]
| Load process behavior.
@param Table $table | [
"Load",
"process",
"behavior",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L236-L242 |
CakeCMS/Core | src/Controller/Component/ProcessComponent.php | ProcessComponent._process | protected function _process($action, Data $messages, array $redirect, array $ids)
{
$count = count($ids);
$defaultMsg = __dn(
'core',
'One record success processed',
'{0} records processed',
$count,
sprintf('<strong>%s</strong>', $count)
);
EventManager::trigger($this->_getEventName($action, self::EVENT_NAME_AFTER), $this->_controller, [
'ids' => $ids
]);
$this->Flash->success($messages->get($action, $defaultMsg));
return $this->_controller->redirect($redirect);
} | php | protected function _process($action, Data $messages, array $redirect, array $ids)
{
$count = count($ids);
$defaultMsg = __dn(
'core',
'One record success processed',
'{0} records processed',
$count,
sprintf('<strong>%s</strong>', $count)
);
EventManager::trigger($this->_getEventName($action, self::EVENT_NAME_AFTER), $this->_controller, [
'ids' => $ids
]);
$this->Flash->success($messages->get($action, $defaultMsg));
return $this->_controller->redirect($redirect);
} | [
"protected",
"function",
"_process",
"(",
"$",
"action",
",",
"Data",
"$",
"messages",
",",
"array",
"$",
"redirect",
",",
"array",
"$",
"ids",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"ids",
")",
";",
"$",
"defaultMsg",
"=",
"__dn",
"(",
"'core'",
",",
"'One record success processed'",
",",
"'{0} records processed'",
",",
"$",
"count",
",",
"sprintf",
"(",
"'<strong>%s</strong>'",
",",
"$",
"count",
")",
")",
";",
"EventManager",
"::",
"trigger",
"(",
"$",
"this",
"->",
"_getEventName",
"(",
"$",
"action",
",",
"self",
"::",
"EVENT_NAME_AFTER",
")",
",",
"$",
"this",
"->",
"_controller",
",",
"[",
"'ids'",
"=>",
"$",
"ids",
"]",
")",
";",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"$",
"messages",
"->",
"get",
"(",
"$",
"action",
",",
"$",
"defaultMsg",
")",
")",
";",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"$",
"redirect",
")",
";",
"}"
]
| Controller process.
@param string $action
@param Data $messages
@param array $redirect
@param array $ids
@return \Cake\Http\Response|null
@throws \Aura\Intl\Exception | [
"Controller",
"process",
"."
]
| train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/ProcessComponent.php#L255-L272 |
xtcommerce/shop-appstore-lib | src/XTCommerce/ShopAppstoreLib/Http.php | Http.parseHeaders | public function parseHeaders($src)
{
$headers = array();
$codeMatched = false;
// curl request header
if (!is_array($src)) {
$src = explode("\n",$src);
}
foreach ($src as $i) {
$row = explode(':', $i, 2);
// header with no key/value - HTTP response, get code and status
if(!isset($row[1])){
$headers[] = $row[0];
$matches = array();
if(!$codeMatched && preg_match('#HTTP/1.[0-1] ([0-9]{3})(.*)#si', $row[0], $matches)){
$headers['Code'] = $matches[1];
$headers['Status'] = trim($matches[2]);
$codeMatched = true;
}
continue;
}
$key = trim($row[0]);
$val = trim($row[1]);
$headers[$key] = $val;
}
return $headers;
} | php | public function parseHeaders($src)
{
$headers = array();
$codeMatched = false;
// curl request header
if (!is_array($src)) {
$src = explode("\n",$src);
}
foreach ($src as $i) {
$row = explode(':', $i, 2);
// header with no key/value - HTTP response, get code and status
if(!isset($row[1])){
$headers[] = $row[0];
$matches = array();
if(!$codeMatched && preg_match('#HTTP/1.[0-1] ([0-9]{3})(.*)#si', $row[0], $matches)){
$headers['Code'] = $matches[1];
$headers['Status'] = trim($matches[2]);
$codeMatched = true;
}
continue;
}
$key = trim($row[0]);
$val = trim($row[1]);
$headers[$key] = $val;
}
return $headers;
} | [
"public",
"function",
"parseHeaders",
"(",
"$",
"src",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"codeMatched",
"=",
"false",
";",
"// curl request header",
"if",
"(",
"!",
"is_array",
"(",
"$",
"src",
")",
")",
"{",
"$",
"src",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"src",
")",
";",
"}",
"foreach",
"(",
"$",
"src",
"as",
"$",
"i",
")",
"{",
"$",
"row",
"=",
"explode",
"(",
"':'",
",",
"$",
"i",
",",
"2",
")",
";",
"// header with no key/value - HTTP response, get code and status",
"if",
"(",
"!",
"isset",
"(",
"$",
"row",
"[",
"1",
"]",
")",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"codeMatched",
"&&",
"preg_match",
"(",
"'#HTTP/1.[0-1] ([0-9]{3})(.*)#si'",
",",
"$",
"row",
"[",
"0",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"headers",
"[",
"'Code'",
"]",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"headers",
"[",
"'Status'",
"]",
"=",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"$",
"codeMatched",
"=",
"true",
";",
"}",
"continue",
";",
"}",
"$",
"key",
"=",
"trim",
"(",
"$",
"row",
"[",
"0",
"]",
")",
";",
"$",
"val",
"=",
"trim",
"(",
"$",
"row",
"[",
"1",
"]",
")",
";",
"$",
"headers",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"headers",
";",
"}"
]
| transform headers from $http_response_header
@param array $src
@internal param $headers
@internal param $http_response_header
@return array | [
"transform",
"headers",
"from",
"$http_response_header"
]
| train | https://github.com/xtcommerce/shop-appstore-lib/blob/b12637502f74e8d1288cf47817e4c02b7f507c3b/src/XTCommerce/ShopAppstoreLib/Http.php#L279-L312 |
aedart/laravel-helpers | src/Traits/Queue/QueueMonitorTrait.php | QueueMonitorTrait.getQueueMonitor | public function getQueueMonitor(): ?Monitor
{
if (!$this->hasQueueMonitor()) {
$this->setQueueMonitor($this->getDefaultQueueMonitor());
}
return $this->queueMonitor;
} | php | public function getQueueMonitor(): ?Monitor
{
if (!$this->hasQueueMonitor()) {
$this->setQueueMonitor($this->getDefaultQueueMonitor());
}
return $this->queueMonitor;
} | [
"public",
"function",
"getQueueMonitor",
"(",
")",
":",
"?",
"Monitor",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasQueueMonitor",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setQueueMonitor",
"(",
"$",
"this",
"->",
"getDefaultQueueMonitor",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"queueMonitor",
";",
"}"
]
| Get queue monitor
If no queue monitor has been set, this method will
set and return a default queue monitor, if any such
value is available
@see getDefaultQueueMonitor()
@return Monitor|null queue monitor or null if none queue monitor has been set | [
"Get",
"queue",
"monitor"
]
| train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Queue/QueueMonitorTrait.php#L53-L59 |
ClanCats/Core | src/classes/CCArr.php | CCArr.push | public static function push( $item, &$arr, $merge = false )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::push - second argument has to be an array.');
}
if ( $merge && is_array( $item ) )
{
foreach ( $item as $value )
{
$arr[] = $value;
}
return $arr;
}
$arr[] = $item;
return $arr;
} | php | public static function push( $item, &$arr, $merge = false )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::push - second argument has to be an array.');
}
if ( $merge && is_array( $item ) )
{
foreach ( $item as $value )
{
$arr[] = $value;
}
return $arr;
}
$arr[] = $item;
return $arr;
} | [
"public",
"static",
"function",
"push",
"(",
"$",
"item",
",",
"&",
"$",
"arr",
",",
"$",
"merge",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::push - second argument has to be an array.'",
")",
";",
"}",
"if",
"(",
"$",
"merge",
"&&",
"is_array",
"(",
"$",
"item",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"$",
"value",
")",
"{",
"$",
"arr",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"arr",
";",
"}",
"$",
"arr",
"[",
"]",
"=",
"$",
"item",
";",
"return",
"$",
"arr",
";",
"}"
]
| Adds a single item or array of items at the end of the referenced array
If you want to combine multiple arrays recursivly or use key => value pairs, please use CCArr::merge()
Example:
$bar = array( 'bar' );
CCArr::push( 'foo', $bar ); // $bar = array( 'bar', 'foo' )
CCArr::push( array( 'foo', 'baz' ), $bar ); // $bar = array( 'bar', array( 'foo', 'baz' ) )
CCArr::push( array( 'foo', 'baz' ), $bar, true ); // $bar = array( 'bar', 'foo', 'baz' )
@param mixed $item The item you would like to add to the array
@param array $array The input array by reference
@param bool $merge If $merge is set to true, push will merge each element of $item into $array
@return array | [
"Adds",
"a",
"single",
"item",
"or",
"array",
"of",
"items",
"at",
"the",
"end",
"of",
"the",
"referenced",
"array",
"If",
"you",
"want",
"to",
"combine",
"multiple",
"arrays",
"recursivly",
"or",
"use",
"key",
"=",
">",
"value",
"pairs",
"please",
"use",
"CCArr",
"::",
"merge",
"()"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L52-L69 |
ClanCats/Core | src/classes/CCArr.php | CCArr.add | public static function add( $key, $item, &$arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::add - second argument has to be an array.');
}
if ( !is_array( static::get( $key, $arr ) ) )
{
return static::set( $key, array( $item ), $arr );
}
return static::set( $key, static::push( $item, static::get( $key, $arr ) ), $arr );
} | php | public static function add( $key, $item, &$arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::add - second argument has to be an array.');
}
if ( !is_array( static::get( $key, $arr ) ) )
{
return static::set( $key, array( $item ), $arr );
}
return static::set( $key, static::push( $item, static::get( $key, $arr ) ), $arr );
} | [
"public",
"static",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"item",
",",
"&",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::add - second argument has to be an array.'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"static",
"::",
"get",
"(",
"$",
"key",
",",
"$",
"arr",
")",
")",
")",
"{",
"return",
"static",
"::",
"set",
"(",
"$",
"key",
",",
"array",
"(",
"$",
"item",
")",
",",
"$",
"arr",
")",
";",
"}",
"return",
"static",
"::",
"set",
"(",
"$",
"key",
",",
"static",
"::",
"push",
"(",
"$",
"item",
",",
"static",
"::",
"get",
"(",
"$",
"key",
",",
"$",
"arr",
")",
")",
",",
"$",
"arr",
")",
";",
"}"
]
| Adds an item to an element in the array
Example:
CCArr::add( 'foo.bar', 'test' );
Results:
array( 'foo' => array( 'bar' => array( 'test' ) ) )
@param string $key
@param mixed $item The item you would like to add to the array
@param array $array
@return array | [
"Adds",
"an",
"item",
"to",
"an",
"element",
"in",
"the",
"array"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L85-L98 |
ClanCats/Core | src/classes/CCArr.php | CCArr.pick | public static function pick( $key, $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::pick - second argument has to be an array.');
}
$return = array();
foreach( $arr as $array )
{
$return[] = CCArr::get( $key, $array );
}
return $return;
} | php | public static function pick( $key, $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::pick - second argument has to be an array.');
}
$return = array();
foreach( $arr as $array )
{
$return[] = CCArr::get( $key, $array );
}
return $return;
} | [
"public",
"static",
"function",
"pick",
"(",
"$",
"key",
",",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::pick - second argument has to be an array.'",
")",
";",
"}",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"array",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"CCArr",
"::",
"get",
"(",
"$",
"key",
",",
"$",
"array",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
]
| get a special item from every array
@param mixed $key
@param array[array] $arr
@return array | [
"get",
"a",
"special",
"item",
"from",
"every",
"array"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L107-L122 |
ClanCats/Core | src/classes/CCArr.php | CCArr.pick_object | public static function pick_object( $key, $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::pick - second argument has to be an array.');
}
$return = array();
foreach( $arr as $object )
{
$return[] = $object->{$key};
}
return $return;
} | php | public static function pick_object( $key, $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::pick - second argument has to be an array.');
}
$return = array();
foreach( $arr as $object )
{
$return[] = $object->{$key};
}
return $return;
} | [
"public",
"static",
"function",
"pick_object",
"(",
"$",
"key",
",",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::pick - second argument has to be an array.'",
")",
";",
"}",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"object",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"object",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"return",
"$",
"return",
";",
"}"
]
| get a special item from every array
@param mixed $key
@param array[obj] $arr
@return array | [
"get",
"a",
"special",
"item",
"from",
"every",
"array"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L131-L146 |
ClanCats/Core | src/classes/CCArr.php | CCArr.sum | public static function sum( $arr, $key = null )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::sum - first argument has to be an array.');
}
$sum = 0;
if ( is_string( $key ) && CCArr::is_multi( $arr ) )
{
$arr = CCArr::pick( $key, $arr );
}
foreach ( $arr as $item )
{
if ( is_numeric( $item ) )
{
$sum += $item;
}
}
return $sum;
} | php | public static function sum( $arr, $key = null )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::sum - first argument has to be an array.');
}
$sum = 0;
if ( is_string( $key ) && CCArr::is_multi( $arr ) )
{
$arr = CCArr::pick( $key, $arr );
}
foreach ( $arr as $item )
{
if ( is_numeric( $item ) )
{
$sum += $item;
}
}
return $sum;
} | [
"public",
"static",
"function",
"sum",
"(",
"$",
"arr",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::sum - first argument has to be an array.'",
")",
";",
"}",
"$",
"sum",
"=",
"0",
";",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
"&&",
"CCArr",
"::",
"is_multi",
"(",
"$",
"arr",
")",
")",
"{",
"$",
"arr",
"=",
"CCArr",
"::",
"pick",
"(",
"$",
"key",
",",
"$",
"arr",
")",
";",
"}",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"item",
")",
")",
"{",
"$",
"sum",
"+=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"sum",
";",
"}"
]
| sum items in an array or use special item in the array
@param array[array] $arr
@param string $key | [
"sum",
"items",
"in",
"an",
"array",
"or",
"use",
"special",
"item",
"in",
"the",
"array"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L192-L215 |
ClanCats/Core | src/classes/CCArr.php | CCArr.average | public static function average( $arr, $key = null )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::average - first argunent has to be an array.');
}
if ( is_string( $key ) && CCArr::is_multi( $arr ) )
{
$arr = CCArr::pick( $key, $arr );
}
return ( static::sum( $arr ) / count( $arr ) );
} | php | public static function average( $arr, $key = null )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::average - first argunent has to be an array.');
}
if ( is_string( $key ) && CCArr::is_multi( $arr ) )
{
$arr = CCArr::pick( $key, $arr );
}
return ( static::sum( $arr ) / count( $arr ) );
} | [
"public",
"static",
"function",
"average",
"(",
"$",
"arr",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::average - first argunent has to be an array.'",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
"&&",
"CCArr",
"::",
"is_multi",
"(",
"$",
"arr",
")",
")",
"{",
"$",
"arr",
"=",
"CCArr",
"::",
"pick",
"(",
"$",
"key",
",",
"$",
"arr",
")",
";",
"}",
"return",
"(",
"static",
"::",
"sum",
"(",
"$",
"arr",
")",
"/",
"count",
"(",
"$",
"arr",
")",
")",
";",
"}"
]
| get the average of the items
@param array[array] $arr
@param string $key | [
"get",
"the",
"average",
"of",
"the",
"items"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L223-L236 |
ClanCats/Core | src/classes/CCArr.php | CCArr.object | public static function object( $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException("CCArr::object - only arrays can be passed.");
}
$object = new \stdClass();
if ( !empty( $arr ) )
{
foreach ( $arr as $name => $value)
{
if ( is_array( $value ) )
{
$value = static::object( $value );
}
$object->$name = $value;
}
}
return $object;
} | php | public static function object( $arr )
{
if( !is_array( $arr ) )
{
throw new \InvalidArgumentException("CCArr::object - only arrays can be passed.");
}
$object = new \stdClass();
if ( !empty( $arr ) )
{
foreach ( $arr as $name => $value)
{
if ( is_array( $value ) )
{
$value = static::object( $value );
}
$object->$name = $value;
}
}
return $object;
} | [
"public",
"static",
"function",
"object",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"CCArr::object - only arrays can be passed.\"",
")",
";",
"}",
"$",
"object",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"arr",
")",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"object",
"(",
"$",
"value",
")",
";",
"}",
"$",
"object",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"object",
";",
"}"
]
| create an object from an array
@param array $array
@return object | [
"create",
"an",
"object",
"from",
"an",
"array"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L244-L266 |
ClanCats/Core | src/classes/CCArr.php | CCArr.merge | public static function merge()
{
// get all arguments
$arrs = func_get_args();
$return = array();
foreach ( $arrs as $arr )
{
if ( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::merge - all arguments have to be arrays.');
}
foreach ( $arr as $key => $value )
{
if ( array_key_exists( $key, $return ) )
{
if ( is_array( $value ) && is_array( $return[$key] ) )
{
$value = static::merge( $return[$key], $value );
}
}
$return[$key] = $value;
}
}
return $return;
} | php | public static function merge()
{
// get all arguments
$arrs = func_get_args();
$return = array();
foreach ( $arrs as $arr )
{
if ( !is_array( $arr ) )
{
throw new \InvalidArgumentException('CCArr::merge - all arguments have to be arrays.');
}
foreach ( $arr as $key => $value )
{
if ( array_key_exists( $key, $return ) )
{
if ( is_array( $value ) && is_array( $return[$key] ) )
{
$value = static::merge( $return[$key], $value );
}
}
$return[$key] = $value;
}
}
return $return;
} | [
"public",
"static",
"function",
"merge",
"(",
")",
"{",
"// get all arguments",
"$",
"arrs",
"=",
"func_get_args",
"(",
")",
";",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arrs",
"as",
"$",
"arr",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'CCArr::merge - all arguments have to be arrays.'",
")",
";",
"}",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"return",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"is_array",
"(",
"$",
"return",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"merge",
"(",
"$",
"return",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
]
| merge arrays recursivly together
@param array $array ...
@return array | [
"merge",
"arrays",
"recursivly",
"together"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L274-L301 |
ClanCats/Core | src/classes/CCArr.php | CCArr.get | public static function get( $key, $arr, $default = null )
{
if ( isset( $arr[$key] ) )
{
return $arr[$key];
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) )
{
case 2:
if ( isset( $arr[$kp[0]][$kp[1]] ) )
{
return $arr[$kp[0]][$kp[1]];
}
break;
case 3:
if ( isset( $arr[$kp[0]][$kp[1]][$kp[2]] ) )
{
return $arr[$kp[0]][$kp[1]][$kp[2]];
}
break;
case 4:
if ( isset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ) )
{
return $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]];
}
break;
// if there are more then 4 parts loop trough them
default:
$curr = $arr;
foreach( $kp as $k )
{
if ( isset( $curr[$k] ) ) {
$curr = $curr[$k];
} else {
return $default;
}
}
return $curr;
break;
}
}
return $default;
} | php | public static function get( $key, $arr, $default = null )
{
if ( isset( $arr[$key] ) )
{
return $arr[$key];
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) )
{
case 2:
if ( isset( $arr[$kp[0]][$kp[1]] ) )
{
return $arr[$kp[0]][$kp[1]];
}
break;
case 3:
if ( isset( $arr[$kp[0]][$kp[1]][$kp[2]] ) )
{
return $arr[$kp[0]][$kp[1]][$kp[2]];
}
break;
case 4:
if ( isset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ) )
{
return $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]];
}
break;
// if there are more then 4 parts loop trough them
default:
$curr = $arr;
foreach( $kp as $k )
{
if ( isset( $curr[$k] ) ) {
$curr = $curr[$k];
} else {
return $default;
}
}
return $curr;
break;
}
}
return $default;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"arr",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"arr",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"kp",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"kp",
")",
")",
"{",
"case",
"2",
":",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
")",
")",
"{",
"return",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
";",
"}",
"break",
";",
"case",
"3",
":",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
")",
")",
"{",
"return",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
";",
"}",
"break",
";",
"case",
"4",
":",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"[",
"$",
"kp",
"[",
"3",
"]",
"]",
")",
")",
"{",
"return",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"[",
"$",
"kp",
"[",
"3",
"]",
"]",
";",
"}",
"break",
";",
"// if there are more then 4 parts loop trough them",
"default",
":",
"$",
"curr",
"=",
"$",
"arr",
";",
"foreach",
"(",
"$",
"kp",
"as",
"$",
"k",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"curr",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"curr",
"=",
"$",
"curr",
"[",
"$",
"k",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"default",
";",
"}",
"}",
"return",
"$",
"curr",
";",
"break",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
]
| return an item from an array with dottet dimensions
@param string $key
@param array $arr
@param mixed $default
@return mixed | [
"return",
"an",
"item",
"from",
"an",
"array",
"with",
"dottet",
"dimensions"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L311-L360 |
ClanCats/Core | src/classes/CCArr.php | CCArr.has | public static function has( $key, $arr )
{
if ( isset( $arr[$key] ) )
{
return true;
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) ) {
case 2:
return isset( $arr[$kp[0]][$kp[1]] ); break;
case 3:
return isset( $arr[$kp[0]][$kp[1]][$kp[2]] ); break;
case 4:
return isset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ); break;
// if there are more then 4 parts loop trough them
default:
$curr = $arr;
foreach( $kp as $k )
{
if ( isset( $curr[$k] ) ) {
$curr = $curr[$k];
} else {
return false;
}
}
return true;
break;
}
}
return false;
} | php | public static function has( $key, $arr )
{
if ( isset( $arr[$key] ) )
{
return true;
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) ) {
case 2:
return isset( $arr[$kp[0]][$kp[1]] ); break;
case 3:
return isset( $arr[$kp[0]][$kp[1]][$kp[2]] ); break;
case 4:
return isset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ); break;
// if there are more then 4 parts loop trough them
default:
$curr = $arr;
foreach( $kp as $k )
{
if ( isset( $curr[$k] ) ) {
$curr = $curr[$k];
} else {
return false;
}
}
return true;
break;
}
}
return false;
} | [
"public",
"static",
"function",
"has",
"(",
"$",
"key",
",",
"$",
"arr",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"kp",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"kp",
")",
")",
"{",
"case",
"2",
":",
"return",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
")",
";",
"break",
";",
"case",
"3",
":",
"return",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
")",
";",
"break",
";",
"case",
"4",
":",
"return",
"isset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"[",
"$",
"kp",
"[",
"3",
"]",
"]",
")",
";",
"break",
";",
"// if there are more then 4 parts loop trough them",
"default",
":",
"$",
"curr",
"=",
"$",
"arr",
";",
"foreach",
"(",
"$",
"kp",
"as",
"$",
"k",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"curr",
"[",
"$",
"k",
"]",
")",
")",
"{",
"$",
"curr",
"=",
"$",
"curr",
"[",
"$",
"k",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"break",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| checks if the array has an item with dottet dimensions
@param string $key
@param array $arr
@return bool | [
"checks",
"if",
"the",
"array",
"has",
"an",
"item",
"with",
"dottet",
"dimensions"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L369-L404 |
ClanCats/Core | src/classes/CCArr.php | CCArr.set | public static function set( $key, $value, &$arr )
{
if ( strpos( $key, '.' ) === false )
{
$arr[$key] = $value;
}
else
{
$kp = explode( '.', $key );
switch ( count( $kp ) )
{
case 2:
$arr[$kp[0]][$kp[1]] = $value; break;
case 3:
$arr[$kp[0]][$kp[1]][$kp[2]] = $value; break;
case 4:
$arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] = $value; break;
// if there are more then 4 parts loop trough them
default:
$kp = array_reverse( $kp );
$curr = $value;
foreach( $kp as $k )
{
$curr = array( $k => $curr );
}
$arr = static::merge( $arr, $curr );
break;
}
}
return $arr;
} | php | public static function set( $key, $value, &$arr )
{
if ( strpos( $key, '.' ) === false )
{
$arr[$key] = $value;
}
else
{
$kp = explode( '.', $key );
switch ( count( $kp ) )
{
case 2:
$arr[$kp[0]][$kp[1]] = $value; break;
case 3:
$arr[$kp[0]][$kp[1]][$kp[2]] = $value; break;
case 4:
$arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] = $value; break;
// if there are more then 4 parts loop trough them
default:
$kp = array_reverse( $kp );
$curr = $value;
foreach( $kp as $k )
{
$curr = array( $k => $curr );
}
$arr = static::merge( $arr, $curr );
break;
}
}
return $arr;
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"&",
"$",
"arr",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"===",
"false",
")",
"{",
"$",
"arr",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"kp",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"kp",
")",
")",
"{",
"case",
"2",
":",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"3",
":",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"4",
":",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"[",
"$",
"kp",
"[",
"3",
"]",
"]",
"=",
"$",
"value",
";",
"break",
";",
"// if there are more then 4 parts loop trough them",
"default",
":",
"$",
"kp",
"=",
"array_reverse",
"(",
"$",
"kp",
")",
";",
"$",
"curr",
"=",
"$",
"value",
";",
"foreach",
"(",
"$",
"kp",
"as",
"$",
"k",
")",
"{",
"$",
"curr",
"=",
"array",
"(",
"$",
"k",
"=>",
"$",
"curr",
")",
";",
"}",
"$",
"arr",
"=",
"static",
"::",
"merge",
"(",
"$",
"arr",
",",
"$",
"curr",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"arr",
";",
"}"
]
| sets an item from an array with dottet dimensions
@param string $key
@param mixed $value
@param array $arr
@return array | [
"sets",
"an",
"item",
"from",
"an",
"array",
"with",
"dottet",
"dimensions"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L414-L449 |
ClanCats/Core | src/classes/CCArr.php | CCArr.delete | public static function delete( $key, &$arr )
{
if ( isset( $arr[$key] ) )
{
unset( $arr[$key] ); return;
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) ) {
case 2:
unset( $arr[$kp[0]][$kp[1]] ); return; break;
case 3:
unset( $arr[$kp[0]][$kp[1]][$kp[2]] ); return; break;
case 4:
unset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ); return; break;
}
}
} | php | public static function delete( $key, &$arr )
{
if ( isset( $arr[$key] ) )
{
unset( $arr[$key] ); return;
}
if ( strpos( $key, '.' ) !== false )
{
$kp = explode( '.', $key );
switch ( count( $kp ) ) {
case 2:
unset( $arr[$kp[0]][$kp[1]] ); return; break;
case 3:
unset( $arr[$kp[0]][$kp[1]][$kp[2]] ); return; break;
case 4:
unset( $arr[$kp[0]][$kp[1]][$kp[2]][$kp[3]] ); return; break;
}
}
} | [
"public",
"static",
"function",
"delete",
"(",
"$",
"key",
",",
"&",
"$",
"arr",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"arr",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"arr",
"[",
"$",
"key",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"kp",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"switch",
"(",
"count",
"(",
"$",
"kp",
")",
")",
"{",
"case",
"2",
":",
"unset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
")",
";",
"return",
";",
"break",
";",
"case",
"3",
":",
"unset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
")",
";",
"return",
";",
"break",
";",
"case",
"4",
":",
"unset",
"(",
"$",
"arr",
"[",
"$",
"kp",
"[",
"0",
"]",
"]",
"[",
"$",
"kp",
"[",
"1",
"]",
"]",
"[",
"$",
"kp",
"[",
"2",
"]",
"]",
"[",
"$",
"kp",
"[",
"3",
"]",
"]",
")",
";",
"return",
";",
"break",
";",
"}",
"}",
"}"
]
| deletes an item from an array with dottet dimensions
@param string $key
@param array $arr
@return void | [
"deletes",
"an",
"item",
"from",
"an",
"array",
"with",
"dottet",
"dimensions"
]
| train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCArr.php#L458-L478 |
inpsyde/inpsyde-filter | src/WordPress/RemoveAccents.php | RemoveAccents.filter | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
return remove_accents( $value );
} | php | public function filter( $value ) {
if ( ! is_string( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not string or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
return remove_accents( $value );
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"do_action",
"(",
"'inpsyde.filter.error'",
",",
"'The given value is not string or empty.'",
",",
"[",
"'method'",
"=>",
"__METHOD__",
",",
"'value'",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"value",
";",
"}",
"return",
"remove_accents",
"(",
"$",
"value",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/RemoveAccents.php#L17-L26 |
webforge-labs/psc-cms | lib/Psc/Net/RequestMatcher.php | RequestMatcher.qvar | public function qvar($name, $default = NULL) {
$query = (array) $this->request->getQuery();
return array_key_exists($name, $query) ? $query[$name] : $default;
} | php | public function qvar($name, $default = NULL) {
$query = (array) $this->request->getQuery();
return array_key_exists($name, $query) ? $query[$name] : $default;
} | [
"public",
"function",
"qvar",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"query",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"request",
"->",
"getQuery",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"query",
")",
"?",
"$",
"query",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
]
| Gibt die QueryVariable oder NULL zurück | [
"Gibt",
"die",
"QueryVariable",
"oder",
"NULL",
"zurück"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/RequestMatcher.php#L150-L153 |
webforge-labs/psc-cms | lib/Psc/Net/RequestMatcher.php | RequestMatcher.bvar | public function bvar($name, $default = NULL) {
$body = (object) $this->request->getBody();
return isset($body->$name) ? $body->$name : $default;
} | php | public function bvar($name, $default = NULL) {
$body = (object) $this->request->getBody();
return isset($body->$name) ? $body->$name : $default;
} | [
"public",
"function",
"bvar",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"body",
"=",
"(",
"object",
")",
"$",
"this",
"->",
"request",
"->",
"getBody",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"body",
"->",
"$",
"name",
")",
"?",
"$",
"body",
"->",
"$",
"name",
":",
"$",
"default",
";",
"}"
]
| Body Var | [
"Body",
"Var"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/RequestMatcher.php#L158-L161 |
webforge-labs/psc-cms | lib/Psc/Net/RequestMatcher.php | RequestMatcher.matchOrderBy | public function matchOrderBy($orderByValue, Array $mappings, Array $default = array()) {
if (is_string($orderByValue)) {
$orderByValue = array($orderByValue => 'ASC');
}
$orderBy = array();
if (is_array($orderByValue)) {
foreach ($orderByValue as $key => $sort) {
$sort = mb_stripos($sort, 'desc') !== FALSE ? 'DESC' : 'ASC';
if (array_key_exists($key, $mappings)) {
$alias = $mappings[$key] ?: $key;
$orderBy[$alias] = $sort;
}
}
}
if (empty($orderBy)) {
return $default;
}
return $orderBy;
} | php | public function matchOrderBy($orderByValue, Array $mappings, Array $default = array()) {
if (is_string($orderByValue)) {
$orderByValue = array($orderByValue => 'ASC');
}
$orderBy = array();
if (is_array($orderByValue)) {
foreach ($orderByValue as $key => $sort) {
$sort = mb_stripos($sort, 'desc') !== FALSE ? 'DESC' : 'ASC';
if (array_key_exists($key, $mappings)) {
$alias = $mappings[$key] ?: $key;
$orderBy[$alias] = $sort;
}
}
}
if (empty($orderBy)) {
return $default;
}
return $orderBy;
} | [
"public",
"function",
"matchOrderBy",
"(",
"$",
"orderByValue",
",",
"Array",
"$",
"mappings",
",",
"Array",
"$",
"default",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"orderByValue",
")",
")",
"{",
"$",
"orderByValue",
"=",
"array",
"(",
"$",
"orderByValue",
"=>",
"'ASC'",
")",
";",
"}",
"$",
"orderBy",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"orderByValue",
")",
")",
"{",
"foreach",
"(",
"$",
"orderByValue",
"as",
"$",
"key",
"=>",
"$",
"sort",
")",
"{",
"$",
"sort",
"=",
"mb_stripos",
"(",
"$",
"sort",
",",
"'desc'",
")",
"!==",
"FALSE",
"?",
"'DESC'",
":",
"'ASC'",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"mappings",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"mappings",
"[",
"$",
"key",
"]",
"?",
":",
"$",
"key",
";",
"$",
"orderBy",
"[",
"$",
"alias",
"]",
"=",
"$",
"sort",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"orderBy",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"orderBy",
";",
"}"
]
| Matches a value as it is meant to be a order by value
returns an orderby-array if the value can be parsed
returns the $default if the value cannot be parsed
the orderby array is like
array (string $field => string ASC|DESC, string $field2 => string ASC|DESC);
lowercase asc or desc will be converted. Other values will be expanded to ASC
if only string is given as value it is treated as $field and the sort is default to ASC | [
"Matches",
"a",
"value",
"as",
"it",
"is",
"meant",
"to",
"be",
"a",
"order",
"by",
"value"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/RequestMatcher.php#L176-L199 |
lode/fem | src/bootstrap.php | bootstrap.set_custom_library | public static function set_custom_library($name, $custom_class) {
if (class_exists('\\alsvanzelf\\fem\\'.$name) == false) {
throw new exception('library does not exist in fem');
}
self::$custom_libraries[$name] = $custom_class;
} | php | public static function set_custom_library($name, $custom_class) {
if (class_exists('\\alsvanzelf\\fem\\'.$name) == false) {
throw new exception('library does not exist in fem');
}
self::$custom_libraries[$name] = $custom_class;
} | [
"public",
"static",
"function",
"set_custom_library",
"(",
"$",
"name",
",",
"$",
"custom_class",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'\\\\alsvanzelf\\\\fem\\\\'",
".",
"$",
"name",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"exception",
"(",
"'library does not exist in fem'",
")",
";",
"}",
"self",
"::",
"$",
"custom_libraries",
"[",
"$",
"name",
"]",
"=",
"$",
"custom_class",
";",
"}"
]
| set a custom library for usage by other fem libraries
use this when extending a fem library
without this, fem will call the non-extended library in its own calls
@param string $name the name of the fem class, i.e. 'page'
@param string $custom_class the (fully qualified) name of the extending class
@return void | [
"set",
"a",
"custom",
"library",
"for",
"usage",
"by",
"other",
"fem",
"libraries",
"use",
"this",
"when",
"extending",
"a",
"fem",
"library",
"without",
"this",
"fem",
"will",
"call",
"the",
"non",
"-",
"extended",
"library",
"in",
"its",
"own",
"calls"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/bootstrap.php#L35-L41 |
lode/fem | src/bootstrap.php | bootstrap.get_library | public static function get_library($name) {
if (class_exists('\\alsvanzelf\\fem\\'.$name) == false) {
throw new exception('library does not exist in fem');
}
if (isset(self::$custom_libraries[$name])) {
return self::$custom_libraries[$name];
}
return '\\alsvanzelf\\fem\\'.$name;
} | php | public static function get_library($name) {
if (class_exists('\\alsvanzelf\\fem\\'.$name) == false) {
throw new exception('library does not exist in fem');
}
if (isset(self::$custom_libraries[$name])) {
return self::$custom_libraries[$name];
}
return '\\alsvanzelf\\fem\\'.$name;
} | [
"public",
"static",
"function",
"get_library",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"class_exists",
"(",
"'\\\\alsvanzelf\\\\fem\\\\'",
".",
"$",
"name",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"exception",
"(",
"'library does not exist in fem'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"custom_libraries",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"custom_libraries",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"'\\\\alsvanzelf\\\\fem\\\\'",
".",
"$",
"name",
";",
"}"
]
| get the class name which should be used for a certain fem library
used internally to determine whether a custom library has been set
returns the fem class name if no custom library is set
@param string $name the name of the fem class, i.e. 'page'
@return string the (fully qualified) name of the class which should be used | [
"get",
"the",
"class",
"name",
"which",
"should",
"be",
"used",
"for",
"a",
"certain",
"fem",
"library",
"used",
"internally",
"to",
"determine",
"whether",
"a",
"custom",
"library",
"has",
"been",
"set",
"returns",
"the",
"fem",
"class",
"name",
"if",
"no",
"custom",
"library",
"is",
"set"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/bootstrap.php#L51-L61 |
lode/fem | src/bootstrap.php | bootstrap.environment | private static function environment() {
$environment = getenv('APP_ENV') ?: 'production';
define('alsvanzelf\fem\ENVIRONMENT', $environment);
define('alsvanzelf\fem\ROOT_DIR', realpath(__DIR__.'/../../../../').'/');
define('alsvanzelf\fem\ROOT_DIR_APP', \alsvanzelf\fem\ROOT_DIR.'application/');
define('alsvanzelf\fem\CLI', (strpos(php_sapi_name(), 'cli') !== false || defined('STDIN')));
if (constant('\alsvanzelf\fem\ENVIRONMENT') == false) {
echo 'no environment set';
exit;
}
} | php | private static function environment() {
$environment = getenv('APP_ENV') ?: 'production';
define('alsvanzelf\fem\ENVIRONMENT', $environment);
define('alsvanzelf\fem\ROOT_DIR', realpath(__DIR__.'/../../../../').'/');
define('alsvanzelf\fem\ROOT_DIR_APP', \alsvanzelf\fem\ROOT_DIR.'application/');
define('alsvanzelf\fem\CLI', (strpos(php_sapi_name(), 'cli') !== false || defined('STDIN')));
if (constant('\alsvanzelf\fem\ENVIRONMENT') == false) {
echo 'no environment set';
exit;
}
} | [
"private",
"static",
"function",
"environment",
"(",
")",
"{",
"$",
"environment",
"=",
"getenv",
"(",
"'APP_ENV'",
")",
"?",
":",
"'production'",
";",
"define",
"(",
"'alsvanzelf\\fem\\ENVIRONMENT'",
",",
"$",
"environment",
")",
";",
"define",
"(",
"'alsvanzelf\\fem\\ROOT_DIR'",
",",
"realpath",
"(",
"__DIR__",
".",
"'/../../../../'",
")",
".",
"'/'",
")",
";",
"define",
"(",
"'alsvanzelf\\fem\\ROOT_DIR_APP'",
",",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"ROOT_DIR",
".",
"'application/'",
")",
";",
"define",
"(",
"'alsvanzelf\\fem\\CLI'",
",",
"(",
"strpos",
"(",
"php_sapi_name",
"(",
")",
",",
"'cli'",
")",
"!==",
"false",
"||",
"defined",
"(",
"'STDIN'",
")",
")",
")",
";",
"if",
"(",
"constant",
"(",
"'\\alsvanzelf\\fem\\ENVIRONMENT'",
")",
"==",
"false",
")",
"{",
"echo",
"'no environment set'",
";",
"exit",
";",
"}",
"}"
]
| environmental check
defines environment and root dir | [
"environmental",
"check",
"defines",
"environment",
"and",
"root",
"dir"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/bootstrap.php#L67-L79 |
lode/fem | src/bootstrap.php | bootstrap.uncertain | private static function uncertain() {
ini_set('display_startup_errors', 0);
ini_set('display_errors', 0);
error_reporting(0);
if (\alsvanzelf\fem\ENVIRONMENT == 'development') {
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
}
$error_handler = function($level, $message, $file, $line, $context) {
throw new \ErrorException($message, $code=0, $level, $file, $line);
};
set_error_handler($error_handler);
} | php | private static function uncertain() {
ini_set('display_startup_errors', 0);
ini_set('display_errors', 0);
error_reporting(0);
if (\alsvanzelf\fem\ENVIRONMENT == 'development') {
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
}
$error_handler = function($level, $message, $file, $line, $context) {
throw new \ErrorException($message, $code=0, $level, $file, $line);
};
set_error_handler($error_handler);
} | [
"private",
"static",
"function",
"uncertain",
"(",
")",
"{",
"ini_set",
"(",
"'display_startup_errors'",
",",
"0",
")",
";",
"ini_set",
"(",
"'display_errors'",
",",
"0",
")",
";",
"error_reporting",
"(",
"0",
")",
";",
"if",
"(",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"ENVIRONMENT",
"==",
"'development'",
")",
"{",
"ini_set",
"(",
"'display_startup_errors'",
",",
"1",
")",
";",
"ini_set",
"(",
"'display_errors'",
",",
"1",
")",
";",
"error_reporting",
"(",
"-",
"1",
")",
";",
"}",
"$",
"error_handler",
"=",
"function",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"file",
",",
"$",
"line",
",",
"$",
"context",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"$",
"message",
",",
"$",
"code",
"=",
"0",
",",
"$",
"level",
",",
"$",
"file",
",",
"$",
"line",
")",
";",
"}",
";",
"set_error_handler",
"(",
"$",
"error_handler",
")",
";",
"}"
]
| error handling
know when to say what depending on environment
and passes errors to exceptions | [
"error",
"handling",
"know",
"when",
"to",
"say",
"what",
"depending",
"on",
"environment",
"and",
"passes",
"errors",
"to",
"exceptions"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/bootstrap.php#L96-L110 |
lode/fem | src/bootstrap.php | bootstrap.secure | private static function secure() {
if (\alsvanzelf\fem\CLI) {
return;
}
header_remove('X-Powered-By');
ini_set('session.use_trans_sid', 0);
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1); // @note this is only effective from 5.5.2
ini_set('session.entropy_file', '/dev/urandom');
} | php | private static function secure() {
if (\alsvanzelf\fem\CLI) {
return;
}
header_remove('X-Powered-By');
ini_set('session.use_trans_sid', 0);
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
ini_set('session.use_strict_mode', 1); // @note this is only effective from 5.5.2
ini_set('session.entropy_file', '/dev/urandom');
} | [
"private",
"static",
"function",
"secure",
"(",
")",
"{",
"if",
"(",
"\\",
"alsvanzelf",
"\\",
"fem",
"\\",
"CLI",
")",
"{",
"return",
";",
"}",
"header_remove",
"(",
"'X-Powered-By'",
")",
";",
"ini_set",
"(",
"'session.use_trans_sid'",
",",
"0",
")",
";",
"ini_set",
"(",
"'session.use_only_cookies'",
",",
"1",
")",
";",
"ini_set",
"(",
"'session.cookie_httponly'",
",",
"1",
")",
";",
"ini_set",
"(",
"'session.use_strict_mode'",
",",
"1",
")",
";",
"// @note this is only effective from 5.5.2",
"ini_set",
"(",
"'session.entropy_file'",
",",
"'/dev/urandom'",
")",
";",
"}"
]
| basic security
stops outputting of php header
and help against session fixation | [
"basic",
"security",
"stops",
"outputting",
"of",
"php",
"header",
"and",
"help",
"against",
"session",
"fixation"
]
| train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/bootstrap.php#L117-L129 |
rayrutjes/domain-foundation | src/Specification/AndSpecification.php | AndSpecification.isSatisfiedBy | public function isSatisfiedBy($object)
{
return $this->left->isSatisfiedBy($object) && $this->right->isSatisfiedBy($object);
} | php | public function isSatisfiedBy($object)
{
return $this->left->isSatisfiedBy($object) && $this->right->isSatisfiedBy($object);
} | [
"public",
"function",
"isSatisfiedBy",
"(",
"$",
"object",
")",
"{",
"return",
"$",
"this",
"->",
"left",
"->",
"isSatisfiedBy",
"(",
"$",
"object",
")",
"&&",
"$",
"this",
"->",
"right",
"->",
"isSatisfiedBy",
"(",
"$",
"object",
")",
";",
"}"
]
| @param $object
@return bool | [
"@param",
"$object"
]
| train | https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Specification/AndSpecification.php#L32-L35 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.warnInsecureSettings | private function warnInsecureSettings(): void
{
if (!self::$warnInsecureSettings) {
return;
}
if (!ini_get('session.use_cookies')) {
$errorMessage = 'The ini setting session.use_cookies should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
if (!ini_get('session.use_only_cookies')) {
$errorMessage = 'The ini setting session.use_only_cookies should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
if (ini_get('session.use_trans_sid')) {
$errorMessage = 'The ini setting session.use_trans_id should be set to false.';
throw new InsecureSettingsException($errorMessage);
}
if (!ini_get('session.use_strict_mode')) {
$errorMessage = 'The ini setting session.use_strict_mode should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
} | php | private function warnInsecureSettings(): void
{
if (!self::$warnInsecureSettings) {
return;
}
if (!ini_get('session.use_cookies')) {
$errorMessage = 'The ini setting session.use_cookies should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
if (!ini_get('session.use_only_cookies')) {
$errorMessage = 'The ini setting session.use_only_cookies should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
if (ini_get('session.use_trans_sid')) {
$errorMessage = 'The ini setting session.use_trans_id should be set to false.';
throw new InsecureSettingsException($errorMessage);
}
if (!ini_get('session.use_strict_mode')) {
$errorMessage = 'The ini setting session.use_strict_mode should be set to true.';
throw new InsecureSettingsException($errorMessage);
}
} | [
"private",
"function",
"warnInsecureSettings",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"warnInsecureSettings",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"ini_get",
"(",
"'session.use_cookies'",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'The ini setting session.use_cookies should be set to true.'",
";",
"throw",
"new",
"InsecureSettingsException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"if",
"(",
"!",
"ini_get",
"(",
"'session.use_only_cookies'",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'The ini setting session.use_only_cookies should be set to true.'",
";",
"throw",
"new",
"InsecureSettingsException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"if",
"(",
"ini_get",
"(",
"'session.use_trans_sid'",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'The ini setting session.use_trans_id should be set to false.'",
";",
"throw",
"new",
"InsecureSettingsException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"if",
"(",
"!",
"ini_get",
"(",
"'session.use_strict_mode'",
")",
")",
"{",
"$",
"errorMessage",
"=",
"'The ini setting session.use_strict_mode should be set to true.'",
";",
"throw",
"new",
"InsecureSettingsException",
"(",
"$",
"errorMessage",
")",
";",
"}",
"}"
]
| Throws exceptions when insecure INI settings are detected.
@throws InsecureSettingsException
@return void | [
"Throws",
"exceptions",
"when",
"insecure",
"INI",
"settings",
"are",
"detected",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L73-L98 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.handleStrict | private function handleStrict(): void
{
if (!ini_get('session.use_strict_mode') || headers_sent()) {
return;
}
$cookieName = session_name();
if (empty($_COOKIE[$cookieName])) {
return;
}
$sessionId = $_COOKIE[$cookieName];
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
if ($this->storageDriver->sessionExists($identifier)) {
return;
}
$newSessionId = session_create_id();
session_id($newSessionId);
} | php | private function handleStrict(): void
{
if (!ini_get('session.use_strict_mode') || headers_sent()) {
return;
}
$cookieName = session_name();
if (empty($_COOKIE[$cookieName])) {
return;
}
$sessionId = $_COOKIE[$cookieName];
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
if ($this->storageDriver->sessionExists($identifier)) {
return;
}
$newSessionId = session_create_id();
session_id($newSessionId);
} | [
"private",
"function",
"handleStrict",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"ini_get",
"(",
"'session.use_strict_mode'",
")",
"||",
"headers_sent",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"cookieName",
"=",
"session_name",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"_COOKIE",
"[",
"$",
"cookieName",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"sessionId",
"=",
"$",
"_COOKIE",
"[",
"$",
"cookieName",
"]",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"if",
"(",
"$",
"this",
"->",
"storageDriver",
"->",
"sessionExists",
"(",
"$",
"identifier",
")",
")",
"{",
"return",
";",
"}",
"$",
"newSessionId",
"=",
"session_create_id",
"(",
")",
";",
"session_id",
"(",
"$",
"newSessionId",
")",
";",
"}"
]
| Rejects arbitrary session ids.
@SuppressWarnings(PHPMD.Superglobals)
@see http://php.net/manual/en/features.session.security.management.php#features.session.security.management.non-adaptive-session Why this security measure is important.
@return void | [
"Rejects",
"arbitrary",
"session",
"ids",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L108-L129 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.open | public function open($savePath, $sessionName): bool
{
$sessionId = session_id();
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
while (!$this->storageDriver->lock($identifier)) {
usleep(1000);
}
return true;
} | php | public function open($savePath, $sessionName): bool
{
$sessionId = session_id();
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
while (!$this->storageDriver->lock($identifier)) {
usleep(1000);
}
return true;
} | [
"public",
"function",
"open",
"(",
"$",
"savePath",
",",
"$",
"sessionName",
")",
":",
"bool",
"{",
"$",
"sessionId",
"=",
"session_id",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"storageDriver",
"->",
"lock",
"(",
"$",
"identifier",
")",
")",
"{",
"usleep",
"(",
"1000",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Opens the session.
@SuppressWarnings(PHPMD.UnusedFormalParameter)
@param string $savePath The path where the session files will be saved.
@param string $sessionName The name of the session
@return bool | [
"Opens",
"the",
"session",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L140-L151 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.close | public function close(): bool
{
$sessionId = session_id();
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
$this->storageDriver->unlock($identifier);
return true;
} | php | public function close(): bool
{
$sessionId = session_id();
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
$this->storageDriver->unlock($identifier);
return true;
} | [
"public",
"function",
"close",
"(",
")",
":",
"bool",
"{",
"$",
"sessionId",
"=",
"session_id",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"$",
"this",
"->",
"storageDriver",
"->",
"unlock",
"(",
"$",
"identifier",
")",
";",
"return",
"true",
";",
"}"
]
| Closes the session
@return bool | [
"Closes",
"the",
"session"
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L158-L167 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.read | public function read($sessionId): string
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
if (!$this->storageDriver->sessionExists($identifier)) {
return '';
}
$content = $this->storageDriver->get($identifier);
if (!$content) {
return '';
}
return $this->cryptProvider->decryptSessionData($sessionId, $content);
} | php | public function read($sessionId): string
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
if (!$this->storageDriver->sessionExists($identifier)) {
return '';
}
$content = $this->storageDriver->get($identifier);
if (!$content) {
return '';
}
return $this->cryptProvider->decryptSessionData($sessionId, $content);
} | [
"public",
"function",
"read",
"(",
"$",
"sessionId",
")",
":",
"string",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"storageDriver",
"->",
"sessionExists",
"(",
"$",
"identifier",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"storageDriver",
"->",
"get",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"cryptProvider",
"->",
"decryptSessionData",
"(",
"$",
"sessionId",
",",
"$",
"content",
")",
";",
"}"
]
| Return the decrypted (but still serialized) data of the session.
@param string $sessionId Id of the session
@return string Decrypted session data (still serialized) | [
"Return",
"the",
"decrypted",
"(",
"but",
"still",
"serialized",
")",
"data",
"of",
"the",
"session",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L175-L189 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.write | public function write($sessionId, $sessionData): bool
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
$content = $this->cryptProvider->encryptSessionData($sessionId, $sessionData);
try {
$this->storageDriver->save($identifier, $content);
return true;
} catch (Exception $e) {
return false;
}
} | php | public function write($sessionId, $sessionData): bool
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
$content = $this->cryptProvider->encryptSessionData($sessionId, $sessionData);
try {
$this->storageDriver->save($identifier, $content);
return true;
} catch (Exception $e) {
return false;
}
} | [
"public",
"function",
"write",
"(",
"$",
"sessionId",
",",
"$",
"sessionData",
")",
":",
"bool",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"encryptSessionData",
"(",
"$",
"sessionId",
",",
"$",
"sessionData",
")",
";",
"try",
"{",
"$",
"this",
"->",
"storageDriver",
"->",
"save",
"(",
"$",
"identifier",
",",
"$",
"content",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
]
| Encrypts the session data and saves to the storage;
@param string $sessionId Id of the session
@param string $sessionData Unencrypted session data
@return boolean | [
"Encrypts",
"the",
"session",
"data",
"and",
"saves",
"to",
"the",
"storage",
";"
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L198-L210 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.destroy | public function destroy($sessionId): bool
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
try {
$this->storageDriver->destroy($identifier);
return true;
} catch (Exception $e) {
return false;
}
} | php | public function destroy($sessionId): bool
{
$identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);
try {
$this->storageDriver->destroy($identifier);
return true;
} catch (Exception $e) {
return false;
}
} | [
"public",
"function",
"destroy",
"(",
"$",
"sessionId",
")",
":",
"bool",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"cryptProvider",
"->",
"makeSessionIdentifier",
"(",
"$",
"sessionId",
")",
";",
"try",
"{",
"$",
"this",
"->",
"storageDriver",
"->",
"destroy",
"(",
"$",
"identifier",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
]
| Destroys the session.
@param string $sessionId Id of the session
@return bool | [
"Destroys",
"the",
"session",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L218-L228 |
phpsess/session-handler | src/SessionHandler.php | SessionHandler.gc | public function gc($maxLife): bool
{
try {
$this->storageDriver->clearOld($maxLife * 1000000);
return true;
} catch (Exception $e) {
return false;
}
} | php | public function gc($maxLife): bool
{
try {
$this->storageDriver->clearOld($maxLife * 1000000);
return true;
} catch (Exception $e) {
return false;
}
} | [
"public",
"function",
"gc",
"(",
"$",
"maxLife",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"this",
"->",
"storageDriver",
"->",
"clearOld",
"(",
"$",
"maxLife",
"*",
"1000000",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
]
| Removes the expired sessions from the storage.
(GC stands for Garbage Collector)
@SuppressWarnings(PHPMD.ShortMethodName)
@param int $maxLife The maximum time (in seconds) that a session must be kept.
@return bool | [
"Removes",
"the",
"expired",
"sessions",
"from",
"the",
"storage",
"."
]
| train | https://github.com/phpsess/session-handler/blob/8b4e60e6a8d2da1c7cba0760523592f8952ef2fa/src/SessionHandler.php#L240-L248 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.ensureConsistency | public function ensureConsistency()
{
if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) {
$this->aUser = null;
}
if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
$this->aCustomer = null;
}
} | php | public function ensureConsistency()
{
if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) {
$this->aUser = null;
}
if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
$this->aCustomer = null;
}
} | [
"public",
"function",
"ensureConsistency",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aUser",
"!==",
"null",
"&&",
"$",
"this",
"->",
"user_id",
"!==",
"$",
"this",
"->",
"aUser",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"aUser",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"!==",
"null",
"&&",
"$",
"this",
"->",
"customer_id",
"!==",
"$",
"this",
"->",
"aCustomer",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"null",
";",
"}",
"}"
]
| Checks and repairs the internal consistency of the object.
This method is executed after an already-instantiated object is re-hydrated
from the database. It exists to check any foreign keys to make sure that
the objects related to the current object are correct based on foreign key.
You can override this method in the stub class, but you should always invoke
the base method from the overridden method (i.e. parent::ensureConsistency()),
in case your model changes.
@throws PropelException | [
"Checks",
"and",
"repairs",
"the",
"internal",
"consistency",
"of",
"the",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L259-L268 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.doInsert | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = UserCustomerRelationPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserCustomerRelationPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(UserCustomerRelationPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(UserCustomerRelationPeer::USER_ID)) {
$modifiedColumns[':p' . $index++] = '`user_id`';
}
if ($this->isColumnModified(UserCustomerRelationPeer::CUSTOMER_ID)) {
$modifiedColumns[':p' . $index++] = '`customer_id`';
}
$sql = sprintf(
'INSERT INTO `user_customer_relation` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`user_id`':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case '`customer_id`':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | php | protected function doInsert(PropelPDO $con)
{
$modifiedColumns = array();
$index = 0;
$this->modifiedColumns[] = UserCustomerRelationPeer::ID;
if (null !== $this->id) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserCustomerRelationPeer::ID . ')');
}
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(UserCustomerRelationPeer::ID)) {
$modifiedColumns[':p' . $index++] = '`id`';
}
if ($this->isColumnModified(UserCustomerRelationPeer::USER_ID)) {
$modifiedColumns[':p' . $index++] = '`user_id`';
}
if ($this->isColumnModified(UserCustomerRelationPeer::CUSTOMER_ID)) {
$modifiedColumns[':p' . $index++] = '`customer_id`';
}
$sql = sprintf(
'INSERT INTO `user_customer_relation` (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case '`id`':
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT);
break;
case '`user_id`':
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT);
break;
case '`customer_id`':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
}
try {
$pk = $con->lastInsertId();
} catch (Exception $e) {
throw new PropelException('Unable to get autoincrement id.', $e);
}
$this->setId($pk);
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"PropelPDO",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"]",
"=",
"UserCustomerRelationPeer",
"::",
"ID",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"id",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Cannot insert a value for auto-increment primary key ('",
".",
"UserCustomerRelationPeer",
"::",
"ID",
".",
"')'",
")",
";",
"}",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"USER_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`user_id`'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"CUSTOMER_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'`customer_id`'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO `user_customer_relation` (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'`id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`user_id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"user_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'`customer_id`'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"customer_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"pk",
"=",
"$",
"con",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"'Unable to get autoincrement id.'",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setId",
"(",
"$",
"pk",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
]
| Insert the row in the database.
@param PropelPDO $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L467-L523 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.doValidate | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if ($this->aCustomer !== null) {
if (!$this->aCustomer->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures());
}
}
if (($retval = UserCustomerRelationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | php | protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their corresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aUser !== null) {
if (!$this->aUser->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
}
}
if ($this->aCustomer !== null) {
if (!$this->aCustomer->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures());
}
}
if (($retval = UserCustomerRelationPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
} | [
"protected",
"function",
"doValidate",
"(",
"$",
"columns",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"alreadyInValidation",
")",
"{",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"true",
";",
"$",
"retval",
"=",
"null",
";",
"$",
"failureMap",
"=",
"array",
"(",
")",
";",
"// We call the validate method on the following object(s) if they",
"// were passed to this object by their corresponding set",
"// method. This object relates to these object(s) by a",
"// foreign key reference.",
"if",
"(",
"$",
"this",
"->",
"aUser",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"aUser",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"this",
"->",
"aUser",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"aCustomer",
"->",
"validate",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"this",
"->",
"aCustomer",
"->",
"getValidationFailures",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"(",
"$",
"retval",
"=",
"UserCustomerRelationPeer",
"::",
"doValidate",
"(",
"$",
"this",
",",
"$",
"columns",
")",
")",
"!==",
"true",
")",
"{",
"$",
"failureMap",
"=",
"array_merge",
"(",
"$",
"failureMap",
",",
"$",
"retval",
")",
";",
"}",
"$",
"this",
"->",
"alreadyInValidation",
"=",
"false",
";",
"}",
"return",
"(",
"!",
"empty",
"(",
"$",
"failureMap",
")",
"?",
"$",
"failureMap",
":",
"true",
")",
";",
"}"
]
| This function performs the validation work for complex object models.
In addition to checking the current object, all related objects will
also be validated. If all pass then <code>true</code> is returned; otherwise
an aggregated array of ValidationFailed objects will be returned.
@param array $columns Array of column names to validate.
@return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objects otherwise. | [
"This",
"function",
"performs",
"the",
"validation",
"work",
"for",
"complex",
"object",
"models",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L592-L629 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.getByName | public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserCustomerRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$field = $this->getByPosition($pos);
return $field;
} | php | public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserCustomerRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$field = $this->getByPosition($pos);
return $field;
} | [
"public",
"function",
"getByName",
"(",
"$",
"name",
",",
"$",
"type",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"pos",
"=",
"UserCustomerRelationPeer",
"::",
"translateFieldName",
"(",
"$",
"name",
",",
"$",
"type",
",",
"BasePeer",
"::",
"TYPE_NUM",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"getByPosition",
"(",
"$",
"pos",
")",
";",
"return",
"$",
"field",
";",
"}"
]
| Retrieves a field from the object by name passed in as a string.
@param string $name name
@param string $type The type of fieldname the $name is of:
one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME
@return mixed Value of field. | [
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"name",
"passed",
"in",
"as",
"a",
"string",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L641-L647 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.getByPosition | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getUserId();
break;
case 2:
return $this->getCustomerId();
break;
default:
return null;
break;
} // switch()
} | php | public function getByPosition($pos)
{
switch ($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getUserId();
break;
case 2:
return $this->getCustomerId();
break;
default:
return null;
break;
} // switch()
} | [
"public",
"function",
"getByPosition",
"(",
"$",
"pos",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"return",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"break",
";",
"case",
"1",
":",
"return",
"$",
"this",
"->",
"getUserId",
"(",
")",
";",
"break",
";",
"case",
"2",
":",
"return",
"$",
"this",
"->",
"getCustomerId",
"(",
")",
";",
"break",
";",
"default",
":",
"return",
"null",
";",
"break",
";",
"}",
"// switch()",
"}"
]
| Retrieves a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@return mixed Value of field at $pos | [
"Retrieves",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L656-L672 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.toArray | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['UserCustomerRelation'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['UserCustomerRelation'][$this->getPrimaryKey()] = true;
$keys = UserCustomerRelationPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getUserId(),
$keys[2] => $this->getCustomerId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
$result['User'] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCustomer) {
$result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | php | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['UserCustomerRelation'][$this->getPrimaryKey()])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['UserCustomerRelation'][$this->getPrimaryKey()] = true;
$keys = UserCustomerRelationPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getUserId(),
$keys[2] => $this->getCustomerId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aUser) {
$result['User'] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCustomer) {
$result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'UserCustomerRelation'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'UserCustomerRelation'",
"]",
"[",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"UserCustomerRelationPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getUserId",
"(",
")",
",",
"$",
"keys",
"[",
"2",
"]",
"=>",
"$",
"this",
"->",
"getCustomerId",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aUser",
")",
"{",
"$",
"result",
"[",
"'User'",
"]",
"=",
"$",
"this",
"->",
"aUser",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aCustomer",
")",
"{",
"$",
"result",
"[",
"'Customer'",
"]",
"=",
"$",
"this",
"->",
"aCustomer",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L689-L716 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.setByName | public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserCustomerRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$this->setByPosition($pos, $value);
} | php | public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = UserCustomerRelationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
$this->setByPosition($pos, $value);
} | [
"public",
"function",
"setByName",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"type",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"pos",
"=",
"UserCustomerRelationPeer",
"::",
"translateFieldName",
"(",
"$",
"name",
",",
"$",
"type",
",",
"BasePeer",
"::",
"TYPE_NUM",
")",
";",
"$",
"this",
"->",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
";",
"}"
]
| Sets a field from the object by name passed in as a string.
@param string $name peer name
@param mixed $value field value
@param string $type The type of fieldname the $name is of:
one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
Defaults to BasePeer::TYPE_PHPNAME
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"name",
"passed",
"in",
"as",
"a",
"string",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L729-L734 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setUserId($value);
break;
case 2:
$this->setCustomerId($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setUserId($value);
break;
case 2:
$this->setCustomerId($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
]
| Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L744-L757 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.fromArray | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserCustomerRelationPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
} | php | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = UserCustomerRelationPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"BasePeer",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"UserCustomerRelationPeer",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setUserId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"2",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"2",
"]",
"]",
")",
";",
"}"
]
| Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
The default key type is the column's BasePeer::TYPE_PHPNAME
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L776-L783 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
if ($this->isColumnModified(UserCustomerRelationPeer::ID)) $criteria->add(UserCustomerRelationPeer::ID, $this->id);
if ($this->isColumnModified(UserCustomerRelationPeer::USER_ID)) $criteria->add(UserCustomerRelationPeer::USER_ID, $this->user_id);
if ($this->isColumnModified(UserCustomerRelationPeer::CUSTOMER_ID)) $criteria->add(UserCustomerRelationPeer::CUSTOMER_ID, $this->customer_id);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(UserCustomerRelationPeer::DATABASE_NAME);
if ($this->isColumnModified(UserCustomerRelationPeer::ID)) $criteria->add(UserCustomerRelationPeer::ID, $this->id);
if ($this->isColumnModified(UserCustomerRelationPeer::USER_ID)) $criteria->add(UserCustomerRelationPeer::USER_ID, $this->user_id);
if ($this->isColumnModified(UserCustomerRelationPeer::CUSTOMER_ID)) $criteria->add(UserCustomerRelationPeer::CUSTOMER_ID, $this->customer_id);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"UserCustomerRelationPeer",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"ID",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"USER_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"USER_ID",
",",
"$",
"this",
"->",
"user_id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"UserCustomerRelationPeer",
"::",
"CUSTOMER_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"UserCustomerRelationPeer",
"::",
"CUSTOMER_ID",
",",
"$",
"this",
"->",
"customer_id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
]
| Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L790-L799 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setUserId($this->getUserId());
$copyObj->setCustomerId($this->getCustomerId());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setUserId($this->getUserId());
$copyObj->setCustomerId($this->getCustomerId());
if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
// store object hash to prevent cycle
$this->startCopy = true;
//unflag object copy
$this->startCopy = false;
} // if ($deepCopy)
if ($makeNew) {
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setUserId",
"(",
"$",
"this",
"->",
"getUserId",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setCustomerId",
"(",
"$",
"this",
"->",
"getCustomerId",
"(",
")",
")",
";",
"if",
"(",
"$",
"deepCopy",
"&&",
"!",
"$",
"this",
"->",
"startCopy",
")",
"{",
"// important: temporarily setNew(false) because this affects the behavior of",
"// the getter/setter methods for fkey referrer objects.",
"$",
"copyObj",
"->",
"setNew",
"(",
"false",
")",
";",
"// store object hash to prevent cycle",
"$",
"this",
"->",
"startCopy",
"=",
"true",
";",
"//unflag object copy",
"$",
"this",
"->",
"startCopy",
"=",
"false",
";",
"}",
"// if ($deepCopy)",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"copyObj",
"->",
"setId",
"(",
"NULL",
")",
";",
"// this is a auto-increment column, so set to default value",
"}",
"}"
]
| Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of UserCustomerRelation (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L858-L878 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.setCustomer | public function setCustomer(Customer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Customer object, it will not be re-added.
if ($v !== null) {
$v->addUserCustomerRelation($this);
}
return $this;
} | php | public function setCustomer(Customer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the Customer object, it will not be re-added.
if ($v !== null) {
$v->addUserCustomerRelation($this);
}
return $this;
} | [
"public",
"function",
"setCustomer",
"(",
"Customer",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aCustomer",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the Customer object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addUserCustomerRelation",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Declares an association between this object and a Customer object.
@param Customer $v
@return UserCustomerRelation The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"Customer",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L979-L997 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php | BaseUserCustomerRelation.getCustomer | public function getCustomer(PropelPDO $con = null, $doQuery = true)
{
if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addUserCustomerRelations($this);
*/
}
return $this->aCustomer;
} | php | public function getCustomer(PropelPDO $con = null, $doQuery = true)
{
if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addUserCustomerRelations($this);
*/
}
return $this->aCustomer;
} | [
"public",
"function",
"getCustomer",
"(",
"PropelPDO",
"$",
"con",
"=",
"null",
",",
"$",
"doQuery",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"customer_id",
"!==",
"null",
")",
"&&",
"$",
"doQuery",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"CustomerQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"customer_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aCustomer->addUserCustomerRelations($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aCustomer",
";",
"}"
]
| Get the associated Customer object
@param PropelPDO $con Optional Connection object.
@param $doQuery Executes a query to get the object if required
@return Customer The associated Customer object.
@throws PropelException | [
"Get",
"the",
"associated",
"Customer",
"object"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseUserCustomerRelation.php#L1008-L1022 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withProtocolVersion | public function withProtocolVersion($version)
{
$previousRequest = $this->previousRequest->withProtocolVersion($version);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withProtocolVersion($version)
{
$previousRequest = $this->previousRequest->withProtocolVersion($version);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withProtocolVersion",
"(",
"$",
"version",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withProtocolVersion",
"(",
"$",
"version",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified HTTP protocol version.
The version string MUST contain only the HTTP version number (e.g.,
"1.1", "1.0").
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
new protocol version.
@param string $version HTTP protocol version
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"HTTP",
"protocol",
"version",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L92-L98 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withHeader | public function withHeader($name, $value)
{
$previousRequest = $this->previousRequest->withHeader($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withHeader($name, $value)
{
$previousRequest = $this->previousRequest->withHeader($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the provided value replacing the specified header.
While header names are case-insensitive, the casing of the header will
be preserved by this function, and returned from getHeaders().
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
new and/or updated header and value.
@param string $name case-insensitive header field name
@param string|string[] $value header value(s)
@throws \InvalidArgumentException for invalid header names or values
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"provided",
"value",
"replacing",
"the",
"specified",
"header",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L201-L207 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withAddedHeader | public function withAddedHeader($name, $value)
{
$previousRequest = $this->previousRequest->withAddedHeader($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withAddedHeader($name, $value)
{
$previousRequest = $this->previousRequest->withAddedHeader($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withAddedHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withAddedHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified header appended with the given value.
Existing values for the specified header will be maintained. The new
value(s) will be appended to the existing list. If the header did not
exist previously, it will be added.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
new header and/or value.
@param string $name case-insensitive header field name to add
@param string|string[] $value header value(s)
@throws \InvalidArgumentException for invalid header names or values
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"header",
"appended",
"with",
"the",
"given",
"value",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L225-L231 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withoutHeader | public function withoutHeader($name)
{
$previousRequest = $this->previousRequest->withoutHeader($name);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withoutHeader($name)
{
$previousRequest = $this->previousRequest->withoutHeader($name);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withoutHeader",
"(",
"$",
"name",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withoutHeader",
"(",
"$",
"name",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance without the specified header.
Header resolution MUST be done without case-sensitivity.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that removes
the named header.
@param string $name case-insensitive header field name to remove
@return static | [
"Return",
"an",
"instance",
"without",
"the",
"specified",
"header",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L245-L251 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withBody | public function withBody(StreamInterface $body)
{
$previousRequest = $this->previousRequest->withBody($body);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withBody(StreamInterface $body)
{
$previousRequest = $this->previousRequest->withBody($body);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withBody",
"(",
"StreamInterface",
"$",
"body",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withBody",
"(",
"$",
"body",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified message body.
The body MUST be a StreamInterface object.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return a new instance that has the
new body stream.
@param StreamInterface $body body
@throws \InvalidArgumentException when the body is not valid
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"message",
"body",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L276-L282 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withRequestTarget | public function withRequestTarget($requestTarget)
{
$previousRequest = $this->previousRequest->withRequestTarget($requestTarget);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withRequestTarget($requestTarget)
{
$previousRequest = $this->previousRequest->withRequestTarget($requestTarget);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withRequestTarget",
"(",
"$",
"requestTarget",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withRequestTarget",
"(",
"$",
"requestTarget",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specific request-target.
If the request needs a non-origin-form request-target — e.g., for
specifying an absolute-form, authority-form, or asterisk-form —
this method may be used to create an instance with the specified
request-target, verbatim.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
changed request target.
@see http://tools.ietf.org/html/rfc7230#section-5.3 (for the various
request-target forms allowed in request messages)
@param mixed $requestTarget
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specific",
"request",
"-",
"target",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L322-L328 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withMethod | public function withMethod($method)
{
$previousRequest = $this->previousRequest->withMethod($method);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withMethod($method)
{
$previousRequest = $this->previousRequest->withMethod($method);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withMethod",
"(",
"$",
"method",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withMethod",
"(",
"$",
"method",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the provided HTTP method.
While HTTP method names are typically all uppercase characters, HTTP
method names are case-sensitive and thus implementations SHOULD NOT
modify the given string.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
changed request method.
@param string $method case-sensitive method
@throws \InvalidArgumentException for invalid HTTP methods
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"provided",
"HTTP",
"method",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L355-L361 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withUri | public function withUri(UriInterface $uri, $preserveHost = false)
{
$previousRequest = $this->previousRequest->withUri($uri, $preserveHost);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withUri(UriInterface $uri, $preserveHost = false)
{
$previousRequest = $this->previousRequest->withUri($uri, $preserveHost);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withUri",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"preserveHost",
"=",
"false",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withUri",
"(",
"$",
"uri",
",",
"$",
"preserveHost",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Returns an instance with the provided URI.
This method MUST update the Host header of the returned request by
default if the URI contains a host component. If the URI does not
contain a host component, any pre-existing Host header MUST be carried
over to the returned request.
You can opt-in to preserving the original state of the Host header by
setting `$preserveHost` to `true`. When `$preserveHost` is set to
`true`, this method interacts with the Host header in the following ways:
- If the Host header is missing or empty, and the new URI contains
a host component, this method MUST update the Host header in the returned
request.
- If the Host header is missing or empty, and the new URI does not contain a
host component, this method MUST NOT update the Host header in the returned
request.
- If a Host header is present and non-empty, this method MUST NOT update
the Host header in the returned request.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
new UriInterface instance.
@see http://tools.ietf.org/html/rfc3986#section-4.3
@param UriInterface $uri new request URI to use
@param bool $preserveHost preserve the original state of the Host header
@return static | [
"Returns",
"an",
"instance",
"with",
"the",
"provided",
"URI",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L407-L413 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withCookieParams | public function withCookieParams(array $cookies)
{
$previousRequest = $this->previousRequest->withCookieParams($cookies);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withCookieParams(array $cookies)
{
$previousRequest = $this->previousRequest->withCookieParams($cookies);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withCookieParams",
"(",
"array",
"$",
"cookies",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withCookieParams",
"(",
"$",
"cookies",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified cookies.
The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST
be compatible with the structure of $_COOKIE. Typically, this data will
be injected at instantiation.
This method MUST NOT update the related Cookie header of the request
instance, nor related values in the server params.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
updated cookie values.
@param array $cookies array of key/value pairs representing cookies
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"cookies",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L461-L467 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withQueryParams | public function withQueryParams(array $query)
{
$previousRequest = $this->previousRequest->withQueryParams($query);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withQueryParams(array $query)
{
$previousRequest = $this->previousRequest->withQueryParams($query);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withQueryParams",
"(",
"array",
"$",
"query",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withQueryParams",
"(",
"$",
"query",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified query string arguments.
These values SHOULD remain immutable over the course of the incoming
request. They MAY be injected during instantiation, such as from PHP's
$_GET superglobal, or MAY be derived from some other value such as the
URI. In cases where the arguments are parsed from the URI, the data
MUST be compatible with what PHP's parse_str() would return for
purposes of how duplicate query parameters are handled, and how nested
sets are handled.
Setting query string arguments MUST NOT change the URI stored by the
request, nor the values in the server params.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
updated query string arguments.
@param array $query array of query string arguments, typically from
$_GET
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"query",
"string",
"arguments",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L508-L514 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withUploadedFiles | public function withUploadedFiles(array $uploadedFiles)
{
$previousRequest = $this->previousRequest->withUploadedFiles($uploadedFiles);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withUploadedFiles(array $uploadedFiles)
{
$previousRequest = $this->previousRequest->withUploadedFiles($uploadedFiles);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withUploadedFiles",
"(",
"array",
"$",
"uploadedFiles",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withUploadedFiles",
"(",
"$",
"uploadedFiles",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Create a new instance with the specified uploaded files.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
updated body parameters.
@param array $uploadedFiles an array tree of UploadedFileInterface instances
@throws \InvalidArgumentException if an invalid structure is provided
@return static | [
"Create",
"a",
"new",
"instance",
"with",
"the",
"specified",
"uploaded",
"files",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L544-L550 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withParsedBody | public function withParsedBody($data)
{
$previousRequest = $this->previousRequest->withParsedBody($data);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withParsedBody($data)
{
$previousRequest = $this->previousRequest->withParsedBody($data);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withParsedBody",
"(",
"$",
"data",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withParsedBody",
"(",
"$",
"data",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified body parameters.
These MAY be injected during instantiation.
If the request Content-Type is either application/x-www-form-urlencoded
or multipart/form-data, and the request method is POST, use this method
ONLY to inject the contents of $_POST.
The data IS NOT REQUIRED to come from $_POST, but MUST be the results of
deserializing the request body content. Deserialization/parsing returns
structured data, and, as such, this method ONLY accepts arrays or objects,
or a null value if nothing was available to parse.
As an example, if content negotiation determines that the request data
is a JSON payload, this method could be used to create a request
instance with the deserialized parameters.
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
updated body parameters.
@param null|array|object $data The deserialized body data. This will
typically be in an array or object.
@throws \InvalidArgumentException if an unsupported argument type is
provided
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"body",
"parameters",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L600-L606 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withAttribute | public function withAttribute($name, $value)
{
$previousRequest = $this->previousRequest->withAttribute($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withAttribute($name, $value)
{
$previousRequest = $this->previousRequest->withAttribute($name, $value);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance with the specified derived request attribute.
This method allows setting a single derived request attribute as
described in getAttributes().
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that has the
updated attribute.
@see getAttributes()
@param string $name the attribute name
@param mixed $value the value of the attribute
@return static | [
"Return",
"an",
"instance",
"with",
"the",
"specified",
"derived",
"request",
"attribute",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L659-L665 |
ixocreate/application | src/Http/Request/AbstractRequestWrapper.php | AbstractRequestWrapper.withoutAttribute | public function withoutAttribute($name)
{
$previousRequest = $this->previousRequest->withoutAttribute($name);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | php | public function withoutAttribute($name)
{
$previousRequest = $this->previousRequest->withoutAttribute($name);
$request = clone $this;
$request->previousRequest = $previousRequest;
return $request;
} | [
"public",
"function",
"withoutAttribute",
"(",
"$",
"name",
")",
"{",
"$",
"previousRequest",
"=",
"$",
"this",
"->",
"previousRequest",
"->",
"withoutAttribute",
"(",
"$",
"name",
")",
";",
"$",
"request",
"=",
"clone",
"$",
"this",
";",
"$",
"request",
"->",
"previousRequest",
"=",
"$",
"previousRequest",
";",
"return",
"$",
"request",
";",
"}"
]
| Return an instance that removes the specified derived request attribute.
This method allows removing a single derived request attribute as
described in getAttributes().
This method MUST be implemented in such a way as to retain the
immutability of the message, and MUST return an instance that removes
the attribute.
@see getAttributes()
@param string $name the attribute name
@return static | [
"Return",
"an",
"instance",
"that",
"removes",
"the",
"specified",
"derived",
"request",
"attribute",
"."
]
| train | https://github.com/ixocreate/application/blob/6b0ef355ecf96af63d0dd5b901b4c9a5a69daf05/src/Http/Request/AbstractRequestWrapper.php#L681-L687 |
yuncms/framework | src/user/models/RegistrationForm.php | RegistrationForm.register | public function register()
{
if (!$this->validate()) {
return false;
}
/** @var User $user */
$user = new User();
$user->setScenario(User::SCENARIO_EMAIL_REGISTER);
$this->loadAttributes($user);
if (!$user->register()) {
return false;
}
Yii::$app->session->setFlash('info', Yii::t('yuncms', 'Your account has been created and a message with further instructions has been sent to your email'));
return Yii::$app->getUser()->login($user, Yii::$app->settings->get('rememberFor','user'));
} | php | public function register()
{
if (!$this->validate()) {
return false;
}
/** @var User $user */
$user = new User();
$user->setScenario(User::SCENARIO_EMAIL_REGISTER);
$this->loadAttributes($user);
if (!$user->register()) {
return false;
}
Yii::$app->session->setFlash('info', Yii::t('yuncms', 'Your account has been created and a message with further instructions has been sent to your email'));
return Yii::$app->getUser()->login($user, Yii::$app->settings->get('rememberFor','user'));
} | [
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var User $user */",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"$",
"user",
"->",
"setScenario",
"(",
"User",
"::",
"SCENARIO_EMAIL_REGISTER",
")",
";",
"$",
"this",
"->",
"loadAttributes",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"user",
"->",
"register",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"'info'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Your account has been created and a message with further instructions has been sent to your email'",
")",
")",
";",
"return",
"Yii",
"::",
"$",
"app",
"->",
"getUser",
"(",
")",
"->",
"login",
"(",
"$",
"user",
",",
"Yii",
"::",
"$",
"app",
"->",
"settings",
"->",
"get",
"(",
"'rememberFor'",
",",
"'user'",
")",
")",
";",
"}"
]
| Registers a new user account. If registration was successful it will set flash message.
@return boolean | [
"Registers",
"a",
"new",
"user",
"account",
".",
"If",
"registration",
"was",
"successful",
"it",
"will",
"set",
"flash",
"message",
"."
]
| train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/user/models/RegistrationForm.php#L106-L121 |
matks/MarkdownBlogBundle | DependencyInjection/MarkdownBlogExtension.php | MarkdownBlogExtension.injectBundleConfigurationParametersIntoContainer | private function injectBundleConfigurationParametersIntoContainer(
ContainerBuilder $container,
array $bundleConfiguration)
{
$parametersToInject = [
'posts_directory',
];
foreach ($parametersToInject as $parameter) {
if (false === array_key_exists($parameter, $bundleConfiguration)) {
throw new \RuntimeException("Expected bundle configuration to contain $parameter");
}
$parameterAlias = 'markdown_blog.'.$parameter;
$container->setParameter($parameterAlias, $bundleConfiguration[$parameter]);
}
} | php | private function injectBundleConfigurationParametersIntoContainer(
ContainerBuilder $container,
array $bundleConfiguration)
{
$parametersToInject = [
'posts_directory',
];
foreach ($parametersToInject as $parameter) {
if (false === array_key_exists($parameter, $bundleConfiguration)) {
throw new \RuntimeException("Expected bundle configuration to contain $parameter");
}
$parameterAlias = 'markdown_blog.'.$parameter;
$container->setParameter($parameterAlias, $bundleConfiguration[$parameter]);
}
} | [
"private",
"function",
"injectBundleConfigurationParametersIntoContainer",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"bundleConfiguration",
")",
"{",
"$",
"parametersToInject",
"=",
"[",
"'posts_directory'",
",",
"]",
";",
"foreach",
"(",
"$",
"parametersToInject",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"false",
"===",
"array_key_exists",
"(",
"$",
"parameter",
",",
"$",
"bundleConfiguration",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Expected bundle configuration to contain $parameter\"",
")",
";",
"}",
"$",
"parameterAlias",
"=",
"'markdown_blog.'",
".",
"$",
"parameter",
";",
"$",
"container",
"->",
"setParameter",
"(",
"$",
"parameterAlias",
",",
"$",
"bundleConfiguration",
"[",
"$",
"parameter",
"]",
")",
";",
"}",
"}"
]
| @param ContainerBuilder $container
@param array $bundleConfiguration
@throws \RuntimeException | [
"@param",
"ContainerBuilder",
"$container",
"@param",
"array",
"$bundleConfiguration"
]
| train | https://github.com/matks/MarkdownBlogBundle/blob/b3438f143ece5e926b891d8f481dba35948b05fb/DependencyInjection/MarkdownBlogExtension.php#L32-L49 |
xinix-technology/norm | src/Norm/Connection/PDOConnection.php | PDOConnection.query | public function query($collection, array $criteria = null)
{
$collection = $this->factory($collection);
if (!empty($this->options['autocreate'])) {
$this->dialect->prepareCollection($collection, $criteria);
}
return new PDOCursor($collection, $criteria);
} | php | public function query($collection, array $criteria = null)
{
$collection = $this->factory($collection);
if (!empty($this->options['autocreate'])) {
$this->dialect->prepareCollection($collection, $criteria);
}
return new PDOCursor($collection, $criteria);
} | [
"public",
"function",
"query",
"(",
"$",
"collection",
",",
"array",
"$",
"criteria",
"=",
"null",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"collection",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'autocreate'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"dialect",
"->",
"prepareCollection",
"(",
"$",
"collection",
",",
"$",
"criteria",
")",
";",
"}",
"return",
"new",
"PDOCursor",
"(",
"$",
"collection",
",",
"$",
"criteria",
")",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/PDOConnection.php#L132-L141 |
xinix-technology/norm | src/Norm/Connection/PDOConnection.php | PDOConnection.remove | public function remove($collection, $criteria = null)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
$this->ddl($collection);
if (func_num_args() === 1) {
$sql = $this->dialect->grammarDelete($collection);
$statement = $this->raw->prepare($sql);
$result = $statement->execute();
} else {
$sql = "DELETE FROM $collectionName WHERE id = :id";
if ($criteria instanceof Model) {
$statement = $this->getRaw()->prepare($sql);
$result = $statement->execute(array(':id' => $criteria->getId()));
} else {
throw new Exception('Unimplemented yet!');
}
}
return $result;
} | php | public function remove($collection, $criteria = null)
{
if ($collection instanceof Collection) {
$collectionName = $collection->getName();
} else {
$collectionName = $collection;
$collection = static::factory($collection);
}
$this->ddl($collection);
if (func_num_args() === 1) {
$sql = $this->dialect->grammarDelete($collection);
$statement = $this->raw->prepare($sql);
$result = $statement->execute();
} else {
$sql = "DELETE FROM $collectionName WHERE id = :id";
if ($criteria instanceof Model) {
$statement = $this->getRaw()->prepare($sql);
$result = $statement->execute(array(':id' => $criteria->getId()));
} else {
throw new Exception('Unimplemented yet!');
}
}
return $result;
} | [
"public",
"function",
"remove",
"(",
"$",
"collection",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
"->",
"getName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collectionName",
"=",
"$",
"collection",
";",
"$",
"collection",
"=",
"static",
"::",
"factory",
"(",
"$",
"collection",
")",
";",
"}",
"$",
"this",
"->",
"ddl",
"(",
"$",
"collection",
")",
";",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"1",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"dialect",
"->",
"grammarDelete",
"(",
"$",
"collection",
")",
";",
"$",
"statement",
"=",
"$",
"this",
"->",
"raw",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"result",
"=",
"$",
"statement",
"->",
"execute",
"(",
")",
";",
"}",
"else",
"{",
"$",
"sql",
"=",
"\"DELETE FROM $collectionName WHERE id = :id\"",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Model",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"getRaw",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"result",
"=",
"$",
"statement",
"->",
"execute",
"(",
"array",
"(",
"':id'",
"=>",
"$",
"criteria",
"->",
"getId",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Unimplemented yet!'",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/PDOConnection.php#L146-L173 |
xinix-technology/norm | src/Norm/Connection/PDOConnection.php | PDOConnection.execute | protected function execute($sql, array $data = array())
{
$statement = $this->raw->prepare($sql);
return $statement->execute($data);
} | php | protected function execute($sql, array $data = array())
{
$statement = $this->raw->prepare($sql);
return $statement->execute($data);
} | [
"protected",
"function",
"execute",
"(",
"$",
"sql",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"raw",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"statement",
"->",
"execute",
"(",
"$",
"data",
")",
";",
"}"
]
| Execute an sql
@param string $sql
@param array $data
@return bool | [
"Execute",
"an",
"sql"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/PDOConnection.php#L209-L214 |
xinix-technology/norm | src/Norm/Connection/PDOConnection.php | PDOConnection.marshall | public function marshall($object)
{
if (is_array($object)) {
$result = array();
foreach ($object as $key => $value) {
if ($key[0] === '$') {
if ($key === '$id' || $key === '$type') {
continue;
}
$result['_'.substr($key, 1)] = $this->marshall($value);
} else {
$result[$key] = $this->marshall($value);
}
}
return $result;
} elseif ($object instanceof NDateTime || $object instanceof DateTime) {
return $object->format('Y-m-d H:i:s');
} elseif ($object instanceof NDate) {
return $object->format('Y-m-d');
} elseif ($object instanceof \Norm\Type\Collection) {
return json_encode($object->toArray());
} elseif (method_exists($object, 'marshall')) {
return $object->marshall();
} else {
return $object;
}
} | php | public function marshall($object)
{
if (is_array($object)) {
$result = array();
foreach ($object as $key => $value) {
if ($key[0] === '$') {
if ($key === '$id' || $key === '$type') {
continue;
}
$result['_'.substr($key, 1)] = $this->marshall($value);
} else {
$result[$key] = $this->marshall($value);
}
}
return $result;
} elseif ($object instanceof NDateTime || $object instanceof DateTime) {
return $object->format('Y-m-d H:i:s');
} elseif ($object instanceof NDate) {
return $object->format('Y-m-d');
} elseif ($object instanceof \Norm\Type\Collection) {
return json_encode($object->toArray());
} elseif (method_exists($object, 'marshall')) {
return $object->marshall();
} else {
return $object;
}
} | [
"public",
"function",
"marshall",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"object",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"[",
"0",
"]",
"===",
"'$'",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'$id'",
"||",
"$",
"key",
"===",
"'$type'",
")",
"{",
"continue",
";",
"}",
"$",
"result",
"[",
"'_'",
".",
"substr",
"(",
"$",
"key",
",",
"1",
")",
"]",
"=",
"$",
"this",
"->",
"marshall",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"marshall",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}",
"elseif",
"(",
"$",
"object",
"instanceof",
"NDateTime",
"||",
"$",
"object",
"instanceof",
"DateTime",
")",
"{",
"return",
"$",
"object",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"elseif",
"(",
"$",
"object",
"instanceof",
"NDate",
")",
"{",
"return",
"$",
"object",
"->",
"format",
"(",
"'Y-m-d'",
")",
";",
"}",
"elseif",
"(",
"$",
"object",
"instanceof",
"\\",
"Norm",
"\\",
"Type",
"\\",
"Collection",
")",
"{",
"return",
"json_encode",
"(",
"$",
"object",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"object",
",",
"'marshall'",
")",
")",
"{",
"return",
"$",
"object",
"->",
"marshall",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"object",
";",
"}",
"}"
]
| {@inheritDoc} | [
"{"
]
| train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/PDOConnection.php#L219-L246 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Process/PcntlSignals.php | PcntlSignals.create | public static function create($install = true)
{
$instance = new PcntlSignals();
if ($install) {
$instance->install(self::getDefaultInstalledSignals());
}
return $instance;
} | php | public static function create($install = true)
{
$instance = new PcntlSignals();
if ($install) {
$instance->install(self::getDefaultInstalledSignals());
}
return $instance;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"install",
"=",
"true",
")",
"{",
"$",
"instance",
"=",
"new",
"PcntlSignals",
"(",
")",
";",
"if",
"(",
"$",
"install",
")",
"{",
"$",
"instance",
"->",
"install",
"(",
"self",
"::",
"getDefaultInstalledSignals",
"(",
")",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
]
| Factory method, can install default signals.
@param bool $install When true installs signals.
@return PcntlSignals | [
"Factory",
"method",
"can",
"install",
"default",
"signals",
"."
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Process/PcntlSignals.php#L32-L39 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Process/PcntlSignals.php | PcntlSignals.install | public function install(array $signals)
{
if (self::isSupported()) {
$callback = [$this, 'dispatchSignal'];
foreach ($signals as $signal) {
\pcntl_signal($signal, $callback);
}
};
} | php | public function install(array $signals)
{
if (self::isSupported()) {
$callback = [$this, 'dispatchSignal'];
foreach ($signals as $signal) {
\pcntl_signal($signal, $callback);
}
};
} | [
"public",
"function",
"install",
"(",
"array",
"$",
"signals",
")",
"{",
"if",
"(",
"self",
"::",
"isSupported",
"(",
")",
")",
"{",
"$",
"callback",
"=",
"[",
"$",
"this",
",",
"'dispatchSignal'",
"]",
";",
"foreach",
"(",
"$",
"signals",
"as",
"$",
"signal",
")",
"{",
"\\",
"pcntl_signal",
"(",
"$",
"signal",
",",
"$",
"callback",
")",
";",
"}",
"}",
";",
"}"
]
| Installs selected signal
@param array $signals | [
"Installs",
"selected",
"signal"
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Process/PcntlSignals.php#L50-L58 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Process/PcntlSignals.php | PcntlSignals.handle | public function handle($signal, $handler, $namespace = self::DEFAULT_NAMESPACE)
{
if (empty($this->handlers[$signal])) {
$this->handlers[$signal] = [];
}
if (empty($this->handlers[$signal][$namespace])) {
$this->handlers[$signal][$namespace] = [];
}
$this->handlers[$signal][$namespace][] = $handler;
return $this;
} | php | public function handle($signal, $handler, $namespace = self::DEFAULT_NAMESPACE)
{
if (empty($this->handlers[$signal])) {
$this->handlers[$signal] = [];
}
if (empty($this->handlers[$signal][$namespace])) {
$this->handlers[$signal][$namespace] = [];
}
$this->handlers[$signal][$namespace][] = $handler;
return $this;
} | [
"public",
"function",
"handle",
"(",
"$",
"signal",
",",
"$",
"handler",
",",
"$",
"namespace",
"=",
"self",
"::",
"DEFAULT_NAMESPACE",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
"[",
"$",
"namespace",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
"[",
"$",
"namespace",
"]",
"[",
"]",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
]
| Registers handler for signal in selected namespace.
@param int $signal Signal id (\SIG* constants)
@param callable $handler Handler callback
@param string $namespace
@return $this | [
"Registers",
"handler",
"for",
"signal",
"in",
"selected",
"namespace",
"."
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Process/PcntlSignals.php#L67-L80 |
SAREhub/PHP_Commons | src/SAREhub/Commons/Process/PcntlSignals.php | PcntlSignals.dispatchSignal | public function dispatchSignal($signal)
{
if (isset($this->handlers[$signal])) {
foreach ($this->handlers[$signal] as $namespaceHandlers) {
foreach ($namespaceHandlers as $handler) {
$handler();
}
}
}
return $this;
} | php | public function dispatchSignal($signal)
{
if (isset($this->handlers[$signal])) {
foreach ($this->handlers[$signal] as $namespaceHandlers) {
foreach ($namespaceHandlers as $handler) {
$handler();
}
}
}
return $this;
} | [
"public",
"function",
"dispatchSignal",
"(",
"$",
"signal",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"signal",
"]",
"as",
"$",
"namespaceHandlers",
")",
"{",
"foreach",
"(",
"$",
"namespaceHandlers",
"as",
"$",
"handler",
")",
"{",
"$",
"handler",
"(",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Dispatch signal on registered handlers.
@param int $signal
@return $this | [
"Dispatch",
"signal",
"on",
"registered",
"handlers",
"."
]
| train | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Process/PcntlSignals.php#L87-L98 |
SachaMorard/phalcon-console | Library/Phalcon/Commands/Builtin/Info.php | Info.run | public function run(array $parameters)
{
$info = new SystemInfo();
printf("%s:\n", Color::head('Environment:'));
foreach ($info->getEnvironment() as $k => $v) {
printf(" %s: %s\n", $k, $v);
}
printf("%s:\n", Color::head('Versions:'));
foreach ($info->getVersions() as $k => $v) {
printf(" %s: %s\n", $k, $v);
}
print PHP_EOL;
return 0;
} | php | public function run(array $parameters)
{
$info = new SystemInfo();
printf("%s:\n", Color::head('Environment:'));
foreach ($info->getEnvironment() as $k => $v) {
printf(" %s: %s\n", $k, $v);
}
printf("%s:\n", Color::head('Versions:'));
foreach ($info->getVersions() as $k => $v) {
printf(" %s: %s\n", $k, $v);
}
print PHP_EOL;
return 0;
} | [
"public",
"function",
"run",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"info",
"=",
"new",
"SystemInfo",
"(",
")",
";",
"printf",
"(",
"\"%s:\\n\"",
",",
"Color",
"::",
"head",
"(",
"'Environment:'",
")",
")",
";",
"foreach",
"(",
"$",
"info",
"->",
"getEnvironment",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"printf",
"(",
"\" %s: %s\\n\"",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"printf",
"(",
"\"%s:\\n\"",
",",
"Color",
"::",
"head",
"(",
"'Versions:'",
")",
")",
";",
"foreach",
"(",
"$",
"info",
"->",
"getVersions",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"printf",
"(",
"\" %s: %s\\n\"",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"print",
"PHP_EOL",
";",
"return",
"0",
";",
"}"
]
| {@inheritdoc}
@param array $parameters
@return mixed | [
"{",
"@inheritdoc",
"}"
]
| train | https://github.com/SachaMorard/phalcon-console/blob/a7922e4c488ea19bc0ecce793e6f01cf9cf3c0c3/Library/Phalcon/Commands/Builtin/Info.php#L53-L70 |
SachaMorard/phalcon-console-migration | Library/Phalcon/Migrations/MigrationScript.php | MigrationScript.batchInsert | public function batchInsert(\Phalcon\Db\Adapter $connection, $tableName, $fields)
{
$migrationData = $this->migrationsDir . '/' . $this->version . '/' . $tableName . '.dat';
if (file_exists($migrationData)) {
$connection->begin();
$batchHandler = fopen($migrationData, 'r');
while (($line = fgets($batchHandler)) !== false) {
$connection->insert($tableName, explode('|', rtrim($line)), $fields, false);
unset($line);
}
fclose($batchHandler);
$connection->commit();
}
} | php | public function batchInsert(\Phalcon\Db\Adapter $connection, $tableName, $fields)
{
$migrationData = $this->migrationsDir . '/' . $this->version . '/' . $tableName . '.dat';
if (file_exists($migrationData)) {
$connection->begin();
$batchHandler = fopen($migrationData, 'r');
while (($line = fgets($batchHandler)) !== false) {
$connection->insert($tableName, explode('|', rtrim($line)), $fields, false);
unset($line);
}
fclose($batchHandler);
$connection->commit();
}
} | [
"public",
"function",
"batchInsert",
"(",
"\\",
"Phalcon",
"\\",
"Db",
"\\",
"Adapter",
"$",
"connection",
",",
"$",
"tableName",
",",
"$",
"fields",
")",
"{",
"$",
"migrationData",
"=",
"$",
"this",
"->",
"migrationsDir",
".",
"'/'",
".",
"$",
"this",
"->",
"version",
".",
"'/'",
".",
"$",
"tableName",
".",
"'.dat'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"migrationData",
")",
")",
"{",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"$",
"batchHandler",
"=",
"fopen",
"(",
"$",
"migrationData",
",",
"'r'",
")",
";",
"while",
"(",
"(",
"$",
"line",
"=",
"fgets",
"(",
"$",
"batchHandler",
")",
")",
"!==",
"false",
")",
"{",
"$",
"connection",
"->",
"insert",
"(",
"$",
"tableName",
",",
"explode",
"(",
"'|'",
",",
"rtrim",
"(",
"$",
"line",
")",
")",
",",
"$",
"fields",
",",
"false",
")",
";",
"unset",
"(",
"$",
"line",
")",
";",
"}",
"fclose",
"(",
"$",
"batchHandler",
")",
";",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"}",
"}"
]
| Inserts data from a data migration file in a table
@param string $tableName
@param string $fields | [
"Inserts",
"data",
"from",
"a",
"data",
"migration",
"file",
"in",
"a",
"table"
]
| train | https://github.com/SachaMorard/phalcon-console-migration/blob/6b79ecb04f3790844eae04d33e3489a98f4f1214/Library/Phalcon/Migrations/MigrationScript.php#L103-L116 |
shiftio/safestream-php-sdk | src/Watermark/WatermarkClient.php | WatermarkClient.create | public function create($videoKey, $watermarkConfiguration, $timeout = 90000) {
$this->validateVideoKey($videoKey);
$this->validateWatermarkConfiguration($watermarkConfiguration);
$this->validateTimeout($timeout);
$config = is_array($watermarkConfiguration) ? $watermarkConfiguration : array($watermarkConfiguration);
$payload = array("key" => $videoKey, "settings" => $config);
return $this->createAPI($payload, $timeout);
} | php | public function create($videoKey, $watermarkConfiguration, $timeout = 90000) {
$this->validateVideoKey($videoKey);
$this->validateWatermarkConfiguration($watermarkConfiguration);
$this->validateTimeout($timeout);
$config = is_array($watermarkConfiguration) ? $watermarkConfiguration : array($watermarkConfiguration);
$payload = array("key" => $videoKey, "settings" => $config);
return $this->createAPI($payload, $timeout);
} | [
"public",
"function",
"create",
"(",
"$",
"videoKey",
",",
"$",
"watermarkConfiguration",
",",
"$",
"timeout",
"=",
"90000",
")",
"{",
"$",
"this",
"->",
"validateVideoKey",
"(",
"$",
"videoKey",
")",
";",
"$",
"this",
"->",
"validateWatermarkConfiguration",
"(",
"$",
"watermarkConfiguration",
")",
";",
"$",
"this",
"->",
"validateTimeout",
"(",
"$",
"timeout",
")",
";",
"$",
"config",
"=",
"is_array",
"(",
"$",
"watermarkConfiguration",
")",
"?",
"$",
"watermarkConfiguration",
":",
"array",
"(",
"$",
"watermarkConfiguration",
")",
";",
"$",
"payload",
"=",
"array",
"(",
"\"key\"",
"=>",
"$",
"videoKey",
",",
"\"settings\"",
"=>",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createAPI",
"(",
"$",
"payload",
",",
"$",
"timeout",
")",
";",
"}"
]
| Watermarks a video
@param $videoKey
The unique key for the video to watermark. The key is a property on the video
defined at ingest time. @see http://docs.safestream.com/docs/video
@param $watermarkConfiguration
A single configuration object OR an array of configuration object
@see WatermarkConfiguration
@param int $timeout The length of time to wait for the watermarking to complete. Most
videos will complete in less than 60 seconds.
A value greater than 0 will cause the function to wait for the watermarking to
complete until the timeout is reached. Otherwise the function will return
immediately
@return mixed
@throws WatermarkClientException
@throws WatermarkConfigurationException
@throws WatermarkingException | [
"Watermarks",
"a",
"video"
]
| train | https://github.com/shiftio/safestream-php-sdk/blob/1957cd5574725b24da1bbff9059aa30a9ca123c2/src/Watermark/WatermarkClient.php#L88-L97 |
shiftio/safestream-php-sdk | src/Watermark/WatermarkClient.php | WatermarkClient.createFromTemplate | public function createFromTemplate($videoKey, $templateId, $templateMapping, $timeout = 90000) {
$payload = array("key" => $videoKey, "settingsTemplateMapping" => array( "id" => $templateId, "mappings" => $templateMapping ));
return $this->createAPI($payload, $timeout);
} | php | public function createFromTemplate($videoKey, $templateId, $templateMapping, $timeout = 90000) {
$payload = array("key" => $videoKey, "settingsTemplateMapping" => array( "id" => $templateId, "mappings" => $templateMapping ));
return $this->createAPI($payload, $timeout);
} | [
"public",
"function",
"createFromTemplate",
"(",
"$",
"videoKey",
",",
"$",
"templateId",
",",
"$",
"templateMapping",
",",
"$",
"timeout",
"=",
"90000",
")",
"{",
"$",
"payload",
"=",
"array",
"(",
"\"key\"",
"=>",
"$",
"videoKey",
",",
"\"settingsTemplateMapping\"",
"=>",
"array",
"(",
"\"id\"",
"=>",
"$",
"templateId",
",",
"\"mappings\"",
"=>",
"$",
"templateMapping",
")",
")",
";",
"return",
"$",
"this",
"->",
"createAPI",
"(",
"$",
"payload",
",",
"$",
"timeout",
")",
";",
"}"
]
| Watermarks a video from an existing watermark template.
For more on watermark templates @see Watermark\Template\Template
@param $videoKey
The unique key for the video to watermark. The key is a property on the video
defined at ingest time. @see http://docs.safestream.com/docs/video
@param $templateId
@param $templateMapping
Key/Value pairs that hydrate the template
@param int $timeout The length of time to wait for the watermarking to complete. Most
videos will complete in less than 60 seconds.
@return mixed
@throws WatermarkClientException
@throws WatermarkingException | [
"Watermarks",
"a",
"video",
"from",
"an",
"existing",
"watermark",
"template",
".",
"For",
"more",
"on",
"watermark",
"templates",
"@see",
"Watermark",
"\\",
"Template",
"\\",
"Template"
]
| train | https://github.com/shiftio/safestream-php-sdk/blob/1957cd5574725b24da1bbff9059aa30a9ca123c2/src/Watermark/WatermarkClient.php#L115-L118 |
webforge-labs/psc-cms | lib/Psc/PHPExcel/Exporter.php | Exporter.createSheet | protected function createSheet($name) {
$name = \Psc\PHPExcel\Helper::sanitizeSheetTitle($name);
$this->excel->addSheet(new PHPExcel_Worksheet($this->excel, $name));
$this->excel->setActiveSheetIndexByName($name);
$this->sheet = $this->excel->getActiveSheet();
$this->setRow(1);
} | php | protected function createSheet($name) {
$name = \Psc\PHPExcel\Helper::sanitizeSheetTitle($name);
$this->excel->addSheet(new PHPExcel_Worksheet($this->excel, $name));
$this->excel->setActiveSheetIndexByName($name);
$this->sheet = $this->excel->getActiveSheet();
$this->setRow(1);
} | [
"protected",
"function",
"createSheet",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"\\",
"Psc",
"\\",
"PHPExcel",
"\\",
"Helper",
"::",
"sanitizeSheetTitle",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"excel",
"->",
"addSheet",
"(",
"new",
"PHPExcel_Worksheet",
"(",
"$",
"this",
"->",
"excel",
",",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"excel",
"->",
"setActiveSheetIndexByName",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"sheet",
"=",
"$",
"this",
"->",
"excel",
"->",
"getActiveSheet",
"(",
")",
";",
"$",
"this",
"->",
"setRow",
"(",
"1",
")",
";",
"}"
]
| Setzt this->sheet auf das gerade erstellte Sheet
und die Row auf Zeile 1 | [
"Setzt",
"this",
"-",
">",
"sheet",
"auf",
"das",
"gerade",
"erstellte",
"Sheet",
"und",
"die",
"Row",
"auf",
"Zeile",
"1"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/PHPExcel/Exporter.php#L79-L86 |
webforge-labs/psc-cms | lib/Psc/PHPExcel/Exporter.php | Exporter.styleColumn | public function styleColumn($char, Array $style) {
$this->sheet->getStyle($char.'1:'.$char.max(2,$this->row->getRowIndex()))
->applyFromArray($style);
} | php | public function styleColumn($char, Array $style) {
$this->sheet->getStyle($char.'1:'.$char.max(2,$this->row->getRowIndex()))
->applyFromArray($style);
} | [
"public",
"function",
"styleColumn",
"(",
"$",
"char",
",",
"Array",
"$",
"style",
")",
"{",
"$",
"this",
"->",
"sheet",
"->",
"getStyle",
"(",
"$",
"char",
".",
"'1:'",
".",
"$",
"char",
".",
"max",
"(",
"2",
",",
"$",
"this",
"->",
"row",
"->",
"getRowIndex",
"(",
")",
")",
")",
"->",
"applyFromArray",
"(",
"$",
"style",
")",
";",
"}"
]
| Sollte erst nach create() ausgeführt werden | [
"Sollte",
"erst",
"nach",
"create",
"()",
"ausgeführt",
"werden"
]
| train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/PHPExcel/Exporter.php#L167-L170 |
uzulla/mock_slim_client | lib/Uzulla/MockSlimClient.php | MockSlimClient.req_dom | public function req_dom($path = '/', $method = 'GET', $input='',$option = [])
{
$html = $this->req($path, $method, $input, $option);
$dom = new \PHPHtmlParser\Dom;
$dom->load($html);
return $dom;
} | php | public function req_dom($path = '/', $method = 'GET', $input='',$option = [])
{
$html = $this->req($path, $method, $input, $option);
$dom = new \PHPHtmlParser\Dom;
$dom->load($html);
return $dom;
} | [
"public",
"function",
"req_dom",
"(",
"$",
"path",
"=",
"'/'",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"input",
"=",
"''",
",",
"$",
"option",
"=",
"[",
"]",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"req",
"(",
"$",
"path",
",",
"$",
"method",
",",
"$",
"input",
",",
"$",
"option",
")",
";",
"$",
"dom",
"=",
"new",
"\\",
"PHPHtmlParser",
"\\",
"Dom",
";",
"$",
"dom",
"->",
"load",
"(",
"$",
"html",
")",
";",
"return",
"$",
"dom",
";",
"}"
]
| get PHPHtmlParser\Dom instance by req() response. | [
"get",
"PHPHtmlParser",
"\\",
"Dom",
"instance",
"by",
"req",
"()",
"response",
"."
]
| train | https://github.com/uzulla/mock_slim_client/blob/1485c2417aa45f010f0143b842e710adf8fdc769/lib/Uzulla/MockSlimClient.php#L24-L31 |
uzulla/mock_slim_client | lib/Uzulla/MockSlimClient.php | MockSlimClient.req | public function req($path = '/', $method = 'GET', $input='',$option = [])
{
// $app->post() が $_POSTにfallbackするので対応
$_POST_OLD = [];
if ($method==='POST') {
$_POST_OLD = $_POST;
parse_str($input, $_POST);
}
// create slim mock with settings.
\Slim\Environment::mock(array_merge([
'REQUEST_METHOD' => $method,
'PATH_INFO' => $path,
'slim.input' => $input,
'SCRIPT_NAME' => '',
'QUERY_STRING' => '',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'ACCEPT_LANGUAGE' => 'ja,en;q=0.7,zh;q=0.3',
'ACCEPT_CHARSET' => 'UTF-8',
'USER_AGENT' => 'PHP UnitTest',
'REMOTE_ADDR' => '127.0.0.1',
'slim.url_scheme' => 'http',
'slim.errors' => @fopen('php://stderr', 'w')
], $option));
$app = static::createSlim();
// \Slim\Slim::getInstance() response only FIRST MADE instance now(2014/05/27).
// slim constructor DON'T overwrite \Slim\Slim::$apps when new slim instance
// bellow code, force overwrite cached instance.
// This is important when you use \Slim\Slim::getInstance().
// (I was falling in hole, when use Class controllers(slim>=2.4.0))
$app->setName('default');
// registration route to slim.
static::registrationRoute($app);
ob_start();
$app->run();
if ($method==='POST') {
$_POST = $_POST_OLD;
}
return ob_get_clean();
} | php | public function req($path = '/', $method = 'GET', $input='',$option = [])
{
// $app->post() が $_POSTにfallbackするので対応
$_POST_OLD = [];
if ($method==='POST') {
$_POST_OLD = $_POST;
parse_str($input, $_POST);
}
// create slim mock with settings.
\Slim\Environment::mock(array_merge([
'REQUEST_METHOD' => $method,
'PATH_INFO' => $path,
'slim.input' => $input,
'SCRIPT_NAME' => '',
'QUERY_STRING' => '',
'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80,
'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'ACCEPT_LANGUAGE' => 'ja,en;q=0.7,zh;q=0.3',
'ACCEPT_CHARSET' => 'UTF-8',
'USER_AGENT' => 'PHP UnitTest',
'REMOTE_ADDR' => '127.0.0.1',
'slim.url_scheme' => 'http',
'slim.errors' => @fopen('php://stderr', 'w')
], $option));
$app = static::createSlim();
// \Slim\Slim::getInstance() response only FIRST MADE instance now(2014/05/27).
// slim constructor DON'T overwrite \Slim\Slim::$apps when new slim instance
// bellow code, force overwrite cached instance.
// This is important when you use \Slim\Slim::getInstance().
// (I was falling in hole, when use Class controllers(slim>=2.4.0))
$app->setName('default');
// registration route to slim.
static::registrationRoute($app);
ob_start();
$app->run();
if ($method==='POST') {
$_POST = $_POST_OLD;
}
return ob_get_clean();
} | [
"public",
"function",
"req",
"(",
"$",
"path",
"=",
"'/'",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"input",
"=",
"''",
",",
"$",
"option",
"=",
"[",
"]",
")",
"{",
"// $app->post() が $_POSTにfallbackするので対応",
"$",
"_POST_OLD",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"method",
"===",
"'POST'",
")",
"{",
"$",
"_POST_OLD",
"=",
"$",
"_POST",
";",
"parse_str",
"(",
"$",
"input",
",",
"$",
"_POST",
")",
";",
"}",
"// create slim mock with settings.",
"\\",
"Slim",
"\\",
"Environment",
"::",
"mock",
"(",
"array_merge",
"(",
"[",
"'REQUEST_METHOD'",
"=>",
"$",
"method",
",",
"'PATH_INFO'",
"=>",
"$",
"path",
",",
"'slim.input'",
"=>",
"$",
"input",
",",
"'SCRIPT_NAME'",
"=>",
"''",
",",
"'QUERY_STRING'",
"=>",
"''",
",",
"'SERVER_NAME'",
"=>",
"'localhost'",
",",
"'SERVER_PORT'",
"=>",
"80",
",",
"'ACCEPT'",
"=>",
"'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'",
",",
"'ACCEPT_LANGUAGE'",
"=>",
"'ja,en;q=0.7,zh;q=0.3'",
",",
"'ACCEPT_CHARSET'",
"=>",
"'UTF-8'",
",",
"'USER_AGENT'",
"=>",
"'PHP UnitTest'",
",",
"'REMOTE_ADDR'",
"=>",
"'127.0.0.1'",
",",
"'slim.url_scheme'",
"=>",
"'http'",
",",
"'slim.errors'",
"=>",
"@",
"fopen",
"(",
"'php://stderr'",
",",
"'w'",
")",
"]",
",",
"$",
"option",
")",
")",
";",
"$",
"app",
"=",
"static",
"::",
"createSlim",
"(",
")",
";",
"// \\Slim\\Slim::getInstance() response only FIRST MADE instance now(2014/05/27).",
"// slim constructor DON'T overwrite \\Slim\\Slim::$apps when new slim instance",
"// bellow code, force overwrite cached instance.",
"// This is important when you use \\Slim\\Slim::getInstance().",
"// (I was falling in hole, when use Class controllers(slim>=2.4.0))",
"$",
"app",
"->",
"setName",
"(",
"'default'",
")",
";",
"// registration route to slim.",
"static",
"::",
"registrationRoute",
"(",
"$",
"app",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"app",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"method",
"===",
"'POST'",
")",
"{",
"$",
"_POST",
"=",
"$",
"_POST_OLD",
";",
"}",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
]
| make vitrual http request. return html(of raw body). | [
"make",
"vitrual",
"http",
"request",
".",
"return",
"html",
"(",
"of",
"raw",
"body",
")",
"."
]
| train | https://github.com/uzulla/mock_slim_client/blob/1485c2417aa45f010f0143b842e710adf8fdc769/lib/Uzulla/MockSlimClient.php#L34-L80 |
iamapen/dbunit-ExcelFriendlyDataSet | src/lib/Iamapen/ExcelFriendlyDataSet/Database/DataSet/ExcelCsvDataSet.php | ExcelCsvDataSet.addTable | public function addTable($tableName, $csvFile)
{
if (!is_file($csvFile)) {
throw new \InvalidArgumentException("Could not find csv file: {$csvFile}");
}
if (!is_readable($csvFile)) {
throw new \InvalidArgumentException("Could not read csv file: {$csvFile}");
}
$fh = fopen($csvFile, 'rb');
fseek($fh, 2); // after BOM
// TODO chunk
$tmpFp = fopen('php://temp', 'w+b');
fwrite($tmpFp, mb_convert_encoding(stream_get_contents($fh), 'UTF-8', 'UTF-16LE'));
rewind($tmpFp);
$columns = $this->getCsvRow($tmpFp);
if ($columns === FALSE)
{
throw new \InvalidArgumentException("Could not determine the headers from the given file {$csvFile}");
}
$metaData = new \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new \PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
while (($row = $this->getCsvRow($tmpFp)) !== FALSE)
{
$table->addRow(array_combine($columns, $row));
}
$this->tables[$tableName] = $table;
} | php | public function addTable($tableName, $csvFile)
{
if (!is_file($csvFile)) {
throw new \InvalidArgumentException("Could not find csv file: {$csvFile}");
}
if (!is_readable($csvFile)) {
throw new \InvalidArgumentException("Could not read csv file: {$csvFile}");
}
$fh = fopen($csvFile, 'rb');
fseek($fh, 2); // after BOM
// TODO chunk
$tmpFp = fopen('php://temp', 'w+b');
fwrite($tmpFp, mb_convert_encoding(stream_get_contents($fh), 'UTF-8', 'UTF-16LE'));
rewind($tmpFp);
$columns = $this->getCsvRow($tmpFp);
if ($columns === FALSE)
{
throw new \InvalidArgumentException("Could not determine the headers from the given file {$csvFile}");
}
$metaData = new \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns);
$table = new \PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData);
while (($row = $this->getCsvRow($tmpFp)) !== FALSE)
{
$table->addRow(array_combine($columns, $row));
}
$this->tables[$tableName] = $table;
} | [
"public",
"function",
"addTable",
"(",
"$",
"tableName",
",",
"$",
"csvFile",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"csvFile",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Could not find csv file: {$csvFile}\"",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"csvFile",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Could not read csv file: {$csvFile}\"",
")",
";",
"}",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"csvFile",
",",
"'rb'",
")",
";",
"fseek",
"(",
"$",
"fh",
",",
"2",
")",
";",
"// after BOM",
"// TODO chunk",
"$",
"tmpFp",
"=",
"fopen",
"(",
"'php://temp'",
",",
"'w+b'",
")",
";",
"fwrite",
"(",
"$",
"tmpFp",
",",
"mb_convert_encoding",
"(",
"stream_get_contents",
"(",
"$",
"fh",
")",
",",
"'UTF-8'",
",",
"'UTF-16LE'",
")",
")",
";",
"rewind",
"(",
"$",
"tmpFp",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"getCsvRow",
"(",
"$",
"tmpFp",
")",
";",
"if",
"(",
"$",
"columns",
"===",
"FALSE",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Could not determine the headers from the given file {$csvFile}\"",
")",
";",
"}",
"$",
"metaData",
"=",
"new",
"\\",
"PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData",
"(",
"$",
"tableName",
",",
"$",
"columns",
")",
";",
"$",
"table",
"=",
"new",
"\\",
"PHPUnit_Extensions_Database_DataSet_DefaultTable",
"(",
"$",
"metaData",
")",
";",
"while",
"(",
"(",
"$",
"row",
"=",
"$",
"this",
"->",
"getCsvRow",
"(",
"$",
"tmpFp",
")",
")",
"!==",
"FALSE",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"array_combine",
"(",
"$",
"columns",
",",
"$",
"row",
")",
")",
";",
"}",
"$",
"this",
"->",
"tables",
"[",
"$",
"tableName",
"]",
"=",
"$",
"table",
";",
"}"
]
| Adds a table to the dataset
The table will be given the passed name. $csvFile should be a path to
a valid csv file (based on the arguments passed to the constructor.)
@param string $tableName
@param string $csvFile | [
"Adds",
"a",
"table",
"to",
"the",
"dataset"
]
| train | https://github.com/iamapen/dbunit-ExcelFriendlyDataSet/blob/036103cb2a2a75608f0a00448301cd3f4a5c4e19/src/lib/Iamapen/ExcelFriendlyDataSet/Database/DataSet/ExcelCsvDataSet.php#L44-L78 |
2amigos/yiifoundation | widgets/Clearing.php | Clearing.init | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.clearing.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::CLEARING_THUMBS);
ArrayHelper::addValue('data-clearing', 'data-clearing', $this->htmlOptions);
parent::init();
} | php | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.clearing.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::CLEARING_THUMBS);
ArrayHelper::addValue('data-clearing', 'data-clearing', $this->htmlOptions);
parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
"'js'",
"=>",
"YII_DEBUG",
"?",
"'foundation/foundation.clearing.js'",
":",
"'foundation.min.js'",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"CLEARING_THUMBS",
")",
";",
"ArrayHelper",
"::",
"addValue",
"(",
"'data-clearing'",
",",
"'data-clearing'",
",",
"$",
"this",
"->",
"htmlOptions",
")",
";",
"parent",
"::",
"init",
"(",
")",
";",
"}"
]
| Initializes the widget | [
"Initializes",
"the",
"widget"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Clearing.php#L45-L53 |
2amigos/yiifoundation | widgets/Clearing.php | Clearing.renderClearing | public function renderClearing()
{
if (empty($this->items)) {
return true;
}
$list = array();
foreach ($this->items as $item) {
$list[] = $this->renderItem($item);
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $list));
} | php | public function renderClearing()
{
if (empty($this->items)) {
return true;
}
$list = array();
foreach ($this->items as $item) {
$list[] = $this->renderItem($item);
}
return \CHtml::tag('ul', $this->htmlOptions, implode("\n", $list));
} | [
"public",
"function",
"renderClearing",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"this",
"->",
"renderItem",
"(",
"$",
"item",
")",
";",
"}",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'ul'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"list",
")",
")",
";",
"}"
]
| Renders the clearing widget
@return bool|string the resulting element | [
"Renders",
"the",
"clearing",
"widget"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Clearing.php#L67-L77 |
2amigos/yiifoundation | widgets/Clearing.php | Clearing.renderItem | public function renderItem($item)
{
$options = ArrayHelper::getValue($item, 'options', array());
if (isset($item['featured'])) {
Html::addCssClass($this->htmlOptions, Enum::ClEARING_FEATURE);
Html::addCssClass($options, Enum::CLEARING_FEATURE_IMG);
}
$imgOptions = array();
$imgOptions['src'] = ArrayHelper::getValue($item, 'th', '#');
$imgOptions['data-caption'] = ArrayHelper::getValue($item, 'caption', null);
$imgOptions['class'] = 'th';
$url = ArrayHelper::getValue($item, 'img', '#');
return \CHtml::tag('li', $options, \CHtml::link(\CHtml::tag('img', $imgOptions), $url));
} | php | public function renderItem($item)
{
$options = ArrayHelper::getValue($item, 'options', array());
if (isset($item['featured'])) {
Html::addCssClass($this->htmlOptions, Enum::ClEARING_FEATURE);
Html::addCssClass($options, Enum::CLEARING_FEATURE_IMG);
}
$imgOptions = array();
$imgOptions['src'] = ArrayHelper::getValue($item, 'th', '#');
$imgOptions['data-caption'] = ArrayHelper::getValue($item, 'caption', null);
$imgOptions['class'] = 'th';
$url = ArrayHelper::getValue($item, 'img', '#');
return \CHtml::tag('li', $options, \CHtml::link(\CHtml::tag('img', $imgOptions), $url));
} | [
"public",
"function",
"renderItem",
"(",
"$",
"item",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'options'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'featured'",
"]",
")",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"ClEARING_FEATURE",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"options",
",",
"Enum",
"::",
"CLEARING_FEATURE_IMG",
")",
";",
"}",
"$",
"imgOptions",
"=",
"array",
"(",
")",
";",
"$",
"imgOptions",
"[",
"'src'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'th'",
",",
"'#'",
")",
";",
"$",
"imgOptions",
"[",
"'data-caption'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'caption'",
",",
"null",
")",
";",
"$",
"imgOptions",
"[",
"'class'",
"]",
"=",
"'th'",
";",
"$",
"url",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'img'",
",",
"'#'",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"$",
"options",
",",
"\\",
"CHtml",
"::",
"link",
"(",
"\\",
"CHtml",
"::",
"tag",
"(",
"'img'",
",",
"$",
"imgOptions",
")",
",",
"$",
"url",
")",
")",
";",
"}"
]
| Renders a clearing (lightbox) item
@param array $item
@return string the resulting LI tag item | [
"Renders",
"a",
"clearing",
"(",
"lightbox",
")",
"item"
]
| train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Clearing.php#L84-L99 |
kevintweber/phpunit-markup-validators | src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php | AssertHTML5.isValidMarkup | public static function isValidMarkup($html,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $html is a string.
if (empty($html) || !is_string($html)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Validate the html.
$connector->setInput($html);
$response = $connector->execute('markup');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | php | public static function isValidMarkup($html,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $html is a string.
if (empty($html) || !is_string($html)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Validate the html.
$connector->setInput($html);
$response = $connector->execute('markup');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | [
"public",
"static",
"function",
"isValidMarkup",
"(",
"$",
"html",
",",
"$",
"message",
"=",
"''",
",",
"ConnectorInterface",
"$",
"connector",
"=",
"null",
")",
"{",
"// Check that $html is a string.",
"if",
"(",
"empty",
"(",
"$",
"html",
")",
"||",
"!",
"is_string",
"(",
"$",
"html",
")",
")",
"{",
"throw",
"\\",
"PHPUnit_Util_InvalidArgumentHelper",
"::",
"factory",
"(",
"1",
",",
"'string'",
")",
";",
"}",
"// Assign connector if there isn't one already.",
"if",
"(",
"$",
"connector",
"===",
"null",
")",
"{",
"$",
"connector",
"=",
"new",
"HTML5ValidatorNuConnector",
"(",
")",
";",
"}",
"// Validate the html.",
"$",
"connector",
"->",
"setInput",
"(",
"$",
"html",
")",
";",
"$",
"response",
"=",
"$",
"connector",
"->",
"execute",
"(",
"'markup'",
")",
";",
"// Tell PHPUnit of the results.",
"$",
"constraint",
"=",
"new",
"GenericConstraint",
"(",
"$",
"connector",
")",
";",
"self",
"::",
"assertThat",
"(",
"$",
"response",
",",
"$",
"constraint",
",",
"$",
"message",
")",
";",
"}"
]
| Asserts that the HTML5 string is valid.
@param string $html The markup to be validated.
@param string $message Test message.
@param ConnectorInterface $connector Connector to HTML5 validation service. | [
"Asserts",
"that",
"the",
"HTML5",
"string",
"is",
"valid",
"."
]
| train | https://github.com/kevintweber/phpunit-markup-validators/blob/bee48f48c7c1c9e811d1a4bedeca8f413d049cb3/src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php#L27-L48 |
kevintweber/phpunit-markup-validators | src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php | AssertHTML5.isValidFile | public static function isValidFile($path,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $path is exists.
if (!file_exists($path)) {
throw new \PHPUnit_Framework_Exception(
sprintf('File "%s" does not exist.'."\n", $path)
);
}
// Get file contents.
$html = file_get_contents($path);
if ($html === false) {
throw new \PHPUnit_Framework_Exception(
sprintf('Cannot read file "%s".'."\n", $path)
);
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Parse the html.
$connector->setInput($html);
$response = $connector->execute('file');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | php | public static function isValidFile($path,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $path is exists.
if (!file_exists($path)) {
throw new \PHPUnit_Framework_Exception(
sprintf('File "%s" does not exist.'."\n", $path)
);
}
// Get file contents.
$html = file_get_contents($path);
if ($html === false) {
throw new \PHPUnit_Framework_Exception(
sprintf('Cannot read file "%s".'."\n", $path)
);
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Parse the html.
$connector->setInput($html);
$response = $connector->execute('file');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | [
"public",
"static",
"function",
"isValidFile",
"(",
"$",
"path",
",",
"$",
"message",
"=",
"''",
",",
"ConnectorInterface",
"$",
"connector",
"=",
"null",
")",
"{",
"// Check that $path is exists.",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"PHPUnit_Framework_Exception",
"(",
"sprintf",
"(",
"'File \"%s\" does not exist.'",
".",
"\"\\n\"",
",",
"$",
"path",
")",
")",
";",
"}",
"// Get file contents.",
"$",
"html",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"html",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"PHPUnit_Framework_Exception",
"(",
"sprintf",
"(",
"'Cannot read file \"%s\".'",
".",
"\"\\n\"",
",",
"$",
"path",
")",
")",
";",
"}",
"// Assign connector if there isn't one already.",
"if",
"(",
"$",
"connector",
"===",
"null",
")",
"{",
"$",
"connector",
"=",
"new",
"HTML5ValidatorNuConnector",
"(",
")",
";",
"}",
"// Parse the html.",
"$",
"connector",
"->",
"setInput",
"(",
"$",
"html",
")",
";",
"$",
"response",
"=",
"$",
"connector",
"->",
"execute",
"(",
"'file'",
")",
";",
"// Tell PHPUnit of the results.",
"$",
"constraint",
"=",
"new",
"GenericConstraint",
"(",
"$",
"connector",
")",
";",
"self",
"::",
"assertThat",
"(",
"$",
"response",
",",
"$",
"constraint",
",",
"$",
"message",
")",
";",
"}"
]
| Asserts that the HTML5 file is valid.
@param string $path The file path to be validated.
@param string $message Test message.
@param ConnectorInterface $connector Connector to HTML5 validation service. | [
"Asserts",
"that",
"the",
"HTML5",
"file",
"is",
"valid",
"."
]
| train | https://github.com/kevintweber/phpunit-markup-validators/blob/bee48f48c7c1c9e811d1a4bedeca8f413d049cb3/src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php#L57-L88 |
kevintweber/phpunit-markup-validators | src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php | AssertHTML5.isValidURL | public static function isValidURL($url,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $url is a string.
if (empty($url) || !is_string($url)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
// Check that $url is a valid url.
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
throw new \PHPUnit_Framework_Exception("Url is not valid.\n");
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Parse the html.
$connector->setInput($url);
$response = $connector->execute('url');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | php | public static function isValidURL($url,
$message = '',
ConnectorInterface $connector = null)
{
// Check that $url is a string.
if (empty($url) || !is_string($url)) {
throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
// Check that $url is a valid url.
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
throw new \PHPUnit_Framework_Exception("Url is not valid.\n");
}
// Assign connector if there isn't one already.
if ($connector === null) {
$connector = new HTML5ValidatorNuConnector();
}
// Parse the html.
$connector->setInput($url);
$response = $connector->execute('url');
// Tell PHPUnit of the results.
$constraint = new GenericConstraint($connector);
self::assertThat($response, $constraint, $message);
} | [
"public",
"static",
"function",
"isValidURL",
"(",
"$",
"url",
",",
"$",
"message",
"=",
"''",
",",
"ConnectorInterface",
"$",
"connector",
"=",
"null",
")",
"{",
"// Check that $url is a string.",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
"||",
"!",
"is_string",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"\\",
"PHPUnit_Util_InvalidArgumentHelper",
"::",
"factory",
"(",
"1",
",",
"'string'",
")",
";",
"}",
"// Check that $url is a valid url.",
"if",
"(",
"filter_var",
"(",
"$",
"url",
",",
"FILTER_VALIDATE_URL",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"PHPUnit_Framework_Exception",
"(",
"\"Url is not valid.\\n\"",
")",
";",
"}",
"// Assign connector if there isn't one already.",
"if",
"(",
"$",
"connector",
"===",
"null",
")",
"{",
"$",
"connector",
"=",
"new",
"HTML5ValidatorNuConnector",
"(",
")",
";",
"}",
"// Parse the html.",
"$",
"connector",
"->",
"setInput",
"(",
"$",
"url",
")",
";",
"$",
"response",
"=",
"$",
"connector",
"->",
"execute",
"(",
"'url'",
")",
";",
"// Tell PHPUnit of the results.",
"$",
"constraint",
"=",
"new",
"GenericConstraint",
"(",
"$",
"connector",
")",
";",
"self",
"::",
"assertThat",
"(",
"$",
"response",
",",
"$",
"constraint",
",",
"$",
"message",
")",
";",
"}"
]
| Asserts that the HTML5 url is valid.
@param string $url The external url to be validated.
@param string $message Test message.
@param ConnectorInterface $connector Connector to HTML5 validation service. | [
"Asserts",
"that",
"the",
"HTML5",
"url",
"is",
"valid",
"."
]
| train | https://github.com/kevintweber/phpunit-markup-validators/blob/bee48f48c7c1c9e811d1a4bedeca8f413d049cb3/src/Kevintweber/PhpunitMarkupValidators/Assert/AssertHTML5.php#L97-L123 |
krzysztofmazur/ntp-client | src/Impl/CompositeNtpClient.php | CompositeNtpClient.getUnixTime | public function getUnixTime(): int
{
foreach ($this->clients as $client) {
try {
return $client->getUnixTime();
} catch (ConnectionException $e) {
//do nothing
}
}
throw new UnableToConnectException("Unable connect to any server");
} | php | public function getUnixTime(): int
{
foreach ($this->clients as $client) {
try {
return $client->getUnixTime();
} catch (ConnectionException $e) {
//do nothing
}
}
throw new UnableToConnectException("Unable connect to any server");
} | [
"public",
"function",
"getUnixTime",
"(",
")",
":",
"int",
"{",
"foreach",
"(",
"$",
"this",
"->",
"clients",
"as",
"$",
"client",
")",
"{",
"try",
"{",
"return",
"$",
"client",
"->",
"getUnixTime",
"(",
")",
";",
"}",
"catch",
"(",
"ConnectionException",
"$",
"e",
")",
"{",
"//do nothing",
"}",
"}",
"throw",
"new",
"UnableToConnectException",
"(",
"\"Unable connect to any server\"",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/krzysztofmazur/ntp-client/blob/3e15ce8ee26d6e2e57a8bdbdf67273762e3fbfd2/src/Impl/CompositeNtpClient.php#L46-L57 |
krzysztofmazur/ntp-client | src/Impl/CompositeNtpClient.php | CompositeNtpClient.getTime | public function getTime(\DateTimeZone $timezone = null): \DateTime
{
return DateTimeConverter::createFromUnixTimestamp($this->getUnixTime(), $timezone);
} | php | public function getTime(\DateTimeZone $timezone = null): \DateTime
{
return DateTimeConverter::createFromUnixTimestamp($this->getUnixTime(), $timezone);
} | [
"public",
"function",
"getTime",
"(",
"\\",
"DateTimeZone",
"$",
"timezone",
"=",
"null",
")",
":",
"\\",
"DateTime",
"{",
"return",
"DateTimeConverter",
"::",
"createFromUnixTimestamp",
"(",
"$",
"this",
"->",
"getUnixTime",
"(",
")",
",",
"$",
"timezone",
")",
";",
"}"
]
| {@inheritdoc} | [
"{"
]
| train | https://github.com/krzysztofmazur/ntp-client/blob/3e15ce8ee26d6e2e57a8bdbdf67273762e3fbfd2/src/Impl/CompositeNtpClient.php#L62-L65 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RemoteAppQuery) {
return $criteria;
}
$query = new RemoteAppQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RemoteAppQuery) {
return $criteria;
}
$query = new RemoteAppQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"RemoteAppQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"RemoteAppQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
]
| Returns a new RemoteAppQuery object.
@param string $modelAlias The alias of a model in the query
@param RemoteAppQuery|Criteria $criteria Optional Criteria to build the query from
@return RemoteAppQuery | [
"Returns",
"a",
"new",
"RemoteAppQuery",
"object",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L173-L185 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.findPkComplex | protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | php | protected function findPkComplex($key, $con)
{
// As the query uses a PK condition, no limit(1) is necessary.
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKey($key)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
} | [
"protected",
"function",
"findPkComplex",
"(",
"$",
"key",
",",
"$",
"con",
")",
"{",
"// As the query uses a PK condition, no limit(1) is necessary.",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"filterByPrimaryKey",
"(",
"$",
"key",
")",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"formatOne",
"(",
"$",
"stmt",
")",
";",
"}"
]
| Find object by primary key.
@param mixed $key Primary key to use for the query
@param PropelPDO $con A connection object
@return RemoteApp|RemoteApp[]|mixed the result, formatted by the current formatter | [
"Find",
"object",
"by",
"primary",
"key",
"."
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L277-L286 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.findPks | public function findPks($keys, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | php | public function findPks($keys, $con = null)
{
if ($con === null) {
$con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
}
$this->basePreSelect($con);
$criteria = $this->isKeepQuery() ? clone $this : $this;
$stmt = $criteria
->filterByPrimaryKeys($keys)
->doSelect($con);
return $criteria->getFormatter()->init($criteria)->format($stmt);
} | [
"public",
"function",
"findPks",
"(",
"$",
"keys",
",",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"con",
"===",
"null",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getConnection",
"(",
"$",
"this",
"->",
"getDbName",
"(",
")",
",",
"Propel",
"::",
"CONNECTION_READ",
")",
";",
"}",
"$",
"this",
"->",
"basePreSelect",
"(",
"$",
"con",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"isKeepQuery",
"(",
")",
"?",
"clone",
"$",
"this",
":",
"$",
"this",
";",
"$",
"stmt",
"=",
"$",
"criteria",
"->",
"filterByPrimaryKeys",
"(",
"$",
"keys",
")",
"->",
"doSelect",
"(",
"$",
"con",
")",
";",
"return",
"$",
"criteria",
"->",
"getFormatter",
"(",
")",
"->",
"init",
"(",
"$",
"criteria",
")",
"->",
"format",
"(",
"$",
"stmt",
")",
";",
"}"
]
| Find objects by primary key
<code>
$objs = $c->findPks(array(12, 56, 832), $con);
</code>
@param array $keys Primary keys to use for the query
@param PropelPDO $con an optional connection object
@return PropelObjectCollection|RemoteApp[]|mixed the list of results, formatted by the current formatter | [
"Find",
"objects",
"by",
"primary",
"key",
"<code",
">",
"$objs",
"=",
"$c",
"-",
">",
"findPks",
"(",
"array",
"(",
"12",
"56",
"832",
")",
"$con",
")",
";",
"<",
"/",
"code",
">",
"@param",
"array",
"$keys",
"Primary",
"keys",
"to",
"use",
"for",
"the",
"query",
"@param",
"PropelPDO",
"$con",
"an",
"optional",
"connection",
"object"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L298-L310 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.filterByApiUrl | public function filterByApiUrl($apiUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiUrl)) {
$apiUrl = str_replace('*', '%', $apiUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_URL, $apiUrl, $comparison);
} | php | public function filterByApiUrl($apiUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiUrl)) {
$apiUrl = str_replace('*', '%', $apiUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_URL, $apiUrl, $comparison);
} | [
"public",
"function",
"filterByApiUrl",
"(",
"$",
"apiUrl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"apiUrl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"apiUrl",
")",
")",
"{",
"$",
"apiUrl",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"apiUrl",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteAppPeer",
"::",
"API_URL",
",",
"$",
"apiUrl",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the api_url column
Example usage:
<code>
$query->filterByApiUrl('fooValue'); // WHERE api_url = 'fooValue'
$query->filterByApiUrl('%fooValue%'); // WHERE api_url LIKE '%fooValue%'
</code>
@param string $apiUrl The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteAppQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"api_url",
"column"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L482-L494 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.filterByApiAuthHttpUser | public function filterByApiAuthHttpUser($apiAuthHttpUser = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthHttpUser)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthHttpUser)) {
$apiAuthHttpUser = str_replace('*', '%', $apiAuthHttpUser);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_HTTP_USER, $apiAuthHttpUser, $comparison);
} | php | public function filterByApiAuthHttpUser($apiAuthHttpUser = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthHttpUser)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthHttpUser)) {
$apiAuthHttpUser = str_replace('*', '%', $apiAuthHttpUser);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_HTTP_USER, $apiAuthHttpUser, $comparison);
} | [
"public",
"function",
"filterByApiAuthHttpUser",
"(",
"$",
"apiAuthHttpUser",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"apiAuthHttpUser",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"apiAuthHttpUser",
")",
")",
"{",
"$",
"apiAuthHttpUser",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"apiAuthHttpUser",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_HTTP_USER",
",",
"$",
"apiAuthHttpUser",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the api_auth_http_user column
Example usage:
<code>
$query->filterByApiAuthHttpUser('fooValue'); // WHERE api_auth_http_user = 'fooValue'
$query->filterByApiAuthHttpUser('%fooValue%'); // WHERE api_auth_http_user LIKE '%fooValue%'
</code>
@param string $apiAuthHttpUser The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteAppQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"api_auth_http_user",
"column"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L511-L523 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.filterByApiAuthHttpPassword | public function filterByApiAuthHttpPassword($apiAuthHttpPassword = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthHttpPassword)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthHttpPassword)) {
$apiAuthHttpPassword = str_replace('*', '%', $apiAuthHttpPassword);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_HTTP_PASSWORD, $apiAuthHttpPassword, $comparison);
} | php | public function filterByApiAuthHttpPassword($apiAuthHttpPassword = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthHttpPassword)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthHttpPassword)) {
$apiAuthHttpPassword = str_replace('*', '%', $apiAuthHttpPassword);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_HTTP_PASSWORD, $apiAuthHttpPassword, $comparison);
} | [
"public",
"function",
"filterByApiAuthHttpPassword",
"(",
"$",
"apiAuthHttpPassword",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"apiAuthHttpPassword",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"apiAuthHttpPassword",
")",
")",
"{",
"$",
"apiAuthHttpPassword",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"apiAuthHttpPassword",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_HTTP_PASSWORD",
",",
"$",
"apiAuthHttpPassword",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the api_auth_http_password column
Example usage:
<code>
$query->filterByApiAuthHttpPassword('fooValue'); // WHERE api_auth_http_password = 'fooValue'
$query->filterByApiAuthHttpPassword('%fooValue%'); // WHERE api_auth_http_password LIKE '%fooValue%'
</code>
@param string $apiAuthHttpPassword The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteAppQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"api_auth_http_password",
"column"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L540-L552 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php | BaseRemoteAppQuery.filterByApiAuthType | public function filterByApiAuthType($apiAuthType = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthType)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthType)) {
$apiAuthType = str_replace('*', '%', $apiAuthType);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_TYPE, $apiAuthType, $comparison);
} | php | public function filterByApiAuthType($apiAuthType = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($apiAuthType)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $apiAuthType)) {
$apiAuthType = str_replace('*', '%', $apiAuthType);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RemoteAppPeer::API_AUTH_TYPE, $apiAuthType, $comparison);
} | [
"public",
"function",
"filterByApiAuthType",
"(",
"$",
"apiAuthType",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"apiAuthType",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"apiAuthType",
")",
")",
"{",
"$",
"apiAuthType",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"apiAuthType",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RemoteAppPeer",
"::",
"API_AUTH_TYPE",
",",
"$",
"apiAuthType",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the api_auth_type column
Example usage:
<code>
$query->filterByApiAuthType('fooValue'); // WHERE api_auth_type = 'fooValue'
$query->filterByApiAuthType('%fooValue%'); // WHERE api_auth_type LIKE '%fooValue%'
</code>
@param string $apiAuthType The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RemoteAppQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"api_auth_type",
"column"
]
| train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppQuery.php#L569-L581 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.