repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.getProperty | public function getProperty($id, $name, $directAccess = false)
{
if ($directAccess) {
if (!isset($this->items[$id][$name])) {
return null;
}
return $this->items[$id][$name];
}
$id = $this->validateAndResolveId($id);
if (!isset($this->items[$id][$name]) && !array_key_exists($name, $this->items[$id])) {
throw new Exception\LogicException(
sprintf('The "%s" item does not have "%s" property.', $id, $name)
);
}
return $this->items[$id][$name];
} | php | public function getProperty($id, $name, $directAccess = false)
{
if ($directAccess) {
if (!isset($this->items[$id][$name])) {
return null;
}
return $this->items[$id][$name];
}
$id = $this->validateAndResolveId($id);
if (!isset($this->items[$id][$name]) && !array_key_exists($name, $this->items[$id])) {
throw new Exception\LogicException(
sprintf('The "%s" item does not have "%s" property.', $id, $name)
);
}
return $this->items[$id][$name];
} | [
"public",
"function",
"getProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"directAccess",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"directAccess",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not have \"%s\" property.'",
",",
"$",
"id",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets a value of an additional property for the layout item
@param string $id The id or alias of the layout item
@param string $name The property name
@param bool $directAccess Indicated whether the item id and property name validation should be skipped.
This flag can be used to increase performance of get operation,
but use it carefully and only when you absolutely sure that:
* the item with the specified id exists
* the value passed as the item id is not an alias
* the property with the specified name exists
@return mixed
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
@throws Exception\LogicException if the layout item does not have the requested property | [
"Gets",
"a",
"value",
"of",
"an",
"additional",
"property",
"for",
"the",
"layout",
"item"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L352-L370 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.setProperty | public function setProperty($id, $name, $value)
{
$id = $this->validateAndResolveId($id);
$this->items[$id][$name] = $value;
} | php | public function setProperty($id, $name, $value)
{
$id = $this->validateAndResolveId($id);
$this->items[$id][$name] = $value;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] | Sets a value of an additional property for the layout item
@param string $id The id or alias of the layout item
@param string $name The property name
@param mixed $value The property value
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist | [
"Sets",
"a",
"value",
"of",
"an",
"additional",
"property",
"for",
"the",
"layout",
"item"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L382-L387 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.addAlias | public function addAlias($alias, $id)
{
$this->validateAlias($alias, true);
$this->validateId($id, true);
// perform additional validations
if ($alias === $id) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because an alias cannot be equal to the item id.',
$alias,
$id
)
);
}
if (isset($this->items[$alias])) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because another item with the same id exists.',
$alias,
$id
)
);
}
if (!isset($this->items[$this->resolveId($id)])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
$this->aliases->add($alias, $id);
} | php | public function addAlias($alias, $id)
{
$this->validateAlias($alias, true);
$this->validateId($id, true);
// perform additional validations
if ($alias === $id) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because an alias cannot be equal to the item id.',
$alias,
$id
)
);
}
if (isset($this->items[$alias])) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because another item with the same id exists.',
$alias,
$id
)
);
}
if (!isset($this->items[$this->resolveId($id)])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
$this->aliases->add($alias, $id);
} | [
"public",
"function",
"addAlias",
"(",
"$",
"alias",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"validateAlias",
"(",
"$",
"alias",
",",
"true",
")",
";",
"$",
"this",
"->",
"validateId",
"(",
"$",
"id",
",",
"true",
")",
";",
"// perform additional validations",
"if",
"(",
"$",
"alias",
"===",
"$",
"id",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" sting cannot be used as an alias for \"%s\" item'",
".",
"' because an alias cannot be equal to the item id.'",
",",
"$",
"alias",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" sting cannot be used as an alias for \"%s\" item'",
".",
"' because another item with the same id exists.'",
",",
"$",
"alias",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"id",
")",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not exist.'",
",",
"$",
"id",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"->",
"add",
"(",
"$",
"alias",
",",
"$",
"id",
")",
";",
"}"
] | Creates an alias for the specified layout item
@param string $alias A string that can be used to access to the layout item instead of its id
@param string $id The layout item id
@throws Exception\InvalidArgumentException if the alias or id are empty or invalid
@throws Exception\ItemNotFoundException if the layout item with the given id does not exist
@throws Exception\AliasAlreadyExistsException if the alias is used for another layout item
@throws Exception\LogicException if the alias cannot be added by other reasons | [
"Creates",
"an",
"alias",
"for",
"the",
"specified",
"layout",
"item"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L412-L442 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.removeAlias | public function removeAlias($alias)
{
$this->validateAlias($alias);
if (!$this->aliases->has($alias)) {
throw new Exception\AliasNotFoundException(sprintf('The "%s" item alias does not exist.', $alias));
}
$this->aliases->remove($alias);
} | php | public function removeAlias($alias)
{
$this->validateAlias($alias);
if (!$this->aliases->has($alias)) {
throw new Exception\AliasNotFoundException(sprintf('The "%s" item alias does not exist.', $alias));
}
$this->aliases->remove($alias);
} | [
"public",
"function",
"removeAlias",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"validateAlias",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"aliases",
"->",
"has",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"AliasNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item alias does not exist.'",
",",
"$",
"alias",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"}"
] | Removes the layout item alias
@param string $alias The layout item alias
@throws Exception\InvalidArgumentException if the alias is empty
@throws Exception\AliasNotFoundException if the alias does not exist | [
"Removes",
"the",
"layout",
"item",
"alias"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L452-L460 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.setBlockTheme | public function setBlockTheme($id, $themes)
{
$id = $this->validateAndResolveId($id);
if (empty($themes)) {
throw new Exception\InvalidArgumentException('The theme must not be empty.');
}
if (!is_string($themes) && !is_array($themes)) {
throw new Exception\UnexpectedTypeException($themes, 'string or array of strings', 'themes');
}
if (!isset($this->blockThemes[$id])) {
$this->blockThemes[$id] = (array)$themes;
} else {
$this->blockThemes[$id] = array_merge($this->blockThemes[$id], (array)$themes);
}
} | php | public function setBlockTheme($id, $themes)
{
$id = $this->validateAndResolveId($id);
if (empty($themes)) {
throw new Exception\InvalidArgumentException('The theme must not be empty.');
}
if (!is_string($themes) && !is_array($themes)) {
throw new Exception\UnexpectedTypeException($themes, 'string or array of strings', 'themes');
}
if (!isset($this->blockThemes[$id])) {
$this->blockThemes[$id] = (array)$themes;
} else {
$this->blockThemes[$id] = array_merge($this->blockThemes[$id], (array)$themes);
}
} | [
"public",
"function",
"setBlockTheme",
"(",
"$",
"id",
",",
"$",
"themes",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"themes",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The theme must not be empty.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"themes",
")",
"&&",
"!",
"is_array",
"(",
"$",
"themes",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"themes",
",",
"'string or array of strings'",
",",
"'themes'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"id",
"]",
"=",
"(",
"array",
")",
"$",
"themes",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"id",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"id",
"]",
",",
"(",
"array",
")",
"$",
"themes",
")",
";",
"}",
"}"
] | Sets the theme(s) to be used for rendering the layout item and its children
@param string $id The id of the layout item to assign the theme(s) to
@param string|string[] $themes The theme(s). For example 'MyBundle:Layout:my_theme.html.twig'
@return self | [
"Sets",
"the",
"theme",
"(",
"s",
")",
"to",
"be",
"used",
"for",
"rendering",
"the",
"layout",
"item",
"and",
"its",
"children"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L503-L517 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.setFormTheme | public function setFormTheme($themes)
{
if (empty($themes)) {
throw new Exception\InvalidArgumentException('The theme must not be empty.');
}
if (!is_string($themes) && !is_array($themes)) {
throw new Exception\UnexpectedTypeException($themes, 'string or array of strings', 'themes');
}
$this->formThemes = array_merge($this->formThemes, (array)$themes);
} | php | public function setFormTheme($themes)
{
if (empty($themes)) {
throw new Exception\InvalidArgumentException('The theme must not be empty.');
}
if (!is_string($themes) && !is_array($themes)) {
throw new Exception\UnexpectedTypeException($themes, 'string or array of strings', 'themes');
}
$this->formThemes = array_merge($this->formThemes, (array)$themes);
} | [
"public",
"function",
"setFormTheme",
"(",
"$",
"themes",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"themes",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The theme must not be empty.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"themes",
")",
"&&",
"!",
"is_array",
"(",
"$",
"themes",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"themes",
",",
"'string or array of strings'",
",",
"'themes'",
")",
";",
"}",
"$",
"this",
"->",
"formThemes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"formThemes",
",",
"(",
"array",
")",
"$",
"themes",
")",
";",
"}"
] | Sets the theme(s) to be used for rendering the layout item and its children
@param string|string[] $themes The theme(s). For example 'MyBundle:Layout:my_theme.html.twig'
@return self | [
"Sets",
"the",
"theme",
"(",
"s",
")",
"to",
"be",
"used",
"for",
"rendering",
"the",
"layout",
"item",
"and",
"its",
"children"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L542-L552 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.getHierarchy | public function getHierarchy($id)
{
$path = $this->getProperty($id, self::PATH);
return $this->hierarchy->get($path);
} | php | public function getHierarchy($id)
{
$path = $this->getProperty($id, self::PATH);
return $this->hierarchy->get($path);
} | [
"public",
"function",
"getHierarchy",
"(",
"$",
"id",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"id",
",",
"self",
"::",
"PATH",
")",
";",
"return",
"$",
"this",
"->",
"hierarchy",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}"
] | Returns the layout items hierarchy from the given path
@param string $id The id or alias of the layout item
@return array
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist | [
"Returns",
"the",
"layout",
"items",
"hierarchy",
"from",
"the",
"given",
"path"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L564-L569 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.getHierarchyIterator | public function getHierarchyIterator($id)
{
$id = $this->validateAndResolveId($id);
$children = $this->hierarchy->get($this->getProperty($id, self::PATH, true));
return new HierarchyIterator($id, $children);
} | php | public function getHierarchyIterator($id)
{
$id = $this->validateAndResolveId($id);
$children = $this->hierarchy->get($this->getProperty($id, self::PATH, true));
return new HierarchyIterator($id, $children);
} | [
"public",
"function",
"getHierarchyIterator",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"$",
"children",
"=",
"$",
"this",
"->",
"hierarchy",
"->",
"get",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"id",
",",
"self",
"::",
"PATH",
",",
"true",
")",
")",
";",
"return",
"new",
"HierarchyIterator",
"(",
"$",
"id",
",",
"$",
"children",
")",
";",
"}"
] | Returns an iterator which can be used to get ids of all children of the given item
The iteration is performed from parent to child
@param string $id The id or alias of the layout item
@return HierarchyIterator
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist | [
"Returns",
"an",
"iterator",
"which",
"can",
"be",
"used",
"to",
"get",
"ids",
"of",
"all",
"children",
"of",
"the",
"given",
"item",
"The",
"iteration",
"is",
"performed",
"from",
"parent",
"to",
"child"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L582-L588 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.validateId | protected function validateId($id, $fullCheck = false)
{
if (!$id) {
throw new Exception\InvalidArgumentException('The item id must not be empty.');
}
if ($fullCheck) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException($id, 'string', 'id');
}
if (!$this->isValidId($id)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item id because it contains illegal characters. '
. 'The valid item id should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$id
)
);
}
}
} | php | protected function validateId($id, $fullCheck = false)
{
if (!$id) {
throw new Exception\InvalidArgumentException('The item id must not be empty.');
}
if ($fullCheck) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException($id, 'string', 'id');
}
if (!$this->isValidId($id)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item id because it contains illegal characters. '
. 'The valid item id should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$id
)
);
}
}
} | [
"protected",
"function",
"validateId",
"(",
"$",
"id",
",",
"$",
"fullCheck",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The item id must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"fullCheck",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"id",
",",
"'string'",
",",
"'id'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidId",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" string cannot be used as the item id because it contains illegal characters. '",
".",
"'The valid item id should start with a letter and only contain '",
".",
"'letters, numbers, underscores (\"_\"), hyphens (\"-\") and colons (\":\").'",
",",
"$",
"id",
")",
")",
";",
"}",
"}",
"}"
] | Checks if the given value can be used as the layout item id
@param string $id The layout item id
@param bool $fullCheck Determines whether all validation rules should be applied
or it is required to validate for empty value only
@throws Exception\InvalidArgumentException if the id is not valid | [
"Checks",
"if",
"the",
"given",
"value",
"can",
"be",
"used",
"as",
"the",
"layout",
"item",
"id"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L636-L656 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.validateAndResolveId | protected function validateAndResolveId($id)
{
$this->validateId($id);
$id = $this->resolveId($id);
if (!isset($this->items[$id])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
return $id;
} | php | protected function validateAndResolveId($id)
{
$this->validateId($id);
$id = $this->resolveId($id);
if (!isset($this->items[$id])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
return $id;
} | [
"protected",
"function",
"validateAndResolveId",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"validateId",
"(",
"$",
"id",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not exist.'",
",",
"$",
"id",
")",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] | Checks the layout item id for empty and returns real id
Also this method raises an exception if the layout item does not exist
@param string $id The layout item id
@return string The resolved item id
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist | [
"Checks",
"the",
"layout",
"item",
"id",
"for",
"empty",
"and",
"returns",
"real",
"id",
"Also",
"this",
"method",
"raises",
"an",
"exception",
"if",
"the",
"layout",
"item",
"does",
"not",
"exist"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L669-L678 |
oroinc/OroLayoutComponent | RawLayout.php | RawLayout.validateAlias | protected function validateAlias($alias, $fullCheck = false)
{
if (!$alias) {
throw new Exception\InvalidArgumentException('The item alias must not be empty.');
}
if ($fullCheck) {
if (!is_string($alias)) {
throw new Exception\UnexpectedTypeException($alias, 'string', 'alias');
}
if (!$this->isValidId($alias)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item alias because it contains illegal characters. '
. 'The valid alias should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$alias
)
);
}
}
} | php | protected function validateAlias($alias, $fullCheck = false)
{
if (!$alias) {
throw new Exception\InvalidArgumentException('The item alias must not be empty.');
}
if ($fullCheck) {
if (!is_string($alias)) {
throw new Exception\UnexpectedTypeException($alias, 'string', 'alias');
}
if (!$this->isValidId($alias)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item alias because it contains illegal characters. '
. 'The valid alias should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$alias
)
);
}
}
} | [
"protected",
"function",
"validateAlias",
"(",
"$",
"alias",
",",
"$",
"fullCheck",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"alias",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The item alias must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"fullCheck",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"alias",
",",
"'string'",
",",
"'alias'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidId",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" string cannot be used as the item alias because it contains illegal characters. '",
".",
"'The valid alias should start with a letter and only contain '",
".",
"'letters, numbers, underscores (\"_\"), hyphens (\"-\") and colons (\":\").'",
",",
"$",
"alias",
")",
")",
";",
"}",
"}",
"}"
] | Checks if the given value can be used as an alias for the layout item
@param string $alias The layout item alias
@param bool $fullCheck Determines whether all validation rules should be applied
or it is required to validate for empty value only
@throws Exception\InvalidArgumentException if the alias is not valid | [
"Checks",
"if",
"the",
"given",
"value",
"can",
"be",
"used",
"as",
"an",
"alias",
"for",
"the",
"layout",
"item"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L689-L709 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupEnvironment('administrator', $input, $output);
// Enable debug, so that JInstaller::install() throws exceptions on problems
$this->joomla->setCfg('debug', 1);
$installer = \JInstaller::getInstance();
if ($installer->install($this->handleExtension($input, $output)))
{
$output->writeln($this->getExtensionInfo($installer));
return 0;
}
else
{
$output->writeln('Installation failed due to unknown reason.');
return 1;
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupEnvironment('administrator', $input, $output);
// Enable debug, so that JInstaller::install() throws exceptions on problems
$this->joomla->setCfg('debug', 1);
$installer = \JInstaller::getInstance();
if ($installer->install($this->handleExtension($input, $output)))
{
$output->writeln($this->getExtensionInfo($installer));
return 0;
}
else
{
$output->writeln('Installation failed due to unknown reason.');
return 1;
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"setupEnvironment",
"(",
"'administrator'",
",",
"$",
"input",
",",
"$",
"output",
")",
";",
"// Enable debug, so that JInstaller::install() throws exceptions on problems",
"$",
"this",
"->",
"joomla",
"->",
"setCfg",
"(",
"'debug'",
",",
"1",
")",
";",
"$",
"installer",
"=",
"\\",
"JInstaller",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"installer",
"->",
"install",
"(",
"$",
"this",
"->",
"handleExtension",
"(",
"$",
"input",
",",
"$",
"output",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"getExtensionInfo",
"(",
"$",
"installer",
")",
")",
";",
"return",
"0",
";",
"}",
"else",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'Installation failed due to unknown reason.'",
")",
";",
"return",
"1",
";",
"}",
"}"
] | Execute the install command
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return integer 0 if everything went fine, 1 on error | [
"Execute",
"the",
"install",
"command"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L74-L95 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.handleExtension | protected function handleExtension(InputInterface $input, OutputInterface $output)
{
$source = $input->getArgument('extension');
if (strpos($source, '://'))
{
$tmpPath = $this->handleDownload($output, $source);
}
elseif (is_dir($source))
{
$tmpPath = $this->handleDirectory($output, $source);
}
else
{
$tmpPath = $this->handleArchive($output, $source);
}
return $tmpPath;
} | php | protected function handleExtension(InputInterface $input, OutputInterface $output)
{
$source = $input->getArgument('extension');
if (strpos($source, '://'))
{
$tmpPath = $this->handleDownload($output, $source);
}
elseif (is_dir($source))
{
$tmpPath = $this->handleDirectory($output, $source);
}
else
{
$tmpPath = $this->handleArchive($output, $source);
}
return $tmpPath;
} | [
"protected",
"function",
"handleExtension",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"source",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'extension'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"source",
",",
"'://'",
")",
")",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleDownload",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_dir",
"(",
"$",
"source",
")",
")",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleDirectory",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"else",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleArchive",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"return",
"$",
"tmpPath",
";",
"}"
] | Handle the specified extension
An extension can be provided as a download, a directory, or an archive.
This method prepares the installation by providing the extension in a
temporary directory ready for install.
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return string The location of the prepared extension | [
"Handle",
"the",
"specified",
"extension",
"An",
"extension",
"can",
"be",
"provided",
"as",
"a",
"download",
"a",
"directory",
"or",
"an",
"archive",
".",
"This",
"method",
"prepares",
"the",
"installation",
"by",
"providing",
"the",
"extension",
"in",
"a",
"temporary",
"directory",
"ready",
"for",
"install",
"."
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L108-L126 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.getExtensionInfo | private function getExtensionInfo($installer)
{
$manifest = $installer->getManifest();
$data = $this->joomla->getExtensionInfo($manifest);
$message = array(
'Installed ' . $data['type'] . ' <info>' . $data['name'] . '</info> version <info>' . $data['version'] . '</info>',
'',
wordwrap($data['description'], 60),
''
);
return $message;
} | php | private function getExtensionInfo($installer)
{
$manifest = $installer->getManifest();
$data = $this->joomla->getExtensionInfo($manifest);
$message = array(
'Installed ' . $data['type'] . ' <info>' . $data['name'] . '</info> version <info>' . $data['version'] . '</info>',
'',
wordwrap($data['description'], 60),
''
);
return $message;
} | [
"private",
"function",
"getExtensionInfo",
"(",
"$",
"installer",
")",
"{",
"$",
"manifest",
"=",
"$",
"installer",
"->",
"getManifest",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getExtensionInfo",
"(",
"$",
"manifest",
")",
";",
"$",
"message",
"=",
"array",
"(",
"'Installed '",
".",
"$",
"data",
"[",
"'type'",
"]",
".",
"' <info>'",
".",
"$",
"data",
"[",
"'name'",
"]",
".",
"'</info> version <info>'",
".",
"$",
"data",
"[",
"'version'",
"]",
".",
"'</info>'",
",",
"''",
",",
"wordwrap",
"(",
"$",
"data",
"[",
"'description'",
"]",
",",
"60",
")",
",",
"''",
")",
";",
"return",
"$",
"message",
";",
"}"
] | Get information about the installed extension
@param \JInstaller $installer
@return array A message array suitable for OutputInterface::write[ln] | [
"Get",
"information",
"about",
"the",
"installed",
"extension"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L135-L148 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.handleDownload | private function handleDownload(OutputInterface $output, $source)
{
$this->writeln($output, "Downloading $source", OutputInterface::VERBOSITY_VERBOSE);
return $this->unpack(\JInstallerHelper::downloadPackage($source));
} | php | private function handleDownload(OutputInterface $output, $source)
{
$this->writeln($output, "Downloading $source", OutputInterface::VERBOSITY_VERBOSE);
return $this->unpack(\JInstallerHelper::downloadPackage($source));
} | [
"private",
"function",
"handleDownload",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Downloading $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"return",
"$",
"this",
"->",
"unpack",
"(",
"\\",
"JInstallerHelper",
"::",
"downloadPackage",
"(",
"$",
"source",
")",
")",
";",
"}"
] | Prepare the installation for an extension specified by a URL
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension | [
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"specified",
"by",
"a",
"URL"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L158-L163 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.handleDirectory | private function handleDirectory(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . uniqid('install_');
$this->writeln($output, "Copying $source", OutputInterface::VERBOSITY_VERBOSE);
mkdir($tmpPath);
copy($source, $tmpPath);
return $tmpPath;
} | php | private function handleDirectory(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . uniqid('install_');
$this->writeln($output, "Copying $source", OutputInterface::VERBOSITY_VERBOSE);
mkdir($tmpPath);
copy($source, $tmpPath);
return $tmpPath;
} | [
"private",
"function",
"handleDirectory",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"tmpDir",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getCfg",
"(",
"'tmp_path'",
")",
";",
"$",
"tmpPath",
"=",
"$",
"tmpDir",
".",
"'/'",
".",
"uniqid",
"(",
"'install_'",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Copying $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"mkdir",
"(",
"$",
"tmpPath",
")",
";",
"copy",
"(",
"$",
"source",
",",
"$",
"tmpPath",
")",
";",
"return",
"$",
"tmpPath",
";",
"}"
] | Prepare the installation for an extension specified by a directory
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension | [
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"specified",
"by",
"a",
"directory"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L173-L183 |
GreenCape/joomla-cli | src/GreenCape/JoomlaCLI/Commands/Install.php | InstallCommand.handleArchive | private function handleArchive(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . basename($source);
$this->writeln($output, "Extracting $source", OutputInterface::VERBOSITY_VERBOSE);
copy($source, $tmpPath);
return $this->unpack($tmpPath);
} | php | private function handleArchive(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . basename($source);
$this->writeln($output, "Extracting $source", OutputInterface::VERBOSITY_VERBOSE);
copy($source, $tmpPath);
return $this->unpack($tmpPath);
} | [
"private",
"function",
"handleArchive",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"tmpDir",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getCfg",
"(",
"'tmp_path'",
")",
";",
"$",
"tmpPath",
"=",
"$",
"tmpDir",
".",
"'/'",
".",
"basename",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Extracting $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"copy",
"(",
"$",
"source",
",",
"$",
"tmpPath",
")",
";",
"return",
"$",
"this",
"->",
"unpack",
"(",
"$",
"tmpPath",
")",
";",
"}"
] | Prepare the installation for an extension in an archive
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension | [
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"in",
"an",
"archive"
] | train | https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L193-L202 |
heidelpay/PhpDoc | src/phpDocumentor/Partials/ServiceProvider.php | ServiceProvider.register | public function register(Application $app)
{
/** @var Translator $translator */
$translator = $app['translator'];
$translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
/** @var ApplicationConfiguration $config */
$config = $app['config'];
$partialsCollection = new PartialsCollection($app['markdown']);
$app['partials'] = $partialsCollection;
/** @var Partial[] $partials */
$partials = $config->getPartials();
if ($partials) {
foreach ($partials as $partial) {
if (! $partial->getName()) {
throw new Exception\MissingNameForPartialException('The name of the partial to load is missing');
}
$content = '';
if ($partial->getContent()) {
$content = $partial->getContent();
} elseif ($partial->getLink()) {
if (! is_readable($partial->getLink())) {
$app['monolog']->error(
sprintf($translator->translate('PPCPP:EXC-NOPARTIAL'), $partial->getLink())
);
continue;
}
$content = file_get_contents($partial->getLink());
}
$partialsCollection->set($partial->getName(), $content);
}
}
} | php | public function register(Application $app)
{
/** @var Translator $translator */
$translator = $app['translator'];
$translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
/** @var ApplicationConfiguration $config */
$config = $app['config'];
$partialsCollection = new PartialsCollection($app['markdown']);
$app['partials'] = $partialsCollection;
/** @var Partial[] $partials */
$partials = $config->getPartials();
if ($partials) {
foreach ($partials as $partial) {
if (! $partial->getName()) {
throw new Exception\MissingNameForPartialException('The name of the partial to load is missing');
}
$content = '';
if ($partial->getContent()) {
$content = $partial->getContent();
} elseif ($partial->getLink()) {
if (! is_readable($partial->getLink())) {
$app['monolog']->error(
sprintf($translator->translate('PPCPP:EXC-NOPARTIAL'), $partial->getLink())
);
continue;
}
$content = file_get_contents($partial->getLink());
}
$partialsCollection->set($partial->getName(), $content);
}
}
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"app",
")",
"{",
"/** @var Translator $translator */",
"$",
"translator",
"=",
"$",
"app",
"[",
"'translator'",
"]",
";",
"$",
"translator",
"->",
"addTranslationFolder",
"(",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'Messages'",
")",
";",
"/** @var ApplicationConfiguration $config */",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"$",
"partialsCollection",
"=",
"new",
"PartialsCollection",
"(",
"$",
"app",
"[",
"'markdown'",
"]",
")",
";",
"$",
"app",
"[",
"'partials'",
"]",
"=",
"$",
"partialsCollection",
";",
"/** @var Partial[] $partials */",
"$",
"partials",
"=",
"$",
"config",
"->",
"getPartials",
"(",
")",
";",
"if",
"(",
"$",
"partials",
")",
"{",
"foreach",
"(",
"$",
"partials",
"as",
"$",
"partial",
")",
"{",
"if",
"(",
"!",
"$",
"partial",
"->",
"getName",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"MissingNameForPartialException",
"(",
"'The name of the partial to load is missing'",
")",
";",
"}",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"$",
"partial",
"->",
"getContent",
"(",
")",
")",
"{",
"$",
"content",
"=",
"$",
"partial",
"->",
"getContent",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"partial",
"->",
"getLink",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"partial",
"->",
"getLink",
"(",
")",
")",
")",
"{",
"$",
"app",
"[",
"'monolog'",
"]",
"->",
"error",
"(",
"sprintf",
"(",
"$",
"translator",
"->",
"translate",
"(",
"'PPCPP:EXC-NOPARTIAL'",
")",
",",
"$",
"partial",
"->",
"getLink",
"(",
")",
")",
")",
";",
"continue",
";",
"}",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"partial",
"->",
"getLink",
"(",
")",
")",
";",
"}",
"$",
"partialsCollection",
"->",
"set",
"(",
"$",
"partial",
"->",
"getName",
"(",
")",
",",
"$",
"content",
")",
";",
"}",
"}",
"}"
] | Registers services on the given app.
@param Application $app An Application instance
@throws Exception\MissingNameForPartialException if a partial has no name provided.
@return void | [
"Registers",
"services",
"on",
"the",
"given",
"app",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Partials/ServiceProvider.php#L34-L70 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.setCustomerId | public function setCustomerId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->customer_id !== $v) {
$this->customer_id = $v;
$this->modifiedColumns[CustomerCustomerGroupTableMap::CUSTOMER_ID] = true;
}
if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
$this->aCustomer = null;
}
return $this;
} | php | public function setCustomerId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->customer_id !== $v) {
$this->customer_id = $v;
$this->modifiedColumns[CustomerCustomerGroupTableMap::CUSTOMER_ID] = true;
}
if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) {
$this->aCustomer = null;
}
return $this;
} | [
"public",
"function",
"setCustomerId",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"int",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"customer_id",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"customer_id",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"!==",
"null",
"&&",
"$",
"this",
"->",
"aCustomer",
"->",
"getId",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [customer_id] column.
@param int $v new value
@return \CustomerGroup\Model\CustomerCustomerGroup The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"customer_id",
"]",
"column",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L374-L391 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.setCustomerGroupId | public function setCustomerGroupId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->customer_group_id !== $v) {
$this->customer_group_id = $v;
$this->modifiedColumns[CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID] = true;
}
if ($this->aCustomerGroup !== null && $this->aCustomerGroup->getId() !== $v) {
$this->aCustomerGroup = null;
}
return $this;
} | php | public function setCustomerGroupId($v)
{
if ($v !== null) {
$v = (int) $v;
}
if ($this->customer_group_id !== $v) {
$this->customer_group_id = $v;
$this->modifiedColumns[CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID] = true;
}
if ($this->aCustomerGroup !== null && $this->aCustomerGroup->getId() !== $v) {
$this->aCustomerGroup = null;
}
return $this;
} | [
"public",
"function",
"setCustomerGroupId",
"(",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"=",
"(",
"int",
")",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"customer_group_id",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"customer_group_id",
"=",
"$",
"v",
";",
"$",
"this",
"->",
"modifiedColumns",
"[",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aCustomerGroup",
"!==",
"null",
"&&",
"$",
"this",
"->",
"aCustomerGroup",
"->",
"getId",
"(",
")",
"!==",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"aCustomerGroup",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set the value of [customer_group_id] column.
@param int $v new value
@return \CustomerGroup\Model\CustomerCustomerGroup The current object (for fluent API support) | [
"Set",
"the",
"value",
"of",
"[",
"customer_group_id",
"]",
"column",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L399-L416 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.hydrate | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
{
try {
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerCustomerGroupTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerCustomerGroupTableMap::translateFieldName('CustomerGroupId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_group_id = (null !== $col) ? (int) $col : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 2; // 2 = CustomerCustomerGroupTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \CustomerGroup\Model\CustomerCustomerGroup object", 0, $e);
}
} | php | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM)
{
try {
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : CustomerCustomerGroupTableMap::translateFieldName('CustomerId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_id = (null !== $col) ? (int) $col : null;
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : CustomerCustomerGroupTableMap::translateFieldName('CustomerGroupId', TableMap::TYPE_PHPNAME, $indexType)];
$this->customer_group_id = (null !== $col) ? (int) $col : null;
$this->resetModified();
$this->setNew(false);
if ($rehydrate) {
$this->ensureConsistency();
}
return $startcol + 2; // 2 = CustomerCustomerGroupTableMap::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) {
throw new PropelException("Error populating \CustomerGroup\Model\CustomerCustomerGroup object", 0, $e);
}
} | [
"public",
"function",
"hydrate",
"(",
"$",
"row",
",",
"$",
"startcol",
"=",
"0",
",",
"$",
"rehydrate",
"=",
"false",
",",
"$",
"indexType",
"=",
"TableMap",
"::",
"TYPE_NUM",
")",
"{",
"try",
"{",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"0",
"+",
"$",
"startcol",
":",
"CustomerCustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'CustomerId'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"customer_id",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"int",
")",
"$",
"col",
":",
"null",
";",
"$",
"col",
"=",
"$",
"row",
"[",
"TableMap",
"::",
"TYPE_NUM",
"==",
"$",
"indexType",
"?",
"1",
"+",
"$",
"startcol",
":",
"CustomerCustomerGroupTableMap",
"::",
"translateFieldName",
"(",
"'CustomerGroupId'",
",",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"indexType",
")",
"]",
";",
"$",
"this",
"->",
"customer_group_id",
"=",
"(",
"null",
"!==",
"$",
"col",
")",
"?",
"(",
"int",
")",
"$",
"col",
":",
"null",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"if",
"(",
"$",
"rehydrate",
")",
"{",
"$",
"this",
"->",
"ensureConsistency",
"(",
")",
";",
"}",
"return",
"$",
"startcol",
"+",
"2",
";",
"// 2 = CustomerCustomerGroupTableMap::NUM_HYDRATE_COLUMNS.",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"\"Error populating \\CustomerGroup\\Model\\CustomerCustomerGroup object\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Hydrates (populates) the object variables with values from the database resultset.
An offset (0-based "start column") is specified so that objects can be hydrated
with a subset of the columns in the resultset rows. This is needed, for example,
for results of JOIN queries where the resultset row includes columns from two or
more tables.
@param array $row The row returned by DataFetcher->fetch().
@param int $startcol 0-based offset column which indicates which restultset column to start with.
@param boolean $rehydrate Whether this object is being re-hydrated from the database.
@param string $indexType The index type of $row. Mostly DataFetcher->getIndexType().
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
@return int next starting column
@throws PropelException - Any caught Exception will be rewrapped as a PropelException. | [
"Hydrates",
"(",
"populates",
")",
"the",
"object",
"variables",
"with",
"values",
"from",
"the",
"database",
"resultset",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L450-L473 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.ensureConsistency | public function ensureConsistency()
{
if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
$this->aCustomer = null;
}
if ($this->aCustomerGroup !== null && $this->customer_group_id !== $this->aCustomerGroup->getId()) {
$this->aCustomerGroup = null;
}
} | php | public function ensureConsistency()
{
if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) {
$this->aCustomer = null;
}
if ($this->aCustomerGroup !== null && $this->customer_group_id !== $this->aCustomerGroup->getId()) {
$this->aCustomerGroup = null;
}
} | [
"public",
"function",
"ensureConsistency",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"!==",
"null",
"&&",
"$",
"this",
"->",
"customer_id",
"!==",
"$",
"this",
"->",
"aCustomer",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"aCustomerGroup",
"!==",
"null",
"&&",
"$",
"this",
"->",
"customer_group_id",
"!==",
"$",
"this",
"->",
"aCustomerGroup",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"this",
"->",
"aCustomerGroup",
"=",
"null",
";",
"}",
"}"
] | Checks and repairs the internal consistency of the object.
This method is executed after an already-instantiated object is re-hydrated
from the database. It exists to check any foreign keys to make sure that
the objects related to the current object are correct based on foreign key.
You can override this method in the stub class, but you should always invoke
the base method from the overridden method (i.e. parent::ensureConsistency()),
in case your model changes.
@throws PropelException | [
"Checks",
"and",
"repairs",
"the",
"internal",
"consistency",
"of",
"the",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L488-L496 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.doInsert | protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
}
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_GROUP_ID';
}
$sql = sprintf(
'INSERT INTO customer_customer_group (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'CUSTOMER_ID':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
case 'CUSTOMER_GROUP_ID':
$stmt->bindValue($identifier, $this->customer_group_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
$this->setNew(false);
} | php | protected function doInsert(ConnectionInterface $con)
{
$modifiedColumns = array();
$index = 0;
// check the columns in natural order for more readable SQL queries
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_ID';
}
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID)) {
$modifiedColumns[':p' . $index++] = 'CUSTOMER_GROUP_ID';
}
$sql = sprintf(
'INSERT INTO customer_customer_group (%s) VALUES (%s)',
implode(', ', $modifiedColumns),
implode(', ', array_keys($modifiedColumns))
);
try {
$stmt = $con->prepare($sql);
foreach ($modifiedColumns as $identifier => $columnName) {
switch ($columnName) {
case 'CUSTOMER_ID':
$stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT);
break;
case 'CUSTOMER_GROUP_ID':
$stmt->bindValue($identifier, $this->customer_group_id, PDO::PARAM_INT);
break;
}
}
$stmt->execute();
} catch (Exception $e) {
Propel::log($e->getMessage(), Propel::LOG_ERR);
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e);
}
$this->setNew(false);
} | [
"protected",
"function",
"doInsert",
"(",
"ConnectionInterface",
"$",
"con",
")",
"{",
"$",
"modifiedColumns",
"=",
"array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"// check the columns in natural order for more readable SQL queries",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CUSTOMER_ID'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
")",
")",
"{",
"$",
"modifiedColumns",
"[",
"':p'",
".",
"$",
"index",
"++",
"]",
"=",
"'CUSTOMER_GROUP_ID'",
";",
"}",
"$",
"sql",
"=",
"sprintf",
"(",
"'INSERT INTO customer_customer_group (%s) VALUES (%s)'",
",",
"implode",
"(",
"', '",
",",
"$",
"modifiedColumns",
")",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"modifiedColumns",
")",
")",
")",
";",
"try",
"{",
"$",
"stmt",
"=",
"$",
"con",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"foreach",
"(",
"$",
"modifiedColumns",
"as",
"$",
"identifier",
"=>",
"$",
"columnName",
")",
"{",
"switch",
"(",
"$",
"columnName",
")",
"{",
"case",
"'CUSTOMER_ID'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"customer_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'CUSTOMER_GROUP_ID'",
":",
"$",
"stmt",
"->",
"bindValue",
"(",
"$",
"identifier",
",",
"$",
"this",
"->",
"customer_group_id",
",",
"PDO",
"::",
"PARAM_INT",
")",
";",
"break",
";",
"}",
"}",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Propel",
"::",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"Propel",
"::",
"LOG_ERR",
")",
";",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Unable to execute INSERT statement [%s]'",
",",
"$",
"sql",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"setNew",
"(",
"false",
")",
";",
"}"
] | Insert the row in the database.
@param ConnectionInterface $con
@throws PropelException
@see doSave() | [
"Insert",
"the",
"row",
"in",
"the",
"database",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L693-L732 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.toArray | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['CustomerCustomerGroup'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['CustomerCustomerGroup'][serialize($this->getPrimaryKey())] = true;
$keys = CustomerCustomerGroupTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getCustomerId(),
$keys[1] => $this->getCustomerGroupId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aCustomer) {
$result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCustomerGroup) {
$result['CustomerGroup'] = $this->aCustomerGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | php | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
{
if (isset($alreadyDumpedObjects['CustomerCustomerGroup'][serialize($this->getPrimaryKey())])) {
return '*RECURSION*';
}
$alreadyDumpedObjects['CustomerCustomerGroup'][serialize($this->getPrimaryKey())] = true;
$keys = CustomerCustomerGroupTableMap::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getCustomerId(),
$keys[1] => $this->getCustomerGroupId(),
);
$virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) {
$result[$key] = $virtualColumn;
}
if ($includeForeignObjects) {
if (null !== $this->aCustomer) {
$result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
if (null !== $this->aCustomerGroup) {
$result['CustomerGroup'] = $this->aCustomerGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
}
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
",",
"$",
"includeLazyLoadColumns",
"=",
"true",
",",
"$",
"alreadyDumpedObjects",
"=",
"array",
"(",
")",
",",
"$",
"includeForeignObjects",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"alreadyDumpedObjects",
"[",
"'CustomerCustomerGroup'",
"]",
"[",
"serialize",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
"]",
")",
")",
"{",
"return",
"'*RECURSION*'",
";",
"}",
"$",
"alreadyDumpedObjects",
"[",
"'CustomerCustomerGroup'",
"]",
"[",
"serialize",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
"]",
"=",
"true",
";",
"$",
"keys",
"=",
"CustomerCustomerGroupTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"keys",
"[",
"0",
"]",
"=>",
"$",
"this",
"->",
"getCustomerId",
"(",
")",
",",
"$",
"keys",
"[",
"1",
"]",
"=>",
"$",
"this",
"->",
"getCustomerGroupId",
"(",
")",
",",
")",
";",
"$",
"virtualColumns",
"=",
"$",
"this",
"->",
"virtualColumns",
";",
"foreach",
"(",
"$",
"virtualColumns",
"as",
"$",
"key",
"=>",
"$",
"virtualColumn",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"virtualColumn",
";",
"}",
"if",
"(",
"$",
"includeForeignObjects",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aCustomer",
")",
"{",
"$",
"result",
"[",
"'Customer'",
"]",
"=",
"$",
"this",
"->",
"aCustomer",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"aCustomerGroup",
")",
"{",
"$",
"result",
"[",
"'CustomerGroup'",
"]",
"=",
"$",
"this",
"->",
"aCustomerGroup",
"->",
"toArray",
"(",
"$",
"keyType",
",",
"$",
"includeLazyLoadColumns",
",",
"$",
"alreadyDumpedObjects",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Exports the object as an array.
You can specify the key type of the array by passing one of the class
type constants.
@param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
Defaults to TableMap::TYPE_PHPNAME.
@param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
@param array $alreadyDumpedObjects List of objects to skip to avoid recursion
@param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
@return array an associative array containing the field names (as keys) and field values | [
"Exports",
"the",
"object",
"as",
"an",
"array",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L805-L831 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.setByPosition | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setCustomerId($value);
break;
case 1:
$this->setCustomerGroupId($value);
break;
} // switch()
} | php | public function setByPosition($pos, $value)
{
switch ($pos) {
case 0:
$this->setCustomerId($value);
break;
case 1:
$this->setCustomerGroupId($value);
break;
} // switch()
} | [
"public",
"function",
"setByPosition",
"(",
"$",
"pos",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"pos",
")",
"{",
"case",
"0",
":",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"1",
":",
"$",
"this",
"->",
"setCustomerGroupId",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"// switch()",
"}"
] | Sets a field from the object by Position as specified in the xml schema.
Zero-based.
@param int $pos position in xml schema
@param mixed $value field value
@return void | [
"Sets",
"a",
"field",
"from",
"the",
"object",
"by",
"Position",
"as",
"specified",
"in",
"the",
"xml",
"schema",
".",
"Zero",
"-",
"based",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L859-L869 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.fromArray | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = CustomerCustomerGroupTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setCustomerId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCustomerGroupId($arr[$keys[1]]);
} | php | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME)
{
$keys = CustomerCustomerGroupTableMap::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setCustomerId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCustomerGroupId($arr[$keys[1]]);
} | [
"public",
"function",
"fromArray",
"(",
"$",
"arr",
",",
"$",
"keyType",
"=",
"TableMap",
"::",
"TYPE_PHPNAME",
")",
"{",
"$",
"keys",
"=",
"CustomerCustomerGroupTableMap",
"::",
"getFieldNames",
"(",
"$",
"keyType",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"0",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"arr",
")",
")",
"$",
"this",
"->",
"setCustomerGroupId",
"(",
"$",
"arr",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
")",
";",
"}"
] | Populates the object using an array.
This is particularly useful when populating an object from one of the
request arrays (e.g. $_POST). This method goes through the column
names, checking to see whether a matching key exists in populated
array. If so the setByName() method is called for that column.
You can specify the key type of the array by additionally passing one
of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
The default key type is the column's TableMap::TYPE_PHPNAME.
@param array $arr An array to populate the object from.
@param string $keyType The type of keys the array uses.
@return void | [
"Populates",
"the",
"object",
"using",
"an",
"array",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L888-L894 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.buildCriteria | public function buildCriteria()
{
$criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME);
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_ID, $this->customer_id);
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $this->customer_group_id);
return $criteria;
} | php | public function buildCriteria()
{
$criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME);
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_ID, $this->customer_id);
if ($this->isColumnModified(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID)) $criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $this->customer_group_id);
return $criteria;
} | [
"public",
"function",
"buildCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CustomerCustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
",",
"$",
"this",
"->",
"customer_id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isColumnModified",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
")",
")",
"$",
"criteria",
"->",
"add",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
",",
"$",
"this",
"->",
"customer_group_id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] | Build a Criteria object containing the values of all modified columns in this object.
@return Criteria The Criteria object containing all modified values. | [
"Build",
"a",
"Criteria",
"object",
"containing",
"the",
"values",
"of",
"all",
"modified",
"columns",
"in",
"this",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L901-L909 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.buildPkeyCriteria | public function buildPkeyCriteria()
{
$criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME);
$criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_ID, $this->customer_id);
$criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $this->customer_group_id);
return $criteria;
} | php | public function buildPkeyCriteria()
{
$criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME);
$criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_ID, $this->customer_id);
$criteria->add(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $this->customer_group_id);
return $criteria;
} | [
"public",
"function",
"buildPkeyCriteria",
"(",
")",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CustomerCustomerGroupTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_ID",
",",
"$",
"this",
"->",
"customer_id",
")",
";",
"$",
"criteria",
"->",
"add",
"(",
"CustomerCustomerGroupTableMap",
"::",
"CUSTOMER_GROUP_ID",
",",
"$",
"this",
"->",
"customer_group_id",
")",
";",
"return",
"$",
"criteria",
";",
"}"
] | Builds a Criteria object containing the primary key for this object.
Unlike buildCriteria() this method includes the primary key values regardless
of whether or not they have been modified.
@return Criteria The Criteria object containing value(s) for primary key(s). | [
"Builds",
"a",
"Criteria",
"object",
"containing",
"the",
"primary",
"key",
"for",
"this",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L919-L926 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.copyInto | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCustomerId($this->getCustomerId());
$copyObj->setCustomerGroupId($this->getCustomerGroupId());
if ($makeNew) {
$copyObj->setNew(true);
}
} | php | public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
{
$copyObj->setCustomerId($this->getCustomerId());
$copyObj->setCustomerGroupId($this->getCustomerGroupId());
if ($makeNew) {
$copyObj->setNew(true);
}
} | [
"public",
"function",
"copyInto",
"(",
"$",
"copyObj",
",",
"$",
"deepCopy",
"=",
"false",
",",
"$",
"makeNew",
"=",
"true",
")",
"{",
"$",
"copyObj",
"->",
"setCustomerId",
"(",
"$",
"this",
"->",
"getCustomerId",
"(",
")",
")",
";",
"$",
"copyObj",
"->",
"setCustomerGroupId",
"(",
"$",
"this",
"->",
"getCustomerGroupId",
"(",
")",
")",
";",
"if",
"(",
"$",
"makeNew",
")",
"{",
"$",
"copyObj",
"->",
"setNew",
"(",
"true",
")",
";",
"}",
"}"
] | Sets contents of passed object to values from current object.
If desired, this method can also make copies of all associated (fkey referrers)
objects.
@param object $copyObj An object of \CustomerGroup\Model\CustomerCustomerGroup (or compatible) type.
@param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
@param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
@throws PropelException | [
"Sets",
"contents",
"of",
"passed",
"object",
"to",
"values",
"from",
"current",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L975-L982 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.setCustomer | public function setCustomer(ChildCustomer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
} | php | public function setCustomer(ChildCustomer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
} | [
"public",
"function",
"setCustomer",
"(",
"ChildCustomer",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aCustomer",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the ChildCustomer object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addCustomerCustomerGroup",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Declares an association between this object and a ChildCustomer object.
@param ChildCustomer $v
@return \CustomerGroup\Model\CustomerCustomerGroup The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildCustomer",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1013-L1031 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.getCustomer | public function getCustomer(ConnectionInterface $con = null)
{
if ($this->aCustomer === null && ($this->customer_id !== null)) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addCustomerCustomerGroups($this);
*/
}
return $this->aCustomer;
} | php | public function getCustomer(ConnectionInterface $con = null)
{
if ($this->aCustomer === null && ($this->customer_id !== null)) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addCustomerCustomerGroups($this);
*/
}
return $this->aCustomer;
} | [
"public",
"function",
"getCustomer",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"customer_id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"CustomerQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"customer_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aCustomer->addCustomerCustomerGroups($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aCustomer",
";",
"}"
] | Get the associated ChildCustomer object
@param ConnectionInterface $con Optional Connection object.
@return ChildCustomer The associated ChildCustomer object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildCustomer",
"object"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1041-L1055 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.setCustomerGroup | public function setCustomerGroup(ChildCustomerGroup $v = null)
{
if ($v === null) {
$this->setCustomerGroupId(NULL);
} else {
$this->setCustomerGroupId($v->getId());
}
$this->aCustomerGroup = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomerGroup object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
} | php | public function setCustomerGroup(ChildCustomerGroup $v = null)
{
if ($v === null) {
$this->setCustomerGroupId(NULL);
} else {
$this->setCustomerGroupId($v->getId());
}
$this->aCustomerGroup = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomerGroup object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
} | [
"public",
"function",
"setCustomerGroup",
"(",
"ChildCustomerGroup",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCustomerGroupId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setCustomerGroupId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aCustomerGroup",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the ChildCustomerGroup object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addCustomerCustomerGroup",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Declares an association between this object and a ChildCustomerGroup object.
@param ChildCustomerGroup $v
@return \CustomerGroup\Model\CustomerCustomerGroup The current object (for fluent API support)
@throws PropelException | [
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildCustomerGroup",
"object",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1064-L1082 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.clear | public function clear()
{
$this->customer_id = null;
$this->customer_group_id = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | php | public function clear()
{
$this->customer_id = null;
$this->customer_group_id = null;
$this->alreadyInSave = false;
$this->clearAllReferences();
$this->resetModified();
$this->setNew(true);
$this->setDeleted(false);
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"customer_id",
"=",
"null",
";",
"$",
"this",
"->",
"customer_group_id",
"=",
"null",
";",
"$",
"this",
"->",
"alreadyInSave",
"=",
"false",
";",
"$",
"this",
"->",
"clearAllReferences",
"(",
")",
";",
"$",
"this",
"->",
"resetModified",
"(",
")",
";",
"$",
"this",
"->",
"setNew",
"(",
"true",
")",
";",
"$",
"this",
"->",
"setDeleted",
"(",
"false",
")",
";",
"}"
] | Clears the current object and sets all attributes to their default values | [
"Clears",
"the",
"current",
"object",
"and",
"sets",
"all",
"attributes",
"to",
"their",
"default",
"values"
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1111-L1120 |
thelia-modules/CustomerGroup | Model/Base/CustomerCustomerGroup.php | CustomerCustomerGroup.clearAllReferences | public function clearAllReferences($deep = false)
{
if ($deep) {
} // if ($deep)
$this->aCustomer = null;
$this->aCustomerGroup = null;
} | php | public function clearAllReferences($deep = false)
{
if ($deep) {
} // if ($deep)
$this->aCustomer = null;
$this->aCustomerGroup = null;
} | [
"public",
"function",
"clearAllReferences",
"(",
"$",
"deep",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"deep",
")",
"{",
"}",
"// if ($deep)",
"$",
"this",
"->",
"aCustomer",
"=",
"null",
";",
"$",
"this",
"->",
"aCustomerGroup",
"=",
"null",
";",
"}"
] | Resets all references to other model objects or collections of model objects.
This method is a user-space workaround for PHP's inability to garbage collect
objects with circular references (even in PHP 5.3). This is currently necessary
when using Propel in certain daemon or large-volume/high-memory operations.
@param boolean $deep Whether to also clear the references on all referrer objects. | [
"Resets",
"all",
"references",
"to",
"other",
"model",
"objects",
"or",
"collections",
"of",
"model",
"objects",
"."
] | train | https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1131-L1138 |
simbiosis-group/yii2-helper | widgets/ModalActiveForm.php | ModalActiveForm.init | public function init()
{
$this->getView()->registerJs(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/js/modal-active-form.js')));
$this->getView()->registerJs(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/js/modal-hint.js')));
$this->getView()->registerCss(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/css/hint.css')));
$this->getView()->registerCss(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/css/select2.css')));
$this->options = ['class' => 'modal-form', 'data-modal-id' => $this->modalId, 'data-select-id' => $this->selectId];
$this->enableClientValidation = true;
parent::init();
} | php | public function init()
{
$this->getView()->registerJs(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/js/modal-active-form.js')));
$this->getView()->registerJs(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/js/modal-hint.js')));
$this->getView()->registerCss(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/css/hint.css')));
$this->getView()->registerCss(file_get_contents(Yii::getAlias('@vendor/anli/yii2-helper/css/select2.css')));
$this->options = ['class' => 'modal-form', 'data-modal-id' => $this->modalId, 'data-select-id' => $this->selectId];
$this->enableClientValidation = true;
parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"file_get_contents",
"(",
"Yii",
"::",
"getAlias",
"(",
"'@vendor/anli/yii2-helper/js/modal-active-form.js'",
")",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"file_get_contents",
"(",
"Yii",
"::",
"getAlias",
"(",
"'@vendor/anli/yii2-helper/js/modal-hint.js'",
")",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerCss",
"(",
"file_get_contents",
"(",
"Yii",
"::",
"getAlias",
"(",
"'@vendor/anli/yii2-helper/css/hint.css'",
")",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerCss",
"(",
"file_get_contents",
"(",
"Yii",
"::",
"getAlias",
"(",
"'@vendor/anli/yii2-helper/css/select2.css'",
")",
")",
")",
";",
"$",
"this",
"->",
"options",
"=",
"[",
"'class'",
"=>",
"'modal-form'",
",",
"'data-modal-id'",
"=>",
"$",
"this",
"->",
"modalId",
",",
"'data-select-id'",
"=>",
"$",
"this",
"->",
"selectId",
"]",
";",
"$",
"this",
"->",
"enableClientValidation",
"=",
"true",
";",
"parent",
"::",
"init",
"(",
")",
";",
"}"
] | Renders the widget. | [
"Renders",
"the",
"widget",
"."
] | train | https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/widgets/ModalActiveForm.php#L38-L50 |
skmetaly/laravel-twitch-restful-api | src/API/Follow.php | Follow.channelFollows | public function channelFollows($channel, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/follows';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
} | php | public function channelFollows($channel, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'https://api.twitch.tv/kraken/channels/' . $channel . '/follows';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
} | [
"public",
"function",
"channelFollows",
"(",
"$",
"channel",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"availableOptions",
"=",
"[",
"'limit'",
",",
"'offset'",
",",
"'direction'",
"]",
";",
"// Filter the available options",
"foreach",
"(",
"$",
"availableOptions",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"option",
"]",
")",
")",
"{",
"$",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"options",
"[",
"$",
"option",
"]",
";",
"}",
"}",
"$",
"url",
"=",
"'https://api.twitch.tv/kraken/channels/'",
".",
"$",
"channel",
".",
"'/follows'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"'body'",
"=>",
"$",
"options",
"]",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a list of follow objects.
Name Required? Type Description
limit optional integer Maximum number of objects in array. Default is 25. Maximum is 100.
offset optional integer Object offset for pagination. Default is 0.
direction optional string Creation date sorting direction. Default is desc. Valid values are asc and desc.
@param $channel
@param $options
@return json | [
"Returns",
"a",
"list",
"of",
"follow",
"objects",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Follow.php#L31-L49 |
skmetaly/laravel-twitch-restful-api | src/API/Follow.php | Follow.userFollowsChannels | public function userFollowsChannels($user, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction', 'sortby'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'kraken/users/' . $user . '/follows/channels';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
} | php | public function userFollowsChannels($user, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction', 'sortby'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'kraken/users/' . $user . '/follows/channels';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
} | [
"public",
"function",
"userFollowsChannels",
"(",
"$",
"user",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"availableOptions",
"=",
"[",
"'limit'",
",",
"'offset'",
",",
"'direction'",
",",
"'sortby'",
"]",
";",
"// Filter the available options",
"foreach",
"(",
"$",
"availableOptions",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"option",
"]",
")",
")",
"{",
"$",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"options",
"[",
"$",
"option",
"]",
";",
"}",
"}",
"$",
"url",
"=",
"'kraken/users/'",
".",
"$",
"user",
".",
"'/follows/channels'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"'body'",
"=>",
"$",
"options",
"]",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Returns a list of follows objects.
Parameters
Name Required? Type Description
limit optional integer Maximum number of objects in array. Default is 25. Maximum is 100.
offset optional integer Object offset for pagination. Default is 0.
direction optional string Sorting direction. Default is desc. Valid values are asc and desc.
sortby optional string Sort key. Default is created_at. Valid values are created_at and last_broadcast.
@param $user
@param array $options
@return mixed | [
"Returns",
"a",
"list",
"of",
"follows",
"objects",
".",
"Parameters",
"Name",
"Required?",
"Type",
"Description",
"limit",
"optional",
"integer",
"Maximum",
"number",
"of",
"objects",
"in",
"array",
".",
"Default",
"is",
"25",
".",
"Maximum",
"is",
"100",
".",
"offset",
"optional",
"integer",
"Object",
"offset",
"for",
"pagination",
".",
"Default",
"is",
"0",
".",
"direction",
"optional",
"string",
"Sorting",
"direction",
".",
"Default",
"is",
"desc",
".",
"Valid",
"values",
"are",
"asc",
"and",
"desc",
".",
"sortby",
"optional",
"string",
"Sort",
"key",
".",
"Default",
"is",
"created_at",
".",
"Valid",
"values",
"are",
"created_at",
"and",
"last_broadcast",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Follow.php#L65-L83 |
skmetaly/laravel-twitch-restful-api | src/API/Follow.php | Follow.userFollowsChannel | public function userFollowsChannel($user, $channel)
{
$response = $this->client->get('kraken/users/' . $user . '/follows/channels/' . $channel);
return $response->json();
} | php | public function userFollowsChannel($user, $channel)
{
$response = $this->client->get('kraken/users/' . $user . '/follows/channels/' . $channel);
return $response->json();
} | [
"public",
"function",
"userFollowsChannel",
"(",
"$",
"user",
",",
"$",
"channel",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"'kraken/users/'",
".",
"$",
"user",
".",
"'/follows/channels/'",
".",
"$",
"channel",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] | Returns 404 Not Found if :user is not following :target. Returns a follow object otherwise.
@param $user
@param $channel
@return mixed | [
"Returns",
"404",
"Not",
"Found",
"if",
":",
"user",
"is",
"not",
"following",
":",
"target",
".",
"Returns",
"a",
"follow",
"object",
"otherwise",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Follow.php#L93-L98 |
skmetaly/laravel-twitch-restful-api | src/API/Follow.php | Follow.authenticatedUserUnfollowsChannel | public function authenticatedUserUnfollowsChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$request = $this->createRequest('DELETE',
config('twitch-api.api_url') . '/kraken/users/' . $user . '/follows/channels/' . $channel, $token);
$response = $this->client->send($request);
if ($response->getStatusCode() == 204) {
return true;
}
return false;
} | php | public function authenticatedUserUnfollowsChannel($user, $channel, $token = null)
{
$token = $this->getToken($token);
$request = $this->createRequest('DELETE',
config('twitch-api.api_url') . '/kraken/users/' . $user . '/follows/channels/' . $channel, $token);
$response = $this->client->send($request);
if ($response->getStatusCode() == 204) {
return true;
}
return false;
} | [
"public",
"function",
"authenticatedUserUnfollowsChannel",
"(",
"$",
"user",
",",
"$",
"channel",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
"$",
"token",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"createRequest",
"(",
"'DELETE'",
",",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/users/'",
".",
"$",
"user",
".",
"'/follows/channels/'",
".",
"$",
"channel",
",",
"$",
"token",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"send",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"==",
"204",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Removes :user from :target's followers. :user is the authenticated user's name and :target is the name of the channel to be unfollowed.
Authenticated, required scope: user_follows_edit
@param $user
@param $channel
@param null $token
@return boolean | [
"Removes",
":",
"user",
"from",
":",
"target",
"s",
"followers",
".",
":",
"user",
"is",
"the",
"authenticated",
"user",
"s",
"name",
"and",
":",
"target",
"is",
"the",
"name",
"of",
"the",
"channel",
"to",
"be",
"unfollowed",
"."
] | train | https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Follow.php#L148-L163 |
Danack/GithubArtaxService | lib/GithubService/Operation/createAuthorization.php | createAuthorization.createRequest | public function createRequest() {
$request = new \Amp\Artax\Request();
$url = null;
$request->setMethod('POST');
$jsonParams = [];
if (array_key_exists('Accept', $this->parameters) == true) {
$value = $this->getFilteredParameter('Accept');
$request->setHeader('Accept', $value);
}
$value = $this->getFilteredParameter('userAgent');
$request->setHeader('User-Agent', $value);
$value = $this->getFilteredParameter('Authorization');
$request->setHeader('Authorization', $value);
if (array_key_exists('otp', $this->parameters) == true) {
$value = $this->getFilteredParameter('otp');
$request->setHeader('X-GitHub-OTP', $value);
}
$value = $this->getFilteredParameter('scopes');
$jsonParams['scopes'] = $value;
$value = $this->getFilteredParameter('note');
$jsonParams['note'] = $value;
if (array_key_exists('note_url', $this->parameters) == true) {
$value = $this->getFilteredParameter('note_url');
$jsonParams['note_url'] = $value;
}
if (array_key_exists('client_id', $this->parameters) == true) {
$value = $this->getFilteredParameter('client_id');
$jsonParams['client_id'] = $value;
}
if (array_key_exists('client_secret', $this->parameters) == true) {
$value = $this->getFilteredParameter('client_secret');
$jsonParams['client_secret'] = $value;
}
if (array_key_exists('fingerprint', $this->parameters) == true) {
$value = $this->getFilteredParameter('fingerprint');
$jsonParams['fingerprint'] = $value;
}
//Parameters are parsed and set, lets prepare the request
if (count($jsonParams)) {
$jsonBody = json_encode($jsonParams);
$request->setHeader("Content-Type", "application/json");
$request->setBody($jsonBody);
}
if ($url == null) {
$url = "https://api.github.com/authorizations";
}
$request->setUri($url);
return $request;
} | php | public function createRequest() {
$request = new \Amp\Artax\Request();
$url = null;
$request->setMethod('POST');
$jsonParams = [];
if (array_key_exists('Accept', $this->parameters) == true) {
$value = $this->getFilteredParameter('Accept');
$request->setHeader('Accept', $value);
}
$value = $this->getFilteredParameter('userAgent');
$request->setHeader('User-Agent', $value);
$value = $this->getFilteredParameter('Authorization');
$request->setHeader('Authorization', $value);
if (array_key_exists('otp', $this->parameters) == true) {
$value = $this->getFilteredParameter('otp');
$request->setHeader('X-GitHub-OTP', $value);
}
$value = $this->getFilteredParameter('scopes');
$jsonParams['scopes'] = $value;
$value = $this->getFilteredParameter('note');
$jsonParams['note'] = $value;
if (array_key_exists('note_url', $this->parameters) == true) {
$value = $this->getFilteredParameter('note_url');
$jsonParams['note_url'] = $value;
}
if (array_key_exists('client_id', $this->parameters) == true) {
$value = $this->getFilteredParameter('client_id');
$jsonParams['client_id'] = $value;
}
if (array_key_exists('client_secret', $this->parameters) == true) {
$value = $this->getFilteredParameter('client_secret');
$jsonParams['client_secret'] = $value;
}
if (array_key_exists('fingerprint', $this->parameters) == true) {
$value = $this->getFilteredParameter('fingerprint');
$jsonParams['fingerprint'] = $value;
}
//Parameters are parsed and set, lets prepare the request
if (count($jsonParams)) {
$jsonBody = json_encode($jsonParams);
$request->setHeader("Content-Type", "application/json");
$request->setBody($jsonBody);
}
if ($url == null) {
$url = "https://api.github.com/authorizations";
}
$request->setUri($url);
return $request;
} | [
"public",
"function",
"createRequest",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"\\",
"Amp",
"\\",
"Artax",
"\\",
"Request",
"(",
")",
";",
"$",
"url",
"=",
"null",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"$",
"jsonParams",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'Accept'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'Accept'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'Accept'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'userAgent'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'User-Agent'",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'Authorization'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'Authorization'",
",",
"$",
"value",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'otp'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'otp'",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'X-GitHub-OTP'",
",",
"$",
"value",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'scopes'",
")",
";",
"$",
"jsonParams",
"[",
"'scopes'",
"]",
"=",
"$",
"value",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'note'",
")",
";",
"$",
"jsonParams",
"[",
"'note'",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"array_key_exists",
"(",
"'note_url'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'note_url'",
")",
";",
"$",
"jsonParams",
"[",
"'note_url'",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'client_id'",
")",
";",
"$",
"jsonParams",
"[",
"'client_id'",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'client_secret'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'client_secret'",
")",
";",
"$",
"jsonParams",
"[",
"'client_secret'",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'fingerprint'",
",",
"$",
"this",
"->",
"parameters",
")",
"==",
"true",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getFilteredParameter",
"(",
"'fingerprint'",
")",
";",
"$",
"jsonParams",
"[",
"'fingerprint'",
"]",
"=",
"$",
"value",
";",
"}",
"//Parameters are parsed and set, lets prepare the request",
"if",
"(",
"count",
"(",
"$",
"jsonParams",
")",
")",
"{",
"$",
"jsonBody",
"=",
"json_encode",
"(",
"$",
"jsonParams",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"\"Content-Type\"",
",",
"\"application/json\"",
")",
";",
"$",
"request",
"->",
"setBody",
"(",
"$",
"jsonBody",
")",
";",
"}",
"if",
"(",
"$",
"url",
"==",
"null",
")",
"{",
"$",
"url",
"=",
"\"https://api.github.com/authorizations\"",
";",
"}",
"$",
"request",
"->",
"setUri",
"(",
"$",
"url",
")",
";",
"return",
"$",
"request",
";",
"}"
] | Create an Amp\Artax\Request object from the operation.
@return \Amp\Artax\Request | [
"Create",
"an",
"Amp",
"\\",
"Artax",
"\\",
"Request",
"object",
"from",
"the",
"operation",
"."
] | train | https://github.com/Danack/GithubArtaxService/blob/9f62b5be4f413207d4012e7fa084d0ae505680eb/lib/GithubService/Operation/createAuthorization.php#L248-L300 |
getuisdk/getui-php-sdk | src/PBBytes.php | PBBytes.parseFromArray | public function parseFromArray()
{
$this->value = '';
// first byte is length
$length = $this->reader->next();
// just extract the string
$pointer = $this->reader->getPointer();
$this->reader->addPointer($length);
$this->value = $this->reader->getMessageFrom($pointer);
} | php | public function parseFromArray()
{
$this->value = '';
// first byte is length
$length = $this->reader->next();
// just extract the string
$pointer = $this->reader->getPointer();
$this->reader->addPointer($length);
$this->value = $this->reader->getMessageFrom($pointer);
} | [
"public",
"function",
"parseFromArray",
"(",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"''",
";",
"// first byte is length\r",
"$",
"length",
"=",
"$",
"this",
"->",
"reader",
"->",
"next",
"(",
")",
";",
"// just extract the string\r",
"$",
"pointer",
"=",
"$",
"this",
"->",
"reader",
"->",
"getPointer",
"(",
")",
";",
"$",
"this",
"->",
"reader",
"->",
"addPointer",
"(",
"$",
"length",
")",
";",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMessageFrom",
"(",
"$",
"pointer",
")",
";",
"}"
] | Parses the message for this type
@param array | [
"Parses",
"the",
"message",
"for",
"this",
"type"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBBytes.php#L24-L34 |
getuisdk/getui-php-sdk | src/PBBytes.php | PBBytes.serializeToString | public function serializeToString($rec = -1)
{
$string = '';
if ($rec > -1) {
$string .= $this->base128->setValue($rec << 3 | $this->wired_type);
}
$string .= $this->base128->setValue(strlen($this->value));
$string .= $this->value;
return $string;
} | php | public function serializeToString($rec = -1)
{
$string = '';
if ($rec > -1) {
$string .= $this->base128->setValue($rec << 3 | $this->wired_type);
}
$string .= $this->base128->setValue(strlen($this->value));
$string .= $this->value;
return $string;
} | [
"public",
"function",
"serializeToString",
"(",
"$",
"rec",
"=",
"-",
"1",
")",
"{",
"$",
"string",
"=",
"''",
";",
"if",
"(",
"$",
"rec",
">",
"-",
"1",
")",
"{",
"$",
"string",
".=",
"$",
"this",
"->",
"base128",
"->",
"setValue",
"(",
"$",
"rec",
"<<",
"3",
"|",
"$",
"this",
"->",
"wired_type",
")",
";",
"}",
"$",
"string",
".=",
"$",
"this",
"->",
"base128",
"->",
"setValue",
"(",
"strlen",
"(",
"$",
"this",
"->",
"value",
")",
")",
";",
"$",
"string",
".=",
"$",
"this",
"->",
"value",
";",
"return",
"$",
"string",
";",
"}"
] | Serializes type
@param mixed $rec
@return mixed | [
"Serializes",
"type"
] | train | https://github.com/getuisdk/getui-php-sdk/blob/e91773b099bcbfd7492a44086b373d1c9fee37e2/src/PBBytes.php#L41-L53 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.incrementOrDecrement | protected function incrementOrDecrement($column, $amount, $extra, $method)
{
$query = $this->newQuery();
if (!$this->exists) {
return $query->{$method}($column, $amount, $extra);
}
$this->incrementOrDecrementAttributeValue($column, $amount, $method);
return $query->where(
$this->getKeyName(),
$this->getKey()
)->{$method}($column, $amount, $extra);
} | php | protected function incrementOrDecrement($column, $amount, $extra, $method)
{
$query = $this->newQuery();
if (!$this->exists) {
return $query->{$method}($column, $amount, $extra);
}
$this->incrementOrDecrementAttributeValue($column, $amount, $method);
return $query->where(
$this->getKeyName(),
$this->getKey()
)->{$method}($column, $amount, $extra);
} | [
"protected",
"function",
"incrementOrDecrement",
"(",
"$",
"column",
",",
"$",
"amount",
",",
"$",
"extra",
",",
"$",
"method",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"newQuery",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
"$",
"query",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"column",
",",
"$",
"amount",
",",
"$",
"extra",
")",
";",
"}",
"$",
"this",
"->",
"incrementOrDecrementAttributeValue",
"(",
"$",
"column",
",",
"$",
"amount",
",",
"$",
"method",
")",
";",
"return",
"$",
"query",
"->",
"where",
"(",
"$",
"this",
"->",
"getKeyName",
"(",
")",
",",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"column",
",",
"$",
"amount",
",",
"$",
"extra",
")",
";",
"}"
] | Run the increment or decrement method on the model.
@param string $column
@param int $amount
@param array $extra
@param string $method
@return int | [
"Run",
"the",
"increment",
"or",
"decrement",
"method",
"on",
"the",
"model",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L417-L431 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.finishSave | protected function finishSave(array $options)
{
$this->fireModelEvent('saved', false);
$this->syncOriginal();
if (Arr::get($options, 'touch', true)) {
$this->touchOwners();
}
} | php | protected function finishSave(array $options)
{
$this->fireModelEvent('saved', false);
$this->syncOriginal();
if (Arr::get($options, 'touch', true)) {
$this->touchOwners();
}
} | [
"protected",
"function",
"finishSave",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'saved'",
",",
"false",
")",
";",
"$",
"this",
"->",
"syncOriginal",
"(",
")",
";",
"if",
"(",
"Arr",
"::",
"get",
"(",
"$",
"options",
",",
"'touch'",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"touchOwners",
"(",
")",
";",
"}",
"}"
] | Perform any actions that are necessary after the model is saved.
@param array $options
@return void | [
"Perform",
"any",
"actions",
"that",
"are",
"necessary",
"after",
"the",
"model",
"is",
"saved",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L560-L569 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.destroy | public static function destroy($ids)
{
// We'll initialize a count here so we will return the total number of deletes
// for the operation. The developers can then check this number as a boolean
// type value or get this total count of records deleted for logging, etc.
$count = 0;
$ids = is_array($ids) ? $ids : func_get_args();
// We will actually pull the models from the database table and call delete on
// each of them individually so that their events get fired properly with a
// correct set of attributes in case the developers wants to check these.
$key = with($instance = new static)->getKeyName();
foreach ($instance->whereIn($key, $ids)->get() as $model) {
if ($model->delete()) {
++$count;
}
}
return $count;
} | php | public static function destroy($ids)
{
// We'll initialize a count here so we will return the total number of deletes
// for the operation. The developers can then check this number as a boolean
// type value or get this total count of records deleted for logging, etc.
$count = 0;
$ids = is_array($ids) ? $ids : func_get_args();
// We will actually pull the models from the database table and call delete on
// each of them individually so that their events get fired properly with a
// correct set of attributes in case the developers wants to check these.
$key = with($instance = new static)->getKeyName();
foreach ($instance->whereIn($key, $ids)->get() as $model) {
if ($model->delete()) {
++$count;
}
}
return $count;
} | [
"public",
"static",
"function",
"destroy",
"(",
"$",
"ids",
")",
"{",
"// We'll initialize a count here so we will return the total number of deletes",
"// for the operation. The developers can then check this number as a boolean",
"// type value or get this total count of records deleted for logging, etc.",
"$",
"count",
"=",
"0",
";",
"$",
"ids",
"=",
"is_array",
"(",
"$",
"ids",
")",
"?",
"$",
"ids",
":",
"func_get_args",
"(",
")",
";",
"// We will actually pull the models from the database table and call delete on",
"// each of them individually so that their events get fired properly with a",
"// correct set of attributes in case the developers wants to check these.",
"$",
"key",
"=",
"with",
"(",
"$",
"instance",
"=",
"new",
"static",
")",
"->",
"getKeyName",
"(",
")",
";",
"foreach",
"(",
"$",
"instance",
"->",
"whereIn",
"(",
"$",
"key",
",",
"$",
"ids",
")",
"->",
"get",
"(",
")",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"delete",
"(",
")",
")",
"{",
"++",
"$",
"count",
";",
"}",
"}",
"return",
"$",
"count",
";",
"}"
] | Destroy the models for the given IDs.
@param array|int $ids
@return int | [
"Destroy",
"the",
"models",
"for",
"the",
"given",
"IDs",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L708-L729 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.delete | public function delete()
{
if (is_null($this->getKeyName())) {
throw new Exception('No primary key defined on model.');
}
// If the model doesn't exist, there is nothing to delete so we'll just return
// immediately and not do anything else. Otherwise, we will continue with a
// deletion process on the model, firing the proper events, and so forth.
if (!$this->exists) {
return;
}
if ($this->fireModelEvent('deleting') === false) {
return false;
}
// Here, we'll touch the owning models, verifying these timestamps get updated
// for the models. This will allow any caching to get broken on the parents
// by the timestamp. Then we will go ahead and delete the model instance.
$this->touchOwners();
$this->performDeleteOnModel();
$this->exists = false;
// Once the model has been deleted, we will fire off the deleted event so that
// the developers may hook into post-delete operations. We will then return
// a boolean true as the delete is presumably successful on the database.
$this->fireModelEvent('deleted', false);
return true;
} | php | public function delete()
{
if (is_null($this->getKeyName())) {
throw new Exception('No primary key defined on model.');
}
// If the model doesn't exist, there is nothing to delete so we'll just return
// immediately and not do anything else. Otherwise, we will continue with a
// deletion process on the model, firing the proper events, and so forth.
if (!$this->exists) {
return;
}
if ($this->fireModelEvent('deleting') === false) {
return false;
}
// Here, we'll touch the owning models, verifying these timestamps get updated
// for the models. This will allow any caching to get broken on the parents
// by the timestamp. Then we will go ahead and delete the model instance.
$this->touchOwners();
$this->performDeleteOnModel();
$this->exists = false;
// Once the model has been deleted, we will fire off the deleted event so that
// the developers may hook into post-delete operations. We will then return
// a boolean true as the delete is presumably successful on the database.
$this->fireModelEvent('deleted', false);
return true;
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getKeyName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No primary key defined on model.'",
")",
";",
"}",
"// If the model doesn't exist, there is nothing to delete so we'll just return",
"// immediately and not do anything else. Otherwise, we will continue with a",
"// deletion process on the model, firing the proper events, and so forth.",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'deleting'",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// Here, we'll touch the owning models, verifying these timestamps get updated",
"// for the models. This will allow any caching to get broken on the parents",
"// by the timestamp. Then we will go ahead and delete the model instance.",
"$",
"this",
"->",
"touchOwners",
"(",
")",
";",
"$",
"this",
"->",
"performDeleteOnModel",
"(",
")",
";",
"$",
"this",
"->",
"exists",
"=",
"false",
";",
"// Once the model has been deleted, we will fire off the deleted event so that",
"// the developers may hook into post-delete operations. We will then return",
"// a boolean true as the delete is presumably successful on the database.",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'deleted'",
",",
"false",
")",
";",
"return",
"true",
";",
"}"
] | Delete the model from the database.
@throws \Exception
@return null|bool | [
"Delete",
"the",
"model",
"from",
"the",
"database",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L738-L770 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.newQueryWithoutScopes | public function newQueryWithoutScopes()
{
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
// Once we have the query builders, we will set the model instances so the
// builder can easily access any information it may need from the model
// while it is constructing and executing various queries against it.
return $builder->setModel($this)->with($this->with);
} | php | public function newQueryWithoutScopes()
{
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
// Once we have the query builders, we will set the model instances so the
// builder can easily access any information it may need from the model
// while it is constructing and executing various queries against it.
return $builder->setModel($this)->with($this->with);
} | [
"public",
"function",
"newQueryWithoutScopes",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"newEloquentBuilder",
"(",
"$",
"this",
"->",
"newBaseQueryBuilder",
"(",
")",
")",
";",
"// Once we have the query builders, we will set the model instances so the",
"// builder can easily access any information it may need from the model",
"// while it is constructing and executing various queries against it.",
"return",
"$",
"builder",
"->",
"setModel",
"(",
"$",
"this",
")",
"->",
"with",
"(",
"$",
"this",
"->",
"with",
")",
";",
"}"
] | Get a new query builder that doesn't have any global scopes.
@return \Mellivora\Database\Eloquent\Builder|static | [
"Get",
"a",
"new",
"query",
"builder",
"that",
"doesn",
"t",
"have",
"any",
"global",
"scopes",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L825-L833 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.newPivot | public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
{
return $using ? new $using($parent, $attributes, $table, $exists)
: new Pivot($parent, $attributes, $table, $exists);
} | php | public function newPivot(Model $parent, array $attributes, $table, $exists, $using = null)
{
return $using ? new $using($parent, $attributes, $table, $exists)
: new Pivot($parent, $attributes, $table, $exists);
} | [
"public",
"function",
"newPivot",
"(",
"Model",
"$",
"parent",
",",
"array",
"$",
"attributes",
",",
"$",
"table",
",",
"$",
"exists",
",",
"$",
"using",
"=",
"null",
")",
"{",
"return",
"$",
"using",
"?",
"new",
"$",
"using",
"(",
"$",
"parent",
",",
"$",
"attributes",
",",
"$",
"table",
",",
"$",
"exists",
")",
":",
"new",
"Pivot",
"(",
"$",
"parent",
",",
"$",
"attributes",
",",
"$",
"table",
",",
"$",
"exists",
")",
";",
"}"
] | Create a new pivot model instance.
@param \Mellivora\Database\Eloquent\Model $parent
@param array $attributes
@param string $table
@param bool $exists
@param null|string $using
@return \Mellivora\Database\Eloquent\Relations\Pivot | [
"Create",
"a",
"new",
"pivot",
"model",
"instance",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L900-L904 |
zhouyl/mellivora | Mellivora/Database/Eloquent/Model.php | Model.getTable | public function getTable()
{
if (!isset($this->table)) {
return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
}
return $this->table;
} | php | public function getTable()
{
if (!isset($this->table)) {
return str_replace('\\', '', Str::snake(Str::plural(class_basename($this))));
}
return $this->table;
} | [
"public",
"function",
"getTable",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"table",
")",
")",
"{",
"return",
"str_replace",
"(",
"'\\\\'",
",",
"''",
",",
"Str",
"::",
"snake",
"(",
"Str",
"::",
"plural",
"(",
"class_basename",
"(",
"$",
"this",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"table",
";",
"}"
] | Get the table associated with the model.
@return string | [
"Get",
"the",
"table",
"associated",
"with",
"the",
"model",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/Model.php#L1089-L1096 |
eymengunay/php-keyclient | src/Payment/AbstractPayment.php | AbstractPayment.get | public function get($key, $default = null)
{
if (array_key_exists($key, $this->params)) {
return $this->params[$key];
}
return $default;
} | php | public function get($key, $default = null)
{
if (array_key_exists($key, $this->params)) {
return $this->params[$key];
}
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"params",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Getter
@param string $key
@param mixed $default
@return mixed | [
"Getter"
] | train | https://github.com/eymengunay/php-keyclient/blob/867e035a2a0707c5df4198a8c321ddfd048a9c56/src/Payment/AbstractPayment.php#L74-L81 |
vaibhavpandeyvpz/sandesh | src/UploadedFile.php | UploadedFile.getStream | public function getStream()
{
if (!$this->stream) {
$this->stream = new Stream($this->file, 'r+');
}
return $this->stream;
} | php | public function getStream()
{
if (!$this->stream) {
$this->stream = new Stream($this->file, 'r+');
}
return $this->stream;
} | [
"public",
"function",
"getStream",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"stream",
")",
"{",
"$",
"this",
"->",
"stream",
"=",
"new",
"Stream",
"(",
"$",
"this",
"->",
"file",
",",
"'r+'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"stream",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/UploadedFile.php#L133-L139 |
vaibhavpandeyvpz/sandesh | src/UploadedFile.php | UploadedFile.moveTo | public function moveTo($targetPath)
{
if ($this->moved) {
throw new \RuntimeException('This file has already been moved');
}
$src = $this->getStream();
$src->rewind();
$dest = new Stream($targetPath, 'w');
while (!$src->eof()) {
$data = $src->read(self::WRITE_BUFFER);
if (!$dest->write($data)) {
break;
}
}
$src->close();
$dest->close();
$this->moved = true;
} | php | public function moveTo($targetPath)
{
if ($this->moved) {
throw new \RuntimeException('This file has already been moved');
}
$src = $this->getStream();
$src->rewind();
$dest = new Stream($targetPath, 'w');
while (!$src->eof()) {
$data = $src->read(self::WRITE_BUFFER);
if (!$dest->write($data)) {
break;
}
}
$src->close();
$dest->close();
$this->moved = true;
} | [
"public",
"function",
"moveTo",
"(",
"$",
"targetPath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"moved",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'This file has already been moved'",
")",
";",
"}",
"$",
"src",
"=",
"$",
"this",
"->",
"getStream",
"(",
")",
";",
"$",
"src",
"->",
"rewind",
"(",
")",
";",
"$",
"dest",
"=",
"new",
"Stream",
"(",
"$",
"targetPath",
",",
"'w'",
")",
";",
"while",
"(",
"!",
"$",
"src",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"src",
"->",
"read",
"(",
"self",
"::",
"WRITE_BUFFER",
")",
";",
"if",
"(",
"!",
"$",
"dest",
"->",
"write",
"(",
"$",
"data",
")",
")",
"{",
"break",
";",
"}",
"}",
"$",
"src",
"->",
"close",
"(",
")",
";",
"$",
"dest",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"moved",
"=",
"true",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/vaibhavpandeyvpz/sandesh/blob/bea2d06c7cac099ed82da973c922859de4158de0/src/UploadedFile.php#L144-L161 |
caffeinated/beverage | src/Command.php | Command.hasRootAccess | public function hasRootAccess()
{
$path = '/root/.' . md5('_radic-cli-perm-test' . time());
$root = (@file_put_contents($path, '1') === false ? false : true);
if ($root !== false) {
$this->getLaravel()->make('files')->delete($path);
}
return $root !== false;
} | php | public function hasRootAccess()
{
$path = '/root/.' . md5('_radic-cli-perm-test' . time());
$root = (@file_put_contents($path, '1') === false ? false : true);
if ($root !== false) {
$this->getLaravel()->make('files')->delete($path);
}
return $root !== false;
} | [
"public",
"function",
"hasRootAccess",
"(",
")",
"{",
"$",
"path",
"=",
"'/root/.'",
".",
"md5",
"(",
"'_radic-cli-perm-test'",
".",
"time",
"(",
")",
")",
";",
"$",
"root",
"=",
"(",
"@",
"file_put_contents",
"(",
"$",
"path",
",",
"'1'",
")",
"===",
"false",
"?",
"false",
":",
"true",
")",
";",
"if",
"(",
"$",
"root",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"getLaravel",
"(",
")",
"->",
"make",
"(",
"'files'",
")",
"->",
"delete",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"root",
"!==",
"false",
";",
"}"
] | hasRootAccess
@return bool | [
"hasRootAccess"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Command.php#L92-L101 |
caffeinated/beverage | src/Command.php | Command.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
if (! $this->allowSudo and ! $this->requireSudo and $this->hasRootAccess()) {
$this->error('Cannot execute this command with root privileges');
exit;
}
if ($this->requireSudo and ! $this->hasRootAccess()) {
$this->error('This command requires root privileges');
exit;
}
$this->getLaravel()->make('events')->fire('command.firing', $this->name);
$return = null;
if (method_exists($this, 'handle')) {
$return = $this->handle();
}
if (method_exists($this, 'fire')) {
$return = $this->fire();
}
$this->getLaravel()->make('events')->fire('command.fired', $this->name);
return $return;
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
if (! $this->allowSudo and ! $this->requireSudo and $this->hasRootAccess()) {
$this->error('Cannot execute this command with root privileges');
exit;
}
if ($this->requireSudo and ! $this->hasRootAccess()) {
$this->error('This command requires root privileges');
exit;
}
$this->getLaravel()->make('events')->fire('command.firing', $this->name);
$return = null;
if (method_exists($this, 'handle')) {
$return = $this->handle();
}
if (method_exists($this, 'fire')) {
$return = $this->fire();
}
$this->getLaravel()->make('events')->fire('command.fired', $this->name);
return $return;
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"allowSudo",
"and",
"!",
"$",
"this",
"->",
"requireSudo",
"and",
"$",
"this",
"->",
"hasRootAccess",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'Cannot execute this command with root privileges'",
")",
";",
"exit",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"requireSudo",
"and",
"!",
"$",
"this",
"->",
"hasRootAccess",
"(",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"'This command requires root privileges'",
")",
";",
"exit",
";",
"}",
"$",
"this",
"->",
"getLaravel",
"(",
")",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'command.firing'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"return",
"=",
"null",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'handle'",
")",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"handle",
"(",
")",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"'fire'",
")",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"fire",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getLaravel",
"(",
")",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'command.fired'",
",",
"$",
"this",
"->",
"name",
")",
";",
"return",
"$",
"return",
";",
"}"
] | execute
@param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return mixed | [
"execute"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Command.php#L110-L132 |
caffeinated/beverage | src/Command.php | Command.arrayTable | protected function arrayTable($arr, array $header = [ 'Key', 'Value' ])
{
$rows = [ ];
foreach ($arr as $key => $val) {
if (is_array($val)) {
$val = print_r(array_slice($val, 0, 5), true);
}
$rows[] = [ (string)$key, (string)$val ];
}
$this->table($header, $rows);
} | php | protected function arrayTable($arr, array $header = [ 'Key', 'Value' ])
{
$rows = [ ];
foreach ($arr as $key => $val) {
if (is_array($val)) {
$val = print_r(array_slice($val, 0, 5), true);
}
$rows[] = [ (string)$key, (string)$val ];
}
$this->table($header, $rows);
} | [
"protected",
"function",
"arrayTable",
"(",
"$",
"arr",
",",
"array",
"$",
"header",
"=",
"[",
"'Key'",
",",
"'Value'",
"]",
")",
"{",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"$",
"val",
"=",
"print_r",
"(",
"array_slice",
"(",
"$",
"val",
",",
"0",
",",
"5",
")",
",",
"true",
")",
";",
"}",
"$",
"rows",
"[",
"]",
"=",
"[",
"(",
"string",
")",
"$",
"key",
",",
"(",
"string",
")",
"$",
"val",
"]",
";",
"}",
"$",
"this",
"->",
"table",
"(",
"$",
"header",
",",
"$",
"rows",
")",
";",
"}"
] | arrayTable
@param $arr
@param array $header | [
"arrayTable"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Command.php#L155-L166 |
wplibs/rules | src/Operator/Between.php | Between.evaluate | public function evaluate( Context $context ) {
/**
* Extracts variables.
*
* @var \Ruler\Variable $left
* @var \Ruler\Variable $right
*/
list( $left, $right ) = $this->getOperands();
$left = $left->prepareValue( $context )->getValue();
$right = $right->prepareValue( $context )->getValue();
if ( 2 !== count( $right ) ) {
return false;
}
// Make sure we have a valid range.
if ( $right[0] > $right[1] ) {
$temp = $right[0];
$right[0] = $right[1];
$right[1] = $temp;
}
return ( $left >= $right[0] && $left <= $right[1] );
} | php | public function evaluate( Context $context ) {
/**
* Extracts variables.
*
* @var \Ruler\Variable $left
* @var \Ruler\Variable $right
*/
list( $left, $right ) = $this->getOperands();
$left = $left->prepareValue( $context )->getValue();
$right = $right->prepareValue( $context )->getValue();
if ( 2 !== count( $right ) ) {
return false;
}
// Make sure we have a valid range.
if ( $right[0] > $right[1] ) {
$temp = $right[0];
$right[0] = $right[1];
$right[1] = $temp;
}
return ( $left >= $right[0] && $left <= $right[1] );
} | [
"public",
"function",
"evaluate",
"(",
"Context",
"$",
"context",
")",
"{",
"/**\n\t\t * Extracts variables.\n\t\t *\n\t\t * @var \\Ruler\\Variable $left\n\t\t * @var \\Ruler\\Variable $right\n\t\t */",
"list",
"(",
"$",
"left",
",",
"$",
"right",
")",
"=",
"$",
"this",
"->",
"getOperands",
"(",
")",
";",
"$",
"left",
"=",
"$",
"left",
"->",
"prepareValue",
"(",
"$",
"context",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"right",
"=",
"$",
"right",
"->",
"prepareValue",
"(",
"$",
"context",
")",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"right",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Make sure we have a valid range.",
"if",
"(",
"$",
"right",
"[",
"0",
"]",
">",
"$",
"right",
"[",
"1",
"]",
")",
"{",
"$",
"temp",
"=",
"$",
"right",
"[",
"0",
"]",
";",
"$",
"right",
"[",
"0",
"]",
"=",
"$",
"right",
"[",
"1",
"]",
";",
"$",
"right",
"[",
"1",
"]",
"=",
"$",
"temp",
";",
"}",
"return",
"(",
"$",
"left",
">=",
"$",
"right",
"[",
"0",
"]",
"&&",
"$",
"left",
"<=",
"$",
"right",
"[",
"1",
"]",
")",
";",
"}"
] | Evaluate the operands.
@param Context $context Context with which to evaluate this Proposition.
@return boolean | [
"Evaluate",
"the",
"operands",
"."
] | train | https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Operator/Between.php#L16-L40 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/FileController.php | FileController.index | public function index()
{
$this->authorize('readList', File::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$query = QueryBuilder::with($params['filter'], $params['orderBy'], $params['query']);
$query->setPageSize($params['perPage']);
$results = $this->fileRepo->getFiles($query, $params['page']);
return $this->respondWithSuccess($results, new FileTransformer);
} | php | public function index()
{
$this->authorize('readList', File::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$query = QueryBuilder::with($params['filter'], $params['orderBy'], $params['query']);
$query->setPageSize($params['perPage']);
$results = $this->fileRepo->getFiles($query, $params['page']);
return $this->respondWithSuccess($results, new FileTransformer);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'readList'",
",",
"File",
"::",
"class",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'list'",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"processor",
"->",
"process",
"(",
"$",
"input",
")",
"->",
"getProcessedFields",
"(",
")",
";",
"$",
"query",
"=",
"QueryBuilder",
"::",
"with",
"(",
"$",
"params",
"[",
"'filter'",
"]",
",",
"$",
"params",
"[",
"'orderBy'",
"]",
",",
"$",
"params",
"[",
"'query'",
"]",
")",
";",
"$",
"query",
"->",
"setPageSize",
"(",
"$",
"params",
"[",
"'perPage'",
"]",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"getFiles",
"(",
"$",
"query",
",",
"$",
"params",
"[",
"'page'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"results",
",",
"new",
"FileTransformer",
")",
";",
"}"
] | Display a listing of the resource.
@return \Illuminate\Http\JsonResponse | [
"Display",
"a",
"listing",
"of",
"the",
"resource",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L62-L71 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/FileController.php | FileController.show | public function show($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('read', $file);
return $this->respondWithSuccess($file, new FileTransformer);
}
return $this->respondNotFound();
} | php | public function show($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('read', $file);
return $this->respondWithSuccess($file, new FileTransformer);
}
return $this->respondNotFound();
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'read'",
",",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"file",
",",
"new",
"FileTransformer",
")",
";",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Display the specified resource.
@param int $id file id
@return Response | [
"Display",
"the",
"specified",
"resource",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L80-L88 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/FileController.php | FileController.store | public function store(Request $request)
{
$this->authorize('create', File::class);
$input = $this->validator->validate('create');
if ($request->hasFile('file')) {
$uploadedFile = $request->file('file');
if ($uploadedFile->isValid()) {
try {
$file = $this->fileRepo->create($input, $uploadedFile, auth()->user());
return $this->respondWithSuccess($file, new FileTransformer);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
}
return $this->respondWithError('The file could not be uploaded - invalid or missing file');
} | php | public function store(Request $request)
{
$this->authorize('create', File::class);
$input = $this->validator->validate('create');
if ($request->hasFile('file')) {
$uploadedFile = $request->file('file');
if ($uploadedFile->isValid()) {
try {
$file = $this->fileRepo->create($input, $uploadedFile, auth()->user());
return $this->respondWithSuccess($file, new FileTransformer);
} catch (RepositoryValidationException $e) {
return $this->respondWithError($e->getMessage());
}
}
}
return $this->respondWithError('The file could not be uploaded - invalid or missing file');
} | [
"public",
"function",
"store",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'create'",
",",
"File",
"::",
"class",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'create'",
")",
";",
"if",
"(",
"$",
"request",
"->",
"hasFile",
"(",
"'file'",
")",
")",
"{",
"$",
"uploadedFile",
"=",
"$",
"request",
"->",
"file",
"(",
"'file'",
")",
";",
"if",
"(",
"$",
"uploadedFile",
"->",
"isValid",
"(",
")",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"create",
"(",
"$",
"input",
",",
"$",
"uploadedFile",
",",
"auth",
"(",
")",
"->",
"user",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"file",
",",
"new",
"FileTransformer",
")",
";",
"}",
"catch",
"(",
"RepositoryValidationException",
"$",
"e",
")",
"{",
"return",
"$",
"this",
"->",
"respondWithError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"respondWithError",
"(",
"'The file could not be uploaded - invalid or missing file'",
")",
";",
"}"
] | Stores newly created file in database.
@param Request $request Request object
@return \Illuminate\Http\JsonResponse | [
"Stores",
"newly",
"created",
"file",
"in",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L97-L113 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/FileController.php | FileController.destroy | public function destroy($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('delete', $file);
$this->fileRepo->delete($file);
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
} | php | public function destroy($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('delete', $file);
$this->fileRepo->delete($file);
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
} | [
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"file",
")",
";",
"$",
"this",
"->",
"fileRepo",
"->",
"delete",
"(",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSimpleSuccess",
"(",
"[",
"'success'",
"=>",
"true",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Remove the specified file from database.
@param int $id Id of the file
@return \Illuminate\Http\JsonResponse | [
"Remove",
"the",
"specified",
"file",
"from",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L122-L132 |
GrupaZero/api | src/Gzero/Api/Controller/Admin/FileController.php | FileController.update | public function update($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('update', $file);
$input = $this->validator->validate('update');
$file = $this->fileRepo->update($file, $input, Auth::user());
return $this->respondWithSuccess($file, new FileTransformer);
}
return $this->respondNotFound();
} | php | public function update($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('update', $file);
$input = $this->validator->validate('update');
$file = $this->fileRepo->update($file, $input, Auth::user());
return $this->respondWithSuccess($file, new FileTransformer);
}
return $this->respondNotFound();
} | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'update'",
",",
"$",
"file",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'update'",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"update",
"(",
"$",
"file",
",",
"$",
"input",
",",
"Auth",
"::",
"user",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"file",
",",
"new",
"FileTransformer",
")",
";",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] | Updates the specified resource in the database.
@param int $id File id
@return \Illuminate\Http\JsonResponse | [
"Updates",
"the",
"specified",
"resource",
"in",
"the",
"database",
"."
] | train | https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L141-L151 |
wolfguarder/yii2-block | controllers/AdminController.php | AdminController.actionIndex | public function actionIndex()
{
$searchModel = $this->module->manager->createBlockSearch();
$dataProvider = $searchModel->search($_GET);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
} | php | public function actionIndex()
{
$searchModel = $this->module->manager->createBlockSearch();
$dataProvider = $searchModel->search($_GET);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createBlockSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"$",
"_GET",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"]",
")",
";",
"}"
] | Lists all Block models.
@return mixed | [
"Lists",
"all",
"Block",
"models",
"."
] | train | https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L48-L57 |
wolfguarder/yii2-block | controllers/AdminController.php | AdminController.actionCreate | public function actionCreate()
{
$model = $this->module->manager->createBlock(['scenario' => 'create']);
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been created'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model
]);
} | php | public function actionCreate()
{
$model = $this->module->manager->createBlock(['scenario' => 'create']);
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been created'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model
]);
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createBlock",
"(",
"[",
"'scenario'",
"=>",
"'create'",
"]",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"create",
"(",
")",
")",
"{",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'block.success'",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'block'",
",",
"'Block has been created'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'create'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] | Creates a new Block model.
If creation is successful, the browser will be redirected to the 'index' page.
@return mixed | [
"Creates",
"a",
"new",
"Block",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | train | https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L64-L76 |
wolfguarder/yii2-block | controllers/AdminController.php | AdminController.actionUpdate | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->scenario = 'update';
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been updated'));
return $this->refresh();
}
return $this->render('update', [
'model' => $model
]);
} | php | public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->scenario = 'update';
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been updated'));
return $this->refresh();
}
return $this->render('update', [
'model' => $model
]);
} | [
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"scenario",
"=",
"'update'",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'returnUrl'",
")",
")",
"{",
"$",
"back",
"=",
"urldecode",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'returnUrl'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"back",
")",
";",
"}",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'block.success'",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'block'",
",",
"'Block has been updated'",
")",
")",
";",
"return",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'update'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] | Updates an existing Block model.
If update is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"Block",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | train | https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L84-L102 |
zhengb302/LumengPHP-Db | src/LumengPHP/Db/Connection/AbstractPDOProvider.php | AbstractPDOProvider.makePdo | protected function makePdo($dsn, $username, $password, array $options = null) {
$pdo = new PDO($dsn, $username, $password, $options);
//设置PDO错误模式为"抛出异常"
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//设置字符集
$pdo->exec("SET NAMES {$this->config['charset']}");
return $pdo;
} | php | protected function makePdo($dsn, $username, $password, array $options = null) {
$pdo = new PDO($dsn, $username, $password, $options);
//设置PDO错误模式为"抛出异常"
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//设置字符集
$pdo->exec("SET NAMES {$this->config['charset']}");
return $pdo;
} | [
"protected",
"function",
"makePdo",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"pdo",
"=",
"new",
"PDO",
"(",
"$",
"dsn",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"options",
")",
";",
"//设置PDO错误模式为\"抛出异常\"",
"$",
"pdo",
"->",
"setAttribute",
"(",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"//设置字符集",
"$",
"pdo",
"->",
"exec",
"(",
"\"SET NAMES {$this->config['charset']}\"",
")",
";",
"return",
"$",
"pdo",
";",
"}"
] | 创建一个PDO对象并返回
@param string $dsn
@param string $username
@param string $password
@param array $options
@return PDO | [
"创建一个PDO对象并返回"
] | train | https://github.com/zhengb302/LumengPHP-Db/blob/47384aa37bc26352efb7ecda3c139cf8cb03db83/src/LumengPHP/Db/Connection/AbstractPDOProvider.php#L47-L57 |
Speicher210/monsum-api | src/Serializer/Handler/DateHandler.php | DateHandler.deserializeDateTimeFromJson | public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
{
// Handle empty or invalid date / datetime values.
if ('' === $data || null === $data || strpos($data, '0000-00-00') !== false) {
return null;
}
// We want to always show the response in the UTC timezone.
$dateTime = parent::deserializeDateTimeFromJson($visitor, $data, $type);
if ($dateTime instanceof \DateTime) {
$dateTime->setTimezone(new \DateTimeZone('UTC'));
}
return $dateTime;
} | php | public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
{
// Handle empty or invalid date / datetime values.
if ('' === $data || null === $data || strpos($data, '0000-00-00') !== false) {
return null;
}
// We want to always show the response in the UTC timezone.
$dateTime = parent::deserializeDateTimeFromJson($visitor, $data, $type);
if ($dateTime instanceof \DateTime) {
$dateTime->setTimezone(new \DateTimeZone('UTC'));
}
return $dateTime;
} | [
"public",
"function",
"deserializeDateTimeFromJson",
"(",
"JsonDeserializationVisitor",
"$",
"visitor",
",",
"$",
"data",
",",
"array",
"$",
"type",
")",
"{",
"// Handle empty or invalid date / datetime values.",
"if",
"(",
"''",
"===",
"$",
"data",
"||",
"null",
"===",
"$",
"data",
"||",
"strpos",
"(",
"$",
"data",
",",
"'0000-00-00'",
")",
"!==",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// We want to always show the response in the UTC timezone.",
"$",
"dateTime",
"=",
"parent",
"::",
"deserializeDateTimeFromJson",
"(",
"$",
"visitor",
",",
"$",
"data",
",",
"$",
"type",
")",
";",
"if",
"(",
"$",
"dateTime",
"instanceof",
"\\",
"DateTime",
")",
"{",
"$",
"dateTime",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"}",
"return",
"$",
"dateTime",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Serializer/Handler/DateHandler.php#L34-L49 |
thupan/framework | src/Service/PDF.php | PDF.RowConfig | public function RowConfig($config){
$conf = (object) $config;
($conf->align ) ? $this->SetAligns ($conf->align ):false;
($conf->background) ? $this->SetBackgrounds($conf->background):false;
($conf->border ) ? $this->SetBorders ($conf->border ):false;
($conf->fill ) ? $this->SetFills ($conf->fill ):false;
($conf->fontColor ) ? $this->SetFontColor ($conf->fontColor ):false;
($conf->font ) ? $this->SetFonts ($conf->font ):false;
($conf->height ) ? $this->SetHeights ($conf->height ):false;
($conf->style ) ? $this->SetStyles ($conf->style ):false;
($conf->size ) ? $this->SetSizes ($conf->size ):false;
($conf->valign ) ? $this->SetVAligns ($conf->valign ):false;
($conf->width ) ? $this->SetWidths ($conf->width ):false;
($conf->reset ) ? $this->ResetConfig ($conf->reset ):false;
} | php | public function RowConfig($config){
$conf = (object) $config;
($conf->align ) ? $this->SetAligns ($conf->align ):false;
($conf->background) ? $this->SetBackgrounds($conf->background):false;
($conf->border ) ? $this->SetBorders ($conf->border ):false;
($conf->fill ) ? $this->SetFills ($conf->fill ):false;
($conf->fontColor ) ? $this->SetFontColor ($conf->fontColor ):false;
($conf->font ) ? $this->SetFonts ($conf->font ):false;
($conf->height ) ? $this->SetHeights ($conf->height ):false;
($conf->style ) ? $this->SetStyles ($conf->style ):false;
($conf->size ) ? $this->SetSizes ($conf->size ):false;
($conf->valign ) ? $this->SetVAligns ($conf->valign ):false;
($conf->width ) ? $this->SetWidths ($conf->width ):false;
($conf->reset ) ? $this->ResetConfig ($conf->reset ):false;
} | [
"public",
"function",
"RowConfig",
"(",
"$",
"config",
")",
"{",
"$",
"conf",
"=",
"(",
"object",
")",
"$",
"config",
";",
"(",
"$",
"conf",
"->",
"align",
")",
"?",
"$",
"this",
"->",
"SetAligns",
"(",
"$",
"conf",
"->",
"align",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"background",
")",
"?",
"$",
"this",
"->",
"SetBackgrounds",
"(",
"$",
"conf",
"->",
"background",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"border",
")",
"?",
"$",
"this",
"->",
"SetBorders",
"(",
"$",
"conf",
"->",
"border",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"fill",
")",
"?",
"$",
"this",
"->",
"SetFills",
"(",
"$",
"conf",
"->",
"fill",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"fontColor",
")",
"?",
"$",
"this",
"->",
"SetFontColor",
"(",
"$",
"conf",
"->",
"fontColor",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"font",
")",
"?",
"$",
"this",
"->",
"SetFonts",
"(",
"$",
"conf",
"->",
"font",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"height",
")",
"?",
"$",
"this",
"->",
"SetHeights",
"(",
"$",
"conf",
"->",
"height",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"style",
")",
"?",
"$",
"this",
"->",
"SetStyles",
"(",
"$",
"conf",
"->",
"style",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"size",
")",
"?",
"$",
"this",
"->",
"SetSizes",
"(",
"$",
"conf",
"->",
"size",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"valign",
")",
"?",
"$",
"this",
"->",
"SetVAligns",
"(",
"$",
"conf",
"->",
"valign",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"width",
")",
"?",
"$",
"this",
"->",
"SetWidths",
"(",
"$",
"conf",
"->",
"width",
")",
":",
"false",
";",
"(",
"$",
"conf",
"->",
"reset",
")",
"?",
"$",
"this",
"->",
"ResetConfig",
"(",
"$",
"conf",
"->",
"reset",
")",
":",
"false",
";",
"}"
] | O formato do array segue nas especificações abaixo:
As chaves possíveis são:
CHAVE | OPÇÕES | DESCRIÇÃO
border : ('B' &| 'T' &| 'R' &| 'L') || 1 || 0 - string ou inteiro (bordas da celula)
style : 'B' | 'I' | 'U' | '' - string (formato da fonte)
font : 'NomeDaFonte' - string (nome da fonte)
background : true || false - boolean (com fundo ou sem fundo)
fill : 0 à 255 - inteiro (cor do preenchimento)
size : 4 à 62 - inteiro (tamanho da fonte)
align : 'L' || 'R' || 'C' || 'J' - string (alinhamento do texto)
width : 1 a (275<landscape> || 190<portrait>) - array (tamanho da coluna)
height : 1 a N - inteiro (tamanho da altura da linha)
reset : true || false - boolean (reseta as configurações do row)
OBS: para cada CHAVE pode-se receber UM VALOR ou um ARRAY com valores
@param mixed[] $config Array de configurações com chave e valores.
Exemplo para colunas padronizadas (como um theader):
$arrayConfig = [
'border' => 1, // aceita array também
'style' => 'B', // aceita array também
'font' => 'Helvetica', // aceita array também
'background' => true, // aceita array também
'fill' => 240, // aceita array também
'size' => 9, // aceita array também
'align' => 'C', // aceita array também
'width' => [15,40,23,20,20], // só aceita array
'height' => 5 , // só aceita inteiro
'reset' => true // só aceita booleano
]; | [
"O",
"formato",
"do",
"array",
"segue",
"nas",
"especificações",
"abaixo",
":",
"As",
"chaves",
"possíveis",
"são",
":"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L509-L526 |
thupan/framework | src/Service/PDF.php | PDF.array_sum_interval | function array_sum_interval($array_external, $interval){
$n_interval=explode(":", $interval);
$sum = 0;
for($i=$n_interval[0]; $i < ($n_interval[1]+1) ; $i++){
$sum += $array_external[$i];
}
return $sum;
} | php | function array_sum_interval($array_external, $interval){
$n_interval=explode(":", $interval);
$sum = 0;
for($i=$n_interval[0]; $i < ($n_interval[1]+1) ; $i++){
$sum += $array_external[$i];
}
return $sum;
} | [
"function",
"array_sum_interval",
"(",
"$",
"array_external",
",",
"$",
"interval",
")",
"{",
"$",
"n_interval",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"interval",
")",
";",
"$",
"sum",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"n_interval",
"[",
"0",
"]",
";",
"$",
"i",
"<",
"(",
"$",
"n_interval",
"[",
"1",
"]",
"+",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sum",
"+=",
"$",
"array_external",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"sum",
";",
"}"
] | Function for sum intervals of an array | [
"Function",
"for",
"sum",
"intervals",
"of",
"an",
"array"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L531-L540 |
thupan/framework | src/Service/PDF.php | PDF.array_sum_intervals | function array_sum_intervals($array_external, $intervals){
$n_intervals=explode(";", $intervals);
$array_amount = count($n_intervals);
$result = 0;
for($i=0; $i < $array_amount ; $i++){
$result += $this->array_sum_interval($array_external, $n_intervals[$i]);
}
return $result;
} | php | function array_sum_intervals($array_external, $intervals){
$n_intervals=explode(";", $intervals);
$array_amount = count($n_intervals);
$result = 0;
for($i=0; $i < $array_amount ; $i++){
$result += $this->array_sum_interval($array_external, $n_intervals[$i]);
}
return $result;
} | [
"function",
"array_sum_intervals",
"(",
"$",
"array_external",
",",
"$",
"intervals",
")",
"{",
"$",
"n_intervals",
"=",
"explode",
"(",
"\";\"",
",",
"$",
"intervals",
")",
";",
"$",
"array_amount",
"=",
"count",
"(",
"$",
"n_intervals",
")",
";",
"$",
"result",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"array_amount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
"+=",
"$",
"this",
"->",
"array_sum_interval",
"(",
"$",
"array_external",
",",
"$",
"n_intervals",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Function for sum a interval of an array | [
"Function",
"for",
"sum",
"a",
"interval",
"of",
"an",
"array"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L542-L552 |
thupan/framework | src/Service/PDF.php | PDF.flipDiagonally | function flipDiagonally($arr)
{
$out = array();
foreach ($arr as $key => $subarr) {
foreach ($subarr as $subkey => $subvalue) {
$out[$subkey][$key] = $subvalue;
}
}
return $out;
} | php | function flipDiagonally($arr)
{
$out = array();
foreach ($arr as $key => $subarr) {
foreach ($subarr as $subkey => $subvalue) {
$out[$subkey][$key] = $subvalue;
}
}
return $out;
} | [
"function",
"flipDiagonally",
"(",
"$",
"arr",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"subarr",
")",
"{",
"foreach",
"(",
"$",
"subarr",
"as",
"$",
"subkey",
"=>",
"$",
"subvalue",
")",
"{",
"$",
"out",
"[",
"$",
"subkey",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"subvalue",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Matriz Transposta - transforma array dados de linhas em colunas | [
"Matriz",
"Transposta",
"-",
"transforma",
"array",
"dados",
"de",
"linhas",
"em",
"colunas"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L555-L564 |
thupan/framework | src/Service/PDF.php | PDF.Image | function Image($file, $x = null, $y = null, $w=0, $h=0, $type='', $link='', $isMask=false, $maskImg=0)
{
//Put an image on the page
if(!isset($this->images[$file]))
{
//First use of image, get info
if($type=='')
{
$pos=strrpos($file, '.');
if(!$pos)
$this->Error('Image file has no extension and no type was specified: '.$file);
$type=substr($file, $pos+1);
}
$type=strtolower($type);
$mqr=get_magic_quotes_runtime();
//set_magic_quotes_runtime(0);
if($type=='jpg' || $type=='jpeg')
$info=$this->_parsejpg($file);
elseif($type=='png'){
$info=$this->_parsepng($file);
if ($info=='alpha') return $this->ImagePngWithAlpha($file, $x, $y, $w, $h, $link);
}
else
{
//Allow for additional formats
$mtd='_parse'.$type;
if(!method_exists($this, $mtd))
$this->Error('Unsupported image type: '.$type);
$info=$this->$mtd($file);
}
//set_magic_quotes_runtime($mqr);
if ($isMask){
$info['cs']="DeviceGray"; // try to force grayscale (instead of indexed)
}
$info['i']=count($this->images)+1;
if ($maskImg>0) $info['masked'] = $maskImg;###
$this->images[$file]=$info;
}
else
$info=$this->images[$file];
//Automatic width and height calculation if needed
if($w==0 && $h==0)
{
//Put image at 72 dpi
$w=$info['w']/$this->k;
$h=$info['h']/$this->k;
}
if($w==0)
$w=$h*$info['w']/$info['h'];
if($h==0)
$h=$w*$info['h']/$info['w'];
// embed hidden, ouside the canvas
if ((float)FPDF_VERSION>=1.7){
if ($isMask) $x = ($this->CurOrientation=='P'?$this->CurPageSize[0]:$this->CurPageSize[1]) + 10;
}else{
if ($isMask) $x = ($this->CurOrientation=='P'?$this->CurPageFormat[0]:$this->CurPageFormat[1]) + 10;
}
$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', $w*$this->k, $h*$this->k, $x*$this->k, ($this->h-($y+$h))*$this->k, $info['i']));
if($link)
$this->Link($x, $y, $w, $h, $link);
return $info['i'];
} | php | function Image($file, $x = null, $y = null, $w=0, $h=0, $type='', $link='', $isMask=false, $maskImg=0)
{
//Put an image on the page
if(!isset($this->images[$file]))
{
//First use of image, get info
if($type=='')
{
$pos=strrpos($file, '.');
if(!$pos)
$this->Error('Image file has no extension and no type was specified: '.$file);
$type=substr($file, $pos+1);
}
$type=strtolower($type);
$mqr=get_magic_quotes_runtime();
//set_magic_quotes_runtime(0);
if($type=='jpg' || $type=='jpeg')
$info=$this->_parsejpg($file);
elseif($type=='png'){
$info=$this->_parsepng($file);
if ($info=='alpha') return $this->ImagePngWithAlpha($file, $x, $y, $w, $h, $link);
}
else
{
//Allow for additional formats
$mtd='_parse'.$type;
if(!method_exists($this, $mtd))
$this->Error('Unsupported image type: '.$type);
$info=$this->$mtd($file);
}
//set_magic_quotes_runtime($mqr);
if ($isMask){
$info['cs']="DeviceGray"; // try to force grayscale (instead of indexed)
}
$info['i']=count($this->images)+1;
if ($maskImg>0) $info['masked'] = $maskImg;###
$this->images[$file]=$info;
}
else
$info=$this->images[$file];
//Automatic width and height calculation if needed
if($w==0 && $h==0)
{
//Put image at 72 dpi
$w=$info['w']/$this->k;
$h=$info['h']/$this->k;
}
if($w==0)
$w=$h*$info['w']/$info['h'];
if($h==0)
$h=$w*$info['h']/$info['w'];
// embed hidden, ouside the canvas
if ((float)FPDF_VERSION>=1.7){
if ($isMask) $x = ($this->CurOrientation=='P'?$this->CurPageSize[0]:$this->CurPageSize[1]) + 10;
}else{
if ($isMask) $x = ($this->CurOrientation=='P'?$this->CurPageFormat[0]:$this->CurPageFormat[1]) + 10;
}
$this->_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', $w*$this->k, $h*$this->k, $x*$this->k, ($this->h-($y+$h))*$this->k, $info['i']));
if($link)
$this->Link($x, $y, $w, $h, $link);
return $info['i'];
} | [
"function",
"Image",
"(",
"$",
"file",
",",
"$",
"x",
"=",
"null",
",",
"$",
"y",
"=",
"null",
",",
"$",
"w",
"=",
"0",
",",
"$",
"h",
"=",
"0",
",",
"$",
"type",
"=",
"''",
",",
"$",
"link",
"=",
"''",
",",
"$",
"isMask",
"=",
"false",
",",
"$",
"maskImg",
"=",
"0",
")",
"{",
"//Put an image on the page",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"images",
"[",
"$",
"file",
"]",
")",
")",
"{",
"//First use of image, get info",
"if",
"(",
"$",
"type",
"==",
"''",
")",
"{",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"file",
",",
"'.'",
")",
";",
"if",
"(",
"!",
"$",
"pos",
")",
"$",
"this",
"->",
"Error",
"(",
"'Image file has no extension and no type was specified: '",
".",
"$",
"file",
")",
";",
"$",
"type",
"=",
"substr",
"(",
"$",
"file",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"$",
"mqr",
"=",
"get_magic_quotes_runtime",
"(",
")",
";",
"//set_magic_quotes_runtime(0);",
"if",
"(",
"$",
"type",
"==",
"'jpg'",
"||",
"$",
"type",
"==",
"'jpeg'",
")",
"$",
"info",
"=",
"$",
"this",
"->",
"_parsejpg",
"(",
"$",
"file",
")",
";",
"elseif",
"(",
"$",
"type",
"==",
"'png'",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"_parsepng",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"info",
"==",
"'alpha'",
")",
"return",
"$",
"this",
"->",
"ImagePngWithAlpha",
"(",
"$",
"file",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"link",
")",
";",
"}",
"else",
"{",
"//Allow for additional formats",
"$",
"mtd",
"=",
"'_parse'",
".",
"$",
"type",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"mtd",
")",
")",
"$",
"this",
"->",
"Error",
"(",
"'Unsupported image type: '",
".",
"$",
"type",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"$",
"mtd",
"(",
"$",
"file",
")",
";",
"}",
"//set_magic_quotes_runtime($mqr);",
"if",
"(",
"$",
"isMask",
")",
"{",
"$",
"info",
"[",
"'cs'",
"]",
"=",
"\"DeviceGray\"",
";",
"// try to force grayscale (instead of indexed)",
"}",
"$",
"info",
"[",
"'i'",
"]",
"=",
"count",
"(",
"$",
"this",
"->",
"images",
")",
"+",
"1",
";",
"if",
"(",
"$",
"maskImg",
">",
"0",
")",
"$",
"info",
"[",
"'masked'",
"]",
"=",
"$",
"maskImg",
";",
"###",
"$",
"this",
"->",
"images",
"[",
"$",
"file",
"]",
"=",
"$",
"info",
";",
"}",
"else",
"$",
"info",
"=",
"$",
"this",
"->",
"images",
"[",
"$",
"file",
"]",
";",
"//Automatic width and height calculation if needed",
"if",
"(",
"$",
"w",
"==",
"0",
"&&",
"$",
"h",
"==",
"0",
")",
"{",
"//Put image at 72 dpi",
"$",
"w",
"=",
"$",
"info",
"[",
"'w'",
"]",
"/",
"$",
"this",
"->",
"k",
";",
"$",
"h",
"=",
"$",
"info",
"[",
"'h'",
"]",
"/",
"$",
"this",
"->",
"k",
";",
"}",
"if",
"(",
"$",
"w",
"==",
"0",
")",
"$",
"w",
"=",
"$",
"h",
"*",
"$",
"info",
"[",
"'w'",
"]",
"/",
"$",
"info",
"[",
"'h'",
"]",
";",
"if",
"(",
"$",
"h",
"==",
"0",
")",
"$",
"h",
"=",
"$",
"w",
"*",
"$",
"info",
"[",
"'h'",
"]",
"/",
"$",
"info",
"[",
"'w'",
"]",
";",
"// embed hidden, ouside the canvas",
"if",
"(",
"(",
"float",
")",
"FPDF_VERSION",
">=",
"1.7",
")",
"{",
"if",
"(",
"$",
"isMask",
")",
"$",
"x",
"=",
"(",
"$",
"this",
"->",
"CurOrientation",
"==",
"'P'",
"?",
"$",
"this",
"->",
"CurPageSize",
"[",
"0",
"]",
":",
"$",
"this",
"->",
"CurPageSize",
"[",
"1",
"]",
")",
"+",
"10",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"isMask",
")",
"$",
"x",
"=",
"(",
"$",
"this",
"->",
"CurOrientation",
"==",
"'P'",
"?",
"$",
"this",
"->",
"CurPageFormat",
"[",
"0",
"]",
":",
"$",
"this",
"->",
"CurPageFormat",
"[",
"1",
"]",
")",
"+",
"10",
";",
"}",
"$",
"this",
"->",
"_out",
"(",
"sprintf",
"(",
"'q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q'",
",",
"$",
"w",
"*",
"$",
"this",
"->",
"k",
",",
"$",
"h",
"*",
"$",
"this",
"->",
"k",
",",
"$",
"x",
"*",
"$",
"this",
"->",
"k",
",",
"(",
"$",
"this",
"->",
"h",
"-",
"(",
"$",
"y",
"+",
"$",
"h",
")",
")",
"*",
"$",
"this",
"->",
"k",
",",
"$",
"info",
"[",
"'i'",
"]",
")",
")",
";",
"if",
"(",
"$",
"link",
")",
"$",
"this",
"->",
"Link",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"$",
"link",
")",
";",
"return",
"$",
"info",
"[",
"'i'",
"]",
";",
"}"
] | *****************************************************************************
*
Public methods *
*
***************************************************************************** | [
"*****************************************************************************",
"*",
"Public",
"methods",
"*",
"*",
"*****************************************************************************"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L605-L670 |
thupan/framework | src/Service/PDF.php | PDF.ImagePngWithAlpha | function ImagePngWithAlpha($file, $x, $y, $w=0, $h=0, $link='')
{
$tmp_alpha = tempnam('.', 'mska');
$this->tmpFiles[] = $tmp_alpha;
$tmp_plain = tempnam('.', 'mskp');
$this->tmpFiles[] = $tmp_plain;
list($wpx, $hpx) = getimagesize($file);
$img = imagecreatefrompng($file);
$alpha_img = imagecreate( $wpx, $hpx );
// generate gray scale pallete
for($c=0;$c<256;$c++) ImageColorAllocate($alpha_img, $c, $c, $c);
// extract alpha channel
$xpx=0;
while ($xpx<$wpx){
$ypx = 0;
while ($ypx<$hpx){
$color_index = imagecolorat($img, $xpx, $ypx);
$alpha = 255-($color_index>>24)*255/127; // GD alpha component: 7 bit only, 0..127!
imagesetpixel($alpha_img, $xpx, $ypx, $alpha);
++$ypx;
}
++$xpx;
}
imagepng($alpha_img, $tmp_alpha);
imagedestroy($alpha_img);
// extract image without alpha channel
$plain_img = imagecreatetruecolor ( $wpx, $hpx );
imagecopy ($plain_img, $img, 0, 0, 0, 0, $wpx, $hpx );
imagepng($plain_img, $tmp_plain);
imagedestroy($plain_img);
//first embed mask image (w, h, x, will be ignored)
$maskImg = $this->Image($tmp_alpha, 0, 0, 0, 0, 'PNG', '', true);
//embed image, masked with previously embedded mask
$this->Image($tmp_plain, $x, $y, $w, $h, 'PNG', $link, false, $maskImg);
} | php | function ImagePngWithAlpha($file, $x, $y, $w=0, $h=0, $link='')
{
$tmp_alpha = tempnam('.', 'mska');
$this->tmpFiles[] = $tmp_alpha;
$tmp_plain = tempnam('.', 'mskp');
$this->tmpFiles[] = $tmp_plain;
list($wpx, $hpx) = getimagesize($file);
$img = imagecreatefrompng($file);
$alpha_img = imagecreate( $wpx, $hpx );
// generate gray scale pallete
for($c=0;$c<256;$c++) ImageColorAllocate($alpha_img, $c, $c, $c);
// extract alpha channel
$xpx=0;
while ($xpx<$wpx){
$ypx = 0;
while ($ypx<$hpx){
$color_index = imagecolorat($img, $xpx, $ypx);
$alpha = 255-($color_index>>24)*255/127; // GD alpha component: 7 bit only, 0..127!
imagesetpixel($alpha_img, $xpx, $ypx, $alpha);
++$ypx;
}
++$xpx;
}
imagepng($alpha_img, $tmp_alpha);
imagedestroy($alpha_img);
// extract image without alpha channel
$plain_img = imagecreatetruecolor ( $wpx, $hpx );
imagecopy ($plain_img, $img, 0, 0, 0, 0, $wpx, $hpx );
imagepng($plain_img, $tmp_plain);
imagedestroy($plain_img);
//first embed mask image (w, h, x, will be ignored)
$maskImg = $this->Image($tmp_alpha, 0, 0, 0, 0, 'PNG', '', true);
//embed image, masked with previously embedded mask
$this->Image($tmp_plain, $x, $y, $w, $h, 'PNG', $link, false, $maskImg);
} | [
"function",
"ImagePngWithAlpha",
"(",
"$",
"file",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
"=",
"0",
",",
"$",
"h",
"=",
"0",
",",
"$",
"link",
"=",
"''",
")",
"{",
"$",
"tmp_alpha",
"=",
"tempnam",
"(",
"'.'",
",",
"'mska'",
")",
";",
"$",
"this",
"->",
"tmpFiles",
"[",
"]",
"=",
"$",
"tmp_alpha",
";",
"$",
"tmp_plain",
"=",
"tempnam",
"(",
"'.'",
",",
"'mskp'",
")",
";",
"$",
"this",
"->",
"tmpFiles",
"[",
"]",
"=",
"$",
"tmp_plain",
";",
"list",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
"=",
"getimagesize",
"(",
"$",
"file",
")",
";",
"$",
"img",
"=",
"imagecreatefrompng",
"(",
"$",
"file",
")",
";",
"$",
"alpha_img",
"=",
"imagecreate",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"// generate gray scale pallete",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"256",
";",
"$",
"c",
"++",
")",
"ImageColorAllocate",
"(",
"$",
"alpha_img",
",",
"$",
"c",
",",
"$",
"c",
",",
"$",
"c",
")",
";",
"// extract alpha channel",
"$",
"xpx",
"=",
"0",
";",
"while",
"(",
"$",
"xpx",
"<",
"$",
"wpx",
")",
"{",
"$",
"ypx",
"=",
"0",
";",
"while",
"(",
"$",
"ypx",
"<",
"$",
"hpx",
")",
"{",
"$",
"color_index",
"=",
"imagecolorat",
"(",
"$",
"img",
",",
"$",
"xpx",
",",
"$",
"ypx",
")",
";",
"$",
"alpha",
"=",
"255",
"-",
"(",
"$",
"color_index",
">>",
"24",
")",
"*",
"255",
"/",
"127",
";",
"// GD alpha component: 7 bit only, 0..127!",
"imagesetpixel",
"(",
"$",
"alpha_img",
",",
"$",
"xpx",
",",
"$",
"ypx",
",",
"$",
"alpha",
")",
";",
"++",
"$",
"ypx",
";",
"}",
"++",
"$",
"xpx",
";",
"}",
"imagepng",
"(",
"$",
"alpha_img",
",",
"$",
"tmp_alpha",
")",
";",
"imagedestroy",
"(",
"$",
"alpha_img",
")",
";",
"// extract image without alpha channel",
"$",
"plain_img",
"=",
"imagecreatetruecolor",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"imagecopy",
"(",
"$",
"plain_img",
",",
"$",
"img",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"imagepng",
"(",
"$",
"plain_img",
",",
"$",
"tmp_plain",
")",
";",
"imagedestroy",
"(",
"$",
"plain_img",
")",
";",
"//first embed mask image (w, h, x, will be ignored)",
"$",
"maskImg",
"=",
"$",
"this",
"->",
"Image",
"(",
"$",
"tmp_alpha",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"'PNG'",
",",
"''",
",",
"true",
")",
";",
"//embed image, masked with previously embedded mask",
"$",
"this",
"->",
"Image",
"(",
"$",
"tmp_plain",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"'PNG'",
",",
"$",
"link",
",",
"false",
",",
"$",
"maskImg",
")",
";",
"}"
] | pixel-wise operation, not very fast | [
"pixel",
"-",
"wise",
"operation",
"not",
"very",
"fast"
] | train | https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L674-L715 |
zhouyl/mellivora | Mellivora/Encryption/CryptServiceProvider.php | CryptServiceProvider.register | public function register()
{
$this->container['crypt'] = function ($container) {
$config = $container['config']->get('security.crypt');
return new Crypt($config->key, $config->cipher, $config->padding);
};
} | php | public function register()
{
$this->container['crypt'] = function ($container) {
$config = $container['config']->get('security.crypt');
return new Crypt($config->key, $config->cipher, $config->padding);
};
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"[",
"'crypt'",
"]",
"=",
"function",
"(",
"$",
"container",
")",
"{",
"$",
"config",
"=",
"$",
"container",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'security.crypt'",
")",
";",
"return",
"new",
"Crypt",
"(",
"$",
"config",
"->",
"key",
",",
"$",
"config",
"->",
"cipher",
",",
"$",
"config",
"->",
"padding",
")",
";",
"}",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Encryption/CryptServiceProvider.php#L14-L21 |
expectation-php/expect | src/matcher/ToEndWith.php | ToEndWith.reportFailed | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' to end with ')
->appendValue($this->pattern);
} | php | public function reportFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' to end with ')
->appendValue($this->pattern);
} | [
"public",
"function",
"reportFailed",
"(",
"FailedMessage",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"appendText",
"(",
"'Expected '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"actual",
")",
"->",
"appendText",
"(",
"' to end with '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"pattern",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToEndWith.php#L62-L68 |
expectation-php/expect | src/matcher/ToEndWith.php | ToEndWith.reportNegativeFailed | public function reportNegativeFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' not to end with ')
->appendValue($this->pattern);
} | php | public function reportNegativeFailed(FailedMessage $message)
{
$message->appendText('Expected ')
->appendValue($this->actual)
->appendText(' not to end with ')
->appendValue($this->pattern);
} | [
"public",
"function",
"reportNegativeFailed",
"(",
"FailedMessage",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"appendText",
"(",
"'Expected '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"actual",
")",
"->",
"appendText",
"(",
"' not to end with '",
")",
"->",
"appendValue",
"(",
"$",
"this",
"->",
"pattern",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToEndWith.php#L73-L79 |
zicht/z | src/Zicht/Tool/Script/Node/Task/ArgNode.php | ArgNode.compile | public function compile(Buffer $buffer)
{
$name = explode('.', $this->name);
$phpName = Util::toPhp($name);
if ($this->conditional) {
if ($this->multiple) {
$buffer->writeln(sprintf('if ($z->isEmpty(%1$s) || array() === $z->get(%1$s)) {', $phpName))->indent(1);
} else {
$buffer->writeln(sprintf('if ($z->isEmpty(%s)) {', $phpName))->indent(1);
}
if (!$this->nodes[0]) {
$buffer->writeln(
sprintf(
'throw new \RuntimeException(\'required variable %s is not defined\');',
join('.', $name)
)
);
}
}
if ($this->nodes[0]) {
$buffer->write('$z->set(')->raw($phpName)->raw(', $z->value(');
if ($this->multiple) {
$buffer->raw('(array)(');
}
$this->nodes[0]->compile($buffer);
if ($this->multiple) {
$buffer->raw(')');
}
$buffer->raw('));')->eol();
}
if ($this->conditional) {
$buffer->indent(-1)->writeln('}');
}
} | php | public function compile(Buffer $buffer)
{
$name = explode('.', $this->name);
$phpName = Util::toPhp($name);
if ($this->conditional) {
if ($this->multiple) {
$buffer->writeln(sprintf('if ($z->isEmpty(%1$s) || array() === $z->get(%1$s)) {', $phpName))->indent(1);
} else {
$buffer->writeln(sprintf('if ($z->isEmpty(%s)) {', $phpName))->indent(1);
}
if (!$this->nodes[0]) {
$buffer->writeln(
sprintf(
'throw new \RuntimeException(\'required variable %s is not defined\');',
join('.', $name)
)
);
}
}
if ($this->nodes[0]) {
$buffer->write('$z->set(')->raw($phpName)->raw(', $z->value(');
if ($this->multiple) {
$buffer->raw('(array)(');
}
$this->nodes[0]->compile($buffer);
if ($this->multiple) {
$buffer->raw(')');
}
$buffer->raw('));')->eol();
}
if ($this->conditional) {
$buffer->indent(-1)->writeln('}');
}
} | [
"public",
"function",
"compile",
"(",
"Buffer",
"$",
"buffer",
")",
"{",
"$",
"name",
"=",
"explode",
"(",
"'.'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"phpName",
"=",
"Util",
"::",
"toPhp",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"conditional",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"multiple",
")",
"{",
"$",
"buffer",
"->",
"writeln",
"(",
"sprintf",
"(",
"'if ($z->isEmpty(%1$s) || array() === $z->get(%1$s)) {'",
",",
"$",
"phpName",
")",
")",
"->",
"indent",
"(",
"1",
")",
";",
"}",
"else",
"{",
"$",
"buffer",
"->",
"writeln",
"(",
"sprintf",
"(",
"'if ($z->isEmpty(%s)) {'",
",",
"$",
"phpName",
")",
")",
"->",
"indent",
"(",
"1",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"nodes",
"[",
"0",
"]",
")",
"{",
"$",
"buffer",
"->",
"writeln",
"(",
"sprintf",
"(",
"'throw new \\RuntimeException(\\'required variable %s is not defined\\');'",
",",
"join",
"(",
"'.'",
",",
"$",
"name",
")",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"nodes",
"[",
"0",
"]",
")",
"{",
"$",
"buffer",
"->",
"write",
"(",
"'$z->set('",
")",
"->",
"raw",
"(",
"$",
"phpName",
")",
"->",
"raw",
"(",
"', $z->value('",
")",
";",
"if",
"(",
"$",
"this",
"->",
"multiple",
")",
"{",
"$",
"buffer",
"->",
"raw",
"(",
"'(array)('",
")",
";",
"}",
"$",
"this",
"->",
"nodes",
"[",
"0",
"]",
"->",
"compile",
"(",
"$",
"buffer",
")",
";",
"if",
"(",
"$",
"this",
"->",
"multiple",
")",
"{",
"$",
"buffer",
"->",
"raw",
"(",
"')'",
")",
";",
"}",
"$",
"buffer",
"->",
"raw",
"(",
"'));'",
")",
"->",
"eol",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"conditional",
")",
"{",
"$",
"buffer",
"->",
"indent",
"(",
"-",
"1",
")",
"->",
"writeln",
"(",
"'}'",
")",
";",
"}",
"}"
] | Compiles the arg node.
@param \Zicht\Tool\Script\Buffer $buffer
@return void | [
"Compiles",
"the",
"arg",
"node",
"."
] | train | https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Node/Task/ArgNode.php#L49-L84 |
heidelpay/PhpDoc | src/phpDocumentor/Command/Project/RunCommand.php | RunCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$parse_command = $this->getApplication()->find('project:parse');
$transform_command = $this->getApplication()->find('project:transform');
$parse_input = new ArrayInput(
array(
'command' => 'project:parse',
'--filename' => $input->getOption('filename'),
'--directory' => $input->getOption('directory'),
'--encoding' => $input->getOption('encoding'),
'--extensions' => $input->getOption('extensions'),
'--ignore' => $input->getOption('ignore'),
'--ignore-tags' => $input->getOption('ignore-tags'),
'--hidden' => $input->getOption('hidden'),
'--ignore-symlinks' => $input->getOption('ignore-symlinks'),
'--markers' => $input->getOption('markers'),
'--title' => $input->getOption('title'),
'--target' => $input->getOption('cache-folder') ?: $input->getOption('target'),
'--force' => $input->getOption('force'),
'--validate' => $input->getOption('validate'),
'--visibility' => $input->getOption('visibility'),
'--defaultpackagename' => $input->getOption('defaultpackagename'),
'--sourcecode' => $input->getOption('sourcecode'),
'--parseprivate' => $input->getOption('parseprivate'),
'--progressbar' => $input->getOption('progressbar'),
'--log' => $input->getOption('log')
),
$this->getDefinition()
);
$return_code = $parse_command->run($parse_input, $output);
if ($return_code !== 0) {
return $return_code;
}
$transform_input = new ArrayInput(
array(
'command' => 'project:transform',
'--source' => $input->getOption('cache-folder') ?: $input->getOption('target'),
'--target' => $input->getOption('target'),
'--template' => $input->getOption('template'),
'--progressbar' => $input->getOption('progressbar'),
'--log' => $input->getOption('log')
)
);
$return_code = $transform_command->run($transform_input, $output);
if ($return_code !== 0) {
return $return_code;
}
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
/** @var ProjectDescriptorBuilder $descriptorBuilder */
$descriptorBuilder = $this->getService('descriptor.builder');
file_put_contents('ast.dump', serialize($descriptorBuilder->getProjectDescriptor()));
}
return 0;
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$parse_command = $this->getApplication()->find('project:parse');
$transform_command = $this->getApplication()->find('project:transform');
$parse_input = new ArrayInput(
array(
'command' => 'project:parse',
'--filename' => $input->getOption('filename'),
'--directory' => $input->getOption('directory'),
'--encoding' => $input->getOption('encoding'),
'--extensions' => $input->getOption('extensions'),
'--ignore' => $input->getOption('ignore'),
'--ignore-tags' => $input->getOption('ignore-tags'),
'--hidden' => $input->getOption('hidden'),
'--ignore-symlinks' => $input->getOption('ignore-symlinks'),
'--markers' => $input->getOption('markers'),
'--title' => $input->getOption('title'),
'--target' => $input->getOption('cache-folder') ?: $input->getOption('target'),
'--force' => $input->getOption('force'),
'--validate' => $input->getOption('validate'),
'--visibility' => $input->getOption('visibility'),
'--defaultpackagename' => $input->getOption('defaultpackagename'),
'--sourcecode' => $input->getOption('sourcecode'),
'--parseprivate' => $input->getOption('parseprivate'),
'--progressbar' => $input->getOption('progressbar'),
'--log' => $input->getOption('log')
),
$this->getDefinition()
);
$return_code = $parse_command->run($parse_input, $output);
if ($return_code !== 0) {
return $return_code;
}
$transform_input = new ArrayInput(
array(
'command' => 'project:transform',
'--source' => $input->getOption('cache-folder') ?: $input->getOption('target'),
'--target' => $input->getOption('target'),
'--template' => $input->getOption('template'),
'--progressbar' => $input->getOption('progressbar'),
'--log' => $input->getOption('log')
)
);
$return_code = $transform_command->run($transform_input, $output);
if ($return_code !== 0) {
return $return_code;
}
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
/** @var ProjectDescriptorBuilder $descriptorBuilder */
$descriptorBuilder = $this->getService('descriptor.builder');
file_put_contents('ast.dump', serialize($descriptorBuilder->getProjectDescriptor()));
}
return 0;
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"parse_command",
"=",
"$",
"this",
"->",
"getApplication",
"(",
")",
"->",
"find",
"(",
"'project:parse'",
")",
";",
"$",
"transform_command",
"=",
"$",
"this",
"->",
"getApplication",
"(",
")",
"->",
"find",
"(",
"'project:transform'",
")",
";",
"$",
"parse_input",
"=",
"new",
"ArrayInput",
"(",
"array",
"(",
"'command'",
"=>",
"'project:parse'",
",",
"'--filename'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'filename'",
")",
",",
"'--directory'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'directory'",
")",
",",
"'--encoding'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'encoding'",
")",
",",
"'--extensions'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'extensions'",
")",
",",
"'--ignore'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'ignore'",
")",
",",
"'--ignore-tags'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'ignore-tags'",
")",
",",
"'--hidden'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'hidden'",
")",
",",
"'--ignore-symlinks'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'ignore-symlinks'",
")",
",",
"'--markers'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'markers'",
")",
",",
"'--title'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'title'",
")",
",",
"'--target'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'cache-folder'",
")",
"?",
":",
"$",
"input",
"->",
"getOption",
"(",
"'target'",
")",
",",
"'--force'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'force'",
")",
",",
"'--validate'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'validate'",
")",
",",
"'--visibility'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'visibility'",
")",
",",
"'--defaultpackagename'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'defaultpackagename'",
")",
",",
"'--sourcecode'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'sourcecode'",
")",
",",
"'--parseprivate'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'parseprivate'",
")",
",",
"'--progressbar'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'progressbar'",
")",
",",
"'--log'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'log'",
")",
")",
",",
"$",
"this",
"->",
"getDefinition",
"(",
")",
")",
";",
"$",
"return_code",
"=",
"$",
"parse_command",
"->",
"run",
"(",
"$",
"parse_input",
",",
"$",
"output",
")",
";",
"if",
"(",
"$",
"return_code",
"!==",
"0",
")",
"{",
"return",
"$",
"return_code",
";",
"}",
"$",
"transform_input",
"=",
"new",
"ArrayInput",
"(",
"array",
"(",
"'command'",
"=>",
"'project:transform'",
",",
"'--source'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'cache-folder'",
")",
"?",
":",
"$",
"input",
"->",
"getOption",
"(",
"'target'",
")",
",",
"'--target'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'target'",
")",
",",
"'--template'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'template'",
")",
",",
"'--progressbar'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'progressbar'",
")",
",",
"'--log'",
"=>",
"$",
"input",
"->",
"getOption",
"(",
"'log'",
")",
")",
")",
";",
"$",
"return_code",
"=",
"$",
"transform_command",
"->",
"run",
"(",
"$",
"transform_input",
",",
"$",
"output",
")",
";",
"if",
"(",
"$",
"return_code",
"!==",
"0",
")",
"{",
"return",
"$",
"return_code",
";",
"}",
"if",
"(",
"$",
"output",
"->",
"getVerbosity",
"(",
")",
"===",
"OutputInterface",
"::",
"VERBOSITY_DEBUG",
")",
"{",
"/** @var ProjectDescriptorBuilder $descriptorBuilder */",
"$",
"descriptorBuilder",
"=",
"$",
"this",
"->",
"getService",
"(",
"'descriptor.builder'",
")",
";",
"file_put_contents",
"(",
"'ast.dump'",
",",
"serialize",
"(",
"$",
"descriptorBuilder",
"->",
"getProjectDescriptor",
"(",
")",
")",
")",
";",
"}",
"return",
"0",
";",
"}"
] | Executes the business logic involved with this command.
@param \Symfony\Component\Console\Input\InputInterface $input
@param \Symfony\Component\Console\Output\OutputInterface $output
@return int | [
"Executes",
"the",
"business",
"logic",
"involved",
"with",
"this",
"command",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Project/RunCommand.php#L229-L287 |
oroinc/OroLayoutComponent | Loader/Driver/YamlDriver.php | YamlDriver.loadResourceGeneratorData | protected function loadResourceGeneratorData($file)
{
$data = Yaml::parse(file_get_contents($file));
$data = isset($data['layout']) ? $data['layout'] : [];
return new GeneratorData($data, $file);
} | php | protected function loadResourceGeneratorData($file)
{
$data = Yaml::parse(file_get_contents($file));
$data = isset($data['layout']) ? $data['layout'] : [];
return new GeneratorData($data, $file);
} | [
"protected",
"function",
"loadResourceGeneratorData",
"(",
"$",
"file",
")",
"{",
"$",
"data",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"$",
"data",
"=",
"isset",
"(",
"$",
"data",
"[",
"'layout'",
"]",
")",
"?",
"$",
"data",
"[",
"'layout'",
"]",
":",
"[",
"]",
";",
"return",
"new",
"GeneratorData",
"(",
"$",
"data",
",",
"$",
"file",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/YamlDriver.php#L28-L34 |
weew/http | src/Weew/Http/HttpResponse.php | HttpResponse.extend | public function extend(IHttpResponse $response) {
$this->setHeaders(clone($response->getHeaders()));
$this->setProtocol($response->getProtocol());
$this->setProtocolVersion($response->getProtocolVersion());
$this->setStatusCode($response->getStatusCode());
$this->setContent($response->getContent());
$this->setCookies(clone($response->getCookies()));
$this->setDefaultContentType();
} | php | public function extend(IHttpResponse $response) {
$this->setHeaders(clone($response->getHeaders()));
$this->setProtocol($response->getProtocol());
$this->setProtocolVersion($response->getProtocolVersion());
$this->setStatusCode($response->getStatusCode());
$this->setContent($response->getContent());
$this->setCookies(clone($response->getCookies()));
$this->setDefaultContentType();
} | [
"public",
"function",
"extend",
"(",
"IHttpResponse",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"setHeaders",
"(",
"clone",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setProtocol",
"(",
"$",
"response",
"->",
"getProtocol",
"(",
")",
")",
";",
"$",
"this",
"->",
"setProtocolVersion",
"(",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
")",
";",
"$",
"this",
"->",
"setStatusCode",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
";",
"$",
"this",
"->",
"setContent",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"this",
"->",
"setCookies",
"(",
"clone",
"(",
"$",
"response",
"->",
"getCookies",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setDefaultContentType",
"(",
")",
";",
"}"
] | Extend current response with another.
@param IHttpResponse $response | [
"Extend",
"current",
"response",
"with",
"another",
"."
] | train | https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpResponse.php#L311-L320 |
raideer/twitch-api | src/Resources/Search.php | Search.searchChannels | public function searchChannels($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
];
return $this->wrapper->request('GET', 'search/channels', ['query' => $this->resolveOptions($params, $defaults)]);
} | php | public function searchChannels($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
];
return $this->wrapper->request('GET', 'search/channels', ['query' => $this->resolveOptions($params, $defaults)]);
} | [
"public",
"function",
"searchChannels",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"urlencode",
"(",
"$",
"query",
")",
",",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'search/channels'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] | Returns a list of channel objects matching the search query.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchchannels
@param string $query Search query
@param array $params Optional parameters
@return array | [
"Returns",
"a",
"list",
"of",
"channel",
"objects",
"matching",
"the",
"search",
"query",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Search.php#L31-L40 |
raideer/twitch-api | src/Resources/Search.php | Search.searchStreams | public function searchStreams($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
'hls' => null,
];
return $this->wrapper->request('GET', 'search/streams', ['query' => $this->resolveOptions($params, $defaults)]);
} | php | public function searchStreams($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
'hls' => null,
];
return $this->wrapper->request('GET', 'search/streams', ['query' => $this->resolveOptions($params, $defaults)]);
} | [
"public",
"function",
"searchStreams",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"urlencode",
"(",
"$",
"query",
")",
",",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"'hls'",
"=>",
"null",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'search/streams'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] | Returns a list of stream objects matching the search query.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchstreams
@param string $query Search query
@param array $params Optional params
@return array | [
"Returns",
"a",
"list",
"of",
"stream",
"objects",
"matching",
"the",
"search",
"query",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Search.php#L53-L63 |
raideer/twitch-api | src/Resources/Search.php | Search.searchGames | public function searchGames($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'type' => 'suggest',
'live' => false,
];
return $this->wrapper->request('GET', 'search/games', ['query' => $this->resolveOptions($params, $defaults)]);
} | php | public function searchGames($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'type' => 'suggest',
'live' => false,
];
return $this->wrapper->request('GET', 'search/games', ['query' => $this->resolveOptions($params, $defaults)]);
} | [
"public",
"function",
"searchGames",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"urlencode",
"(",
"$",
"query",
")",
",",
"'limit'",
"=>",
"25",
",",
"'type'",
"=>",
"'suggest'",
",",
"'live'",
"=>",
"false",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'search/games'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] | Returns a list of game objects matching the search query.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchgames
@param string $query Search query
@param array $params Optional params
@return array | [
"Returns",
"a",
"list",
"of",
"game",
"objects",
"matching",
"the",
"search",
"query",
"."
] | train | https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Search.php#L76-L86 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.setDefault | public function setDefault($name)
{
$name = strtolower($name);
if (!isset($this->drivers[$name])) {
throw new InvalidArgumentException(
"Unregistered cache driver name '$name'"
);
}
$this->default = $name;
return $this;
} | php | public function setDefault($name)
{
$name = strtolower($name);
if (!isset($this->drivers[$name])) {
throw new InvalidArgumentException(
"Unregistered cache driver name '$name'"
);
}
$this->default = $name;
return $this;
} | [
"public",
"function",
"setDefault",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"drivers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unregistered cache driver name '$name'\"",
")",
";",
"}",
"$",
"this",
"->",
"default",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | 设定默认的缓存名称
@param string $name
@throws \Symfony\Component\Cache\Exception\InvalidArgumentException
@return \Mellivora\Cache\Manager | [
"设定默认的缓存名称"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L66-L79 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.setDrivers | public function setDrivers(array $drivers)
{
foreach ($drivers as $name => $config) {
$this->setDriver($name, $config);
}
return $this;
} | php | public function setDrivers(array $drivers)
{
foreach ($drivers as $name => $config) {
$this->setDriver($name, $config);
}
return $this;
} | [
"public",
"function",
"setDrivers",
"(",
"array",
"$",
"drivers",
")",
"{",
"foreach",
"(",
"$",
"drivers",
"as",
"$",
"name",
"=>",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"setDriver",
"(",
"$",
"name",
",",
"$",
"config",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | 批量设定缓存驱动配置
@param array $drivers
@return \Mellivora\Cache\Manager | [
"批量设定缓存驱动配置"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L104-L111 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.setDriver | public function setDriver($name, array $config)
{
if (!isset($config['connector'])) {
$config['connector'] = NullConnector::class;
}
$this->drivers[strtolower($name)] = $config;
return $this;
} | php | public function setDriver($name, array $config)
{
if (!isset($config['connector'])) {
$config['connector'] = NullConnector::class;
}
$this->drivers[strtolower($name)] = $config;
return $this;
} | [
"public",
"function",
"setDriver",
"(",
"$",
"name",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'connector'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'connector'",
"]",
"=",
"NullConnector",
"::",
"class",
";",
"}",
"$",
"this",
"->",
"drivers",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"=",
"$",
"config",
";",
"return",
"$",
"this",
";",
"}"
] | 设定缓存驱动配置
@param string $name
@param array $config
@return \Mellivora\Cache\Manager | [
"设定缓存驱动配置"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L121-L130 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.getConnector | protected function getConnector($name)
{
$config = isset($this->drivers[$name]) ? $this->drivers[$name] : false;
if ($config === false) {
throw new InvalidArgumentException(
"Unregistered cache driver name '$name'"
);
}
if (!isset($this->connectors[$name])) {
if (!is_subclass_of($config['connector'], Connector::class)) {
throw new InvalidArgumentException(
$config['connector'] . ' must implement of ' . Connector::class
);
}
$connector = new $config['connector']($config);
$this->connectors[$name] = $connector;
}
return $this->connectors[$name];
} | php | protected function getConnector($name)
{
$config = isset($this->drivers[$name]) ? $this->drivers[$name] : false;
if ($config === false) {
throw new InvalidArgumentException(
"Unregistered cache driver name '$name'"
);
}
if (!isset($this->connectors[$name])) {
if (!is_subclass_of($config['connector'], Connector::class)) {
throw new InvalidArgumentException(
$config['connector'] . ' must implement of ' . Connector::class
);
}
$connector = new $config['connector']($config);
$this->connectors[$name] = $connector;
}
return $this->connectors[$name];
} | [
"protected",
"function",
"getConnector",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"isset",
"(",
"$",
"this",
"->",
"drivers",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"drivers",
"[",
"$",
"name",
"]",
":",
"false",
";",
"if",
"(",
"$",
"config",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unregistered cache driver name '$name'\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"config",
"[",
"'connector'",
"]",
",",
"Connector",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"config",
"[",
"'connector'",
"]",
".",
"' must implement of '",
".",
"Connector",
"::",
"class",
")",
";",
"}",
"$",
"connector",
"=",
"new",
"$",
"config",
"[",
"'connector'",
"]",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
"=",
"$",
"connector",
";",
"}",
"return",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
";",
"}"
] | 根据名称获取缓存构造器
@param string $name
@throws \Symfony\Component\Cache\Exception\InvalidArgumentException
@return \Mellivora\Cache\Connector | [
"根据名称获取缓存构造器"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L141-L164 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.getCache | public function getCache($name)
{
$cache = $this->getConnector($name)->getCacheAdapter();
if ($this->logger instanceof LoggerInterface) {
$cache->setLogger($this->logger);
}
return $cache;
} | php | public function getCache($name)
{
$cache = $this->getConnector($name)->getCacheAdapter();
if ($this->logger instanceof LoggerInterface) {
$cache->setLogger($this->logger);
}
return $cache;
} | [
"public",
"function",
"getCache",
"(",
"$",
"name",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"getConnector",
"(",
"$",
"name",
")",
"->",
"getCacheAdapter",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
"instanceof",
"LoggerInterface",
")",
"{",
"$",
"cache",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"cache",
";",
"}"
] | 获取 psr-6 标准 cache 适配器
@param string $name
@return \Symfony\Component\Cache\Adapter\AbstractAdapter | [
"获取",
"psr",
"-",
"6",
"标准",
"cache",
"适配器"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L173-L182 |
zhouyl/mellivora | Mellivora/Cache/Manager.php | Manager.getSimpleCache | public function getSimpleCache($name)
{
$cache = $this->getConnector($name)->getSimpleCacheAdapter();
if ($this->logger instanceof LoggerInterface) {
$cache->setLogger($this->logger);
}
return $cache;
} | php | public function getSimpleCache($name)
{
$cache = $this->getConnector($name)->getSimpleCacheAdapter();
if ($this->logger instanceof LoggerInterface) {
$cache->setLogger($this->logger);
}
return $cache;
} | [
"public",
"function",
"getSimpleCache",
"(",
"$",
"name",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"getConnector",
"(",
"$",
"name",
")",
"->",
"getSimpleCacheAdapter",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
"instanceof",
"LoggerInterface",
")",
"{",
"$",
"cache",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"cache",
";",
"}"
] | 获取 psr-16 标准 simple-cache 适配器
@param string $name
@return \Symfony\Component\Cache\Simple\AbstractCache | [
"获取",
"psr",
"-",
"16",
"标准",
"simple",
"-",
"cache",
"适配器"
] | train | https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Cache/Manager.php#L191-L200 |
php-lug/lug | src/Component/Grid/View/GridView.php | GridView.getDataSource | public function getDataSource(array $options = [])
{
if ($this->definition !== null) {
$options = array_merge($this->definition->getOptions(), $options);
}
ksort($options);
return isset($this->cache[$hash = sha1(json_encode($options))])
? $this->cache[$hash]
: $this->cache[$hash] = $this->dataSourceBuilder->createDataSource($options);
} | php | public function getDataSource(array $options = [])
{
if ($this->definition !== null) {
$options = array_merge($this->definition->getOptions(), $options);
}
ksort($options);
return isset($this->cache[$hash = sha1(json_encode($options))])
? $this->cache[$hash]
: $this->cache[$hash] = $this->dataSourceBuilder->createDataSource($options);
} | [
"public",
"function",
"getDataSource",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"definition",
"!==",
"null",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"definition",
"->",
"getOptions",
"(",
")",
",",
"$",
"options",
")",
";",
"}",
"ksort",
"(",
"$",
"options",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"=",
"sha1",
"(",
"json_encode",
"(",
"$",
"options",
")",
")",
"]",
")",
"?",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"hash",
"]",
"=",
"$",
"this",
"->",
"dataSourceBuilder",
"->",
"createDataSource",
"(",
"$",
"options",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/View/GridView.php#L59-L70 |
ekuiter/feature-php | FeaturePhp/Exporter/ZipExporter.php | ZipExporter.open | private function open() {
if (file_exists($this->target) && !unlink($this->target))
throw new ZipExporterException("could not remove existing zip archive at \"$this->target\"");
$zip = new \ZipArchive();
if (!$zip->open($this->target, \ZipArchive::CREATE))
throw new ZipExporterException("could not create zip archive at \"$this->target\"");
return $zip;
} | php | private function open() {
if (file_exists($this->target) && !unlink($this->target))
throw new ZipExporterException("could not remove existing zip archive at \"$this->target\"");
$zip = new \ZipArchive();
if (!$zip->open($this->target, \ZipArchive::CREATE))
throw new ZipExporterException("could not create zip archive at \"$this->target\"");
return $zip;
} | [
"private",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"target",
")",
"&&",
"!",
"unlink",
"(",
"$",
"this",
"->",
"target",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not remove existing zip archive at \\\"$this->target\\\"\"",
")",
";",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"!",
"$",
"zip",
"->",
"open",
"(",
"$",
"this",
"->",
"target",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not create zip archive at \\\"$this->target\\\"\"",
")",
";",
"return",
"$",
"zip",
";",
"}"
] | Opens and returns the targeted ZIP archive.
@return \ZipArchive | [
"Opens",
"and",
"returns",
"the",
"targeted",
"ZIP",
"archive",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/ZipExporter.php#L41-L49 |
ekuiter/feature-php | FeaturePhp/Exporter/ZipExporter.php | ZipExporter.export | public function export($product) {
$productLineName = $product->getProductLine()->getName();
$files = $product->generateFiles();
$zip = $this->open();
if (count($files) === 0)
$files[] = new fphp\File\TextFile("NOTICE", "No files were generated.");
foreach ($files as $file)
if (!$file->getContent()->addToZip($zip, fphp\Helper\Path::join($productLineName, $file->getTarget())))
throw new ZipExporterException("could not add file to zip archive at \"$this->target\"");
$this->close($zip);
} | php | public function export($product) {
$productLineName = $product->getProductLine()->getName();
$files = $product->generateFiles();
$zip = $this->open();
if (count($files) === 0)
$files[] = new fphp\File\TextFile("NOTICE", "No files were generated.");
foreach ($files as $file)
if (!$file->getContent()->addToZip($zip, fphp\Helper\Path::join($productLineName, $file->getTarget())))
throw new ZipExporterException("could not add file to zip archive at \"$this->target\"");
$this->close($zip);
} | [
"public",
"function",
"export",
"(",
"$",
"product",
")",
"{",
"$",
"productLineName",
"=",
"$",
"product",
"->",
"getProductLine",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"files",
"=",
"$",
"product",
"->",
"generateFiles",
"(",
")",
";",
"$",
"zip",
"=",
"$",
"this",
"->",
"open",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"files",
")",
"===",
"0",
")",
"$",
"files",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"File",
"\\",
"TextFile",
"(",
"\"NOTICE\"",
",",
"\"No files were generated.\"",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"if",
"(",
"!",
"$",
"file",
"->",
"getContent",
"(",
")",
"->",
"addToZip",
"(",
"$",
"zip",
",",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"$",
"productLineName",
",",
"$",
"file",
"->",
"getTarget",
"(",
")",
")",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not add file to zip archive at \\\"$this->target\\\"\"",
")",
";",
"$",
"this",
"->",
"close",
"(",
"$",
"zip",
")",
";",
"}"
] | Exports a product as a ZIP archive.
Every generated file is added to the archive at its target path. If there are no files,
a NOTICE file is generated because \ZipArchive does not support saving an empty ZIP archive.
The archive's root directory has the product line's name.
@param \FeaturePhp\ProductLine\Product $product | [
"Exports",
"a",
"product",
"as",
"a",
"ZIP",
"archive",
".",
"Every",
"generated",
"file",
"is",
"added",
"to",
"the",
"archive",
"at",
"its",
"target",
"path",
".",
"If",
"there",
"are",
"no",
"files",
"a",
"NOTICE",
"file",
"is",
"generated",
"because",
"\\",
"ZipArchive",
"does",
"not",
"support",
"saving",
"an",
"empty",
"ZIP",
"archive",
".",
"The",
"archive",
"s",
"root",
"directory",
"has",
"the",
"product",
"line",
"s",
"name",
"."
] | train | https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/ZipExporter.php#L67-L80 |
frdl/webfan | .ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php | SourceLoader.addPsr0 | public function addPsr0($prefix, $base_dir, $prepend = false)
{
$prefix = trim($prefix, '\\') . '\\';
$base_dir = rtrim($base_dir, self::DS) . self::DS;
if(isset($this->autoloadersPsr0[$prefix]) === false) {
$this->autoloadersPsr0[$prefix] = array();
}
if($prepend) {
array_unshift($this->autoloadersPsr0[$prefix], $base_dir);
} else {
array_push($this->autoloadersPsr0[$prefix], $base_dir);
}
return $this;
} | php | public function addPsr0($prefix, $base_dir, $prepend = false)
{
$prefix = trim($prefix, '\\') . '\\';
$base_dir = rtrim($base_dir, self::DS) . self::DS;
if(isset($this->autoloadersPsr0[$prefix]) === false) {
$this->autoloadersPsr0[$prefix] = array();
}
if($prepend) {
array_unshift($this->autoloadersPsr0[$prefix], $base_dir);
} else {
array_push($this->autoloadersPsr0[$prefix], $base_dir);
}
return $this;
} | [
"public",
"function",
"addPsr0",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"$",
"prefix",
"=",
"trim",
"(",
"$",
"prefix",
",",
"'\\\\'",
")",
".",
"'\\\\'",
";",
"$",
"base_dir",
"=",
"rtrim",
"(",
"$",
"base_dir",
",",
"self",
"::",
"DS",
")",
".",
"self",
"::",
"DS",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
",",
"$",
"base_dir",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
",",
"$",
"base_dir",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Psr-0 | [
"Psr",
"-",
"0"
] | train | https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php#L344-L359 |
frdl/webfan | .ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php | SourceLoader.addNamespace | public function addNamespace($prefix, $base_dir, $prepend = false)
{
return $this->addPsr4($prefix, $base_dir, $prepend);
} | php | public function addNamespace($prefix, $base_dir, $prepend = false)
{
return $this->addPsr4($prefix, $base_dir, $prepend);
} | [
"public",
"function",
"addNamespace",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"addPsr4",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
")",
";",
"}"
] | Psr-4 | [
"Psr",
"-",
"4"
] | train | https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php#L364-L367 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php | TraitAssembler.create | public function create($data)
{
$traitDescriptor = new TraitDescriptor();
$traitDescriptor->setFullyQualifiedStructuralElementName($data->getName());
$traitDescriptor->setName($data->getShortName());
$traitDescriptor->setLine($data->getLinenumber());
$traitDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
$traitDescriptor->setNamespace(
'\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
);
$this->assembleDocBlock($data->getDocBlock(), $traitDescriptor);
$this->addProperties($data->getProperties(), $traitDescriptor);
$this->addMethods($data->getMethods(), $traitDescriptor);
return $traitDescriptor;
} | php | public function create($data)
{
$traitDescriptor = new TraitDescriptor();
$traitDescriptor->setFullyQualifiedStructuralElementName($data->getName());
$traitDescriptor->setName($data->getShortName());
$traitDescriptor->setLine($data->getLinenumber());
$traitDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
$traitDescriptor->setNamespace(
'\\' . (strtolower($data->getNamespace()) == 'global' ? '' :$data->getNamespace())
);
$this->assembleDocBlock($data->getDocBlock(), $traitDescriptor);
$this->addProperties($data->getProperties(), $traitDescriptor);
$this->addMethods($data->getMethods(), $traitDescriptor);
return $traitDescriptor;
} | [
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"traitDescriptor",
"=",
"new",
"TraitDescriptor",
"(",
")",
";",
"$",
"traitDescriptor",
"->",
"setFullyQualifiedStructuralElementName",
"(",
"$",
"data",
"->",
"getName",
"(",
")",
")",
";",
"$",
"traitDescriptor",
"->",
"setName",
"(",
"$",
"data",
"->",
"getShortName",
"(",
")",
")",
";",
"$",
"traitDescriptor",
"->",
"setLine",
"(",
"$",
"data",
"->",
"getLinenumber",
"(",
")",
")",
";",
"$",
"traitDescriptor",
"->",
"setPackage",
"(",
"$",
"this",
"->",
"extractPackageFromDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
")",
"?",
":",
"''",
")",
";",
"// Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself",
"$",
"traitDescriptor",
"->",
"setNamespace",
"(",
"'\\\\'",
".",
"(",
"strtolower",
"(",
"$",
"data",
"->",
"getNamespace",
"(",
")",
")",
"==",
"'global'",
"?",
"''",
":",
"$",
"data",
"->",
"getNamespace",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"assembleDocBlock",
"(",
"$",
"data",
"->",
"getDocBlock",
"(",
")",
",",
"$",
"traitDescriptor",
")",
";",
"$",
"this",
"->",
"addProperties",
"(",
"$",
"data",
"->",
"getProperties",
"(",
")",
",",
"$",
"traitDescriptor",
")",
";",
"$",
"this",
"->",
"addMethods",
"(",
"$",
"data",
"->",
"getMethods",
"(",
")",
",",
"$",
"traitDescriptor",
")",
";",
"return",
"$",
"traitDescriptor",
";",
"}"
] | Creates a Descriptor from the provided data.
@param TraitReflector $data
@return TraitDescriptor | [
"Creates",
"a",
"Descriptor",
"from",
"the",
"provided",
"data",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L31-L51 |
heidelpay/PhpDoc | src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php | TraitAssembler.addMethods | protected function addMethods($methods, $traitDescriptor)
{
foreach ($methods as $method) {
$methodDescriptor = $this->getBuilder()->buildDescriptor($method);
if ($methodDescriptor) {
$methodDescriptor->setParent($traitDescriptor);
$traitDescriptor->getMethods()->set($methodDescriptor->getName(), $methodDescriptor);
}
}
} | php | protected function addMethods($methods, $traitDescriptor)
{
foreach ($methods as $method) {
$methodDescriptor = $this->getBuilder()->buildDescriptor($method);
if ($methodDescriptor) {
$methodDescriptor->setParent($traitDescriptor);
$traitDescriptor->getMethods()->set($methodDescriptor->getName(), $methodDescriptor);
}
}
} | [
"protected",
"function",
"addMethods",
"(",
"$",
"methods",
",",
"$",
"traitDescriptor",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"methodDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"methodDescriptor",
")",
"{",
"$",
"methodDescriptor",
"->",
"setParent",
"(",
"$",
"traitDescriptor",
")",
";",
"$",
"traitDescriptor",
"->",
"getMethods",
"(",
")",
"->",
"set",
"(",
"$",
"methodDescriptor",
"->",
"getName",
"(",
")",
",",
"$",
"methodDescriptor",
")",
";",
"}",
"}",
"}"
] | Registers the child methods with the generated Trait Descriptor.
@param MethodReflector[] $methods
@param TraitDescriptor $traitDescriptor
@return void | [
"Registers",
"the",
"child",
"methods",
"with",
"the",
"generated",
"Trait",
"Descriptor",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L80-L89 |
mothership-ec/composer | src/Composer/Command/InitCommand.php | InitCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$whitelist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
$options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
if (isset($options['author'])) {
$options['authors'] = $this->formatAuthors($options['author']);
unset($options['author']);
}
if (isset($options['stability'])) {
$options['minimum-stability'] = $options['stability'];
unset($options['stability']);
}
$options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
if (array() === $options['require']) {
$options['require'] = new \stdClass;
}
if (isset($options['require-dev'])) {
$options['require-dev'] = $this->formatRequirements($options['require-dev']);
if (array() === $options['require-dev']) {
$options['require-dev'] = new \stdClass;
}
}
$file = new JsonFile('composer.json');
$json = $file->encode($options);
if ($input->isInteractive()) {
$this->getIO()->writeError(array('', $json, ''));
if (!$this->getIO()->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ', true)) {
$this->getIO()->writeError('<error>Command aborted</error>');
return 1;
}
}
$file->write($options);
if ($input->isInteractive() && is_dir('.git')) {
$ignoreFile = realpath('.gitignore');
if (false === $ignoreFile) {
$ignoreFile = realpath('.') . '/.gitignore';
}
if (!$this->hasVendorIgnore($ignoreFile)) {
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
if ($this->getIO()->askConfirmation($question, true)) {
$this->addVendorIgnore($ignoreFile);
}
}
}
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$whitelist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
$options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
if (isset($options['author'])) {
$options['authors'] = $this->formatAuthors($options['author']);
unset($options['author']);
}
if (isset($options['stability'])) {
$options['minimum-stability'] = $options['stability'];
unset($options['stability']);
}
$options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
if (array() === $options['require']) {
$options['require'] = new \stdClass;
}
if (isset($options['require-dev'])) {
$options['require-dev'] = $this->formatRequirements($options['require-dev']);
if (array() === $options['require-dev']) {
$options['require-dev'] = new \stdClass;
}
}
$file = new JsonFile('composer.json');
$json = $file->encode($options);
if ($input->isInteractive()) {
$this->getIO()->writeError(array('', $json, ''));
if (!$this->getIO()->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ', true)) {
$this->getIO()->writeError('<error>Command aborted</error>');
return 1;
}
}
$file->write($options);
if ($input->isInteractive() && is_dir('.git')) {
$ignoreFile = realpath('.gitignore');
if (false === $ignoreFile) {
$ignoreFile = realpath('.') . '/.gitignore';
}
if (!$this->hasVendorIgnore($ignoreFile)) {
$question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
if ($this->getIO()->askConfirmation($question, true)) {
$this->addVendorIgnore($ignoreFile);
}
}
}
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"whitelist",
"=",
"array",
"(",
"'name'",
",",
"'description'",
",",
"'author'",
",",
"'type'",
",",
"'homepage'",
",",
"'require'",
",",
"'require-dev'",
",",
"'stability'",
",",
"'license'",
")",
";",
"$",
"options",
"=",
"array_filter",
"(",
"array_intersect_key",
"(",
"$",
"input",
"->",
"getOptions",
"(",
")",
",",
"array_flip",
"(",
"$",
"whitelist",
")",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'author'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'authors'",
"]",
"=",
"$",
"this",
"->",
"formatAuthors",
"(",
"$",
"options",
"[",
"'author'",
"]",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'author'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'stability'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'minimum-stability'",
"]",
"=",
"$",
"options",
"[",
"'stability'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'stability'",
"]",
")",
";",
"}",
"$",
"options",
"[",
"'require'",
"]",
"=",
"isset",
"(",
"$",
"options",
"[",
"'require'",
"]",
")",
"?",
"$",
"this",
"->",
"formatRequirements",
"(",
"$",
"options",
"[",
"'require'",
"]",
")",
":",
"new",
"\\",
"stdClass",
";",
"if",
"(",
"array",
"(",
")",
"===",
"$",
"options",
"[",
"'require'",
"]",
")",
"{",
"$",
"options",
"[",
"'require'",
"]",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'require-dev'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'require-dev'",
"]",
"=",
"$",
"this",
"->",
"formatRequirements",
"(",
"$",
"options",
"[",
"'require-dev'",
"]",
")",
";",
"if",
"(",
"array",
"(",
")",
"===",
"$",
"options",
"[",
"'require-dev'",
"]",
")",
"{",
"$",
"options",
"[",
"'require-dev'",
"]",
"=",
"new",
"\\",
"stdClass",
";",
"}",
"}",
"$",
"file",
"=",
"new",
"JsonFile",
"(",
"'composer.json'",
")",
";",
"$",
"json",
"=",
"$",
"file",
"->",
"encode",
"(",
"$",
"options",
")",
";",
"if",
"(",
"$",
"input",
"->",
"isInteractive",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"array",
"(",
"''",
",",
"$",
"json",
",",
"''",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askConfirmation",
"(",
"'Do you confirm generation [<comment>yes</comment>]? '",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"'<error>Command aborted</error>'",
")",
";",
"return",
"1",
";",
"}",
"}",
"$",
"file",
"->",
"write",
"(",
"$",
"options",
")",
";",
"if",
"(",
"$",
"input",
"->",
"isInteractive",
"(",
")",
"&&",
"is_dir",
"(",
"'.git'",
")",
")",
"{",
"$",
"ignoreFile",
"=",
"realpath",
"(",
"'.gitignore'",
")",
";",
"if",
"(",
"false",
"===",
"$",
"ignoreFile",
")",
"{",
"$",
"ignoreFile",
"=",
"realpath",
"(",
"'.'",
")",
".",
"'/.gitignore'",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVendorIgnore",
"(",
"$",
"ignoreFile",
")",
")",
"{",
"$",
"question",
"=",
"'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? '",
";",
"if",
"(",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askConfirmation",
"(",
"$",
"question",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"addVendorIgnore",
"(",
"$",
"ignoreFile",
")",
";",
"}",
"}",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/InitCommand.php#L79-L136 |
mothership-ec/composer | src/Composer/Command/InitCommand.php | InitCommand.interact | protected function interact(InputInterface $input, OutputInterface $output)
{
$git = $this->getGitConfig();
$formatter = $this->getHelperSet()->get('formatter');
$this->getIO()->writeError(array(
'',
$formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
''
));
// namespace
$this->getIO()->writeError(array(
'',
'This command will guide you through creating your composer.json config.',
'',
));
$cwd = realpath(".");
if (!$name = $input->getOption('name')) {
$name = basename($cwd);
$name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
$name = strtolower($name);
if (isset($git['github.user'])) {
$name = $git['github.user'] . '/' . $name;
} elseif (!empty($_SERVER['USERNAME'])) {
$name = $_SERVER['USERNAME'] . '/' . $name;
} elseif (get_current_user()) {
$name = get_current_user() . '/' . $name;
} else {
// package names must be in the format foo/bar
$name = $name . '/' . $name;
}
} else {
if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $name)) {
throw new \InvalidArgumentException(
'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
);
}
}
$name = $this->getIO()->askAndValidate(
'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
function ($value) use ($name) {
if (null === $value) {
return $name;
}
if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $value)) {
throw new \InvalidArgumentException(
'The package name '.$value.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
);
}
return $value;
},
null,
$name
);
$input->setOption('name', $name);
$description = $input->getOption('description') ?: false;
$description = $this->getIO()->ask(
'Description [<comment>'.$description.'</comment>]: ',
$description
);
$input->setOption('description', $description);
if (null === $author = $input->getOption('author')) {
if (isset($git['user.name']) && isset($git['user.email'])) {
$author = sprintf('%s <%s>', $git['user.name'], $git['user.email']);
}
}
$self = $this;
$author = $this->getIO()->askAndValidate(
'Author [<comment>'.$author.'</comment>]: ',
function ($value) use ($self, $author) {
$value = $value ?: $author;
$author = $self->parseAuthorString($value);
return sprintf('%s <%s>', $author['name'], $author['email']);
},
null,
$author
);
$input->setOption('author', $author);
$minimumStability = $input->getOption('stability') ?: null;
$minimumStability = $this->getIO()->askAndValidate(
'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
function ($value) use ($self, $minimumStability) {
if (null === $value) {
return $minimumStability;
}
if (!isset(BasePackage::$stabilities[$value])) {
throw new \InvalidArgumentException(
'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
implode(', ', array_keys(BasePackage::$stabilities))
);
}
return $value;
},
null,
$minimumStability
);
$input->setOption('stability', $minimumStability);
$type = $input->getOption('type') ?: false;
$type = $this->getIO()->ask(
'Package Type [<comment>'.$type.'</comment>]: ',
$type
);
$input->setOption('type', $type);
$license = $input->getOption('license') ?: false;
$license = $this->getIO()->ask(
'License [<comment>'.$license.'</comment>]: ',
$license
);
$input->setOption('license', $license);
$this->getIO()->writeError(array('', 'Define your dependencies.', ''));
$question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
$requirements = array();
if ($this->getIO()->askConfirmation($question, true)) {
$requirements = $this->determineRequirements($input, $output, $input->getOption('require'));
}
$input->setOption('require', $requirements);
$question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
$devRequirements = array();
if ($this->getIO()->askConfirmation($question, true)) {
$devRequirements = $this->determineRequirements($input, $output, $input->getOption('require-dev'));
}
$input->setOption('require-dev', $devRequirements);
} | php | protected function interact(InputInterface $input, OutputInterface $output)
{
$git = $this->getGitConfig();
$formatter = $this->getHelperSet()->get('formatter');
$this->getIO()->writeError(array(
'',
$formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
''
));
// namespace
$this->getIO()->writeError(array(
'',
'This command will guide you through creating your composer.json config.',
'',
));
$cwd = realpath(".");
if (!$name = $input->getOption('name')) {
$name = basename($cwd);
$name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
$name = strtolower($name);
if (isset($git['github.user'])) {
$name = $git['github.user'] . '/' . $name;
} elseif (!empty($_SERVER['USERNAME'])) {
$name = $_SERVER['USERNAME'] . '/' . $name;
} elseif (get_current_user()) {
$name = get_current_user() . '/' . $name;
} else {
// package names must be in the format foo/bar
$name = $name . '/' . $name;
}
} else {
if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $name)) {
throw new \InvalidArgumentException(
'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
);
}
}
$name = $this->getIO()->askAndValidate(
'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
function ($value) use ($name) {
if (null === $value) {
return $name;
}
if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}', $value)) {
throw new \InvalidArgumentException(
'The package name '.$value.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
);
}
return $value;
},
null,
$name
);
$input->setOption('name', $name);
$description = $input->getOption('description') ?: false;
$description = $this->getIO()->ask(
'Description [<comment>'.$description.'</comment>]: ',
$description
);
$input->setOption('description', $description);
if (null === $author = $input->getOption('author')) {
if (isset($git['user.name']) && isset($git['user.email'])) {
$author = sprintf('%s <%s>', $git['user.name'], $git['user.email']);
}
}
$self = $this;
$author = $this->getIO()->askAndValidate(
'Author [<comment>'.$author.'</comment>]: ',
function ($value) use ($self, $author) {
$value = $value ?: $author;
$author = $self->parseAuthorString($value);
return sprintf('%s <%s>', $author['name'], $author['email']);
},
null,
$author
);
$input->setOption('author', $author);
$minimumStability = $input->getOption('stability') ?: null;
$minimumStability = $this->getIO()->askAndValidate(
'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
function ($value) use ($self, $minimumStability) {
if (null === $value) {
return $minimumStability;
}
if (!isset(BasePackage::$stabilities[$value])) {
throw new \InvalidArgumentException(
'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
implode(', ', array_keys(BasePackage::$stabilities))
);
}
return $value;
},
null,
$minimumStability
);
$input->setOption('stability', $minimumStability);
$type = $input->getOption('type') ?: false;
$type = $this->getIO()->ask(
'Package Type [<comment>'.$type.'</comment>]: ',
$type
);
$input->setOption('type', $type);
$license = $input->getOption('license') ?: false;
$license = $this->getIO()->ask(
'License [<comment>'.$license.'</comment>]: ',
$license
);
$input->setOption('license', $license);
$this->getIO()->writeError(array('', 'Define your dependencies.', ''));
$question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
$requirements = array();
if ($this->getIO()->askConfirmation($question, true)) {
$requirements = $this->determineRequirements($input, $output, $input->getOption('require'));
}
$input->setOption('require', $requirements);
$question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
$devRequirements = array();
if ($this->getIO()->askConfirmation($question, true)) {
$devRequirements = $this->determineRequirements($input, $output, $input->getOption('require-dev'));
}
$input->setOption('require-dev', $devRequirements);
} | [
"protected",
"function",
"interact",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"git",
"=",
"$",
"this",
"->",
"getGitConfig",
"(",
")",
";",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getHelperSet",
"(",
")",
"->",
"get",
"(",
"'formatter'",
")",
";",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"array",
"(",
"''",
",",
"$",
"formatter",
"->",
"formatBlock",
"(",
"'Welcome to the Composer config generator'",
",",
"'bg=blue;fg=white'",
",",
"true",
")",
",",
"''",
")",
")",
";",
"// namespace",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"array",
"(",
"''",
",",
"'This command will guide you through creating your composer.json config.'",
",",
"''",
",",
")",
")",
";",
"$",
"cwd",
"=",
"realpath",
"(",
"\".\"",
")",
";",
"if",
"(",
"!",
"$",
"name",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'name'",
")",
")",
"{",
"$",
"name",
"=",
"basename",
"(",
"$",
"cwd",
")",
";",
"$",
"name",
"=",
"preg_replace",
"(",
"'{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}'",
",",
"'\\\\1\\\\3-\\\\2\\\\4'",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"git",
"[",
"'github.user'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"git",
"[",
"'github.user'",
"]",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'USERNAME'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"_SERVER",
"[",
"'USERNAME'",
"]",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"elseif",
"(",
"get_current_user",
"(",
")",
")",
"{",
"$",
"name",
"=",
"get_current_user",
"(",
")",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"else",
"{",
"// package names must be in the format foo/bar",
"$",
"name",
"=",
"$",
"name",
".",
"'/'",
".",
"$",
"name",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'{^[a-z0-9_.-]+/[a-z0-9_.-]+$}'",
",",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The package name '",
".",
"$",
"name",
".",
"' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'",
")",
";",
"}",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askAndValidate",
"(",
"'Package name (<vendor>/<name>) [<comment>'",
".",
"$",
"name",
".",
"'</comment>]: '",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"name",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'{^[a-z0-9_.-]+/[a-z0-9_.-]+$}'",
",",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The package name '",
".",
"$",
"value",
".",
"' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
",",
"null",
",",
"$",
"name",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"$",
"description",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'description'",
")",
"?",
":",
"false",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"ask",
"(",
"'Description [<comment>'",
".",
"$",
"description",
".",
"'</comment>]: '",
",",
"$",
"description",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'description'",
",",
"$",
"description",
")",
";",
"if",
"(",
"null",
"===",
"$",
"author",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'author'",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"git",
"[",
"'user.name'",
"]",
")",
"&&",
"isset",
"(",
"$",
"git",
"[",
"'user.email'",
"]",
")",
")",
"{",
"$",
"author",
"=",
"sprintf",
"(",
"'%s <%s>'",
",",
"$",
"git",
"[",
"'user.name'",
"]",
",",
"$",
"git",
"[",
"'user.email'",
"]",
")",
";",
"}",
"}",
"$",
"self",
"=",
"$",
"this",
";",
"$",
"author",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askAndValidate",
"(",
"'Author [<comment>'",
".",
"$",
"author",
".",
"'</comment>]: '",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"self",
",",
"$",
"author",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"?",
":",
"$",
"author",
";",
"$",
"author",
"=",
"$",
"self",
"->",
"parseAuthorString",
"(",
"$",
"value",
")",
";",
"return",
"sprintf",
"(",
"'%s <%s>'",
",",
"$",
"author",
"[",
"'name'",
"]",
",",
"$",
"author",
"[",
"'email'",
"]",
")",
";",
"}",
",",
"null",
",",
"$",
"author",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'author'",
",",
"$",
"author",
")",
";",
"$",
"minimumStability",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'stability'",
")",
"?",
":",
"null",
";",
"$",
"minimumStability",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askAndValidate",
"(",
"'Minimum Stability [<comment>'",
".",
"$",
"minimumStability",
".",
"'</comment>]: '",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"self",
",",
"$",
"minimumStability",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"minimumStability",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"BasePackage",
"::",
"$",
"stabilities",
"[",
"$",
"value",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid minimum stability \"'",
".",
"$",
"value",
".",
"'\". Must be empty or one of: '",
".",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"BasePackage",
"::",
"$",
"stabilities",
")",
")",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
",",
"null",
",",
"$",
"minimumStability",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'stability'",
",",
"$",
"minimumStability",
")",
";",
"$",
"type",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'type'",
")",
"?",
":",
"false",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"ask",
"(",
"'Package Type [<comment>'",
".",
"$",
"type",
".",
"'</comment>]: '",
",",
"$",
"type",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'type'",
",",
"$",
"type",
")",
";",
"$",
"license",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'license'",
")",
"?",
":",
"false",
";",
"$",
"license",
"=",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"ask",
"(",
"'License [<comment>'",
".",
"$",
"license",
".",
"'</comment>]: '",
",",
"$",
"license",
")",
";",
"$",
"input",
"->",
"setOption",
"(",
"'license'",
",",
"$",
"license",
")",
";",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"writeError",
"(",
"array",
"(",
"''",
",",
"'Define your dependencies.'",
",",
"''",
")",
")",
";",
"$",
"question",
"=",
"'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? '",
";",
"$",
"requirements",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askConfirmation",
"(",
"$",
"question",
",",
"true",
")",
")",
"{",
"$",
"requirements",
"=",
"$",
"this",
"->",
"determineRequirements",
"(",
"$",
"input",
",",
"$",
"output",
",",
"$",
"input",
"->",
"getOption",
"(",
"'require'",
")",
")",
";",
"}",
"$",
"input",
"->",
"setOption",
"(",
"'require'",
",",
"$",
"requirements",
")",
";",
"$",
"question",
"=",
"'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? '",
";",
"$",
"devRequirements",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getIO",
"(",
")",
"->",
"askConfirmation",
"(",
"$",
"question",
",",
"true",
")",
")",
"{",
"$",
"devRequirements",
"=",
"$",
"this",
"->",
"determineRequirements",
"(",
"$",
"input",
",",
"$",
"output",
",",
"$",
"input",
"->",
"getOption",
"(",
"'require-dev'",
")",
")",
";",
"}",
"$",
"input",
"->",
"setOption",
"(",
"'require-dev'",
",",
"$",
"devRequirements",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/InitCommand.php#L141-L282 |
mothership-ec/composer | src/Composer/Command/InitCommand.php | InitCommand.findBestVersionForPackage | private function findBestVersionForPackage(InputInterface $input, $name)
{
// find the latest version allowed in this pool
$versionSelector = new VersionSelector($this->getPool($input));
$package = $versionSelector->findBestCandidate($name);
if (!$package) {
throw new \InvalidArgumentException(sprintf(
'Could not find package %s at any version for your minimum-stability (%s). Check the package spelling or your minimum-stability',
$name,
$this->getMinimumStability($input)
));
}
return $versionSelector->findRecommendedRequireVersion($package);
} | php | private function findBestVersionForPackage(InputInterface $input, $name)
{
// find the latest version allowed in this pool
$versionSelector = new VersionSelector($this->getPool($input));
$package = $versionSelector->findBestCandidate($name);
if (!$package) {
throw new \InvalidArgumentException(sprintf(
'Could not find package %s at any version for your minimum-stability (%s). Check the package spelling or your minimum-stability',
$name,
$this->getMinimumStability($input)
));
}
return $versionSelector->findRecommendedRequireVersion($package);
} | [
"private",
"function",
"findBestVersionForPackage",
"(",
"InputInterface",
"$",
"input",
",",
"$",
"name",
")",
"{",
"// find the latest version allowed in this pool",
"$",
"versionSelector",
"=",
"new",
"VersionSelector",
"(",
"$",
"this",
"->",
"getPool",
"(",
"$",
"input",
")",
")",
";",
"$",
"package",
"=",
"$",
"versionSelector",
"->",
"findBestCandidate",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"package",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Could not find package %s at any version for your minimum-stability (%s). Check the package spelling or your minimum-stability'",
",",
"$",
"name",
",",
"$",
"this",
"->",
"getMinimumStability",
"(",
"$",
"input",
")",
")",
")",
";",
"}",
"return",
"$",
"versionSelector",
"->",
"findRecommendedRequireVersion",
"(",
"$",
"package",
")",
";",
"}"
] | Given a package name, this determines the best version to use in the require key.
This returns a version with the ~ operator prefixed when possible.
@param InputInterface $input
@param string $name
@return string
@throws \InvalidArgumentException | [
"Given",
"a",
"package",
"name",
"this",
"determines",
"the",
"best",
"version",
"to",
"use",
"in",
"the",
"require",
"key",
"."
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/InitCommand.php#L594-L609 |
meta-tech/pws-auth | src/MetaTech/Util/Tool.php | Tool.formatDate | public static function formatDate($date, $fromFormat='d-m-Y', $toFormat='Y-m-d')
{
$dt = \DateTime::createFromFormat($fromFormat, $date);
return !$dt ? null : $dt->format($toFormat);
} | php | public static function formatDate($date, $fromFormat='d-m-Y', $toFormat='Y-m-d')
{
$dt = \DateTime::createFromFormat($fromFormat, $date);
return !$dt ? null : $dt->format($toFormat);
} | [
"public",
"static",
"function",
"formatDate",
"(",
"$",
"date",
",",
"$",
"fromFormat",
"=",
"'d-m-Y'",
",",
"$",
"toFormat",
"=",
"'Y-m-d'",
")",
"{",
"$",
"dt",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"fromFormat",
",",
"$",
"date",
")",
";",
"return",
"!",
"$",
"dt",
"?",
"null",
":",
"$",
"dt",
"->",
"format",
"(",
"$",
"toFormat",
")",
";",
"}"
] | /*!
@method formatDate
@public
@static
@param str $date
@param str $fromFormat
@param str $toFormat
@return str | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/Util/Tool.php#L57-L61 |
meta-tech/pws-auth | src/MetaTech/Util/Tool.php | Tool.dateFromTime | public static function dateFromTime($time=null)
{
return date(self::TIMESTAMP_SQLDATETIME, $time==null ? microtime(true) : $time);
} | php | public static function dateFromTime($time=null)
{
return date(self::TIMESTAMP_SQLDATETIME, $time==null ? microtime(true) : $time);
} | [
"public",
"static",
"function",
"dateFromTime",
"(",
"$",
"time",
"=",
"null",
")",
"{",
"return",
"date",
"(",
"self",
"::",
"TIMESTAMP_SQLDATETIME",
",",
"$",
"time",
"==",
"null",
"?",
"microtime",
"(",
"true",
")",
":",
"$",
"time",
")",
";",
"}"
] | /*!
@public
@static
@param float $time
@return string sqldatetime format | [
"/",
"*",
"!"
] | train | https://github.com/meta-tech/pws-auth/blob/6ba2727cf82470ffbda65925b077fadcd64a77ee/src/MetaTech/Util/Tool.php#L70-L73 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.