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
|
---|---|---|---|---|---|---|---|---|---|---|---|
13,500 | ronan-gloo/jade-php | src/Jade/Lexer.php | Lexer.scan | protected function scan($regex, $type)
{
if (preg_match($regex, $this->input, $matches)) {
$this->consume($matches[0]);
return $this->token($type, isset($matches[1]) && mb_strlen($matches[1]) > 0 ? $matches[1] : '');
}
} | php | protected function scan($regex, $type)
{
if (preg_match($regex, $this->input, $matches)) {
$this->consume($matches[0]);
return $this->token($type, isset($matches[1]) && mb_strlen($matches[1]) > 0 ? $matches[1] : '');
}
} | [
"protected",
"function",
"scan",
"(",
"$",
"regex",
",",
"$",
"type",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"this",
"->",
"input",
",",
"$",
"matches",
")",
")",
"{",
"$",
"this",
"->",
"consume",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"return",
"$",
"this",
"->",
"token",
"(",
"$",
"type",
",",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
"&&",
"mb_strlen",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
">",
"0",
"?",
"$",
"matches",
"[",
"1",
"]",
":",
"''",
")",
";",
"}",
"}"
]
| Helper to create tokens | [
"Helper",
"to",
"create",
"tokens"
]
| 77230d2eef2f0d4f045292a5906162f0c0499421 | https://github.com/ronan-gloo/jade-php/blob/77230d2eef2f0d4f045292a5906162f0c0499421/src/Jade/Lexer.php#L111-L118 |
13,501 | ronan-gloo/jade-php | src/Jade/Lexer.php | Lexer.lookahead | public function lookahead($number = 1)
{
$fetch = $number - count($this->stash);
while ($fetch-- > 0) {
$this->stash[] = $this->next();
}
return $this->stash[--$number];
} | php | public function lookahead($number = 1)
{
$fetch = $number - count($this->stash);
while ($fetch-- > 0) {
$this->stash[] = $this->next();
}
return $this->stash[--$number];
} | [
"public",
"function",
"lookahead",
"(",
"$",
"number",
"=",
"1",
")",
"{",
"$",
"fetch",
"=",
"$",
"number",
"-",
"count",
"(",
"$",
"this",
"->",
"stash",
")",
";",
"while",
"(",
"$",
"fetch",
"--",
">",
"0",
")",
"{",
"$",
"this",
"->",
"stash",
"[",
"]",
"=",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stash",
"[",
"--",
"$",
"number",
"]",
";",
"}"
]
| Lookahead token 'n'.
@param integer $number number of tokens to predict
@return Object predicted token | [
"Lookahead",
"token",
"n",
"."
]
| 77230d2eef2f0d4f045292a5906162f0c0499421 | https://github.com/ronan-gloo/jade-php/blob/77230d2eef2f0d4f045292a5906162f0c0499421/src/Jade/Lexer.php#L137-L146 |
13,502 | ronan-gloo/jade-php | src/Jade/Lexer.php | Lexer.scanEOS | protected function scanEOS()
{
if (!$this->length()) {
if (count($this->indentStack)) {
array_shift($this->indentStack);
return $this->token('outdent');
}
return $this->token('eos');
}
} | php | protected function scanEOS()
{
if (!$this->length()) {
if (count($this->indentStack)) {
array_shift($this->indentStack);
return $this->token('outdent');
}
return $this->token('eos');
}
} | [
"protected",
"function",
"scanEOS",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"length",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"indentStack",
")",
")",
"{",
"array_shift",
"(",
"$",
"this",
"->",
"indentStack",
")",
";",
"return",
"$",
"this",
"->",
"token",
"(",
"'outdent'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"token",
"(",
"'eos'",
")",
";",
"}",
"}"
]
| Scan EOS from input & return it if found.
@return Object|null | [
"Scan",
"EOS",
"from",
"input",
"&",
"return",
"it",
"if",
"found",
"."
]
| 77230d2eef2f0d4f045292a5906162f0c0499421 | https://github.com/ronan-gloo/jade-php/blob/77230d2eef2f0d4f045292a5906162f0c0499421/src/Jade/Lexer.php#L196-L208 |
13,503 | ronan-gloo/jade-php | src/Jade/Lexer.php | Lexer.scanComment | protected function scanComment()
{
if (preg_match('/^ *\/\/(-)?([^\n]*)/', $this->input, $matches)) {
$this->consume($matches[0]);
$token = $this->token('comment', isset($matches[2]) ? $matches[2] : '');
$token->buffer = '-' !== $matches[1];
return $token;
}
} | php | protected function scanComment()
{
if (preg_match('/^ *\/\/(-)?([^\n]*)/', $this->input, $matches)) {
$this->consume($matches[0]);
$token = $this->token('comment', isset($matches[2]) ? $matches[2] : '');
$token->buffer = '-' !== $matches[1];
return $token;
}
} | [
"protected",
"function",
"scanComment",
"(",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^ *\\/\\/(-)?([^\\n]*)/'",
",",
"$",
"this",
"->",
"input",
",",
"$",
"matches",
")",
")",
"{",
"$",
"this",
"->",
"consume",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"token",
"(",
"'comment'",
",",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"$",
"matches",
"[",
"2",
"]",
":",
"''",
")",
";",
"$",
"token",
"->",
"buffer",
"=",
"'-'",
"!==",
"$",
"matches",
"[",
"1",
"]",
";",
"return",
"$",
"token",
";",
"}",
"}"
]
| Scan comment from input & return it if found.
@return Object|null | [
"Scan",
"comment",
"from",
"input",
"&",
"return",
"it",
"if",
"found",
"."
]
| 77230d2eef2f0d4f045292a5906162f0c0499421 | https://github.com/ronan-gloo/jade-php/blob/77230d2eef2f0d4f045292a5906162f0c0499421/src/Jade/Lexer.php#L233-L242 |
13,504 | antarestupin/Accessible | lib/Accessible/Reader/ConstraintsReader.php | ConstraintsReader.isConstraintsValidationEnabled | public static function isConstraintsValidationEnabled($objectClasses, $annotationReader)
{
$enabled = Configuration::isConstraintsValidationEnabled();
foreach ($objectClasses as $class) {
if ($annotationReader->getClassAnnotation($class, self::$disableConstraintsValidationAnnotationClass) !== null) {
$enabled = false;
break;
}
if ($annotationReader->getClassAnnotation($class, self::$enableConstraintsValidationAnnotationClass) !== null) {
$enabled = true;
break;
}
}
return $enabled;
} | php | public static function isConstraintsValidationEnabled($objectClasses, $annotationReader)
{
$enabled = Configuration::isConstraintsValidationEnabled();
foreach ($objectClasses as $class) {
if ($annotationReader->getClassAnnotation($class, self::$disableConstraintsValidationAnnotationClass) !== null) {
$enabled = false;
break;
}
if ($annotationReader->getClassAnnotation($class, self::$enableConstraintsValidationAnnotationClass) !== null) {
$enabled = true;
break;
}
}
return $enabled;
} | [
"public",
"static",
"function",
"isConstraintsValidationEnabled",
"(",
"$",
"objectClasses",
",",
"$",
"annotationReader",
")",
"{",
"$",
"enabled",
"=",
"Configuration",
"::",
"isConstraintsValidationEnabled",
"(",
")",
";",
"foreach",
"(",
"$",
"objectClasses",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"annotationReader",
"->",
"getClassAnnotation",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"disableConstraintsValidationAnnotationClass",
")",
"!==",
"null",
")",
"{",
"$",
"enabled",
"=",
"false",
";",
"break",
";",
"}",
"if",
"(",
"$",
"annotationReader",
"->",
"getClassAnnotation",
"(",
"$",
"class",
",",
"self",
"::",
"$",
"enableConstraintsValidationAnnotationClass",
")",
"!==",
"null",
")",
"{",
"$",
"enabled",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"$",
"enabled",
";",
"}"
]
| Indicates wether the constraints validation is enabled or not for the given object.
@param array $objectClasses The classes of the object to read.
@param \Doctrine\Common\Annotations\Reader $annotationReader The annotation reader to use.
@return boolean True if the validation is enabled, else false. | [
"Indicates",
"wether",
"the",
"constraints",
"validation",
"is",
"enabled",
"or",
"not",
"for",
"the",
"given",
"object",
"."
]
| d12ce93d72f74c099dfd2109371fcd6ddfffdca4 | https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/ConstraintsReader.php#L31-L47 |
13,505 | antarestupin/Accessible | lib/Accessible/Reader/ConstraintsReader.php | ConstraintsReader.validatePropertyValue | public static function validatePropertyValue($object, $property, $value)
{
return Configuration::getConstraintsValidator()->validatePropertyValue($object, $property, $value);
} | php | public static function validatePropertyValue($object, $property, $value)
{
return Configuration::getConstraintsValidator()->validatePropertyValue($object, $property, $value);
} | [
"public",
"static",
"function",
"validatePropertyValue",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"return",
"Configuration",
"::",
"getConstraintsValidator",
"(",
")",
"->",
"validatePropertyValue",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"value",
")",
";",
"}"
]
| Validates the given value compared to given property constraints.
If the value is valid, a call to `count` to the object returned
by this method should give 0.
@param object $object The object to compare.
@param string $property The name of the reference property.
@param mixed $value The value to check.
@return Symfony\Component\Validator\ConstraintViolationList
The list of constraints violations the check returns. | [
"Validates",
"the",
"given",
"value",
"compared",
"to",
"given",
"property",
"constraints",
".",
"If",
"the",
"value",
"is",
"valid",
"a",
"call",
"to",
"count",
"to",
"the",
"object",
"returned",
"by",
"this",
"method",
"should",
"give",
"0",
"."
]
| d12ce93d72f74c099dfd2109371fcd6ddfffdca4 | https://github.com/antarestupin/Accessible/blob/d12ce93d72f74c099dfd2109371fcd6ddfffdca4/lib/Accessible/Reader/ConstraintsReader.php#L61-L64 |
13,506 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.onBeforeWrite | protected function onBeforeWrite() {
parent::onBeforeWrite();
// Changes in 2.4 mean that $this->Content can now become polluted with UTF-8 HTML entitised garbage
// we'll leave this legacy conversion in for now?
$this->Content = str_replace(' ', '', $this->Content);
$formatter = $this->getFormatter();
$formatter->analyseSavedContent($this);
// set a lock expiry in the past if there's not one already set
if (!$this->WikiLockExpiry) {
$this->WikiLockExpiry = date('Y-m-d H:i:s');
}
// Make sure to set the last editor to the current user
if (Member::currentUser()) {
$this->WikiLastEditor = Member::currentUser()->Email;
}
} | php | protected function onBeforeWrite() {
parent::onBeforeWrite();
// Changes in 2.4 mean that $this->Content can now become polluted with UTF-8 HTML entitised garbage
// we'll leave this legacy conversion in for now?
$this->Content = str_replace(' ', '', $this->Content);
$formatter = $this->getFormatter();
$formatter->analyseSavedContent($this);
// set a lock expiry in the past if there's not one already set
if (!$this->WikiLockExpiry) {
$this->WikiLockExpiry = date('Y-m-d H:i:s');
}
// Make sure to set the last editor to the current user
if (Member::currentUser()) {
$this->WikiLastEditor = Member::currentUser()->Email;
}
} | [
"protected",
"function",
"onBeforeWrite",
"(",
")",
"{",
"parent",
"::",
"onBeforeWrite",
"(",
")",
";",
"// Changes in 2.4 mean that $this->Content can now become polluted with UTF-8 HTML entitised garbage",
"// we'll leave this legacy conversion in for now?",
"$",
"this",
"->",
"Content",
"=",
"str_replace",
"(",
"' '",
",",
"''",
",",
"$",
"this",
"->",
"Content",
")",
";",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
";",
"$",
"formatter",
"->",
"analyseSavedContent",
"(",
"$",
"this",
")",
";",
"// set a lock expiry in the past if there's not one already set",
"if",
"(",
"!",
"$",
"this",
"->",
"WikiLockExpiry",
")",
"{",
"$",
"this",
"->",
"WikiLockExpiry",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"}",
"// Make sure to set the last editor to the current user",
"if",
"(",
"Member",
"::",
"currentUser",
"(",
")",
")",
"{",
"$",
"this",
"->",
"WikiLastEditor",
"=",
"Member",
"::",
"currentUser",
"(",
")",
"->",
"Email",
";",
"}",
"}"
]
| Before writing, convert any page links to appropriate
new, non-published, pages
@see sapphire/core/model/SiteTree#onBeforeWrite() | [
"Before",
"writing",
"convert",
"any",
"page",
"links",
"to",
"appropriate",
"new",
"non",
"-",
"published",
"pages"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L84-L103 |
13,507 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.getCMSFields | public function getCMSFields() {
$fields = parent::getCMSFields();
$options = $this->getEditorTypeOptions();
$fields->addFieldToTab('Root.Behaviour', new OptionsetField('EditorType', _t('WikiPage.EDITORTYPE', 'Editor Type'), $options));
// if we're not using the HTML editor type, we should just use a textarea edit field
$formatter = $this->getFormatter();
if ($formatter) {
$formatter->updateCMSFields($fields);
}
return $fields;
} | php | public function getCMSFields() {
$fields = parent::getCMSFields();
$options = $this->getEditorTypeOptions();
$fields->addFieldToTab('Root.Behaviour', new OptionsetField('EditorType', _t('WikiPage.EDITORTYPE', 'Editor Type'), $options));
// if we're not using the HTML editor type, we should just use a textarea edit field
$formatter = $this->getFormatter();
if ($formatter) {
$formatter->updateCMSFields($fields);
}
return $fields;
} | [
"public",
"function",
"getCMSFields",
"(",
")",
"{",
"$",
"fields",
"=",
"parent",
"::",
"getCMSFields",
"(",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getEditorTypeOptions",
"(",
")",
";",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.Behaviour'",
",",
"new",
"OptionsetField",
"(",
"'EditorType'",
",",
"_t",
"(",
"'WikiPage.EDITORTYPE'",
",",
"'Editor Type'",
")",
",",
"$",
"options",
")",
")",
";",
"// if we're not using the HTML editor type, we should just use a textarea edit field",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
";",
"if",
"(",
"$",
"formatter",
")",
"{",
"$",
"formatter",
"->",
"updateCMSFields",
"(",
"$",
"fields",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Get the CMS fields
@see sapphire/core/model/SiteTree#getCMSFields() | [
"Get",
"the",
"CMS",
"fields"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L125-L138 |
13,508 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.getActualEditorType | public function getActualEditorType() {
if ($this->EditorType && $this->EditorType != 'Inherit') {
return $this->EditorType;
}
$parent = $this->getParent();
$editorType = 'Wiki';
while ($parent != null && $parent instanceof WikiPage) {
if ($parent->EditorType && $parent->EditorType != 'Inherit') {
return $parent->EditorType;
}
$parent = $parent->getParent();
}
return 'Wiki';
} | php | public function getActualEditorType() {
if ($this->EditorType && $this->EditorType != 'Inherit') {
return $this->EditorType;
}
$parent = $this->getParent();
$editorType = 'Wiki';
while ($parent != null && $parent instanceof WikiPage) {
if ($parent->EditorType && $parent->EditorType != 'Inherit') {
return $parent->EditorType;
}
$parent = $parent->getParent();
}
return 'Wiki';
} | [
"public",
"function",
"getActualEditorType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"EditorType",
"&&",
"$",
"this",
"->",
"EditorType",
"!=",
"'Inherit'",
")",
"{",
"return",
"$",
"this",
"->",
"EditorType",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"$",
"editorType",
"=",
"'Wiki'",
";",
"while",
"(",
"$",
"parent",
"!=",
"null",
"&&",
"$",
"parent",
"instanceof",
"WikiPage",
")",
"{",
"if",
"(",
"$",
"parent",
"->",
"EditorType",
"&&",
"$",
"parent",
"->",
"EditorType",
"!=",
"'Inherit'",
")",
"{",
"return",
"$",
"parent",
"->",
"EditorType",
";",
"}",
"$",
"parent",
"=",
"$",
"parent",
"->",
"getParent",
"(",
")",
";",
"}",
"return",
"'Wiki'",
";",
"}"
]
| Return the editor type to use for this item. Will interrogate
parents if needbe
@return String | [
"Return",
"the",
"editor",
"type",
"to",
"use",
"for",
"this",
"item",
".",
"Will",
"interrogate",
"parents",
"if",
"needbe"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L155-L170 |
13,509 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.getFormatter | public function getFormatter($formatter=null) {
if (!$formatter) {
$formatter = $this->getActualEditorType();
}
if (!isset(self::$registered_formatters[$formatter])) {
throw new Exception("Formatter $formatter does not exist");
}
return self::$registered_formatters[$formatter];
} | php | public function getFormatter($formatter=null) {
if (!$formatter) {
$formatter = $this->getActualEditorType();
}
if (!isset(self::$registered_formatters[$formatter])) {
throw new Exception("Formatter $formatter does not exist");
}
return self::$registered_formatters[$formatter];
} | [
"public",
"function",
"getFormatter",
"(",
"$",
"formatter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"formatter",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getActualEditorType",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"registered_formatters",
"[",
"$",
"formatter",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Formatter $formatter does not exist\"",
")",
";",
"}",
"return",
"self",
"::",
"$",
"registered_formatters",
"[",
"$",
"formatter",
"]",
";",
"}"
]
| Gets the formatter for a given type. If none specified, gets the current formatter
@return SimpleWikiFormatter | [
"Gets",
"the",
"formatter",
"for",
"a",
"given",
"type",
".",
"If",
"none",
"specified",
"gets",
"the",
"current",
"formatter"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L177-L187 |
13,510 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.ParsedContent | public function ParsedContent() {
$formatter = $this->getFormatter();
$content = $formatter->formatContent($this);
// purify the output - we don't want people breaking pages if we set purify=true
if (self::$purify_output) {
include_once SIMPLEWIKI_DIR . '/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
$content = $purifier->purify($content);
$content = preg_replace_callback('/\%5B(.*?)\%5D/', array($this, 'reformatShortcodes'), $content);
}
return $content;
} | php | public function ParsedContent() {
$formatter = $this->getFormatter();
$content = $formatter->formatContent($this);
// purify the output - we don't want people breaking pages if we set purify=true
if (self::$purify_output) {
include_once SIMPLEWIKI_DIR . '/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier.auto.php';
$purifier = new HTMLPurifier();
$content = $purifier->purify($content);
$content = preg_replace_callback('/\%5B(.*?)\%5D/', array($this, 'reformatShortcodes'), $content);
}
return $content;
} | [
"public",
"function",
"ParsedContent",
"(",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
";",
"$",
"content",
"=",
"$",
"formatter",
"->",
"formatContent",
"(",
"$",
"this",
")",
";",
"// purify the output - we don't want people breaking pages if we set purify=true",
"if",
"(",
"self",
"::",
"$",
"purify_output",
")",
"{",
"include_once",
"SIMPLEWIKI_DIR",
".",
"'/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier.auto.php'",
";",
"$",
"purifier",
"=",
"new",
"HTMLPurifier",
"(",
")",
";",
"$",
"content",
"=",
"$",
"purifier",
"->",
"purify",
"(",
"$",
"content",
")",
";",
"$",
"content",
"=",
"preg_replace_callback",
"(",
"'/\\%5B(.*?)\\%5D/'",
",",
"array",
"(",
"$",
"this",
",",
"'reformatShortcodes'",
")",
",",
"$",
"content",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
]
| Retrieves the page's content, passed through any necessary parsing
eg Wiki based content
@return String | [
"Retrieves",
"the",
"page",
"s",
"content",
"passed",
"through",
"any",
"necessary",
"parsing",
"eg",
"Wiki",
"based",
"content"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L195-L208 |
13,511 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.getWikiRoot | public function getWikiRoot() {
$current = $this;
$parent = $current->Parent();
while ($parent instanceof WikiPage) {
$current = $parent;
$parent = $current->Parent();
}
return $current;
} | php | public function getWikiRoot() {
$current = $this;
$parent = $current->Parent();
while ($parent instanceof WikiPage) {
$current = $parent;
$parent = $current->Parent();
}
return $current;
} | [
"public",
"function",
"getWikiRoot",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
";",
"$",
"parent",
"=",
"$",
"current",
"->",
"Parent",
"(",
")",
";",
"while",
"(",
"$",
"parent",
"instanceof",
"WikiPage",
")",
"{",
"$",
"current",
"=",
"$",
"parent",
";",
"$",
"parent",
"=",
"$",
"current",
"->",
"Parent",
"(",
")",
";",
"}",
"return",
"$",
"current",
";",
"}"
]
| Get the root of the wiki that this wiki page exists in
@return WikiPage | [
"Get",
"the",
"root",
"of",
"the",
"wiki",
"that",
"this",
"wiki",
"page",
"exists",
"in"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L225-L233 |
13,512 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage.lock | public function lock($member = null) {
if (!$member) {
$member = Member::currentUser();
}
// set the updated lock expiry based on now + lock timeout
$this->WikiLastEditor = $member->Email;
$this->WikiLockExpiry = date('Y-m-d H:i:s', time() + $this->config()->get('lock_time'));
// save it with us as the editor
$this->write();
} | php | public function lock($member = null) {
if (!$member) {
$member = Member::currentUser();
}
// set the updated lock expiry based on now + lock timeout
$this->WikiLastEditor = $member->Email;
$this->WikiLockExpiry = date('Y-m-d H:i:s', time() + $this->config()->get('lock_time'));
// save it with us as the editor
$this->write();
} | [
"public",
"function",
"lock",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Member",
"::",
"currentUser",
"(",
")",
";",
"}",
"// set the updated lock expiry based on now + lock timeout",
"$",
"this",
"->",
"WikiLastEditor",
"=",
"$",
"member",
"->",
"Email",
";",
"$",
"this",
"->",
"WikiLockExpiry",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'lock_time'",
")",
")",
";",
"// save it with us as the editor",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}"
]
| Lock the page for the current user
@param Member $member
The user to lock the page for | [
"Lock",
"the",
"page",
"for",
"the",
"current",
"user"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L241-L252 |
13,513 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.edit | public function edit() {
HtmlEditorField::include_js();
// Requirements::javascript('simplewiki/javascript/sslinks/editor_plugin_src.js');
$existing = $this->getEditingLocks($this->data(), true);
// oops, we've somehow got here even though we shouldn't have
if ($existing && $existing['user'] != Member::currentUser()->Email) {
return $this->redirect($this->data()->Link());
}
if (!$this->data()->canEdit()) {
return Security::permissionFailure($this);
}
$this->form = $this->EditForm();
// check who's editing and whether or not we should bail out
return $this->renderWith(array('WikiPage', 'Page'));
} | php | public function edit() {
HtmlEditorField::include_js();
// Requirements::javascript('simplewiki/javascript/sslinks/editor_plugin_src.js');
$existing = $this->getEditingLocks($this->data(), true);
// oops, we've somehow got here even though we shouldn't have
if ($existing && $existing['user'] != Member::currentUser()->Email) {
return $this->redirect($this->data()->Link());
}
if (!$this->data()->canEdit()) {
return Security::permissionFailure($this);
}
$this->form = $this->EditForm();
// check who's editing and whether or not we should bail out
return $this->renderWith(array('WikiPage', 'Page'));
} | [
"public",
"function",
"edit",
"(",
")",
"{",
"HtmlEditorField",
"::",
"include_js",
"(",
")",
";",
"//\t\tRequirements::javascript('simplewiki/javascript/sslinks/editor_plugin_src.js');",
"$",
"existing",
"=",
"$",
"this",
"->",
"getEditingLocks",
"(",
"$",
"this",
"->",
"data",
"(",
")",
",",
"true",
")",
";",
"// oops, we've somehow got here even though we shouldn't have",
"if",
"(",
"$",
"existing",
"&&",
"$",
"existing",
"[",
"'user'",
"]",
"!=",
"Member",
"::",
"currentUser",
"(",
")",
"->",
"Email",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"Link",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"canEdit",
"(",
")",
")",
"{",
"return",
"Security",
"::",
"permissionFailure",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"form",
"=",
"$",
"this",
"->",
"EditForm",
"(",
")",
";",
"// check who's editing and whether or not we should bail out",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"'WikiPage'",
",",
"'Page'",
")",
")",
";",
"}"
]
| Action handler for editing this wiki page
Creates a form that's used for editing the page's content,
as well as adding in a couple of additional toolbar actions
for adding a simple link and a simple image | [
"Action",
"handler",
"for",
"editing",
"this",
"wiki",
"page"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L387-L405 |
13,514 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.EditForm | public function EditForm() {
// make sure to load fresh from db
$record = DataObject::get_by_id('WikiPage', $this->data()->ID);
$formatter = $record->getFormatter();
$editorField = $formatter->getEditingField($record);
$helpLink = $formatter->getHelpUrl();
$fields = FieldList::create(
new LiteralField('Preview', '<div data-url="'.$this->Link('livepreview').'" id="editorPreview"></div>'),
new LiteralField('DialogContent', '<div id="dialogContent" style="display:none;"></div>'),
$editorField,
new DropdownField('EditorType', _t('WikiPage.EDITORTYPE', 'Editor Type'), $this->data()->getEditorTypeOptions()),
new HiddenField('LockUpdate', '', $this->data()->Link('updatelock')),
new HiddenField('LockLength', '', $this->config()->get('lock_time') - 10)
);
if ($helpLink) {
$fields->push(new LiteralField('HelpLink', '<a target="_blank" href="' . $helpLink . '">' . _t('WikiPage.EDITOR_HELP_LINK', 'Editor Help') . '</a>'));
}
$actions = null;
if (!WikiPage::$auto_publish) {
$actions = FieldList::create(
new FormAction('save', _t('WikiPage.SAVE', 'Save')),
new FormAction('done', _t('WikiPage.DONE', 'Done (Draft)')),
new FormAction('publish', _t('WikiPage.PUBLISH', 'Publish'))
);
} else {
$actions = FieldList::create(
new FormAction('save', _t('WikiPage.SAVE', 'Save')),
new FormAction('publish', _t('WikiPage.FINISHED', 'Finished'))
);
}
$actions->push(new FormAction('cancel', _t('WikiPage.CANCEL_EDIT', 'Cancel')));
$actions->push(new FormAction('revert', _t('WikiPage.REVERT_EDIT', 'Revert')));
if (Permission::check(MANAGE_WIKI_PAGES)) {
$actions->push(new FormAction('addpage_t', _t('WikiPage.ADD_PAGE', 'New Page')));
$actions->push(new FormAction('delete', _t('WikiPage.DELETE_PAGE', 'Delete Page')));
}
$form = new Form($this, "EditForm", $fields, $actions);
$form->loadDataFrom($record);
$this->extend('updateWikiEditForm', $form);
return $form;
} | php | public function EditForm() {
// make sure to load fresh from db
$record = DataObject::get_by_id('WikiPage', $this->data()->ID);
$formatter = $record->getFormatter();
$editorField = $formatter->getEditingField($record);
$helpLink = $formatter->getHelpUrl();
$fields = FieldList::create(
new LiteralField('Preview', '<div data-url="'.$this->Link('livepreview').'" id="editorPreview"></div>'),
new LiteralField('DialogContent', '<div id="dialogContent" style="display:none;"></div>'),
$editorField,
new DropdownField('EditorType', _t('WikiPage.EDITORTYPE', 'Editor Type'), $this->data()->getEditorTypeOptions()),
new HiddenField('LockUpdate', '', $this->data()->Link('updatelock')),
new HiddenField('LockLength', '', $this->config()->get('lock_time') - 10)
);
if ($helpLink) {
$fields->push(new LiteralField('HelpLink', '<a target="_blank" href="' . $helpLink . '">' . _t('WikiPage.EDITOR_HELP_LINK', 'Editor Help') . '</a>'));
}
$actions = null;
if (!WikiPage::$auto_publish) {
$actions = FieldList::create(
new FormAction('save', _t('WikiPage.SAVE', 'Save')),
new FormAction('done', _t('WikiPage.DONE', 'Done (Draft)')),
new FormAction('publish', _t('WikiPage.PUBLISH', 'Publish'))
);
} else {
$actions = FieldList::create(
new FormAction('save', _t('WikiPage.SAVE', 'Save')),
new FormAction('publish', _t('WikiPage.FINISHED', 'Finished'))
);
}
$actions->push(new FormAction('cancel', _t('WikiPage.CANCEL_EDIT', 'Cancel')));
$actions->push(new FormAction('revert', _t('WikiPage.REVERT_EDIT', 'Revert')));
if (Permission::check(MANAGE_WIKI_PAGES)) {
$actions->push(new FormAction('addpage_t', _t('WikiPage.ADD_PAGE', 'New Page')));
$actions->push(new FormAction('delete', _t('WikiPage.DELETE_PAGE', 'Delete Page')));
}
$form = new Form($this, "EditForm", $fields, $actions);
$form->loadDataFrom($record);
$this->extend('updateWikiEditForm', $form);
return $form;
} | [
"public",
"function",
"EditForm",
"(",
")",
"{",
"// make sure to load fresh from db",
"$",
"record",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"'WikiPage'",
",",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"ID",
")",
";",
"$",
"formatter",
"=",
"$",
"record",
"->",
"getFormatter",
"(",
")",
";",
"$",
"editorField",
"=",
"$",
"formatter",
"->",
"getEditingField",
"(",
"$",
"record",
")",
";",
"$",
"helpLink",
"=",
"$",
"formatter",
"->",
"getHelpUrl",
"(",
")",
";",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
"new",
"LiteralField",
"(",
"'Preview'",
",",
"'<div data-url=\"'",
".",
"$",
"this",
"->",
"Link",
"(",
"'livepreview'",
")",
".",
"'\" id=\"editorPreview\"></div>'",
")",
",",
"new",
"LiteralField",
"(",
"'DialogContent'",
",",
"'<div id=\"dialogContent\" style=\"display:none;\"></div>'",
")",
",",
"$",
"editorField",
",",
"new",
"DropdownField",
"(",
"'EditorType'",
",",
"_t",
"(",
"'WikiPage.EDITORTYPE'",
",",
"'Editor Type'",
")",
",",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"getEditorTypeOptions",
"(",
")",
")",
",",
"new",
"HiddenField",
"(",
"'LockUpdate'",
",",
"''",
",",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"Link",
"(",
"'updatelock'",
")",
")",
",",
"new",
"HiddenField",
"(",
"'LockLength'",
",",
"''",
",",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"get",
"(",
"'lock_time'",
")",
"-",
"10",
")",
")",
";",
"if",
"(",
"$",
"helpLink",
")",
"{",
"$",
"fields",
"->",
"push",
"(",
"new",
"LiteralField",
"(",
"'HelpLink'",
",",
"'<a target=\"_blank\" href=\"'",
".",
"$",
"helpLink",
".",
"'\">'",
".",
"_t",
"(",
"'WikiPage.EDITOR_HELP_LINK'",
",",
"'Editor Help'",
")",
".",
"'</a>'",
")",
")",
";",
"}",
"$",
"actions",
"=",
"null",
";",
"if",
"(",
"!",
"WikiPage",
"::",
"$",
"auto_publish",
")",
"{",
"$",
"actions",
"=",
"FieldList",
"::",
"create",
"(",
"new",
"FormAction",
"(",
"'save'",
",",
"_t",
"(",
"'WikiPage.SAVE'",
",",
"'Save'",
")",
")",
",",
"new",
"FormAction",
"(",
"'done'",
",",
"_t",
"(",
"'WikiPage.DONE'",
",",
"'Done (Draft)'",
")",
")",
",",
"new",
"FormAction",
"(",
"'publish'",
",",
"_t",
"(",
"'WikiPage.PUBLISH'",
",",
"'Publish'",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"actions",
"=",
"FieldList",
"::",
"create",
"(",
"new",
"FormAction",
"(",
"'save'",
",",
"_t",
"(",
"'WikiPage.SAVE'",
",",
"'Save'",
")",
")",
",",
"new",
"FormAction",
"(",
"'publish'",
",",
"_t",
"(",
"'WikiPage.FINISHED'",
",",
"'Finished'",
")",
")",
")",
";",
"}",
"$",
"actions",
"->",
"push",
"(",
"new",
"FormAction",
"(",
"'cancel'",
",",
"_t",
"(",
"'WikiPage.CANCEL_EDIT'",
",",
"'Cancel'",
")",
")",
")",
";",
"$",
"actions",
"->",
"push",
"(",
"new",
"FormAction",
"(",
"'revert'",
",",
"_t",
"(",
"'WikiPage.REVERT_EDIT'",
",",
"'Revert'",
")",
")",
")",
";",
"if",
"(",
"Permission",
"::",
"check",
"(",
"MANAGE_WIKI_PAGES",
")",
")",
"{",
"$",
"actions",
"->",
"push",
"(",
"new",
"FormAction",
"(",
"'addpage_t'",
",",
"_t",
"(",
"'WikiPage.ADD_PAGE'",
",",
"'New Page'",
")",
")",
")",
";",
"$",
"actions",
"->",
"push",
"(",
"new",
"FormAction",
"(",
"'delete'",
",",
"_t",
"(",
"'WikiPage.DELETE_PAGE'",
",",
"'Delete Page'",
")",
")",
")",
";",
"}",
"$",
"form",
"=",
"new",
"Form",
"(",
"$",
"this",
",",
"\"EditForm\"",
",",
"$",
"fields",
",",
"$",
"actions",
")",
";",
"$",
"form",
"->",
"loadDataFrom",
"(",
"$",
"record",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"'updateWikiEditForm'",
",",
"$",
"form",
")",
";",
"return",
"$",
"form",
";",
"}"
]
| Creates the form used for editing the page's content
@return Form | [
"Creates",
"the",
"form",
"used",
"for",
"editing",
"the",
"page",
"s",
"content"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L412-L462 |
13,515 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.revert | public function revert() {
if ($this->data()->IsModifiedOnStage) {
$this->data()->doRevertToLive();
}
return $this->redirect($this->data()->Link() . '?stage=Live');
} | php | public function revert() {
if ($this->data()->IsModifiedOnStage) {
$this->data()->doRevertToLive();
}
return $this->redirect($this->data()->Link() . '?stage=Live');
} | [
"public",
"function",
"revert",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"IsModifiedOnStage",
")",
"{",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"doRevertToLive",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"Link",
"(",
")",
".",
"'?stage=Live'",
")",
";",
"}"
]
| Option for the user to revert the changes made since it was last published | [
"Option",
"for",
"the",
"user",
"to",
"revert",
"the",
"changes",
"made",
"since",
"it",
"was",
"last",
"published"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L501-L506 |
13,516 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.delete | public function delete() {
$page = $this->data();
/* @var $page Page */
if ($page) {
$parent = $page->Parent();
$ID = $page->ID;
$page->deleteFromStage('Live');
// only fully delete if we're autopublishing stuff.. a bit counter
// intuitive, but works pretty well
if (WikiPage::$auto_publish) {
$page->ID = $ID;
$page->deleteFromStage('Stage');
}
return $this->redirect($parent->Link());
return;
}
throw new Exception("Invalid request");
} | php | public function delete() {
$page = $this->data();
/* @var $page Page */
if ($page) {
$parent = $page->Parent();
$ID = $page->ID;
$page->deleteFromStage('Live');
// only fully delete if we're autopublishing stuff.. a bit counter
// intuitive, but works pretty well
if (WikiPage::$auto_publish) {
$page->ID = $ID;
$page->deleteFromStage('Stage');
}
return $this->redirect($parent->Link());
return;
}
throw new Exception("Invalid request");
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"data",
"(",
")",
";",
"/* @var $page Page */",
"if",
"(",
"$",
"page",
")",
"{",
"$",
"parent",
"=",
"$",
"page",
"->",
"Parent",
"(",
")",
";",
"$",
"ID",
"=",
"$",
"page",
"->",
"ID",
";",
"$",
"page",
"->",
"deleteFromStage",
"(",
"'Live'",
")",
";",
"// only fully delete if we're autopublishing stuff.. a bit counter",
"// intuitive, but works pretty well",
"if",
"(",
"WikiPage",
"::",
"$",
"auto_publish",
")",
"{",
"$",
"page",
"->",
"ID",
"=",
"$",
"ID",
";",
"$",
"page",
"->",
"deleteFromStage",
"(",
"'Stage'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"parent",
"->",
"Link",
"(",
")",
")",
";",
"return",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"Invalid request\"",
")",
";",
"}"
]
| Deletes the current page and returns the user to the parent
of the now deleted page. | [
"Deletes",
"the",
"current",
"page",
"and",
"returns",
"the",
"user",
"to",
"the",
"parent",
"of",
"the",
"now",
"deleted",
"page",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L513-L534 |
13,517 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.addpage | public function addpage($args) {
if (!Permission::check(MANAGE_WIKI_PAGES)) {
return Security::permissionFailure($this);
}
$pageName = trim($args['NewPageName']);
$createType = $args['CreateType'] ? $args['CreateType'] : 'child';
if (!strlen($pageName)) {
throw new Exception("Invalid page name");
}
$createContext = $this->data();
if ($args['CreateContext']) {
$createContext = DataObject::get_by_id('WikiPage', $args['CreateContext']);
}
if (!$createContext instanceof WikiPage) {
throw new Exception("You must select an existing wiki page.");
}
// now see whether to add the new page above, below or as a child
$page = new WikiPage();
$page->Title = $pageName;
$page->MenuTitle = $pageName;
switch ($createType) {
case 'sibling': {
$page->ParentID = $createContext->ParentID;
break;
}
case 'child':
default: {
$page->ParentID = $createContext->ID;
break;
}
}
$page->writeToStage('Stage');
// publish if we're on autopublish
if (WikiPage::$auto_publish) {
$page->doPublish();
}
return $this->redirect($page->Link('edit') . '?stage=Stage');
} | php | public function addpage($args) {
if (!Permission::check(MANAGE_WIKI_PAGES)) {
return Security::permissionFailure($this);
}
$pageName = trim($args['NewPageName']);
$createType = $args['CreateType'] ? $args['CreateType'] : 'child';
if (!strlen($pageName)) {
throw new Exception("Invalid page name");
}
$createContext = $this->data();
if ($args['CreateContext']) {
$createContext = DataObject::get_by_id('WikiPage', $args['CreateContext']);
}
if (!$createContext instanceof WikiPage) {
throw new Exception("You must select an existing wiki page.");
}
// now see whether to add the new page above, below or as a child
$page = new WikiPage();
$page->Title = $pageName;
$page->MenuTitle = $pageName;
switch ($createType) {
case 'sibling': {
$page->ParentID = $createContext->ParentID;
break;
}
case 'child':
default: {
$page->ParentID = $createContext->ID;
break;
}
}
$page->writeToStage('Stage');
// publish if we're on autopublish
if (WikiPage::$auto_publish) {
$page->doPublish();
}
return $this->redirect($page->Link('edit') . '?stage=Stage');
} | [
"public",
"function",
"addpage",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"Permission",
"::",
"check",
"(",
"MANAGE_WIKI_PAGES",
")",
")",
"{",
"return",
"Security",
"::",
"permissionFailure",
"(",
"$",
"this",
")",
";",
"}",
"$",
"pageName",
"=",
"trim",
"(",
"$",
"args",
"[",
"'NewPageName'",
"]",
")",
";",
"$",
"createType",
"=",
"$",
"args",
"[",
"'CreateType'",
"]",
"?",
"$",
"args",
"[",
"'CreateType'",
"]",
":",
"'child'",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"pageName",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid page name\"",
")",
";",
"}",
"$",
"createContext",
"=",
"$",
"this",
"->",
"data",
"(",
")",
";",
"if",
"(",
"$",
"args",
"[",
"'CreateContext'",
"]",
")",
"{",
"$",
"createContext",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"'WikiPage'",
",",
"$",
"args",
"[",
"'CreateContext'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"createContext",
"instanceof",
"WikiPage",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"You must select an existing wiki page.\"",
")",
";",
"}",
"// now see whether to add the new page above, below or as a child",
"$",
"page",
"=",
"new",
"WikiPage",
"(",
")",
";",
"$",
"page",
"->",
"Title",
"=",
"$",
"pageName",
";",
"$",
"page",
"->",
"MenuTitle",
"=",
"$",
"pageName",
";",
"switch",
"(",
"$",
"createType",
")",
"{",
"case",
"'sibling'",
":",
"{",
"$",
"page",
"->",
"ParentID",
"=",
"$",
"createContext",
"->",
"ParentID",
";",
"break",
";",
"}",
"case",
"'child'",
":",
"default",
":",
"{",
"$",
"page",
"->",
"ParentID",
"=",
"$",
"createContext",
"->",
"ID",
";",
"break",
";",
"}",
"}",
"$",
"page",
"->",
"writeToStage",
"(",
"'Stage'",
")",
";",
"// publish if we're on autopublish",
"if",
"(",
"WikiPage",
"::",
"$",
"auto_publish",
")",
"{",
"$",
"page",
"->",
"doPublish",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"page",
"->",
"Link",
"(",
"'edit'",
")",
".",
"'?stage=Stage'",
")",
";",
"}"
]
| Creates an entirely new page as a child of the current page, or
'after' a selected page. | [
"Creates",
"an",
"entirely",
"new",
"page",
"as",
"a",
"child",
"of",
"the",
"current",
"page",
"or",
"after",
"a",
"selected",
"page",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L540-L586 |
13,518 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.save | public function save($data, $form) {
if (!$this->data()->canEdit()) {
return Security::permissionFailure($this);
}
$existing = $this->getEditingLocks($this->data(), true);
// oops, we've somehow got here even though we shouldn't have
if ($existing && $existing['user'] != Member::currentUser()->Email) {
return "Someone somehow locked it while you were gone, this shouldn't happen like this :(";
}
$this->savePage($this->data(), $form);
if (WikiPage::$auto_publish) {
// do publish
$this->data()->doPublish();
}
return $this->redirect($this->data()->Link('edit') . '?stage=Stage');
} | php | public function save($data, $form) {
if (!$this->data()->canEdit()) {
return Security::permissionFailure($this);
}
$existing = $this->getEditingLocks($this->data(), true);
// oops, we've somehow got here even though we shouldn't have
if ($existing && $existing['user'] != Member::currentUser()->Email) {
return "Someone somehow locked it while you were gone, this shouldn't happen like this :(";
}
$this->savePage($this->data(), $form);
if (WikiPage::$auto_publish) {
// do publish
$this->data()->doPublish();
}
return $this->redirect($this->data()->Link('edit') . '?stage=Stage');
} | [
"public",
"function",
"save",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"canEdit",
"(",
")",
")",
"{",
"return",
"Security",
"::",
"permissionFailure",
"(",
"$",
"this",
")",
";",
"}",
"$",
"existing",
"=",
"$",
"this",
"->",
"getEditingLocks",
"(",
"$",
"this",
"->",
"data",
"(",
")",
",",
"true",
")",
";",
"// oops, we've somehow got here even though we shouldn't have",
"if",
"(",
"$",
"existing",
"&&",
"$",
"existing",
"[",
"'user'",
"]",
"!=",
"Member",
"::",
"currentUser",
"(",
")",
"->",
"Email",
")",
"{",
"return",
"\"Someone somehow locked it while you were gone, this shouldn't happen like this :(\"",
";",
"}",
"$",
"this",
"->",
"savePage",
"(",
"$",
"this",
"->",
"data",
"(",
")",
",",
"$",
"form",
")",
";",
"if",
"(",
"WikiPage",
"::",
"$",
"auto_publish",
")",
"{",
"// do publish",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"doPublish",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"Link",
"(",
"'edit'",
")",
".",
"'?stage=Stage'",
")",
";",
"}"
]
| Save the submitted data
@return | [
"Save",
"the",
"submitted",
"data"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L608-L626 |
13,519 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.Form | public function Form() {
// The editing form hasn't been put in place by the 'edit' action
// so lets just show the status form
$append = '';
if (!$this->form) {
if (WikiPage::$show_edit_button || $this->data()->canEdit()) {
// create the information form
$this->form = $this->StatusForm();
}
} else {
// if we have got an editing form, then we'll add a New Page
// form if we have permissions to do so
if (Permission::check(MANAGE_WIKI_PAGES)) {
$append = $this->CreatePageForm()->forTemplate();
}
}
return $this->form->forTemplate() . $append;
} | php | public function Form() {
// The editing form hasn't been put in place by the 'edit' action
// so lets just show the status form
$append = '';
if (!$this->form) {
if (WikiPage::$show_edit_button || $this->data()->canEdit()) {
// create the information form
$this->form = $this->StatusForm();
}
} else {
// if we have got an editing form, then we'll add a New Page
// form if we have permissions to do so
if (Permission::check(MANAGE_WIKI_PAGES)) {
$append = $this->CreatePageForm()->forTemplate();
}
}
return $this->form->forTemplate() . $append;
} | [
"public",
"function",
"Form",
"(",
")",
"{",
"// The editing form hasn't been put in place by the 'edit' action",
"// so lets just show the status form",
"$",
"append",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"form",
")",
"{",
"if",
"(",
"WikiPage",
"::",
"$",
"show_edit_button",
"||",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"canEdit",
"(",
")",
")",
"{",
"// create the information form ",
"$",
"this",
"->",
"form",
"=",
"$",
"this",
"->",
"StatusForm",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// if we have got an editing form, then we'll add a New Page",
"// form if we have permissions to do so",
"if",
"(",
"Permission",
"::",
"check",
"(",
"MANAGE_WIKI_PAGES",
")",
")",
"{",
"$",
"append",
"=",
"$",
"this",
"->",
"CreatePageForm",
"(",
")",
"->",
"forTemplate",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"form",
"->",
"forTemplate",
"(",
")",
".",
"$",
"append",
";",
"}"
]
| Return the form to the user if it exists, otherwise some information
about who is currently editing
@return Form | [
"Return",
"the",
"form",
"to",
"the",
"user",
"if",
"it",
"exists",
"otherwise",
"some",
"information",
"about",
"who",
"is",
"currently",
"editing"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L685-L703 |
13,520 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.StatusForm | public function StatusForm() {
$existing = $this->getEditingLocks($this->data());
if ($existing && $existing['user'] != Member::currentUser()->Email) {
$fields = FieldList::create(
new ReadonlyField('ExistingEditor', '', _t('WikiPage.EXISTINGEDITOR', 'This page is currently locked for editing by ' . $existing['user'] . ' until ' . $existing['expires']))
);
$actions = FieldList::create();
} else {
$fields = FieldList::create();
$actions = FieldList::create(
new FormAction('startediting', _t('WikiPage.STARTEDIT', 'Edit Page'))
);
}
return new Form($this, 'StatusForm', $fields, $actions);
} | php | public function StatusForm() {
$existing = $this->getEditingLocks($this->data());
if ($existing && $existing['user'] != Member::currentUser()->Email) {
$fields = FieldList::create(
new ReadonlyField('ExistingEditor', '', _t('WikiPage.EXISTINGEDITOR', 'This page is currently locked for editing by ' . $existing['user'] . ' until ' . $existing['expires']))
);
$actions = FieldList::create();
} else {
$fields = FieldList::create();
$actions = FieldList::create(
new FormAction('startediting', _t('WikiPage.STARTEDIT', 'Edit Page'))
);
}
return new Form($this, 'StatusForm', $fields, $actions);
} | [
"public",
"function",
"StatusForm",
"(",
")",
"{",
"$",
"existing",
"=",
"$",
"this",
"->",
"getEditingLocks",
"(",
"$",
"this",
"->",
"data",
"(",
")",
")",
";",
"if",
"(",
"$",
"existing",
"&&",
"$",
"existing",
"[",
"'user'",
"]",
"!=",
"Member",
"::",
"currentUser",
"(",
")",
"->",
"Email",
")",
"{",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
"new",
"ReadonlyField",
"(",
"'ExistingEditor'",
",",
"''",
",",
"_t",
"(",
"'WikiPage.EXISTINGEDITOR'",
",",
"'This page is currently locked for editing by '",
".",
"$",
"existing",
"[",
"'user'",
"]",
".",
"' until '",
".",
"$",
"existing",
"[",
"'expires'",
"]",
")",
")",
")",
";",
"$",
"actions",
"=",
"FieldList",
"::",
"create",
"(",
")",
";",
"}",
"else",
"{",
"$",
"fields",
"=",
"FieldList",
"::",
"create",
"(",
")",
";",
"$",
"actions",
"=",
"FieldList",
"::",
"create",
"(",
"new",
"FormAction",
"(",
"'startediting'",
",",
"_t",
"(",
"'WikiPage.STARTEDIT'",
",",
"'Edit Page'",
")",
")",
")",
";",
"}",
"return",
"new",
"Form",
"(",
"$",
"this",
",",
"'StatusForm'",
",",
"$",
"fields",
",",
"$",
"actions",
")",
";",
"}"
]
| Gets the status form that is used by users to trigger the editing mode
if they have the relevant access to it.
@return Form | [
"Gets",
"the",
"status",
"form",
"that",
"is",
"used",
"by",
"users",
"to",
"trigger",
"the",
"editing",
"mode",
"if",
"they",
"have",
"the",
"relevant",
"access",
"to",
"it",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L711-L727 |
13,521 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.updatelock | public function updatelock($data) {
if ($this->data()->ID && $this->data()->canEdit()) {
$lock = $this->getEditingLocks($this->data(), true);
$response = new stdClass();
$response->status = 1;
if ($lock != null && $lock['user'] != Member::currentUser()->Email) {
// someone else has stolen it !
$response->status = 0;
$response->message = _t('WikiPage.LOCK_STOLEN', "Another user (" . $lock['user'] . ") has forcefully taken this lock");
}
return Convert::raw2json($response);
}
} | php | public function updatelock($data) {
if ($this->data()->ID && $this->data()->canEdit()) {
$lock = $this->getEditingLocks($this->data(), true);
$response = new stdClass();
$response->status = 1;
if ($lock != null && $lock['user'] != Member::currentUser()->Email) {
// someone else has stolen it !
$response->status = 0;
$response->message = _t('WikiPage.LOCK_STOLEN', "Another user (" . $lock['user'] . ") has forcefully taken this lock");
}
return Convert::raw2json($response);
}
} | [
"public",
"function",
"updatelock",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"ID",
"&&",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"canEdit",
"(",
")",
")",
"{",
"$",
"lock",
"=",
"$",
"this",
"->",
"getEditingLocks",
"(",
"$",
"this",
"->",
"data",
"(",
")",
",",
"true",
")",
";",
"$",
"response",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"response",
"->",
"status",
"=",
"1",
";",
"if",
"(",
"$",
"lock",
"!=",
"null",
"&&",
"$",
"lock",
"[",
"'user'",
"]",
"!=",
"Member",
"::",
"currentUser",
"(",
")",
"->",
"Email",
")",
"{",
"// someone else has stolen it !",
"$",
"response",
"->",
"status",
"=",
"0",
";",
"$",
"response",
"->",
"message",
"=",
"_t",
"(",
"'WikiPage.LOCK_STOLEN'",
",",
"\"Another user (\"",
".",
"$",
"lock",
"[",
"'user'",
"]",
".",
"\") has forcefully taken this lock\"",
")",
";",
"}",
"return",
"Convert",
"::",
"raw2json",
"(",
"$",
"response",
")",
";",
"}",
"}"
]
| Updates the lock timeout for the given object
@param <type> $data | [
"Updates",
"the",
"lock",
"timeout",
"for",
"the",
"given",
"object"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L734-L746 |
13,522 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.getEditingLocks | protected function getEditingLocks($page, $doLock=false) {
$currentStage = Versioned::current_stage();
Versioned::reading_stage('Stage');
$filter = array(
'WikiPage.ID' => $page->ID,
'WikiLockExpiry' => date('Y-m-d H:i:s'),
);
$user = Member::currentUser();
$currentLock = WikiPage::get()->filter($filter)->first();
$lock = null;
if ($currentLock && $currentLock->ID) {
// if there's a current lock in place, lets return that value
$lock = array(
'user' => $currentLock->WikiLastEditor,
'expires' => $currentLock->WikiLockExpiry,
);
}
// If we're trying to take the lock, make sure that a) there's no existing
// lock or b) we currently hold the lock
if ($doLock && ($currentLock == null || !$currentLock->ID || $currentLock->WikiLastEditor == $user->Email)) {
$page->lock();
}
Versioned::reading_stage($currentStage);
return $lock;
} | php | protected function getEditingLocks($page, $doLock=false) {
$currentStage = Versioned::current_stage();
Versioned::reading_stage('Stage');
$filter = array(
'WikiPage.ID' => $page->ID,
'WikiLockExpiry' => date('Y-m-d H:i:s'),
);
$user = Member::currentUser();
$currentLock = WikiPage::get()->filter($filter)->first();
$lock = null;
if ($currentLock && $currentLock->ID) {
// if there's a current lock in place, lets return that value
$lock = array(
'user' => $currentLock->WikiLastEditor,
'expires' => $currentLock->WikiLockExpiry,
);
}
// If we're trying to take the lock, make sure that a) there's no existing
// lock or b) we currently hold the lock
if ($doLock && ($currentLock == null || !$currentLock->ID || $currentLock->WikiLastEditor == $user->Email)) {
$page->lock();
}
Versioned::reading_stage($currentStage);
return $lock;
} | [
"protected",
"function",
"getEditingLocks",
"(",
"$",
"page",
",",
"$",
"doLock",
"=",
"false",
")",
"{",
"$",
"currentStage",
"=",
"Versioned",
"::",
"current_stage",
"(",
")",
";",
"Versioned",
"::",
"reading_stage",
"(",
"'Stage'",
")",
";",
"$",
"filter",
"=",
"array",
"(",
"'WikiPage.ID'",
"=>",
"$",
"page",
"->",
"ID",
",",
"'WikiLockExpiry'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
")",
";",
"$",
"user",
"=",
"Member",
"::",
"currentUser",
"(",
")",
";",
"$",
"currentLock",
"=",
"WikiPage",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"$",
"filter",
")",
"->",
"first",
"(",
")",
";",
"$",
"lock",
"=",
"null",
";",
"if",
"(",
"$",
"currentLock",
"&&",
"$",
"currentLock",
"->",
"ID",
")",
"{",
"// if there's a current lock in place, lets return that value",
"$",
"lock",
"=",
"array",
"(",
"'user'",
"=>",
"$",
"currentLock",
"->",
"WikiLastEditor",
",",
"'expires'",
"=>",
"$",
"currentLock",
"->",
"WikiLockExpiry",
",",
")",
";",
"}",
"// If we're trying to take the lock, make sure that a) there's no existing",
"// lock or b) we currently hold the lock",
"if",
"(",
"$",
"doLock",
"&&",
"(",
"$",
"currentLock",
"==",
"null",
"||",
"!",
"$",
"currentLock",
"->",
"ID",
"||",
"$",
"currentLock",
"->",
"WikiLastEditor",
"==",
"$",
"user",
"->",
"Email",
")",
")",
"{",
"$",
"page",
"->",
"lock",
"(",
")",
";",
"}",
"Versioned",
"::",
"reading_stage",
"(",
"$",
"currentStage",
")",
";",
"return",
"$",
"lock",
";",
"}"
]
| Lock the page for editing
@param SiteTree $page
The page being edited
@param boolean $doLock
Whether to actually lock the page for ourselves
@return array
The names of any existing editors | [
"Lock",
"the",
"page",
"for",
"editing"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L758-L790 |
13,523 | nyeholt/silverstripe-simplewiki | code/pages/WikiPage.php | WikiPage_Controller.objectdetails | public function objectdetails() {
$response = new stdClass;
if (isset($_GET['ID'])) {
$type = null;
if (isset($_GET['type'])) {
$type = $_GET['type'] == 'href' ? 'SiteTree' : 'File';
} else {
$type = 'SiteTree';
}
$object = DataObject::get_by_id($type, $_GET['ID']);
$response->Title = $object->Title;
$response->Link = $object->Link();
if ($object instanceof Image) {
$response->Name = $object->Name;
$response->Filename = $object->Filename;
$response->width = $object->getWidth();
$response->height = $object->getHeight();
}
$response->error = 0;
} else {
$response->error = 1;
$response->message = "Invalid image ID";
}
echo json_encode($response);
} | php | public function objectdetails() {
$response = new stdClass;
if (isset($_GET['ID'])) {
$type = null;
if (isset($_GET['type'])) {
$type = $_GET['type'] == 'href' ? 'SiteTree' : 'File';
} else {
$type = 'SiteTree';
}
$object = DataObject::get_by_id($type, $_GET['ID']);
$response->Title = $object->Title;
$response->Link = $object->Link();
if ($object instanceof Image) {
$response->Name = $object->Name;
$response->Filename = $object->Filename;
$response->width = $object->getWidth();
$response->height = $object->getHeight();
}
$response->error = 0;
} else {
$response->error = 1;
$response->message = "Invalid image ID";
}
echo json_encode($response);
} | [
"public",
"function",
"objectdetails",
"(",
")",
"{",
"$",
"response",
"=",
"new",
"stdClass",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'ID'",
"]",
")",
")",
"{",
"$",
"type",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"type",
"=",
"$",
"_GET",
"[",
"'type'",
"]",
"==",
"'href'",
"?",
"'SiteTree'",
":",
"'File'",
";",
"}",
"else",
"{",
"$",
"type",
"=",
"'SiteTree'",
";",
"}",
"$",
"object",
"=",
"DataObject",
"::",
"get_by_id",
"(",
"$",
"type",
",",
"$",
"_GET",
"[",
"'ID'",
"]",
")",
";",
"$",
"response",
"->",
"Title",
"=",
"$",
"object",
"->",
"Title",
";",
"$",
"response",
"->",
"Link",
"=",
"$",
"object",
"->",
"Link",
"(",
")",
";",
"if",
"(",
"$",
"object",
"instanceof",
"Image",
")",
"{",
"$",
"response",
"->",
"Name",
"=",
"$",
"object",
"->",
"Name",
";",
"$",
"response",
"->",
"Filename",
"=",
"$",
"object",
"->",
"Filename",
";",
"$",
"response",
"->",
"width",
"=",
"$",
"object",
"->",
"getWidth",
"(",
")",
";",
"$",
"response",
"->",
"height",
"=",
"$",
"object",
"->",
"getHeight",
"(",
")",
";",
"}",
"$",
"response",
"->",
"error",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"response",
"->",
"error",
"=",
"1",
";",
"$",
"response",
"->",
"message",
"=",
"\"Invalid image ID\"",
";",
"}",
"echo",
"json_encode",
"(",
"$",
"response",
")",
";",
"}"
]
| Retrieves information about a selected image for the frontend
image insertion tool - hacky for now, ideally need to pull through the
backend ImageForm
@return string | [
"Retrieves",
"information",
"about",
"a",
"selected",
"image",
"for",
"the",
"frontend",
"image",
"insertion",
"tool",
"-",
"hacky",
"for",
"now",
"ideally",
"need",
"to",
"pull",
"through",
"the",
"backend",
"ImageForm"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/code/pages/WikiPage.php#L843-L871 |
13,524 | itrnka/ha-framework | src/ha/Component/Password/PasswordDefault.php | PasswordDefault.setValue | public function setValue(string $rawValue) : void
{
if (strlen($rawValue) < 8) {
throw new PasswordPolicyException('Password is too short@' . __METHOD__);
}
$this->rawValue = $rawValue;
} | php | public function setValue(string $rawValue) : void
{
if (strlen($rawValue) < 8) {
throw new PasswordPolicyException('Password is too short@' . __METHOD__);
}
$this->rawValue = $rawValue;
} | [
"public",
"function",
"setValue",
"(",
"string",
"$",
"rawValue",
")",
":",
"void",
"{",
"if",
"(",
"strlen",
"(",
"$",
"rawValue",
")",
"<",
"8",
")",
"{",
"throw",
"new",
"PasswordPolicyException",
"(",
"'Password is too short@'",
".",
"__METHOD__",
")",
";",
"}",
"$",
"this",
"->",
"rawValue",
"=",
"$",
"rawValue",
";",
"}"
]
| Set password value.
@param string $rawValue
@throws PasswordPolicyException | [
"Set",
"password",
"value",
"."
]
| a72b09c28f8e966c37f98a0004e4fbbce80df42c | https://github.com/itrnka/ha-framework/blob/a72b09c28f8e966c37f98a0004e4fbbce80df42c/src/ha/Component/Password/PasswordDefault.php#L34-L40 |
13,525 | itrnka/ha-framework | src/ha/Component/Password/PasswordDefault.php | PasswordDefault.verify | public function verify(string $hash) : bool
{
if (is_null($this->rawValue)) {
return false;
}
return password_verify($this->rawValue, $hash);
} | php | public function verify(string $hash) : bool
{
if (is_null($this->rawValue)) {
return false;
}
return password_verify($this->rawValue, $hash);
} | [
"public",
"function",
"verify",
"(",
"string",
"$",
"hash",
")",
":",
"bool",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"rawValue",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"password_verify",
"(",
"$",
"this",
"->",
"rawValue",
",",
"$",
"hash",
")",
";",
"}"
]
| Verify password hash
@param string $hash
@return bool | [
"Verify",
"password",
"hash"
]
| a72b09c28f8e966c37f98a0004e4fbbce80df42c | https://github.com/itrnka/ha-framework/blob/a72b09c28f8e966c37f98a0004e4fbbce80df42c/src/ha/Component/Password/PasswordDefault.php#L72-L78 |
13,526 | PandaPlatform/framework | src/Panda/Routing/Route.php | Route.getParameterNames | public function getParameterNames()
{
if (isset($this->parameterNames)) {
return $this->parameterNames;
}
return $this->parameterNames = $this->compileParameterNames();
} | php | public function getParameterNames()
{
if (isset($this->parameterNames)) {
return $this->parameterNames;
}
return $this->parameterNames = $this->compileParameterNames();
} | [
"public",
"function",
"getParameterNames",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameterNames",
")",
")",
"{",
"return",
"$",
"this",
"->",
"parameterNames",
";",
"}",
"return",
"$",
"this",
"->",
"parameterNames",
"=",
"$",
"this",
"->",
"compileParameterNames",
"(",
")",
";",
"}"
]
| Get all of the parameter names for the route.
@return array | [
"Get",
"all",
"of",
"the",
"parameter",
"names",
"for",
"the",
"route",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Routing/Route.php#L262-L269 |
13,527 | PandaPlatform/framework | src/Panda/Routing/Route.php | Route.getParameter | public function getParameter($name, $default = null)
{
try {
return ArrayHelper::get($this->getParameters(), $name, $default);
} catch (Exception $ex) {
return $default;
}
} | php | public function getParameter($name, $default = null)
{
try {
return ArrayHelper::get($this->getParameters(), $name, $default);
} catch (Exception $ex) {
return $default;
}
} | [
"public",
"function",
"getParameter",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"ArrayHelper",
"::",
"get",
"(",
"$",
"this",
"->",
"getParameters",
"(",
")",
",",
"$",
"name",
",",
"$",
"default",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"return",
"$",
"default",
";",
"}",
"}"
]
| Get a given parameter from the route.
@param string $name
@param mixed $default
@return string|object | [
"Get",
"a",
"given",
"parameter",
"from",
"the",
"route",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Routing/Route.php#L293-L300 |
13,528 | PandaPlatform/framework | src/Panda/Routing/Route.php | Route.compileRoute | protected function compileRoute()
{
$uri = preg_replace('/\{(\w+?)\?\}/', '{$1}', $this->uri);
$this->compiled = (new SymfonyRoute($uri, $optionals = [], $requirements = [], [], $domain = ''))->compile();
} | php | protected function compileRoute()
{
$uri = preg_replace('/\{(\w+?)\?\}/', '{$1}', $this->uri);
$this->compiled = (new SymfonyRoute($uri, $optionals = [], $requirements = [], [], $domain = ''))->compile();
} | [
"protected",
"function",
"compileRoute",
"(",
")",
"{",
"$",
"uri",
"=",
"preg_replace",
"(",
"'/\\{(\\w+?)\\?\\}/'",
",",
"'{$1}'",
",",
"$",
"this",
"->",
"uri",
")",
";",
"$",
"this",
"->",
"compiled",
"=",
"(",
"new",
"SymfonyRoute",
"(",
"$",
"uri",
",",
"$",
"optionals",
"=",
"[",
"]",
",",
"$",
"requirements",
"=",
"[",
"]",
",",
"[",
"]",
",",
"$",
"domain",
"=",
"''",
")",
")",
"->",
"compile",
"(",
")",
";",
"}"
]
| Compile the current route.
@throws LogicException | [
"Compile",
"the",
"current",
"route",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Routing/Route.php#L377-L382 |
13,529 | PandaPlatform/framework | src/Panda/Routing/Route.php | Route.runCallable | protected function runCallable()
{
$parameters = $this->resolveMethodDependencies(
$this->getParametersWithoutNulls(), new ReflectionFunction($this->action['uses'])
);
$callable = $this->action['uses'];
return call_user_func_array($callable, $parameters);
} | php | protected function runCallable()
{
$parameters = $this->resolveMethodDependencies(
$this->getParametersWithoutNulls(), new ReflectionFunction($this->action['uses'])
);
$callable = $this->action['uses'];
return call_user_func_array($callable, $parameters);
} | [
"protected",
"function",
"runCallable",
"(",
")",
"{",
"$",
"parameters",
"=",
"$",
"this",
"->",
"resolveMethodDependencies",
"(",
"$",
"this",
"->",
"getParametersWithoutNulls",
"(",
")",
",",
"new",
"ReflectionFunction",
"(",
"$",
"this",
"->",
"action",
"[",
"'uses'",
"]",
")",
")",
";",
"$",
"callable",
"=",
"$",
"this",
"->",
"action",
"[",
"'uses'",
"]",
";",
"return",
"call_user_func_array",
"(",
"$",
"callable",
",",
"$",
"parameters",
")",
";",
"}"
]
| Run the route action as callable and return the response.
@return mixed
@throws LogicException | [
"Run",
"the",
"route",
"action",
"as",
"callable",
"and",
"return",
"the",
"response",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Routing/Route.php#L443-L452 |
13,530 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php | HTMLPurifier_Config.getBatchSerial | public function getBatchSerial($namespace) {
if (empty($this->serials[$namespace])) {
$batch = $this->getBatch($namespace);
unset($batch['DefinitionRev']);
$this->serials[$namespace] = md5(serialize($batch));
}
return $this->serials[$namespace];
} | php | public function getBatchSerial($namespace) {
if (empty($this->serials[$namespace])) {
$batch = $this->getBatch($namespace);
unset($batch['DefinitionRev']);
$this->serials[$namespace] = md5(serialize($batch));
}
return $this->serials[$namespace];
} | [
"public",
"function",
"getBatchSerial",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"serials",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"batch",
"=",
"$",
"this",
"->",
"getBatch",
"(",
"$",
"namespace",
")",
";",
"unset",
"(",
"$",
"batch",
"[",
"'DefinitionRev'",
"]",
")",
";",
"$",
"this",
"->",
"serials",
"[",
"$",
"namespace",
"]",
"=",
"md5",
"(",
"serialize",
"(",
"$",
"batch",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"serials",
"[",
"$",
"namespace",
"]",
";",
"}"
]
| Returns a md5 signature of a segment of the configuration object
that uniquely identifies that particular configuration
@note Revision is handled specially and is removed from the batch
before processing!
@param $namespace Namespace to get serial for | [
"Returns",
"a",
"md5",
"signature",
"of",
"a",
"segment",
"of",
"the",
"configuration",
"object",
"that",
"uniquely",
"identifies",
"that",
"particular",
"configuration"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php#L197-L204 |
13,531 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php | HTMLPurifier_Config.getSerial | public function getSerial() {
if (empty($this->serial)) {
$this->serial = md5(serialize($this->getAll()));
}
return $this->serial;
} | php | public function getSerial() {
if (empty($this->serial)) {
$this->serial = md5(serialize($this->getAll()));
}
return $this->serial;
} | [
"public",
"function",
"getSerial",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"serial",
")",
")",
"{",
"$",
"this",
"->",
"serial",
"=",
"md5",
"(",
"serialize",
"(",
"$",
"this",
"->",
"getAll",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"serial",
";",
"}"
]
| Returns a md5 signature for the entire configuration object
that uniquely identifies that particular configuration | [
"Returns",
"a",
"md5",
"signature",
"for",
"the",
"entire",
"configuration",
"object",
"that",
"uniquely",
"identifies",
"that",
"particular",
"configuration"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php#L210-L215 |
13,532 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php | HTMLPurifier_Config.getAll | public function getAll() {
if (!$this->finalized) $this->autoFinalize();
$ret = array();
foreach ($this->plist->squash() as $name => $value) {
list($ns, $key) = explode('.', $name, 2);
$ret[$ns][$key] = $value;
}
return $ret;
} | php | public function getAll() {
if (!$this->finalized) $this->autoFinalize();
$ret = array();
foreach ($this->plist->squash() as $name => $value) {
list($ns, $key) = explode('.', $name, 2);
$ret[$ns][$key] = $value;
}
return $ret;
} | [
"public",
"function",
"getAll",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"finalized",
")",
"$",
"this",
"->",
"autoFinalize",
"(",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"plist",
"->",
"squash",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"ns",
",",
"$",
"key",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"$",
"ret",
"[",
"$",
"ns",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Retrieves all directives, organized by namespace
@warning This is a pretty inefficient function, avoid if you can | [
"Retrieves",
"all",
"directives",
"organized",
"by",
"namespace"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php#L221-L229 |
13,533 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php | HTMLPurifier_Config.prepareArrayFromForm | public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) {
if ($index !== false) $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
$mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc();
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
$ret = array();
foreach ($allowed as $key) {
list($ns, $directive) = $key;
$skey = "$ns.$directive";
if (!empty($array["Null_$skey"])) {
$ret[$ns][$directive] = null;
continue;
}
if (!isset($array[$skey])) continue;
$value = $mq ? stripslashes($array[$skey]) : $array[$skey];
$ret[$ns][$directive] = $value;
}
return $ret;
} | php | public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) {
if ($index !== false) $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array();
$mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc();
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema);
$ret = array();
foreach ($allowed as $key) {
list($ns, $directive) = $key;
$skey = "$ns.$directive";
if (!empty($array["Null_$skey"])) {
$ret[$ns][$directive] = null;
continue;
}
if (!isset($array[$skey])) continue;
$value = $mq ? stripslashes($array[$skey]) : $array[$skey];
$ret[$ns][$directive] = $value;
}
return $ret;
} | [
"public",
"static",
"function",
"prepareArrayFromForm",
"(",
"$",
"array",
",",
"$",
"index",
"=",
"false",
",",
"$",
"allowed",
"=",
"true",
",",
"$",
"mq_fix",
"=",
"true",
",",
"$",
"schema",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"$",
"array",
"=",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"index",
"]",
")",
"&&",
"is_array",
"(",
"$",
"array",
"[",
"$",
"index",
"]",
")",
")",
"?",
"$",
"array",
"[",
"$",
"index",
"]",
":",
"array",
"(",
")",
";",
"$",
"mq",
"=",
"$",
"mq_fix",
"&&",
"function_exists",
"(",
"'get_magic_quotes_gpc'",
")",
"&&",
"get_magic_quotes_gpc",
"(",
")",
";",
"$",
"allowed",
"=",
"HTMLPurifier_Config",
"::",
"getAllowedDirectivesForForm",
"(",
"$",
"allowed",
",",
"$",
"schema",
")",
";",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"allowed",
"as",
"$",
"key",
")",
"{",
"list",
"(",
"$",
"ns",
",",
"$",
"directive",
")",
"=",
"$",
"key",
";",
"$",
"skey",
"=",
"\"$ns.$directive\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"\"Null_$skey\"",
"]",
")",
")",
"{",
"$",
"ret",
"[",
"$",
"ns",
"]",
"[",
"$",
"directive",
"]",
"=",
"null",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"skey",
"]",
")",
")",
"continue",
";",
"$",
"value",
"=",
"$",
"mq",
"?",
"stripslashes",
"(",
"$",
"array",
"[",
"$",
"skey",
"]",
")",
":",
"$",
"array",
"[",
"$",
"skey",
"]",
";",
"$",
"ret",
"[",
"$",
"ns",
"]",
"[",
"$",
"directive",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"ret",
";",
"}"
]
| Prepares an array from a form into something usable for the more
strict parts of HTMLPurifier_Config | [
"Prepares",
"an",
"array",
"from",
"a",
"form",
"into",
"something",
"usable",
"for",
"the",
"more",
"strict",
"parts",
"of",
"HTMLPurifier_Config"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php#L489-L507 |
13,534 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php | HTMLPurifier_Config.triggerError | protected function triggerError($msg, $no) {
// determine previous stack frame
$backtrace = debug_backtrace();
if ($this->chatty && isset($backtrace[1])) {
$frame = $backtrace[1];
$extra = " on line {$frame['line']} in file {$frame['file']}";
} else {
$extra = '';
}
trigger_error($msg . $extra, $no);
} | php | protected function triggerError($msg, $no) {
// determine previous stack frame
$backtrace = debug_backtrace();
if ($this->chatty && isset($backtrace[1])) {
$frame = $backtrace[1];
$extra = " on line {$frame['line']} in file {$frame['file']}";
} else {
$extra = '';
}
trigger_error($msg . $extra, $no);
} | [
"protected",
"function",
"triggerError",
"(",
"$",
"msg",
",",
"$",
"no",
")",
"{",
"// determine previous stack frame",
"$",
"backtrace",
"=",
"debug_backtrace",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"chatty",
"&&",
"isset",
"(",
"$",
"backtrace",
"[",
"1",
"]",
")",
")",
"{",
"$",
"frame",
"=",
"$",
"backtrace",
"[",
"1",
"]",
";",
"$",
"extra",
"=",
"\" on line {$frame['line']} in file {$frame['file']}\"",
";",
"}",
"else",
"{",
"$",
"extra",
"=",
"''",
";",
"}",
"trigger_error",
"(",
"$",
"msg",
".",
"$",
"extra",
",",
"$",
"no",
")",
";",
"}"
]
| Produces a nicely formatted error message by supplying the
stack frame information from two levels up and OUTSIDE of
HTMLPurifier_Config. | [
"Produces",
"a",
"nicely",
"formatted",
"error",
"message",
"by",
"supplying",
"the",
"stack",
"frame",
"information",
"from",
"two",
"levels",
"up",
"and",
"OUTSIDE",
"of",
"HTMLPurifier_Config",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/Config.php#L555-L565 |
13,535 | terdia/legato-framework | src/Mail/Mail.php | Mail.send | public static function send($params)
{
$params = array_merge([
'subject' => '',
'view' => '',
'body' => '',
'bodyHtml' => '',
'to' => [],
'bcc' => [],
'cc' => [],
'replyTo' => [],
'file' => '',
], $params);
$message = (new static())->to($params['to'])->from($params['from'])
->subject($params['subject'])->bcc($params['bcc'])->cc($params['cc'])
->reply($params['replyTo']);
if ($params['view'] != '') {
$message->body(makeMail($params['view'], ['data' => $params['body']]), 'text/html');
} else {
$message->body($params['body']);
}
if ($params['file'] != '') {
$message->attachment($params['file']);
}
return self::getMailerClient()->send($message);
} | php | public static function send($params)
{
$params = array_merge([
'subject' => '',
'view' => '',
'body' => '',
'bodyHtml' => '',
'to' => [],
'bcc' => [],
'cc' => [],
'replyTo' => [],
'file' => '',
], $params);
$message = (new static())->to($params['to'])->from($params['from'])
->subject($params['subject'])->bcc($params['bcc'])->cc($params['cc'])
->reply($params['replyTo']);
if ($params['view'] != '') {
$message->body(makeMail($params['view'], ['data' => $params['body']]), 'text/html');
} else {
$message->body($params['body']);
}
if ($params['file'] != '') {
$message->attachment($params['file']);
}
return self::getMailerClient()->send($message);
} | [
"public",
"static",
"function",
"send",
"(",
"$",
"params",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"[",
"'subject'",
"=>",
"''",
",",
"'view'",
"=>",
"''",
",",
"'body'",
"=>",
"''",
",",
"'bodyHtml'",
"=>",
"''",
",",
"'to'",
"=>",
"[",
"]",
",",
"'bcc'",
"=>",
"[",
"]",
",",
"'cc'",
"=>",
"[",
"]",
",",
"'replyTo'",
"=>",
"[",
"]",
",",
"'file'",
"=>",
"''",
",",
"]",
",",
"$",
"params",
")",
";",
"$",
"message",
"=",
"(",
"new",
"static",
"(",
")",
")",
"->",
"to",
"(",
"$",
"params",
"[",
"'to'",
"]",
")",
"->",
"from",
"(",
"$",
"params",
"[",
"'from'",
"]",
")",
"->",
"subject",
"(",
"$",
"params",
"[",
"'subject'",
"]",
")",
"->",
"bcc",
"(",
"$",
"params",
"[",
"'bcc'",
"]",
")",
"->",
"cc",
"(",
"$",
"params",
"[",
"'cc'",
"]",
")",
"->",
"reply",
"(",
"$",
"params",
"[",
"'replyTo'",
"]",
")",
";",
"if",
"(",
"$",
"params",
"[",
"'view'",
"]",
"!=",
"''",
")",
"{",
"$",
"message",
"->",
"body",
"(",
"makeMail",
"(",
"$",
"params",
"[",
"'view'",
"]",
",",
"[",
"'data'",
"=>",
"$",
"params",
"[",
"'body'",
"]",
"]",
")",
",",
"'text/html'",
")",
";",
"}",
"else",
"{",
"$",
"message",
"->",
"body",
"(",
"$",
"params",
"[",
"'body'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"params",
"[",
"'file'",
"]",
"!=",
"''",
")",
"{",
"$",
"message",
"->",
"attachment",
"(",
"$",
"params",
"[",
"'file'",
"]",
")",
";",
"}",
"return",
"self",
"::",
"getMailerClient",
"(",
")",
"->",
"send",
"(",
"$",
"message",
")",
";",
"}"
]
| Send message using chosen driver.
@param $params
@return int|mixed | [
"Send",
"message",
"using",
"chosen",
"driver",
"."
]
| 44057c1c3c6f3e9643e9fade51bd417860fafda8 | https://github.com/terdia/legato-framework/blob/44057c1c3c6f3e9643e9fade51bd417860fafda8/src/Mail/Mail.php#L52-L81 |
13,536 | ssnepenthe/soter | src/class-slack-notifier.php | Slack_Notifier.build_attachment_fields | protected function build_attachment_fields( Vulnerabilities $vulnerabilities ) {
$fields = [];
foreach ( $vulnerabilities as $vulnerability ) {
$fixed_in = $vulnerability->fixed_in
? 'Fixed in v' . $vulnerability->fixed_in
: 'Not fixed yet';
$wpvdb_url = "https://wpvulndb.com/vulnerabilities/{$vulnerability->id}";
$fields[] = [
'title' => $vulnerability->title,
'value' => "{$fixed_in} - <{$wpvdb_url}|More info>",
];
}
return $fields;
} | php | protected function build_attachment_fields( Vulnerabilities $vulnerabilities ) {
$fields = [];
foreach ( $vulnerabilities as $vulnerability ) {
$fixed_in = $vulnerability->fixed_in
? 'Fixed in v' . $vulnerability->fixed_in
: 'Not fixed yet';
$wpvdb_url = "https://wpvulndb.com/vulnerabilities/{$vulnerability->id}";
$fields[] = [
'title' => $vulnerability->title,
'value' => "{$fixed_in} - <{$wpvdb_url}|More info>",
];
}
return $fields;
} | [
"protected",
"function",
"build_attachment_fields",
"(",
"Vulnerabilities",
"$",
"vulnerabilities",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"vulnerabilities",
"as",
"$",
"vulnerability",
")",
"{",
"$",
"fixed_in",
"=",
"$",
"vulnerability",
"->",
"fixed_in",
"?",
"'Fixed in v'",
".",
"$",
"vulnerability",
"->",
"fixed_in",
":",
"'Not fixed yet'",
";",
"$",
"wpvdb_url",
"=",
"\"https://wpvulndb.com/vulnerabilities/{$vulnerability->id}\"",
";",
"$",
"fields",
"[",
"]",
"=",
"[",
"'title'",
"=>",
"$",
"vulnerability",
"->",
"title",
",",
"'value'",
"=>",
"\"{$fixed_in} - <{$wpvdb_url}|More info>\"",
",",
"]",
";",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Generates the fields array for the message attachment.
@param Vulnerabilities $vulnerabilities List of vulnerabilities.
@return array | [
"Generates",
"the",
"fields",
"array",
"for",
"the",
"message",
"attachment",
"."
]
| f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7 | https://github.com/ssnepenthe/soter/blob/f6d7032f8562e23c2ee8dbf9d60ef1114c8cdce7/src/class-slack-notifier.php#L92-L108 |
13,537 | inpsyde/wp-db-tools | src/Db/WpDbAdapter.php | WpDbAdapter.query | public function query( $query, $options = 0 ) {
$result = $this->wpdb->get_results( (string) $query );
$this->last_affected_rows = (int) $this->wpdb->rows_affected;
$this->last_insert_id = (int) $this->wpdb->insert_id;
$this->last_statement = NULL;
if ( ! is_array( $result ) )
$result = [];
return new GenericResult( $result );
} | php | public function query( $query, $options = 0 ) {
$result = $this->wpdb->get_results( (string) $query );
$this->last_affected_rows = (int) $this->wpdb->rows_affected;
$this->last_insert_id = (int) $this->wpdb->insert_id;
$this->last_statement = NULL;
if ( ! is_array( $result ) )
$result = [];
return new GenericResult( $result );
} | [
"public",
"function",
"query",
"(",
"$",
"query",
",",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"wpdb",
"->",
"get_results",
"(",
"(",
"string",
")",
"$",
"query",
")",
";",
"$",
"this",
"->",
"last_affected_rows",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"wpdb",
"->",
"rows_affected",
";",
"$",
"this",
"->",
"last_insert_id",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"wpdb",
"->",
"insert_id",
";",
"$",
"this",
"->",
"last_statement",
"=",
"NULL",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"result",
")",
")",
"$",
"result",
"=",
"[",
"]",
";",
"return",
"new",
"GenericResult",
"(",
"$",
"result",
")",
";",
"}"
]
| Executes a plain SQL query and return the results
@param $query
@param int $options
@return \WpDbTools\Type\Result | [
"Executes",
"a",
"plain",
"SQL",
"query",
"and",
"return",
"the",
"results"
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Db/WpDbAdapter.php#L76-L86 |
13,538 | inpsyde/wp-db-tools | src/Db/WpDbAdapter.php | WpDbAdapter.query_statement | public function query_statement( Statement $statement, array $data, $options = 0 ) {
$query = call_user_func_array(
[ $this->wpdb, 'prepare' ],
array_merge( [ (string) $statement] , $data )
);
$result = $this->query( $query );
$this->last_statement = $statement;
return $result;
} | php | public function query_statement( Statement $statement, array $data, $options = 0 ) {
$query = call_user_func_array(
[ $this->wpdb, 'prepare' ],
array_merge( [ (string) $statement] , $data )
);
$result = $this->query( $query );
$this->last_statement = $statement;
return $result;
} | [
"public",
"function",
"query_statement",
"(",
"Statement",
"$",
"statement",
",",
"array",
"$",
"data",
",",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"query",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"wpdb",
",",
"'prepare'",
"]",
",",
"array_merge",
"(",
"[",
"(",
"string",
")",
"$",
"statement",
"]",
",",
"$",
"data",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"last_statement",
"=",
"$",
"statement",
";",
"return",
"$",
"result",
";",
"}"
]
| Executes a Statement and return a Result
@param Statement $statement
@param array $data
@param int $options (Optional)
@return Result | [
"Executes",
"a",
"Statement",
"and",
"return",
"a",
"Result"
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Db/WpDbAdapter.php#L97-L107 |
13,539 | inpsyde/wp-db-tools | src/Db/WpDbAdapter.php | WpDbAdapter.execute_statement | public function execute_statement( Statement $statement, array $data, $options = 0 ) {
$this->query_statement( $statement, $data, $options );
return $this->last_affected_rows();
} | php | public function execute_statement( Statement $statement, array $data, $options = 0 ) {
$this->query_statement( $statement, $data, $options );
return $this->last_affected_rows();
} | [
"public",
"function",
"execute_statement",
"(",
"Statement",
"$",
"statement",
",",
"array",
"$",
"data",
",",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"query_statement",
"(",
"$",
"statement",
",",
"$",
"data",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"last_affected_rows",
"(",
")",
";",
"}"
]
| Executes a Statement and return the number of affected rows
@param Statement $statement
@param array $data
@param int $options (Optional)
@return int | [
"Executes",
"a",
"Statement",
"and",
"return",
"the",
"number",
"of",
"affected",
"rows"
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Db/WpDbAdapter.php#L118-L123 |
13,540 | inpsyde/wp-db-tools | src/Db/WpDbAdapter.php | WpDbAdapter.last_insert_id | public function last_insert_id( Statement $statement = NULL ) {
if ( $statement && ! $this->last_statement === $statement )
return FALSE;
return $this->last_insert_id;
} | php | public function last_insert_id( Statement $statement = NULL ) {
if ( $statement && ! $this->last_statement === $statement )
return FALSE;
return $this->last_insert_id;
} | [
"public",
"function",
"last_insert_id",
"(",
"Statement",
"$",
"statement",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"statement",
"&&",
"!",
"$",
"this",
"->",
"last_statement",
"===",
"$",
"statement",
")",
"return",
"FALSE",
";",
"return",
"$",
"this",
"->",
"last_insert_id",
";",
"}"
]
| Returns the inserted ID of the last executed statement. If a statement
is provided it should be verified that it is the same as the last executed one.
@param Statement $statement (Optional)
@return int|false | [
"Returns",
"the",
"inserted",
"ID",
"of",
"the",
"last",
"executed",
"statement",
".",
"If",
"a",
"statement",
"is",
"provided",
"it",
"should",
"be",
"verified",
"that",
"it",
"is",
"the",
"same",
"as",
"the",
"last",
"executed",
"one",
"."
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Db/WpDbAdapter.php#L133-L139 |
13,541 | inpsyde/wp-db-tools | src/Db/WpDbAdapter.php | WpDbAdapter.last_affected_rows | public function last_affected_rows( Statement $statement = NULL ) {
if ( $statement && ! $this->last_statement === $statement )
return FALSE;
return $this->last_affected_rows;
} | php | public function last_affected_rows( Statement $statement = NULL ) {
if ( $statement && ! $this->last_statement === $statement )
return FALSE;
return $this->last_affected_rows;
} | [
"public",
"function",
"last_affected_rows",
"(",
"Statement",
"$",
"statement",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"statement",
"&&",
"!",
"$",
"this",
"->",
"last_statement",
"===",
"$",
"statement",
")",
"return",
"FALSE",
";",
"return",
"$",
"this",
"->",
"last_affected_rows",
";",
"}"
]
| Returns the number of affected rows of the last executed statement.
If a statement is provided it should be verified that it is the same
as the last executed one.
@param Statement $statement (Optional)
@return mixed | [
"Returns",
"the",
"number",
"of",
"affected",
"rows",
"of",
"the",
"last",
"executed",
"statement",
".",
"If",
"a",
"statement",
"is",
"provided",
"it",
"should",
"be",
"verified",
"that",
"it",
"is",
"the",
"same",
"as",
"the",
"last",
"executed",
"one",
"."
]
| f16f4a96e1e326733ab0ef940e2c9247b6285694 | https://github.com/inpsyde/wp-db-tools/blob/f16f4a96e1e326733ab0ef940e2c9247b6285694/src/Db/WpDbAdapter.php#L150-L156 |
13,542 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.paramExists | public function paramExists($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (strlen($name) == 1) {
return isset($this->shortNames[$name]);
} else {
return isset($this->longNames[$name]);
} //if
} | php | public function paramExists($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (strlen($name) == 1) {
return isset($this->shortNames[$name]);
} else {
return isset($this->longNames[$name]);
} //if
} | [
"public",
"function",
"paramExists",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"1",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
")",
";",
"}",
"else",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"name",
"]",
")",
";",
"}",
"//if",
"}"
]
| checks if parameter is allowed
@author Patrick Forget <patforg at webtrendi.com>
@param string $name either short or long name of the parameter to check
@return boolean true if definition exisits, false otherwise | [
"checks",
"if",
"parameter",
"is",
"allowed"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L85-L96 |
13,543 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.allowsValue | public function allowsValue($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName])) {
return $this->longNames[$longName]['parameterType'] !== false ? true : false;
} else {
return false;
} //if
} | php | public function allowsValue($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName])) {
return $this->longNames[$longName]['parameterType'] !== false ? true : false;
} else {
return false;
} //if
} | [
"public",
"function",
"allowsValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"$",
"longName",
"=",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"1",
"?",
"(",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
":",
"''",
")",
":",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"[",
"'parameterType'",
"]",
"!==",
"false",
"?",
"true",
":",
"false",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"//if",
"}"
]
| checks if parameter allows a value if so what type
@author Patrick Forget <patforg at webtrendi.com>
@param string $name either short or long name of the parameter to check
@return boolean|string false doesn't allow value, The value "string" or "integer" depending which type it allows | [
"checks",
"if",
"parameter",
"allows",
"a",
"value",
"if",
"so",
"what",
"type"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L108-L121 |
13,544 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.getValueType | public function getValueType($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName]['parameterType'])
&& $this->longNames[$longName]['parameterType'] !== false) {
return $this->longNames[$longName]['parameterType'];
} else {
return '';
} //if
} | php | public function getValueType($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName]['parameterType'])
&& $this->longNames[$longName]['parameterType'] !== false) {
return $this->longNames[$longName]['parameterType'];
} else {
return '';
} //if
} | [
"public",
"function",
"getValueType",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"$",
"longName",
"=",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"1",
"?",
"(",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
":",
"''",
")",
":",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"[",
"'parameterType'",
"]",
")",
"&&",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"[",
"'parameterType'",
"]",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"[",
"'parameterType'",
"]",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"//if",
"}"
]
| returns the type of value allowed
@author Patrick Forget <patforg at webtrendi.com> | [
"returns",
"the",
"type",
"of",
"value",
"allowed"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L128-L142 |
13,545 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.getShortName | public function getShortName($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (isset($this->longNames[$name])) {
return $this->longNames[$name]['shortName'];
} else {
return null;
} //if
} | php | public function getShortName($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (isset($this->longNames[$name])) {
return $this->longNames[$name]['shortName'];
} else {
return null;
} //if
} | [
"public",
"function",
"getShortName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"longNames",
"[",
"$",
"name",
"]",
"[",
"'shortName'",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"//if",
"}"
]
| retreive short name of a parameter using its long name
@author Patrick Forget <patforg at webtrendi.com>
@param string $name long name of the parameter to check
@return string character of the short name or null if it doesn't exist | [
"retreive",
"short",
"name",
"of",
"a",
"parameter",
"using",
"its",
"long",
"name"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L178-L189 |
13,546 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.getLongName | public function getLongName($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (isset($this->shortNames[$name])) {
return $this->shortNames[$name];
} else {
return null;
} //if
} | php | public function getLongName($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
if (isset($this->shortNames[$name])) {
return $this->shortNames[$name];
} else {
return null;
} //if
} | [
"public",
"function",
"getLongName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"//if",
"}"
]
| retreive long name of a parameter using its short name
@author Patrick Forget <patforg at webtrendi.com>
@param string $name short name of the parameter to check
@return string long name or null if it doesn't exist | [
"retreive",
"long",
"name",
"of",
"a",
"parameter",
"using",
"its",
"short",
"name"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L200-L211 |
13,547 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.getDescription | public function getDescription($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName])) {
return $this->longNames[$longName]['description'];
} else {
return null;
} //if
} | php | public function getDescription($name)
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
$longName = (strlen($name) == 1 ? ( isset($this->shortNames[$name]) ? $this->shortNames[$name] : '') : $name);
if (isset($this->longNames[$longName])) {
return $this->longNames[$longName]['description'];
} else {
return null;
} //if
} | [
"public",
"function",
"getDescription",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"$",
"longName",
"=",
"(",
"strlen",
"(",
"$",
"name",
")",
"==",
"1",
"?",
"(",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"name",
"]",
":",
"''",
")",
":",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"[",
"'description'",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"//if",
"}"
]
| retreive description of a paramter
@author Patrick Forget <patforg at webtrendi.com>
@param string $name either short or long name of the parameter to check
@return string description or null if it doesn't exist | [
"retreive",
"description",
"of",
"a",
"paramter"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L222-L235 |
13,548 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.getUsage | public function getUsage()
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
/* build list of argument names and calculate
the first column width so we can pad to
align definitions */
$firstCol = array();
$longestDef = 0;
foreach (array_keys($this->longNames) as $longName) {
ob_start();
echo "--{$longName}|-{$this->getShortName($longName)}";
if ($this->allowsValue($longName)) {
echo "={$this->getValueType($longName)}";
} //if
if ($this->allowsMultiple($longName)) {
echo "+";
} //if
$defLength = ob_get_length();
$longestDef = max($longestDef, $defLength);
$firstCol[$longName] = ob_get_contents();
ob_end_clean();
} //foreach
$firstColMaxWidth = $longestDef + 4;
ob_start();
foreach ($firstCol as $longName => $def) {
$currentDefLength = strlen($def);
$padding = str_repeat(" ", $firstColMaxWidth - $currentDefLength);
echo "{$def}{$padding}{$this->getDescription($longName)}", PHP_EOL;
} //foreach
echo PHP_EOL;
$usage = ob_get_contents();
ob_end_clean();
return $usage;
} | php | public function getUsage()
{
if (!$this->isParsed) {
$this->parseDefinitions();
} //if
/* build list of argument names and calculate
the first column width so we can pad to
align definitions */
$firstCol = array();
$longestDef = 0;
foreach (array_keys($this->longNames) as $longName) {
ob_start();
echo "--{$longName}|-{$this->getShortName($longName)}";
if ($this->allowsValue($longName)) {
echo "={$this->getValueType($longName)}";
} //if
if ($this->allowsMultiple($longName)) {
echo "+";
} //if
$defLength = ob_get_length();
$longestDef = max($longestDef, $defLength);
$firstCol[$longName] = ob_get_contents();
ob_end_clean();
} //foreach
$firstColMaxWidth = $longestDef + 4;
ob_start();
foreach ($firstCol as $longName => $def) {
$currentDefLength = strlen($def);
$padding = str_repeat(" ", $firstColMaxWidth - $currentDefLength);
echo "{$def}{$padding}{$this->getDescription($longName)}", PHP_EOL;
} //foreach
echo PHP_EOL;
$usage = ob_get_contents();
ob_end_clean();
return $usage;
} | [
"public",
"function",
"getUsage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsed",
")",
"{",
"$",
"this",
"->",
"parseDefinitions",
"(",
")",
";",
"}",
"//if",
"/* build list of argument names and calculate\n the first column width so we can pad to \n align definitions */",
"$",
"firstCol",
"=",
"array",
"(",
")",
";",
"$",
"longestDef",
"=",
"0",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"longNames",
")",
"as",
"$",
"longName",
")",
"{",
"ob_start",
"(",
")",
";",
"echo",
"\"--{$longName}|-{$this->getShortName($longName)}\"",
";",
"if",
"(",
"$",
"this",
"->",
"allowsValue",
"(",
"$",
"longName",
")",
")",
"{",
"echo",
"\"={$this->getValueType($longName)}\"",
";",
"}",
"//if",
"if",
"(",
"$",
"this",
"->",
"allowsMultiple",
"(",
"$",
"longName",
")",
")",
"{",
"echo",
"\"+\"",
";",
"}",
"//if",
"$",
"defLength",
"=",
"ob_get_length",
"(",
")",
";",
"$",
"longestDef",
"=",
"max",
"(",
"$",
"longestDef",
",",
"$",
"defLength",
")",
";",
"$",
"firstCol",
"[",
"$",
"longName",
"]",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}",
"//foreach",
"$",
"firstColMaxWidth",
"=",
"$",
"longestDef",
"+",
"4",
";",
"ob_start",
"(",
")",
";",
"foreach",
"(",
"$",
"firstCol",
"as",
"$",
"longName",
"=>",
"$",
"def",
")",
"{",
"$",
"currentDefLength",
"=",
"strlen",
"(",
"$",
"def",
")",
";",
"$",
"padding",
"=",
"str_repeat",
"(",
"\" \"",
",",
"$",
"firstColMaxWidth",
"-",
"$",
"currentDefLength",
")",
";",
"echo",
"\"{$def}{$padding}{$this->getDescription($longName)}\"",
",",
"PHP_EOL",
";",
"}",
"//foreach",
"echo",
"PHP_EOL",
";",
"$",
"usage",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"usage",
";",
"}"
]
| builds a usage definition based on definition of params
@author Patrick Forget <patforg at webtrendi.com> | [
"builds",
"a",
"usage",
"definition",
"based",
"on",
"definition",
"of",
"params"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L242-L293 |
13,549 | webtrendi/clapp | src/Clapp/CommandLineArgumentDefinition.php | CommandLineArgumentDefinition.parseDefinitions | protected function parseDefinitions()
{
foreach ($this->definitions as $nameDef => $description) {
$nameParts = explode("|", $nameDef);
if (sizeof($nameParts) !== 2) {
throw new \UnexpectedValueException("Unexpected argument name definition expecting \"longName|char\"");
} //if
$longName = $nameParts[0];
$isMulti = false;
$parameterType = false;
$shortNameLength = strlen($nameParts[1]);
if ($shortNameLength == 1) {
$shortName = $nameParts[1];
} else {
$secondChar = substr($nameParts[1], 1, 1);
switch ($secondChar) {
case '=':
$shortNameParts = explode("=", $nameParts[1]);
$shortName = $shortNameParts[0];
$parameterTypeString = $shortNameParts[1];
if (substr($parameterTypeString, -1) === '+') {
$isMulti = true;
$parameterTypeString = substr($parameterTypeString, 0, -1); // remove trailing +
} //if
switch ($parameterTypeString) {
case 'i':
case 'int':
case 'integer':
$parameterType = 'integer';
break;
case 's':
case 'str':
case 'string':
$parameterType = 'string';
break;
default:
throw new \UnexpectedValueException("Expecting parameter type".
" to be either integer or string");
break;
} //switch
break;
case '+':
if ($shortNameLength > 2) {
throw new \UnexpectedValueException("Multiple flag charachter (+)".
" should be last character in definition");
} //if
$shortName = substr($nameParts[1], 0, 1);
$isMulti = true;
break;
default:
throw new \UnexpectedValueException("Expecting short name definition to be a single char");
break;
} // switch
} //if
if (isset($this->longNames[$longName])) {
throw new \UnexpectedValueException("Cannot redefine long name {$longName}");
} //if
if (isset($this->shortNames[$shortName])) {
throw new \UnexpectedValueException("Cannot redefine short name {$shortName}");
} //if
$this->longNames[$longName] = array(
'shortName' => $shortName,
'isMultipleAllowed' => $isMulti,
'parameterType' => $parameterType,
'description' => $description
);
$this->shortNames[$shortName] = $longName;
} //foreach
$this->isParsed = true;
} | php | protected function parseDefinitions()
{
foreach ($this->definitions as $nameDef => $description) {
$nameParts = explode("|", $nameDef);
if (sizeof($nameParts) !== 2) {
throw new \UnexpectedValueException("Unexpected argument name definition expecting \"longName|char\"");
} //if
$longName = $nameParts[0];
$isMulti = false;
$parameterType = false;
$shortNameLength = strlen($nameParts[1]);
if ($shortNameLength == 1) {
$shortName = $nameParts[1];
} else {
$secondChar = substr($nameParts[1], 1, 1);
switch ($secondChar) {
case '=':
$shortNameParts = explode("=", $nameParts[1]);
$shortName = $shortNameParts[0];
$parameterTypeString = $shortNameParts[1];
if (substr($parameterTypeString, -1) === '+') {
$isMulti = true;
$parameterTypeString = substr($parameterTypeString, 0, -1); // remove trailing +
} //if
switch ($parameterTypeString) {
case 'i':
case 'int':
case 'integer':
$parameterType = 'integer';
break;
case 's':
case 'str':
case 'string':
$parameterType = 'string';
break;
default:
throw new \UnexpectedValueException("Expecting parameter type".
" to be either integer or string");
break;
} //switch
break;
case '+':
if ($shortNameLength > 2) {
throw new \UnexpectedValueException("Multiple flag charachter (+)".
" should be last character in definition");
} //if
$shortName = substr($nameParts[1], 0, 1);
$isMulti = true;
break;
default:
throw new \UnexpectedValueException("Expecting short name definition to be a single char");
break;
} // switch
} //if
if (isset($this->longNames[$longName])) {
throw new \UnexpectedValueException("Cannot redefine long name {$longName}");
} //if
if (isset($this->shortNames[$shortName])) {
throw new \UnexpectedValueException("Cannot redefine short name {$shortName}");
} //if
$this->longNames[$longName] = array(
'shortName' => $shortName,
'isMultipleAllowed' => $isMulti,
'parameterType' => $parameterType,
'description' => $description
);
$this->shortNames[$shortName] = $longName;
} //foreach
$this->isParsed = true;
} | [
"protected",
"function",
"parseDefinitions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"definitions",
"as",
"$",
"nameDef",
"=>",
"$",
"description",
")",
"{",
"$",
"nameParts",
"=",
"explode",
"(",
"\"|\"",
",",
"$",
"nameDef",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"nameParts",
")",
"!==",
"2",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Unexpected argument name definition expecting \\\"longName|char\\\"\"",
")",
";",
"}",
"//if",
"$",
"longName",
"=",
"$",
"nameParts",
"[",
"0",
"]",
";",
"$",
"isMulti",
"=",
"false",
";",
"$",
"parameterType",
"=",
"false",
";",
"$",
"shortNameLength",
"=",
"strlen",
"(",
"$",
"nameParts",
"[",
"1",
"]",
")",
";",
"if",
"(",
"$",
"shortNameLength",
"==",
"1",
")",
"{",
"$",
"shortName",
"=",
"$",
"nameParts",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"secondChar",
"=",
"substr",
"(",
"$",
"nameParts",
"[",
"1",
"]",
",",
"1",
",",
"1",
")",
";",
"switch",
"(",
"$",
"secondChar",
")",
"{",
"case",
"'='",
":",
"$",
"shortNameParts",
"=",
"explode",
"(",
"\"=\"",
",",
"$",
"nameParts",
"[",
"1",
"]",
")",
";",
"$",
"shortName",
"=",
"$",
"shortNameParts",
"[",
"0",
"]",
";",
"$",
"parameterTypeString",
"=",
"$",
"shortNameParts",
"[",
"1",
"]",
";",
"if",
"(",
"substr",
"(",
"$",
"parameterTypeString",
",",
"-",
"1",
")",
"===",
"'+'",
")",
"{",
"$",
"isMulti",
"=",
"true",
";",
"$",
"parameterTypeString",
"=",
"substr",
"(",
"$",
"parameterTypeString",
",",
"0",
",",
"-",
"1",
")",
";",
"// remove trailing +",
"}",
"//if",
"switch",
"(",
"$",
"parameterTypeString",
")",
"{",
"case",
"'i'",
":",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"$",
"parameterType",
"=",
"'integer'",
";",
"break",
";",
"case",
"'s'",
":",
"case",
"'str'",
":",
"case",
"'string'",
":",
"$",
"parameterType",
"=",
"'string'",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Expecting parameter type\"",
".",
"\" to be either integer or string\"",
")",
";",
"break",
";",
"}",
"//switch",
"break",
";",
"case",
"'+'",
":",
"if",
"(",
"$",
"shortNameLength",
">",
"2",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Multiple flag charachter (+)\"",
".",
"\" should be last character in definition\"",
")",
";",
"}",
"//if",
"$",
"shortName",
"=",
"substr",
"(",
"$",
"nameParts",
"[",
"1",
"]",
",",
"0",
",",
"1",
")",
";",
"$",
"isMulti",
"=",
"true",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Expecting short name definition to be a single char\"",
")",
";",
"break",
";",
"}",
"// switch",
"}",
"//if",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Cannot redefine long name {$longName}\"",
")",
";",
"}",
"//if",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"shortName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Cannot redefine short name {$shortName}\"",
")",
";",
"}",
"//if",
"$",
"this",
"->",
"longNames",
"[",
"$",
"longName",
"]",
"=",
"array",
"(",
"'shortName'",
"=>",
"$",
"shortName",
",",
"'isMultipleAllowed'",
"=>",
"$",
"isMulti",
",",
"'parameterType'",
"=>",
"$",
"parameterType",
",",
"'description'",
"=>",
"$",
"description",
")",
";",
"$",
"this",
"->",
"shortNames",
"[",
"$",
"shortName",
"]",
"=",
"$",
"longName",
";",
"}",
"//foreach",
"$",
"this",
"->",
"isParsed",
"=",
"true",
";",
"}"
]
| parses the definitions
@author Patrick Forget <patforg at webtrendi.com> | [
"parses",
"the",
"definitions"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandLineArgumentDefinition.php#L301-L388 |
13,550 | BenConstable/lock | src/BenConstable/Lock/Lock.php | Lock.acquire | public function acquire()
{
if (!$this->locked) {
$this->fp = @fopen($this->filePath, 'a');
if (!$this->fp || !flock($this->fp, LOCK_EX | LOCK_NB)) {
throw new LockException("Could not get lock on {$this->filePath}");
} else {
$this->locked = true;
}
}
return $this;
} | php | public function acquire()
{
if (!$this->locked) {
$this->fp = @fopen($this->filePath, 'a');
if (!$this->fp || !flock($this->fp, LOCK_EX | LOCK_NB)) {
throw new LockException("Could not get lock on {$this->filePath}");
} else {
$this->locked = true;
}
}
return $this;
} | [
"public",
"function",
"acquire",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"locked",
")",
"{",
"$",
"this",
"->",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"filePath",
",",
"'a'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fp",
"||",
"!",
"flock",
"(",
"$",
"this",
"->",
"fp",
",",
"LOCK_EX",
"|",
"LOCK_NB",
")",
")",
"{",
"throw",
"new",
"LockException",
"(",
"\"Could not get lock on {$this->filePath}\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"locked",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Acquire a lock on the resource.
@return \BenConstable\Lock\Lock This, for chaining
@throws \BenConstable\Lock\Exception\LockException If lock could not be acquired | [
"Acquire",
"a",
"lock",
"on",
"the",
"resource",
"."
]
| 40b86cf8c2c4f90374d79c0b0d76999e99ed32c6 | https://github.com/BenConstable/lock/blob/40b86cf8c2c4f90374d79c0b0d76999e99ed32c6/src/BenConstable/Lock/Lock.php#L64-L77 |
13,551 | BenConstable/lock | src/BenConstable/Lock/Lock.php | Lock.release | public function release()
{
if ($this->locked) {
flock($this->fp, LOCK_UN);
fclose($this->fp);
$this->fp = null;
$this->locked = false;
}
return $this;
} | php | public function release()
{
if ($this->locked) {
flock($this->fp, LOCK_UN);
fclose($this->fp);
$this->fp = null;
$this->locked = false;
}
return $this;
} | [
"public",
"function",
"release",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"flock",
"(",
"$",
"this",
"->",
"fp",
",",
"LOCK_UN",
")",
";",
"fclose",
"(",
"$",
"this",
"->",
"fp",
")",
";",
"$",
"this",
"->",
"fp",
"=",
"null",
";",
"$",
"this",
"->",
"locked",
"=",
"false",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Release the lock on the resource, if we have one.
@return \BenConstable\Lock\Lock This, for chaining | [
"Release",
"the",
"lock",
"on",
"the",
"resource",
"if",
"we",
"have",
"one",
"."
]
| 40b86cf8c2c4f90374d79c0b0d76999e99ed32c6 | https://github.com/BenConstable/lock/blob/40b86cf8c2c4f90374d79c0b0d76999e99ed32c6/src/BenConstable/Lock/Lock.php#L84-L95 |
13,552 | econic/CsvReader | Classes/Econic/CsvReader/Reader.php | Reader.addKeys | public function addKeys($keys) {
foreach ((array)$keys as $position => $key) {
$this->keys[$position] = $key;
}
return $this;
} | php | public function addKeys($keys) {
foreach ((array)$keys as $position => $key) {
$this->keys[$position] = $key;
}
return $this;
} | [
"public",
"function",
"addKeys",
"(",
"$",
"keys",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"keys",
"as",
"$",
"position",
"=>",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"keys",
"[",
"$",
"position",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets the keys for the properties
Existing keys will be overridden only when necessary
@param array $keys two dimensional array with the keys | [
"Sets",
"the",
"keys",
"for",
"the",
"properties",
"Existing",
"keys",
"will",
"be",
"overridden",
"only",
"when",
"necessary"
]
| d650c278ab0602ffe1f5847580e0cf0f1c8167ae | https://github.com/econic/CsvReader/blob/d650c278ab0602ffe1f5847580e0cf0f1c8167ae/Classes/Econic/CsvReader/Reader.php#L254-L259 |
13,553 | econic/CsvReader | Classes/Econic/CsvReader/Reader.php | Reader.setKey | public function setKey($location, $key) {
$this->keys[(integer)$location] = (string)$key;
return $this;
} | php | public function setKey($location, $key) {
$this->keys[(integer)$location] = (string)$key;
return $this;
} | [
"public",
"function",
"setKey",
"(",
"$",
"location",
",",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"keys",
"[",
"(",
"integer",
")",
"$",
"location",
"]",
"=",
"(",
"string",
")",
"$",
"key",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the key for a property
@param integer $location which key should be replaced
@param string $key what the new associative key should be named like | [
"Sets",
"the",
"key",
"for",
"a",
"property"
]
| d650c278ab0602ffe1f5847580e0cf0f1c8167ae | https://github.com/econic/CsvReader/blob/d650c278ab0602ffe1f5847580e0cf0f1c8167ae/Classes/Econic/CsvReader/Reader.php#L267-L270 |
13,554 | econic/CsvReader | Classes/Econic/CsvReader/Reader.php | Reader.resetModifiers | public function resetModifiers($key = false) {
if ($key) {
unset($this->modifiers[$key]);
} else {
$this->modifiers = array();
}
return $this;
} | php | public function resetModifiers($key = false) {
if ($key) {
unset($this->modifiers[$key]);
} else {
$this->modifiers = array();
}
return $this;
} | [
"public",
"function",
"resetModifiers",
"(",
"$",
"key",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"modifiers",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modifiers",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| resets the modifiers | [
"resets",
"the",
"modifiers"
]
| d650c278ab0602ffe1f5847580e0cf0f1c8167ae | https://github.com/econic/CsvReader/blob/d650c278ab0602ffe1f5847580e0cf0f1c8167ae/Classes/Econic/CsvReader/Reader.php#L304-L311 |
13,555 | econic/CsvReader | Classes/Econic/CsvReader/Reader.php | Reader.parse | public function parse() {
$lines = str_getcsv($this->source, $this->newline, $this->enclosure, $this->escape);
// add keys from headline if available
if ($this->getSourceHasHeadline()) {
$keys = explode($this->delimiter, $lines[0]);
$this->addKeys($keys);
unset($lines[0]);
}
foreach ($lines as $line) { // iterate over all lines
$values = str_getcsv($line, $this->delimiter, $this->enclosure, $this->escape); // save values in an array
foreach ($values as $key => $value) {
/* remove the escape character, because PHP doesn't do it
* https://bugs.php.net/bug.php?id=55413
*/
$values[$key] = str_replace($this->escape.$this->enclosure, $this->enclosure, $value);
// trim all values if trimming is enabled
if ($this->trim) {
$values[$key] = trim($values[$key]);
}
}
$dataset = array(); // create dataset
foreach ($values as $position => $rawValue) { // iterate over all values
$key = isset($this->keys[$position]) ? $this->keys[$position] : $position; // use the property number or a given key as index
$processedValue = $rawValue;
if (isset($this->modifiers[$key])) { // if there are registered modifiers for that key, let them do their work
foreach ((array)$this->modifiers[$key] as $modifier) {
$processedValue = call_user_func($modifier, $processedValue);
}
}
$dataset[$key] = $processedValue;
}
$this->result[] = $dataset; // add dataset to the final result
}
return $this->result;
} | php | public function parse() {
$lines = str_getcsv($this->source, $this->newline, $this->enclosure, $this->escape);
// add keys from headline if available
if ($this->getSourceHasHeadline()) {
$keys = explode($this->delimiter, $lines[0]);
$this->addKeys($keys);
unset($lines[0]);
}
foreach ($lines as $line) { // iterate over all lines
$values = str_getcsv($line, $this->delimiter, $this->enclosure, $this->escape); // save values in an array
foreach ($values as $key => $value) {
/* remove the escape character, because PHP doesn't do it
* https://bugs.php.net/bug.php?id=55413
*/
$values[$key] = str_replace($this->escape.$this->enclosure, $this->enclosure, $value);
// trim all values if trimming is enabled
if ($this->trim) {
$values[$key] = trim($values[$key]);
}
}
$dataset = array(); // create dataset
foreach ($values as $position => $rawValue) { // iterate over all values
$key = isset($this->keys[$position]) ? $this->keys[$position] : $position; // use the property number or a given key as index
$processedValue = $rawValue;
if (isset($this->modifiers[$key])) { // if there are registered modifiers for that key, let them do their work
foreach ((array)$this->modifiers[$key] as $modifier) {
$processedValue = call_user_func($modifier, $processedValue);
}
}
$dataset[$key] = $processedValue;
}
$this->result[] = $dataset; // add dataset to the final result
}
return $this->result;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"lines",
"=",
"str_getcsv",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"this",
"->",
"newline",
",",
"$",
"this",
"->",
"enclosure",
",",
"$",
"this",
"->",
"escape",
")",
";",
"// add keys from headline if available",
"if",
"(",
"$",
"this",
"->",
"getSourceHasHeadline",
"(",
")",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"$",
"lines",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"addKeys",
"(",
"$",
"keys",
")",
";",
"unset",
"(",
"$",
"lines",
"[",
"0",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"// iterate over all lines",
"$",
"values",
"=",
"str_getcsv",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"delimiter",
",",
"$",
"this",
"->",
"enclosure",
",",
"$",
"this",
"->",
"escape",
")",
";",
"// save values in an array",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"/* remove the escape character, because PHP doesn't do it\n\t\t\t\t * https://bugs.php.net/bug.php?id=55413\n\t\t\t\t */",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"escape",
".",
"$",
"this",
"->",
"enclosure",
",",
"$",
"this",
"->",
"enclosure",
",",
"$",
"value",
")",
";",
"// trim all values if trimming is enabled",
"if",
"(",
"$",
"this",
"->",
"trim",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"dataset",
"=",
"array",
"(",
")",
";",
"// create dataset",
"foreach",
"(",
"$",
"values",
"as",
"$",
"position",
"=>",
"$",
"rawValue",
")",
"{",
"// iterate over all values",
"$",
"key",
"=",
"isset",
"(",
"$",
"this",
"->",
"keys",
"[",
"$",
"position",
"]",
")",
"?",
"$",
"this",
"->",
"keys",
"[",
"$",
"position",
"]",
":",
"$",
"position",
";",
"// use the property number or a given key as index",
"$",
"processedValue",
"=",
"$",
"rawValue",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"modifiers",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// if there are registered modifiers for that key, let them do their work",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"modifiers",
"[",
"$",
"key",
"]",
"as",
"$",
"modifier",
")",
"{",
"$",
"processedValue",
"=",
"call_user_func",
"(",
"$",
"modifier",
",",
"$",
"processedValue",
")",
";",
"}",
"}",
"$",
"dataset",
"[",
"$",
"key",
"]",
"=",
"$",
"processedValue",
";",
"}",
"$",
"this",
"->",
"result",
"[",
"]",
"=",
"$",
"dataset",
";",
"// add dataset to the final result",
"}",
"return",
"$",
"this",
"->",
"result",
";",
"}"
]
| main function, parses the source and returns the result array
@return array result | [
"main",
"function",
"parses",
"the",
"source",
"and",
"returns",
"the",
"result",
"array"
]
| d650c278ab0602ffe1f5847580e0cf0f1c8167ae | https://github.com/econic/CsvReader/blob/d650c278ab0602ffe1f5847580e0cf0f1c8167ae/Classes/Econic/CsvReader/Reader.php#L318-L364 |
13,556 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/PropertyList.php | HTMLPurifier_PropertyList.squash | public function squash($force = false) {
if ($this->cache !== null && !$force) return $this->cache;
if ($this->parent) {
return $this->cache = array_merge($this->parent->squash($force), $this->data);
} else {
return $this->cache = $this->data;
}
} | php | public function squash($force = false) {
if ($this->cache !== null && !$force) return $this->cache;
if ($this->parent) {
return $this->cache = array_merge($this->parent->squash($force), $this->data);
} else {
return $this->cache = $this->data;
}
} | [
"public",
"function",
"squash",
"(",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"!==",
"null",
"&&",
"!",
"$",
"force",
")",
"return",
"$",
"this",
"->",
"cache",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
")",
"{",
"return",
"$",
"this",
"->",
"cache",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"parent",
"->",
"squash",
"(",
"$",
"force",
")",
",",
"$",
"this",
"->",
"data",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"cache",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"}"
]
| Squashes this property list and all of its property lists into a single
array, and returns the array. This value is cached by default.
@param $force If true, ignores the cache and regenerates the array. | [
"Squashes",
"this",
"property",
"list",
"and",
"all",
"of",
"its",
"property",
"lists",
"into",
"a",
"single",
"array",
"and",
"returns",
"the",
"array",
".",
"This",
"value",
"is",
"cached",
"by",
"default",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/PropertyList.php#L62-L69 |
13,557 | ignasbernotas/console | src/Process/Signals.php | Signals.handleExit | public function handleExit(\Closure $callback)
{
// You cannot assign a signal handler for SIGKILL
$this->append(SIGHUP, $callback);
$this->append(SIGINT, $callback);
$this->append(SIGQUIT, $callback);
$this->append(SIGTERM, $callback);
} | php | public function handleExit(\Closure $callback)
{
// You cannot assign a signal handler for SIGKILL
$this->append(SIGHUP, $callback);
$this->append(SIGINT, $callback);
$this->append(SIGQUIT, $callback);
$this->append(SIGTERM, $callback);
} | [
"public",
"function",
"handleExit",
"(",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"// You cannot assign a signal handler for SIGKILL",
"$",
"this",
"->",
"append",
"(",
"SIGHUP",
",",
"$",
"callback",
")",
";",
"$",
"this",
"->",
"append",
"(",
"SIGINT",
",",
"$",
"callback",
")",
";",
"$",
"this",
"->",
"append",
"(",
"SIGQUIT",
",",
"$",
"callback",
")",
";",
"$",
"this",
"->",
"append",
"(",
"SIGTERM",
",",
"$",
"callback",
")",
";",
"}"
]
| Handle application exit signals
@param \Closure $callback callback to run after the signal is received
@return void | [
"Handle",
"application",
"exit",
"signals"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Process/Signals.php#L23-L31 |
13,558 | ignasbernotas/console | src/Process/Signals.php | Signals.append | public function append($signal, Closure $callback)
{
if (empty($this->listeners)) {
declare(ticks = 1);
}
$this->listeners[$signal] = $callback;
pcntl_signal($signal, [$this, "executeListener"]);
return $this;
} | php | public function append($signal, Closure $callback)
{
if (empty($this->listeners)) {
declare(ticks = 1);
}
$this->listeners[$signal] = $callback;
pcntl_signal($signal, [$this, "executeListener"]);
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"signal",
",",
"Closure",
"$",
"callback",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"listeners",
")",
")",
"{",
"declare",
"(",
"ticks",
"=",
"1",
")",
";",
"}",
"$",
"this",
"->",
"listeners",
"[",
"$",
"signal",
"]",
"=",
"$",
"callback",
";",
"pcntl_signal",
"(",
"$",
"signal",
",",
"[",
"$",
"this",
",",
"\"executeListener\"",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add signal listener
@param int $signal signal id
@param \Closure $callback function to run when the signal is
received
@return $this | [
"Add",
"signal",
"listener"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Process/Signals.php#L42-L53 |
13,559 | ignasbernotas/console | src/Process/Signals.php | Signals.executeListener | public function executeListener($signal, $exit = true)
{
$return = null;
if (isset($this->listeners[$signal])) {
$return = call_user_func_array($this->listeners[$signal], [$signal]);
}
if (true === $exit) {
// exit the application
posix_kill(posix_getpid(), SIGKILL);
}
return $return;
} | php | public function executeListener($signal, $exit = true)
{
$return = null;
if (isset($this->listeners[$signal])) {
$return = call_user_func_array($this->listeners[$signal], [$signal]);
}
if (true === $exit) {
// exit the application
posix_kill(posix_getpid(), SIGKILL);
}
return $return;
} | [
"public",
"function",
"executeListener",
"(",
"$",
"signal",
",",
"$",
"exit",
"=",
"true",
")",
"{",
"$",
"return",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"signal",
"]",
")",
")",
"{",
"$",
"return",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"listeners",
"[",
"$",
"signal",
"]",
",",
"[",
"$",
"signal",
"]",
")",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"exit",
")",
"{",
"// exit the application",
"posix_kill",
"(",
"posix_getpid",
"(",
")",
",",
"SIGKILL",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
]
| Method which is executed when a signal is received
@param int $signal signal Id
@param bool $exit
@return mixed | [
"Method",
"which",
"is",
"executed",
"when",
"a",
"signal",
"is",
"received"
]
| 909e613b140413062424d6a465da08aac355be55 | https://github.com/ignasbernotas/console/blob/909e613b140413062424d6a465da08aac355be55/src/Process/Signals.php#L63-L77 |
13,560 | chippyash/Strong-Type | src/Chippyash/Type/TypeFactory.php | TypeFactory.create | public static function create($type, $value, $extra = null)
{
switch (strtolower($type)) {
case 'int':
case 'integer':
return self::createInt($value);
case 'float':
case 'double':
return self::createFloat($value);
case 'string':
return self::createString($value);
case 'bool':
case 'boolean':
return self::createBool($value);
case 'digit':
return self::createDigit($value);
case 'natural':
return self::createNatural($value);
case 'whole':
return self::createWhole($value);
case 'complex':
return self::createComplex($value, $extra);
case 'rational':
return self::createRational($value, $extra);
default:
throw new InvalidTypeException(strtolower($type));
}
} | php | public static function create($type, $value, $extra = null)
{
switch (strtolower($type)) {
case 'int':
case 'integer':
return self::createInt($value);
case 'float':
case 'double':
return self::createFloat($value);
case 'string':
return self::createString($value);
case 'bool':
case 'boolean':
return self::createBool($value);
case 'digit':
return self::createDigit($value);
case 'natural':
return self::createNatural($value);
case 'whole':
return self::createWhole($value);
case 'complex':
return self::createComplex($value, $extra);
case 'rational':
return self::createRational($value, $extra);
default:
throw new InvalidTypeException(strtolower($type));
}
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"type",
",",
"$",
"value",
",",
"$",
"extra",
"=",
"null",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'int'",
":",
"case",
"'integer'",
":",
"return",
"self",
"::",
"createInt",
"(",
"$",
"value",
")",
";",
"case",
"'float'",
":",
"case",
"'double'",
":",
"return",
"self",
"::",
"createFloat",
"(",
"$",
"value",
")",
";",
"case",
"'string'",
":",
"return",
"self",
"::",
"createString",
"(",
"$",
"value",
")",
";",
"case",
"'bool'",
":",
"case",
"'boolean'",
":",
"return",
"self",
"::",
"createBool",
"(",
"$",
"value",
")",
";",
"case",
"'digit'",
":",
"return",
"self",
"::",
"createDigit",
"(",
"$",
"value",
")",
";",
"case",
"'natural'",
":",
"return",
"self",
"::",
"createNatural",
"(",
"$",
"value",
")",
";",
"case",
"'whole'",
":",
"return",
"self",
"::",
"createWhole",
"(",
"$",
"value",
")",
";",
"case",
"'complex'",
":",
"return",
"self",
"::",
"createComplex",
"(",
"$",
"value",
",",
"$",
"extra",
")",
";",
"case",
"'rational'",
":",
"return",
"self",
"::",
"createRational",
"(",
"$",
"value",
",",
"$",
"extra",
")",
";",
"default",
":",
"throw",
"new",
"InvalidTypeException",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"}",
"}"
]
| Generic type factory
@param string $type
@param mixed $value
@param mixed $extra required for some types
@return \Chippyash\Type\AbstractType
@throws InvalidTypeException | [
"Generic",
"type",
"factory"
]
| 9d364c10c68c10f768254fb25b0b1db3dbef6fa9 | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/TypeFactory.php#L39-L66 |
13,561 | chippyash/Strong-Type | src/Chippyash/Type/TypeFactory.php | TypeFactory.createInt | public static function createInt($value)
{
if ($value instanceof NumericTypeInterface) {
return $value->asIntType();
}
if (!is_numeric($value)) {
throw new \InvalidArgumentException("'{$value}' is no valid numeric for IntType");
}
if (self::getRequiredType() == self::TYPE_GMP) {
return new GMPIntType($value);
}
return new IntType($value);
} | php | public static function createInt($value)
{
if ($value instanceof NumericTypeInterface) {
return $value->asIntType();
}
if (!is_numeric($value)) {
throw new \InvalidArgumentException("'{$value}' is no valid numeric for IntType");
}
if (self::getRequiredType() == self::TYPE_GMP) {
return new GMPIntType($value);
}
return new IntType($value);
} | [
"public",
"static",
"function",
"createInt",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"NumericTypeInterface",
")",
"{",
"return",
"$",
"value",
"->",
"asIntType",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"'{$value}' is no valid numeric for IntType\"",
")",
";",
"}",
"if",
"(",
"self",
"::",
"getRequiredType",
"(",
")",
"==",
"self",
"::",
"TYPE_GMP",
")",
"{",
"return",
"new",
"GMPIntType",
"(",
"$",
"value",
")",
";",
"}",
"return",
"new",
"IntType",
"(",
"$",
"value",
")",
";",
"}"
]
| Create an IntType
@param mixed $value
@return \Chippyash\Type\Number\IntType
@throws \InvalidArgumentException | [
"Create",
"an",
"IntType"
]
| 9d364c10c68c10f768254fb25b0b1db3dbef6fa9 | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/TypeFactory.php#L76-L89 |
13,562 | chippyash/Strong-Type | src/Chippyash/Type/TypeFactory.php | TypeFactory.createFloat | public static function createFloat($value)
{
if ($value instanceof NumericTypeInterface) {
return $value->asFloatType();
}
if (!is_numeric($value)) {
throw new \InvalidArgumentException("'{$value}' is no valid numeric for FloatType");
}
if (self::getRequiredType() == self::TYPE_GMP) {
return RationalTypeFactory::create($value);
}
return new FloatType($value);
} | php | public static function createFloat($value)
{
if ($value instanceof NumericTypeInterface) {
return $value->asFloatType();
}
if (!is_numeric($value)) {
throw new \InvalidArgumentException("'{$value}' is no valid numeric for FloatType");
}
if (self::getRequiredType() == self::TYPE_GMP) {
return RationalTypeFactory::create($value);
}
return new FloatType($value);
} | [
"public",
"static",
"function",
"createFloat",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"NumericTypeInterface",
")",
"{",
"return",
"$",
"value",
"->",
"asFloatType",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"'{$value}' is no valid numeric for FloatType\"",
")",
";",
"}",
"if",
"(",
"self",
"::",
"getRequiredType",
"(",
")",
"==",
"self",
"::",
"TYPE_GMP",
")",
"{",
"return",
"RationalTypeFactory",
"::",
"create",
"(",
"$",
"value",
")",
";",
"}",
"return",
"new",
"FloatType",
"(",
"$",
"value",
")",
";",
"}"
]
| Create a FloatType
@param mixed $value
@return \Chippyash\Type\Number\FloatType|\Chippyash\Type\Number\Rational\GMPRationalType
@throws \InvalidArgumentException | [
"Create",
"a",
"FloatType"
]
| 9d364c10c68c10f768254fb25b0b1db3dbef6fa9 | https://github.com/chippyash/Strong-Type/blob/9d364c10c68c10f768254fb25b0b1db3dbef6fa9/src/Chippyash/Type/TypeFactory.php#L99-L113 |
13,563 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createContactFromStdClass | public static function createContactFromStdClass(\stdClass $stdContact): Contact
{
if (empty($stdContact->FirstName)) {
throw new \InvalidArgumentException("stdClass argument must contain FirstName attribute");
}
if (empty($stdContact->Phone)) {
throw new \InvalidArgumentException("stdClass argument must contain Phone attribute");
}
$contact = new Contact(
$stdContact->FirstName,
$stdContact->Phone,
$stdContact->LastName ?? null,
$stdContact->Title ?? null,
$stdContact->Organization ?? null,
$stdContact->Email ?? null,
$stdContact->Notes ?? null
);
return $contact;
} | php | public static function createContactFromStdClass(\stdClass $stdContact): Contact
{
if (empty($stdContact->FirstName)) {
throw new \InvalidArgumentException("stdClass argument must contain FirstName attribute");
}
if (empty($stdContact->Phone)) {
throw new \InvalidArgumentException("stdClass argument must contain Phone attribute");
}
$contact = new Contact(
$stdContact->FirstName,
$stdContact->Phone,
$stdContact->LastName ?? null,
$stdContact->Title ?? null,
$stdContact->Organization ?? null,
$stdContact->Email ?? null,
$stdContact->Notes ?? null
);
return $contact;
} | [
"public",
"static",
"function",
"createContactFromStdClass",
"(",
"\\",
"stdClass",
"$",
"stdContact",
")",
":",
"Contact",
"{",
"if",
"(",
"empty",
"(",
"$",
"stdContact",
"->",
"FirstName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"stdClass argument must contain FirstName attribute\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"stdContact",
"->",
"Phone",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"stdClass argument must contain Phone attribute\"",
")",
";",
"}",
"$",
"contact",
"=",
"new",
"Contact",
"(",
"$",
"stdContact",
"->",
"FirstName",
",",
"$",
"stdContact",
"->",
"Phone",
",",
"$",
"stdContact",
"->",
"LastName",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Title",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Organization",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Email",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Notes",
"??",
"null",
")",
";",
"return",
"$",
"contact",
";",
"}"
]
| Creates a Contact using the stdClass given.
@param \stdClass $stdContact An stdClass object matching the format of the IP1 SMS API.
@return Contact
@throws \InvalidArgumentException Thrown when required parameters in the argument is missing. | [
"Creates",
"a",
"Contact",
"using",
"the",
"stdClass",
"given",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L37-L56 |
13,564 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createContactFromAttributes | public static function createContactFromAttributes(
string $firstName,
string $phoneNumber,
?string $lastName = null,
?string $title = null,
?string $organization = null,
?string $email = null,
?string $notes = null
) : Contact {
return new Contact(
$firstName,
$phoneNumber,
$lastName,
$title,
$organization,
$email,
$notes
);
} | php | public static function createContactFromAttributes(
string $firstName,
string $phoneNumber,
?string $lastName = null,
?string $title = null,
?string $organization = null,
?string $email = null,
?string $notes = null
) : Contact {
return new Contact(
$firstName,
$phoneNumber,
$lastName,
$title,
$organization,
$email,
$notes
);
} | [
"public",
"static",
"function",
"createContactFromAttributes",
"(",
"string",
"$",
"firstName",
",",
"string",
"$",
"phoneNumber",
",",
"?",
"string",
"$",
"lastName",
"=",
"null",
",",
"?",
"string",
"$",
"title",
"=",
"null",
",",
"?",
"string",
"$",
"organization",
"=",
"null",
",",
"?",
"string",
"$",
"email",
"=",
"null",
",",
"?",
"string",
"$",
"notes",
"=",
"null",
")",
":",
"Contact",
"{",
"return",
"new",
"Contact",
"(",
"$",
"firstName",
",",
"$",
"phoneNumber",
",",
"$",
"lastName",
",",
"$",
"title",
",",
"$",
"organization",
",",
"$",
"email",
",",
"$",
"notes",
")",
";",
"}"
]
| Creates a Contact using the parameters given.
@param string $firstName The first name of the contact in question.
@param string $phoneNumber Contact phone number: with country code and without spaces and dashes.
@param string|null $lastName Contact last name.
@param string|null $title Contact title.
@param string|null $organization Contact company or other organization.
@param string|null $email Contact email address.
@param string|null $notes Contact notes.
@return Contact | [
"Creates",
"a",
"Contact",
"using",
"the",
"parameters",
"given",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L68-L86 |
13,565 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createProcessedContactFromStdClassArray | public static function createProcessedContactFromStdClassArray(array $contactArray): ClassValidationArray
{
$contacts = new ClassValidationArray();
foreach ($contactArray as $c) {
$contacts[] = self::createProcessedContactFromStdClass($c);
}
return $contacts;
} | php | public static function createProcessedContactFromStdClassArray(array $contactArray): ClassValidationArray
{
$contacts = new ClassValidationArray();
foreach ($contactArray as $c) {
$contacts[] = self::createProcessedContactFromStdClass($c);
}
return $contacts;
} | [
"public",
"static",
"function",
"createProcessedContactFromStdClassArray",
"(",
"array",
"$",
"contactArray",
")",
":",
"ClassValidationArray",
"{",
"$",
"contacts",
"=",
"new",
"ClassValidationArray",
"(",
")",
";",
"foreach",
"(",
"$",
"contactArray",
"as",
"$",
"c",
")",
"{",
"$",
"contacts",
"[",
"]",
"=",
"self",
"::",
"createProcessedContactFromStdClass",
"(",
"$",
"c",
")",
";",
"}",
"return",
"$",
"contacts",
";",
"}"
]
| Take an array filled with contact stdClasses and returns a ClassValidationArray filled with ProcessedContact.
@param array $contactArray An array filled with stdClass contacts.
@return ClassValidationArray Filled with ProcessedContact. | [
"Take",
"an",
"array",
"filled",
"with",
"contact",
"stdClasses",
"and",
"returns",
"a",
"ClassValidationArray",
"filled",
"with",
"ProcessedContact",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L102-L109 |
13,566 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createProcessedContactFromStdClass | public static function createProcessedContactFromStdClass(\stdClass $stdContact): ProcessedContact
{
if (empty($stdContact->FirstName)) {
throw new \InvalidArgumentException("stdClass argument must contain FirstName attribute");
}
if (empty($stdContact->Phone)) {
throw new \InvalidArgumentException("stdClass argument must contain Phone attribute");
}
$contact = new ProcessedContact(
$stdContact->FirstName,
$stdContact->Phone,
$stdContact->ID,
$stdContact->OwnerID,
$stdContact->LastName ?? null,
$stdContact->Title ?? null,
$stdContact->Organization ?? null,
$stdContact->Email ?? null,
$stdContact->Notes ?? null,
isset($stdContact->Created) ? new \DateTime($stdContact->Created, new \DateTimeZone("UTC")) : null,
isset($stdContact->Modified) ? new \DateTime($stdContact->Modified, new \DateTimeZone("UTC")) : null
);
return $contact;
} | php | public static function createProcessedContactFromStdClass(\stdClass $stdContact): ProcessedContact
{
if (empty($stdContact->FirstName)) {
throw new \InvalidArgumentException("stdClass argument must contain FirstName attribute");
}
if (empty($stdContact->Phone)) {
throw new \InvalidArgumentException("stdClass argument must contain Phone attribute");
}
$contact = new ProcessedContact(
$stdContact->FirstName,
$stdContact->Phone,
$stdContact->ID,
$stdContact->OwnerID,
$stdContact->LastName ?? null,
$stdContact->Title ?? null,
$stdContact->Organization ?? null,
$stdContact->Email ?? null,
$stdContact->Notes ?? null,
isset($stdContact->Created) ? new \DateTime($stdContact->Created, new \DateTimeZone("UTC")) : null,
isset($stdContact->Modified) ? new \DateTime($stdContact->Modified, new \DateTimeZone("UTC")) : null
);
return $contact;
} | [
"public",
"static",
"function",
"createProcessedContactFromStdClass",
"(",
"\\",
"stdClass",
"$",
"stdContact",
")",
":",
"ProcessedContact",
"{",
"if",
"(",
"empty",
"(",
"$",
"stdContact",
"->",
"FirstName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"stdClass argument must contain FirstName attribute\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"stdContact",
"->",
"Phone",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"stdClass argument must contain Phone attribute\"",
")",
";",
"}",
"$",
"contact",
"=",
"new",
"ProcessedContact",
"(",
"$",
"stdContact",
"->",
"FirstName",
",",
"$",
"stdContact",
"->",
"Phone",
",",
"$",
"stdContact",
"->",
"ID",
",",
"$",
"stdContact",
"->",
"OwnerID",
",",
"$",
"stdContact",
"->",
"LastName",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Title",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Organization",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Email",
"??",
"null",
",",
"$",
"stdContact",
"->",
"Notes",
"??",
"null",
",",
"isset",
"(",
"$",
"stdContact",
"->",
"Created",
")",
"?",
"new",
"\\",
"DateTime",
"(",
"$",
"stdContact",
"->",
"Created",
",",
"new",
"\\",
"DateTimeZone",
"(",
"\"UTC\"",
")",
")",
":",
"null",
",",
"isset",
"(",
"$",
"stdContact",
"->",
"Modified",
")",
"?",
"new",
"\\",
"DateTime",
"(",
"$",
"stdContact",
"->",
"Modified",
",",
"new",
"\\",
"DateTimeZone",
"(",
"\"UTC\"",
")",
")",
":",
"null",
")",
";",
"return",
"$",
"contact",
";",
"}"
]
| Creates a ProcessedContact using the stdClass given.
@param \stdClass $stdContact An stdClass object matching the format of the IP1 SMS API.
@return ProcessedContact
@throws \InvalidArgumentException Thrown when required parameters in the argument is missing. | [
"Creates",
"a",
"ProcessedContact",
"using",
"the",
"stdClass",
"given",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L116-L138 |
13,567 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createProcessedGroupFromStdClass | public static function createProcessedGroupFromStdClass(\stdClass $stdGroup): ProcessedGroup
{
return new ProcessedGroup(
$stdGroup->Name,
$stdGroup->Color,
$stdGroup->ID,
$stdGroup->OwnerID,
new \DateTime($stdGroup->Created),
new \DateTime($stdGroup->Modified)
);
} | php | public static function createProcessedGroupFromStdClass(\stdClass $stdGroup): ProcessedGroup
{
return new ProcessedGroup(
$stdGroup->Name,
$stdGroup->Color,
$stdGroup->ID,
$stdGroup->OwnerID,
new \DateTime($stdGroup->Created),
new \DateTime($stdGroup->Modified)
);
} | [
"public",
"static",
"function",
"createProcessedGroupFromStdClass",
"(",
"\\",
"stdClass",
"$",
"stdGroup",
")",
":",
"ProcessedGroup",
"{",
"return",
"new",
"ProcessedGroup",
"(",
"$",
"stdGroup",
"->",
"Name",
",",
"$",
"stdGroup",
"->",
"Color",
",",
"$",
"stdGroup",
"->",
"ID",
",",
"$",
"stdGroup",
"->",
"OwnerID",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"stdGroup",
"->",
"Created",
")",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"stdGroup",
"->",
"Modified",
")",
")",
";",
"}"
]
| Takes a stdClass group and returns a ProcessedGroup.
@param \stdClass $stdGroup A single stdClass group.
@return ProcessedGroup | [
"Takes",
"a",
"stdClass",
"group",
"and",
"returns",
"a",
"ProcessedGroup",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L153-L163 |
13,568 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createProcessedOutGoingSMSFromStdClass | public static function createProcessedOutGoingSMSFromStdClass(\stdClass $stdClassSMS): ProcessedOutGoingSMS
{
return new ProcessedOutGoingSMS(
$stdClassSMS->From,
$stdClassSMS->Message,
$stdClassSMS->To,
$stdClassSMS->ID,
new \DateTime($stdClassSMS->Created ?? null),
new \DateTime($stdClassSMS->Updated ?? null),
$stdClassSMS->Status,
$stdClassSMS->StatusDescription,
$stdClassSMS->BundleID
);
} | php | public static function createProcessedOutGoingSMSFromStdClass(\stdClass $stdClassSMS): ProcessedOutGoingSMS
{
return new ProcessedOutGoingSMS(
$stdClassSMS->From,
$stdClassSMS->Message,
$stdClassSMS->To,
$stdClassSMS->ID,
new \DateTime($stdClassSMS->Created ?? null),
new \DateTime($stdClassSMS->Updated ?? null),
$stdClassSMS->Status,
$stdClassSMS->StatusDescription,
$stdClassSMS->BundleID
);
} | [
"public",
"static",
"function",
"createProcessedOutGoingSMSFromStdClass",
"(",
"\\",
"stdClass",
"$",
"stdClassSMS",
")",
":",
"ProcessedOutGoingSMS",
"{",
"return",
"new",
"ProcessedOutGoingSMS",
"(",
"$",
"stdClassSMS",
"->",
"From",
",",
"$",
"stdClassSMS",
"->",
"Message",
",",
"$",
"stdClassSMS",
"->",
"To",
",",
"$",
"stdClassSMS",
"->",
"ID",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"stdClassSMS",
"->",
"Created",
"??",
"null",
")",
",",
"new",
"\\",
"DateTime",
"(",
"$",
"stdClassSMS",
"->",
"Updated",
"??",
"null",
")",
",",
"$",
"stdClassSMS",
"->",
"Status",
",",
"$",
"stdClassSMS",
"->",
"StatusDescription",
",",
"$",
"stdClassSMS",
"->",
"BundleID",
")",
";",
"}"
]
| Creates a ProcessedOutGoingSMS from an stdClass object.
@param \stdClass $stdClassSMS An stdClass.
@return ProcessedOutGoingSMS | [
"Creates",
"a",
"ProcessedOutGoingSMS",
"from",
"an",
"stdClass",
"object",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L223-L236 |
13,569 | iP1SMS/ip1-php-sdk | src/Recipient/RecipientFactory.php | RecipientFactory.createProcessedOutGoingSMSFromStdClassArray | public static function createProcessedOutGoingSMSFromStdClassArray(array $stdClassArray): ClassValidationArray
{
$array = new ClassValidationArray(ProcessedOutGoingSMS::class);
foreach ($stdClassArray as $stdClass) {
$array[]= self::createProcessedOutGoingSMSFromStdClass($stdClass);
}
return $array;
} | php | public static function createProcessedOutGoingSMSFromStdClassArray(array $stdClassArray): ClassValidationArray
{
$array = new ClassValidationArray(ProcessedOutGoingSMS::class);
foreach ($stdClassArray as $stdClass) {
$array[]= self::createProcessedOutGoingSMSFromStdClass($stdClass);
}
return $array;
} | [
"public",
"static",
"function",
"createProcessedOutGoingSMSFromStdClassArray",
"(",
"array",
"$",
"stdClassArray",
")",
":",
"ClassValidationArray",
"{",
"$",
"array",
"=",
"new",
"ClassValidationArray",
"(",
"ProcessedOutGoingSMS",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"stdClassArray",
"as",
"$",
"stdClass",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"self",
"::",
"createProcessedOutGoingSMSFromStdClass",
"(",
"$",
"stdClass",
")",
";",
"}",
"return",
"$",
"array",
";",
"}"
]
| Creates a ClassValidationArray filled with ProcessedOutGoingSMS given an array of stdClass.
@param array $stdClassArray An array of stdClass OutGoingSMS.
@return ClassValidationArray Filled with ProcessedOutGoingSMS. | [
"Creates",
"a",
"ClassValidationArray",
"filled",
"with",
"ProcessedOutGoingSMS",
"given",
"an",
"array",
"of",
"stdClass",
"."
]
| 348e6572a279363ba689c9e0f5689b83a25930f5 | https://github.com/iP1SMS/ip1-php-sdk/blob/348e6572a279363ba689c9e0f5689b83a25930f5/src/Recipient/RecipientFactory.php#L242-L249 |
13,570 | delatbabel/site-config | src/Repository/ConfigLoaderRepository.php | ConfigLoaderRepository.fetchConfig | public function fetchConfig()
{
if (Cache::has($this->getCacheKey())) {
return Cache::get($this->getCacheKey());
}
return null;
} | php | public function fetchConfig()
{
if (Cache::has($this->getCacheKey())) {
return Cache::get($this->getCacheKey());
}
return null;
} | [
"public",
"function",
"fetchConfig",
"(",
")",
"{",
"if",
"(",
"Cache",
"::",
"has",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
")",
"{",
"return",
"Cache",
"::",
"get",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Fetch the stored config from the cache.
@return mixed | [
"Fetch",
"the",
"stored",
"config",
"from",
"the",
"cache",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Repository/ConfigLoaderRepository.php#L78-L85 |
13,571 | delatbabel/site-config | src/Repository/ConfigLoaderRepository.php | ConfigLoaderRepository.loadEnvironment | public function loadEnvironment()
{
// Fetch the current application environment.
$this->environment = app()->environment();
$this->website_id = null;
// Fetch the current web site data and check to see if it has an
// alternative environment.
$website_data = WebsiteModel::currentWebsiteData();
if (! empty($website_data)) {
if (! empty($website_data['environment'])) {
$this->environment = $website_data['environment'];
}
// We also want the website ID
$this->website_id = $website_data['id'];
}
$this->cache_key = 'site-config.' . $this->environment . '.' . $this->website_id;
return $this;
} | php | public function loadEnvironment()
{
// Fetch the current application environment.
$this->environment = app()->environment();
$this->website_id = null;
// Fetch the current web site data and check to see if it has an
// alternative environment.
$website_data = WebsiteModel::currentWebsiteData();
if (! empty($website_data)) {
if (! empty($website_data['environment'])) {
$this->environment = $website_data['environment'];
}
// We also want the website ID
$this->website_id = $website_data['id'];
}
$this->cache_key = 'site-config.' . $this->environment . '.' . $this->website_id;
return $this;
} | [
"public",
"function",
"loadEnvironment",
"(",
")",
"{",
"// Fetch the current application environment.",
"$",
"this",
"->",
"environment",
"=",
"app",
"(",
")",
"->",
"environment",
"(",
")",
";",
"$",
"this",
"->",
"website_id",
"=",
"null",
";",
"// Fetch the current web site data and check to see if it has an",
"// alternative environment.",
"$",
"website_data",
"=",
"WebsiteModel",
"::",
"currentWebsiteData",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"website_data",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"website_data",
"[",
"'environment'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"environment",
"=",
"$",
"website_data",
"[",
"'environment'",
"]",
";",
"}",
"// We also want the website ID",
"$",
"this",
"->",
"website_id",
"=",
"$",
"website_data",
"[",
"'id'",
"]",
";",
"}",
"$",
"this",
"->",
"cache_key",
"=",
"'site-config.'",
".",
"$",
"this",
"->",
"environment",
".",
"'.'",
".",
"$",
"this",
"->",
"website_id",
";",
"return",
"$",
"this",
";",
"}"
]
| Loads the internal website_id and environment
@return ConfigLoaderRepository | [
"Loads",
"the",
"internal",
"website_id",
"and",
"environment"
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Repository/ConfigLoaderRepository.php#L115-L135 |
13,572 | delatbabel/site-config | src/Repository/ConfigLoaderRepository.php | ConfigLoaderRepository.loadConfiguration | public function loadConfiguration()
{
/** @var ConfigLoaderRepository $repository */
$repository = $this->loadEnvironment();
$cache = $repository->fetchConfig();
if (! empty($cache)) {
return $cache;
}
$config = [];
// Fetch all groups, and fetch the config for each group based on the
// environment and website ID of the current site.
foreach ($repository->fetchAllGroups() as $group) {
$groupConfig = ConfigModel::fetchSettings(
$repository->getEnvironment(),
$repository->getWebsiteId(),
$group
);
$config[$group] = $groupConfig;
}
$repository->storeConfig($config);
return $config;
} | php | public function loadConfiguration()
{
/** @var ConfigLoaderRepository $repository */
$repository = $this->loadEnvironment();
$cache = $repository->fetchConfig();
if (! empty($cache)) {
return $cache;
}
$config = [];
// Fetch all groups, and fetch the config for each group based on the
// environment and website ID of the current site.
foreach ($repository->fetchAllGroups() as $group) {
$groupConfig = ConfigModel::fetchSettings(
$repository->getEnvironment(),
$repository->getWebsiteId(),
$group
);
$config[$group] = $groupConfig;
}
$repository->storeConfig($config);
return $config;
} | [
"public",
"function",
"loadConfiguration",
"(",
")",
"{",
"/** @var ConfigLoaderRepository $repository */",
"$",
"repository",
"=",
"$",
"this",
"->",
"loadEnvironment",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"repository",
"->",
"fetchConfig",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cache",
")",
")",
"{",
"return",
"$",
"cache",
";",
"}",
"$",
"config",
"=",
"[",
"]",
";",
"// Fetch all groups, and fetch the config for each group based on the",
"// environment and website ID of the current site.",
"foreach",
"(",
"$",
"repository",
"->",
"fetchAllGroups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"$",
"groupConfig",
"=",
"ConfigModel",
"::",
"fetchSettings",
"(",
"$",
"repository",
"->",
"getEnvironment",
"(",
")",
",",
"$",
"repository",
"->",
"getWebsiteId",
"(",
")",
",",
"$",
"group",
")",
";",
"$",
"config",
"[",
"$",
"group",
"]",
"=",
"$",
"groupConfig",
";",
"}",
"$",
"repository",
"->",
"storeConfig",
"(",
"$",
"config",
")",
";",
"return",
"$",
"config",
";",
"}"
]
| Load the database backed configuration.
This function does the work of loading the entire site configuration
from the database and returns it as a group => [key=>value] set. The
configuration is retrieved from cache if it already exists there, and
stored into the cache after it is loaded.
@return array | [
"Load",
"the",
"database",
"backed",
"configuration",
"."
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Repository/ConfigLoaderRepository.php#L147-L172 |
13,573 | delatbabel/site-config | src/Repository/ConfigLoaderRepository.php | ConfigLoaderRepository.setRunningConfiguration | public function setRunningConfiguration(RepositoryContract $config)
{
// Load the configuration into the current running config.
foreach ($this->loadConfiguration() as $group => $groupConfig) {
$config->set($group, $groupConfig);
}
} | php | public function setRunningConfiguration(RepositoryContract $config)
{
// Load the configuration into the current running config.
foreach ($this->loadConfiguration() as $group => $groupConfig) {
$config->set($group, $groupConfig);
}
} | [
"public",
"function",
"setRunningConfiguration",
"(",
"RepositoryContract",
"$",
"config",
")",
"{",
"// Load the configuration into the current running config.",
"foreach",
"(",
"$",
"this",
"->",
"loadConfiguration",
"(",
")",
"as",
"$",
"group",
"=>",
"$",
"groupConfig",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"$",
"group",
",",
"$",
"groupConfig",
")",
";",
"}",
"}"
]
| Load the database backed configuration and save it
Load the database backed configuration and save it
into the current running config
@param RepositoryContract $config
@return void | [
"Load",
"the",
"database",
"backed",
"configuration",
"and",
"save",
"it"
]
| e547e63f5ea7140036bb3fe46ff47143b4f93d0f | https://github.com/delatbabel/site-config/blob/e547e63f5ea7140036bb3fe46ff47143b4f93d0f/src/Repository/ConfigLoaderRepository.php#L183-L189 |
13,574 | guillaumemonet/Rad | src/Rad/Utils/Filter.php | Filter.matchFilter | public static function matchFilter(array &$datas, array $get) {
if (sizeof($get) > 0) {
$datas = array_filter($datas, function($obj) use($get) {
return array_intersect_assoc((array) $obj, $get) == $get;
});
}
} | php | public static function matchFilter(array &$datas, array $get) {
if (sizeof($get) > 0) {
$datas = array_filter($datas, function($obj) use($get) {
return array_intersect_assoc((array) $obj, $get) == $get;
});
}
} | [
"public",
"static",
"function",
"matchFilter",
"(",
"array",
"&",
"$",
"datas",
",",
"array",
"$",
"get",
")",
"{",
"if",
"(",
"sizeof",
"(",
"$",
"get",
")",
">",
"0",
")",
"{",
"$",
"datas",
"=",
"array_filter",
"(",
"$",
"datas",
",",
"function",
"(",
"$",
"obj",
")",
"use",
"(",
"$",
"get",
")",
"{",
"return",
"array_intersect_assoc",
"(",
"(",
"array",
")",
"$",
"obj",
",",
"$",
"get",
")",
"==",
"$",
"get",
";",
"}",
")",
";",
"}",
"}"
]
| Return mathing objects with get filter
@param array $datas
@param array $get | [
"Return",
"mathing",
"objects",
"with",
"get",
"filter"
]
| cb9932f570cf3c2a7197f81e1d959c2729989e59 | https://github.com/guillaumemonet/Rad/blob/cb9932f570cf3c2a7197f81e1d959c2729989e59/src/Rad/Utils/Filter.php#L45-L51 |
13,575 | venta/framework | src/Framework/Kernel/Bootstrap/ErrorHandling.php | ErrorHandling.registerErrorRenderer | private function registerErrorRenderer()
{
if ($this->kernel()->isCli()) {
$this->container()->bind(ErrorRendererContract::class, ConsoleErrorRenderer::class);
} else {
$this->container()->bind(ErrorRendererContract::class, HttpErrorRenderer::class);
}
} | php | private function registerErrorRenderer()
{
if ($this->kernel()->isCli()) {
$this->container()->bind(ErrorRendererContract::class, ConsoleErrorRenderer::class);
} else {
$this->container()->bind(ErrorRendererContract::class, HttpErrorRenderer::class);
}
} | [
"private",
"function",
"registerErrorRenderer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"kernel",
"(",
")",
"->",
"isCli",
"(",
")",
")",
"{",
"$",
"this",
"->",
"container",
"(",
")",
"->",
"bind",
"(",
"ErrorRendererContract",
"::",
"class",
",",
"ConsoleErrorRenderer",
"::",
"class",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"container",
"(",
")",
"->",
"bind",
"(",
"ErrorRendererContract",
"::",
"class",
",",
"HttpErrorRenderer",
"::",
"class",
")",
";",
"}",
"}"
]
| Registers the default error renderer. | [
"Registers",
"the",
"default",
"error",
"renderer",
"."
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Framework/Kernel/Bootstrap/ErrorHandling.php#L42-L49 |
13,576 | venta/framework | src/Framework/Kernel/Bootstrap/ErrorHandling.php | ErrorHandling.registerErrorReporters | private function registerErrorReporters()
{
$this->container()->factory(
ErrorReporterAggregateContract::class,
function () {
$reporters = new ErrorReporterAggregate($this->container());
$reporters->push(LogErrorReporter::class);
return $reporters;
},
true
);
} | php | private function registerErrorReporters()
{
$this->container()->factory(
ErrorReporterAggregateContract::class,
function () {
$reporters = new ErrorReporterAggregate($this->container());
$reporters->push(LogErrorReporter::class);
return $reporters;
},
true
);
} | [
"private",
"function",
"registerErrorReporters",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"(",
")",
"->",
"factory",
"(",
"ErrorReporterAggregateContract",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"reporters",
"=",
"new",
"ErrorReporterAggregate",
"(",
"$",
"this",
"->",
"container",
"(",
")",
")",
";",
"$",
"reporters",
"->",
"push",
"(",
"LogErrorReporter",
"::",
"class",
")",
";",
"return",
"$",
"reporters",
";",
"}",
",",
"true",
")",
";",
"}"
]
| Registers default error reporters. | [
"Registers",
"default",
"error",
"reporters",
"."
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Framework/Kernel/Bootstrap/ErrorHandling.php#L54-L66 |
13,577 | venta/framework | src/Http/src/Cookie.php | Cookie.freezeExpiration | private function freezeExpiration(DateTimeInterface $expires): DateTimeImmutable
{
if (!$expires instanceof DateTimeImmutable) {
$expires = new DateTimeImmutable($expires->format(DateTime::ISO8601), $expires->getTimezone());
}
return $expires;
} | php | private function freezeExpiration(DateTimeInterface $expires): DateTimeImmutable
{
if (!$expires instanceof DateTimeImmutable) {
$expires = new DateTimeImmutable($expires->format(DateTime::ISO8601), $expires->getTimezone());
}
return $expires;
} | [
"private",
"function",
"freezeExpiration",
"(",
"DateTimeInterface",
"$",
"expires",
")",
":",
"DateTimeImmutable",
"{",
"if",
"(",
"!",
"$",
"expires",
"instanceof",
"DateTimeImmutable",
")",
"{",
"$",
"expires",
"=",
"new",
"DateTimeImmutable",
"(",
"$",
"expires",
"->",
"format",
"(",
"DateTime",
"::",
"ISO8601",
")",
",",
"$",
"expires",
"->",
"getTimezone",
"(",
")",
")",
";",
"}",
"return",
"$",
"expires",
";",
"}"
]
| Creates immutable date time instance from the provided one.
@param DateTimeInterface $expires
@return DateTimeImmutable | [
"Creates",
"immutable",
"date",
"time",
"instance",
"from",
"the",
"provided",
"one",
"."
]
| 514a7854cc69f84f47e62a58cc55efd68b7c9f83 | https://github.com/venta/framework/blob/514a7854cc69f84f47e62a58cc55efd68b7c9f83/src/Http/src/Cookie.php#L263-L270 |
13,578 | Im0rtality/Underscore | src/Mutator/ShuffleMutator.php | ShuffleMutator.shuffleAssoc | private function shuffleAssoc(array $values)
{
$keys = array_keys($values);
shuffle($keys);
$output = [];
foreach ($keys as $key) {
$output[$key] = $values[$key];
}
return $output;
} | php | private function shuffleAssoc(array $values)
{
$keys = array_keys($values);
shuffle($keys);
$output = [];
foreach ($keys as $key) {
$output[$key] = $values[$key];
}
return $output;
} | [
"private",
"function",
"shuffleAssoc",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"values",
")",
";",
"shuffle",
"(",
"$",
"keys",
")",
";",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"output",
"[",
"$",
"key",
"]",
"=",
"$",
"values",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"output",
";",
"}"
]
| Shuffle an array while preserving keys.
@param array $values
@return array | [
"Shuffle",
"an",
"array",
"while",
"preserving",
"keys",
"."
]
| 2deb95cfd340761d00ecd0f033e67ce600f2b535 | https://github.com/Im0rtality/Underscore/blob/2deb95cfd340761d00ecd0f033e67ce600f2b535/src/Mutator/ShuffleMutator.php#L30-L41 |
13,579 | mimmi20/Wurfl | src/Handlers/AbstractHandler.php | AbstractHandler.updateUserAgentsWithDeviceIDMap | final public function updateUserAgentsWithDeviceIDMap($userAgent, $deviceID)
{
if (isset($this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)])) {
$this->logger->debug($this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)] . "\t"); //old_id
$this->logger->debug($deviceID . "\t"); //new id
$this->logger->debug($this->normalizeUserAgent($userAgent) . "\t\n");//normalized user agent
//$this->logger->printMessage($userAgent . "\t");//cleaned user agent
$this->overwritten_devices[] = $this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)];
}
$this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)] = $deviceID;
} | php | final public function updateUserAgentsWithDeviceIDMap($userAgent, $deviceID)
{
if (isset($this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)])) {
$this->logger->debug($this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)] . "\t"); //old_id
$this->logger->debug($deviceID . "\t"); //new id
$this->logger->debug($this->normalizeUserAgent($userAgent) . "\t\n");//normalized user agent
//$this->logger->printMessage($userAgent . "\t");//cleaned user agent
$this->overwritten_devices[] = $this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)];
}
$this->userAgentsWithDeviceID[$this->normalizeUserAgent($userAgent)] = $deviceID;
} | [
"final",
"public",
"function",
"updateUserAgentsWithDeviceIDMap",
"(",
"$",
"userAgent",
",",
"$",
"deviceID",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"[",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"userAgent",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"[",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"userAgent",
")",
"]",
".",
"\"\\t\"",
")",
";",
"//old_id",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"$",
"deviceID",
".",
"\"\\t\"",
")",
";",
"//new id",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"userAgent",
")",
".",
"\"\\t\\n\"",
")",
";",
"//normalized user agent",
"//$this->logger->printMessage($userAgent . \"\\t\");//cleaned user agent",
"$",
"this",
"->",
"overwritten_devices",
"[",
"]",
"=",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"[",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"userAgent",
")",
"]",
";",
"}",
"$",
"this",
"->",
"userAgentsWithDeviceID",
"[",
"$",
"this",
"->",
"normalizeUserAgent",
"(",
"$",
"userAgent",
")",
"]",
"=",
"$",
"deviceID",
";",
"}"
]
| Updates the map containing the classified user agents. These are stored in the associative
array userAgentsWithDeviceID like user_agent => deviceID.
Before adding the user agent to the map it normalizes by using the normalizeUserAgent
function.
@see normalizeUserAgent()
@see userAgentsWithDeviceID
@param string $userAgent
@param string $deviceID | [
"Updates",
"the",
"map",
"containing",
"the",
"classified",
"user",
"agents",
".",
"These",
"are",
"stored",
"in",
"the",
"associative",
"array",
"userAgentsWithDeviceID",
"like",
"user_agent",
"=",
">",
"deviceID",
".",
"Before",
"adding",
"the",
"user",
"agent",
"to",
"the",
"map",
"it",
"normalizes",
"by",
"using",
"the",
"normalizeUserAgent",
"function",
"."
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/AbstractHandler.php#L169-L179 |
13,580 | mimmi20/Wurfl | src/Handlers/AbstractHandler.php | AbstractHandler.getUserAgentsForBucket | public function getUserAgentsForBucket()
{
if (empty($this->userAgents)) {
$this->userAgents = $this->persistenceProvider->load($this->getPrefix(self::PREFIX_UA_BUCKET));
}
return $this->userAgents;
} | php | public function getUserAgentsForBucket()
{
if (empty($this->userAgents)) {
$this->userAgents = $this->persistenceProvider->load($this->getPrefix(self::PREFIX_UA_BUCKET));
}
return $this->userAgents;
} | [
"public",
"function",
"getUserAgentsForBucket",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"userAgents",
")",
")",
"{",
"$",
"this",
"->",
"userAgents",
"=",
"$",
"this",
"->",
"persistenceProvider",
"->",
"load",
"(",
"$",
"this",
"->",
"getPrefix",
"(",
"self",
"::",
"PREFIX_UA_BUCKET",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"userAgents",
";",
"}"
]
| Returns a list of User Agents associated with the bucket
@return array User agents | [
"Returns",
"a",
"list",
"of",
"User",
"Agents",
"associated",
"with",
"the",
"bucket"
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/Handlers/AbstractHandler.php#L238-L245 |
13,581 | mimmi20/Wurfl | src/VirtualCapability/Tool/DeviceFactory.php | DeviceFactory.normalizeBrowser | private static function normalizeBrowser(Device $device)
{
if ($device->getBrowser()->name === 'IE' && preg_match('#Trident/([\d\.]+)#', $device->getDeviceUa(), $matches)) {
if (array_key_exists($matches[1], self::$trident_map)) {
$compatibilityViewCheck = self::$trident_map[$matches[1]];
if ($device->getBrowser()->version !== $compatibilityViewCheck) {
$device->getBrowser()->version = $compatibilityViewCheck . '(Compatibility View)';
}
return;
}
}
} | php | private static function normalizeBrowser(Device $device)
{
if ($device->getBrowser()->name === 'IE' && preg_match('#Trident/([\d\.]+)#', $device->getDeviceUa(), $matches)) {
if (array_key_exists($matches[1], self::$trident_map)) {
$compatibilityViewCheck = self::$trident_map[$matches[1]];
if ($device->getBrowser()->version !== $compatibilityViewCheck) {
$device->getBrowser()->version = $compatibilityViewCheck . '(Compatibility View)';
}
return;
}
}
} | [
"private",
"static",
"function",
"normalizeBrowser",
"(",
"Device",
"$",
"device",
")",
"{",
"if",
"(",
"$",
"device",
"->",
"getBrowser",
"(",
")",
"->",
"name",
"===",
"'IE'",
"&&",
"preg_match",
"(",
"'#Trident/([\\d\\.]+)#'",
",",
"$",
"device",
"->",
"getDeviceUa",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"self",
"::",
"$",
"trident_map",
")",
")",
"{",
"$",
"compatibilityViewCheck",
"=",
"self",
"::",
"$",
"trident_map",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"if",
"(",
"$",
"device",
"->",
"getBrowser",
"(",
")",
"->",
"version",
"!==",
"$",
"compatibilityViewCheck",
")",
"{",
"$",
"device",
"->",
"getBrowser",
"(",
")",
"->",
"version",
"=",
"$",
"compatibilityViewCheck",
".",
"'(Compatibility View)'",
";",
"}",
"return",
";",
"}",
"}",
"}"
]
| normalize the Browser Information
@param \Wurfl\VirtualCapability\Tool\Device $device | [
"normalize",
"the",
"Browser",
"Information"
]
| 443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec | https://github.com/mimmi20/Wurfl/blob/443ed0d73a0b9a21ebd0d6ddf1e32669b9de44ec/src/VirtualCapability/Tool/DeviceFactory.php#L909-L922 |
13,582 | astronati/php-fantasy-football-quotations-parser | src/Map/Row/Normalizer/Field/NormalizedFieldsContainer.php | NormalizedFieldsContainer.add | public function add(string $type, RowFieldNormalizerInterface $normalizer)
{
$this->normalizers[$type] = $normalizer;
return $this;
} | php | public function add(string $type, RowFieldNormalizerInterface $normalizer)
{
$this->normalizers[$type] = $normalizer;
return $this;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"type",
",",
"RowFieldNormalizerInterface",
"$",
"normalizer",
")",
"{",
"$",
"this",
"->",
"normalizers",
"[",
"$",
"type",
"]",
"=",
"$",
"normalizer",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a new normalized field
@param string $type The name of the field
@param RowFieldNormalizerInterface $normalizer
@return $this | [
"Add",
"a",
"new",
"normalized",
"field"
]
| 1214f313c325ac7e9fc4d5218b85b3d7234f7bf3 | https://github.com/astronati/php-fantasy-football-quotations-parser/blob/1214f313c325ac7e9fc4d5218b85b3d7234f7bf3/src/Map/Row/Normalizer/Field/NormalizedFieldsContainer.php#L18-L22 |
13,583 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/HTMLModuleManager.php | HTMLPurifier_HTMLModuleManager.addModule | public function addModule($module) {
$this->registerModule($module);
if (is_object($module)) $module = $module->name;
$this->userModules[] = $module;
} | php | public function addModule($module) {
$this->registerModule($module);
if (is_object($module)) $module = $module->name;
$this->userModules[] = $module;
} | [
"public",
"function",
"addModule",
"(",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"registerModule",
"(",
"$",
"module",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"module",
")",
")",
"$",
"module",
"=",
"$",
"module",
"->",
"name",
";",
"$",
"this",
"->",
"userModules",
"[",
"]",
"=",
"$",
"module",
";",
"}"
]
| Adds a module to the current doctype by first registering it,
and then tacking it on to the active doctype | [
"Adds",
"a",
"module",
"to",
"the",
"current",
"doctype",
"by",
"first",
"registering",
"it",
"and",
"then",
"tacking",
"it",
"on",
"to",
"the",
"active",
"doctype"
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/HTMLModuleManager.php#L181-L185 |
13,584 | nyeholt/silverstripe-simplewiki | thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/HTMLModuleManager.php | HTMLPurifier_HTMLModuleManager.getElements | public function getElements() {
$elements = array();
foreach ($this->modules as $module) {
if (!$this->trusted && !$module->safe) continue;
foreach ($module->info as $name => $v) {
if (isset($elements[$name])) continue;
$elements[$name] = $this->getElement($name);
}
}
// remove dud elements, this happens when an element that
// appeared to be safe actually wasn't
foreach ($elements as $n => $v) {
if ($v === false) unset($elements[$n]);
}
return $elements;
} | php | public function getElements() {
$elements = array();
foreach ($this->modules as $module) {
if (!$this->trusted && !$module->safe) continue;
foreach ($module->info as $name => $v) {
if (isset($elements[$name])) continue;
$elements[$name] = $this->getElement($name);
}
}
// remove dud elements, this happens when an element that
// appeared to be safe actually wasn't
foreach ($elements as $n => $v) {
if ($v === false) unset($elements[$n]);
}
return $elements;
} | [
"public",
"function",
"getElements",
"(",
")",
"{",
"$",
"elements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"trusted",
"&&",
"!",
"$",
"module",
"->",
"safe",
")",
"continue",
";",
"foreach",
"(",
"$",
"module",
"->",
"info",
"as",
"$",
"name",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"elements",
"[",
"$",
"name",
"]",
")",
")",
"continue",
";",
"$",
"elements",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"getElement",
"(",
"$",
"name",
")",
";",
"}",
"}",
"// remove dud elements, this happens when an element that",
"// appeared to be safe actually wasn't",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"n",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"false",
")",
"unset",
"(",
"$",
"elements",
"[",
"$",
"n",
"]",
")",
";",
"}",
"return",
"$",
"elements",
";",
"}"
]
| Retrieves merged element definitions.
@return Array of HTMLPurifier_ElementDef | [
"Retrieves",
"merged",
"element",
"definitions",
"."
]
| ecffed0d75be1454901e1cb24633472b8f67c967 | https://github.com/nyeholt/silverstripe-simplewiki/blob/ecffed0d75be1454901e1cb24633472b8f67c967/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/HTMLModuleManager.php#L299-L318 |
13,585 | wpup/digster | src/extensions/class-i18n-extensions.php | I18n_Extensions.trans | public function trans( $message ) {
$theme = wp_get_theme();
$domain = $theme->get( 'TextDomain' );
return __( $message, $domain );
} | php | public function trans( $message ) {
$theme = wp_get_theme();
$domain = $theme->get( 'TextDomain' );
return __( $message, $domain );
} | [
"public",
"function",
"trans",
"(",
"$",
"message",
")",
"{",
"$",
"theme",
"=",
"wp_get_theme",
"(",
")",
";",
"$",
"domain",
"=",
"$",
"theme",
"->",
"get",
"(",
"'TextDomain'",
")",
";",
"return",
"__",
"(",
"$",
"message",
",",
"$",
"domain",
")",
";",
"}"
]
| Translate message.
@param string $message
@return string | [
"Translate",
"message",
"."
]
| 9ef9626ce82673af698bc0976d6c38a532e4a6d9 | https://github.com/wpup/digster/blob/9ef9626ce82673af698bc0976d6c38a532e4a6d9/src/extensions/class-i18n-extensions.php#L46-L50 |
13,586 | cbednarski/pharcc | src/cbednarski/Pharcc/Config.php | Config.loadFile | public static function loadFile($path)
{
if (!realpath($path)) {
throw new \RuntimeException('Unable to load configuration file from ' . $path);
}
$data = Yaml::parse($path);
return new static(pathinfo($path, PATHINFO_DIRNAME), $data);
} | php | public static function loadFile($path)
{
if (!realpath($path)) {
throw new \RuntimeException('Unable to load configuration file from ' . $path);
}
$data = Yaml::parse($path);
return new static(pathinfo($path, PATHINFO_DIRNAME), $data);
} | [
"public",
"static",
"function",
"loadFile",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"realpath",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to load configuration file from '",
".",
"$",
"path",
")",
";",
"}",
"$",
"data",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"path",
")",
";",
"return",
"new",
"static",
"(",
"pathinfo",
"(",
"$",
"path",
",",
"PATHINFO_DIRNAME",
")",
",",
"$",
"data",
")",
";",
"}"
]
| Load configuration data from the specified file
@param string $path Read this config file
@return self
@throws \RuntimeException | [
"Load",
"configuration",
"data",
"from",
"the",
"specified",
"file"
]
| 562f9d3d13d2856de6a7ca846a83fe70897baaea | https://github.com/cbednarski/pharcc/blob/562f9d3d13d2856de6a7ca846a83fe70897baaea/src/cbednarski/Pharcc/Config.php#L22-L31 |
13,587 | webtrendi/clapp | src/Clapp/CommandArgumentFilter.php | CommandArgumentFilter.getParam | public function getParam($name)
{
if (!$this->parsed) {
$this->parseParams();
} //if
$longName = strlen($name) === 1 ? $this->definitions->getLongName($name) : $name;
if (isset($this->params[$longName])) {
return $this->params[$longName];
} else {
if ($this->definitions->allowsValue($longName)) {
return null;
} else {
return false;
} //if
} //if
} | php | public function getParam($name)
{
if (!$this->parsed) {
$this->parseParams();
} //if
$longName = strlen($name) === 1 ? $this->definitions->getLongName($name) : $name;
if (isset($this->params[$longName])) {
return $this->params[$longName];
} else {
if ($this->definitions->allowsValue($longName)) {
return null;
} else {
return false;
} //if
} //if
} | [
"public",
"function",
"getParam",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"parsed",
")",
"{",
"$",
"this",
"->",
"parseParams",
"(",
")",
";",
"}",
"//if",
"$",
"longName",
"=",
"strlen",
"(",
"$",
"name",
")",
"===",
"1",
"?",
"$",
"this",
"->",
"definitions",
"->",
"getLongName",
"(",
"$",
"name",
")",
":",
"$",
"name",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"longName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"longName",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"definitions",
"->",
"allowsValue",
"(",
"$",
"longName",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"//if",
"}",
"//if",
"}"
]
| returns parameter matching provided name
@author Patrick Forget <patforg at webtrendi.com>
@param string name of the paramter to retreive
@return mixed if param the param appears only once the method will
return 1 if the parameter doesn't take a value. The specified value
for that param will returned if it does take value.
If many occurence of the param appear the number of occurences will
be returned for params that do not take values. An array of values
will be returned for the parameters that do take values.
If the parameter is not present null if it takes a value and false if
it's not present and doesn't allow values | [
"returns",
"parameter",
"matching",
"provided",
"name"
]
| 2747f7abaefd70c107ef553e01f3d812cfa8241c | https://github.com/webtrendi/clapp/blob/2747f7abaefd70c107ef553e01f3d812cfa8241c/src/Clapp/CommandArgumentFilter.php#L88-L105 |
13,588 | PandaPlatform/framework | src/Panda/Support/Helpers/UrlHelper.php | UrlHelper.get | public static function get($url, $parameters = [], $host = null, $protocol = null)
{
// Check url arguments
if (empty($url)) {
throw new InvalidArgumentException(__METHOD__ . ': The given url is empty.');
}
// Get current url info
$urlInfo = static::info($url);
$finalUrl = ArrayHelper::get($urlInfo, 'path.plain', '', true);
// Build url query
$urlParameters = ArrayHelper::get($urlInfo, 'path.parameters', [], true);
$parameters = ArrayHelper::merge($parameters, $urlParameters);
if (!empty($parameters)) {
$finalUrl .= '?' . http_build_query($parameters);
}
// Set protocol
$host = $host ?: $urlInfo['host'];
$protocol = $protocol ?: $urlInfo['protocol'];
// Resolve URL according to system configuration
return (empty($host) ? '' : $protocol . '://') . static::normalize($host . '/' . $finalUrl);
} | php | public static function get($url, $parameters = [], $host = null, $protocol = null)
{
// Check url arguments
if (empty($url)) {
throw new InvalidArgumentException(__METHOD__ . ': The given url is empty.');
}
// Get current url info
$urlInfo = static::info($url);
$finalUrl = ArrayHelper::get($urlInfo, 'path.plain', '', true);
// Build url query
$urlParameters = ArrayHelper::get($urlInfo, 'path.parameters', [], true);
$parameters = ArrayHelper::merge($parameters, $urlParameters);
if (!empty($parameters)) {
$finalUrl .= '?' . http_build_query($parameters);
}
// Set protocol
$host = $host ?: $urlInfo['host'];
$protocol = $protocol ?: $urlInfo['protocol'];
// Resolve URL according to system configuration
return (empty($host) ? '' : $protocol . '://') . static::normalize($host . '/' . $finalUrl);
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"host",
"=",
"null",
",",
"$",
"protocol",
"=",
"null",
")",
"{",
"// Check url arguments",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"': The given url is empty.'",
")",
";",
"}",
"// Get current url info",
"$",
"urlInfo",
"=",
"static",
"::",
"info",
"(",
"$",
"url",
")",
";",
"$",
"finalUrl",
"=",
"ArrayHelper",
"::",
"get",
"(",
"$",
"urlInfo",
",",
"'path.plain'",
",",
"''",
",",
"true",
")",
";",
"// Build url query",
"$",
"urlParameters",
"=",
"ArrayHelper",
"::",
"get",
"(",
"$",
"urlInfo",
",",
"'path.parameters'",
",",
"[",
"]",
",",
"true",
")",
";",
"$",
"parameters",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"parameters",
",",
"$",
"urlParameters",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"finalUrl",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
";",
"}",
"// Set protocol",
"$",
"host",
"=",
"$",
"host",
"?",
":",
"$",
"urlInfo",
"[",
"'host'",
"]",
";",
"$",
"protocol",
"=",
"$",
"protocol",
"?",
":",
"$",
"urlInfo",
"[",
"'protocol'",
"]",
";",
"// Resolve URL according to system configuration",
"return",
"(",
"empty",
"(",
"$",
"host",
")",
"?",
"''",
":",
"$",
"protocol",
".",
"'://'",
")",
".",
"static",
"::",
"normalize",
"(",
"$",
"host",
".",
"'/'",
".",
"$",
"finalUrl",
")",
";",
"}"
]
| Creates and returns a url with parameters in url encoding.
@param string $url The base url.
@param array $parameters An associative array of parameters as key => value.
@param string $host
@param string $protocol
@return string
@throws InvalidArgumentException | [
"Creates",
"and",
"returns",
"a",
"url",
"with",
"parameters",
"in",
"url",
"encoding",
"."
]
| a78cf051b379896b5a4d5df620988e37a0e632f5 | https://github.com/PandaPlatform/framework/blob/a78cf051b379896b5a4d5df620988e37a0e632f5/src/Panda/Support/Helpers/UrlHelper.php#L33-L58 |
13,589 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.addFiles | public function addFiles($type, $fileArray)
{
$method = 'add' . ucfirst($type) . "Files";
if (method_exists($this, $method))
{
$this->$method($fileArray);
}
else
{
$this->say('Missing method: ' . $method);
}
return true;
} | php | public function addFiles($type, $fileArray)
{
$method = 'add' . ucfirst($type) . "Files";
if (method_exists($this, $method))
{
$this->$method($fileArray);
}
else
{
$this->say('Missing method: ' . $method);
}
return true;
} | [
"public",
"function",
"addFiles",
"(",
"$",
"type",
",",
"$",
"fileArray",
")",
"{",
"$",
"method",
"=",
"'add'",
".",
"ucfirst",
"(",
"$",
"type",
")",
".",
"\"Files\"",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"fileArray",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"say",
"(",
"'Missing method: '",
".",
"$",
"method",
")",
";",
"}",
"return",
"true",
";",
"}"
]
| Add files to array
@param string $type - Type (media, component etc.)
@param array $fileArray - File array
@return bool
@since 1.0 | [
"Add",
"files",
"to",
"array"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L116-L130 |
13,590 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.getFiles | public function getFiles($type)
{
$f = $type . 'Files';
if (property_exists($this, $f))
{
return self::${$f};
}
$this->say('Missing Files: ' . $type);
return "";
} | php | public function getFiles($type)
{
$f = $type . 'Files';
if (property_exists($this, $f))
{
return self::${$f};
}
$this->say('Missing Files: ' . $type);
return "";
} | [
"public",
"function",
"getFiles",
"(",
"$",
"type",
")",
"{",
"$",
"f",
"=",
"$",
"type",
".",
"'Files'",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"f",
")",
")",
"{",
"return",
"self",
"::",
"$",
"{",
"$",
"f",
"}",
";",
"}",
"$",
"this",
"->",
"say",
"(",
"'Missing Files: '",
".",
"$",
"type",
")",
";",
"return",
"\"\"",
";",
"}"
]
| Retrieve the files
@param string $type Type (media, component etc.)
@return mixed
@since 1.0 | [
"Retrieve",
"the",
"files"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L141-L153 |
13,591 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.copyTarget | protected function copyTarget($path, $tar)
{
$map = array();
$hdl = opendir($path);
while ($entry = readdir($hdl))
{
$p = $path . "/" . $entry;
// Ignore hidden files
if (substr($entry, 0, 1) != '.')
{
if (isset($this->getJConfig()->exclude)
&& in_array($entry, explode(',', $this->getJConfig()->exclude)))
{
continue;
}
if (is_file($p))
{
$map[] = array("file" => $entry);
$this->_copy($p, $tar . "/" . $entry);
}
else
{
$map[] = array("folder" => $entry);
$this->_copyDir($p, $tar . "/" . $entry);
}
}
}
closedir($hdl);
return $map;
} | php | protected function copyTarget($path, $tar)
{
$map = array();
$hdl = opendir($path);
while ($entry = readdir($hdl))
{
$p = $path . "/" . $entry;
// Ignore hidden files
if (substr($entry, 0, 1) != '.')
{
if (isset($this->getJConfig()->exclude)
&& in_array($entry, explode(',', $this->getJConfig()->exclude)))
{
continue;
}
if (is_file($p))
{
$map[] = array("file" => $entry);
$this->_copy($p, $tar . "/" . $entry);
}
else
{
$map[] = array("folder" => $entry);
$this->_copyDir($p, $tar . "/" . $entry);
}
}
}
closedir($hdl);
return $map;
} | [
"protected",
"function",
"copyTarget",
"(",
"$",
"path",
",",
"$",
"tar",
")",
"{",
"$",
"map",
"=",
"array",
"(",
")",
";",
"$",
"hdl",
"=",
"opendir",
"(",
"$",
"path",
")",
";",
"while",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"hdl",
")",
")",
"{",
"$",
"p",
"=",
"$",
"path",
".",
"\"/\"",
".",
"$",
"entry",
";",
"// Ignore hidden files",
"if",
"(",
"substr",
"(",
"$",
"entry",
",",
"0",
",",
"1",
")",
"!=",
"'.'",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getJConfig",
"(",
")",
"->",
"exclude",
")",
"&&",
"in_array",
"(",
"$",
"entry",
",",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"getJConfig",
"(",
")",
"->",
"exclude",
")",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"p",
")",
")",
"{",
"$",
"map",
"[",
"]",
"=",
"array",
"(",
"\"file\"",
"=>",
"$",
"entry",
")",
";",
"$",
"this",
"->",
"_copy",
"(",
"$",
"p",
",",
"$",
"tar",
".",
"\"/\"",
".",
"$",
"entry",
")",
";",
"}",
"else",
"{",
"$",
"map",
"[",
"]",
"=",
"array",
"(",
"\"folder\"",
"=>",
"$",
"entry",
")",
";",
"$",
"this",
"->",
"_copyDir",
"(",
"$",
"p",
",",
"$",
"tar",
".",
"\"/\"",
".",
"$",
"entry",
")",
";",
"}",
"}",
"}",
"closedir",
"(",
"$",
"hdl",
")",
";",
"return",
"$",
"map",
";",
"}"
]
| Copies the files and maps them into an array
@param string $path - Folder path
@param string $tar - Target path
@return array
@since 1.0 | [
"Copies",
"the",
"files",
"and",
"maps",
"them",
"into",
"an",
"array"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L236-L270 |
13,592 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.generatePluginFileList | public function generatePluginFileList($files, $plugin)
{
if (!count($files))
{
return "";
}
$text = array();
foreach ($files as $f)
{
foreach ($f as $type => $value)
{
$p = "";
if ($value == $plugin . ".php")
{
$p = ' plugin="' . $plugin . '"';
}
$text[] = "<" . $type . $p . ">" . $value . "</" . $type . ">";
}
}
return implode("\n", $text);
} | php | public function generatePluginFileList($files, $plugin)
{
if (!count($files))
{
return "";
}
$text = array();
foreach ($files as $f)
{
foreach ($f as $type => $value)
{
$p = "";
if ($value == $plugin . ".php")
{
$p = ' plugin="' . $plugin . '"';
}
$text[] = "<" . $type . $p . ">" . $value . "</" . $type . ">";
}
}
return implode("\n", $text);
} | [
"public",
"function",
"generatePluginFileList",
"(",
"$",
"files",
",",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"files",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"text",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"foreach",
"(",
"$",
"f",
"as",
"$",
"type",
"=>",
"$",
"value",
")",
"{",
"$",
"p",
"=",
"\"\"",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"plugin",
".",
"\".php\"",
")",
"{",
"$",
"p",
"=",
"' plugin=\"'",
".",
"$",
"plugin",
".",
"'\"'",
";",
"}",
"$",
"text",
"[",
"]",
"=",
"\"<\"",
".",
"$",
"type",
".",
"$",
"p",
".",
"\">\"",
".",
"$",
"value",
".",
"\"</\"",
".",
"$",
"type",
".",
"\">\"",
";",
"}",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"}"
]
| Generate a list of files for plugins
@param array $files Files and Folders array
@param string $plugin The plugin file
@return string
@since 1.0 | [
"Generate",
"a",
"list",
"of",
"files",
"for",
"plugins"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L379-L405 |
13,593 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.generateModuleFileList | public function generateModuleFileList($files, $module)
{
if (!count($files))
{
return "";
}
$text = array();
foreach ($files as $f)
{
foreach ($f as $type => $value)
{
$p = "";
if ($value == $module . ".php")
{
$p = ' module="' . $module . '"';
}
$text[] = "<" . $type . $p . ">" . $value . "</" . $type . ">";
}
}
return implode("\n", $text);
} | php | public function generateModuleFileList($files, $module)
{
if (!count($files))
{
return "";
}
$text = array();
foreach ($files as $f)
{
foreach ($f as $type => $value)
{
$p = "";
if ($value == $module . ".php")
{
$p = ' module="' . $module . '"';
}
$text[] = "<" . $type . $p . ">" . $value . "</" . $type . ">";
}
}
return implode("\n", $text);
} | [
"public",
"function",
"generateModuleFileList",
"(",
"$",
"files",
",",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"files",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"text",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"f",
")",
"{",
"foreach",
"(",
"$",
"f",
"as",
"$",
"type",
"=>",
"$",
"value",
")",
"{",
"$",
"p",
"=",
"\"\"",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"module",
".",
"\".php\"",
")",
"{",
"$",
"p",
"=",
"' module=\"'",
".",
"$",
"module",
".",
"'\"'",
";",
"}",
"$",
"text",
"[",
"]",
"=",
"\"<\"",
".",
"$",
"type",
".",
"$",
"p",
".",
"\">\"",
".",
"$",
"value",
".",
"\"</\"",
".",
"$",
"type",
".",
"\">\"",
";",
"}",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"}"
]
| Generate a list of files for modules
@param array $files Files and Folders array
@param string $module The module
@return string
@since 1.0 | [
"Generate",
"a",
"list",
"of",
"files",
"for",
"modules"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L417-L443 |
13,594 | joomla-projects/jorobo | src/Tasks/Build/Base.php | Base.resetFiles | public function resetFiles()
{
self::$backendFiles = array();
self::$backendLanguageFiles = array();
self::$frontendFiles = array();
self::$frontendLanguageFiles = array();
self::$mediaFiles = array();
} | php | public function resetFiles()
{
self::$backendFiles = array();
self::$backendLanguageFiles = array();
self::$frontendFiles = array();
self::$frontendLanguageFiles = array();
self::$mediaFiles = array();
} | [
"public",
"function",
"resetFiles",
"(",
")",
"{",
"self",
"::",
"$",
"backendFiles",
"=",
"array",
"(",
")",
";",
"self",
"::",
"$",
"backendLanguageFiles",
"=",
"array",
"(",
")",
";",
"self",
"::",
"$",
"frontendFiles",
"=",
"array",
"(",
")",
";",
"self",
"::",
"$",
"frontendLanguageFiles",
"=",
"array",
"(",
")",
";",
"self",
"::",
"$",
"mediaFiles",
"=",
"array",
"(",
")",
";",
"}"
]
| Reset the files list, before build another part
@return void
@since 1.0 | [
"Reset",
"the",
"files",
"list",
"before",
"build",
"another",
"part"
]
| e72dd0ed15f387739f67cacdbc2c0bd1b427f317 | https://github.com/joomla-projects/jorobo/blob/e72dd0ed15f387739f67cacdbc2c0bd1b427f317/src/Tasks/Build/Base.php#L452-L459 |
13,595 | yidas/php-google-api-client-helper | src/services/People.php | People.findByResource | public static function findByResource($resourceName, $optParams=[])
{
$optParams = ($optParams) ? $optParams : [
'personFields' => self::$personFields,
];
self::$person = self::getService()->people->get($resourceName, $optParams);
self::$resourceName = $resourceName;
return new self;
} | php | public static function findByResource($resourceName, $optParams=[])
{
$optParams = ($optParams) ? $optParams : [
'personFields' => self::$personFields,
];
self::$person = self::getService()->people->get($resourceName, $optParams);
self::$resourceName = $resourceName;
return new self;
} | [
"public",
"static",
"function",
"findByResource",
"(",
"$",
"resourceName",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"$",
"optParams",
"=",
"(",
"$",
"optParams",
")",
"?",
"$",
"optParams",
":",
"[",
"'personFields'",
"=>",
"self",
"::",
"$",
"personFields",
",",
"]",
";",
"self",
"::",
"$",
"person",
"=",
"self",
"::",
"getService",
"(",
")",
"->",
"people",
"->",
"get",
"(",
"$",
"resourceName",
",",
"$",
"optParams",
")",
";",
"self",
"::",
"$",
"resourceName",
"=",
"$",
"resourceName",
";",
"return",
"new",
"self",
";",
"}"
]
| find a contact to cache
@param string $resourceName The resource name of the contact.
@param array $optParams
@return self | [
"find",
"a",
"contact",
"to",
"cache"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/services/People.php#L160-L171 |
13,596 | yidas/php-google-api-client-helper | src/services/People.php | People.listPeopleConnections | public static function listPeopleConnections($optParams=[])
{
$optParams = ($optParams) ? $optParams : [
'pageSize' => 0,
'personFields' => self::$personFields,
];
return self::getService()->people_connections->listPeopleConnections('people/me', $optParams);
} | php | public static function listPeopleConnections($optParams=[])
{
$optParams = ($optParams) ? $optParams : [
'pageSize' => 0,
'personFields' => self::$personFields,
];
return self::getService()->people_connections->listPeopleConnections('people/me', $optParams);
} | [
"public",
"static",
"function",
"listPeopleConnections",
"(",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"$",
"optParams",
"=",
"(",
"$",
"optParams",
")",
"?",
"$",
"optParams",
":",
"[",
"'pageSize'",
"=>",
"0",
",",
"'personFields'",
"=>",
"self",
"::",
"$",
"personFields",
",",
"]",
";",
"return",
"self",
"::",
"getService",
"(",
")",
"->",
"people_connections",
"->",
"listPeopleConnections",
"(",
"'people/me'",
",",
"$",
"optParams",
")",
";",
"}"
]
| list People Connections
@param array $optParams
@return object Google listPeopleConnections() | [
"list",
"People",
"Connections"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/services/People.php#L179-L187 |
13,597 | yidas/php-google-api-client-helper | src/services/People.php | People.getSimpleContacts | public static function getSimpleContacts()
{
$contactObj = self::listPeopleConnections();
// Parser
$contacts = [];
if (count($contactObj->getConnections()) != 0) {
foreach ($contactObj->getConnections() as $person) {
// var_dump($person);exit;
$data = [];
// Resource name
$data['id'] = $person->getResourceName();
$data['name'] = isset($person->getNames()[0])
? $person->getNames()[0]->getDisplayName()
: null;
$data['email'] = isset($person->getEmailAddresses()[0])
? $person->getEmailAddresses()[0]->getValue()
: null;
$data['phone'] = isset($person->getPhoneNumbers()[0])
? $person->getPhoneNumbers()[0]->getValue()
: null;
$contacts[] = $data;
}
}
return $contacts;
} | php | public static function getSimpleContacts()
{
$contactObj = self::listPeopleConnections();
// Parser
$contacts = [];
if (count($contactObj->getConnections()) != 0) {
foreach ($contactObj->getConnections() as $person) {
// var_dump($person);exit;
$data = [];
// Resource name
$data['id'] = $person->getResourceName();
$data['name'] = isset($person->getNames()[0])
? $person->getNames()[0]->getDisplayName()
: null;
$data['email'] = isset($person->getEmailAddresses()[0])
? $person->getEmailAddresses()[0]->getValue()
: null;
$data['phone'] = isset($person->getPhoneNumbers()[0])
? $person->getPhoneNumbers()[0]->getValue()
: null;
$contacts[] = $data;
}
}
return $contacts;
} | [
"public",
"static",
"function",
"getSimpleContacts",
"(",
")",
"{",
"$",
"contactObj",
"=",
"self",
"::",
"listPeopleConnections",
"(",
")",
";",
"// Parser\r",
"$",
"contacts",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"contactObj",
"->",
"getConnections",
"(",
")",
")",
"!=",
"0",
")",
"{",
"foreach",
"(",
"$",
"contactObj",
"->",
"getConnections",
"(",
")",
"as",
"$",
"person",
")",
"{",
"// var_dump($person);exit;\r",
"$",
"data",
"=",
"[",
"]",
";",
"// Resource name\r",
"$",
"data",
"[",
"'id'",
"]",
"=",
"$",
"person",
"->",
"getResourceName",
"(",
")",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"isset",
"(",
"$",
"person",
"->",
"getNames",
"(",
")",
"[",
"0",
"]",
")",
"?",
"$",
"person",
"->",
"getNames",
"(",
")",
"[",
"0",
"]",
"->",
"getDisplayName",
"(",
")",
":",
"null",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"isset",
"(",
"$",
"person",
"->",
"getEmailAddresses",
"(",
")",
"[",
"0",
"]",
")",
"?",
"$",
"person",
"->",
"getEmailAddresses",
"(",
")",
"[",
"0",
"]",
"->",
"getValue",
"(",
")",
":",
"null",
";",
"$",
"data",
"[",
"'phone'",
"]",
"=",
"isset",
"(",
"$",
"person",
"->",
"getPhoneNumbers",
"(",
")",
"[",
"0",
"]",
")",
"?",
"$",
"person",
"->",
"getPhoneNumbers",
"(",
")",
"[",
"0",
"]",
"->",
"getValue",
"(",
")",
":",
"null",
";",
"$",
"contacts",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"return",
"$",
"contacts",
";",
"}"
]
| Get simple contact data with parser
@return array Contacts | [
"Get",
"simple",
"contact",
"data",
"with",
"parser"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/services/People.php#L194-L224 |
13,598 | yidas/php-google-api-client-helper | src/services/People.php | People.createContact | public static function createContact()
{
$person = self::getPerson();
// New person check
if (isset($person->resourceName)) {
throw new Exception("You should use newPeron() before create", 500);
}
return self::getService()->people->createContact($person);
} | php | public static function createContact()
{
$person = self::getPerson();
// New person check
if (isset($person->resourceName)) {
throw new Exception("You should use newPeron() before create", 500);
}
return self::getService()->people->createContact($person);
} | [
"public",
"static",
"function",
"createContact",
"(",
")",
"{",
"$",
"person",
"=",
"self",
"::",
"getPerson",
"(",
")",
";",
"// New person check\r",
"if",
"(",
"isset",
"(",
"$",
"person",
"->",
"resourceName",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"You should use newPeron() before create\"",
",",
"500",
")",
";",
"}",
"return",
"self",
"::",
"getService",
"(",
")",
"->",
"people",
"->",
"createContact",
"(",
"$",
"person",
")",
";",
"}"
]
| Create a People Contact
@return Google_Service_PeopleService_Person | [
"Create",
"a",
"People",
"Contact"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/services/People.php#L231-L241 |
13,599 | yidas/php-google-api-client-helper | src/services/People.php | People.updateContact | public static function updateContact($optParams=null)
{
self::checkFind();
// Default opt helper
$optParams = (is_null($optParams))
? ['updatePersonFields' => self::$personFields]
: $optParams;
return self::getService()->people->updateContact(self::$resourceName, self::getPerson(), $optParams);
} | php | public static function updateContact($optParams=null)
{
self::checkFind();
// Default opt helper
$optParams = (is_null($optParams))
? ['updatePersonFields' => self::$personFields]
: $optParams;
return self::getService()->people->updateContact(self::$resourceName, self::getPerson(), $optParams);
} | [
"public",
"static",
"function",
"updateContact",
"(",
"$",
"optParams",
"=",
"null",
")",
"{",
"self",
"::",
"checkFind",
"(",
")",
";",
"// Default opt helper\r",
"$",
"optParams",
"=",
"(",
"is_null",
"(",
"$",
"optParams",
")",
")",
"?",
"[",
"'updatePersonFields'",
"=>",
"self",
"::",
"$",
"personFields",
"]",
":",
"$",
"optParams",
";",
"return",
"self",
"::",
"getService",
"(",
")",
"->",
"people",
"->",
"updateContact",
"(",
"self",
"::",
"$",
"resourceName",
",",
"self",
"::",
"getPerson",
"(",
")",
",",
"$",
"optParams",
")",
";",
"}"
]
| Update a People Contact
@param array $optParams Optional parameters.
@return Google_Service_PeopleService_PeopleEmpty | [
"Update",
"a",
"People",
"Contact"
]
| e0edfebc41fb4e55bcf4125af58304894a2863fe | https://github.com/yidas/php-google-api-client-helper/blob/e0edfebc41fb4e55bcf4125af58304894a2863fe/src/services/People.php#L249-L259 |
Subsets and Splits