id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,100
|
Erebot/API
|
src/Event/Match/TextAbstract.php
|
TextAbstract.setPrefixRequirement
|
public function setPrefixRequirement($requirePrefix = false)
{
if ($requirePrefix !== null && !is_bool($requirePrefix)) {
throw new \Erebot\InvalidValueException(
'$requirePrefix must be a boolean or null'
);
}
$this->requirePrefix = $requirePrefix;
}
|
php
|
public function setPrefixRequirement($requirePrefix = false)
{
if ($requirePrefix !== null && !is_bool($requirePrefix)) {
throw new \Erebot\InvalidValueException(
'$requirePrefix must be a boolean or null'
);
}
$this->requirePrefix = $requirePrefix;
}
|
[
"public",
"function",
"setPrefixRequirement",
"(",
"$",
"requirePrefix",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"requirePrefix",
"!==",
"null",
"&&",
"!",
"is_bool",
"(",
"$",
"requirePrefix",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'$requirePrefix must be a boolean or null'",
")",
";",
"}",
"$",
"this",
"->",
"requirePrefix",
"=",
"$",
"requirePrefix",
";",
"}"
] |
Sets the constraint on prefix requirement.
\param bool|null $requirePrefix
(optional) Whether a prefix will be required (\b true),
allowed (\b null) or disallowed (\b false).
The default is to prohibit the use of a prefix.
\throw Erebot::InvalidValueException
The given value for $requirePrefix is invalid.
|
[
"Sets",
"the",
"constraint",
"on",
"prefix",
"requirement",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Event/Match/TextAbstract.php#L111-L120
|
225,101
|
yawik/behat
|
src/SummaryFormContext.php
|
SummaryFormContext.iSaveWorkflow
|
public function iSaveWorkflow()
{
$locator = '#workflowSettings-buttons-submit';
$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
$element->click();
}
|
php
|
public function iSaveWorkflow()
{
$locator = '#workflowSettings-buttons-submit';
$element = $this->minkContext->getSession()->getPage()->find('css',$locator);
$element->click();
}
|
[
"public",
"function",
"iSaveWorkflow",
"(",
")",
"{",
"$",
"locator",
"=",
"'#workflowSettings-buttons-submit'",
";",
"$",
"element",
"=",
"$",
"this",
"->",
"minkContext",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'css'",
",",
"$",
"locator",
")",
";",
"$",
"element",
"->",
"click",
"(",
")",
";",
"}"
] |
Saving organization workflow
|
[
"Saving",
"organization",
"workflow"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/SummaryFormContext.php#L94-L99
|
225,102
|
UCSLabs/form
|
Parser/LessVariablesParser.php
|
LessVariablesParser.flatten
|
public function flatten($data, $originalNames = array())
{
$ret = array();
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data));
foreach ($it as $name => $value) {
if (!is_array($value)) {
if (isset($originalNames[$name])) {
$name = $originalNames[$name];
}
$ret[$name] = $value;
}
}
return $ret;
}
|
php
|
public function flatten($data, $originalNames = array())
{
$ret = array();
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($data));
foreach ($it as $name => $value) {
if (!is_array($value)) {
if (isset($originalNames[$name])) {
$name = $originalNames[$name];
}
$ret[$name] = $value;
}
}
return $ret;
}
|
[
"public",
"function",
"flatten",
"(",
"$",
"data",
",",
"$",
"originalNames",
"=",
"array",
"(",
")",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"$",
"it",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveArrayIterator",
"(",
"$",
"data",
")",
")",
";",
"foreach",
"(",
"$",
"it",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"originalNames",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"originalNames",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"ret",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Flattent the given data
|
[
"Flattent",
"the",
"given",
"data"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/Parser/LessVariablesParser.php#L178-L194
|
225,103
|
UCSLabs/form
|
Parser/LessVariablesParser.php
|
LessVariablesParser.extractField
|
private function extractField($blocks)
{
$fieldData = array();
$pattern = "/([a-zA-Z]+) *(.+)/";
foreach ($blocks as $block) {
$match = preg_match($pattern, $block, $matches);
// A full double string match found
if (count($matches) == 3) {
$docLabel = trim(strtolower($matches[1]));
$docValue = trim($matches[2]);
if (in_array($docLabel, self::$VALID_EXPRESSIONS)) {
$fieldData[self::$VALID_EXPRESSIONS_NAMES[$docLabel]] = $docValue;
}
}
}
return $fieldData;
}
|
php
|
private function extractField($blocks)
{
$fieldData = array();
$pattern = "/([a-zA-Z]+) *(.+)/";
foreach ($blocks as $block) {
$match = preg_match($pattern, $block, $matches);
// A full double string match found
if (count($matches) == 3) {
$docLabel = trim(strtolower($matches[1]));
$docValue = trim($matches[2]);
if (in_array($docLabel, self::$VALID_EXPRESSIONS)) {
$fieldData[self::$VALID_EXPRESSIONS_NAMES[$docLabel]] = $docValue;
}
}
}
return $fieldData;
}
|
[
"private",
"function",
"extractField",
"(",
"$",
"blocks",
")",
"{",
"$",
"fieldData",
"=",
"array",
"(",
")",
";",
"$",
"pattern",
"=",
"\"/([a-zA-Z]+) *(.+)/\"",
";",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"block",
")",
"{",
"$",
"match",
"=",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"block",
",",
"$",
"matches",
")",
";",
"// A full double string match found",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"==",
"3",
")",
"{",
"$",
"docLabel",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
";",
"$",
"docValue",
"=",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"docLabel",
",",
"self",
"::",
"$",
"VALID_EXPRESSIONS",
")",
")",
"{",
"$",
"fieldData",
"[",
"self",
"::",
"$",
"VALID_EXPRESSIONS_NAMES",
"[",
"$",
"docLabel",
"]",
"]",
"=",
"$",
"docValue",
";",
"}",
"}",
"}",
"return",
"$",
"fieldData",
";",
"}"
] |
This is the main function supposed to parse and return fields
properly
|
[
"This",
"is",
"the",
"main",
"function",
"supposed",
"to",
"parse",
"and",
"return",
"fields",
"properly"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/Parser/LessVariablesParser.php#L200-L221
|
225,104
|
SetBased/php-abc-form
|
src/Validator/LengthValidator.php
|
LengthValidator.validate
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not valid.
if (!is_scalar($value))
{
return false;
}
$length = mb_strlen($value, Html::$encoding);
return (($this->minLength<=$length) && ($length<=$this->maxLength));
}
|
php
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not valid.
if (!is_scalar($value))
{
return false;
}
$length = mb_strlen($value, Html::$encoding);
return (($this->minLength<=$length) && ($length<=$this->maxLength));
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"// An empty value is valid.",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// Objects and arrays are not valid.",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"value",
",",
"Html",
"::",
"$",
"encoding",
")",
";",
"return",
"(",
"(",
"$",
"this",
"->",
"minLength",
"<=",
"$",
"length",
")",
"&&",
"(",
"$",
"length",
"<=",
"$",
"this",
"->",
"maxLength",
")",
")",
";",
"}"
] |
Returns true if the length of the value of a form control is within the specified range. Otherwise returns false.
Note:
* Empty values are considered valid.
@param Control $control The form control.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"length",
"of",
"the",
"value",
"of",
"a",
"form",
"control",
"is",
"within",
"the",
"specified",
"range",
".",
"Otherwise",
"returns",
"false",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/LengthValidator.php#L59-L78
|
225,105
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderFile.php
|
AppenderFile.openFile
|
protected function openFile() {
$file = $this->getTargetFile();
// Create the target folder if needed
if(!is_file($file)) {
$dir = dirname($file);
if(!is_dir($dir)) {
$success = \n2n\io\IoUtils::mkdirs($dir, 0777, true);
if ($success === false) {
$this->warn("Failed creating target directory [$dir]. Closing appender.");
$this->closed = true;
return false;
}
}
}
$mode = $this->append ? 'a' : 'w';
$this->fp = \n2n\io\IoUtils::fopen($file, $mode);
if ($this->fp === false) {
$this->warn("Failed opening target file. Closing appender.");
$this->fp = null;
$this->closed = true;
return false;
}
// Required when appending with concurrent access
if($this->append) {
\n2n\io\IoUtils::fseek($this->fp, 0, SEEK_END);
}
// Write the header
$this->write($this->layout->getHeader());
}
|
php
|
protected function openFile() {
$file = $this->getTargetFile();
// Create the target folder if needed
if(!is_file($file)) {
$dir = dirname($file);
if(!is_dir($dir)) {
$success = \n2n\io\IoUtils::mkdirs($dir, 0777, true);
if ($success === false) {
$this->warn("Failed creating target directory [$dir]. Closing appender.");
$this->closed = true;
return false;
}
}
}
$mode = $this->append ? 'a' : 'w';
$this->fp = \n2n\io\IoUtils::fopen($file, $mode);
if ($this->fp === false) {
$this->warn("Failed opening target file. Closing appender.");
$this->fp = null;
$this->closed = true;
return false;
}
// Required when appending with concurrent access
if($this->append) {
\n2n\io\IoUtils::fseek($this->fp, 0, SEEK_END);
}
// Write the header
$this->write($this->layout->getHeader());
}
|
[
"protected",
"function",
"openFile",
"(",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getTargetFile",
"(",
")",
";",
"// Create the target folder if needed\r",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"success",
"=",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"mkdirs",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"if",
"(",
"$",
"success",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed creating target directory [$dir]. Closing appender.\"",
")",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"return",
"false",
";",
"}",
"}",
"}",
"$",
"mode",
"=",
"$",
"this",
"->",
"append",
"?",
"'a'",
":",
"'w'",
";",
"$",
"this",
"->",
"fp",
"=",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"fopen",
"(",
"$",
"file",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fp",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed opening target file. Closing appender.\"",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"return",
"false",
";",
"}",
"// Required when appending with concurrent access\r",
"if",
"(",
"$",
"this",
"->",
"append",
")",
"{",
"\\",
"n2n",
"\\",
"io",
"\\",
"IoUtils",
"::",
"fseek",
"(",
"$",
"this",
"->",
"fp",
",",
"0",
",",
"SEEK_END",
")",
";",
"}",
"// Write the header\r",
"$",
"this",
"->",
"write",
"(",
"$",
"this",
"->",
"layout",
"->",
"getHeader",
"(",
")",
")",
";",
"}"
] |
Acquires the target file resource, creates the destination folder if
necessary. Writes layout header to file.
@return boolean FALSE if opening failed
|
[
"Acquires",
"the",
"target",
"file",
"resource",
"creates",
"the",
"destination",
"folder",
"if",
"necessary",
".",
"Writes",
"layout",
"header",
"to",
"file",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderFile.php#L82-L115
|
225,106
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/daily/DailyFile.php
|
DailyFile.append
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
$eventDate = $this->getDate($event->getTimestamp());
// Initial setting of current date
if (!isset($this->currentDate)) {
$this->currentDate = $eventDate;
}
// Check if rollover is needed
else if ($this->currentDate !== $eventDate) {
$this->currentDate = $eventDate;
// Close the file if it's open.
// Note: $this->close() is not called here because it would set
// $this->closed to true and the appender would not recieve
// any more logging requests
if (is_resource($this->fp)) {
$this->write($this->layout->getFooter());
fclose($this->fp);
}
$this->fp = null;
}
parent::append($event);
}
|
php
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
$eventDate = $this->getDate($event->getTimestamp());
// Initial setting of current date
if (!isset($this->currentDate)) {
$this->currentDate = $eventDate;
}
// Check if rollover is needed
else if ($this->currentDate !== $eventDate) {
$this->currentDate = $eventDate;
// Close the file if it's open.
// Note: $this->close() is not called here because it would set
// $this->closed to true and the appender would not recieve
// any more logging requests
if (is_resource($this->fp)) {
$this->write($this->layout->getFooter());
fclose($this->fp);
}
$this->fp = null;
}
parent::append($event);
}
|
[
"public",
"function",
"append",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"$",
"eventDate",
"=",
"$",
"this",
"->",
"getDate",
"(",
"$",
"event",
"->",
"getTimestamp",
"(",
")",
")",
";",
"// Initial setting of current date\r",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentDate",
")",
")",
"{",
"$",
"this",
"->",
"currentDate",
"=",
"$",
"eventDate",
";",
"}",
"// Check if rollover is needed\r",
"else",
"if",
"(",
"$",
"this",
"->",
"currentDate",
"!==",
"$",
"eventDate",
")",
"{",
"$",
"this",
"->",
"currentDate",
"=",
"$",
"eventDate",
";",
"// Close the file if it's open.\r",
"// Note: $this->close() is not called here because it would set\r",
"// $this->closed to true and the appender would not recieve\r",
"// any more logging requests\r",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"fp",
")",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"$",
"this",
"->",
"layout",
"->",
"getFooter",
"(",
")",
")",
";",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"}",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"}",
"parent",
"::",
"append",
"(",
"$",
"event",
")",
";",
"}"
] |
Appends a logging event.
If the target file changes because of passage of time (e.g. at midnight)
the current file is closed. A new file, with the new date, will be
opened by the write() method.
|
[
"Appends",
"a",
"logging",
"event",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/daily/DailyFile.php#L78-L102
|
225,107
|
czogori/Dami
|
src/Dami/Migration.php
|
Migration.migrate
|
public function migrate($version = null, $message = null, $up = true)
{
return $this->execute($version, $message, $up);
}
|
php
|
public function migrate($version = null, $message = null, $up = true)
{
return $this->execute($version, $message, $up);
}
|
[
"public",
"function",
"migrate",
"(",
"$",
"version",
"=",
"null",
",",
"$",
"message",
"=",
"null",
",",
"$",
"up",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"version",
",",
"$",
"message",
",",
"$",
"up",
")",
";",
"}"
] |
Migrate the schema to the given version.
@return integer Number of migrations.
|
[
"Migrate",
"the",
"schema",
"to",
"the",
"given",
"version",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration.php#L32-L35
|
225,108
|
czogori/Dami
|
src/Dami/Migration.php
|
Migration.execute
|
private function execute($version = null, $message = null, $up = true)
{
$files = $this->migrationFiles->get($version, $up);
if (null === $files) {
return 0;
}
$this->schemaManipulation->execute('BEGIN');
try {
foreach ($files as $file) {
require_once $file->getPath();
$definition = $this->createMigrationApiInstance($file->getClassName());
if ($message) {
$message($file->getName(), $file->getVersion());
}
if ($up) {
$definition->up();
} else {
$definition->down();
}
foreach ($definition->getActions() as $action) {
if (!is_callable($action)) {
throw new \InvalidArgumentException('Migration must be callable');
}
$action = call_user_func_array($action, array());
if ($action instanceof MigrationApi) {
$action->execute();
}
}
$this->schemaTable->migrateToVersion($file->getVersion(), $up);
}
$this->schemaManipulation->execute('COMMIT');
} catch (\Exception $e) {
$this->schemaManipulation->execute('ROLLBACK');
throw $e;
}
return count($files);
}
|
php
|
private function execute($version = null, $message = null, $up = true)
{
$files = $this->migrationFiles->get($version, $up);
if (null === $files) {
return 0;
}
$this->schemaManipulation->execute('BEGIN');
try {
foreach ($files as $file) {
require_once $file->getPath();
$definition = $this->createMigrationApiInstance($file->getClassName());
if ($message) {
$message($file->getName(), $file->getVersion());
}
if ($up) {
$definition->up();
} else {
$definition->down();
}
foreach ($definition->getActions() as $action) {
if (!is_callable($action)) {
throw new \InvalidArgumentException('Migration must be callable');
}
$action = call_user_func_array($action, array());
if ($action instanceof MigrationApi) {
$action->execute();
}
}
$this->schemaTable->migrateToVersion($file->getVersion(), $up);
}
$this->schemaManipulation->execute('COMMIT');
} catch (\Exception $e) {
$this->schemaManipulation->execute('ROLLBACK');
throw $e;
}
return count($files);
}
|
[
"private",
"function",
"execute",
"(",
"$",
"version",
"=",
"null",
",",
"$",
"message",
"=",
"null",
",",
"$",
"up",
"=",
"true",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"migrationFiles",
"->",
"get",
"(",
"$",
"version",
",",
"$",
"up",
")",
";",
"if",
"(",
"null",
"===",
"$",
"files",
")",
"{",
"return",
"0",
";",
"}",
"$",
"this",
"->",
"schemaManipulation",
"->",
"execute",
"(",
"'BEGIN'",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"require_once",
"$",
"file",
"->",
"getPath",
"(",
")",
";",
"$",
"definition",
"=",
"$",
"this",
"->",
"createMigrationApiInstance",
"(",
"$",
"file",
"->",
"getClassName",
"(",
")",
")",
";",
"if",
"(",
"$",
"message",
")",
"{",
"$",
"message",
"(",
"$",
"file",
"->",
"getName",
"(",
")",
",",
"$",
"file",
"->",
"getVersion",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"up",
")",
"{",
"$",
"definition",
"->",
"up",
"(",
")",
";",
"}",
"else",
"{",
"$",
"definition",
"->",
"down",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"definition",
"->",
"getActions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"action",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Migration must be callable'",
")",
";",
"}",
"$",
"action",
"=",
"call_user_func_array",
"(",
"$",
"action",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"$",
"action",
"instanceof",
"MigrationApi",
")",
"{",
"$",
"action",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"schemaTable",
"->",
"migrateToVersion",
"(",
"$",
"file",
"->",
"getVersion",
"(",
")",
",",
"$",
"up",
")",
";",
"}",
"$",
"this",
"->",
"schemaManipulation",
"->",
"execute",
"(",
"'COMMIT'",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"schemaManipulation",
"->",
"execute",
"(",
"'ROLLBACK'",
")",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"count",
"(",
"$",
"files",
")",
";",
"}"
] |
Execute migrate.
@param string $version The version of migration to rollback or migrate.
@return integer Number of executed migrations.
|
[
"Execute",
"migrate",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration.php#L66-L106
|
225,109
|
railken/amethyst-data-builder
|
src/DataBuilders/CommonDataBuilder.php
|
CommonDataBuilder.extract
|
public function extract(Collection $resources, Closure $callback)
{
foreach ($resources as $resource) {
$callback($resource, [$this->inflector->singularize($this->getVariableName()) => $resource]);
}
}
|
php
|
public function extract(Collection $resources, Closure $callback)
{
foreach ($resources as $resource) {
$callback($resource, [$this->inflector->singularize($this->getVariableName()) => $resource]);
}
}
|
[
"public",
"function",
"extract",
"(",
"Collection",
"$",
"resources",
",",
"Closure",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"resources",
"as",
"$",
"resource",
")",
"{",
"$",
"callback",
"(",
"$",
"resource",
",",
"[",
"$",
"this",
"->",
"inflector",
"->",
"singularize",
"(",
"$",
"this",
"->",
"getVariableName",
"(",
")",
")",
"=>",
"$",
"resource",
"]",
")",
";",
"}",
"}"
] |
Extract a single resource.
@param Collection $resources
@param \Closure $callback
|
[
"Extract",
"a",
"single",
"resource",
"."
] |
55334227b6b7f14cf755b02e7cd36a11db00f454
|
https://github.com/railken/amethyst-data-builder/blob/55334227b6b7f14cf755b02e7cd36a11db00f454/src/DataBuilders/CommonDataBuilder.php#L73-L78
|
225,110
|
railken/amethyst-data-builder
|
src/DataBuilders/CommonDataBuilder.php
|
CommonDataBuilder.parse
|
public function parse(Collection $resources): Collection
{
return new Collection([$this->inflector->pluralize($this->getVariableName()) => $resources]);
}
|
php
|
public function parse(Collection $resources): Collection
{
return new Collection([$this->inflector->pluralize($this->getVariableName()) => $resources]);
}
|
[
"public",
"function",
"parse",
"(",
"Collection",
"$",
"resources",
")",
":",
"Collection",
"{",
"return",
"new",
"Collection",
"(",
"[",
"$",
"this",
"->",
"inflector",
"->",
"pluralize",
"(",
"$",
"this",
"->",
"getVariableName",
"(",
")",
")",
"=>",
"$",
"resources",
"]",
")",
";",
"}"
] |
Parse collection of resources.
@param Collection $resources
@return Collection
|
[
"Parse",
"collection",
"of",
"resources",
"."
] |
55334227b6b7f14cf755b02e7cd36a11db00f454
|
https://github.com/railken/amethyst-data-builder/blob/55334227b6b7f14cf755b02e7cd36a11db00f454/src/DataBuilders/CommonDataBuilder.php#L87-L90
|
225,111
|
SetBased/php-abc-form
|
src/Form.php
|
Form.csrfCheck
|
public function csrfCheck()
{
// Return immediately if CSRF check is disabled.
if (!$this->csrfCheck) return;
$control = $this->hiddenFieldSet->getFormControlByName('ses_csrf_token');
// If CSRF tokens (from session and from submitted form) don't match: possible CSRF attack.
$ses_csrf_token1 = Abc::$session->getCsrfToken();
$ses_csrf_token2 = $control->getSubmittedValue();
if ($ses_csrf_token1!==$ses_csrf_token2)
{
throw new BadRequestException('Possible CSRF attack');
}
}
|
php
|
public function csrfCheck()
{
// Return immediately if CSRF check is disabled.
if (!$this->csrfCheck) return;
$control = $this->hiddenFieldSet->getFormControlByName('ses_csrf_token');
// If CSRF tokens (from session and from submitted form) don't match: possible CSRF attack.
$ses_csrf_token1 = Abc::$session->getCsrfToken();
$ses_csrf_token2 = $control->getSubmittedValue();
if ($ses_csrf_token1!==$ses_csrf_token2)
{
throw new BadRequestException('Possible CSRF attack');
}
}
|
[
"public",
"function",
"csrfCheck",
"(",
")",
"{",
"// Return immediately if CSRF check is disabled.",
"if",
"(",
"!",
"$",
"this",
"->",
"csrfCheck",
")",
"return",
";",
"$",
"control",
"=",
"$",
"this",
"->",
"hiddenFieldSet",
"->",
"getFormControlByName",
"(",
"'ses_csrf_token'",
")",
";",
"// If CSRF tokens (from session and from submitted form) don't match: possible CSRF attack.",
"$",
"ses_csrf_token1",
"=",
"Abc",
"::",
"$",
"session",
"->",
"getCsrfToken",
"(",
")",
";",
"$",
"ses_csrf_token2",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"if",
"(",
"$",
"ses_csrf_token1",
"!==",
"$",
"ses_csrf_token2",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"'Possible CSRF attack'",
")",
";",
"}",
"}"
] |
Defends against CSRF attacks using State Full Double Submit Cookie.
@throws RuntimeException
|
[
"Defends",
"against",
"CSRF",
"attacks",
"using",
"State",
"Full",
"Double",
"Submit",
"Cookie",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Form.php#L88-L102
|
225,112
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.getMainForeignKeyColumnName
|
public function getMainForeignKeyColumnName() {
/** @var KeyValueTableInterface $this */
if (empty($this->_detectedMainForeignKeyColumnName)) {
foreach ($this->getTableStructure()->getRelations() as $relationConfig) {
if ($relationConfig->getType() === Relation::BELONGS_TO) {
$this->_detectedMainForeignKeyColumnName = $relationConfig->getLocalColumnName();
break;
}
}
if ($this->_detectedMainForeignKeyColumnName === null) {
throw new \BadMethodCallException(
get_called_class() . '::' . __METHOD__ . ' - cannot find foreign key column name'
);
}
}
return $this->_detectedMainForeignKeyColumnName;
}
|
php
|
public function getMainForeignKeyColumnName() {
/** @var KeyValueTableInterface $this */
if (empty($this->_detectedMainForeignKeyColumnName)) {
foreach ($this->getTableStructure()->getRelations() as $relationConfig) {
if ($relationConfig->getType() === Relation::BELONGS_TO) {
$this->_detectedMainForeignKeyColumnName = $relationConfig->getLocalColumnName();
break;
}
}
if ($this->_detectedMainForeignKeyColumnName === null) {
throw new \BadMethodCallException(
get_called_class() . '::' . __METHOD__ . ' - cannot find foreign key column name'
);
}
}
return $this->_detectedMainForeignKeyColumnName;
}
|
[
"public",
"function",
"getMainForeignKeyColumnName",
"(",
")",
"{",
"/** @var KeyValueTableInterface $this */",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_detectedMainForeignKeyColumnName",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getTableStructure",
"(",
")",
"->",
"getRelations",
"(",
")",
"as",
"$",
"relationConfig",
")",
"{",
"if",
"(",
"$",
"relationConfig",
"->",
"getType",
"(",
")",
"===",
"Relation",
"::",
"BELONGS_TO",
")",
"{",
"$",
"this",
"->",
"_detectedMainForeignKeyColumnName",
"=",
"$",
"relationConfig",
"->",
"getLocalColumnName",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"_detectedMainForeignKeyColumnName",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"get_called_class",
"(",
")",
".",
"'::'",
".",
"__METHOD__",
".",
"' - cannot find foreign key column name'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_detectedMainForeignKeyColumnName",
";",
"}"
] |
Override if you wish to provide key manually
@return string|null - null returned when there is no foreign key
@throws \UnexpectedValueException
@throws \InvalidArgumentException
@throws \BadMethodCallException
|
[
"Override",
"if",
"you",
"wish",
"to",
"provide",
"key",
"manually"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L37-L53
|
225,113
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.makeDataForRecord
|
static public function makeDataForRecord($key, $value, $foreignKeyValue = null) {
$record = [
static::getKeysColumnName() => $key,
static::getValuesColumnName() => static::encodeValue($value),
];
if ($foreignKeyValue !== null && ($foreignKeyColumn = static::getInstance()->getMainForeignKeyColumnName())) {
$record[$foreignKeyColumn] = $foreignKeyValue;
}
return $record;
}
|
php
|
static public function makeDataForRecord($key, $value, $foreignKeyValue = null) {
$record = [
static::getKeysColumnName() => $key,
static::getValuesColumnName() => static::encodeValue($value),
];
if ($foreignKeyValue !== null && ($foreignKeyColumn = static::getInstance()->getMainForeignKeyColumnName())) {
$record[$foreignKeyColumn] = $foreignKeyValue;
}
return $record;
}
|
[
"static",
"public",
"function",
"makeDataForRecord",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"foreignKeyValue",
"=",
"null",
")",
"{",
"$",
"record",
"=",
"[",
"static",
"::",
"getKeysColumnName",
"(",
")",
"=>",
"$",
"key",
",",
"static",
"::",
"getValuesColumnName",
"(",
")",
"=>",
"static",
"::",
"encodeValue",
"(",
"$",
"value",
")",
",",
"]",
";",
"if",
"(",
"$",
"foreignKeyValue",
"!==",
"null",
"&&",
"(",
"$",
"foreignKeyColumn",
"=",
"static",
"::",
"getInstance",
"(",
")",
"->",
"getMainForeignKeyColumnName",
"(",
")",
")",
")",
"{",
"$",
"record",
"[",
"$",
"foreignKeyColumn",
"]",
"=",
"$",
"foreignKeyValue",
";",
"}",
"return",
"$",
"record",
";",
"}"
] |
Make array that represents DB record and can be saved to DB
@param string $key
@param mixed $value
@param mixed $foreignKeyValue
@return array
|
[
"Make",
"array",
"that",
"represents",
"DB",
"record",
"and",
"can",
"be",
"saved",
"to",
"DB"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L77-L86
|
225,114
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.convertToDataForRecords
|
static public function convertToDataForRecords(array $settingsAssoc, $foreignKeyValue = null, $additionalConstantValues = []) {
$records = [];
foreach ($settingsAssoc as $key => $value) {
$records[] = array_merge(
$additionalConstantValues,
static::makeDataForRecord($key, $value, $foreignKeyValue)
);
}
return $records;
}
|
php
|
static public function convertToDataForRecords(array $settingsAssoc, $foreignKeyValue = null, $additionalConstantValues = []) {
$records = [];
foreach ($settingsAssoc as $key => $value) {
$records[] = array_merge(
$additionalConstantValues,
static::makeDataForRecord($key, $value, $foreignKeyValue)
);
}
return $records;
}
|
[
"static",
"public",
"function",
"convertToDataForRecords",
"(",
"array",
"$",
"settingsAssoc",
",",
"$",
"foreignKeyValue",
"=",
"null",
",",
"$",
"additionalConstantValues",
"=",
"[",
"]",
")",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"settingsAssoc",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"records",
"[",
"]",
"=",
"array_merge",
"(",
"$",
"additionalConstantValues",
",",
"static",
"::",
"makeDataForRecord",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"foreignKeyValue",
")",
")",
";",
"}",
"return",
"$",
"records",
";",
"}"
] |
Convert associative array to arrays that represent DB record and are ready for saving to DB
@param array $settingsAssoc - associative array of settings
@param mixed $foreignKeyValue
@param array $additionalConstantValues - contains constant values for all records (for example: admin id)
@return array
|
[
"Convert",
"associative",
"array",
"to",
"arrays",
"that",
"represent",
"DB",
"record",
"and",
"are",
"ready",
"for",
"saving",
"to",
"DB"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L107-L116
|
225,115
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.decodeValues
|
static public function decodeValues(array $settingsAssoc) {
foreach ($settingsAssoc as $key => &$value) {
$value = static::decodeValue($value);
}
return $settingsAssoc;
}
|
php
|
static public function decodeValues(array $settingsAssoc) {
foreach ($settingsAssoc as $key => &$value) {
$value = static::decodeValue($value);
}
return $settingsAssoc;
}
|
[
"static",
"public",
"function",
"decodeValues",
"(",
"array",
"$",
"settingsAssoc",
")",
"{",
"foreach",
"(",
"$",
"settingsAssoc",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"decodeValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"settingsAssoc",
";",
"}"
] |
Decode values for passed settings associative array
@param array $settingsAssoc
@return mixed
|
[
"Decode",
"values",
"for",
"passed",
"settings",
"associative",
"array"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L123-L128
|
225,116
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.updateOrCreateRecord
|
static public function updateOrCreateRecord(array $data) {
if (empty($data[static::getKeysColumnName()])) {
throw new \InvalidArgumentException(
'$record argument does not contain value for key \'' . static::getKeysColumnName() . '\' or its value is empty'
);
} else if (!array_key_exists(static::getValuesColumnName(), $data)) {
throw new \InvalidArgumentException(
'$record argument does not contain value for key \'' . static::getValuesColumnName() . '\' or its value is empty'
);
}
$conditions = [
static::getKeysColumnName() => $data[static::getKeysColumnName()]
];
$fkName = static::getInstance()->getMainForeignKeyColumnName();
if (!empty($fkName)) {
if (empty($data[$fkName])) {
throw new \InvalidArgumentException("\$record argument does not contain value for key '{$fkName}' or its value is empty");
}
$conditions[$fkName] = $data[$fkName];
}
/** @var Record $object */
$object = static::getInstance()->newRecord()->fromDb($conditions);
if ($object->existsInDb()) {
$success = $object
->begin()
->updateValues(array_diff_key($data, [static::getKeysColumnName() => '', $fkName => '']), false)
->commit();
} else {
$object
->reset()
->updateValues($data, false);
$success = $object->save();
}
static::cleanCachedValues(empty($fkName) ? null : $data[$fkName]);
return $success;
}
|
php
|
static public function updateOrCreateRecord(array $data) {
if (empty($data[static::getKeysColumnName()])) {
throw new \InvalidArgumentException(
'$record argument does not contain value for key \'' . static::getKeysColumnName() . '\' or its value is empty'
);
} else if (!array_key_exists(static::getValuesColumnName(), $data)) {
throw new \InvalidArgumentException(
'$record argument does not contain value for key \'' . static::getValuesColumnName() . '\' or its value is empty'
);
}
$conditions = [
static::getKeysColumnName() => $data[static::getKeysColumnName()]
];
$fkName = static::getInstance()->getMainForeignKeyColumnName();
if (!empty($fkName)) {
if (empty($data[$fkName])) {
throw new \InvalidArgumentException("\$record argument does not contain value for key '{$fkName}' or its value is empty");
}
$conditions[$fkName] = $data[$fkName];
}
/** @var Record $object */
$object = static::getInstance()->newRecord()->fromDb($conditions);
if ($object->existsInDb()) {
$success = $object
->begin()
->updateValues(array_diff_key($data, [static::getKeysColumnName() => '', $fkName => '']), false)
->commit();
} else {
$object
->reset()
->updateValues($data, false);
$success = $object->save();
}
static::cleanCachedValues(empty($fkName) ? null : $data[$fkName]);
return $success;
}
|
[
"static",
"public",
"function",
"updateOrCreateRecord",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"static",
"::",
"getKeysColumnName",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$record argument does not contain value for key \\''",
".",
"static",
"::",
"getKeysColumnName",
"(",
")",
".",
"'\\' or its value is empty'",
")",
";",
"}",
"else",
"if",
"(",
"!",
"array_key_exists",
"(",
"static",
"::",
"getValuesColumnName",
"(",
")",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$record argument does not contain value for key \\''",
".",
"static",
"::",
"getValuesColumnName",
"(",
")",
".",
"'\\' or its value is empty'",
")",
";",
"}",
"$",
"conditions",
"=",
"[",
"static",
"::",
"getKeysColumnName",
"(",
")",
"=>",
"$",
"data",
"[",
"static",
"::",
"getKeysColumnName",
"(",
")",
"]",
"]",
";",
"$",
"fkName",
"=",
"static",
"::",
"getInstance",
"(",
")",
"->",
"getMainForeignKeyColumnName",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"fkName",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"$",
"fkName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"\\$record argument does not contain value for key '{$fkName}' or its value is empty\"",
")",
";",
"}",
"$",
"conditions",
"[",
"$",
"fkName",
"]",
"=",
"$",
"data",
"[",
"$",
"fkName",
"]",
";",
"}",
"/** @var Record $object */",
"$",
"object",
"=",
"static",
"::",
"getInstance",
"(",
")",
"->",
"newRecord",
"(",
")",
"->",
"fromDb",
"(",
"$",
"conditions",
")",
";",
"if",
"(",
"$",
"object",
"->",
"existsInDb",
"(",
")",
")",
"{",
"$",
"success",
"=",
"$",
"object",
"->",
"begin",
"(",
")",
"->",
"updateValues",
"(",
"array_diff_key",
"(",
"$",
"data",
",",
"[",
"static",
"::",
"getKeysColumnName",
"(",
")",
"=>",
"''",
",",
"$",
"fkName",
"=>",
"''",
"]",
")",
",",
"false",
")",
"->",
"commit",
"(",
")",
";",
"}",
"else",
"{",
"$",
"object",
"->",
"reset",
"(",
")",
"->",
"updateValues",
"(",
"$",
"data",
",",
"false",
")",
";",
"$",
"success",
"=",
"$",
"object",
"->",
"save",
"(",
")",
";",
"}",
"static",
"::",
"cleanCachedValues",
"(",
"empty",
"(",
"$",
"fkName",
")",
"?",
"null",
":",
"$",
"data",
"[",
"$",
"fkName",
"]",
")",
";",
"return",
"$",
"success",
";",
"}"
] |
Update existing value or create new one
@param array $data - must contain: key, foreign_key, value
@return Record
@throws \PeskyORM\Exception\RecordNotFoundException
@throws \UnexpectedValueException
@throws \PeskyORM\Exception\OrmException
@throws \PeskyORM\Exception\InvalidTableColumnConfigException
@throws \PeskyORM\Exception\InvalidDataException
@throws \PeskyORM\Exception\DbException
@throws \PDOException
@throws \InvalidArgumentException
@throws \BadMethodCallException
|
[
"Update",
"existing",
"value",
"or",
"create",
"new",
"one"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L170-L205
|
225,117
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php
|
KeyValueTableHelpers.updateOrCreateRecords
|
static public function updateOrCreateRecords(array $records) {
$table = static::getInstance();
$alreadyInTransaction = $table::inTransaction();
if (!$alreadyInTransaction) {
$table::beginTransaction();
}
try {
foreach ($records as $record) {
$success = $table::updateOrCreateRecord($record);
if (!$success) {
if (!$alreadyInTransaction) {
$table::rollBackTransaction();
}
return false;
}
}
if (!$alreadyInTransaction) {
$table::commitTransaction();
}
return true;
} catch (\Exception $exc) {
if (!$alreadyInTransaction && $table::inTransaction()) {
$table::rollBackTransaction();
}
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw $exc;
}
}
|
php
|
static public function updateOrCreateRecords(array $records) {
$table = static::getInstance();
$alreadyInTransaction = $table::inTransaction();
if (!$alreadyInTransaction) {
$table::beginTransaction();
}
try {
foreach ($records as $record) {
$success = $table::updateOrCreateRecord($record);
if (!$success) {
if (!$alreadyInTransaction) {
$table::rollBackTransaction();
}
return false;
}
}
if (!$alreadyInTransaction) {
$table::commitTransaction();
}
return true;
} catch (\Exception $exc) {
if (!$alreadyInTransaction && $table::inTransaction()) {
$table::rollBackTransaction();
}
/** @noinspection ExceptionsAnnotatingAndHandlingInspection */
throw $exc;
}
}
|
[
"static",
"public",
"function",
"updateOrCreateRecords",
"(",
"array",
"$",
"records",
")",
"{",
"$",
"table",
"=",
"static",
"::",
"getInstance",
"(",
")",
";",
"$",
"alreadyInTransaction",
"=",
"$",
"table",
"::",
"inTransaction",
"(",
")",
";",
"if",
"(",
"!",
"$",
"alreadyInTransaction",
")",
"{",
"$",
"table",
"::",
"beginTransaction",
"(",
")",
";",
"}",
"try",
"{",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"success",
"=",
"$",
"table",
"::",
"updateOrCreateRecord",
"(",
"$",
"record",
")",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"if",
"(",
"!",
"$",
"alreadyInTransaction",
")",
"{",
"$",
"table",
"::",
"rollBackTransaction",
"(",
")",
";",
"}",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"alreadyInTransaction",
")",
"{",
"$",
"table",
"::",
"commitTransaction",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exc",
")",
"{",
"if",
"(",
"!",
"$",
"alreadyInTransaction",
"&&",
"$",
"table",
"::",
"inTransaction",
"(",
")",
")",
"{",
"$",
"table",
"::",
"rollBackTransaction",
"(",
")",
";",
"}",
"/** @noinspection ExceptionsAnnotatingAndHandlingInspection */",
"throw",
"$",
"exc",
";",
"}",
"}"
] |
Update existing values and create new
@param array $records
@return bool
|
[
"Update",
"existing",
"values",
"and",
"create",
"new"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/KeyValueTableUtils/KeyValueTableHelpers.php#L212-L239
|
225,118
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/Common/EncodingResponse.php
|
EncodingResponse.getErrorMessage
|
public function getErrorMessage()
{
$errorValue = null;
if ($this->hasError()) {
$errorValue = (string) $this->xmlElement->errors->error;
}
return $errorValue;
}
|
php
|
public function getErrorMessage()
{
$errorValue = null;
if ($this->hasError()) {
$errorValue = (string) $this->xmlElement->errors->error;
}
return $errorValue;
}
|
[
"public",
"function",
"getErrorMessage",
"(",
")",
"{",
"$",
"errorValue",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasError",
"(",
")",
")",
"{",
"$",
"errorValue",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"xmlElement",
"->",
"errors",
"->",
"error",
";",
"}",
"return",
"$",
"errorValue",
";",
"}"
] |
Returns the error message
@return string Error message
|
[
"Returns",
"the",
"error",
"message"
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Common/EncodingResponse.php#L68-L75
|
225,119
|
DrNixx/yii2-onix
|
src/collections/AbstractSortedSet.php
|
AbstractSortedSet.offsetGet
|
public function offsetGet($element)
{
try {
return (bool) $this->map->find($element);
} catch (\OutOfBoundsException $e) {
return false;
}
}
|
php
|
public function offsetGet($element)
{
try {
return (bool) $this->map->find($element);
} catch (\OutOfBoundsException $e) {
return false;
}
}
|
[
"public",
"function",
"offsetGet",
"(",
"$",
"element",
")",
"{",
"try",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"map",
"->",
"find",
"(",
"$",
"element",
")",
";",
"}",
"catch",
"(",
"\\",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Get the value for an element
@param mixed $element The element
@return mixed The found value
|
[
"Get",
"the",
"value",
"for",
"an",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/AbstractSortedSet.php#L193-L200
|
225,120
|
SlayerBirden/dataflow
|
src/Pipe/Map.php
|
Map.pass
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$dataBag[$this->field] = ($this->callback)($dataBag[$this->field] ?? null, $dataBag);
return $dataBag;
}
|
php
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$dataBag[$this->field] = ($this->callback)($dataBag[$this->field] ?? null, $dataBag);
return $dataBag;
}
|
[
"public",
"function",
"pass",
"(",
"DataBagInterface",
"$",
"dataBag",
")",
":",
"DataBagInterface",
"{",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"field",
"]",
"=",
"(",
"$",
"this",
"->",
"callback",
")",
"(",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"field",
"]",
"??",
"null",
",",
"$",
"dataBag",
")",
";",
"return",
"$",
"dataBag",
";",
"}"
] |
Mapping handler.
Proceeds to transform an entry to a new value using callback function.
{@inheritdoc}
|
[
"Mapping",
"handler",
".",
"Proceeds",
"to",
"transform",
"an",
"entry",
"to",
"a",
"new",
"value",
"using",
"callback",
"function",
"."
] |
a9cb826b106e882e43523d39fea319adc4893e00
|
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Pipe/Map.php#L39-L44
|
225,121
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerAppender.php
|
LoggerAppender.warn
|
protected function warn($message) {
$id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
throw new \n2n\log4php\LoggerException("log4php: [$id]: $message", E_USER_WARNING);
}
|
php
|
protected function warn($message) {
$id = get_class($this) . (empty($this->name) ? '' : ":{$this->name}");
throw new \n2n\log4php\LoggerException("log4php: [$id]: $message", E_USER_WARNING);
}
|
[
"protected",
"function",
"warn",
"(",
"$",
"message",
")",
"{",
"$",
"id",
"=",
"get_class",
"(",
"$",
"this",
")",
".",
"(",
"empty",
"(",
"$",
"this",
"->",
"name",
")",
"?",
"''",
":",
"\":{$this->name}\"",
")",
";",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"log4php: [$id]: $message\"",
",",
"E_USER_WARNING",
")",
";",
"}"
] |
Triggers a warning for this logger with the given message.
|
[
"Triggers",
"a",
"warning",
"for",
"this",
"logger",
"with",
"the",
"given",
"message",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerAppender.php#L282-L285
|
225,122
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/EncodingClient.php
|
EncodingClient.factory
|
public static function factory($config = array())
{
$config = self::getConfigCollection($config);
$client = new EncodingClient($config->get('base_url'), $config->get('userid'), $config->get('userkey'));
$client->setConfig($config);
// Add the XML service description to the client
$description = ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'guzzle_encoding_com.json');
$client->setDescription($description);
return $client;
}
|
php
|
public static function factory($config = array())
{
$config = self::getConfigCollection($config);
$client = new EncodingClient($config->get('base_url'), $config->get('userid'), $config->get('userkey'));
$client->setConfig($config);
// Add the XML service description to the client
$description = ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'guzzle_encoding_com.json');
$client->setDescription($description);
return $client;
}
|
[
"public",
"static",
"function",
"factory",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"config",
"=",
"self",
"::",
"getConfigCollection",
"(",
"$",
"config",
")",
";",
"$",
"client",
"=",
"new",
"EncodingClient",
"(",
"$",
"config",
"->",
"get",
"(",
"'base_url'",
")",
",",
"$",
"config",
"->",
"get",
"(",
"'userid'",
")",
",",
"$",
"config",
"->",
"get",
"(",
"'userkey'",
")",
")",
";",
"$",
"client",
"->",
"setConfig",
"(",
"$",
"config",
")",
";",
"// Add the XML service description to the client",
"$",
"description",
"=",
"ServiceDescription",
"::",
"factory",
"(",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'guzzle_encoding_com.json'",
")",
";",
"$",
"client",
"->",
"setDescription",
"(",
"$",
"description",
")",
";",
"return",
"$",
"client",
";",
"}"
] |
Create new EncodingClient Instance
@param array|Collection $config
Configuration data. Array keys:
base_url - http(s)://manage.encoding.com
userid - API User Id
userkey - API Key
@return EncodingClient
|
[
"Create",
"new",
"EncodingClient",
"Instance"
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/EncodingClient.php#L38-L51
|
225,123
|
stubbles/stubbles-input
|
src/main/php/broker/RequestBroker.php
|
RequestBroker.buildInTypes
|
public static function buildInTypes(): array
{
if (null === self::$buildInParamBroker) {
self::$buildInParamBroker = [
'array' => new param\ArrayParamBroker(),
'bool' => new param\BoolParamBroker(),
'customdatespan' => new param\CustomDatespanParamBroker(),
'date' => new param\DateParamBroker(),
'datespan' => new param\DatespanParamBroker(),
'day' => new param\DayParamBroker(),
'float' => new param\FloatParamBroker(),
'httpuri' => new param\HttpUriParamBroker(),
'integer' => new param\IntegerParamBroker(),
'json' => new param\JsonParamBroker(),
'mail' => new param\MailParamBroker(),
'month' => new param\MonthParamBroker(),
'oneof' => new param\OneOfParamBroker(),
'password' => new param\PasswordParamBroker(),
'string' => new param\StringParamBroker(),
'secret' => new param\SecretParamBroker(),
'text' => new param\TextParamBroker(),
'week' => new param\WeekParamBroker(),
];
}
return self::$buildInParamBroker;
}
|
php
|
public static function buildInTypes(): array
{
if (null === self::$buildInParamBroker) {
self::$buildInParamBroker = [
'array' => new param\ArrayParamBroker(),
'bool' => new param\BoolParamBroker(),
'customdatespan' => new param\CustomDatespanParamBroker(),
'date' => new param\DateParamBroker(),
'datespan' => new param\DatespanParamBroker(),
'day' => new param\DayParamBroker(),
'float' => new param\FloatParamBroker(),
'httpuri' => new param\HttpUriParamBroker(),
'integer' => new param\IntegerParamBroker(),
'json' => new param\JsonParamBroker(),
'mail' => new param\MailParamBroker(),
'month' => new param\MonthParamBroker(),
'oneof' => new param\OneOfParamBroker(),
'password' => new param\PasswordParamBroker(),
'string' => new param\StringParamBroker(),
'secret' => new param\SecretParamBroker(),
'text' => new param\TextParamBroker(),
'week' => new param\WeekParamBroker(),
];
}
return self::$buildInParamBroker;
}
|
[
"public",
"static",
"function",
"buildInTypes",
"(",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"buildInParamBroker",
")",
"{",
"self",
"::",
"$",
"buildInParamBroker",
"=",
"[",
"'array'",
"=>",
"new",
"param",
"\\",
"ArrayParamBroker",
"(",
")",
",",
"'bool'",
"=>",
"new",
"param",
"\\",
"BoolParamBroker",
"(",
")",
",",
"'customdatespan'",
"=>",
"new",
"param",
"\\",
"CustomDatespanParamBroker",
"(",
")",
",",
"'date'",
"=>",
"new",
"param",
"\\",
"DateParamBroker",
"(",
")",
",",
"'datespan'",
"=>",
"new",
"param",
"\\",
"DatespanParamBroker",
"(",
")",
",",
"'day'",
"=>",
"new",
"param",
"\\",
"DayParamBroker",
"(",
")",
",",
"'float'",
"=>",
"new",
"param",
"\\",
"FloatParamBroker",
"(",
")",
",",
"'httpuri'",
"=>",
"new",
"param",
"\\",
"HttpUriParamBroker",
"(",
")",
",",
"'integer'",
"=>",
"new",
"param",
"\\",
"IntegerParamBroker",
"(",
")",
",",
"'json'",
"=>",
"new",
"param",
"\\",
"JsonParamBroker",
"(",
")",
",",
"'mail'",
"=>",
"new",
"param",
"\\",
"MailParamBroker",
"(",
")",
",",
"'month'",
"=>",
"new",
"param",
"\\",
"MonthParamBroker",
"(",
")",
",",
"'oneof'",
"=>",
"new",
"param",
"\\",
"OneOfParamBroker",
"(",
")",
",",
"'password'",
"=>",
"new",
"param",
"\\",
"PasswordParamBroker",
"(",
")",
",",
"'string'",
"=>",
"new",
"param",
"\\",
"StringParamBroker",
"(",
")",
",",
"'secret'",
"=>",
"new",
"param",
"\\",
"SecretParamBroker",
"(",
")",
",",
"'text'",
"=>",
"new",
"param",
"\\",
"TextParamBroker",
"(",
")",
",",
"'week'",
"=>",
"new",
"param",
"\\",
"WeekParamBroker",
"(",
")",
",",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"buildInParamBroker",
";",
"}"
] |
returns list of build in param brokers
@return \stubbles\input\broker\param\ParamBroker[]
|
[
"returns",
"list",
"of",
"build",
"in",
"param",
"brokers"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/RequestBroker.php#L38-L64
|
225,124
|
stubbles/stubbles-input
|
src/main/php/broker/RequestBroker.php
|
RequestBroker.procure
|
public function procure(Request $request, $object, string $group = null)
{
if (!is_object($object)) {
throw new \InvalidArgumentException('Parameter $object must be an object instance');
}
foreach (self::targetMethodsOf($object, $group) as $targetMethod) {
$targetMethod->invoke(
$object,
$this->paramBroker($targetMethod->expectedType())
->procure($request, $targetMethod->annotation())
);
}
return $object;
}
|
php
|
public function procure(Request $request, $object, string $group = null)
{
if (!is_object($object)) {
throw new \InvalidArgumentException('Parameter $object must be an object instance');
}
foreach (self::targetMethodsOf($object, $group) as $targetMethod) {
$targetMethod->invoke(
$object,
$this->paramBroker($targetMethod->expectedType())
->procure($request, $targetMethod->annotation())
);
}
return $object;
}
|
[
"public",
"function",
"procure",
"(",
"Request",
"$",
"request",
",",
"$",
"object",
",",
"string",
"$",
"group",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Parameter $object must be an object instance'",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"targetMethodsOf",
"(",
"$",
"object",
",",
"$",
"group",
")",
"as",
"$",
"targetMethod",
")",
"{",
"$",
"targetMethod",
"->",
"invoke",
"(",
"$",
"object",
",",
"$",
"this",
"->",
"paramBroker",
"(",
"$",
"targetMethod",
"->",
"expectedType",
"(",
")",
")",
"->",
"procure",
"(",
"$",
"request",
",",
"$",
"targetMethod",
"->",
"annotation",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
fills given object with values from request
@param \stubbles\input\Request $request
@param object $object the object instance to fill with values
@param string $group restrict procurement to given group
@return object
@throws \InvalidArgumentException
|
[
"fills",
"given",
"object",
"with",
"values",
"from",
"request"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/RequestBroker.php#L96-L111
|
225,125
|
stubbles/stubbles-input
|
src/main/php/broker/RequestBroker.php
|
RequestBroker.paramBroker
|
public function paramBroker($type): ParamBroker
{
if (isset($this->paramBrokers[$type])) {
return $this->paramBrokers[$type];
}
throw new \RuntimeException('No param broker found for ' . $type);
}
|
php
|
public function paramBroker($type): ParamBroker
{
if (isset($this->paramBrokers[$type])) {
return $this->paramBrokers[$type];
}
throw new \RuntimeException('No param broker found for ' . $type);
}
|
[
"public",
"function",
"paramBroker",
"(",
"$",
"type",
")",
":",
"ParamBroker",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"paramBrokers",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"paramBrokers",
"[",
"$",
"type",
"]",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No param broker found for '",
".",
"$",
"type",
")",
";",
"}"
] |
returns param broker for requested type
@param string $type
@return \stubbles\input\broker\param\ParamBroker
@throws \RuntimeException
|
[
"returns",
"param",
"broker",
"for",
"requested",
"type"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/RequestBroker.php#L120-L127
|
225,126
|
stubbles/stubbles-input
|
src/main/php/broker/RequestBroker.php
|
RequestBroker.targetMethodsOf
|
public static function targetMethodsOf($object, string $group = null): Sequence
{
return methodsOf($object, \ReflectionMethod::IS_PUBLIC)->filter(
function(\ReflectionMethod $method) use ($group)
{
if ($method->isStatic() || $method->isConstructor() || $method->isDestructor()) {
return false;
}
if (!annotationsOf($method)->contain('Request')) {
return false;
}
if (empty($group) || annotationsOf($method)->firstNamed('Request')->paramGroup() === $group) {
return true;
}
return false;
}
)->map(
function(\ReflectionMethod $method)
{
return new TargetMethod(
$method,
annotationsOf($method)->firstNamed('Request')
);
}
);
}
|
php
|
public static function targetMethodsOf($object, string $group = null): Sequence
{
return methodsOf($object, \ReflectionMethod::IS_PUBLIC)->filter(
function(\ReflectionMethod $method) use ($group)
{
if ($method->isStatic() || $method->isConstructor() || $method->isDestructor()) {
return false;
}
if (!annotationsOf($method)->contain('Request')) {
return false;
}
if (empty($group) || annotationsOf($method)->firstNamed('Request')->paramGroup() === $group) {
return true;
}
return false;
}
)->map(
function(\ReflectionMethod $method)
{
return new TargetMethod(
$method,
annotationsOf($method)->firstNamed('Request')
);
}
);
}
|
[
"public",
"static",
"function",
"targetMethodsOf",
"(",
"$",
"object",
",",
"string",
"$",
"group",
"=",
"null",
")",
":",
"Sequence",
"{",
"return",
"methodsOf",
"(",
"$",
"object",
",",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
"->",
"filter",
"(",
"function",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
"use",
"(",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"method",
"->",
"isStatic",
"(",
")",
"||",
"$",
"method",
"->",
"isConstructor",
"(",
")",
"||",
"$",
"method",
"->",
"isDestructor",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"annotationsOf",
"(",
"$",
"method",
")",
"->",
"contain",
"(",
"'Request'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"group",
")",
"||",
"annotationsOf",
"(",
"$",
"method",
")",
"->",
"firstNamed",
"(",
"'Request'",
")",
"->",
"paramGroup",
"(",
")",
"===",
"$",
"group",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
")",
"->",
"map",
"(",
"function",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
"{",
"return",
"new",
"TargetMethod",
"(",
"$",
"method",
",",
"annotationsOf",
"(",
"$",
"method",
")",
"->",
"firstNamed",
"(",
"'Request'",
")",
")",
";",
"}",
")",
";",
"}"
] |
returns all methods of given instance which are applicable for brokerage
@param object|string|\ReflectionClass $object
@param string $group optional restrict list to given group
@return \stubbles\input\broker\TargetMethod[]
|
[
"returns",
"all",
"methods",
"of",
"given",
"instance",
"which",
"are",
"applicable",
"for",
"brokerage"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/RequestBroker.php#L136-L164
|
225,127
|
SetBased/php-abc-form
|
src/Cleaner/RemoveWhitespaceCleaner.php
|
RemoveWhitespaceCleaner.clean
|
public function clean($value)
{
if ($value==='' || $value===null || $value===false)
{
return null;
}
$tmp = AmbiguityCleaner::get()->clean($value);
$tmp = str_replace([' ', "\t", "\n"], '', $tmp);
if ($tmp==='') $tmp = null;
return $tmp;
}
|
php
|
public function clean($value)
{
if ($value==='' || $value===null || $value===false)
{
return null;
}
$tmp = AmbiguityCleaner::get()->clean($value);
$tmp = str_replace([' ', "\t", "\n"], '', $tmp);
if ($tmp==='') $tmp = null;
return $tmp;
}
|
[
"public",
"function",
"clean",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"tmp",
"=",
"AmbiguityCleaner",
"::",
"get",
"(",
")",
"->",
"clean",
"(",
"$",
"value",
")",
";",
"$",
"tmp",
"=",
"str_replace",
"(",
"[",
"' '",
",",
"\"\\t\"",
",",
"\"\\n\"",
"]",
",",
"''",
",",
"$",
"tmp",
")",
";",
"if",
"(",
"$",
"tmp",
"===",
"''",
")",
"$",
"tmp",
"=",
"null",
";",
"return",
"$",
"tmp",
";",
"}"
] |
Returns a submitted value with all whitespace removed.
@param string|null $value The submitted value.
@return string|null
@since 1.0.0
@api
|
[
"Returns",
"a",
"submitted",
"value",
"with",
"all",
"whitespace",
"removed",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Cleaner/RemoveWhitespaceCleaner.php#L43-L56
|
225,128
|
the-support-group/validation-adaptor
|
src/ValidationAdaptor.php
|
ValidationAdaptor.getMappedMethod
|
public function getMappedMethod($method)
{
// Check if the method called is provided in the mapping.
if (!array_key_exists($method, self::$validatorMapping)) {
throw new Exception(sprintf(
'Mapping for method "%s" not found, make sure it exists in the mapping file.',
$method
));
}
return self::$validatorMapping[$method];
}
|
php
|
public function getMappedMethod($method)
{
// Check if the method called is provided in the mapping.
if (!array_key_exists($method, self::$validatorMapping)) {
throw new Exception(sprintf(
'Mapping for method "%s" not found, make sure it exists in the mapping file.',
$method
));
}
return self::$validatorMapping[$method];
}
|
[
"public",
"function",
"getMappedMethod",
"(",
"$",
"method",
")",
"{",
"// Check if the method called is provided in the mapping.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"method",
",",
"self",
"::",
"$",
"validatorMapping",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Mapping for method \"%s\" not found, make sure it exists in the mapping file.'",
",",
"$",
"method",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"validatorMapping",
"[",
"$",
"method",
"]",
";",
"}"
] |
Get mapped method.
@param string $method The validation method to map.
@return string
|
[
"Get",
"mapped",
"method",
"."
] |
23c2a5d4cd7f1a914b4e32f064e703558f4dd23b
|
https://github.com/the-support-group/validation-adaptor/blob/23c2a5d4cd7f1a914b4e32f064e703558f4dd23b/src/ValidationAdaptor.php#L77-L88
|
225,129
|
UCSLabs/Referenceable
|
ReferenceGeneratorCollection.php
|
ReferenceGeneratorCollection.add
|
public function add(ReferenceGeneratorInterface $generator)
{
$this->generators[] = $generator;
usort($this->generators,array($this,'compareGenerators'));
}
|
php
|
public function add(ReferenceGeneratorInterface $generator)
{
$this->generators[] = $generator;
usort($this->generators,array($this,'compareGenerators'));
}
|
[
"public",
"function",
"add",
"(",
"ReferenceGeneratorInterface",
"$",
"generator",
")",
"{",
"$",
"this",
"->",
"generators",
"[",
"]",
"=",
"$",
"generator",
";",
"usort",
"(",
"$",
"this",
"->",
"generators",
",",
"array",
"(",
"$",
"this",
",",
"'compareGenerators'",
")",
")",
";",
"}"
] |
Adds a generator.
@param string $name The generator name
@param ReferenceGeneratorInterface $generator A ReferenceGeneratorInterface instance
@api
|
[
"Adds",
"a",
"generator",
"."
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorCollection.php#L74-L78
|
225,130
|
UCSLabs/Referenceable
|
ReferenceGeneratorCollection.php
|
ReferenceGeneratorCollection.get
|
public function get($index)
{
if( $index >= count($this->generators) || $index < 0 )
return null;
return $this->generators[$index];
}
|
php
|
public function get($index)
{
if( $index >= count($this->generators) || $index < 0 )
return null;
return $this->generators[$index];
}
|
[
"public",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
">=",
"count",
"(",
"$",
"this",
"->",
"generators",
")",
"||",
"$",
"index",
"<",
"0",
")",
"return",
"null",
";",
"return",
"$",
"this",
"->",
"generators",
"[",
"$",
"index",
"]",
";",
"}"
] |
Gets a generator by name.
@param integer $index get the generator at the given index
@return ReferenceGeneratorInterface|null A ReferenceGeneratorInterface
instance or null when not found
|
[
"Gets",
"a",
"generator",
"by",
"name",
"."
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorCollection.php#L98-L104
|
225,131
|
UCSLabs/Referenceable
|
ReferenceGeneratorCollection.php
|
ReferenceGeneratorCollection.remove
|
public function remove($index)
{
if( $index >= count($this->generators) || $index < 0 )
return;
unset($this->generators[$index]);
$this->generators = array_values($this->generators);
}
|
php
|
public function remove($index)
{
if( $index >= count($this->generators) || $index < 0 )
return;
unset($this->generators[$index]);
$this->generators = array_values($this->generators);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"$",
"index",
">=",
"count",
"(",
"$",
"this",
"->",
"generators",
")",
"||",
"$",
"index",
"<",
"0",
")",
"return",
";",
"unset",
"(",
"$",
"this",
"->",
"generators",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"generators",
"=",
"array_values",
"(",
"$",
"this",
"->",
"generators",
")",
";",
"}"
] |
Removes a generator or an array of generators by name from the collection
@param string|array $name The generator name or an array of generator names
|
[
"Removes",
"a",
"generator",
"or",
"an",
"array",
"of",
"generators",
"by",
"name",
"from",
"the",
"collection"
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorCollection.php#L111-L118
|
225,132
|
UCSLabs/Referenceable
|
ReferenceGeneratorCollection.php
|
ReferenceGeneratorCollection.addCollection
|
public function addCollection(ReferenceGeneratorCollection $collection)
{
// we need to remove all generators with the same names first because
// just replacing them
// would not place the new generator at the end of the merged array
foreach ($collection->all() as $generator) {
$this->generators[] = $generator;
}
usort($this->generators,array($this,'compareGenerators'));
}
|
php
|
public function addCollection(ReferenceGeneratorCollection $collection)
{
// we need to remove all generators with the same names first because
// just replacing them
// would not place the new generator at the end of the merged array
foreach ($collection->all() as $generator) {
$this->generators[] = $generator;
}
usort($this->generators,array($this,'compareGenerators'));
}
|
[
"public",
"function",
"addCollection",
"(",
"ReferenceGeneratorCollection",
"$",
"collection",
")",
"{",
"// we need to remove all generators with the same names first because ",
"// just replacing them",
"// would not place the new generator at the end of the merged array",
"foreach",
"(",
"$",
"collection",
"->",
"all",
"(",
")",
"as",
"$",
"generator",
")",
"{",
"$",
"this",
"->",
"generators",
"[",
"]",
"=",
"$",
"generator",
";",
"}",
"usort",
"(",
"$",
"this",
"->",
"generators",
",",
"array",
"(",
"$",
"this",
",",
"'compareGenerators'",
")",
")",
";",
"}"
] |
Adds a generator collection at the end of the current set by appending all
generators of the added collection.
@param ReferenceGeneratorCollection $collection
A ReferenceGeneratorCollection instance
@api
|
[
"Adds",
"a",
"generator",
"collection",
"at",
"the",
"end",
"of",
"the",
"current",
"set",
"by",
"appending",
"all",
"generators",
"of",
"the",
"added",
"collection",
"."
] |
72cef440197898605237805293109be1e4a79d67
|
https://github.com/UCSLabs/Referenceable/blob/72cef440197898605237805293109be1e4a79d67/ReferenceGeneratorCollection.php#L129-L139
|
225,133
|
yawik/behat
|
src/MailContext.php
|
MailContext.beforeScenario
|
public function beforeScenario(BeforeScenarioScope $scope)
{
$core = $scope->getEnvironment()->getContext(CoreContext::class);
/* @var FileTransport $transport */
$transport = $core->getServiceManager()->get('Core/MailService')->getTransport();
$path = $transport->getOptions()->getPath() . '/*.eml';
foreach (glob($path) as $filename) {
unlink($filename);
}
$this->subjects = $this->fromMails = $this->toMails = array();
}
|
php
|
public function beforeScenario(BeforeScenarioScope $scope)
{
$core = $scope->getEnvironment()->getContext(CoreContext::class);
/* @var FileTransport $transport */
$transport = $core->getServiceManager()->get('Core/MailService')->getTransport();
$path = $transport->getOptions()->getPath() . '/*.eml';
foreach (glob($path) as $filename) {
unlink($filename);
}
$this->subjects = $this->fromMails = $this->toMails = array();
}
|
[
"public",
"function",
"beforeScenario",
"(",
"BeforeScenarioScope",
"$",
"scope",
")",
"{",
"$",
"core",
"=",
"$",
"scope",
"->",
"getEnvironment",
"(",
")",
"->",
"getContext",
"(",
"CoreContext",
"::",
"class",
")",
";",
"/* @var FileTransport $transport */",
"$",
"transport",
"=",
"$",
"core",
"->",
"getServiceManager",
"(",
")",
"->",
"get",
"(",
"'Core/MailService'",
")",
"->",
"getTransport",
"(",
")",
";",
"$",
"path",
"=",
"$",
"transport",
"->",
"getOptions",
"(",
")",
"->",
"getPath",
"(",
")",
".",
"'/*.eml'",
";",
"foreach",
"(",
"glob",
"(",
"$",
"path",
")",
"as",
"$",
"filename",
")",
"{",
"unlink",
"(",
"$",
"filename",
")",
";",
"}",
"$",
"this",
"->",
"subjects",
"=",
"$",
"this",
"->",
"fromMails",
"=",
"$",
"this",
"->",
"toMails",
"=",
"array",
"(",
")",
";",
"}"
] |
Cleans all files before start test
@BeforeScenario @mail
@param BeforeScenarioScope $scope
|
[
"Cleans",
"all",
"files",
"before",
"start",
"test"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/MailContext.php#L47-L58
|
225,134
|
GFG/dto-context
|
src/DTOContext/Context/Base.php
|
Base.prepareExport
|
protected function prepareExport($data)
{
return [
'name' => $this->getName(),
'info' => $this->info,
'hash' => $this->getHash(),
'data_wrapper' => get_class($this->getDatawrapper()),
'data' => $data
];
}
|
php
|
protected function prepareExport($data)
{
return [
'name' => $this->getName(),
'info' => $this->info,
'hash' => $this->getHash(),
'data_wrapper' => get_class($this->getDatawrapper()),
'data' => $data
];
}
|
[
"protected",
"function",
"prepareExport",
"(",
"$",
"data",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'info'",
"=>",
"$",
"this",
"->",
"info",
",",
"'hash'",
"=>",
"$",
"this",
"->",
"getHash",
"(",
")",
",",
"'data_wrapper'",
"=>",
"get_class",
"(",
"$",
"this",
"->",
"getDatawrapper",
"(",
")",
")",
",",
"'data'",
"=>",
"$",
"data",
"]",
";",
"}"
] |
Prepare the info to be exported
@param array
@return array
|
[
"Prepare",
"the",
"info",
"to",
"be",
"exported"
] |
c1a47273d3dc2704bfd3f90c2560726688d54558
|
https://github.com/GFG/dto-context/blob/c1a47273d3dc2704bfd3f90c2560726688d54558/src/DTOContext/Context/Base.php#L188-L197
|
225,135
|
Finesse/MiniDB
|
src/Database.php
|
Database.table
|
public function table($table, string $alias = null): Query
{
return $this->builder()->table($table, $alias);
}
|
php
|
public function table($table, string $alias = null): Query
{
return $this->builder()->table($table, $alias);
}
|
[
"public",
"function",
"table",
"(",
"$",
"table",
",",
"string",
"$",
"alias",
"=",
"null",
")",
":",
"Query",
"{",
"return",
"$",
"this",
"->",
"builder",
"(",
")",
"->",
"table",
"(",
"$",
"table",
",",
"$",
"alias",
")",
";",
"}"
] |
Makes a query builder instance with a selected table.
@param string|\Closure|Query|StatementInterface $table Not prefixed table name without quotes
@param string|null $alias Table alias. Warning! Alias is not allowed in insert, update and delete queries in some
of the DBMSs.
@return Query
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Makes",
"a",
"query",
"builder",
"instance",
"with",
"a",
"selected",
"table",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Database.php#L125-L128
|
225,136
|
Finesse/MiniDB
|
src/Database.php
|
Database.withTablePrefix
|
public function withTablePrefix(string $prefix): self
{
return new static($this->connection, $this->grammar, new TablePrefixer($prefix));
}
|
php
|
public function withTablePrefix(string $prefix): self
{
return new static($this->connection, $this->grammar, new TablePrefixer($prefix));
}
|
[
"public",
"function",
"withTablePrefix",
"(",
"string",
"$",
"prefix",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"grammar",
",",
"new",
"TablePrefixer",
"(",
"$",
"prefix",
")",
")",
";",
"}"
] |
Makes a self copy with the same dependencies instances but with another table prefix.
@param string $prefix Table prefix
@return static
|
[
"Makes",
"a",
"self",
"copy",
"with",
"the",
"same",
"dependencies",
"instances",
"but",
"with",
"another",
"table",
"prefix",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Database.php#L160-L163
|
225,137
|
Finesse/MiniDB
|
src/Database.php
|
Database.withTablesPrefixed
|
public function withTablesPrefixed(string $prefix): self
{
return new static(
$this->connection,
$this->grammar,
new TablePrefixer($prefix.$this->tablePrefixer->tablePrefix)
);
}
|
php
|
public function withTablesPrefixed(string $prefix): self
{
return new static(
$this->connection,
$this->grammar,
new TablePrefixer($prefix.$this->tablePrefixer->tablePrefix)
);
}
|
[
"public",
"function",
"withTablesPrefixed",
"(",
"string",
"$",
"prefix",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"grammar",
",",
"new",
"TablePrefixer",
"(",
"$",
"prefix",
".",
"$",
"this",
"->",
"tablePrefixer",
"->",
"tablePrefix",
")",
")",
";",
"}"
] |
Makes a self copy with the same dependencies instances but with added table prefix.
The table prefix is not replaced, it is prefixed. For example, if an instance table prefix is `demo_`, calling
this method with the argument `test_` will make an instance with `test_demo_` table prefix.
@param string $prefix Table prefix
@return static
|
[
"Makes",
"a",
"self",
"copy",
"with",
"the",
"same",
"dependencies",
"instances",
"but",
"with",
"added",
"table",
"prefix",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Database.php#L174-L181
|
225,138
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerHierarchy.php
|
LoggerHierarchy.isDisabled
|
public function isDisabled(\n2n\log4php\LoggerLevel $level) {
return ($this->threshold->toInt() > $level->toInt());
}
|
php
|
public function isDisabled(\n2n\log4php\LoggerLevel $level) {
return ($this->threshold->toInt() > $level->toInt());
}
|
[
"public",
"function",
"isDisabled",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"$",
"level",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"threshold",
"->",
"toInt",
"(",
")",
">",
"$",
"level",
"->",
"toInt",
"(",
")",
")",
";",
"}"
] |
Returns true if the hierarchy is disabled for given log level and false
otherwise.
@return boolean
|
[
"Returns",
"true",
"if",
"the",
"hierarchy",
"is",
"disabled",
"for",
"given",
"log",
"level",
"and",
"false",
"otherwise",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerHierarchy.php#L177-L179
|
225,139
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerHierarchy.php
|
LoggerHierarchy.resetConfiguration
|
public function resetConfiguration() {
$root = $this->getRootLogger();
$root->setLevel(\n2n\log4php\LoggerLevel::getLevelDebug());
$this->setThreshold(\n2n\log4php\LoggerLevel::getLevelAll());
$this->shutDown();
foreach($this->loggers as $logger) {
$logger->setLevel(null);
$logger->setAdditivity(true);
$logger->removeAllAppenders();
}
$this->rendererMap->reset();
\n2n\log4php\appender\AppenderPool::clear();
}
|
php
|
public function resetConfiguration() {
$root = $this->getRootLogger();
$root->setLevel(\n2n\log4php\LoggerLevel::getLevelDebug());
$this->setThreshold(\n2n\log4php\LoggerLevel::getLevelAll());
$this->shutDown();
foreach($this->loggers as $logger) {
$logger->setLevel(null);
$logger->setAdditivity(true);
$logger->removeAllAppenders();
}
$this->rendererMap->reset();
\n2n\log4php\appender\AppenderPool::clear();
}
|
[
"public",
"function",
"resetConfiguration",
"(",
")",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"getRootLogger",
"(",
")",
";",
"$",
"root",
"->",
"setLevel",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"getLevelDebug",
"(",
")",
")",
";",
"$",
"this",
"->",
"setThreshold",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"getLevelAll",
"(",
")",
")",
";",
"$",
"this",
"->",
"shutDown",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"setLevel",
"(",
"null",
")",
";",
"$",
"logger",
"->",
"setAdditivity",
"(",
"true",
")",
";",
"$",
"logger",
"->",
"removeAllAppenders",
"(",
")",
";",
"}",
"$",
"this",
"->",
"rendererMap",
"->",
"reset",
"(",
")",
";",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"appender",
"\\",
"AppenderPool",
"::",
"clear",
"(",
")",
";",
"}"
] |
Reset all values contained in this hierarchy instance to their
default.
This removes all appenders from all loggers, sets
the level of all non-root loggers to <i>null</i>,
sets their additivity flag to <i>true</i> and sets the level
of the root logger to {@link LOGGER_LEVEL_DEBUG}.
<p>Existing loggers are not removed. They are just reset.
<p>This method should be used sparingly and with care as it will
block all logging until it is completed.</p>
|
[
"Reset",
"all",
"values",
"contained",
"in",
"this",
"hierarchy",
"instance",
"to",
"their",
"default",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerHierarchy.php#L195-L210
|
225,140
|
DrNixx/yii2-onix
|
src/collections/AbstractMap.php
|
AbstractMap.hashKey
|
protected function hashKey($key)
{
if ($key instanceof \DateTime) {
return md5('_' . $key->format('c'));
} elseif (is_object($key)) {
return spl_object_hash($key);
} elseif (false === $key) {
return md5('_false');
} elseif (true === $key) {
return md5('_true');
} elseif (null === $key) {
return md5('_null');
} elseif (is_array($key)) {
array_multisort($key);
return md5(json_encode($key));
} elseif (is_int($key)) {
return md5('_' . $key);
} elseif (is_float($key)) {
return md5('_' . $key);
} else {
return md5(strval($key));
}
}
|
php
|
protected function hashKey($key)
{
if ($key instanceof \DateTime) {
return md5('_' . $key->format('c'));
} elseif (is_object($key)) {
return spl_object_hash($key);
} elseif (false === $key) {
return md5('_false');
} elseif (true === $key) {
return md5('_true');
} elseif (null === $key) {
return md5('_null');
} elseif (is_array($key)) {
array_multisort($key);
return md5(json_encode($key));
} elseif (is_int($key)) {
return md5('_' . $key);
} elseif (is_float($key)) {
return md5('_' . $key);
} else {
return md5(strval($key));
}
}
|
[
"protected",
"function",
"hashKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"key",
"instanceof",
"\\",
"DateTime",
")",
"{",
"return",
"md5",
"(",
"'_'",
".",
"$",
"key",
"->",
"format",
"(",
"'c'",
")",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"key",
")",
")",
"{",
"return",
"spl_object_hash",
"(",
"$",
"key",
")",
";",
"}",
"elseif",
"(",
"false",
"===",
"$",
"key",
")",
"{",
"return",
"md5",
"(",
"'_false'",
")",
";",
"}",
"elseif",
"(",
"true",
"===",
"$",
"key",
")",
"{",
"return",
"md5",
"(",
"'_true'",
")",
";",
"}",
"elseif",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"return",
"md5",
"(",
"'_null'",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"array_multisort",
"(",
"$",
"key",
")",
";",
"return",
"md5",
"(",
"json_encode",
"(",
"$",
"key",
")",
")",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"return",
"md5",
"(",
"'_'",
".",
"$",
"key",
")",
";",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"key",
")",
")",
"{",
"return",
"md5",
"(",
"'_'",
".",
"$",
"key",
")",
";",
"}",
"else",
"{",
"return",
"md5",
"(",
"strval",
"(",
"$",
"key",
")",
")",
";",
"}",
"}"
] |
Hash a key.
@param mixed $key Key to be hashed.
@return string|int Hashed key.
|
[
"Hash",
"a",
"key",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/AbstractMap.php#L65-L87
|
225,141
|
OPCVM360/sdk-php
|
Services/OPCVM360.php
|
Services_OPCVM360.buildQuery
|
public static function buildQuery($queryData)
{
$query = '';
// Loop through all of the $query_data
foreach ($queryData as $key => $value) {
// If the value is an array, we will end up recursing
if (is_array($value)) {
// Loop through the values
foreach ($value as $value2) {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Recurse
$query .= self::buildQuery(array($key => $value2));
}
} else {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Add the key and the urlencoded value (as a string)
$query .= $key . '=' . urlencode((string) $value);
}
}
return $query;
}
|
php
|
public static function buildQuery($queryData)
{
$query = '';
// Loop through all of the $query_data
foreach ($queryData as $key => $value) {
// If the value is an array, we will end up recursing
if (is_array($value)) {
// Loop through the values
foreach ($value as $value2) {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Recurse
$query .= self::buildQuery(array($key => $value2));
}
} else {
// Add an arg_separator if needed
if ($query !== '') {
$query .= '&';
}
// Add the key and the urlencoded value (as a string)
$query .= $key . '=' . urlencode((string) $value);
}
}
return $query;
}
|
[
"public",
"static",
"function",
"buildQuery",
"(",
"$",
"queryData",
")",
"{",
"$",
"query",
"=",
"''",
";",
"// Loop through all of the $query_data",
"foreach",
"(",
"$",
"queryData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// If the value is an array, we will end up recursing",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"// Loop through the values",
"foreach",
"(",
"$",
"value",
"as",
"$",
"value2",
")",
"{",
"// Add an arg_separator if needed",
"if",
"(",
"$",
"query",
"!==",
"''",
")",
"{",
"$",
"query",
".=",
"'&'",
";",
"}",
"// Recurse",
"$",
"query",
".=",
"self",
"::",
"buildQuery",
"(",
"array",
"(",
"$",
"key",
"=>",
"$",
"value2",
")",
")",
";",
"}",
"}",
"else",
"{",
"// Add an arg_separator if needed",
"if",
"(",
"$",
"query",
"!==",
"''",
")",
"{",
"$",
"query",
".=",
"'&'",
";",
"}",
"// Add the key and the urlencoded value (as a string)",
"$",
"query",
".=",
"$",
"key",
".",
"'='",
".",
"urlencode",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"query",
";",
"}"
] |
Build a query string from query data
:param array $queryData: An associative array of keys and values. The
values can be a simple type or a list, in which case the list is
converted to multiple query parameters with the same key.
:param string $queryStringStyle: Determine how to build the url
- strict: Build a standards compliant query string without braces (can be hacked by using braces in key)
- php: Build a PHP compatible query string with nested array syntax
:return: The encoded query string
|
[
"Build",
"a",
"query",
"string",
"from",
"query",
"data"
] |
f21c0eec3a917c31a73a66e32978a1179a864549
|
https://github.com/OPCVM360/sdk-php/blob/f21c0eec3a917c31a73a66e32978a1179a864549/Services/OPCVM360.php#L83-L110
|
225,142
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php
|
XmlAbstractCommand.process
|
protected function process()
{
// Uses the response object by default
$this->result = $this->getRequest()->getResponse();
$contentType = $this->result->getContentType();
if (stripos($contentType, 'xml') === false) {
throw new \Exception('The Response is not in a valid XML Content Type.');
}
$body = trim($this->result->getBody(true));
$this->result = new EncodingResponse($body);
$this->handleResponseErrors($this->result);
}
|
php
|
protected function process()
{
// Uses the response object by default
$this->result = $this->getRequest()->getResponse();
$contentType = $this->result->getContentType();
if (stripos($contentType, 'xml') === false) {
throw new \Exception('The Response is not in a valid XML Content Type.');
}
$body = trim($this->result->getBody(true));
$this->result = new EncodingResponse($body);
$this->handleResponseErrors($this->result);
}
|
[
"protected",
"function",
"process",
"(",
")",
"{",
"// Uses the response object by default",
"$",
"this",
"->",
"result",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getResponse",
"(",
")",
";",
"$",
"contentType",
"=",
"$",
"this",
"->",
"result",
"->",
"getContentType",
"(",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"contentType",
",",
"'xml'",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The Response is not in a valid XML Content Type.'",
")",
";",
"}",
"$",
"body",
"=",
"trim",
"(",
"$",
"this",
"->",
"result",
"->",
"getBody",
"(",
"true",
")",
")",
";",
"$",
"this",
"->",
"result",
"=",
"new",
"EncodingResponse",
"(",
"$",
"body",
")",
";",
"$",
"this",
"->",
"handleResponseErrors",
"(",
"$",
"this",
"->",
"result",
")",
";",
"}"
] |
Create the result of the command after the request has been completed.
We expect the response to be an XML, so this method converts the repons
to a SimpleXMLElement object. Also, exceptions are thrown accordingly.
|
[
"Create",
"the",
"result",
"of",
"the",
"command",
"after",
"the",
"request",
"has",
"been",
"completed",
".",
"We",
"expect",
"the",
"response",
"to",
"be",
"an",
"XML",
"so",
"this",
"method",
"converts",
"the",
"repons",
"to",
"a",
"SimpleXMLElement",
"object",
".",
"Also",
"exceptions",
"are",
"thrown",
"accordingly",
"."
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php#L29-L44
|
225,143
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php
|
XmlAbstractCommand.build
|
protected function build()
{
$this->rawXml = $this->buildXML();
$this->client->setDefaultOption('headers', array(
'Content-Type' => 'application/x-www-form-urlencoded'
));
$this->request = $this->client->post(null, null, array(
"xml" => ($this->rawXml->saveXML())
));
}
|
php
|
protected function build()
{
$this->rawXml = $this->buildXML();
$this->client->setDefaultOption('headers', array(
'Content-Type' => 'application/x-www-form-urlencoded'
));
$this->request = $this->client->post(null, null, array(
"xml" => ($this->rawXml->saveXML())
));
}
|
[
"protected",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"rawXml",
"=",
"$",
"this",
"->",
"buildXML",
"(",
")",
";",
"$",
"this",
"->",
"client",
"->",
"setDefaultOption",
"(",
"'headers'",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'application/x-www-form-urlencoded'",
")",
")",
";",
"$",
"this",
"->",
"request",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"null",
",",
"null",
",",
"array",
"(",
"\"xml\"",
"=>",
"(",
"$",
"this",
"->",
"rawXml",
"->",
"saveXML",
"(",
")",
")",
")",
")",
";",
"}"
] |
Prepares the request to the API.
|
[
"Prepares",
"the",
"request",
"to",
"the",
"API",
"."
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php#L49-L60
|
225,144
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php
|
XmlAbstractCommand.buildXML
|
public function buildXML()
{
$xml = new EncodingRequest();
$request = $xml->setDomQuery($this->client->getConfig('userid'), $this->client->getConfig('userkey'), $this->getName());
foreach ($this->getOperation()->getParams() as $name => $arg) {
if ($this->get($name) === true) {
$request->appendChild($xml->createElement($name));
} else {
if (! is_null($this->get($name)) && $this->get($name) !== false) {
if (! is_array($this->get($name))) {
// Non Array Type - String, Integer, etc ..
$request->appendChild($xml->createElement($name, $this->get($name)));
} else {
if ($name == "source") {
// Build "Flat" Array to XML
foreach ($this->get($name) as $key => $value) {
$request->appendChild($xml->createElement($name, $value));
}
} else {
// Build Array to XML
$arrayRoot = $request->appendChild($xml->createElement($name));
foreach ($this->get($name) as $key => $value) {
if (! is_array($value)) {
$arrayRoot->appendChild($xml->createElement($key, $value));
} else {
if ($key == "destination") {
// Build "Flat" Array to XML in a sub Element
foreach ($value as $subValue) {
$arrayRoot->appendChild($xml->createElement($key, $subValue));
}
} else {
$arraySubRoot = $arrayRoot->appendChild($xml->createElement($key));
foreach ($value as $subKey => $subValue) {
$arraySubRoot->appendChild($xml->createElement($subKey, $subValue));
}
}
}
}
}
}
}
}
}
return $xml;
}
|
php
|
public function buildXML()
{
$xml = new EncodingRequest();
$request = $xml->setDomQuery($this->client->getConfig('userid'), $this->client->getConfig('userkey'), $this->getName());
foreach ($this->getOperation()->getParams() as $name => $arg) {
if ($this->get($name) === true) {
$request->appendChild($xml->createElement($name));
} else {
if (! is_null($this->get($name)) && $this->get($name) !== false) {
if (! is_array($this->get($name))) {
// Non Array Type - String, Integer, etc ..
$request->appendChild($xml->createElement($name, $this->get($name)));
} else {
if ($name == "source") {
// Build "Flat" Array to XML
foreach ($this->get($name) as $key => $value) {
$request->appendChild($xml->createElement($name, $value));
}
} else {
// Build Array to XML
$arrayRoot = $request->appendChild($xml->createElement($name));
foreach ($this->get($name) as $key => $value) {
if (! is_array($value)) {
$arrayRoot->appendChild($xml->createElement($key, $value));
} else {
if ($key == "destination") {
// Build "Flat" Array to XML in a sub Element
foreach ($value as $subValue) {
$arrayRoot->appendChild($xml->createElement($key, $subValue));
}
} else {
$arraySubRoot = $arrayRoot->appendChild($xml->createElement($key));
foreach ($value as $subKey => $subValue) {
$arraySubRoot->appendChild($xml->createElement($subKey, $subValue));
}
}
}
}
}
}
}
}
}
return $xml;
}
|
[
"public",
"function",
"buildXML",
"(",
")",
"{",
"$",
"xml",
"=",
"new",
"EncodingRequest",
"(",
")",
";",
"$",
"request",
"=",
"$",
"xml",
"->",
"setDomQuery",
"(",
"$",
"this",
"->",
"client",
"->",
"getConfig",
"(",
"'userid'",
")",
",",
"$",
"this",
"->",
"client",
"->",
"getConfig",
"(",
"'userkey'",
")",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOperation",
"(",
")",
"->",
"getParams",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
"===",
"true",
")",
"{",
"$",
"request",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"name",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
")",
"&&",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
")",
")",
"{",
"// Non Array Type - String, Integer, etc ..",
"$",
"request",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"name",
"==",
"\"source\"",
")",
"{",
"// Build \"Flat\" Array to XML",
"foreach",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"request",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"name",
",",
"$",
"value",
")",
")",
";",
"}",
"}",
"else",
"{",
"// Build Array to XML",
"$",
"arrayRoot",
"=",
"$",
"request",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"name",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"arrayRoot",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"key",
"==",
"\"destination\"",
")",
"{",
"// Build \"Flat\" Array to XML in a sub Element",
"foreach",
"(",
"$",
"value",
"as",
"$",
"subValue",
")",
"{",
"$",
"arrayRoot",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"key",
",",
"$",
"subValue",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"arraySubRoot",
"=",
"$",
"arrayRoot",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"key",
")",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"subKey",
"=>",
"$",
"subValue",
")",
"{",
"$",
"arraySubRoot",
"->",
"appendChild",
"(",
"$",
"xml",
"->",
"createElement",
"(",
"$",
"subKey",
",",
"$",
"subValue",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"xml",
";",
"}"
] |
Builds the XML for the request body.
@return EncodingRequest XML in DOMDocument format
|
[
"Builds",
"the",
"XML",
"for",
"the",
"request",
"body",
"."
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php#L67-L123
|
225,145
|
svilborg/guzzle-encoding-com
|
src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php
|
XmlAbstractCommand.getResponseBody
|
public function getResponseBody($encodeEntities = true)
{
$body = (string) $this->getResponse()->getBody();
if ($encodeEntities) {
return htmlentities($body);
}
return $body;
}
|
php
|
public function getResponseBody($encodeEntities = true)
{
$body = (string) $this->getResponse()->getBody();
if ($encodeEntities) {
return htmlentities($body);
}
return $body;
}
|
[
"public",
"function",
"getResponseBody",
"(",
"$",
"encodeEntities",
"=",
"true",
")",
"{",
"$",
"body",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"$",
"encodeEntities",
")",
"{",
"return",
"htmlentities",
"(",
"$",
"body",
")",
";",
"}",
"return",
"$",
"body",
";",
"}"
] |
Returns the response body, by default with
encoded HTML entities as string.
@param boolean $encodeEntities
Encode the HTML entities on the body
@return string Response body
|
[
"Returns",
"the",
"response",
"body",
"by",
"default",
"with",
"encoded",
"HTML",
"entities",
"as",
"string",
"."
] |
0f42505e85013d1753502c0f3d0aa8955fb24cce
|
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Command/XmlAbstractCommand.php#L170-L179
|
225,146
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerConfigurable.php
|
LoggerConfigurable.setBoolean
|
protected function setBoolean($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toBooleanEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
}
}
|
php
|
protected function setBoolean($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toBooleanEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.");
}
}
|
[
"protected",
"function",
"setBoolean",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toBooleanEx",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid value given for '$property' property: [$value]. Expected a boolean value. Property not changed.\"",
")",
";",
"}",
"}"
] |
Setter function for boolean type.
|
[
"Setter",
"function",
"for",
"boolean",
"type",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerConfigurable.php#L34-L41
|
225,147
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerConfigurable.php
|
LoggerConfigurable.setLevel
|
protected function setLevel($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toLevelEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
}
}
|
php
|
protected function setLevel($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toLevelEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.");
}
}
|
[
"protected",
"function",
"setLevel",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toLevelEx",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid value given for '$property' property: [$value]. Expected a level value. Property not changed.\"",
")",
";",
"}",
"}"
] |
Setter function for LoggerLevel values.
|
[
"Setter",
"function",
"for",
"LoggerLevel",
"values",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerConfigurable.php#L54-L61
|
225,148
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerConfigurable.php
|
LoggerConfigurable.setFileSize
|
protected function setFileSize($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toFileSizeEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
}
}
|
php
|
protected function setFileSize($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toFileSizeEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.");
}
}
|
[
"protected",
"function",
"setFileSize",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toFileSizeEx",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid value given for '$property' property: [$value]. Expected a file size value. Property not changed.\"",
")",
";",
"}",
"}"
] |
Setter for file size.
|
[
"Setter",
"for",
"file",
"size",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerConfigurable.php#L74-L81
|
225,149
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerConfigurable.php
|
LoggerConfigurable.setNumeric
|
protected function setNumeric($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toNumericEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
}
}
|
php
|
protected function setNumeric($property, $value) {
try {
$this->$property = \n2n\log4php\option\OptionConverter::toNumericEx($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.");
}
}
|
[
"protected",
"function",
"setNumeric",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toNumericEx",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid value given for '$property' property: [$value]. Expected a number. Property not changed.\"",
")",
";",
"}",
"}"
] |
Setter function for numeric type.
|
[
"Setter",
"function",
"for",
"numeric",
"type",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerConfigurable.php#L84-L91
|
225,150
|
n2n/n2n-log4php
|
src/app/n2n/log4php/LoggerConfigurable.php
|
LoggerConfigurable.setString
|
protected function setString($property, $value, $nullable = false) {
if ($value === null) {
if($nullable) {
$this->$property= null;
} else {
$this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
}
} else {
try {
$value = \n2n\log4php\option\OptionConverter::toStringEx($value);
$this->$property = \n2n\log4php\option\OptionConverter::substConstants($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
}
}
}
|
php
|
protected function setString($property, $value, $nullable = false) {
if ($value === null) {
if($nullable) {
$this->$property= null;
} else {
$this->warn("Null value given for '$property' property. Expected a string. Property not changed.");
}
} else {
try {
$value = \n2n\log4php\option\OptionConverter::toStringEx($value);
$this->$property = \n2n\log4php\option\OptionConverter::substConstants($value);
} catch (\Exception $ex) {
$value = var_export($value, true);
$this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
}
}
}
|
[
"protected",
"function",
"setString",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"nullable",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"nullable",
")",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Null value given for '$property' property. Expected a string. Property not changed.\"",
")",
";",
"}",
"}",
"else",
"{",
"try",
"{",
"$",
"value",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toStringEx",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"$",
"property",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"substConstants",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"value",
"=",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.\"",
")",
";",
"}",
"}",
"}"
] |
Setter function for string type.
|
[
"Setter",
"function",
"for",
"string",
"type",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/LoggerConfigurable.php#L94-L110
|
225,151
|
cmsgears/module-forms
|
common/models/forms/GenericForm.php
|
GenericForm.processFormSubmit
|
public function processFormSubmit( $form ) {
$date = DateUtil::getDateTime();
$attributes = parent::getFormAttributes();
$fields = $attributes[ 'fields' ];
$attribs = [];
$user = Yii::$app->user->getIdentity();
$formSubmit = new FormSubmit();
$formSubmit->formId = $form->id;
$formSubmit->submittedAt = $date;
if( isset( $user ) ) {
$formSubmit->submittedBy = $user->id;
}
// Collect fields to save in json format
foreach ( $fields as $field ) {
$fieldName = $field->name;
// Convert CheckBox array to csv
if( $field->isCheckboxGroup() ) {
$this->$fieldName = join( ",", $this->$fieldName );
}
if( $field->compress ) {
$attribs[ $field->name ] = $this->$fieldName;
}
}
$formSubmit->data = json_encode( $attribs );
// Create/Update form submit
if( $form->uniqueSubmit ) {
// Find existing form submit
$existingFormSubmit = Yii::$app->factory->get( 'formSubmitService' )->findFirstByFormIdSubmittedBy( $formSubmit->formId, $formSubmit->submittedBy );
if( isset( $existingFormSubmit ) ) {
// Over write existing submit
if( $form->updateSubmit ) {
// update form submit
$existingFormSubmit->submittedAt = $formSubmit->submittedAt;
$existingFormSubmit->update();
$formSubmit = $existingFormSubmit;
}
// Throw error
else {
throw new ForbiddenHttpException( Yii::$app->coreMessage->getMessage( FormsGlobal::ERROR_RE_SUBMIT ) );
}
}
else {
// save form submit
$formSubmit->save();
}
}
else {
// save form submit
$formSubmit->save();
}
// Create/Update form submit fields
if( $formSubmit->id > 0 ) {
// Save Form Fields
foreach ( $fields as $field ) {
$fieldName = $field->name;
if( !$field->compress ) {
$formSubmitField = Yii::$app->factory->get( 'formSubmitFieldService' )->findByName( $formSubmit->id, $fieldName );
if( isset( $formSubmitField ) ) {
$formSubmitField->value = $this->$fieldName;
$formSubmitField->update();
}
else {
$formSubmitField = new FormSubmitField();
$formSubmitField->formSubmitId = $formSubmit->id;
$formSubmitField->name = $field->name;
$fieldName = $field->name;
$formSubmitField->value = $this->$fieldName;
$formSubmitField->save();
}
}
}
}
return $formSubmit;
}
|
php
|
public function processFormSubmit( $form ) {
$date = DateUtil::getDateTime();
$attributes = parent::getFormAttributes();
$fields = $attributes[ 'fields' ];
$attribs = [];
$user = Yii::$app->user->getIdentity();
$formSubmit = new FormSubmit();
$formSubmit->formId = $form->id;
$formSubmit->submittedAt = $date;
if( isset( $user ) ) {
$formSubmit->submittedBy = $user->id;
}
// Collect fields to save in json format
foreach ( $fields as $field ) {
$fieldName = $field->name;
// Convert CheckBox array to csv
if( $field->isCheckboxGroup() ) {
$this->$fieldName = join( ",", $this->$fieldName );
}
if( $field->compress ) {
$attribs[ $field->name ] = $this->$fieldName;
}
}
$formSubmit->data = json_encode( $attribs );
// Create/Update form submit
if( $form->uniqueSubmit ) {
// Find existing form submit
$existingFormSubmit = Yii::$app->factory->get( 'formSubmitService' )->findFirstByFormIdSubmittedBy( $formSubmit->formId, $formSubmit->submittedBy );
if( isset( $existingFormSubmit ) ) {
// Over write existing submit
if( $form->updateSubmit ) {
// update form submit
$existingFormSubmit->submittedAt = $formSubmit->submittedAt;
$existingFormSubmit->update();
$formSubmit = $existingFormSubmit;
}
// Throw error
else {
throw new ForbiddenHttpException( Yii::$app->coreMessage->getMessage( FormsGlobal::ERROR_RE_SUBMIT ) );
}
}
else {
// save form submit
$formSubmit->save();
}
}
else {
// save form submit
$formSubmit->save();
}
// Create/Update form submit fields
if( $formSubmit->id > 0 ) {
// Save Form Fields
foreach ( $fields as $field ) {
$fieldName = $field->name;
if( !$field->compress ) {
$formSubmitField = Yii::$app->factory->get( 'formSubmitFieldService' )->findByName( $formSubmit->id, $fieldName );
if( isset( $formSubmitField ) ) {
$formSubmitField->value = $this->$fieldName;
$formSubmitField->update();
}
else {
$formSubmitField = new FormSubmitField();
$formSubmitField->formSubmitId = $formSubmit->id;
$formSubmitField->name = $field->name;
$fieldName = $field->name;
$formSubmitField->value = $this->$fieldName;
$formSubmitField->save();
}
}
}
}
return $formSubmit;
}
|
[
"public",
"function",
"processFormSubmit",
"(",
"$",
"form",
")",
"{",
"$",
"date",
"=",
"DateUtil",
"::",
"getDateTime",
"(",
")",
";",
"$",
"attributes",
"=",
"parent",
"::",
"getFormAttributes",
"(",
")",
";",
"$",
"fields",
"=",
"$",
"attributes",
"[",
"'fields'",
"]",
";",
"$",
"attribs",
"=",
"[",
"]",
";",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"getIdentity",
"(",
")",
";",
"$",
"formSubmit",
"=",
"new",
"FormSubmit",
"(",
")",
";",
"$",
"formSubmit",
"->",
"formId",
"=",
"$",
"form",
"->",
"id",
";",
"$",
"formSubmit",
"->",
"submittedAt",
"=",
"$",
"date",
";",
"if",
"(",
"isset",
"(",
"$",
"user",
")",
")",
"{",
"$",
"formSubmit",
"->",
"submittedBy",
"=",
"$",
"user",
"->",
"id",
";",
"}",
"// Collect fields to save in json format",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"$",
"field",
"->",
"name",
";",
"// Convert CheckBox array to csv",
"if",
"(",
"$",
"field",
"->",
"isCheckboxGroup",
"(",
")",
")",
"{",
"$",
"this",
"->",
"$",
"fieldName",
"=",
"join",
"(",
"\",\"",
",",
"$",
"this",
"->",
"$",
"fieldName",
")",
";",
"}",
"if",
"(",
"$",
"field",
"->",
"compress",
")",
"{",
"$",
"attribs",
"[",
"$",
"field",
"->",
"name",
"]",
"=",
"$",
"this",
"->",
"$",
"fieldName",
";",
"}",
"}",
"$",
"formSubmit",
"->",
"data",
"=",
"json_encode",
"(",
"$",
"attribs",
")",
";",
"// Create/Update form submit",
"if",
"(",
"$",
"form",
"->",
"uniqueSubmit",
")",
"{",
"// Find existing form submit",
"$",
"existingFormSubmit",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"get",
"(",
"'formSubmitService'",
")",
"->",
"findFirstByFormIdSubmittedBy",
"(",
"$",
"formSubmit",
"->",
"formId",
",",
"$",
"formSubmit",
"->",
"submittedBy",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"existingFormSubmit",
")",
")",
"{",
"// Over write existing submit",
"if",
"(",
"$",
"form",
"->",
"updateSubmit",
")",
"{",
"// update form submit",
"$",
"existingFormSubmit",
"->",
"submittedAt",
"=",
"$",
"formSubmit",
"->",
"submittedAt",
";",
"$",
"existingFormSubmit",
"->",
"update",
"(",
")",
";",
"$",
"formSubmit",
"=",
"$",
"existingFormSubmit",
";",
"}",
"// Throw error",
"else",
"{",
"throw",
"new",
"ForbiddenHttpException",
"(",
"Yii",
"::",
"$",
"app",
"->",
"coreMessage",
"->",
"getMessage",
"(",
"FormsGlobal",
"::",
"ERROR_RE_SUBMIT",
")",
")",
";",
"}",
"}",
"else",
"{",
"// save form submit",
"$",
"formSubmit",
"->",
"save",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// save form submit",
"$",
"formSubmit",
"->",
"save",
"(",
")",
";",
"}",
"// Create/Update form submit fields",
"if",
"(",
"$",
"formSubmit",
"->",
"id",
">",
"0",
")",
"{",
"// Save Form Fields",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"$",
"field",
"->",
"name",
";",
"if",
"(",
"!",
"$",
"field",
"->",
"compress",
")",
"{",
"$",
"formSubmitField",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"get",
"(",
"'formSubmitFieldService'",
")",
"->",
"findByName",
"(",
"$",
"formSubmit",
"->",
"id",
",",
"$",
"fieldName",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"formSubmitField",
")",
")",
"{",
"$",
"formSubmitField",
"->",
"value",
"=",
"$",
"this",
"->",
"$",
"fieldName",
";",
"$",
"formSubmitField",
"->",
"update",
"(",
")",
";",
"}",
"else",
"{",
"$",
"formSubmitField",
"=",
"new",
"FormSubmitField",
"(",
")",
";",
"$",
"formSubmitField",
"->",
"formSubmitId",
"=",
"$",
"formSubmit",
"->",
"id",
";",
"$",
"formSubmitField",
"->",
"name",
"=",
"$",
"field",
"->",
"name",
";",
"$",
"fieldName",
"=",
"$",
"field",
"->",
"name",
";",
"$",
"formSubmitField",
"->",
"value",
"=",
"$",
"this",
"->",
"$",
"fieldName",
";",
"$",
"formSubmitField",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"formSubmit",
";",
"}"
] |
Process the submitted form and save all the form fields except captcha field.
@throws \yii\web\ForbiddenHttpException
@param \cmsgears\core\common\models\resources\Form $form
@return void
|
[
"Process",
"the",
"submitted",
"form",
"and",
"save",
"all",
"the",
"form",
"fields",
"except",
"captcha",
"field",
"."
] |
84cbb26e8ecb945410bb2604b84440d5ed841308
|
https://github.com/cmsgears/module-forms/blob/84cbb26e8ecb945410bb2604b84440d5ed841308/common/models/forms/GenericForm.php#L77-L186
|
225,152
|
Positibe/CoreBundle
|
Repository/FilterRepository.php
|
FilterRepository.filterLike
|
public static function filterLike(QueryBuilder $queryBuilder, &$criteria, $field, $alias = 'o')
{
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
$queryBuilder->andWhere(sprintf('%s.%s LIKE :%s', $alias, $field, $field))->setParameter(
$field,
'%'.$criteria[$field].'%'
);
}
unset($criteria[$field]);
}
return $criteria;
}
|
php
|
public static function filterLike(QueryBuilder $queryBuilder, &$criteria, $field, $alias = 'o')
{
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
$queryBuilder->andWhere(sprintf('%s.%s LIKE :%s', $alias, $field, $field))->setParameter(
$field,
'%'.$criteria[$field].'%'
);
}
unset($criteria[$field]);
}
return $criteria;
}
|
[
"public",
"static",
"function",
"filterLike",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"&",
"$",
"criteria",
",",
"$",
"field",
",",
"$",
"alias",
"=",
"'o'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"sprintf",
"(",
"'%s.%s LIKE :%s'",
",",
"$",
"alias",
",",
"$",
"field",
",",
"$",
"field",
")",
")",
"->",
"setParameter",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"criteria",
"[",
"$",
"field",
"]",
".",
"'%'",
")",
";",
"}",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Filter a field with LIKE sql function
@param QueryBuilder $queryBuilder
@param $criteria
@param $field
@param string $alias
@return mixed
|
[
"Filter",
"a",
"field",
"with",
"LIKE",
"sql",
"function"
] |
b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54
|
https://github.com/Positibe/CoreBundle/blob/b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54/Repository/FilterRepository.php#L33-L46
|
225,153
|
Positibe/CoreBundle
|
Repository/FilterRepository.php
|
FilterRepository.filterEnumByName
|
public static function filterEnumByName(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$enumTypeName,
$isJoined = false,
$alias = 'o'
) {
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
if (!$isJoined) {
$queryBuilder->join(sprintf('%s.%s', $alias, $field), 'enum')->join('enum.type', 'enumType');
}
$queryBuilder
->andWhere('enumType.name = :enumType')
->andWhere(sprintf('enum.name LIKE :%s', $field))
->setParameter($field, '%'.$criteria[$field].'%')
->setParameter('enumType', $enumTypeName);
}
unset($criteria[$field]);
}
return $criteria;
}
|
php
|
public static function filterEnumByName(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$enumTypeName,
$isJoined = false,
$alias = 'o'
) {
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
if (!$isJoined) {
$queryBuilder->join(sprintf('%s.%s', $alias, $field), 'enum')->join('enum.type', 'enumType');
}
$queryBuilder
->andWhere('enumType.name = :enumType')
->andWhere(sprintf('enum.name LIKE :%s', $field))
->setParameter($field, '%'.$criteria[$field].'%')
->setParameter('enumType', $enumTypeName);
}
unset($criteria[$field]);
}
return $criteria;
}
|
[
"public",
"static",
"function",
"filterEnumByName",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"&",
"$",
"criteria",
",",
"$",
"field",
",",
"$",
"enumTypeName",
",",
"$",
"isJoined",
"=",
"false",
",",
"$",
"alias",
"=",
"'o'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"isJoined",
")",
"{",
"$",
"queryBuilder",
"->",
"join",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"field",
")",
",",
"'enum'",
")",
"->",
"join",
"(",
"'enum.type'",
",",
"'enumType'",
")",
";",
"}",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'enumType.name = :enumType'",
")",
"->",
"andWhere",
"(",
"sprintf",
"(",
"'enum.name LIKE :%s'",
",",
"$",
"field",
")",
")",
"->",
"setParameter",
"(",
"$",
"field",
",",
"'%'",
".",
"$",
"criteria",
"[",
"$",
"field",
"]",
".",
"'%'",
")",
"->",
"setParameter",
"(",
"'enumType'",
",",
"$",
"enumTypeName",
")",
";",
"}",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Filter an enumerator field from PositibeEnumBundle
@param QueryBuilder $queryBuilder
@param $criteria
@param $field
@param $enumTypeName
@param bool|false $isJoined
@param string $alias
@return mixed
|
[
"Filter",
"an",
"enumerator",
"field",
"from",
"PositibeEnumBundle"
] |
b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54
|
https://github.com/Positibe/CoreBundle/blob/b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54/Repository/FilterRepository.php#L95-L118
|
225,154
|
Positibe/CoreBundle
|
Repository/FilterRepository.php
|
FilterRepository.filterRangeDate
|
public static function filterRangeDate(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$fieldFrom,
$fieldTo,
$alias = 'o'
) {
if (isset($criteria[$fieldFrom]) || isset($criteria[$fieldTo]) && $criteria[$fieldTo] != '') {
if (!empty($criteria[$fieldFrom])) {
$from = $criteria[$fieldFrom].' 00:00:00';
$queryBuilder
->andWhere($queryBuilder->expr()->gte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldFrom)))
->setParameter($fieldFrom, \DateTime::createFromFormat('d/m/Y H:i:s', $from));
}
unset($criteria[$fieldFrom]);
if (!empty($criteria[$fieldTo])) {
$to = $criteria[$fieldTo].' 23:59:59';
$queryBuilder
->andWhere($queryBuilder->expr()->lte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldTo)))
->setParameter($fieldTo, \DateTime::createFromFormat('d/m/Y H:i:s', $to));
}
unset($criteria[$fieldTo]);
}
return $criteria;
}
|
php
|
public static function filterRangeDate(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$fieldFrom,
$fieldTo,
$alias = 'o'
) {
if (isset($criteria[$fieldFrom]) || isset($criteria[$fieldTo]) && $criteria[$fieldTo] != '') {
if (!empty($criteria[$fieldFrom])) {
$from = $criteria[$fieldFrom].' 00:00:00';
$queryBuilder
->andWhere($queryBuilder->expr()->gte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldFrom)))
->setParameter($fieldFrom, \DateTime::createFromFormat('d/m/Y H:i:s', $from));
}
unset($criteria[$fieldFrom]);
if (!empty($criteria[$fieldTo])) {
$to = $criteria[$fieldTo].' 23:59:59';
$queryBuilder
->andWhere($queryBuilder->expr()->lte(sprintf('%s.%s', $alias, $field), sprintf(':%s', $fieldTo)))
->setParameter($fieldTo, \DateTime::createFromFormat('d/m/Y H:i:s', $to));
}
unset($criteria[$fieldTo]);
}
return $criteria;
}
|
[
"public",
"static",
"function",
"filterRangeDate",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"&",
"$",
"criteria",
",",
"$",
"field",
",",
"$",
"fieldFrom",
",",
"$",
"fieldTo",
",",
"$",
"alias",
"=",
"'o'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"criteria",
"[",
"$",
"fieldFrom",
"]",
")",
"||",
"isset",
"(",
"$",
"criteria",
"[",
"$",
"fieldTo",
"]",
")",
"&&",
"$",
"criteria",
"[",
"$",
"fieldTo",
"]",
"!=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"$",
"fieldFrom",
"]",
")",
")",
"{",
"$",
"from",
"=",
"$",
"criteria",
"[",
"$",
"fieldFrom",
"]",
".",
"' 00:00:00'",
";",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"gte",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"field",
")",
",",
"sprintf",
"(",
"':%s'",
",",
"$",
"fieldFrom",
")",
")",
")",
"->",
"setParameter",
"(",
"$",
"fieldFrom",
",",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'d/m/Y H:i:s'",
",",
"$",
"from",
")",
")",
";",
"}",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"fieldFrom",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"$",
"fieldTo",
"]",
")",
")",
"{",
"$",
"to",
"=",
"$",
"criteria",
"[",
"$",
"fieldTo",
"]",
".",
"' 23:59:59'",
";",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"field",
")",
",",
"sprintf",
"(",
"':%s'",
",",
"$",
"fieldTo",
")",
")",
")",
"->",
"setParameter",
"(",
"$",
"fieldTo",
",",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'d/m/Y H:i:s'",
",",
"$",
"to",
")",
")",
";",
"}",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"fieldTo",
"]",
")",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Filter a datetime field by a range
@param QueryBuilder $queryBuilder
@param $criteria
@param $field
@param $fieldFrom
@param $fieldTo
@param string $alias
@return mixed
|
[
"Filter",
"a",
"datetime",
"field",
"by",
"a",
"range"
] |
b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54
|
https://github.com/Positibe/CoreBundle/blob/b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54/Repository/FilterRepository.php#L131-L157
|
225,155
|
Positibe/CoreBundle
|
Repository/FilterRepository.php
|
FilterRepository.filterToOneField
|
public static function filterToOneField(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$toOneField,
$isJoined = false,
$alias = 'o',
$aliasField = null
) {
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
if (!$isJoined) {
$queryBuilder
->join(sprintf('%s.%s', $alias, $toOneField), $toOneField);
}
$queryBuilder
->andWhere(sprintf('%s.%s LIKE :%s', $toOneField, $aliasField ?: $field, $toOneField.'_'.$field))
->setParameter($toOneField.'_'.$field, '%'.$criteria[$field].'%');
}
unset($criteria[$field]);
}
return $criteria;
}
|
php
|
public static function filterToOneField(
QueryBuilder $queryBuilder,
&$criteria,
$field,
$toOneField,
$isJoined = false,
$alias = 'o',
$aliasField = null
) {
if (isset($criteria[$field])) {
if (!empty($criteria[$field])) {
if (!$isJoined) {
$queryBuilder
->join(sprintf('%s.%s', $alias, $toOneField), $toOneField);
}
$queryBuilder
->andWhere(sprintf('%s.%s LIKE :%s', $toOneField, $aliasField ?: $field, $toOneField.'_'.$field))
->setParameter($toOneField.'_'.$field, '%'.$criteria[$field].'%');
}
unset($criteria[$field]);
}
return $criteria;
}
|
[
"public",
"static",
"function",
"filterToOneField",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"&",
"$",
"criteria",
",",
"$",
"field",
",",
"$",
"toOneField",
",",
"$",
"isJoined",
"=",
"false",
",",
"$",
"alias",
"=",
"'o'",
",",
"$",
"aliasField",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"isJoined",
")",
"{",
"$",
"queryBuilder",
"->",
"join",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"toOneField",
")",
",",
"$",
"toOneField",
")",
";",
"}",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"sprintf",
"(",
"'%s.%s LIKE :%s'",
",",
"$",
"toOneField",
",",
"$",
"aliasField",
"?",
":",
"$",
"field",
",",
"$",
"toOneField",
".",
"'_'",
".",
"$",
"field",
")",
")",
"->",
"setParameter",
"(",
"$",
"toOneField",
".",
"'_'",
".",
"$",
"field",
",",
"'%'",
".",
"$",
"criteria",
"[",
"$",
"field",
"]",
".",
"'%'",
")",
";",
"}",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"field",
"]",
")",
";",
"}",
"return",
"$",
"criteria",
";",
"}"
] |
Filter a field thar has its to one relation with LIKE %x%
e.g.
FilterRepository::filterToOneField($queryBuilder, $criteria, 'name', 'collection');
FilterRepository::filterToOneField($queryBuilder, $criteria, 'name', 'collection', true, 'col'); //If collection was already joined
FilterRepository::filterToOneField($queryBuilder, $criteria, 'collection_name', 'collection', false, 'o', 'name'); //If you use diferent filter key
@param QueryBuilder $queryBuilder
@param $criteria
@param $field
@param $toOneField
@param bool|false $isJoined
@param string $alias
@param null $aliasField
@return mixed
|
[
"Filter",
"a",
"field",
"thar",
"has",
"its",
"to",
"one",
"relation",
"with",
"LIKE",
"%x%"
] |
b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54
|
https://github.com/Positibe/CoreBundle/blob/b39d702ebc7e60c41b04e07a3c74ca94ee2b8a54/Repository/FilterRepository.php#L176-L199
|
225,156
|
SetBased/php-abc-form
|
src/Control/RadiosControl.php
|
RadiosControl.mergeValuesBase
|
public function mergeValuesBase(array $values): void
{
if (array_key_exists($this->name, $values))
{
$this->setValuesBase($values);
}
}
|
php
|
public function mergeValuesBase(array $values): void
{
if (array_key_exists($this->name, $values))
{
$this->setValuesBase($values);
}
}
|
[
"public",
"function",
"mergeValuesBase",
"(",
"array",
"$",
"values",
")",
":",
"void",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"values",
")",
")",
"{",
"$",
"this",
"->",
"setValuesBase",
"(",
"$",
"values",
")",
";",
"}",
"}"
] |
Sets the value of the checked radio button.
@param array $values
|
[
"Sets",
"the",
"value",
"of",
"the",
"checked",
"radio",
"button",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/RadiosControl.php#L175-L181
|
225,157
|
SetBased/php-abc-form
|
src/Control/RadiosControl.php
|
RadiosControl.labelAttributes
|
private function labelAttributes(array $option): array
{
$attributes = [];
if (is_array($this->labelAttributesMap))
{
foreach ($this->labelAttributesMap as $key => $name)
{
if (isset($option[$key])) $attributes[$name] = $option[$key];
}
}
return $attributes;
}
|
php
|
private function labelAttributes(array $option): array
{
$attributes = [];
if (is_array($this->labelAttributesMap))
{
foreach ($this->labelAttributesMap as $key => $name)
{
if (isset($option[$key])) $attributes[$name] = $option[$key];
}
}
return $attributes;
}
|
[
"private",
"function",
"labelAttributes",
"(",
"array",
"$",
"option",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"labelAttributesMap",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"labelAttributesMap",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"option",
"[",
"$",
"key",
"]",
")",
")",
"$",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"option",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Returns the attributes for the label element.
@param array $option The option.
@return array
|
[
"Returns",
"the",
"attributes",
"for",
"the",
"label",
"element",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/RadiosControl.php#L427-L440
|
225,158
|
SetBased/php-abc-table-detail
|
src/TableRow/DateTimeTableRow.php
|
DateTimeTableRow.addRow
|
public static function addRow(DetailTable $table, $header, ?string $value, ?string $format = null): void
{
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
if ($date)
{
// The $value is a valid datetime.
$table->addRow($header,
['class' => 'date',
'data-value' => $date->format('Y-m-d H:i:s')],
$date->format(($format) ? $format : self::$defaultFormat));
}
else
{
// The $value is not a valid datetime.
$table->addRow($header, [], $value);
}
}
|
php
|
public static function addRow(DetailTable $table, $header, ?string $value, ?string $format = null): void
{
$date = \DateTime::createFromFormat('Y-m-d H:i:s', $value);
if ($date)
{
// The $value is a valid datetime.
$table->addRow($header,
['class' => 'date',
'data-value' => $date->format('Y-m-d H:i:s')],
$date->format(($format) ? $format : self::$defaultFormat));
}
else
{
// The $value is not a valid datetime.
$table->addRow($header, [], $value);
}
}
|
[
"public",
"static",
"function",
"addRow",
"(",
"DetailTable",
"$",
"table",
",",
"$",
"header",
",",
"?",
"string",
"$",
"value",
",",
"?",
"string",
"$",
"format",
"=",
"null",
")",
":",
"void",
"{",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"date",
")",
"{",
"// The $value is a valid datetime. ",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
",",
"[",
"'class'",
"=>",
"'date'",
",",
"'data-value'",
"=>",
"$",
"date",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
"]",
",",
"$",
"date",
"->",
"format",
"(",
"(",
"$",
"format",
")",
"?",
"$",
"format",
":",
"self",
"::",
"$",
"defaultFormat",
")",
")",
";",
"}",
"else",
"{",
"// The $value is not a valid datetime.",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
",",
"[",
"]",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Adds a row with a datetime value to a detail table.
@param DetailTable $table The detail table.
@param string|int|null $header The header text of this table row.
@param string|null $value The datetime in Y-m-d H:i:s format.
@param string|null $format The format specifier for formatting the content of this table column. If null
the default format is used.
|
[
"Adds",
"a",
"row",
"with",
"a",
"datetime",
"value",
"to",
"a",
"detail",
"table",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/DateTimeTableRow.php#L30-L47
|
225,159
|
PureBilling/PureMachineSDK
|
src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php
|
WebServiceClient.call
|
public function call($webServiceName, $inputData=null,
$version=null)
{
if (is_null($version)) {
$version = $this->getVersion();
}
//Create unique token to identify the call
$token = uniqid("CALL_");
if ($this->isSymfony()) {
$eventDispatcher = $this->symfonyContainer->get("event_dispatcher");
}
/*
* Throw initial event before executing
* the call, remote or local
*/
if (($inputData instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCallingEvent($token, $webServiceName, $inputData, $version,
$this->_connectionTimeout, $this->_timeOut,
$this->_proxy, $this->_proxyPort);
$eventDispatcher->dispatch("puremachine.webservice.calling", $event);
}
//check if the service is local
if ($this->isSymfony() && $this->symfonyContainer->has('pureMachine.sdk.webServiceManager')) {
$WebServiceManager = $this->symfonyContainer->get('pureMachine.sdk.webServiceManager');
if ($WebServiceManager->getSchema($webServiceName)) {
$return = $WebServiceManager->localCall($webServiceName, $inputData, $version);
/*
* Throw post event after executing
* the local call
*/
if (($return instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCalledEvent($token, $webServiceName, $return, $version, true);
$eventDispatcher->dispatch("puremachine.webservice.called", $event);
}
return $return;
}
}
//We did not found the webService in local, we do it remotely.
$return = $this->remoteCall($webServiceName, $inputData, $version);
/*
* Throw post event after executing
* the local call
*/
if (($return instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCalledEvent($token, $webServiceName, $return, $version, false);
$eventDispatcher->dispatch("puremachine.webservice.called", $event);
}
return $return;
}
|
php
|
public function call($webServiceName, $inputData=null,
$version=null)
{
if (is_null($version)) {
$version = $this->getVersion();
}
//Create unique token to identify the call
$token = uniqid("CALL_");
if ($this->isSymfony()) {
$eventDispatcher = $this->symfonyContainer->get("event_dispatcher");
}
/*
* Throw initial event before executing
* the call, remote or local
*/
if (($inputData instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCallingEvent($token, $webServiceName, $inputData, $version,
$this->_connectionTimeout, $this->_timeOut,
$this->_proxy, $this->_proxyPort);
$eventDispatcher->dispatch("puremachine.webservice.calling", $event);
}
//check if the service is local
if ($this->isSymfony() && $this->symfonyContainer->has('pureMachine.sdk.webServiceManager')) {
$WebServiceManager = $this->symfonyContainer->get('pureMachine.sdk.webServiceManager');
if ($WebServiceManager->getSchema($webServiceName)) {
$return = $WebServiceManager->localCall($webServiceName, $inputData, $version);
/*
* Throw post event after executing
* the local call
*/
if (($return instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCalledEvent($token, $webServiceName, $return, $version, true);
$eventDispatcher->dispatch("puremachine.webservice.called", $event);
}
return $return;
}
}
//We did not found the webService in local, we do it remotely.
$return = $this->remoteCall($webServiceName, $inputData, $version);
/*
* Throw post event after executing
* the local call
*/
if (($return instanceof BaseStore) && $this->isSymfony()) {
$event = new WebServiceCalledEvent($token, $webServiceName, $return, $version, false);
$eventDispatcher->dispatch("puremachine.webservice.called", $event);
}
return $return;
}
|
[
"public",
"function",
"call",
"(",
"$",
"webServiceName",
",",
"$",
"inputData",
"=",
"null",
",",
"$",
"version",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"version",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"getVersion",
"(",
")",
";",
"}",
"//Create unique token to identify the call",
"$",
"token",
"=",
"uniqid",
"(",
"\"CALL_\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isSymfony",
"(",
")",
")",
"{",
"$",
"eventDispatcher",
"=",
"$",
"this",
"->",
"symfonyContainer",
"->",
"get",
"(",
"\"event_dispatcher\"",
")",
";",
"}",
"/*\n * Throw initial event before executing\n * the call, remote or local\n */",
"if",
"(",
"(",
"$",
"inputData",
"instanceof",
"BaseStore",
")",
"&&",
"$",
"this",
"->",
"isSymfony",
"(",
")",
")",
"{",
"$",
"event",
"=",
"new",
"WebServiceCallingEvent",
"(",
"$",
"token",
",",
"$",
"webServiceName",
",",
"$",
"inputData",
",",
"$",
"version",
",",
"$",
"this",
"->",
"_connectionTimeout",
",",
"$",
"this",
"->",
"_timeOut",
",",
"$",
"this",
"->",
"_proxy",
",",
"$",
"this",
"->",
"_proxyPort",
")",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"\"puremachine.webservice.calling\"",
",",
"$",
"event",
")",
";",
"}",
"//check if the service is local",
"if",
"(",
"$",
"this",
"->",
"isSymfony",
"(",
")",
"&&",
"$",
"this",
"->",
"symfonyContainer",
"->",
"has",
"(",
"'pureMachine.sdk.webServiceManager'",
")",
")",
"{",
"$",
"WebServiceManager",
"=",
"$",
"this",
"->",
"symfonyContainer",
"->",
"get",
"(",
"'pureMachine.sdk.webServiceManager'",
")",
";",
"if",
"(",
"$",
"WebServiceManager",
"->",
"getSchema",
"(",
"$",
"webServiceName",
")",
")",
"{",
"$",
"return",
"=",
"$",
"WebServiceManager",
"->",
"localCall",
"(",
"$",
"webServiceName",
",",
"$",
"inputData",
",",
"$",
"version",
")",
";",
"/*\n * Throw post event after executing\n * the local call\n */",
"if",
"(",
"(",
"$",
"return",
"instanceof",
"BaseStore",
")",
"&&",
"$",
"this",
"->",
"isSymfony",
"(",
")",
")",
"{",
"$",
"event",
"=",
"new",
"WebServiceCalledEvent",
"(",
"$",
"token",
",",
"$",
"webServiceName",
",",
"$",
"return",
",",
"$",
"version",
",",
"true",
")",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"\"puremachine.webservice.called\"",
",",
"$",
"event",
")",
";",
"}",
"return",
"$",
"return",
";",
"}",
"}",
"//We did not found the webService in local, we do it remotely.",
"$",
"return",
"=",
"$",
"this",
"->",
"remoteCall",
"(",
"$",
"webServiceName",
",",
"$",
"inputData",
",",
"$",
"version",
")",
";",
"/*\n * Throw post event after executing\n * the local call\n */",
"if",
"(",
"(",
"$",
"return",
"instanceof",
"BaseStore",
")",
"&&",
"$",
"this",
"->",
"isSymfony",
"(",
")",
")",
"{",
"$",
"event",
"=",
"new",
"WebServiceCalledEvent",
"(",
"$",
"token",
",",
"$",
"webServiceName",
",",
"$",
"return",
",",
"$",
"version",
",",
"false",
")",
";",
"$",
"eventDispatcher",
"->",
"dispatch",
"(",
"\"puremachine.webservice.called\"",
",",
"$",
"event",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Call a webService
If the webService is local, make the call without
doing any HTTP call
|
[
"Call",
"a",
"webService"
] |
1cd3b6a629cbc913513a5d043e6423d1836d5177
|
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php#L122-L179
|
225,160
|
PureBilling/PureMachineSDK
|
src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php
|
WebServiceClient.checkType
|
protected function checkType($value, $type, $allowedClassNames, $errorCode)
{
//We only accept object of array
if ($type && $value && gettype($value) != $type)
throw new WebServiceException("Should be a $type"
.", but it's a " . gettype($value), $errorCode);
if (!$value && count($allowedClassNames) >0) {
throw new WebServiceException("Should a instance of "
. $this->_getAllowedClassNameString($allowedClassNames)
.", but it's null ", $errorCode);
}
//check if the value implement JsonSerializable if needed
if ($this->needToImplementJsonSerializable($value) &&
!($value instanceof JsonSerializable)) {
throw new WebServiceException("object of type ".get_class($value)." has to implement "
."PureMachine\Bundle\SDKBundle\Store\JsonSerializable "
."Interface",
$errorCode);
}
//If value is store, we validate it
if ($value instanceof BaseStore) {
//Check if the type if fine if defined
if(count($allowedClassNames) >0 &&
!in_array(get_class($value), $allowedClassNames)) {
throw new WebServiceException("your store should be a intance of "
. $this->_getAllowedClassNameString($allowedClassNames)
.", but it's a " . get_class($value),
$errorCode);
}
//Validate the store
if (!$value->validate($this->getValidator())) {
$violations = $value->getViolations();
$property = $violations[0]->getPropertyPath();
$message = $value->getFirstErrorString();
throw new WebServiceException($message, $errorCode);
}
//We have an array of object, and potentiallt stores
//We need to check the type and validate stores
} elseif ($type == 'array' && is_array($allowedClassNames) && count($allowedClassNames) > 0) {
foreach ($value as $store) {
$this->checkType($store, 'object', $allowedClassNames, $errorCode);
}
}
}
|
php
|
protected function checkType($value, $type, $allowedClassNames, $errorCode)
{
//We only accept object of array
if ($type && $value && gettype($value) != $type)
throw new WebServiceException("Should be a $type"
.", but it's a " . gettype($value), $errorCode);
if (!$value && count($allowedClassNames) >0) {
throw new WebServiceException("Should a instance of "
. $this->_getAllowedClassNameString($allowedClassNames)
.", but it's null ", $errorCode);
}
//check if the value implement JsonSerializable if needed
if ($this->needToImplementJsonSerializable($value) &&
!($value instanceof JsonSerializable)) {
throw new WebServiceException("object of type ".get_class($value)." has to implement "
."PureMachine\Bundle\SDKBundle\Store\JsonSerializable "
."Interface",
$errorCode);
}
//If value is store, we validate it
if ($value instanceof BaseStore) {
//Check if the type if fine if defined
if(count($allowedClassNames) >0 &&
!in_array(get_class($value), $allowedClassNames)) {
throw new WebServiceException("your store should be a intance of "
. $this->_getAllowedClassNameString($allowedClassNames)
.", but it's a " . get_class($value),
$errorCode);
}
//Validate the store
if (!$value->validate($this->getValidator())) {
$violations = $value->getViolations();
$property = $violations[0]->getPropertyPath();
$message = $value->getFirstErrorString();
throw new WebServiceException($message, $errorCode);
}
//We have an array of object, and potentiallt stores
//We need to check the type and validate stores
} elseif ($type == 'array' && is_array($allowedClassNames) && count($allowedClassNames) > 0) {
foreach ($value as $store) {
$this->checkType($store, 'object', $allowedClassNames, $errorCode);
}
}
}
|
[
"protected",
"function",
"checkType",
"(",
"$",
"value",
",",
"$",
"type",
",",
"$",
"allowedClassNames",
",",
"$",
"errorCode",
")",
"{",
"//We only accept object of array",
"if",
"(",
"$",
"type",
"&&",
"$",
"value",
"&&",
"gettype",
"(",
"$",
"value",
")",
"!=",
"$",
"type",
")",
"throw",
"new",
"WebServiceException",
"(",
"\"Should be a $type\"",
".",
"\", but it's a \"",
".",
"gettype",
"(",
"$",
"value",
")",
",",
"$",
"errorCode",
")",
";",
"if",
"(",
"!",
"$",
"value",
"&&",
"count",
"(",
"$",
"allowedClassNames",
")",
">",
"0",
")",
"{",
"throw",
"new",
"WebServiceException",
"(",
"\"Should a instance of \"",
".",
"$",
"this",
"->",
"_getAllowedClassNameString",
"(",
"$",
"allowedClassNames",
")",
".",
"\", but it's null \"",
",",
"$",
"errorCode",
")",
";",
"}",
"//check if the value implement JsonSerializable if needed",
"if",
"(",
"$",
"this",
"->",
"needToImplementJsonSerializable",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"JsonSerializable",
")",
")",
"{",
"throw",
"new",
"WebServiceException",
"(",
"\"object of type \"",
".",
"get_class",
"(",
"$",
"value",
")",
".",
"\" has to implement \"",
".",
"\"PureMachine\\Bundle\\SDKBundle\\Store\\JsonSerializable \"",
".",
"\"Interface\"",
",",
"$",
"errorCode",
")",
";",
"}",
"//If value is store, we validate it",
"if",
"(",
"$",
"value",
"instanceof",
"BaseStore",
")",
"{",
"//Check if the type if fine if defined",
"if",
"(",
"count",
"(",
"$",
"allowedClassNames",
")",
">",
"0",
"&&",
"!",
"in_array",
"(",
"get_class",
"(",
"$",
"value",
")",
",",
"$",
"allowedClassNames",
")",
")",
"{",
"throw",
"new",
"WebServiceException",
"(",
"\"your store should be a intance of \"",
".",
"$",
"this",
"->",
"_getAllowedClassNameString",
"(",
"$",
"allowedClassNames",
")",
".",
"\", but it's a \"",
".",
"get_class",
"(",
"$",
"value",
")",
",",
"$",
"errorCode",
")",
";",
"}",
"//Validate the store",
"if",
"(",
"!",
"$",
"value",
"->",
"validate",
"(",
"$",
"this",
"->",
"getValidator",
"(",
")",
")",
")",
"{",
"$",
"violations",
"=",
"$",
"value",
"->",
"getViolations",
"(",
")",
";",
"$",
"property",
"=",
"$",
"violations",
"[",
"0",
"]",
"->",
"getPropertyPath",
"(",
")",
";",
"$",
"message",
"=",
"$",
"value",
"->",
"getFirstErrorString",
"(",
")",
";",
"throw",
"new",
"WebServiceException",
"(",
"$",
"message",
",",
"$",
"errorCode",
")",
";",
"}",
"//We have an array of object, and potentiallt stores",
"//We need to check the type and validate stores",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'array'",
"&&",
"is_array",
"(",
"$",
"allowedClassNames",
")",
"&&",
"count",
"(",
"$",
"allowedClassNames",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"store",
")",
"{",
"$",
"this",
"->",
"checkType",
"(",
"$",
"store",
",",
"'object'",
",",
"$",
"allowedClassNames",
",",
"$",
"errorCode",
")",
";",
"}",
"}",
"}"
] |
Check json schema type validity using symfony2 Validation system
return the error message if any or false
@param string $value value to check
@param string $type type to check
|
[
"Check",
"json",
"schema",
"type",
"validity",
"using",
"symfony2",
"Validation",
"system",
"return",
"the",
"error",
"message",
"if",
"any",
"or",
"false"
] |
1cd3b6a629cbc913513a5d043e6423d1836d5177
|
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php#L366-L413
|
225,161
|
PureBilling/PureMachineSDK
|
src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php
|
WebServiceClient.translateException
|
protected function translateException($store)
{
if(!$this->isSymfony() || !$this->symfonyContainer) return null;
$translator = $this->getSymfonyTranslator();
$translatedMessage = $translator->trans($store->getCode(), array(), 'messages', $translator->getLocale());
if($translatedMessage!=$store->getCode()) return $translatedMessage;
return null;
}
|
php
|
protected function translateException($store)
{
if(!$this->isSymfony() || !$this->symfonyContainer) return null;
$translator = $this->getSymfonyTranslator();
$translatedMessage = $translator->trans($store->getCode(), array(), 'messages', $translator->getLocale());
if($translatedMessage!=$store->getCode()) return $translatedMessage;
return null;
}
|
[
"protected",
"function",
"translateException",
"(",
"$",
"store",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isSymfony",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"symfonyContainer",
")",
"return",
"null",
";",
"$",
"translator",
"=",
"$",
"this",
"->",
"getSymfonyTranslator",
"(",
")",
";",
"$",
"translatedMessage",
"=",
"$",
"translator",
"->",
"trans",
"(",
"$",
"store",
"->",
"getCode",
"(",
")",
",",
"array",
"(",
")",
",",
"'messages'",
",",
"$",
"translator",
"->",
"getLocale",
"(",
")",
")",
";",
"if",
"(",
"$",
"translatedMessage",
"!=",
"$",
"store",
"->",
"getCode",
"(",
")",
")",
"return",
"$",
"translatedMessage",
";",
"return",
"null",
";",
"}"
] |
Uses the exception code to try to found a translation for the exception, if found
will override the message on the exception, if not found will leave the message as it it
@param \Exception $e
@return void
|
[
"Uses",
"the",
"exception",
"code",
"to",
"try",
"to",
"found",
"a",
"translation",
"for",
"the",
"exception",
"if",
"found",
"will",
"override",
"the",
"message",
"on",
"the",
"exception",
"if",
"not",
"found",
"will",
"leave",
"the",
"message",
"as",
"it",
"it"
] |
1cd3b6a629cbc913513a5d043e6423d1836d5177
|
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Service/WebServiceClient.php#L456-L465
|
225,162
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderPool.php
|
AppenderPool.add
|
public static function add(\n2n\log4php\LoggerAppender $appender) {
$name = $appender->getName();
if(empty($name)) {
throw new \n2n\log4php\LoggerException('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
return;
}
if (isset(self::$appenders[$name])) {
throw new \n2n\log4php\LoggerException("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
}
self::$appenders[$name] = $appender;
}
|
php
|
public static function add(\n2n\log4php\LoggerAppender $appender) {
$name = $appender->getName();
if(empty($name)) {
throw new \n2n\log4php\LoggerException('log4php: Cannot add unnamed appender to pool.', E_USER_WARNING);
return;
}
if (isset(self::$appenders[$name])) {
throw new \n2n\log4php\LoggerException("log4php: Appender [$name] already exists in pool. Overwriting existing appender.", E_USER_WARNING);
}
self::$appenders[$name] = $appender;
}
|
[
"public",
"static",
"function",
"add",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerAppender",
"$",
"appender",
")",
"{",
"$",
"name",
"=",
"$",
"appender",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"'log4php: Cannot add unnamed appender to pool.'",
",",
"E_USER_WARNING",
")",
";",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"appenders",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"log4php: Appender [$name] already exists in pool. Overwriting existing appender.\"",
",",
"E_USER_WARNING",
")",
";",
"}",
"self",
"::",
"$",
"appenders",
"[",
"$",
"name",
"]",
"=",
"$",
"appender",
";",
"}"
] |
Adds an appender to the pool.
The appender must be named for this operation.
@param \n2n\log4php\LoggerAppender $appender
|
[
"Adds",
"an",
"appender",
"to",
"the",
"pool",
".",
"The",
"appender",
"must",
"be",
"named",
"for",
"this",
"operation",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderPool.php#L43-L56
|
225,163
|
railken/amethyst-file
|
src/Http/Controllers/Admin/FilesController.php
|
FilesController.upload
|
public function upload($id, Request $request)
{
$entity = $this->getQuery()->where('id', $id)->first();
if (!$entity) {
return $this->response([], Response::HTTP_NOT_FOUND);
}
$manager = $this->getManager();
if ($request->file('file') === null) {
return $this->error(['errors' => ['message' => 'Missing file']]);
}
$result = $manager->uploadFile(
$entity,
$request->file('file')
);
if (!$result->ok()) {
return $this->error(['errors' => $result->getSimpleErrors()]);
}
return $this->success(['data' => $this->getManager()->getSerializer()->serialize($result->getResource())->toArray()], 201);
}
|
php
|
public function upload($id, Request $request)
{
$entity = $this->getQuery()->where('id', $id)->first();
if (!$entity) {
return $this->response([], Response::HTTP_NOT_FOUND);
}
$manager = $this->getManager();
if ($request->file('file') === null) {
return $this->error(['errors' => ['message' => 'Missing file']]);
}
$result = $manager->uploadFile(
$entity,
$request->file('file')
);
if (!$result->ok()) {
return $this->error(['errors' => $result->getSimpleErrors()]);
}
return $this->success(['data' => $this->getManager()->getSerializer()->serialize($result->getResource())->toArray()], 201);
}
|
[
"public",
"function",
"upload",
"(",
"$",
"id",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
"->",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"(",
"[",
"]",
",",
"Response",
"::",
"HTTP_NOT_FOUND",
")",
";",
"}",
"$",
"manager",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"file",
"(",
"'file'",
")",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"[",
"'errors'",
"=>",
"[",
"'message'",
"=>",
"'Missing file'",
"]",
"]",
")",
";",
"}",
"$",
"result",
"=",
"$",
"manager",
"->",
"uploadFile",
"(",
"$",
"entity",
",",
"$",
"request",
"->",
"file",
"(",
"'file'",
")",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"ok",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"[",
"'errors'",
"=>",
"$",
"result",
"->",
"getSimpleErrors",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"success",
"(",
"[",
"'data'",
"=>",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getSerializer",
"(",
")",
"->",
"serialize",
"(",
"$",
"result",
"->",
"getResource",
"(",
")",
")",
"->",
"toArray",
"(",
")",
"]",
",",
"201",
")",
";",
"}"
] |
The attributes that are fillable.
@param mixed $id
@param Request $request
@return \Symfony\Component\HttpFoundation\Response
|
[
"The",
"attributes",
"that",
"are",
"fillable",
"."
] |
732916420373fd2ad1a80393d86f8a4d26e47768
|
https://github.com/railken/amethyst-file/blob/732916420373fd2ad1a80393d86f8a4d26e47768/src/Http/Controllers/Admin/FilesController.php#L37-L61
|
225,164
|
stubbles/stubbles-input
|
src/main/php/Filter.php
|
Filter.error
|
protected function error($error, array $details = []): array
{
$error = ParamError::fromData($error, $details);
return [null, [$error->id() => $error]];
}
|
php
|
protected function error($error, array $details = []): array
{
$error = ParamError::fromData($error, $details);
return [null, [$error->id() => $error]];
}
|
[
"protected",
"function",
"error",
"(",
"$",
"error",
",",
"array",
"$",
"details",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"error",
"=",
"ParamError",
"::",
"fromData",
"(",
"$",
"error",
",",
"$",
"details",
")",
";",
"return",
"[",
"null",
",",
"[",
"$",
"error",
"->",
"id",
"(",
")",
"=>",
"$",
"error",
"]",
"]",
";",
"}"
] |
helper function to return null and one error
@return array
|
[
"helper",
"function",
"to",
"return",
"null",
"and",
"one",
"error"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Filter.php#L76-L80
|
225,165
|
czogori/Dami
|
src/Dami/Migration/SchemaTable.php
|
SchemaTable.migrateToVersion
|
public function migrateToVersion($version, $up = true)
{
$this->createIfNotExists();
$currentVersion = $this->getCurrentVersion();
if ($up) {
$this->up($version);
} else {
$this->down($version);
}
}
|
php
|
public function migrateToVersion($version, $up = true)
{
$this->createIfNotExists();
$currentVersion = $this->getCurrentVersion();
if ($up) {
$this->up($version);
} else {
$this->down($version);
}
}
|
[
"public",
"function",
"migrateToVersion",
"(",
"$",
"version",
",",
"$",
"up",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"createIfNotExists",
"(",
")",
";",
"$",
"currentVersion",
"=",
"$",
"this",
"->",
"getCurrentVersion",
"(",
")",
";",
"if",
"(",
"$",
"up",
")",
"{",
"$",
"this",
"->",
"up",
"(",
"$",
"version",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"down",
"(",
"$",
"version",
")",
";",
"}",
"}"
] |
Migrare to given version.
@param string $version Version of migration.
@return void
|
[
"Migrare",
"to",
"given",
"version",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/SchemaTable.php#L43-L52
|
225,166
|
czogori/Dami
|
src/Dami/Migration/SchemaTable.php
|
SchemaTable.getVersions
|
public function getVersions()
{
$this->createIfNotExists();
$sql = 'SELECT version FROM schema_migration ORDER BY version DESC';
$versions = array();
foreach ($this->connection->query($sql) as $row) {
$versions[] = $row['version'];
}
return $versions;
}
|
php
|
public function getVersions()
{
$this->createIfNotExists();
$sql = 'SELECT version FROM schema_migration ORDER BY version DESC';
$versions = array();
foreach ($this->connection->query($sql) as $row) {
$versions[] = $row['version'];
}
return $versions;
}
|
[
"public",
"function",
"getVersions",
"(",
")",
"{",
"$",
"this",
"->",
"createIfNotExists",
"(",
")",
";",
"$",
"sql",
"=",
"'SELECT version FROM schema_migration ORDER BY version DESC'",
";",
"$",
"versions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"connection",
"->",
"query",
"(",
"$",
"sql",
")",
"as",
"$",
"row",
")",
"{",
"$",
"versions",
"[",
"]",
"=",
"$",
"row",
"[",
"'version'",
"]",
";",
"}",
"return",
"$",
"versions",
";",
"}"
] |
Get all versions of migrations.
@return array Versions of migrations.
|
[
"Get",
"all",
"versions",
"of",
"migrations",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/SchemaTable.php#L59-L69
|
225,167
|
czogori/Dami
|
src/Dami/Migration/SchemaTable.php
|
SchemaTable.createIfNotExists
|
private function createIfNotExists()
{
$table = new Table('schema_migration');
if ($this->info->isTableExists($table)) {
return;
}
$primaryKey = new PrimaryKey(array('version'));
$primaryKey->disableAutoIncrement();
$table->addConstraint($primaryKey);
$table
->addColumn(new BigIntegerColumn('version'))
->addColumn(new DateTimeColumn('created_at', array('nullable' => false, 'default' => 'now()')));
$this->manipulation->create($table);
}
|
php
|
private function createIfNotExists()
{
$table = new Table('schema_migration');
if ($this->info->isTableExists($table)) {
return;
}
$primaryKey = new PrimaryKey(array('version'));
$primaryKey->disableAutoIncrement();
$table->addConstraint($primaryKey);
$table
->addColumn(new BigIntegerColumn('version'))
->addColumn(new DateTimeColumn('created_at', array('nullable' => false, 'default' => 'now()')));
$this->manipulation->create($table);
}
|
[
"private",
"function",
"createIfNotExists",
"(",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"'schema_migration'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"info",
"->",
"isTableExists",
"(",
"$",
"table",
")",
")",
"{",
"return",
";",
"}",
"$",
"primaryKey",
"=",
"new",
"PrimaryKey",
"(",
"array",
"(",
"'version'",
")",
")",
";",
"$",
"primaryKey",
"->",
"disableAutoIncrement",
"(",
")",
";",
"$",
"table",
"->",
"addConstraint",
"(",
"$",
"primaryKey",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"new",
"BigIntegerColumn",
"(",
"'version'",
")",
")",
"->",
"addColumn",
"(",
"new",
"DateTimeColumn",
"(",
"'created_at'",
",",
"array",
"(",
"'nullable'",
"=>",
"false",
",",
"'default'",
"=>",
"'now()'",
")",
")",
")",
";",
"$",
"this",
"->",
"manipulation",
"->",
"create",
"(",
"$",
"table",
")",
";",
"}"
] |
Create schema table if not exists.
@return void
|
[
"Create",
"schema",
"table",
"if",
"not",
"exists",
"."
] |
19612e643f8bea76706cc667c3f2c12a42d4cd19
|
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/SchemaTable.php#L126-L140
|
225,168
|
stubbles/stubbles-input
|
src/main/php/valuereader/MissingValueReader.php
|
MissingValueReader.reportError
|
private function reportError(string $errorId = null)
{
$reportError = $this->reportError;
$reportError((null === $errorId) ? ($this->defaultErrorId) : ($errorId));
}
|
php
|
private function reportError(string $errorId = null)
{
$reportError = $this->reportError;
$reportError((null === $errorId) ? ($this->defaultErrorId) : ($errorId));
}
|
[
"private",
"function",
"reportError",
"(",
"string",
"$",
"errorId",
"=",
"null",
")",
"{",
"$",
"reportError",
"=",
"$",
"this",
"->",
"reportError",
";",
"$",
"reportError",
"(",
"(",
"null",
"===",
"$",
"errorId",
")",
"?",
"(",
"$",
"this",
"->",
"defaultErrorId",
")",
":",
"(",
"$",
"errorId",
")",
")",
";",
"}"
] |
reports the error
@param string $errorId optional
|
[
"reports",
"the",
"error"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/valuereader/MissingValueReader.php#L56-L60
|
225,169
|
DrNixx/yii2-onix
|
src/collections/TreeSet.php
|
TreeSet.offsetSet
|
public function offsetSet($element, $value)
{
$map = $this->getMap();
if ($value) {
$map[$element] = true;
} else {
unset($map[$element]);
}
}
|
php
|
public function offsetSet($element, $value)
{
$map = $this->getMap();
if ($value) {
$map[$element] = true;
} else {
unset($map[$element]);
}
}
|
[
"public",
"function",
"offsetSet",
"(",
"$",
"element",
",",
"$",
"value",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
";",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"map",
"[",
"$",
"element",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"map",
"[",
"$",
"element",
"]",
")",
";",
"}",
"}"
] |
Set the value for an element
@param mixed $element The element
@param mixed $value The value
@return void
|
[
"Set",
"the",
"value",
"for",
"an",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeSet.php#L75-L83
|
225,170
|
DrNixx/yii2-onix
|
src/collections/TreeSet.php
|
TreeSet.containsAll
|
public function containsAll($elements)
{
foreach ($elements as $element) {
if (false === $this->contains($element)) {
return false;
}
}
return true;
}
|
php
|
public function containsAll($elements)
{
foreach ($elements as $element) {
if (false === $this->contains($element)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"containsAll",
"(",
"$",
"elements",
")",
"{",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"contains",
"(",
"$",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns `true` if the set contains all of the specified elements.
@param CollectionInterface|array $elements Elements to test.
@return bool `true` if the set contains all of the specified elements, otherwise `false`.
@see contains
|
[
"Returns",
"true",
"if",
"the",
"set",
"contains",
"all",
"of",
"the",
"specified",
"elements",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeSet.php#L163-L172
|
225,171
|
DrNixx/yii2-onix
|
src/collections/TreeSet.php
|
TreeSet.retainAll
|
public function retainAll($elements)
{
if ($elements instanceof CollectionInterface) {
$elements = $elements->toArray();
}
$this->clear()->addAll($elements);
return $this;
}
|
php
|
public function retainAll($elements)
{
if ($elements instanceof CollectionInterface) {
$elements = $elements->toArray();
}
$this->clear()->addAll($elements);
return $this;
}
|
[
"public",
"function",
"retainAll",
"(",
"$",
"elements",
")",
"{",
"if",
"(",
"$",
"elements",
"instanceof",
"CollectionInterface",
")",
"{",
"$",
"elements",
"=",
"$",
"elements",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"this",
"->",
"clear",
"(",
")",
"->",
"addAll",
"(",
"$",
"elements",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Retains only the elements in the set that are contained in the specified
collection.
In other words, removes from the set all of its elements that are not
contained in the specified collection.
This is an optional operation.
@param CollectionInterface|array $elements Elements to be retained in the set.
@return SetInterface A reference to the set.
@throws NullPointerException If one or more of the elements is null and the set does not permit null
elements (optional).
@throws UnexpectedValueException If one or more of the elements is incompatible with the set (optional).
@throws UnsupportedOperationException If the `retainAll` operation is not supported by the set.
@see remove, removeAll
|
[
"Retains",
"only",
"the",
"elements",
"in",
"the",
"set",
"that",
"are",
"contained",
"in",
"the",
"specified",
"collection",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeSet.php#L232-L240
|
225,172
|
PureBilling/PureMachineSDK
|
src/PureMachine/Bundle/StoreBundle/Store/Base/BaseStore.php
|
BaseStore.getViolations
|
public function getViolations($ignoredVioltations=null)
{
if (!$this->isValidated())
throw new StoreException("You must call validate() method before.",
StoreException::STORE_002);
if (!is_array($ignoredVioltations)) {
return $this->violations;
}
/**
* Ignore violation by property path
*/
$violations = array();
foreach ($this->getViolations() as $violation) {
if (!in_array($violation->getPropertyPath(), $ignoredVioltations)) {
$violations[] = $violation;
}
}
return $violations;
}
|
php
|
public function getViolations($ignoredVioltations=null)
{
if (!$this->isValidated())
throw new StoreException("You must call validate() method before.",
StoreException::STORE_002);
if (!is_array($ignoredVioltations)) {
return $this->violations;
}
/**
* Ignore violation by property path
*/
$violations = array();
foreach ($this->getViolations() as $violation) {
if (!in_array($violation->getPropertyPath(), $ignoredVioltations)) {
$violations[] = $violation;
}
}
return $violations;
}
|
[
"public",
"function",
"getViolations",
"(",
"$",
"ignoredVioltations",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidated",
"(",
")",
")",
"throw",
"new",
"StoreException",
"(",
"\"You must call validate() method before.\"",
",",
"StoreException",
"::",
"STORE_002",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ignoredVioltations",
")",
")",
"{",
"return",
"$",
"this",
"->",
"violations",
";",
"}",
"/**\n * Ignore violation by property path\n */",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getViolations",
"(",
")",
"as",
"$",
"violation",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"violation",
"->",
"getPropertyPath",
"(",
")",
",",
"$",
"ignoredVioltations",
")",
")",
"{",
"$",
"violations",
"[",
"]",
"=",
"$",
"violation",
";",
"}",
"}",
"return",
"$",
"violations",
";",
"}"
] |
Return validation violations
need to run validate() bedore
|
[
"Return",
"validation",
"violations"
] |
1cd3b6a629cbc913513a5d043e6423d1836d5177
|
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/StoreBundle/Store/Base/BaseStore.php#L134-L155
|
225,173
|
PureBilling/PureMachineSDK
|
src/PureMachine/Bundle/StoreBundle/Store/Base/BaseStore.php
|
BaseStore.serialize
|
public function serialize($includePrivate=false, $includeInternal=true, $removeNullValues=false,
$dateAsISO8601=false)
{
$answer = array();
$schema = $this->_jsonSchema;
foreach ($schema['definition'] as $property => $definition) {
$method = 'get' . ucfirst($property);
//Checking special types
if ($definition['private'] == true && !$includePrivate) {
continue;
}
if ($definition['internal'] == true && !$includeInternal) {
continue;
}
$valueFromMethod = $this->$method();
if (isset($definition['type'])) {
switch ($definition['type']) {
case "datetime":
if ($dateAsISO8601 && !is_null($valueFromMethod)) {
$valueFromMethod = $valueFromMethod->format("c");
} else {
$valueFromMethod = $this->$property; //Integer value
}
break;
}
}
$value = StoreHelper::serialize($valueFromMethod, $includePrivate, $includeInternal, $removeNullValues, $dateAsISO8601);
if (is_null($value)
&& $removeNullValues
&& array_key_exists('validationConstraints', $definition)
&& !$definition['keepIfNull']
&& !(in_array('NotBlank', $definition['validationConstraints']))) {
continue;
}
$answer[$property] = $value;
/**
* Add aliases
*/
if ($definition['alias']) {
$alias = $definition['alias'];
$method = 'get' . ucfirst($alias);
if (method_exists($this, $method)) {
$answer[$alias] = $this->$method();
} else {
$answer[$alias] = $answer[$property];
}
}
}
return (object) $answer;
}
|
php
|
public function serialize($includePrivate=false, $includeInternal=true, $removeNullValues=false,
$dateAsISO8601=false)
{
$answer = array();
$schema = $this->_jsonSchema;
foreach ($schema['definition'] as $property => $definition) {
$method = 'get' . ucfirst($property);
//Checking special types
if ($definition['private'] == true && !$includePrivate) {
continue;
}
if ($definition['internal'] == true && !$includeInternal) {
continue;
}
$valueFromMethod = $this->$method();
if (isset($definition['type'])) {
switch ($definition['type']) {
case "datetime":
if ($dateAsISO8601 && !is_null($valueFromMethod)) {
$valueFromMethod = $valueFromMethod->format("c");
} else {
$valueFromMethod = $this->$property; //Integer value
}
break;
}
}
$value = StoreHelper::serialize($valueFromMethod, $includePrivate, $includeInternal, $removeNullValues, $dateAsISO8601);
if (is_null($value)
&& $removeNullValues
&& array_key_exists('validationConstraints', $definition)
&& !$definition['keepIfNull']
&& !(in_array('NotBlank', $definition['validationConstraints']))) {
continue;
}
$answer[$property] = $value;
/**
* Add aliases
*/
if ($definition['alias']) {
$alias = $definition['alias'];
$method = 'get' . ucfirst($alias);
if (method_exists($this, $method)) {
$answer[$alias] = $this->$method();
} else {
$answer[$alias] = $answer[$property];
}
}
}
return (object) $answer;
}
|
[
"public",
"function",
"serialize",
"(",
"$",
"includePrivate",
"=",
"false",
",",
"$",
"includeInternal",
"=",
"true",
",",
"$",
"removeNullValues",
"=",
"false",
",",
"$",
"dateAsISO8601",
"=",
"false",
")",
"{",
"$",
"answer",
"=",
"array",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"this",
"->",
"_jsonSchema",
";",
"foreach",
"(",
"$",
"schema",
"[",
"'definition'",
"]",
"as",
"$",
"property",
"=>",
"$",
"definition",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"property",
")",
";",
"//Checking special types",
"if",
"(",
"$",
"definition",
"[",
"'private'",
"]",
"==",
"true",
"&&",
"!",
"$",
"includePrivate",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"definition",
"[",
"'internal'",
"]",
"==",
"true",
"&&",
"!",
"$",
"includeInternal",
")",
"{",
"continue",
";",
"}",
"$",
"valueFromMethod",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"definition",
"[",
"'type'",
"]",
")",
")",
"{",
"switch",
"(",
"$",
"definition",
"[",
"'type'",
"]",
")",
"{",
"case",
"\"datetime\"",
":",
"if",
"(",
"$",
"dateAsISO8601",
"&&",
"!",
"is_null",
"(",
"$",
"valueFromMethod",
")",
")",
"{",
"$",
"valueFromMethod",
"=",
"$",
"valueFromMethod",
"->",
"format",
"(",
"\"c\"",
")",
";",
"}",
"else",
"{",
"$",
"valueFromMethod",
"=",
"$",
"this",
"->",
"$",
"property",
";",
"//Integer value",
"}",
"break",
";",
"}",
"}",
"$",
"value",
"=",
"StoreHelper",
"::",
"serialize",
"(",
"$",
"valueFromMethod",
",",
"$",
"includePrivate",
",",
"$",
"includeInternal",
",",
"$",
"removeNullValues",
",",
"$",
"dateAsISO8601",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"&&",
"$",
"removeNullValues",
"&&",
"array_key_exists",
"(",
"'validationConstraints'",
",",
"$",
"definition",
")",
"&&",
"!",
"$",
"definition",
"[",
"'keepIfNull'",
"]",
"&&",
"!",
"(",
"in_array",
"(",
"'NotBlank'",
",",
"$",
"definition",
"[",
"'validationConstraints'",
"]",
")",
")",
")",
"{",
"continue",
";",
"}",
"$",
"answer",
"[",
"$",
"property",
"]",
"=",
"$",
"value",
";",
"/**\n * Add aliases\n */",
"if",
"(",
"$",
"definition",
"[",
"'alias'",
"]",
")",
"{",
"$",
"alias",
"=",
"$",
"definition",
"[",
"'alias'",
"]",
";",
"$",
"method",
"=",
"'get'",
".",
"ucfirst",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"answer",
"[",
"$",
"alias",
"]",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"else",
"{",
"$",
"answer",
"[",
"$",
"alias",
"]",
"=",
"$",
"answer",
"[",
"$",
"property",
"]",
";",
"}",
"}",
"}",
"return",
"(",
"object",
")",
"$",
"answer",
";",
"}"
] |
Serilize the Store
if removeNullValues is True, non mandatory null values are removed from serialized store
|
[
"Serilize",
"the",
"Store"
] |
1cd3b6a629cbc913513a5d043e6423d1836d5177
|
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/StoreBundle/Store/Base/BaseStore.php#L181-L240
|
225,174
|
railken/amethyst-file
|
src/Models/File.php
|
File.getFullUrl
|
public function getFullUrl(string $name = '')
{
if (!isset($this->media[0])) {
return null;
}
return $this->media[0]->disk === 's3'
? $this->media[0]->getTemporaryUrl(new \DateTime('+1 hour'))
: $this->media[0]->getFullUrl($name);
}
|
php
|
public function getFullUrl(string $name = '')
{
if (!isset($this->media[0])) {
return null;
}
return $this->media[0]->disk === 's3'
? $this->media[0]->getTemporaryUrl(new \DateTime('+1 hour'))
: $this->media[0]->getFullUrl($name);
}
|
[
"public",
"function",
"getFullUrl",
"(",
"string",
"$",
"name",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"media",
"[",
"0",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"media",
"[",
"0",
"]",
"->",
"disk",
"===",
"'s3'",
"?",
"$",
"this",
"->",
"media",
"[",
"0",
"]",
"->",
"getTemporaryUrl",
"(",
"new",
"\\",
"DateTime",
"(",
"'+1 hour'",
")",
")",
":",
"$",
"this",
"->",
"media",
"[",
"0",
"]",
"->",
"getFullUrl",
"(",
"$",
"name",
")",
";",
"}"
] |
Get the full url to a original media file.
@param string $name
@return string
|
[
"Get",
"the",
"full",
"url",
"to",
"a",
"original",
"media",
"file",
"."
] |
732916420373fd2ad1a80393d86f8a4d26e47768
|
https://github.com/railken/amethyst-file/blob/732916420373fd2ad1a80393d86f8a4d26e47768/src/Models/File.php#L57-L66
|
225,175
|
railken/amethyst-file
|
src/Models/File.php
|
File.downloadable
|
public function downloadable()
{
$media = $this->media[0];
if ($media->disk === 's3') {
return $media->getTemporaryUrl(new \DateTime('+1 hour'));
}
if (in_array($media->disk, ['local', 'public'], true)) {
return $media->getPath();
}
return $media->getFullUrl();
}
|
php
|
public function downloadable()
{
$media = $this->media[0];
if ($media->disk === 's3') {
return $media->getTemporaryUrl(new \DateTime('+1 hour'));
}
if (in_array($media->disk, ['local', 'public'], true)) {
return $media->getPath();
}
return $media->getFullUrl();
}
|
[
"public",
"function",
"downloadable",
"(",
")",
"{",
"$",
"media",
"=",
"$",
"this",
"->",
"media",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"media",
"->",
"disk",
"===",
"'s3'",
")",
"{",
"return",
"$",
"media",
"->",
"getTemporaryUrl",
"(",
"new",
"\\",
"DateTime",
"(",
"'+1 hour'",
")",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"media",
"->",
"disk",
",",
"[",
"'local'",
",",
"'public'",
"]",
",",
"true",
")",
")",
"{",
"return",
"$",
"media",
"->",
"getPath",
"(",
")",
";",
"}",
"return",
"$",
"media",
"->",
"getFullUrl",
"(",
")",
";",
"}"
] |
Get url downloadable.
@return string
|
[
"Get",
"url",
"downloadable",
"."
] |
732916420373fd2ad1a80393d86f8a4d26e47768
|
https://github.com/railken/amethyst-file/blob/732916420373fd2ad1a80393d86f8a4d26e47768/src/Models/File.php#L73-L86
|
225,176
|
stubbles/stubbles-input
|
src/main/php/Params.php
|
Params.value
|
public function value(string $paramName): Value
{
return Value::of($this->params[$paramName] ?? null);
}
|
php
|
public function value(string $paramName): Value
{
return Value::of($this->params[$paramName] ?? null);
}
|
[
"public",
"function",
"value",
"(",
"string",
"$",
"paramName",
")",
":",
"Value",
"{",
"return",
"Value",
"::",
"of",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"paramName",
"]",
"??",
"null",
")",
";",
"}"
] |
returns raw value of parameter or null if not set
@param string $paramName
@return \stubbles\values\Value
|
[
"returns",
"raw",
"value",
"of",
"parameter",
"or",
"null",
"if",
"not",
"set"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Params.php#L62-L65
|
225,177
|
stubbles/stubbles-input
|
src/main/php/Params.php
|
Params.errors
|
public function errors(): ParamErrors
{
if (null === $this->errors) {
$this->errors = new ParamErrors();
}
return $this->errors;
}
|
php
|
public function errors(): ParamErrors
{
if (null === $this->errors) {
$this->errors = new ParamErrors();
}
return $this->errors;
}
|
[
"public",
"function",
"errors",
"(",
")",
":",
"ParamErrors",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"errors",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"new",
"ParamErrors",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"errors",
";",
"}"
] |
returns error collection for request parameters
@return \stubbles\input\errors\ParamErrors
|
[
"returns",
"error",
"collection",
"for",
"request",
"parameters"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/Params.php#L82-L89
|
225,178
|
SetBased/php-abc-form
|
src/Validator/HttpValidator.php
|
HttpValidator.validate
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not a valid http URL.
if (!is_scalar($value))
{
return false;
}
// Filter valid URL from the value.
$url = filter_var($value, FILTER_VALIDATE_URL);
// If the actual value and the filtered value are not equal the value is not a valid url.
if ($url!==$value)
{
return false;
}
// filter_var allows not to specify the HTTP protocol. Test the URL starts with http (or https).
if (substr($url, 0, 4)!=='http')
{
return false;
}
// Test that the page actually exits. We consider all HTTP 200-399 responses as valid.
try
{
$headers = get_headers($url);
$ok = (is_array($headers) && preg_match('/^HTTP\\/\\d+\\.\\d+\\s+[23]\\d\\d\\s*.*$/', $headers[0]));
}
catch (\Exception $e)
{
// Something went wrong. Possibly:
// * Unable to open stream
// * Peer certificate did not match expected
$ok = false;
}
return $ok;
}
|
php
|
public function validate(Control $control): bool
{
$value = $control->getSubmittedValue();
// An empty value is valid.
if ($value==='' || $value===null || $value===false)
{
return true;
}
// Objects and arrays are not a valid http URL.
if (!is_scalar($value))
{
return false;
}
// Filter valid URL from the value.
$url = filter_var($value, FILTER_VALIDATE_URL);
// If the actual value and the filtered value are not equal the value is not a valid url.
if ($url!==$value)
{
return false;
}
// filter_var allows not to specify the HTTP protocol. Test the URL starts with http (or https).
if (substr($url, 0, 4)!=='http')
{
return false;
}
// Test that the page actually exits. We consider all HTTP 200-399 responses as valid.
try
{
$headers = get_headers($url);
$ok = (is_array($headers) && preg_match('/^HTTP\\/\\d+\\.\\d+\\s+[23]\\d\\d\\s*.*$/', $headers[0]));
}
catch (\Exception $e)
{
// Something went wrong. Possibly:
// * Unable to open stream
// * Peer certificate did not match expected
$ok = false;
}
return $ok;
}
|
[
"public",
"function",
"validate",
"(",
"Control",
"$",
"control",
")",
":",
"bool",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getSubmittedValue",
"(",
")",
";",
"// An empty value is valid.",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"true",
";",
"}",
"// Objects and arrays are not a valid http URL.",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Filter valid URL from the value.",
"$",
"url",
"=",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_URL",
")",
";",
"// If the actual value and the filtered value are not equal the value is not a valid url.",
"if",
"(",
"$",
"url",
"!==",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"// filter_var allows not to specify the HTTP protocol. Test the URL starts with http (or https).",
"if",
"(",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"4",
")",
"!==",
"'http'",
")",
"{",
"return",
"false",
";",
"}",
"// Test that the page actually exits. We consider all HTTP 200-399 responses as valid.",
"try",
"{",
"$",
"headers",
"=",
"get_headers",
"(",
"$",
"url",
")",
";",
"$",
"ok",
"=",
"(",
"is_array",
"(",
"$",
"headers",
")",
"&&",
"preg_match",
"(",
"'/^HTTP\\\\/\\\\d+\\\\.\\\\d+\\\\s+[23]\\\\d\\\\d\\\\s*.*$/'",
",",
"$",
"headers",
"[",
"0",
"]",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Something went wrong. Possibly:",
"// * Unable to open stream",
"// * Peer certificate did not match expected",
"$",
"ok",
"=",
"false",
";",
"}",
"return",
"$",
"ok",
";",
"}"
] |
Returns true if the value of the form control is a valid http URL.
Note:
* Empty values are considered valid.
* This validator will test if the URL actually exists.
@param Control $control The form control.
@return bool
@since 1.0.0
@api
|
[
"Returns",
"true",
"if",
"the",
"value",
"of",
"the",
"form",
"control",
"is",
"a",
"valid",
"http",
"URL",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Validator/HttpValidator.php#L28-L74
|
225,179
|
RevisionTen/cqrs
|
Services/MessageBus.php
|
MessageBus.dispatch
|
public function dispatch(Message $message): void
{
$this->messages[] = $message;
// Add message to debug log.
$context = $message->context ?? [];
$this->logger->debug($message->message, $context);
}
|
php
|
public function dispatch(Message $message): void
{
$this->messages[] = $message;
// Add message to debug log.
$context = $message->context ?? [];
$this->logger->debug($message->message, $context);
}
|
[
"public",
"function",
"dispatch",
"(",
"Message",
"$",
"message",
")",
":",
"void",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"$",
"message",
";",
"// Add message to debug log.",
"$",
"context",
"=",
"$",
"message",
"->",
"context",
"??",
"[",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"$",
"message",
"->",
"message",
",",
"$",
"context",
")",
";",
"}"
] |
Dispatches a Message to the Message Bus.
@param Message $message
|
[
"Dispatches",
"a",
"Message",
"to",
"the",
"Message",
"Bus",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/MessageBus.php#L38-L45
|
225,180
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.getAuthorizationUrl
|
public function getAuthorizationUrl($scopes = [])
{
$this->provider;
$authorizationUrl = $this->provider->getAuthorizationUrl([
'scope' => join(' ', $scopes)
]);
$_SESSION['oauth2_lockme_state'] = $this->provider->getState();
return $authorizationUrl;
}
|
php
|
public function getAuthorizationUrl($scopes = [])
{
$this->provider;
$authorizationUrl = $this->provider->getAuthorizationUrl([
'scope' => join(' ', $scopes)
]);
$_SESSION['oauth2_lockme_state'] = $this->provider->getState();
return $authorizationUrl;
}
|
[
"public",
"function",
"getAuthorizationUrl",
"(",
"$",
"scopes",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"provider",
";",
"$",
"authorizationUrl",
"=",
"$",
"this",
"->",
"provider",
"->",
"getAuthorizationUrl",
"(",
"[",
"'scope'",
"=>",
"join",
"(",
"' '",
",",
"$",
"scopes",
")",
"]",
")",
";",
"$",
"_SESSION",
"[",
"'oauth2_lockme_state'",
"]",
"=",
"$",
"this",
"->",
"provider",
"->",
"getState",
"(",
")",
";",
"return",
"$",
"authorizationUrl",
";",
"}"
] |
Generate authorization URL
@param array $scopes Array of requested scopes
@return string Redirect URL
|
[
"Generate",
"authorization",
"URL"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L38-L46
|
225,181
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.getTokenForCode
|
public function getTokenForCode($code, $state)
{
if ($state != $_SESSION['oauth2_lockme_state']) {
unset($_SESSION['oauth2_lockme_state']);
throw new \Exception("Wrong state");
}
unset($_SESSION['oauth2_lockme_state']);
$this->accessToken = $this->provider->getAccessToken('authorization_code', [
'code' => $code
]);
return $this->accessToken;
}
|
php
|
public function getTokenForCode($code, $state)
{
if ($state != $_SESSION['oauth2_lockme_state']) {
unset($_SESSION['oauth2_lockme_state']);
throw new \Exception("Wrong state");
}
unset($_SESSION['oauth2_lockme_state']);
$this->accessToken = $this->provider->getAccessToken('authorization_code', [
'code' => $code
]);
return $this->accessToken;
}
|
[
"public",
"function",
"getTokenForCode",
"(",
"$",
"code",
",",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"!=",
"$",
"_SESSION",
"[",
"'oauth2_lockme_state'",
"]",
")",
"{",
"unset",
"(",
"$",
"_SESSION",
"[",
"'oauth2_lockme_state'",
"]",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Wrong state\"",
")",
";",
"}",
"unset",
"(",
"$",
"_SESSION",
"[",
"'oauth2_lockme_state'",
"]",
")",
";",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"this",
"->",
"provider",
"->",
"getAccessToken",
"(",
"'authorization_code'",
",",
"[",
"'code'",
"=>",
"$",
"code",
"]",
")",
";",
"return",
"$",
"this",
"->",
"accessToken",
";",
"}"
] |
Get Access token from AuthCode
@param string $code AuthCode
@param string $state State code
@return AccessToken Access Token
@throws \Exception
|
[
"Get",
"Access",
"token",
"from",
"AuthCode"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L55-L67
|
225,182
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.refreshToken
|
public function refreshToken($accessToken = null)
{
$accessToken = $accessToken ?: $this->accessToken;
$this->accessToken = $this->provider->getAccessToken('refresh_token', [
'refresh_token' => $accessToken->getRefreshToken()
]);
return $this->accessToken;
}
|
php
|
public function refreshToken($accessToken = null)
{
$accessToken = $accessToken ?: $this->accessToken;
$this->accessToken = $this->provider->getAccessToken('refresh_token', [
'refresh_token' => $accessToken->getRefreshToken()
]);
return $this->accessToken;
}
|
[
"public",
"function",
"refreshToken",
"(",
"$",
"accessToken",
"=",
"null",
")",
"{",
"$",
"accessToken",
"=",
"$",
"accessToken",
"?",
":",
"$",
"this",
"->",
"accessToken",
";",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"this",
"->",
"provider",
"->",
"getAccessToken",
"(",
"'refresh_token'",
",",
"[",
"'refresh_token'",
"=>",
"$",
"accessToken",
"->",
"getRefreshToken",
"(",
")",
"]",
")",
";",
"return",
"$",
"this",
"->",
"accessToken",
";",
"}"
] |
Refresh access token
@param AccessToken|null $accessToken Access token
@return AccessToken Refreshed token
|
[
"Refresh",
"access",
"token"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L74-L81
|
225,183
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.setDefaultAccessToken
|
public function setDefaultAccessToken($token)
{
if (is_string($token)) {
$this->accessToken = new AccessToken(json_decode($token, true));
} elseif ($token instanceof AccessToken) {
$this->accessToken = $token;
} else {
throw new \Exception("Incorrect access token");
}
if ($this->accessToken->hasExpired()) {
$this->refreshToken();
}
return $this->accessToken;
}
|
php
|
public function setDefaultAccessToken($token)
{
if (is_string($token)) {
$this->accessToken = new AccessToken(json_decode($token, true));
} elseif ($token instanceof AccessToken) {
$this->accessToken = $token;
} else {
throw new \Exception("Incorrect access token");
}
if ($this->accessToken->hasExpired()) {
$this->refreshToken();
}
return $this->accessToken;
}
|
[
"public",
"function",
"setDefaultAccessToken",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"token",
")",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"new",
"AccessToken",
"(",
"json_decode",
"(",
"$",
"token",
",",
"true",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"token",
"instanceof",
"AccessToken",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"token",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Incorrect access token\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"accessToken",
"->",
"hasExpired",
"(",
")",
")",
"{",
"$",
"this",
"->",
"refreshToken",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"accessToken",
";",
"}"
] |
Create default access token
@param string|AccessToken $token Default access token
@return AccessToken
@throws \Exception
|
[
"Create",
"default",
"access",
"token"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L89-L102
|
225,184
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.Reservation
|
public function Reservation($roomId, $id, $accessToken = null)
{
return $this->provider->executeRequest("GET", "/room/{$roomId}/reservation/{$id}", $accessToken ?: $this->accessToken);
}
|
php
|
public function Reservation($roomId, $id, $accessToken = null)
{
return $this->provider->executeRequest("GET", "/room/{$roomId}/reservation/{$id}", $accessToken ?: $this->accessToken);
}
|
[
"public",
"function",
"Reservation",
"(",
"$",
"roomId",
",",
"$",
"id",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"provider",
"->",
"executeRequest",
"(",
"\"GET\"",
",",
"\"/room/{$roomId}/reservation/{$id}\"",
",",
"$",
"accessToken",
"?",
":",
"$",
"this",
"->",
"accessToken",
")",
";",
"}"
] |
Get reservation data
@param int $roomId Room ID
@param string $id Reservation ID
@param string|AccessToken|null $accessToken Access token
@return array
|
[
"Get",
"reservation",
"data"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L131-L134
|
225,185
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.AddReservation
|
public function AddReservation($data, $accessToken = null)
{
if (!$data['roomid']) {
throw new \Exception("No room ID");
}
if (!$data["date"]) {
throw new \Exception("No date");
}
if (!$data["hour"]) {
throw new \Exception("No hour");
}
return $this->provider->executeRequest("PUT", "/room/{$data['roomid']}/reservation", $accessToken ?: $this->accessToken, $data);
}
|
php
|
public function AddReservation($data, $accessToken = null)
{
if (!$data['roomid']) {
throw new \Exception("No room ID");
}
if (!$data["date"]) {
throw new \Exception("No date");
}
if (!$data["hour"]) {
throw new \Exception("No hour");
}
return $this->provider->executeRequest("PUT", "/room/{$data['roomid']}/reservation", $accessToken ?: $this->accessToken, $data);
}
|
[
"public",
"function",
"AddReservation",
"(",
"$",
"data",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"[",
"'roomid'",
"]",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No room ID\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"data",
"[",
"\"date\"",
"]",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No date\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"data",
"[",
"\"hour\"",
"]",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No hour\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"provider",
"->",
"executeRequest",
"(",
"\"PUT\"",
",",
"\"/room/{$data['roomid']}/reservation\"",
",",
"$",
"accessToken",
"?",
":",
"$",
"this",
"->",
"accessToken",
",",
"$",
"data",
")",
";",
"}"
] |
Add new reservation
@param array $data Reservation data
@param string|AccessToken|null $accessToken Access token
@return int
@throws \Exception
|
[
"Add",
"new",
"reservation"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L143-L155
|
225,186
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.GetMessage
|
public function GetMessage($messageId, $accessToken = null)
{
return $this->provider->executeRequest("GET", "/message/{$messageId}", $accessToken ?: $this->accessToken);
}
|
php
|
public function GetMessage($messageId, $accessToken = null)
{
return $this->provider->executeRequest("GET", "/message/{$messageId}", $accessToken ?: $this->accessToken);
}
|
[
"public",
"function",
"GetMessage",
"(",
"$",
"messageId",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"provider",
"->",
"executeRequest",
"(",
"\"GET\"",
",",
"\"/message/{$messageId}\"",
",",
"$",
"accessToken",
"?",
":",
"$",
"this",
"->",
"accessToken",
")",
";",
"}"
] |
Get callback message details
@param int $messageId Message ID
@param null $accessToken
@return array
|
[
"Get",
"callback",
"message",
"details"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L221-L224
|
225,187
|
Lustmored/lockme-sdk
|
src/Lockme.php
|
Lockme.MarkMessageRead
|
public function MarkMessageRead($messageId, $accessToken = null)
{
return $this->provider->executeRequest("POST", "/message/{$messageId}", $accessToken ?: $this->accessToken);
}
|
php
|
public function MarkMessageRead($messageId, $accessToken = null)
{
return $this->provider->executeRequest("POST", "/message/{$messageId}", $accessToken ?: $this->accessToken);
}
|
[
"public",
"function",
"MarkMessageRead",
"(",
"$",
"messageId",
",",
"$",
"accessToken",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"provider",
"->",
"executeRequest",
"(",
"\"POST\"",
",",
"\"/message/{$messageId}\"",
",",
"$",
"accessToken",
"?",
":",
"$",
"this",
"->",
"accessToken",
")",
";",
"}"
] |
Mark callback message as read
@param int $messageId Message ID
@param null $accessToken
@return bool
|
[
"Mark",
"callback",
"message",
"as",
"read"
] |
e8c604e85153cb74f0bccde54f702fb6f9006fd0
|
https://github.com/Lustmored/lockme-sdk/blob/e8c604e85153cb74f0bccde54f702fb6f9006fd0/src/Lockme.php#L232-L235
|
225,188
|
SetBased/php-abc-table-overview
|
src/TableColumn/DualTableColumn.php
|
DualTableColumn.sortOrder1
|
public function sortOrder1(int $sortOrder, bool $descendingFlag = false): void
{
$this->sortDirection = ($descendingFlag) ? 'desc' : 'asc';
$this->sortOrder = $sortOrder;
}
|
php
|
public function sortOrder1(int $sortOrder, bool $descendingFlag = false): void
{
$this->sortDirection = ($descendingFlag) ? 'desc' : 'asc';
$this->sortOrder = $sortOrder;
}
|
[
"public",
"function",
"sortOrder1",
"(",
"int",
"$",
"sortOrder",
",",
"bool",
"$",
"descendingFlag",
"=",
"false",
")",
":",
"void",
"{",
"$",
"this",
"->",
"sortDirection",
"=",
"(",
"$",
"descendingFlag",
")",
"?",
"'desc'",
":",
"'asc'",
";",
"$",
"this",
"->",
"sortOrder",
"=",
"$",
"sortOrder",
";",
"}"
] |
Sets the sorting order of the first table column.
@param int $sortOrder The sorting order.
@param bool $descendingFlag If set the data is sorted descending, otherwise ascending.
|
[
"Sets",
"the",
"sorting",
"order",
"of",
"the",
"first",
"table",
"column",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/TableColumn/DualTableColumn.php#L175-L179
|
225,189
|
SetBased/php-abc-table-overview
|
src/TableColumn/DualTableColumn.php
|
DualTableColumn.sortOrder2
|
public function sortOrder2(int $sortOrder, bool $descendingFlag = false): void
{
$this->sortDirection2 = ($descendingFlag) ? 'desc' : 'asc';
$this->sortOrder2 = $sortOrder;
}
|
php
|
public function sortOrder2(int $sortOrder, bool $descendingFlag = false): void
{
$this->sortDirection2 = ($descendingFlag) ? 'desc' : 'asc';
$this->sortOrder2 = $sortOrder;
}
|
[
"public",
"function",
"sortOrder2",
"(",
"int",
"$",
"sortOrder",
",",
"bool",
"$",
"descendingFlag",
"=",
"false",
")",
":",
"void",
"{",
"$",
"this",
"->",
"sortDirection2",
"=",
"(",
"$",
"descendingFlag",
")",
"?",
"'desc'",
":",
"'asc'",
";",
"$",
"this",
"->",
"sortOrder2",
"=",
"$",
"sortOrder",
";",
"}"
] |
Sets the sorting order of second table column.
@param int $sortOrder The sorting order.
@param bool $descendingFlag If set the data is sorted descending, otherwise ascending.
|
[
"Sets",
"the",
"sorting",
"order",
"of",
"second",
"table",
"column",
"."
] |
1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a
|
https://github.com/SetBased/php-abc-table-overview/blob/1cdbd1c9e9ff972af3b2f7b622f9f2da8f301d9a/src/TableColumn/DualTableColumn.php#L188-L192
|
225,190
|
RevisionTen/cqrs
|
Services/CommandBus.php
|
CommandBus.dispatch
|
public function dispatch(CommandInterface $command, bool $qeueEvents = false): void
{
try {
if ($command instanceof CommandInterface) {
// Reset aggregates.
$this->aggregates = [];
/**
* Get Handler for Command.
*
* @var HandlerInterface $handler
*/
$handlerClass = $command->getHandlerClass();
$handler = new $handlerClass($this->messageBus, $this->aggregateFactory);
if ($handler instanceof HandlerInterface) {
// Invoke Handler.
$handler($command, $this->aggregates);
// Check for events on aggregates, pass them to EventBus#publish()
$events = [];
/** @var AggregateInterface $aggregate */
foreach ($this->aggregates as $aggregate) {
/** @var array $pendingEvents */
$pendingEvents = $aggregate->getPendingEvents();
$events += $pendingEvents;
}
$this->eventBus->publish($events, $this, $qeueEvents);
} else {
throw new InterfaceException(\get_class($handler).' must implement '.HandlerInterface::class);
}
} else {
throw new InterfaceException(\get_class($command).' must implement '.CommandInterface::class);
}
} catch (InterfaceException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
$command->getUuid(),
$command->getAggregateUuid(),
$e
));
}
}
|
php
|
public function dispatch(CommandInterface $command, bool $qeueEvents = false): void
{
try {
if ($command instanceof CommandInterface) {
// Reset aggregates.
$this->aggregates = [];
/**
* Get Handler for Command.
*
* @var HandlerInterface $handler
*/
$handlerClass = $command->getHandlerClass();
$handler = new $handlerClass($this->messageBus, $this->aggregateFactory);
if ($handler instanceof HandlerInterface) {
// Invoke Handler.
$handler($command, $this->aggregates);
// Check for events on aggregates, pass them to EventBus#publish()
$events = [];
/** @var AggregateInterface $aggregate */
foreach ($this->aggregates as $aggregate) {
/** @var array $pendingEvents */
$pendingEvents = $aggregate->getPendingEvents();
$events += $pendingEvents;
}
$this->eventBus->publish($events, $this, $qeueEvents);
} else {
throw new InterfaceException(\get_class($handler).' must implement '.HandlerInterface::class);
}
} else {
throw new InterfaceException(\get_class($command).' must implement '.CommandInterface::class);
}
} catch (InterfaceException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
$command->getUuid(),
$command->getAggregateUuid(),
$e
));
}
}
|
[
"public",
"function",
"dispatch",
"(",
"CommandInterface",
"$",
"command",
",",
"bool",
"$",
"qeueEvents",
"=",
"false",
")",
":",
"void",
"{",
"try",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"CommandInterface",
")",
"{",
"// Reset aggregates.",
"$",
"this",
"->",
"aggregates",
"=",
"[",
"]",
";",
"/**\n * Get Handler for Command.\n *\n * @var HandlerInterface $handler\n */",
"$",
"handlerClass",
"=",
"$",
"command",
"->",
"getHandlerClass",
"(",
")",
";",
"$",
"handler",
"=",
"new",
"$",
"handlerClass",
"(",
"$",
"this",
"->",
"messageBus",
",",
"$",
"this",
"->",
"aggregateFactory",
")",
";",
"if",
"(",
"$",
"handler",
"instanceof",
"HandlerInterface",
")",
"{",
"// Invoke Handler.",
"$",
"handler",
"(",
"$",
"command",
",",
"$",
"this",
"->",
"aggregates",
")",
";",
"// Check for events on aggregates, pass them to EventBus#publish()",
"$",
"events",
"=",
"[",
"]",
";",
"/** @var AggregateInterface $aggregate */",
"foreach",
"(",
"$",
"this",
"->",
"aggregates",
"as",
"$",
"aggregate",
")",
"{",
"/** @var array $pendingEvents */",
"$",
"pendingEvents",
"=",
"$",
"aggregate",
"->",
"getPendingEvents",
"(",
")",
";",
"$",
"events",
"+=",
"$",
"pendingEvents",
";",
"}",
"$",
"this",
"->",
"eventBus",
"->",
"publish",
"(",
"$",
"events",
",",
"$",
"this",
",",
"$",
"qeueEvents",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InterfaceException",
"(",
"\\",
"get_class",
"(",
"$",
"handler",
")",
".",
"' must implement '",
".",
"HandlerInterface",
"::",
"class",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"InterfaceException",
"(",
"\\",
"get_class",
"(",
"$",
"command",
")",
".",
"' must implement '",
".",
"CommandInterface",
"::",
"class",
")",
";",
"}",
"}",
"catch",
"(",
"InterfaceException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"command",
"->",
"getUuid",
"(",
")",
",",
"$",
"command",
"->",
"getAggregateUuid",
"(",
")",
",",
"$",
"e",
")",
")",
";",
"}",
"}"
] |
This function is used to dispatch a provided Command.
@param CommandInterface $command
@param bool $qeueEvents
|
[
"This",
"function",
"is",
"used",
"to",
"dispatch",
"a",
"provided",
"Command",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/CommandBus.php#L55-L101
|
225,191
|
sopinetchat/SopinetChatBundle
|
Entity/Chat.php
|
Chat.getDevices
|
public function getDevices()
{
$devices = array();
foreach ($this->getChatMembers() as $chatMember) {
/* @var $chatMember User */
// Devices to Array
$devicesObject = $chatMember->getDevices();
foreach ($devicesObject as $do) {
$devices[] = $do;
}
}
return $devices;
}
|
php
|
public function getDevices()
{
$devices = array();
foreach ($this->getChatMembers() as $chatMember) {
/* @var $chatMember User */
// Devices to Array
$devicesObject = $chatMember->getDevices();
foreach ($devicesObject as $do) {
$devices[] = $do;
}
}
return $devices;
}
|
[
"public",
"function",
"getDevices",
"(",
")",
"{",
"$",
"devices",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getChatMembers",
"(",
")",
"as",
"$",
"chatMember",
")",
"{",
"/* @var $chatMember User */",
"// Devices to Array",
"$",
"devicesObject",
"=",
"$",
"chatMember",
"->",
"getDevices",
"(",
")",
";",
"foreach",
"(",
"$",
"devicesObject",
"as",
"$",
"do",
")",
"{",
"$",
"devices",
"[",
"]",
"=",
"$",
"do",
";",
"}",
"}",
"return",
"$",
"devices",
";",
"}"
] |
Devuelve los dispositivos de todos los usuarios
vinculados al Chat
@return array|bool
|
[
"Devuelve",
"los",
"dispositivos",
"de",
"todos",
"los",
"usuarios",
"vinculados",
"al",
"Chat"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Entity/Chat.php#L304-L317
|
225,192
|
php-toolkit/str-utils
|
src/Token.php
|
Token.verify
|
public static function verify(string $hash, string $password): bool
{
return \hash_equals($hash, \crypt($password, $hash));
}
|
php
|
public static function verify(string $hash, string $password): bool
{
return \hash_equals($hash, \crypt($password, $hash));
}
|
[
"public",
"static",
"function",
"verify",
"(",
"string",
"$",
"hash",
",",
"string",
"$",
"password",
")",
":",
"bool",
"{",
"return",
"\\",
"hash_equals",
"(",
"$",
"hash",
",",
"\\",
"crypt",
"(",
"$",
"password",
",",
"$",
"hash",
")",
")",
";",
"}"
] |
this will be used to compare a password against a hash
@param string $hash
@param string $password the user input
@return bool
|
[
"this",
"will",
"be",
"used",
"to",
"compare",
"a",
"password",
"against",
"a",
"hash"
] |
2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278
|
https://github.com/php-toolkit/str-utils/blob/2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278/src/Token.php#L103-L106
|
225,193
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.info
|
public function info($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelInfo(), $message, $throwable);
}
|
php
|
public function info($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelInfo(), $message, $throwable);
}
|
[
"public",
"function",
"info",
"(",
"$",
"message",
",",
"$",
"throwable",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"getLevelInfo",
"(",
")",
",",
"$",
"message",
",",
"$",
"throwable",
")",
";",
"}"
] |
Log a message object with the INFO Level.
@param mixed $message message
@param Exception $throwable Optional throwable information to include
in the logging event.
|
[
"Log",
"a",
"message",
"object",
"with",
"the",
"INFO",
"Level",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L127-L129
|
225,194
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.error
|
public function error($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelError(), $message, $throwable);
}
|
php
|
public function error($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelError(), $message, $throwable);
}
|
[
"public",
"function",
"error",
"(",
"$",
"message",
",",
"$",
"throwable",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"getLevelError",
"(",
")",
",",
"$",
"message",
",",
"$",
"throwable",
")",
";",
"}"
] |
Log a message object with the ERROR level.
@param mixed $message message
@param Exception $throwable Optional throwable information to include
in the logging event.
|
[
"Log",
"a",
"message",
"object",
"with",
"the",
"ERROR",
"level",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L149-L151
|
225,195
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.fatal
|
public function fatal($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelFatal(), $message, $throwable);
}
|
php
|
public function fatal($message, $throwable = null) {
$this->log(\n2n\log4php\LoggerLevel::getLevelFatal(), $message, $throwable);
}
|
[
"public",
"function",
"fatal",
"(",
"$",
"message",
",",
"$",
"throwable",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"getLevelFatal",
"(",
")",
",",
"$",
"message",
",",
"$",
"throwable",
")",
";",
"}"
] |
Log a message object with the FATAL level.
@param mixed $message message
@param Exception $throwable Optional throwable information to include
in the logging event.
|
[
"Log",
"a",
"message",
"object",
"with",
"the",
"FATAL",
"level",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L160-L162
|
225,196
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.log
|
public function log(\n2n\log4php\LoggerLevel $level, $message, $throwable = null) {
if($this->isEnabledFor($level)) {
$event = new \n2n\log4php\logging\LoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
$this->callAppenders($event);
}
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
// Use the event if already created
if (isset($event)) {
$this->parent->logEvent($event);
} else {
$this->parent->log($level, $message, $throwable);
}
}
}
|
php
|
public function log(\n2n\log4php\LoggerLevel $level, $message, $throwable = null) {
if($this->isEnabledFor($level)) {
$event = new \n2n\log4php\logging\LoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
$this->callAppenders($event);
}
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
// Use the event if already created
if (isset($event)) {
$this->parent->logEvent($event);
} else {
$this->parent->log($level, $message, $throwable);
}
}
}
|
[
"public",
"function",
"log",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"$",
"level",
",",
"$",
"message",
",",
"$",
"throwable",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabledFor",
"(",
"$",
"level",
")",
")",
"{",
"$",
"event",
"=",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"(",
"$",
"this",
"->",
"fqcn",
",",
"$",
"this",
",",
"$",
"level",
",",
"$",
"message",
",",
"null",
",",
"$",
"throwable",
")",
";",
"$",
"this",
"->",
"callAppenders",
"(",
"$",
"event",
")",
";",
"}",
"// Forward the event upstream if additivity is turned on\r",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
")",
"&&",
"$",
"this",
"->",
"getAdditivity",
"(",
")",
")",
"{",
"// Use the event if already created\r",
"if",
"(",
"isset",
"(",
"$",
"event",
")",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"logEvent",
"(",
"$",
"event",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"parent",
"->",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"throwable",
")",
";",
"}",
"}",
"}"
] |
Log a message using the provided logging level.
@param \n2n\log4php\LoggerLevel $level The logging level.
@param mixed $message Message to log.
@param Exception $throwable Optional throwable information to include
in the logging event.
|
[
"Log",
"a",
"message",
"using",
"the",
"provided",
"logging",
"level",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L172-L188
|
225,197
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.logEvent
|
public function logEvent(\n2n\log4php\logging\LoggingEvent $event) {
if($this->isEnabledFor($event->getLevel())) {
$this->callAppenders($event);
}
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
$this->parent->logEvent($event);
}
}
|
php
|
public function logEvent(\n2n\log4php\logging\LoggingEvent $event) {
if($this->isEnabledFor($event->getLevel())) {
$this->callAppenders($event);
}
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
$this->parent->logEvent($event);
}
}
|
[
"public",
"function",
"logEvent",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabledFor",
"(",
"$",
"event",
"->",
"getLevel",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"callAppenders",
"(",
"$",
"event",
")",
";",
"}",
"// Forward the event upstream if additivity is turned on\r",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
")",
"&&",
"$",
"this",
"->",
"getAdditivity",
"(",
")",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"logEvent",
"(",
"$",
"event",
")",
";",
"}",
"}"
] |
Logs an already prepared logging event object.
@param \n2n\log4php\logging\LoggingEvent $event
|
[
"Logs",
"an",
"already",
"prepared",
"logging",
"event",
"object",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L194-L203
|
225,198
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.forcedLog
|
public function forcedLog($fqcn, $throwable, \n2n\log4php\LoggerLevel $level, $message) {
$event = new \n2n\log4php\logging\LoggingEvent($fqcn, $this, $level, $message, null, $throwable);
$this->callAppenders($event);
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
$this->parent->logEvent($event);
}
}
|
php
|
public function forcedLog($fqcn, $throwable, \n2n\log4php\LoggerLevel $level, $message) {
$event = new \n2n\log4php\logging\LoggingEvent($fqcn, $this, $level, $message, null, $throwable);
$this->callAppenders($event);
// Forward the event upstream if additivity is turned on
if(isset($this->parent) && $this->getAdditivity()) {
$this->parent->logEvent($event);
}
}
|
[
"public",
"function",
"forcedLog",
"(",
"$",
"fqcn",
",",
"$",
"throwable",
",",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"$",
"level",
",",
"$",
"message",
")",
"{",
"$",
"event",
"=",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"(",
"$",
"fqcn",
",",
"$",
"this",
",",
"$",
"level",
",",
"$",
"message",
",",
"null",
",",
"$",
"throwable",
")",
";",
"$",
"this",
"->",
"callAppenders",
"(",
"$",
"event",
")",
";",
"// Forward the event upstream if additivity is turned on\r",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parent",
")",
"&&",
"$",
"this",
"->",
"getAdditivity",
"(",
")",
")",
"{",
"$",
"this",
"->",
"parent",
"->",
"logEvent",
"(",
"$",
"event",
")",
";",
"}",
"}"
] |
This method creates a new logging event and logs the event without
further checks.
It should not be called directly. Use {@link trace()}, {@link debug()},
{@link info()}, {@link warn()}, {@link error()} and {@link fatal()}
wrappers.
@param string $fqcn Fully qualified class name of the Logger
@param Exception $throwable Optional throwable information to include
in the logging event.
@param \n2n\log4php\LoggerLevel $level log level
@param mixed $message message to log
|
[
"This",
"method",
"creates",
"a",
"new",
"logging",
"event",
"and",
"logs",
"the",
"event",
"without",
"further",
"checks",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L232-L240
|
225,199
|
n2n/n2n-log4php
|
src/app/n2n/log4php/Logger.php
|
Logger.isAttached
|
public function isAttached(\n2n\log4php\LoggerAppender $appender) {
return isset($this->appenders[$appender->getName()]);
}
|
php
|
public function isAttached(\n2n\log4php\LoggerAppender $appender) {
return isset($this->appenders[$appender->getName()]);
}
|
[
"public",
"function",
"isAttached",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerAppender",
"$",
"appender",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"appenders",
"[",
"$",
"appender",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}"
] |
Checks whether an appender is attached to this logger instance.
@param \n2n\log4php\LoggerAppender $appender
@return boolean
|
[
"Checks",
"whether",
"an",
"appender",
"is",
"attached",
"to",
"this",
"logger",
"instance",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L419-L421
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.