id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
18,900 | steeffeen/FancyManiaLinks | FML/Script/Features/EntrySubmit.php | EntrySubmit.getEntrySubmitScriptText | protected function getEntrySubmitScriptText()
{
$url = $this->buildCompatibleUrl();
$entryName = $this->entry->getName();
$link = Builder::escapeText($url . $entryName . "=");
return "
declare Value = TextLib::URLEncode(Entry.Value);
OpenLink({$link}^Value, CMlScript::LinkType::Goto);
";
} | php | protected function getEntrySubmitScriptText()
{
$url = $this->buildCompatibleUrl();
$entryName = $this->entry->getName();
$link = Builder::escapeText($url . $entryName . "=");
return "
declare Value = TextLib::URLEncode(Entry.Value);
OpenLink({$link}^Value, CMlScript::LinkType::Goto);
";
} | [
"protected",
"function",
"getEntrySubmitScriptText",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildCompatibleUrl",
"(",
")",
";",
"$",
"entryName",
"=",
"$",
"this",
"->",
"entry",
"->",
"getName",
"(",
")",
";",
"$",
"link",
"=",
"Builder",
"::",
"escapeText",
"(",
"$",
"url",
".",
"$",
"entryName",
".",
"\"=\"",
")",
";",
"return",
"\"\ndeclare Value = TextLib::URLEncode(Entry.Value);\nOpenLink({$link}^Value, CMlScript::LinkType::Goto);\n\"",
";",
"}"
]
| Get the entry submit event script text
@return string | [
"Get",
"the",
"entry",
"submit",
"event",
"script",
"text"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/EntrySubmit.php#L114-L123 |
18,901 | steeffeen/FancyManiaLinks | FML/Script/Features/EntrySubmit.php | EntrySubmit.buildCompatibleUrl | protected function buildCompatibleUrl()
{
$url = $this->url;
$parametersIndex = stripos($url, "?");
if (!is_int($parametersIndex) || $parametersIndex < 0) {
$url .= "?";
} else {
$url .= "&";
}
return $url;
} | php | protected function buildCompatibleUrl()
{
$url = $this->url;
$parametersIndex = stripos($url, "?");
if (!is_int($parametersIndex) || $parametersIndex < 0) {
$url .= "?";
} else {
$url .= "&";
}
return $url;
} | [
"protected",
"function",
"buildCompatibleUrl",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
";",
"$",
"parametersIndex",
"=",
"stripos",
"(",
"$",
"url",
",",
"\"?\"",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"parametersIndex",
")",
"||",
"$",
"parametersIndex",
"<",
"0",
")",
"{",
"$",
"url",
".=",
"\"?\"",
";",
"}",
"else",
"{",
"$",
"url",
".=",
"\"&\"",
";",
"}",
"return",
"$",
"url",
";",
"}"
]
| Build the submit url compatible for the entry parameter
@return string | [
"Build",
"the",
"submit",
"url",
"compatible",
"for",
"the",
"entry",
"parameter"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/EntrySubmit.php#L130-L140 |
18,902 | helthe/Chronos | Field/DayOfWeekField.php | DayOfWeekField.matchesHash | private function matchesHash($hash, \DateTime $date)
{
$ordinals = array(
'1' => 'first',
'2' => 'second',
'3' => 'third',
'4' => 'fourth',
'5' => 'fifth'
);
$hashParts = explode('#', $hash);
if ($hashParts[0] != $this->getFieldValueFromDate($date)) {
return false;
}
return $this->matchesRelativeDate($date, $ordinals[$hashParts[1]]);
} | php | private function matchesHash($hash, \DateTime $date)
{
$ordinals = array(
'1' => 'first',
'2' => 'second',
'3' => 'third',
'4' => 'fourth',
'5' => 'fifth'
);
$hashParts = explode('#', $hash);
if ($hashParts[0] != $this->getFieldValueFromDate($date)) {
return false;
}
return $this->matchesRelativeDate($date, $ordinals[$hashParts[1]]);
} | [
"private",
"function",
"matchesHash",
"(",
"$",
"hash",
",",
"\\",
"DateTime",
"$",
"date",
")",
"{",
"$",
"ordinals",
"=",
"array",
"(",
"'1'",
"=>",
"'first'",
",",
"'2'",
"=>",
"'second'",
",",
"'3'",
"=>",
"'third'",
",",
"'4'",
"=>",
"'fourth'",
",",
"'5'",
"=>",
"'fifth'",
")",
";",
"$",
"hashParts",
"=",
"explode",
"(",
"'#'",
",",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"hashParts",
"[",
"0",
"]",
"!=",
"$",
"this",
"->",
"getFieldValueFromDate",
"(",
"$",
"date",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"matchesRelativeDate",
"(",
"$",
"date",
",",
"$",
"ordinals",
"[",
"$",
"hashParts",
"[",
"1",
"]",
"]",
")",
";",
"}"
]
| Checks if the hash value matches the given date.
@param string $hash
@param \DateTime $date
@return Boolean | [
"Checks",
"if",
"the",
"hash",
"value",
"matches",
"the",
"given",
"date",
"."
]
| 6c783c55c32b323550fc6f21cd644c2be82720b0 | https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/DayOfWeekField.php#L101-L117 |
18,903 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/PDOStatement.php | PDOStatement.bindColumn | public function bindColumn($column, &$param, $type = null)
{
if ($type === null) :
$this->_statement->bindColumn($column, $param);
else :
$this->_statement->bindColumn($column, $param, $type);
endif;
} | php | public function bindColumn($column, &$param, $type = null)
{
if ($type === null) :
$this->_statement->bindColumn($column, $param);
else :
$this->_statement->bindColumn($column, $param, $type);
endif;
} | [
"public",
"function",
"bindColumn",
"(",
"$",
"column",
",",
"&",
"$",
"param",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
":",
"$",
"this",
"->",
"_statement",
"->",
"bindColumn",
"(",
"$",
"column",
",",
"$",
"param",
")",
";",
"else",
":",
"$",
"this",
"->",
"_statement",
"->",
"bindColumn",
"(",
"$",
"column",
",",
"$",
"param",
",",
"$",
"type",
")",
";",
"endif",
";",
"}"
]
| Bind a value of the column or field table
@access public
@param string $column
@param mixed $param
@param string $type
@return void | [
"Bind",
"a",
"value",
"of",
"the",
"column",
"or",
"field",
"table"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDOStatement.php#L62-L69 |
18,904 | simple-php-mvc/simple-php-mvc | src/MVC/DataBase/PDOStatement.php | PDOStatement.bindParam | public function bindParam($column, &$param, $type = null)
{
if ($type === null) :
$this->_statement->bindParam($column, $param);
else :
$this->_statement->bindParam($column, $param, $type);
endif;
} | php | public function bindParam($column, &$param, $type = null)
{
if ($type === null) :
$this->_statement->bindParam($column, $param);
else :
$this->_statement->bindParam($column, $param, $type);
endif;
} | [
"public",
"function",
"bindParam",
"(",
"$",
"column",
",",
"&",
"$",
"param",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
")",
":",
"$",
"this",
"->",
"_statement",
"->",
"bindParam",
"(",
"$",
"column",
",",
"$",
"param",
")",
";",
"else",
":",
"$",
"this",
"->",
"_statement",
"->",
"bindParam",
"(",
"$",
"column",
",",
"$",
"param",
",",
"$",
"type",
")",
";",
"endif",
";",
"}"
]
| Bind a value of the param SQL
@access public
@param string $column
@param mixed $param
@param string $type
@return void | [
"Bind",
"a",
"value",
"of",
"the",
"param",
"SQL"
]
| e319eb09d29afad6993acb4a7e35f32a87dd0841 | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDOStatement.php#L79-L86 |
18,905 | voda/php-translator | Antee/i18n/GettextTranslator.php | GettextTranslator.pgettext | public function pgettext($context, $message) {
if ($this->reader === null) {
return $message;
}
return $this->reader->pgettext((string)$context, (string)$message);
} | php | public function pgettext($context, $message) {
if ($this->reader === null) {
return $message;
}
return $this->reader->pgettext((string)$context, (string)$message);
} | [
"public",
"function",
"pgettext",
"(",
"$",
"context",
",",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reader",
"===",
"null",
")",
"{",
"return",
"$",
"message",
";",
"}",
"return",
"$",
"this",
"->",
"reader",
"->",
"pgettext",
"(",
"(",
"string",
")",
"$",
"context",
",",
"(",
"string",
")",
"$",
"message",
")",
";",
"}"
]
| gettext with contect.
@param string $context
@param string $message
@return string | [
"gettext",
"with",
"contect",
"."
]
| b1890ce89f7185b8958e6cf89cf2ad231d5e5f58 | https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L110-L115 |
18,906 | voda/php-translator | Antee/i18n/GettextTranslator.php | GettextTranslator.npgettext | public function npgettext($context, $singular, $plural, $count) {
if ($this->reader === null) {
return $count > 1 ? $plural : $singular;
}
return $this->reader->npgettext((string)$context, (string)$singular, (string)$plural, $count);
} | php | public function npgettext($context, $singular, $plural, $count) {
if ($this->reader === null) {
return $count > 1 ? $plural : $singular;
}
return $this->reader->npgettext((string)$context, (string)$singular, (string)$plural, $count);
} | [
"public",
"function",
"npgettext",
"(",
"$",
"context",
",",
"$",
"singular",
",",
"$",
"plural",
",",
"$",
"count",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"reader",
"===",
"null",
")",
"{",
"return",
"$",
"count",
">",
"1",
"?",
"$",
"plural",
":",
"$",
"singular",
";",
"}",
"return",
"$",
"this",
"->",
"reader",
"->",
"npgettext",
"(",
"(",
"string",
")",
"$",
"context",
",",
"(",
"string",
")",
"$",
"singular",
",",
"(",
"string",
")",
"$",
"plural",
",",
"$",
"count",
")",
";",
"}"
]
| Plural version of gettext with context.
@param string $context
@param string $singular
@param string $plural
@param int $count
@return string | [
"Plural",
"version",
"of",
"gettext",
"with",
"context",
"."
]
| b1890ce89f7185b8958e6cf89cf2ad231d5e5f58 | https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L126-L131 |
18,907 | npbtrac/yii2-enpii-cms | libs/override/web/NpView.php | NpView.addBaseUrlScript | public function addBaseUrlScript()
{
// Add base Url and absolute base Url to the head
$arrJsPosHEad = empty($this->js[static::POS_HEAD]) ? [] : $this->js[static::POS_HEAD];
array_unshift($arrJsPosHEad,
"var absoluteBaseUrl = \"" . Yii::$app->urlManager->createAbsoluteUrl('site/index') . "\";");
array_unshift($arrJsPosHEad, "var baseUrl = \"" . Yii::$app->urlManager->baseUrl . "\";");
$this->js[static::POS_HEAD] = $arrJsPosHEad;
} | php | public function addBaseUrlScript()
{
// Add base Url and absolute base Url to the head
$arrJsPosHEad = empty($this->js[static::POS_HEAD]) ? [] : $this->js[static::POS_HEAD];
array_unshift($arrJsPosHEad,
"var absoluteBaseUrl = \"" . Yii::$app->urlManager->createAbsoluteUrl('site/index') . "\";");
array_unshift($arrJsPosHEad, "var baseUrl = \"" . Yii::$app->urlManager->baseUrl . "\";");
$this->js[static::POS_HEAD] = $arrJsPosHEad;
} | [
"public",
"function",
"addBaseUrlScript",
"(",
")",
"{",
"// Add base Url and absolute base Url to the head",
"$",
"arrJsPosHEad",
"=",
"empty",
"(",
"$",
"this",
"->",
"js",
"[",
"static",
"::",
"POS_HEAD",
"]",
")",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"js",
"[",
"static",
"::",
"POS_HEAD",
"]",
";",
"array_unshift",
"(",
"$",
"arrJsPosHEad",
",",
"\"var absoluteBaseUrl = \\\"\"",
".",
"Yii",
"::",
"$",
"app",
"->",
"urlManager",
"->",
"createAbsoluteUrl",
"(",
"'site/index'",
")",
".",
"\"\\\";\"",
")",
";",
"array_unshift",
"(",
"$",
"arrJsPosHEad",
",",
"\"var baseUrl = \\\"\"",
".",
"Yii",
"::",
"$",
"app",
"->",
"urlManager",
"->",
"baseUrl",
".",
"\"\\\";\"",
")",
";",
"$",
"this",
"->",
"js",
"[",
"static",
"::",
"POS_HEAD",
"]",
"=",
"$",
"arrJsPosHEad",
";",
"}"
]
| Put javascript for base url to head | [
"Put",
"javascript",
"for",
"base",
"url",
"to",
"head"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/web/NpView.php#L70-L78 |
18,908 | npbtrac/yii2-enpii-cms | libs/override/web/NpView.php | NpView.setBrowserTitle | public function setBrowserTitle($title, $isFrontend = true, $prefix = 'Backend')
{
$strResult = ($isFrontend ? $title : $prefix . ' :: ' . $title);
$this->title = $strResult;
} | php | public function setBrowserTitle($title, $isFrontend = true, $prefix = 'Backend')
{
$strResult = ($isFrontend ? $title : $prefix . ' :: ' . $title);
$this->title = $strResult;
} | [
"public",
"function",
"setBrowserTitle",
"(",
"$",
"title",
",",
"$",
"isFrontend",
"=",
"true",
",",
"$",
"prefix",
"=",
"'Backend'",
")",
"{",
"$",
"strResult",
"=",
"(",
"$",
"isFrontend",
"?",
"$",
"title",
":",
"$",
"prefix",
".",
"' :: '",
".",
"$",
"title",
")",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"strResult",
";",
"}"
]
| Set title for browser with prefix
@param $title
@param bool $isFrontend
@param string $prefix | [
"Set",
"title",
"for",
"browser",
"with",
"prefix"
]
| 3495e697509a57a573983f552629ff9f707a63b9 | https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/web/NpView.php#L86-L90 |
18,909 | SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/EnvironmentHelper.php | EnvironmentHelper.getVar | public static function getVar(string $name, $defaultValue = null)
{
$value = getenv($name);
return $value !== false ? $value : $defaultValue;
} | php | public static function getVar(string $name, $defaultValue = null)
{
$value = getenv($name);
return $value !== false ? $value : $defaultValue;
} | [
"public",
"static",
"function",
"getVar",
"(",
"string",
"$",
"name",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"getenv",
"(",
"$",
"name",
")",
";",
"return",
"$",
"value",
"!==",
"false",
"?",
"$",
"value",
":",
"$",
"defaultValue",
";",
"}"
]
| Returns value of environment variable or default value
@param string $name
@param null $defaultValue
@return mixed value from env or defaultValue | [
"Returns",
"value",
"of",
"environment",
"variable",
"or",
"default",
"value"
]
| 4e1769ab6411a584112df1151dcc90e6b82fe2bb | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L14-L18 |
18,910 | SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/EnvironmentHelper.php | EnvironmentHelper.getRequiredVar | public static function getRequiredVar(string $name)
{
$value = getenv($name);
if ($value === false) {
throw EnvVarNotFoundException::create($name);
}
return $value;
} | php | public static function getRequiredVar(string $name)
{
$value = getenv($name);
if ($value === false) {
throw EnvVarNotFoundException::create($name);
}
return $value;
} | [
"public",
"static",
"function",
"getRequiredVar",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"getenv",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"throw",
"EnvVarNotFoundException",
"::",
"create",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Returns value of environment variable or throws Exception when is not defined
@param string $name
@return mixed value from env
@throws EnvVarNotFoundException | [
"Returns",
"value",
"of",
"environment",
"variable",
"or",
"throws",
"Exception",
"when",
"is",
"not",
"defined"
]
| 4e1769ab6411a584112df1151dcc90e6b82fe2bb | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L26-L33 |
18,911 | SAREhub/PHP_Commons | src/SAREhub/Commons/Misc/EnvironmentHelper.php | EnvironmentHelper.getVars | public static function getVars(array $schema, string $prefix = ""): array
{
$env = [];
foreach ($schema as $name => $default) {
$env[$name] = self::getVar($prefix . $name, $default);
}
return $env;
} | php | public static function getVars(array $schema, string $prefix = ""): array
{
$env = [];
foreach ($schema as $name => $default) {
$env[$name] = self::getVar($prefix . $name, $default);
}
return $env;
} | [
"public",
"static",
"function",
"getVars",
"(",
"array",
"$",
"schema",
",",
"string",
"$",
"prefix",
"=",
"\"\"",
")",
":",
"array",
"{",
"$",
"env",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"name",
"=>",
"$",
"default",
")",
"{",
"$",
"env",
"[",
"$",
"name",
"]",
"=",
"self",
"::",
"getVar",
"(",
"$",
"prefix",
".",
"$",
"name",
",",
"$",
"default",
")",
";",
"}",
"return",
"$",
"env",
";",
"}"
]
| Returns values of environment variables defined in schema parameter
@param array $schema Format: ["variableName" => defaultValue]
@param string $prefix Its added to variableName when getting value from env
@return array ["variableName" => valueFromEnv|defaultValue] | [
"Returns",
"values",
"of",
"environment",
"variables",
"defined",
"in",
"schema",
"parameter"
]
| 4e1769ab6411a584112df1151dcc90e6b82fe2bb | https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L41-L48 |
18,912 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.setPosition | public function setPosition($posX, $posY, $posZ = null)
{
$this->setX($posX)
->setY($posY);
if ($posZ !== null) {
$this->setZ($posZ);
}
return $this;
} | php | public function setPosition($posX, $posY, $posZ = null)
{
$this->setX($posX)
->setY($posY);
if ($posZ !== null) {
$this->setZ($posZ);
}
return $this;
} | [
"public",
"function",
"setPosition",
"(",
"$",
"posX",
",",
"$",
"posY",
",",
"$",
"posZ",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setX",
"(",
"$",
"posX",
")",
"->",
"setY",
"(",
"$",
"posY",
")",
";",
"if",
"(",
"$",
"posZ",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setZ",
"(",
"$",
"posZ",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the Control position
@api
@param float $posX Horizontal position
@param float $posY Vertical position
@param float $posZ (optional) Depth
@return static | [
"Set",
"the",
"Control",
"position"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L253-L261 |
18,913 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.getDataAttribute | public function getDataAttribute($name)
{
if (isset($this->dataAttributes[$name])) {
return $this->dataAttributes[$name];
}
return null;
} | php | public function getDataAttribute($name)
{
if (isset($this->dataAttributes[$name])) {
return $this->dataAttributes[$name];
}
return null;
} | [
"public",
"function",
"getDataAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dataAttributes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"dataAttributes",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
]
| Get data attribute
@api
@param string $name Name
@return mixed | [
"Get",
"data",
"attribute"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L663-L669 |
18,914 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addDataAttributes | public function addDataAttributes(array $dataAttributes)
{
foreach ($dataAttributes as $name => $value) {
$this->addDataAttribute($name, $value);
}
return $this;
} | php | public function addDataAttributes(array $dataAttributes)
{
foreach ($dataAttributes as $name => $value) {
$this->addDataAttribute($name, $value);
}
return $this;
} | [
"public",
"function",
"addDataAttributes",
"(",
"array",
"$",
"dataAttributes",
")",
"{",
"foreach",
"(",
"$",
"dataAttributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addDataAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add multiple data attributes
@api
@param mixed[] $dataAttributes Data attributes
@return static | [
"Add",
"multiple",
"data",
"attributes"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L703-L709 |
18,915 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addScriptFeature | public function addScriptFeature(ScriptFeature $scriptFeature)
{
if (!in_array($scriptFeature, $this->scriptFeatures, true)) {
array_push($this->scriptFeatures, $scriptFeature);
}
return $this;
} | php | public function addScriptFeature(ScriptFeature $scriptFeature)
{
if (!in_array($scriptFeature, $this->scriptFeatures, true)) {
array_push($this->scriptFeatures, $scriptFeature);
}
return $this;
} | [
"public",
"function",
"addScriptFeature",
"(",
"ScriptFeature",
"$",
"scriptFeature",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"scriptFeature",
",",
"$",
"this",
"->",
"scriptFeatures",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"scriptFeatures",
",",
"$",
"scriptFeature",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a new Script Feature
@api
@param ScriptFeature $scriptFeature Script Feature
@return static | [
"Add",
"a",
"new",
"Script",
"Feature"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L764-L770 |
18,916 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addActionTriggerFeature | public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK)
{
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
$this->addScriptFeature($actionTrigger);
return $this;
} | php | public function addActionTriggerFeature($actionName, $eventLabel = ScriptLabel::MOUSECLICK)
{
$actionTrigger = new ActionTrigger($actionName, $this, $eventLabel);
$this->addScriptFeature($actionTrigger);
return $this;
} | [
"public",
"function",
"addActionTriggerFeature",
"(",
"$",
"actionName",
",",
"$",
"eventLabel",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
")",
"{",
"$",
"actionTrigger",
"=",
"new",
"ActionTrigger",
"(",
"$",
"actionName",
",",
"$",
"this",
",",
"$",
"eventLabel",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"actionTrigger",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a dynamic Action Trigger
@api
@param string $actionName Action to trigger
@param string $eventLabel (optional) Event on which the action is triggered
@return static | [
"Add",
"a",
"dynamic",
"Action",
"Trigger"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L820-L825 |
18,917 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addMapInfoFeature | public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK)
{
$mapInfo = new MapInfo($this, $eventLabel);
$this->addScriptFeature($mapInfo);
return $this;
} | php | public function addMapInfoFeature($eventLabel = ScriptLabel::MOUSECLICK)
{
$mapInfo = new MapInfo($this, $eventLabel);
$this->addScriptFeature($mapInfo);
return $this;
} | [
"public",
"function",
"addMapInfoFeature",
"(",
"$",
"eventLabel",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
")",
"{",
"$",
"mapInfo",
"=",
"new",
"MapInfo",
"(",
"$",
"this",
",",
"$",
"eventLabel",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"mapInfo",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a dynamic Feature opening the current map info
@api
@param string $eventLabel (optional) Event on which the map info will be opened
@return static | [
"Add",
"a",
"dynamic",
"Feature",
"opening",
"the",
"current",
"map",
"info"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L834-L839 |
18,918 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addPlayerProfileFeature | public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK)
{
$playerProfile = new PlayerProfile($login, $this, $eventLabel);
$this->addScriptFeature($playerProfile);
return $this;
} | php | public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK)
{
$playerProfile = new PlayerProfile($login, $this, $eventLabel);
$this->addScriptFeature($playerProfile);
return $this;
} | [
"public",
"function",
"addPlayerProfileFeature",
"(",
"$",
"login",
",",
"$",
"eventLabel",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
")",
"{",
"$",
"playerProfile",
"=",
"new",
"PlayerProfile",
"(",
"$",
"login",
",",
"$",
"this",
",",
"$",
"eventLabel",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"playerProfile",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a dynamic Feature to open a specific player profile
@api
@param string $login Login of the player
@param string $eventLabel (optional) Event on which the player profile will be opened
@return static | [
"Add",
"a",
"dynamic",
"Feature",
"to",
"open",
"a",
"specific",
"player",
"profile"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L849-L854 |
18,919 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addUISoundFeature | public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK)
{
$uiSound = new UISound($soundName, $this, $variant, $eventLabel);
$this->addScriptFeature($uiSound);
return $this;
} | php | public function addUISoundFeature($soundName, $variant = 0, $eventLabel = ScriptLabel::MOUSECLICK)
{
$uiSound = new UISound($soundName, $this, $variant, $eventLabel);
$this->addScriptFeature($uiSound);
return $this;
} | [
"public",
"function",
"addUISoundFeature",
"(",
"$",
"soundName",
",",
"$",
"variant",
"=",
"0",
",",
"$",
"eventLabel",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
")",
"{",
"$",
"uiSound",
"=",
"new",
"UISound",
"(",
"$",
"soundName",
",",
"$",
"this",
",",
"$",
"variant",
",",
"$",
"eventLabel",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"uiSound",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a dynamic Feature playing a UISound
@api
@param string $soundName UISound name
@param int $variant (optional) Sound variant
@param string $eventLabel (optional) Event on which the sound will be played
@return static | [
"Add",
"a",
"dynamic",
"Feature",
"playing",
"a",
"UISound"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L865-L870 |
18,920 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addToggleFeature | public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false)
{
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
$this->addScriptFeature($toggle);
return $this;
} | php | public function addToggleFeature(Control $toggledControl, $labelName = ScriptLabel::MOUSECLICK, $onlyShow = false, $onlyHide = false)
{
$toggle = new Toggle($this, $toggledControl, $labelName, $onlyShow, $onlyHide);
$this->addScriptFeature($toggle);
return $this;
} | [
"public",
"function",
"addToggleFeature",
"(",
"Control",
"$",
"toggledControl",
",",
"$",
"labelName",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
",",
"$",
"onlyShow",
"=",
"false",
",",
"$",
"onlyHide",
"=",
"false",
")",
"{",
"$",
"toggle",
"=",
"new",
"Toggle",
"(",
"$",
"this",
",",
"$",
"toggledControl",
",",
"$",
"labelName",
",",
"$",
"onlyShow",
",",
"$",
"onlyHide",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"toggle",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a dynamic Feature toggling another Control
@api
@param Control $toggledControl Toggled Control
@param string $labelName (optional) Script label name
@param bool $onlyShow (optional) If it should only show the Control but not toggle
@param bool $onlyHide (optional) If it should only hide the Control but not toggle
@return static | [
"Add",
"a",
"dynamic",
"Feature",
"toggling",
"another",
"Control"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L882-L887 |
18,921 | steeffeen/FancyManiaLinks | FML/Controls/Control.php | Control.addScriptText | public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK)
{
$customText = new ControlScript($this, $scriptText, $label);
$this->addScriptFeature($customText);
return $this;
} | php | public function addScriptText($scriptText, $label = ScriptLabel::MOUSECLICK)
{
$customText = new ControlScript($this, $scriptText, $label);
$this->addScriptFeature($customText);
return $this;
} | [
"public",
"function",
"addScriptText",
"(",
"$",
"scriptText",
",",
"$",
"label",
"=",
"ScriptLabel",
"::",
"MOUSECLICK",
")",
"{",
"$",
"customText",
"=",
"new",
"ControlScript",
"(",
"$",
"this",
",",
"$",
"scriptText",
",",
"$",
"label",
")",
";",
"$",
"this",
"->",
"addScriptFeature",
"(",
"$",
"customText",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a custom Control Script text part
@api
@param string $scriptText Script text
@param string $label (optional) Script label name
@return static | [
"Add",
"a",
"custom",
"Control",
"Script",
"text",
"part"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L930-L935 |
18,922 | webforge-labs/psc-cms | lib/Psc/CMS/Controller/NavigationController.php | NavigationController.saveEntity | public function saveEntity($context, FormData $requestData, $subResource = NULL) {
$this->setContext($context);
return $this->saveFormular((array) $requestData);
} | php | public function saveEntity($context, FormData $requestData, $subResource = NULL) {
$this->setContext($context);
return $this->saveFormular((array) $requestData);
} | [
"public",
"function",
"saveEntity",
"(",
"$",
"context",
",",
"FormData",
"$",
"requestData",
",",
"$",
"subResource",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"setContext",
"(",
"$",
"context",
")",
";",
"return",
"$",
"this",
"->",
"saveFormular",
"(",
"(",
"array",
")",
"$",
"requestData",
")",
";",
"}"
]
| Overrides the saving of the AbstractEntityController to just save the navigation tree from UI
@return array | [
"Overrides",
"the",
"saving",
"of",
"the",
"AbstractEntityController",
"to",
"just",
"save",
"the",
"navigation",
"tree",
"from",
"UI"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/NavigationController.php#L40-L43 |
18,923 | webforge-labs/psc-cms | lib/Psc/CMS/Controller/NavigationController.php | NavigationController.createNewNode | public function createNewNode(stdClass $jsonNode) {
$nodeClass = $this->container->getRoleFQN('NavigationNode');
$node = new $nodeClass((array) $jsonNode->title);
$node->generateSlugs();
$defaultSlug = current($node->getI18nSlug()); // not matter what current language is, this is the default language
$page = $this->createNewPage($defaultSlug);
$this->dc->getEntityManager()->persist($page);
$node->setPage($page);
return $node;
} | php | public function createNewNode(stdClass $jsonNode) {
$nodeClass = $this->container->getRoleFQN('NavigationNode');
$node = new $nodeClass((array) $jsonNode->title);
$node->generateSlugs();
$defaultSlug = current($node->getI18nSlug()); // not matter what current language is, this is the default language
$page = $this->createNewPage($defaultSlug);
$this->dc->getEntityManager()->persist($page);
$node->setPage($page);
return $node;
} | [
"public",
"function",
"createNewNode",
"(",
"stdClass",
"$",
"jsonNode",
")",
"{",
"$",
"nodeClass",
"=",
"$",
"this",
"->",
"container",
"->",
"getRoleFQN",
"(",
"'NavigationNode'",
")",
";",
"$",
"node",
"=",
"new",
"$",
"nodeClass",
"(",
"(",
"array",
")",
"$",
"jsonNode",
"->",
"title",
")",
";",
"$",
"node",
"->",
"generateSlugs",
"(",
")",
";",
"$",
"defaultSlug",
"=",
"current",
"(",
"$",
"node",
"->",
"getI18nSlug",
"(",
")",
")",
";",
"// not matter what current language is, this is the default language",
"$",
"page",
"=",
"$",
"this",
"->",
"createNewPage",
"(",
"$",
"defaultSlug",
")",
";",
"$",
"this",
"->",
"dc",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"page",
")",
";",
"$",
"node",
"->",
"setPage",
"(",
"$",
"page",
")",
";",
"return",
"$",
"node",
";",
"}"
]
| Just create one, the attributes will be set automatically
@return Webforge\CMS\Navigation\Node | [
"Just",
"create",
"one",
"the",
"attributes",
"will",
"be",
"set",
"automatically"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/NavigationController.php#L306-L318 |
18,924 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/CyclicBarrier.php | CyclicBarrier.nextGeneration | public function nextGeneration()
{
// signal completion of last generation
Cond::broadcast($this->cond);
// set up next generation
$this->count = $this->parties;
$this->generation = new Generation();
} | php | public function nextGeneration()
{
// signal completion of last generation
Cond::broadcast($this->cond);
// set up next generation
$this->count = $this->parties;
$this->generation = new Generation();
} | [
"public",
"function",
"nextGeneration",
"(",
")",
"{",
"// signal completion of last generation",
"Cond",
"::",
"broadcast",
"(",
"$",
"this",
"->",
"cond",
")",
";",
"// set up next generation",
"$",
"this",
"->",
"count",
"=",
"$",
"this",
"->",
"parties",
";",
"$",
"this",
"->",
"generation",
"=",
"new",
"Generation",
"(",
")",
";",
"}"
]
| Updates state on barrier trip and wakes up everyone.
Called only while holding lock.
@return void
@visibility private | [
"Updates",
"state",
"on",
"barrier",
"trip",
"and",
"wakes",
"up",
"everyone",
".",
"Called",
"only",
"while",
"holding",
"lock",
"."
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/CyclicBarrier.php#L77-L85 |
18,925 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/CyclicBarrier.php | CyclicBarrier.breakBarrier | public function breakBarrier()
{
$this->generation->broken = true;
$this->count = $this->parties;
Cond::broadcast($this->cond);
} | php | public function breakBarrier()
{
$this->generation->broken = true;
$this->count = $this->parties;
Cond::broadcast($this->cond);
} | [
"public",
"function",
"breakBarrier",
"(",
")",
"{",
"$",
"this",
"->",
"generation",
"->",
"broken",
"=",
"true",
";",
"$",
"this",
"->",
"count",
"=",
"$",
"this",
"->",
"parties",
";",
"Cond",
"::",
"broadcast",
"(",
"$",
"this",
"->",
"cond",
")",
";",
"}"
]
| Sets current barrier generation as broken and wakes up everyone.
Called only while holding lock.
@return void
@visibility private | [
"Sets",
"current",
"barrier",
"generation",
"as",
"broken",
"and",
"wakes",
"up",
"everyone",
".",
"Called",
"only",
"while",
"holding",
"lock",
"."
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/CyclicBarrier.php#L94-L99 |
18,926 | phug-php/formatter | src/Phug/Formatter.php | Formatter.storeDebugNode | public function storeDebugNode(NodeInterface $node)
{
$nodeId = count($this->debugNodes);
$this->debugNodes[] = $node;
return $nodeId;
} | php | public function storeDebugNode(NodeInterface $node)
{
$nodeId = count($this->debugNodes);
$this->debugNodes[] = $node;
return $nodeId;
} | [
"public",
"function",
"storeDebugNode",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"nodeId",
"=",
"count",
"(",
"$",
"this",
"->",
"debugNodes",
")",
";",
"$",
"this",
"->",
"debugNodes",
"[",
"]",
"=",
"$",
"node",
";",
"return",
"$",
"nodeId",
";",
"}"
]
| Store a node in a debug list and return the allocated index for it.
@param NodeInterface $node
@return int | [
"Store",
"a",
"node",
"in",
"a",
"debug",
"list",
"and",
"return",
"the",
"allocated",
"index",
"for",
"it",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L162-L168 |
18,927 | phug-php/formatter | src/Phug/Formatter.php | Formatter.getDebugError | public function getDebugError($error, $code, $path = null)
{
/** @var \Throwable $error */
$line = $this->getSourceLine($error);
if ($line === false) {
return $error;
}
$source = explode("\n", $code, max(2, $line));
array_pop($source);
$source = implode("\n", $source);
$pos = mb_strrpos($source, 'PUG_DEBUG:');
if ($pos === false) {
throw $error;
}
$nodeId = intval(mb_substr($source, $pos + 10, 32));
if (!$this->debugIdExists($nodeId)) {
throw $error;
}
$node = $this->getNodeFromDebugId($nodeId);
$nodeLocation = $node->getSourceLocation();
$location = new SourceLocation(
($nodeLocation ? $nodeLocation->getPath() : null) ?: $path,
$nodeLocation ? $nodeLocation->getLine() : 0,
$nodeLocation ? $nodeLocation->getOffset() : 0,
$nodeLocation ? $nodeLocation->getOffsetLength() : 0
);
$className = $this->getOption('located_exception_class_name');
return new $className(
$location,
$error->getMessage(),
$error->getCode(),
$error
);
} | php | public function getDebugError($error, $code, $path = null)
{
/** @var \Throwable $error */
$line = $this->getSourceLine($error);
if ($line === false) {
return $error;
}
$source = explode("\n", $code, max(2, $line));
array_pop($source);
$source = implode("\n", $source);
$pos = mb_strrpos($source, 'PUG_DEBUG:');
if ($pos === false) {
throw $error;
}
$nodeId = intval(mb_substr($source, $pos + 10, 32));
if (!$this->debugIdExists($nodeId)) {
throw $error;
}
$node = $this->getNodeFromDebugId($nodeId);
$nodeLocation = $node->getSourceLocation();
$location = new SourceLocation(
($nodeLocation ? $nodeLocation->getPath() : null) ?: $path,
$nodeLocation ? $nodeLocation->getLine() : 0,
$nodeLocation ? $nodeLocation->getOffset() : 0,
$nodeLocation ? $nodeLocation->getOffsetLength() : 0
);
$className = $this->getOption('located_exception_class_name');
return new $className(
$location,
$error->getMessage(),
$error->getCode(),
$error
);
} | [
"public",
"function",
"getDebugError",
"(",
"$",
"error",
",",
"$",
"code",
",",
"$",
"path",
"=",
"null",
")",
"{",
"/** @var \\Throwable $error */",
"$",
"line",
"=",
"$",
"this",
"->",
"getSourceLine",
"(",
"$",
"error",
")",
";",
"if",
"(",
"$",
"line",
"===",
"false",
")",
"{",
"return",
"$",
"error",
";",
"}",
"$",
"source",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"code",
",",
"max",
"(",
"2",
",",
"$",
"line",
")",
")",
";",
"array_pop",
"(",
"$",
"source",
")",
";",
"$",
"source",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"source",
")",
";",
"$",
"pos",
"=",
"mb_strrpos",
"(",
"$",
"source",
",",
"'PUG_DEBUG:'",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"false",
")",
"{",
"throw",
"$",
"error",
";",
"}",
"$",
"nodeId",
"=",
"intval",
"(",
"mb_substr",
"(",
"$",
"source",
",",
"$",
"pos",
"+",
"10",
",",
"32",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"debugIdExists",
"(",
"$",
"nodeId",
")",
")",
"{",
"throw",
"$",
"error",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"getNodeFromDebugId",
"(",
"$",
"nodeId",
")",
";",
"$",
"nodeLocation",
"=",
"$",
"node",
"->",
"getSourceLocation",
"(",
")",
";",
"$",
"location",
"=",
"new",
"SourceLocation",
"(",
"(",
"$",
"nodeLocation",
"?",
"$",
"nodeLocation",
"->",
"getPath",
"(",
")",
":",
"null",
")",
"?",
":",
"$",
"path",
",",
"$",
"nodeLocation",
"?",
"$",
"nodeLocation",
"->",
"getLine",
"(",
")",
":",
"0",
",",
"$",
"nodeLocation",
"?",
"$",
"nodeLocation",
"->",
"getOffset",
"(",
")",
":",
"0",
",",
"$",
"nodeLocation",
"?",
"$",
"nodeLocation",
"->",
"getOffsetLength",
"(",
")",
":",
"0",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'located_exception_class_name'",
")",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"location",
",",
"$",
"error",
"->",
"getMessage",
"(",
")",
",",
"$",
"error",
"->",
"getCode",
"(",
")",
",",
"$",
"error",
")",
";",
"}"
]
| Return a formatted error linked to pug source.
@param \Throwable $error
@param string $code
@param string $path
@throws \Throwable
@return LocatedException|\Throwable | [
"Return",
"a",
"formatted",
"error",
"linked",
"to",
"pug",
"source",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L269-L303 |
18,928 | phug-php/formatter | src/Phug/Formatter.php | Formatter.setFormatHandler | public function setFormatHandler($doctype, $format)
{
if (!is_a($format, FormatInterface::class, true)) {
throw new \InvalidArgumentException(
"Passed format class $format must ".
'implement '.FormatInterface::class
);
}
$this->setOption(['formats', $doctype], $format);
return $this;
} | php | public function setFormatHandler($doctype, $format)
{
if (!is_a($format, FormatInterface::class, true)) {
throw new \InvalidArgumentException(
"Passed format class $format must ".
'implement '.FormatInterface::class
);
}
$this->setOption(['formats', $doctype], $format);
return $this;
} | [
"public",
"function",
"setFormatHandler",
"(",
"$",
"doctype",
",",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"format",
",",
"FormatInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Passed format class $format must \"",
".",
"'implement '",
".",
"FormatInterface",
"::",
"class",
")",
";",
"}",
"$",
"this",
"->",
"setOption",
"(",
"[",
"'formats'",
",",
"$",
"doctype",
"]",
",",
"$",
"format",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the format handler for a given doctype identifier.
@param string $doctype doctype identifier
@param FormatInterface|string $format format handler
@return $this | [
"Set",
"the",
"format",
"handler",
"for",
"a",
"given",
"doctype",
"identifier",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L313-L324 |
18,929 | phug-php/formatter | src/Phug/Formatter.php | Formatter.initFormats | public function initFormats()
{
$this->dependencies = new DependencyInjection();
$this->mixins = new DependencyInjection();
$this->destructors = new SplObjectStorage();
$this->formats = [];
return $this;
} | php | public function initFormats()
{
$this->dependencies = new DependencyInjection();
$this->mixins = new DependencyInjection();
$this->destructors = new SplObjectStorage();
$this->formats = [];
return $this;
} | [
"public",
"function",
"initFormats",
"(",
")",
"{",
"$",
"this",
"->",
"dependencies",
"=",
"new",
"DependencyInjection",
"(",
")",
";",
"$",
"this",
"->",
"mixins",
"=",
"new",
"DependencyInjection",
"(",
")",
";",
"$",
"this",
"->",
"destructors",
"=",
"new",
"SplObjectStorage",
"(",
")",
";",
"$",
"this",
"->",
"formats",
"=",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Initialize the formats list and dependencies.
@return $this | [
"Initialize",
"the",
"formats",
"list",
"and",
"dependencies",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L341-L349 |
18,930 | phug-php/formatter | src/Phug/Formatter.php | Formatter.getFormatInstance | public function getFormatInstance($format = null)
{
$format = $format ?: $this->format;
if (!($format instanceof FormatInterface)) {
if (!isset($this->formats[$format])) {
$event = new NewFormatEvent($this, new $format($this));
$this->trigger($event);
$this->formats[$format] = $event->getFormat();
}
$format = $this->formats[$format];
}
return $format;
} | php | public function getFormatInstance($format = null)
{
$format = $format ?: $this->format;
if (!($format instanceof FormatInterface)) {
if (!isset($this->formats[$format])) {
$event = new NewFormatEvent($this, new $format($this));
$this->trigger($event);
$this->formats[$format] = $event->getFormat();
}
$format = $this->formats[$format];
}
return $format;
} | [
"public",
"function",
"getFormatInstance",
"(",
"$",
"format",
"=",
"null",
")",
"{",
"$",
"format",
"=",
"$",
"format",
"?",
":",
"$",
"this",
"->",
"format",
";",
"if",
"(",
"!",
"(",
"$",
"format",
"instanceof",
"FormatInterface",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"formats",
"[",
"$",
"format",
"]",
")",
")",
"{",
"$",
"event",
"=",
"new",
"NewFormatEvent",
"(",
"$",
"this",
",",
"new",
"$",
"format",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"formats",
"[",
"$",
"format",
"]",
"=",
"$",
"event",
"->",
"getFormat",
"(",
")",
";",
"}",
"$",
"format",
"=",
"$",
"this",
"->",
"formats",
"[",
"$",
"format",
"]",
";",
"}",
"return",
"$",
"format",
";",
"}"
]
| Return current format as instance of FormatInterface.
@param FormatInterface|string optional format, if missing current format is used
@return FormatInterface | [
"Return",
"current",
"format",
"as",
"instance",
"of",
"FormatInterface",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L358-L373 |
18,931 | phug-php/formatter | src/Phug/Formatter.php | Formatter.setFormat | public function setFormat($doctype)
{
$formats = $this->getOption('formats');
$this->format = empty($formats[$doctype])
? $this->getOption('default_format')
: $formats[$doctype];
return $this;
} | php | public function setFormat($doctype)
{
$formats = $this->getOption('formats');
$this->format = empty($formats[$doctype])
? $this->getOption('default_format')
: $formats[$doctype];
return $this;
} | [
"public",
"function",
"setFormat",
"(",
"$",
"doctype",
")",
"{",
"$",
"formats",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'formats'",
")",
";",
"$",
"this",
"->",
"format",
"=",
"empty",
"(",
"$",
"formats",
"[",
"$",
"doctype",
"]",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"'default_format'",
")",
":",
"$",
"formats",
"[",
"$",
"doctype",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Set a format name as the current or fallback to default if not available.
@param string $doctype format identifier
@return $this | [
"Set",
"a",
"format",
"name",
"as",
"the",
"current",
"or",
"fallback",
"to",
"default",
"if",
"not",
"available",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L418-L426 |
18,932 | phug-php/formatter | src/Phug/Formatter.php | Formatter.format | public function format(ElementInterface $element, $format = null)
{
if ($element instanceof DoctypeElement) {
$formats = $this->getOption('formats');
$doctype = $element->getValue();
$this->setFormat($doctype);
if (isset($formats[$doctype])) {
$element->setValue(null);
}
}
$format = $this->getFormatInstance($format);
$format->setFormatter($this);
$formatEvent = new FormatEvent($element, $format);
$this->trigger($formatEvent);
$element = $formatEvent->getElement();
$format = $formatEvent->getFormat();
$stringifyEvent = new StringifyEvent($formatEvent, $element ? $format($element) : '');
$this->trigger($stringifyEvent);
return $stringifyEvent->getOutput();
} | php | public function format(ElementInterface $element, $format = null)
{
if ($element instanceof DoctypeElement) {
$formats = $this->getOption('formats');
$doctype = $element->getValue();
$this->setFormat($doctype);
if (isset($formats[$doctype])) {
$element->setValue(null);
}
}
$format = $this->getFormatInstance($format);
$format->setFormatter($this);
$formatEvent = new FormatEvent($element, $format);
$this->trigger($formatEvent);
$element = $formatEvent->getElement();
$format = $formatEvent->getFormat();
$stringifyEvent = new StringifyEvent($formatEvent, $element ? $format($element) : '');
$this->trigger($stringifyEvent);
return $stringifyEvent->getOutput();
} | [
"public",
"function",
"format",
"(",
"ElementInterface",
"$",
"element",
",",
"$",
"format",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"DoctypeElement",
")",
"{",
"$",
"formats",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'formats'",
")",
";",
"$",
"doctype",
"=",
"$",
"element",
"->",
"getValue",
"(",
")",
";",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"doctype",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"formats",
"[",
"$",
"doctype",
"]",
")",
")",
"{",
"$",
"element",
"->",
"setValue",
"(",
"null",
")",
";",
"}",
"}",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormatInstance",
"(",
"$",
"format",
")",
";",
"$",
"format",
"->",
"setFormatter",
"(",
"$",
"this",
")",
";",
"$",
"formatEvent",
"=",
"new",
"FormatEvent",
"(",
"$",
"element",
",",
"$",
"format",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"formatEvent",
")",
";",
"$",
"element",
"=",
"$",
"formatEvent",
"->",
"getElement",
"(",
")",
";",
"$",
"format",
"=",
"$",
"formatEvent",
"->",
"getFormat",
"(",
")",
";",
"$",
"stringifyEvent",
"=",
"new",
"StringifyEvent",
"(",
"$",
"formatEvent",
",",
"$",
"element",
"?",
"$",
"format",
"(",
"$",
"element",
")",
":",
"''",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"stringifyEvent",
")",
";",
"return",
"$",
"stringifyEvent",
"->",
"getOutput",
"(",
")",
";",
"}"
]
| Entry point of the Formatter, typically waiting for a DocumentElement and
a format, to return a string with HTML and PHP nested.
@param ElementInterface $element
@param FormatInterface|null $format
@return string | [
"Entry",
"point",
"of",
"the",
"Formatter",
"typically",
"waiting",
"for",
"a",
"DocumentElement",
"and",
"a",
"format",
"to",
"return",
"a",
"string",
"with",
"HTML",
"and",
"PHP",
"nested",
"."
]
| 3f9286a169a0d45b8b8acc1fae64e880ebdb567e | https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter.php#L533-L557 |
18,933 | inpsyde/inpsyde-filter | src/FilterFactory.php | FilterFactory.create | public function create( $type, array $properties = [ ] ) {
$type = (string) $type;
if ( isset( $this->classes[ $type ] ) ) {
$class = $this->classes[ $type ];
return new $class( $properties );
} else if ( class_exists( $type ) ) {
$class = new $type( $properties );
if ( $class instanceof FilterInterface ) {
return $class;
}
}
throw new Exception\InvalidArgumentException(
sprintf(
'The given class <code>%s</code> does not exists.',
$type
)
);
} | php | public function create( $type, array $properties = [ ] ) {
$type = (string) $type;
if ( isset( $this->classes[ $type ] ) ) {
$class = $this->classes[ $type ];
return new $class( $properties );
} else if ( class_exists( $type ) ) {
$class = new $type( $properties );
if ( $class instanceof FilterInterface ) {
return $class;
}
}
throw new Exception\InvalidArgumentException(
sprintf(
'The given class <code>%s</code> does not exists.',
$type
)
);
} | [
"public",
"function",
"create",
"(",
"$",
"type",
",",
"array",
"$",
"properties",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"(",
"string",
")",
"$",
"type",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"classes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"classes",
"[",
"$",
"type",
"]",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"properties",
")",
";",
"}",
"else",
"if",
"(",
"class_exists",
"(",
"$",
"type",
")",
")",
"{",
"$",
"class",
"=",
"new",
"$",
"type",
"(",
"$",
"properties",
")",
";",
"if",
"(",
"$",
"class",
"instanceof",
"FilterInterface",
")",
"{",
"return",
"$",
"class",
";",
"}",
"}",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The given class <code>%s</code> does not exists.'",
",",
"$",
"type",
")",
")",
";",
"}"
]
| Creates and returns a new filter instance of the given type.
@param $type
@param array $properties
@throws Exception\InvalidArgumentException if Filter of given $type is not found.
@return FilterInterface | [
"Creates",
"and",
"returns",
"a",
"new",
"filter",
"instance",
"of",
"the",
"given",
"type",
"."
]
| 777a6208ea4dfbeed89e6d0712a35dc25eab498b | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/FilterFactory.php#L46-L69 |
18,934 | php-rise/rise | src/Router.php | Router.match | public function match() {
$result = false;
$this->matchedStatus = $this->result->getStatus();
if ($this->result->hasHandler()) {
$result = true;
$this->matchedHandler = $this->result->getHandler();
} else {
$this->matchedHandler = $this->notFoundHandler;
}
return $result;
} | php | public function match() {
$result = false;
$this->matchedStatus = $this->result->getStatus();
if ($this->result->hasHandler()) {
$result = true;
$this->matchedHandler = $this->result->getHandler();
} else {
$this->matchedHandler = $this->notFoundHandler;
}
return $result;
} | [
"public",
"function",
"match",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"this",
"->",
"matchedStatus",
"=",
"$",
"this",
"->",
"result",
"->",
"getStatus",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"result",
"->",
"hasHandler",
"(",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"$",
"this",
"->",
"matchedHandler",
"=",
"$",
"this",
"->",
"result",
"->",
"getHandler",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"matchedHandler",
"=",
"$",
"this",
"->",
"notFoundHandler",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Match current HTTP request.
@return bool | [
"Match",
"current",
"HTTP",
"request",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Router.php#L75-L88 |
18,935 | askupasoftware/amarkal | Loaders/ClassLoader.php | ClassLoader.register_autoload_filter | public function register_autoload_filter( $namespace, $filter )
{
if(is_callable( $filter ) )
{
if( !isset($this->filters[$namespace]) )
{
$this->filters[$namespace] = array();
}
$this->filters[$namespace][] = $filter;
}
} | php | public function register_autoload_filter( $namespace, $filter )
{
if(is_callable( $filter ) )
{
if( !isset($this->filters[$namespace]) )
{
$this->filters[$namespace] = array();
}
$this->filters[$namespace][] = $filter;
}
} | [
"public",
"function",
"register_autoload_filter",
"(",
"$",
"namespace",
",",
"$",
"filter",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"filter",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"this",
"->",
"filters",
"[",
"$",
"namespace",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"filters",
"[",
"$",
"namespace",
"]",
"[",
"]",
"=",
"$",
"filter",
";",
"}",
"}"
]
| Autoload filters are functions that are used to autoload classes. These
functions accept a class name as an argument and return the appropriate
file path to that class.
Autoload filters are applied per namespace. Each namespace can have
multiple autoload filters. The class loader will loop through all the filters
until a file is found. The filters are looped through in the order in which
they were registered.
@param type $namespace The namespace in which the filter is applied.
@param type $filter A callable that returns the file path for the given class. | [
"Autoload",
"filters",
"are",
"functions",
"that",
"are",
"used",
"to",
"autoload",
"classes",
".",
"These",
"functions",
"accept",
"a",
"class",
"name",
"as",
"an",
"argument",
"and",
"return",
"the",
"appropriate",
"file",
"path",
"to",
"that",
"class",
".",
"Autoload",
"filters",
"are",
"applied",
"per",
"namespace",
".",
"Each",
"namespace",
"can",
"have",
"multiple",
"autoload",
"filters",
".",
"The",
"class",
"loader",
"will",
"loop",
"through",
"all",
"the",
"filters",
"until",
"a",
"file",
"is",
"found",
".",
"The",
"filters",
"are",
"looped",
"through",
"in",
"the",
"order",
"in",
"which",
"they",
"were",
"registered",
"."
]
| fe8283e2d6847ef697abec832da7ee741a85058c | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Loaders/ClassLoader.php#L150-L161 |
18,936 | webforge-labs/psc-cms | lib/Psc/CMS/EntityPropertyMeta.php | EntityPropertyMeta.getCanonicalName | public function getCanonicalName() {
if (mb_strpos($this->name, 'i18n') === 0) {
return mb_strtolower(mb_substr($this->name,4,1)).mb_substr($this->name, 5);
}
return $this->name;
} | php | public function getCanonicalName() {
if (mb_strpos($this->name, 'i18n') === 0) {
return mb_strtolower(mb_substr($this->name,4,1)).mb_substr($this->name, 5);
}
return $this->name;
} | [
"public",
"function",
"getCanonicalName",
"(",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"this",
"->",
"name",
",",
"'i18n'",
")",
"===",
"0",
")",
"{",
"return",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"name",
",",
"4",
",",
"1",
")",
")",
".",
"mb_substr",
"(",
"$",
"this",
"->",
"name",
",",
"5",
")",
";",
"}",
"return",
"$",
"this",
"->",
"name",
";",
"}"
]
| Returns the name of the property but cannonical
cannonical means: for example without i18n in front of it | [
"Returns",
"the",
"name",
"of",
"the",
"property",
"but",
"cannonical"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityPropertyMeta.php#L125-L131 |
18,937 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/File/Upload.php | Zend_Validate_File_Upload.getFiles | public function getFiles($file = null)
{
if ($file !== null) {
$return = array();
foreach ($this->_files as $name => $content) {
if ($name === $file) {
$return[$file] = $this->_files[$name];
}
if ($content['name'] === $file) {
$return[$name] = $this->_files[$name];
}
}
if (count($return) === 0) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The file '$file' was not found");
}
return $return;
}
return $this->_files;
} | php | public function getFiles($file = null)
{
if ($file !== null) {
$return = array();
foreach ($this->_files as $name => $content) {
if ($name === $file) {
$return[$file] = $this->_files[$name];
}
if ($content['name'] === $file) {
$return[$name] = $this->_files[$name];
}
}
if (count($return) === 0) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The file '$file' was not found");
}
return $return;
}
return $this->_files;
} | [
"public",
"function",
"getFiles",
"(",
"$",
"file",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"file",
"!==",
"null",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_files",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"_files",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"$",
"content",
"[",
"'name'",
"]",
"===",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"_files",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"return",
")",
"===",
"0",
")",
"{",
"require_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The file '$file' was not found\"",
")",
";",
"}",
"return",
"$",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"_files",
";",
"}"
]
| Returns the array of set files
@param string $files (Optional) The file to return in detail
@return array
@throws Zend_Validate_Exception If file is not found | [
"Returns",
"the",
"array",
"of",
"set",
"files"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Upload.php#L96-L119 |
18,938 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/File/Upload.php | Zend_Validate_File_Upload.setFiles | public function setFiles($files = array())
{
if (count($files) === 0) {
$this->_files = $_FILES;
} else {
$this->_files = $files;
}
foreach($this->_files as $file => $content) {
if (!isset($content['error'])) {
unset($this->_files[$file]);
}
}
return $this;
} | php | public function setFiles($files = array())
{
if (count($files) === 0) {
$this->_files = $_FILES;
} else {
$this->_files = $files;
}
foreach($this->_files as $file => $content) {
if (!isset($content['error'])) {
unset($this->_files[$file]);
}
}
return $this;
} | [
"public",
"function",
"setFiles",
"(",
"$",
"files",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"files",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"_files",
"=",
"$",
"_FILES",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_files",
"=",
"$",
"files",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_files",
"as",
"$",
"file",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"[",
"'error'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_files",
"[",
"$",
"file",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets the files to be checked
@param array $files The files to check in syntax of Zend_File_Transfer
@return Zend_Validate_File_Upload Provides a fluent interface | [
"Sets",
"the",
"files",
"to",
"be",
"checked"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Upload.php#L127-L142 |
18,939 | haldayne/boost | src/GuardedMapAbstract.php | GuardedMapAbstract.set | public function set($key, $value)
{
$result = $this->allowed($value);
if ($this->passes($result)) {
parent::set($key, $this->normalize($value));
} else {
throw new \UnexpectedValueException(sprintf(
'Value of type "%s" forbidden in this instance of %s',
gettype($value),
get_class($this)
));
}
} | php | public function set($key, $value)
{
$result = $this->allowed($value);
if ($this->passes($result)) {
parent::set($key, $this->normalize($value));
} else {
throw new \UnexpectedValueException(sprintf(
'Value of type "%s" forbidden in this instance of %s',
gettype($value),
get_class($this)
));
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"allowed",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"this",
"->",
"passes",
"(",
"$",
"result",
")",
")",
"{",
"parent",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"normalize",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'Value of type \"%s\" forbidden in this instance of %s'",
",",
"gettype",
"(",
"$",
"value",
")",
",",
"get_class",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"}"
]
| Set the value at a given key, provided that the value passes the
defined guard. Optionally, normalize the value before setting.
{@inheritDoc}
@throws \UnexpectedValueException | [
"Set",
"the",
"value",
"at",
"a",
"given",
"key",
"provided",
"that",
"the",
"value",
"passes",
"the",
"defined",
"guard",
".",
"Optionally",
"normalize",
"the",
"value",
"before",
"setting",
"."
]
| d18cc398557e23f9c316ea7fb40b90f84cc53650 | https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/GuardedMapAbstract.php#L25-L37 |
18,940 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRoleQuery.php | BaseRoleQuery.create | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RoleQuery) {
return $criteria;
}
$query = new RoleQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | php | public static function create($modelAlias = null, $criteria = null)
{
if ($criteria instanceof RoleQuery) {
return $criteria;
}
$query = new RoleQuery(null, null, $modelAlias);
if ($criteria instanceof Criteria) {
$query->mergeWith($criteria);
}
return $query;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelAlias",
"=",
"null",
",",
"$",
"criteria",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"criteria",
"instanceof",
"RoleQuery",
")",
"{",
"return",
"$",
"criteria",
";",
"}",
"$",
"query",
"=",
"new",
"RoleQuery",
"(",
"null",
",",
"null",
",",
"$",
"modelAlias",
")",
";",
"if",
"(",
"$",
"criteria",
"instanceof",
"Criteria",
")",
"{",
"$",
"query",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
]
| Returns a new RoleQuery object.
@param string $modelAlias The alias of a model in the query
@param RoleQuery|Criteria $criteria Optional Criteria to build the query from
@return RoleQuery | [
"Returns",
"a",
"new",
"RoleQuery",
"object",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRoleQuery.php#L75-L87 |
18,941 | slashworks/control-bundle | src/Slashworks/BackendBundle/Model/om/BaseRoleQuery.php | BaseRoleQuery.filterByRole | public function filterByRole($role = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($role)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $role)) {
$role = str_replace('*', '%', $role);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RolePeer::ROLE, $role, $comparison);
} | php | public function filterByRole($role = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($role)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $role)) {
$role = str_replace('*', '%', $role);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(RolePeer::ROLE, $role, $comparison);
} | [
"public",
"function",
"filterByRole",
"(",
"$",
"role",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"role",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"role",
")",
")",
"{",
"$",
"role",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"role",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"RolePeer",
"::",
"ROLE",
",",
"$",
"role",
",",
"$",
"comparison",
")",
";",
"}"
]
| Filter the query on the role column
Example usage:
<code>
$query->filterByRole('fooValue'); // WHERE role = 'fooValue'
$query->filterByRole('%fooValue%'); // WHERE role LIKE '%fooValue%'
</code>
@param string $role The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return RoleQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"role",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRoleQuery.php#L326-L338 |
18,942 | anime-db/app-bundle | src/Service/CommandExecutor.php | CommandExecutor.send | public function send($command, $host = '')
{
$host = $host ?: $this->host;
if (!$host) {
throw new \InvalidArgumentException('Unknown host that will run the command');
}
$content = 'command='.urlencode($command);
$fp = fsockopen($this->host, 80, $errno, $errstr, self::TIMEOUT);
$request = 'POST '.$this->path." HTTP/1.1\r\n";
$request .= 'Host: '.$host."\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= 'Content-Length: '.strlen($content)."\r\n";
$request .= "Connection: Close\r\n\r\n";
$request .= $content;
fwrite($fp, $request);
fclose($fp);
} | php | public function send($command, $host = '')
{
$host = $host ?: $this->host;
if (!$host) {
throw new \InvalidArgumentException('Unknown host that will run the command');
}
$content = 'command='.urlencode($command);
$fp = fsockopen($this->host, 80, $errno, $errstr, self::TIMEOUT);
$request = 'POST '.$this->path." HTTP/1.1\r\n";
$request .= 'Host: '.$host."\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= 'Content-Length: '.strlen($content)."\r\n";
$request .= "Connection: Close\r\n\r\n";
$request .= $content;
fwrite($fp, $request);
fclose($fp);
} | [
"public",
"function",
"send",
"(",
"$",
"command",
",",
"$",
"host",
"=",
"''",
")",
"{",
"$",
"host",
"=",
"$",
"host",
"?",
":",
"$",
"this",
"->",
"host",
";",
"if",
"(",
"!",
"$",
"host",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unknown host that will run the command'",
")",
";",
"}",
"$",
"content",
"=",
"'command='",
".",
"urlencode",
"(",
"$",
"command",
")",
";",
"$",
"fp",
"=",
"fsockopen",
"(",
"$",
"this",
"->",
"host",
",",
"80",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"self",
"::",
"TIMEOUT",
")",
";",
"$",
"request",
"=",
"'POST '",
".",
"$",
"this",
"->",
"path",
".",
"\" HTTP/1.1\\r\\n\"",
";",
"$",
"request",
".=",
"'Host: '",
".",
"$",
"host",
".",
"\"\\r\\n\"",
";",
"$",
"request",
".=",
"\"Content-Type: application/x-www-form-urlencoded\\r\\n\"",
";",
"$",
"request",
".=",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"content",
")",
".",
"\"\\r\\n\"",
";",
"$",
"request",
".=",
"\"Connection: Close\\r\\n\\r\\n\"",
";",
"$",
"request",
".=",
"$",
"content",
";",
"fwrite",
"(",
"$",
"fp",
",",
"$",
"request",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"}"
]
| Send the command to perform in a new thread.
@param string $command
@param string $host | [
"Send",
"the",
"command",
"to",
"perform",
"in",
"a",
"new",
"thread",
"."
]
| ca3b342081719d41ba018792a75970cbb1f1fe22 | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/CommandExecutor.php#L157-L174 |
18,943 | cviebrock/guzzle-stripbom-plugin | src/Cviebrock/Guzzle/Plugin/StripBom/StripBomPlugin.php | StripBomPlugin.onRequestComplete | public function onRequestComplete(Event $event)
{
if ($body = $event['response']->getBody()) {
if (substr($body, 0, 3) === "\xef\xbb\xbf") {
// UTF-8
$event['response']->setBody(substr($body, 3));
} else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" ||
substr($body, 0, 4) === "\x00\x00\xfe\xff"
) {
// UTF-32
$event['response']->setBody(substr($body, 4));
} else if (substr($body, 0, 2) === "\xff\xfe" ||
substr($body, 0, 2) === "\xfe\xff"
) {
// UTF-16
$event['response']->setBody(substr($body, 2));
}
}
} | php | public function onRequestComplete(Event $event)
{
if ($body = $event['response']->getBody()) {
if (substr($body, 0, 3) === "\xef\xbb\xbf") {
// UTF-8
$event['response']->setBody(substr($body, 3));
} else if (substr($body, 0, 4) === "\xff\xfe\x00\x00" ||
substr($body, 0, 4) === "\x00\x00\xfe\xff"
) {
// UTF-32
$event['response']->setBody(substr($body, 4));
} else if (substr($body, 0, 2) === "\xff\xfe" ||
substr($body, 0, 2) === "\xfe\xff"
) {
// UTF-16
$event['response']->setBody(substr($body, 2));
}
}
} | [
"public",
"function",
"onRequestComplete",
"(",
"Event",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"body",
"=",
"$",
"event",
"[",
"'response'",
"]",
"->",
"getBody",
"(",
")",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"3",
")",
"===",
"\"\\xef\\xbb\\xbf\"",
")",
"{",
"// UTF-8",
"$",
"event",
"[",
"'response'",
"]",
"->",
"setBody",
"(",
"substr",
"(",
"$",
"body",
",",
"3",
")",
")",
";",
"}",
"else",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"4",
")",
"===",
"\"\\xff\\xfe\\x00\\x00\"",
"||",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"4",
")",
"===",
"\"\\x00\\x00\\xfe\\xff\"",
")",
"{",
"// UTF-32",
"$",
"event",
"[",
"'response'",
"]",
"->",
"setBody",
"(",
"substr",
"(",
"$",
"body",
",",
"4",
")",
")",
";",
"}",
"else",
"if",
"(",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"2",
")",
"===",
"\"\\xff\\xfe\"",
"||",
"substr",
"(",
"$",
"body",
",",
"0",
",",
"2",
")",
"===",
"\"\\xfe\\xff\"",
")",
"{",
"// UTF-16",
"$",
"event",
"[",
"'response'",
"]",
"->",
"setBody",
"(",
"substr",
"(",
"$",
"body",
",",
"2",
")",
")",
";",
"}",
"}",
"}"
]
| When the request is complete, check the message body and strip any BOMs, if they exist.
@param Event $event | [
"When",
"the",
"request",
"is",
"complete",
"check",
"the",
"message",
"body",
"and",
"strip",
"any",
"BOMs",
"if",
"they",
"exist",
"."
]
| a8e7b5e166572790865d49eaf832e8e8ef8d7f21 | https://github.com/cviebrock/guzzle-stripbom-plugin/blob/a8e7b5e166572790865d49eaf832e8e8ef8d7f21/src/Cviebrock/Guzzle/Plugin/StripBom/StripBomPlugin.php#L26-L44 |
18,944 | phore/phore-micro-app | src/Auth/AclRule.php | AclRule.REJECT | public function REJECT(int $http_code=403, string $message="Access denied") : self
{
$this->rejectHttpCode = $http_code;
$this->rejectMessage = $message;
$this->action = self::ACTION_REJECT;
return $this;
} | php | public function REJECT(int $http_code=403, string $message="Access denied") : self
{
$this->rejectHttpCode = $http_code;
$this->rejectMessage = $message;
$this->action = self::ACTION_REJECT;
return $this;
} | [
"public",
"function",
"REJECT",
"(",
"int",
"$",
"http_code",
"=",
"403",
",",
"string",
"$",
"message",
"=",
"\"Access denied\"",
")",
":",
"self",
"{",
"$",
"this",
"->",
"rejectHttpCode",
"=",
"$",
"http_code",
";",
"$",
"this",
"->",
"rejectMessage",
"=",
"$",
"message",
";",
"$",
"this",
"->",
"action",
"=",
"self",
"::",
"ACTION_REJECT",
";",
"return",
"$",
"this",
";",
"}"
]
| Reject the Request
@param string|null $alias
@return AclRule | [
"Reject",
"the",
"Request"
]
| 6cf87a647b8b0be05afbfe6bd020650e98558c23 | https://github.com/phore/phore-micro-app/blob/6cf87a647b8b0be05afbfe6bd020650e98558c23/src/Auth/AclRule.php#L123-L129 |
18,945 | trendwerk/dev-uploads | class-tp-dev-uploads.php | TP_Dev_Uploads.placehold | function placehold( $rules ) {
if( 'development' == WP_ENV || 'staging' == WP_ENV ) {
$dir = wp_upload_dir();
$uploads_rel_path = str_replace( trailingslashit( home_url() ), '', $dir['baseurl'] );
$tp_images_rules = array(
'',
'# BEGIN TP Development uploads',
'RewriteCond %{REQUEST_FILENAME} !-f',
'RewriteRule ^' . $uploads_rel_path . '/(.*)-([0-9]+)x([0-9]+).(gif|jpe?g|png|bmp)$ http://www.placehold.it/$2x$3 [NC,L]',
'RewriteCond %{REQUEST_FILENAME} !-f',
'RewriteRule ^' . $uploads_rel_path . '/(.*)(gif|jpe?g|png|bmp)$ http://www.placehold.it/600x600 [NC,L]',
'# END TP Development uploads',
'',
);
$rules = explode( "\n", $rules );
$rules = wp_parse_args( $rules, $tp_images_rules );
$rules = implode( "\n", $rules );
}
return $rules;
} | php | function placehold( $rules ) {
if( 'development' == WP_ENV || 'staging' == WP_ENV ) {
$dir = wp_upload_dir();
$uploads_rel_path = str_replace( trailingslashit( home_url() ), '', $dir['baseurl'] );
$tp_images_rules = array(
'',
'# BEGIN TP Development uploads',
'RewriteCond %{REQUEST_FILENAME} !-f',
'RewriteRule ^' . $uploads_rel_path . '/(.*)-([0-9]+)x([0-9]+).(gif|jpe?g|png|bmp)$ http://www.placehold.it/$2x$3 [NC,L]',
'RewriteCond %{REQUEST_FILENAME} !-f',
'RewriteRule ^' . $uploads_rel_path . '/(.*)(gif|jpe?g|png|bmp)$ http://www.placehold.it/600x600 [NC,L]',
'# END TP Development uploads',
'',
);
$rules = explode( "\n", $rules );
$rules = wp_parse_args( $rules, $tp_images_rules );
$rules = implode( "\n", $rules );
}
return $rules;
} | [
"function",
"placehold",
"(",
"$",
"rules",
")",
"{",
"if",
"(",
"'development'",
"==",
"WP_ENV",
"||",
"'staging'",
"==",
"WP_ENV",
")",
"{",
"$",
"dir",
"=",
"wp_upload_dir",
"(",
")",
";",
"$",
"uploads_rel_path",
"=",
"str_replace",
"(",
"trailingslashit",
"(",
"home_url",
"(",
")",
")",
",",
"''",
",",
"$",
"dir",
"[",
"'baseurl'",
"]",
")",
";",
"$",
"tp_images_rules",
"=",
"array",
"(",
"''",
",",
"'# BEGIN TP Development uploads'",
",",
"'RewriteCond %{REQUEST_FILENAME} !-f'",
",",
"'RewriteRule ^'",
".",
"$",
"uploads_rel_path",
".",
"'/(.*)-([0-9]+)x([0-9]+).(gif|jpe?g|png|bmp)$ http://www.placehold.it/$2x$3 [NC,L]'",
",",
"'RewriteCond %{REQUEST_FILENAME} !-f'",
",",
"'RewriteRule ^'",
".",
"$",
"uploads_rel_path",
".",
"'/(.*)(gif|jpe?g|png|bmp)$ http://www.placehold.it/600x600 [NC,L]'",
",",
"'# END TP Development uploads'",
",",
"''",
",",
")",
";",
"$",
"rules",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"rules",
")",
";",
"$",
"rules",
"=",
"wp_parse_args",
"(",
"$",
"rules",
",",
"$",
"tp_images_rules",
")",
";",
"$",
"rules",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"rules",
")",
";",
"}",
"return",
"$",
"rules",
";",
"}"
]
| Redirect images from uploads to placehold.it on develop and release environments if they don't exist
@param string $rules WordPress' own rules
@return string New rules | [
"Redirect",
"images",
"from",
"uploads",
"to",
"placehold",
".",
"it",
"on",
"develop",
"and",
"release",
"environments",
"if",
"they",
"don",
"t",
"exist"
]
| 31e6efbb15e329271f2e44f9a6abfd2ac0212744 | https://github.com/trendwerk/dev-uploads/blob/31e6efbb15e329271f2e44f9a6abfd2ac0212744/class-tp-dev-uploads.php#L27-L50 |
18,946 | zephia/pilot-api-client | src/Client/PilotApiClient.php | PilotApiClient.storeLead | public function storeLead(LeadData $lead_data, $notification_email = '')
{
$form_params = [
'debug' => $this->debug,
'action' => 'create',
'appkey' => $this->getAppKey(),
];
$form_params = array_merge($form_params, $lead_data->toArray());
if (!empty($notification_email)) {
$form_params['notification_email'] = $notification_email;
}
$response = $this->guzzleClient->post(self::BASE_URI, [
'body' => $form_params
]);
if ($response->getStatusCode() === 200) {
$content = json_decode($response->getBody()->getContents());
if ($content->success === false) {
throw new InvalidArgumentException($content->data);
}
return $content;
}
} | php | public function storeLead(LeadData $lead_data, $notification_email = '')
{
$form_params = [
'debug' => $this->debug,
'action' => 'create',
'appkey' => $this->getAppKey(),
];
$form_params = array_merge($form_params, $lead_data->toArray());
if (!empty($notification_email)) {
$form_params['notification_email'] = $notification_email;
}
$response = $this->guzzleClient->post(self::BASE_URI, [
'body' => $form_params
]);
if ($response->getStatusCode() === 200) {
$content = json_decode($response->getBody()->getContents());
if ($content->success === false) {
throw new InvalidArgumentException($content->data);
}
return $content;
}
} | [
"public",
"function",
"storeLead",
"(",
"LeadData",
"$",
"lead_data",
",",
"$",
"notification_email",
"=",
"''",
")",
"{",
"$",
"form_params",
"=",
"[",
"'debug'",
"=>",
"$",
"this",
"->",
"debug",
",",
"'action'",
"=>",
"'create'",
",",
"'appkey'",
"=>",
"$",
"this",
"->",
"getAppKey",
"(",
")",
",",
"]",
";",
"$",
"form_params",
"=",
"array_merge",
"(",
"$",
"form_params",
",",
"$",
"lead_data",
"->",
"toArray",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"notification_email",
")",
")",
"{",
"$",
"form_params",
"[",
"'notification_email'",
"]",
"=",
"$",
"notification_email",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzleClient",
"->",
"post",
"(",
"self",
"::",
"BASE_URI",
",",
"[",
"'body'",
"=>",
"$",
"form_params",
"]",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"===",
"200",
")",
"{",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"if",
"(",
"$",
"content",
"->",
"success",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"content",
"->",
"data",
")",
";",
"}",
"return",
"$",
"content",
";",
"}",
"}"
]
| Stores a lead
@param LeadData $lead_data
@param string $notification_email
@throws InvalidArgumentException
@return mixed | [
"Stores",
"a",
"lead"
]
| 218fbf2fc5892e2ffc554ddd01fa95d63d6e3c0f | https://github.com/zephia/pilot-api-client/blob/218fbf2fc5892e2ffc554ddd01fa95d63d6e3c0f/src/Client/PilotApiClient.php#L58-L83 |
18,947 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.addSectionMediaElement | public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = ($type == 'image') ? 'images' : 'embeddings';
if(!array_key_exists($mediaId, self::$_sectionMedia[$key])) {
$cImg = self::countSectionMediaElements('images');
$cObj = self::countSectionMediaElements('embeddings');
$rID = self::countSectionMediaElements() + 7;
$media = array();
if($type == 'image') {
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$folder = 'media';
$file = $type.$cImg.'.'.strtolower($ext);
} elseif($type == 'oleObject') {
$cObj++;
$folder = 'embedding';
$file = $type.$cObj.'.bin';
}
$media['source'] = $src;
$media['target'] = "$folder/section_$file";
$media['type'] = $type;
$media['rID'] = $rID;
self::$_sectionMedia[$key][$mediaId] = $media;
if($type == 'oleObject') {
return array($rID, ++self::$_objectId);
} else {
return $rID;
}
} else {
if($type == 'oleObject') {
$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
return array($rID, ++self::$_objectId);
} else {
return self::$_sectionMedia[$key][$mediaId]['rID'];
}
}
} | php | public static function addSectionMediaElement($src, $type, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = ($type == 'image') ? 'images' : 'embeddings';
if(!array_key_exists($mediaId, self::$_sectionMedia[$key])) {
$cImg = self::countSectionMediaElements('images');
$cObj = self::countSectionMediaElements('embeddings');
$rID = self::countSectionMediaElements() + 7;
$media = array();
if($type == 'image') {
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php' && $type == 'image') ? true : false;
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$folder = 'media';
$file = $type.$cImg.'.'.strtolower($ext);
} elseif($type == 'oleObject') {
$cObj++;
$folder = 'embedding';
$file = $type.$cObj.'.bin';
}
$media['source'] = $src;
$media['target'] = "$folder/section_$file";
$media['type'] = $type;
$media['rID'] = $rID;
self::$_sectionMedia[$key][$mediaId] = $media;
if($type == 'oleObject') {
return array($rID, ++self::$_objectId);
} else {
return $rID;
}
} else {
if($type == 'oleObject') {
$rID = self::$_sectionMedia[$key][$mediaId]['rID'];
return array($rID, ++self::$_objectId);
} else {
return self::$_sectionMedia[$key][$mediaId]['rID'];
}
}
} | [
"public",
"static",
"function",
"addSectionMediaElement",
"(",
"$",
"src",
",",
"$",
"type",
",",
"PHPWord_Section_MemoryImage",
"$",
"memoryImage",
"=",
"null",
")",
"{",
"$",
"mediaId",
"=",
"md5",
"(",
"$",
"src",
")",
";",
"$",
"key",
"=",
"(",
"$",
"type",
"==",
"'image'",
")",
"?",
"'images'",
":",
"'embeddings'",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"mediaId",
",",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"cImg",
"=",
"self",
"::",
"countSectionMediaElements",
"(",
"'images'",
")",
";",
"$",
"cObj",
"=",
"self",
"::",
"countSectionMediaElements",
"(",
"'embeddings'",
")",
";",
"$",
"rID",
"=",
"self",
"::",
"countSectionMediaElements",
"(",
")",
"+",
"7",
";",
"$",
"media",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"type",
"==",
"'image'",
")",
"{",
"$",
"cImg",
"++",
";",
"$",
"inf",
"=",
"pathinfo",
"(",
"$",
"src",
")",
";",
"$",
"isMemImage",
"=",
"(",
"substr",
"(",
"strtolower",
"(",
"$",
"inf",
"[",
"'extension'",
"]",
")",
",",
"0",
",",
"3",
")",
"==",
"'php'",
"&&",
"$",
"type",
"==",
"'image'",
")",
"?",
"true",
":",
"false",
";",
"if",
"(",
"$",
"isMemImage",
")",
"{",
"$",
"ext",
"=",
"$",
"memoryImage",
"->",
"getImageExtension",
"(",
")",
";",
"$",
"media",
"[",
"'isMemImage'",
"]",
"=",
"true",
";",
"$",
"media",
"[",
"'createfunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageCreateFunction",
"(",
")",
";",
"$",
"media",
"[",
"'imagefunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageFunction",
"(",
")",
";",
"}",
"else",
"{",
"$",
"ext",
"=",
"$",
"inf",
"[",
"'extension'",
"]",
";",
"if",
"(",
"$",
"ext",
"==",
"'jpeg'",
")",
"{",
"// Office crashes when adding a jpEg Image, so rename to jpg\r",
"$",
"ext",
"=",
"'jpg'",
";",
"}",
"}",
"$",
"folder",
"=",
"'media'",
";",
"$",
"file",
"=",
"$",
"type",
".",
"$",
"cImg",
".",
"'.'",
".",
"strtolower",
"(",
"$",
"ext",
")",
";",
"}",
"elseif",
"(",
"$",
"type",
"==",
"'oleObject'",
")",
"{",
"$",
"cObj",
"++",
";",
"$",
"folder",
"=",
"'embedding'",
";",
"$",
"file",
"=",
"$",
"type",
".",
"$",
"cObj",
".",
"'.bin'",
";",
"}",
"$",
"media",
"[",
"'source'",
"]",
"=",
"$",
"src",
";",
"$",
"media",
"[",
"'target'",
"]",
"=",
"\"$folder/section_$file\"",
";",
"$",
"media",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"media",
"[",
"'rID'",
"]",
"=",
"$",
"rID",
";",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"=",
"$",
"media",
";",
"if",
"(",
"$",
"type",
"==",
"'oleObject'",
")",
"{",
"return",
"array",
"(",
"$",
"rID",
",",
"++",
"self",
"::",
"$",
"_objectId",
")",
";",
"}",
"else",
"{",
"return",
"$",
"rID",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"type",
"==",
"'oleObject'",
")",
"{",
"$",
"rID",
"=",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"[",
"'rID'",
"]",
";",
"return",
"array",
"(",
"$",
"rID",
",",
"++",
"self",
"::",
"$",
"_objectId",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"[",
"'rID'",
"]",
";",
"}",
"}",
"}"
]
| Add new Section Media Element
@param string $src
@param string $type
@return mixed | [
"Add",
"new",
"Section",
"Media",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L77-L133 |
18,948 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.addSectionLinkElement | public static function addSectionLinkElement($linkSrc) {
$rID = self::countSectionMediaElements() + 7;
$link = array();
$link['target'] = $linkSrc;
$link['rID'] = $rID;
$link['type'] = 'hyperlink';
self::$_sectionMedia['links'][] = $link;
return $rID;
} | php | public static function addSectionLinkElement($linkSrc) {
$rID = self::countSectionMediaElements() + 7;
$link = array();
$link['target'] = $linkSrc;
$link['rID'] = $rID;
$link['type'] = 'hyperlink';
self::$_sectionMedia['links'][] = $link;
return $rID;
} | [
"public",
"static",
"function",
"addSectionLinkElement",
"(",
"$",
"linkSrc",
")",
"{",
"$",
"rID",
"=",
"self",
"::",
"countSectionMediaElements",
"(",
")",
"+",
"7",
";",
"$",
"link",
"=",
"array",
"(",
")",
";",
"$",
"link",
"[",
"'target'",
"]",
"=",
"$",
"linkSrc",
";",
"$",
"link",
"[",
"'rID'",
"]",
"=",
"$",
"rID",
";",
"$",
"link",
"[",
"'type'",
"]",
"=",
"'hyperlink'",
";",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'links'",
"]",
"[",
"]",
"=",
"$",
"link",
";",
"return",
"$",
"rID",
";",
"}"
]
| Add new Section Link Element
@param string $linkSrc
@param string $linkName
@return mixed | [
"Add",
"new",
"Section",
"Link",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L143-L154 |
18,949 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.getSectionMediaElements | public static function getSectionMediaElements($key = null) {
if(!is_null($key)) {
return self::$_sectionMedia[$key];
} else {
$arrImages = self::$_sectionMedia['images'];
$arrObjects = self::$_sectionMedia['embeddings'];
$arrLinks = self::$_sectionMedia['links'];
return array_merge($arrImages, $arrObjects, $arrLinks);
}
} | php | public static function getSectionMediaElements($key = null) {
if(!is_null($key)) {
return self::$_sectionMedia[$key];
} else {
$arrImages = self::$_sectionMedia['images'];
$arrObjects = self::$_sectionMedia['embeddings'];
$arrLinks = self::$_sectionMedia['links'];
return array_merge($arrImages, $arrObjects, $arrLinks);
}
} | [
"public",
"static",
"function",
"getSectionMediaElements",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"$",
"arrImages",
"=",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'images'",
"]",
";",
"$",
"arrObjects",
"=",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'embeddings'",
"]",
";",
"$",
"arrLinks",
"=",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'links'",
"]",
";",
"return",
"array_merge",
"(",
"$",
"arrImages",
",",
"$",
"arrObjects",
",",
"$",
"arrLinks",
")",
";",
"}",
"}"
]
| Get Section Media Elements
@param string $key
@return array | [
"Get",
"Section",
"Media",
"Elements"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L162-L171 |
18,950 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.countSectionMediaElements | public static function countSectionMediaElements($key = null) {
if(!is_null($key)) {
return count(self::$_sectionMedia[$key]);
} else {
$cImages = count(self::$_sectionMedia['images']);
$cObjects = count(self::$_sectionMedia['embeddings']);
$cLinks = count(self::$_sectionMedia['links']);
return ($cImages + $cObjects + $cLinks);
}
} | php | public static function countSectionMediaElements($key = null) {
if(!is_null($key)) {
return count(self::$_sectionMedia[$key]);
} else {
$cImages = count(self::$_sectionMedia['images']);
$cObjects = count(self::$_sectionMedia['embeddings']);
$cLinks = count(self::$_sectionMedia['links']);
return ($cImages + $cObjects + $cLinks);
}
} | [
"public",
"static",
"function",
"countSectionMediaElements",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"count",
"(",
"self",
"::",
"$",
"_sectionMedia",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"cImages",
"=",
"count",
"(",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'images'",
"]",
")",
";",
"$",
"cObjects",
"=",
"count",
"(",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'embeddings'",
"]",
")",
";",
"$",
"cLinks",
"=",
"count",
"(",
"self",
"::",
"$",
"_sectionMedia",
"[",
"'links'",
"]",
")",
";",
"return",
"(",
"$",
"cImages",
"+",
"$",
"cObjects",
"+",
"$",
"cLinks",
")",
";",
"}",
"}"
]
| Get Section Media Elements Count
@param string $key
@return int | [
"Get",
"Section",
"Media",
"Elements",
"Count"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L179-L188 |
18,951 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.addHeaderMediaElement | public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = 'header'.$headerCount;
if(!array_key_exists($key, self::$_headerMedia)) {
self::$_headerMedia[$key] = array();
}
if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
$cImg = self::countHeaderMediaElements($key);
$rID = $cImg + 1;
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
$media = array();
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$file = 'image'.$cImg.'.'.strtolower($ext);
$media['source'] = $src;
$media['target'] = 'media/'.$key.'_'.$file;
$media['type'] = 'image';
$media['rID'] = $rID;
self::$_headerMedia[$key][$mediaId] = $media;
return $rID;
} else {
return self::$_headerMedia[$key][$mediaId]['rID'];
}
} | php | public static function addHeaderMediaElement($headerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = 'header'.$headerCount;
if(!array_key_exists($key, self::$_headerMedia)) {
self::$_headerMedia[$key] = array();
}
if(!array_key_exists($mediaId, self::$_headerMedia[$key])) {
$cImg = self::countHeaderMediaElements($key);
$rID = $cImg + 1;
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
$media = array();
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$file = 'image'.$cImg.'.'.strtolower($ext);
$media['source'] = $src;
$media['target'] = 'media/'.$key.'_'.$file;
$media['type'] = 'image';
$media['rID'] = $rID;
self::$_headerMedia[$key][$mediaId] = $media;
return $rID;
} else {
return self::$_headerMedia[$key][$mediaId]['rID'];
}
} | [
"public",
"static",
"function",
"addHeaderMediaElement",
"(",
"$",
"headerCount",
",",
"$",
"src",
",",
"PHPWord_Section_MemoryImage",
"$",
"memoryImage",
"=",
"null",
")",
"{",
"$",
"mediaId",
"=",
"md5",
"(",
"$",
"src",
")",
";",
"$",
"key",
"=",
"'header'",
".",
"$",
"headerCount",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"_headerMedia",
")",
")",
"{",
"self",
"::",
"$",
"_headerMedia",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"mediaId",
",",
"self",
"::",
"$",
"_headerMedia",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"cImg",
"=",
"self",
"::",
"countHeaderMediaElements",
"(",
"$",
"key",
")",
";",
"$",
"rID",
"=",
"$",
"cImg",
"+",
"1",
";",
"$",
"cImg",
"++",
";",
"$",
"inf",
"=",
"pathinfo",
"(",
"$",
"src",
")",
";",
"$",
"isMemImage",
"=",
"(",
"substr",
"(",
"strtolower",
"(",
"$",
"inf",
"[",
"'extension'",
"]",
")",
",",
"0",
",",
"3",
")",
"==",
"'php'",
")",
"?",
"true",
":",
"false",
";",
"$",
"media",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"isMemImage",
")",
"{",
"$",
"ext",
"=",
"$",
"memoryImage",
"->",
"getImageExtension",
"(",
")",
";",
"$",
"media",
"[",
"'isMemImage'",
"]",
"=",
"true",
";",
"$",
"media",
"[",
"'createfunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageCreateFunction",
"(",
")",
";",
"$",
"media",
"[",
"'imagefunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageFunction",
"(",
")",
";",
"}",
"else",
"{",
"$",
"ext",
"=",
"$",
"inf",
"[",
"'extension'",
"]",
";",
"if",
"(",
"$",
"ext",
"==",
"'jpeg'",
")",
"{",
"// Office crashes when adding a jpEg Image, so rename to jpg\r",
"$",
"ext",
"=",
"'jpg'",
";",
"}",
"}",
"$",
"file",
"=",
"'image'",
".",
"$",
"cImg",
".",
"'.'",
".",
"strtolower",
"(",
"$",
"ext",
")",
";",
"$",
"media",
"[",
"'source'",
"]",
"=",
"$",
"src",
";",
"$",
"media",
"[",
"'target'",
"]",
"=",
"'media/'",
".",
"$",
"key",
".",
"'_'",
".",
"$",
"file",
";",
"$",
"media",
"[",
"'type'",
"]",
"=",
"'image'",
";",
"$",
"media",
"[",
"'rID'",
"]",
"=",
"$",
"rID",
";",
"self",
"::",
"$",
"_headerMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"=",
"$",
"media",
";",
"return",
"$",
"rID",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"_headerMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"[",
"'rID'",
"]",
";",
"}",
"}"
]
| Add new Header Media Element
@param int $headerCount
@param string $src
@return int | [
"Add",
"new",
"Header",
"Media",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L197-L238 |
18,952 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Media.php | PHPWord_Media.addFooterMediaElement | public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = 'footer'.$footerCount;
if(!array_key_exists($key, self::$_footerMedia)) {
self::$_footerMedia[$key] = array();
}
if(!array_key_exists($mediaId, self::$_footerMedia[$key])) {
$cImg = self::countFooterMediaElements($key);
$rID = $cImg + 1;
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
$media = array();
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$file = 'image'.$cImg.'.'.strtolower($ext);
$media['source'] = $src;
$media['target'] = 'media/'.$key.'_'.$file;
$media['type'] = 'image';
$media['rID'] = $rID;
self::$_footerMedia[$key][$mediaId] = $media;
return $rID;
} else {
return self::$_footerMedia[$key][$mediaId]['rID'];
}
} | php | public static function addFooterMediaElement($footerCount, $src, PHPWord_Section_MemoryImage $memoryImage = null) {
$mediaId = md5($src);
$key = 'footer'.$footerCount;
if(!array_key_exists($key, self::$_footerMedia)) {
self::$_footerMedia[$key] = array();
}
if(!array_key_exists($mediaId, self::$_footerMedia[$key])) {
$cImg = self::countFooterMediaElements($key);
$rID = $cImg + 1;
$cImg++;
$inf = pathinfo($src);
$isMemImage = (substr(strtolower($inf['extension']), 0, 3) == 'php') ? true : false;
$media = array();
if($isMemImage) {
$ext = $memoryImage->getImageExtension();
$media['isMemImage'] = true;
$media['createfunction'] = $memoryImage->getImageCreateFunction();
$media['imagefunction'] = $memoryImage->getImageFunction();
} else {
$ext = $inf['extension'];
if($ext == 'jpeg') { // Office crashes when adding a jpEg Image, so rename to jpg
$ext = 'jpg';
}
}
$file = 'image'.$cImg.'.'.strtolower($ext);
$media['source'] = $src;
$media['target'] = 'media/'.$key.'_'.$file;
$media['type'] = 'image';
$media['rID'] = $rID;
self::$_footerMedia[$key][$mediaId] = $media;
return $rID;
} else {
return self::$_footerMedia[$key][$mediaId]['rID'];
}
} | [
"public",
"static",
"function",
"addFooterMediaElement",
"(",
"$",
"footerCount",
",",
"$",
"src",
",",
"PHPWord_Section_MemoryImage",
"$",
"memoryImage",
"=",
"null",
")",
"{",
"$",
"mediaId",
"=",
"md5",
"(",
"$",
"src",
")",
";",
"$",
"key",
"=",
"'footer'",
".",
"$",
"footerCount",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"self",
"::",
"$",
"_footerMedia",
")",
")",
"{",
"self",
"::",
"$",
"_footerMedia",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"mediaId",
",",
"self",
"::",
"$",
"_footerMedia",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"cImg",
"=",
"self",
"::",
"countFooterMediaElements",
"(",
"$",
"key",
")",
";",
"$",
"rID",
"=",
"$",
"cImg",
"+",
"1",
";",
"$",
"cImg",
"++",
";",
"$",
"inf",
"=",
"pathinfo",
"(",
"$",
"src",
")",
";",
"$",
"isMemImage",
"=",
"(",
"substr",
"(",
"strtolower",
"(",
"$",
"inf",
"[",
"'extension'",
"]",
")",
",",
"0",
",",
"3",
")",
"==",
"'php'",
")",
"?",
"true",
":",
"false",
";",
"$",
"media",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"isMemImage",
")",
"{",
"$",
"ext",
"=",
"$",
"memoryImage",
"->",
"getImageExtension",
"(",
")",
";",
"$",
"media",
"[",
"'isMemImage'",
"]",
"=",
"true",
";",
"$",
"media",
"[",
"'createfunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageCreateFunction",
"(",
")",
";",
"$",
"media",
"[",
"'imagefunction'",
"]",
"=",
"$",
"memoryImage",
"->",
"getImageFunction",
"(",
")",
";",
"}",
"else",
"{",
"$",
"ext",
"=",
"$",
"inf",
"[",
"'extension'",
"]",
";",
"if",
"(",
"$",
"ext",
"==",
"'jpeg'",
")",
"{",
"// Office crashes when adding a jpEg Image, so rename to jpg\r",
"$",
"ext",
"=",
"'jpg'",
";",
"}",
"}",
"$",
"file",
"=",
"'image'",
".",
"$",
"cImg",
".",
"'.'",
".",
"strtolower",
"(",
"$",
"ext",
")",
";",
"$",
"media",
"[",
"'source'",
"]",
"=",
"$",
"src",
";",
"$",
"media",
"[",
"'target'",
"]",
"=",
"'media/'",
".",
"$",
"key",
".",
"'_'",
".",
"$",
"file",
";",
"$",
"media",
"[",
"'type'",
"]",
"=",
"'image'",
";",
"$",
"media",
"[",
"'rID'",
"]",
"=",
"$",
"rID",
";",
"self",
"::",
"$",
"_footerMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"=",
"$",
"media",
";",
"return",
"$",
"rID",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"_footerMedia",
"[",
"$",
"key",
"]",
"[",
"$",
"mediaId",
"]",
"[",
"'rID'",
"]",
";",
"}",
"}"
]
| Add new Footer Media Element
@param int $footerCount
@param string $src
@return int | [
"Add",
"new",
"Footer",
"Media",
"Element"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Media.php#L266-L307 |
18,953 | lode/fem | src/build.php | build.database_dump_structure | public static function database_dump_structure($dump_directory) {
if (is_dir($dump_directory) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('directory not found');
}
$mysql = bootstrap::get_library('mysql');
$tables = $mysql::select($mysql::AS_ARRAY, "SHOW TABLES;");
foreach ($tables as $table) {
$table_name = current($table);
$drop = "DROP TABLE IF EXISTS `".$table_name."`;";
$dump = $mysql::select($mysql::AS_ROW, "SHOW CREATE TABLE `%s`;", $table_name);
// structure should be w/o references to data
$dump = $dump['Create Table'];
$dump = preg_replace('{ AUTO_INCREMENT=[0-9]+}i', '', $dump);
$full_dump = $drop."\n\n".$dump.";\n";
file_put_contents($dump_directory.'/'.$table_name.'.sql', $full_dump);
}
} | php | public static function database_dump_structure($dump_directory) {
if (is_dir($dump_directory) == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('directory not found');
}
$mysql = bootstrap::get_library('mysql');
$tables = $mysql::select($mysql::AS_ARRAY, "SHOW TABLES;");
foreach ($tables as $table) {
$table_name = current($table);
$drop = "DROP TABLE IF EXISTS `".$table_name."`;";
$dump = $mysql::select($mysql::AS_ROW, "SHOW CREATE TABLE `%s`;", $table_name);
// structure should be w/o references to data
$dump = $dump['Create Table'];
$dump = preg_replace('{ AUTO_INCREMENT=[0-9]+}i', '', $dump);
$full_dump = $drop."\n\n".$dump.";\n";
file_put_contents($dump_directory.'/'.$table_name.'.sql', $full_dump);
}
} | [
"public",
"static",
"function",
"database_dump_structure",
"(",
"$",
"dump_directory",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dump_directory",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'directory not found'",
")",
";",
"}",
"$",
"mysql",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'mysql'",
")",
";",
"$",
"tables",
"=",
"$",
"mysql",
"::",
"select",
"(",
"$",
"mysql",
"::",
"AS_ARRAY",
",",
"\"SHOW TABLES;\"",
")",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"$",
"table_name",
"=",
"current",
"(",
"$",
"table",
")",
";",
"$",
"drop",
"=",
"\"DROP TABLE IF EXISTS `\"",
".",
"$",
"table_name",
".",
"\"`;\"",
";",
"$",
"dump",
"=",
"$",
"mysql",
"::",
"select",
"(",
"$",
"mysql",
"::",
"AS_ROW",
",",
"\"SHOW CREATE TABLE `%s`;\"",
",",
"$",
"table_name",
")",
";",
"// structure should be w/o references to data",
"$",
"dump",
"=",
"$",
"dump",
"[",
"'Create Table'",
"]",
";",
"$",
"dump",
"=",
"preg_replace",
"(",
"'{ AUTO_INCREMENT=[0-9]+}i'",
",",
"''",
",",
"$",
"dump",
")",
";",
"$",
"full_dump",
"=",
"$",
"drop",
".",
"\"\\n\\n\"",
".",
"$",
"dump",
".",
"\";\\n\"",
";",
"file_put_contents",
"(",
"$",
"dump_directory",
".",
"'/'",
".",
"$",
"table_name",
".",
"'.sql'",
",",
"$",
"full_dump",
")",
";",
"}",
"}"
]
| dumps create table statements per table in the specified path
@param string $dump_directory directory to be filled with tablename.sql files
@return void | [
"dumps",
"create",
"table",
"statements",
"per",
"table",
"in",
"the",
"specified",
"path"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/build.php#L13-L35 |
18,954 | lode/fem | src/build.php | build.check_composer_updates | public static function check_composer_updates() {
$composer_json = file_get_contents(ROOT_DIR.'/composer.json');
$composer_json = json_decode($composer_json, true);
if (empty($composer_json['require'])) {
$exception = bootstrap::get_library('exception');
throw new $exception('there are no required packages to check');
}
$composer_lock = file_get_contents(ROOT_DIR.'/composer.lock');
$composer_lock = json_decode($composer_lock, true);
if (empty($composer_lock['packages'])) {
$exception = bootstrap::get_library('exception');
throw new $exception('lock file is missing its packages');
}
$composer_executable = 'composer';
if (file_exists(ROOT_DIR.'composer.phar')) {
$composer_executable = 'php composer.phar';
}
$required_packages = $composer_json['require'];
$installed_packages = $composer_lock['packages'];
$update_packages = [];
foreach ($installed_packages as $installed_package) {
$package_name = $installed_package['name'];
$installed_version = preg_replace('/v([0-9].*)/', '$1', $installed_package['version']);
$version_regex = '/versions\s*:.+v?([0-9]+\.[0-9]+(\.[0-9]+)?)(,|$)/U';
// skip dependencies of dependencies
if (empty($required_packages[$package_name])) {
continue;
}
// check commit hash for dev-* versions
if (strpos($installed_version, 'dev-') === 0) {
$installed_version = $installed_package['source']['reference'];
$version_regex = '/source\s*:.+ ([a-f0-9]{40})$/m';
}
// find out the newest release
$package_info = shell_exec($composer_executable.' show -a '.escapeshellarg($package_name));
preg_match($version_regex, $package_info, $possible_version);
if (empty($possible_version)) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not find out newest release for '.$package_name);
}
if (ENVIRONMENT == 'development') {
echo 'installed '.$package_name.' at '.$installed_version.', possible version is '.$possible_version[1].PHP_EOL;
}
if ($possible_version[1] == $installed_version) {
continue;
}
$update_packages[$package_name] = [
'required' => $required_packages[$package_name],
'installed' => $installed_version,
'possible' => $possible_version[1],
];
}
return $update_packages;
} | php | public static function check_composer_updates() {
$composer_json = file_get_contents(ROOT_DIR.'/composer.json');
$composer_json = json_decode($composer_json, true);
if (empty($composer_json['require'])) {
$exception = bootstrap::get_library('exception');
throw new $exception('there are no required packages to check');
}
$composer_lock = file_get_contents(ROOT_DIR.'/composer.lock');
$composer_lock = json_decode($composer_lock, true);
if (empty($composer_lock['packages'])) {
$exception = bootstrap::get_library('exception');
throw new $exception('lock file is missing its packages');
}
$composer_executable = 'composer';
if (file_exists(ROOT_DIR.'composer.phar')) {
$composer_executable = 'php composer.phar';
}
$required_packages = $composer_json['require'];
$installed_packages = $composer_lock['packages'];
$update_packages = [];
foreach ($installed_packages as $installed_package) {
$package_name = $installed_package['name'];
$installed_version = preg_replace('/v([0-9].*)/', '$1', $installed_package['version']);
$version_regex = '/versions\s*:.+v?([0-9]+\.[0-9]+(\.[0-9]+)?)(,|$)/U';
// skip dependencies of dependencies
if (empty($required_packages[$package_name])) {
continue;
}
// check commit hash for dev-* versions
if (strpos($installed_version, 'dev-') === 0) {
$installed_version = $installed_package['source']['reference'];
$version_regex = '/source\s*:.+ ([a-f0-9]{40})$/m';
}
// find out the newest release
$package_info = shell_exec($composer_executable.' show -a '.escapeshellarg($package_name));
preg_match($version_regex, $package_info, $possible_version);
if (empty($possible_version)) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not find out newest release for '.$package_name);
}
if (ENVIRONMENT == 'development') {
echo 'installed '.$package_name.' at '.$installed_version.', possible version is '.$possible_version[1].PHP_EOL;
}
if ($possible_version[1] == $installed_version) {
continue;
}
$update_packages[$package_name] = [
'required' => $required_packages[$package_name],
'installed' => $installed_version,
'possible' => $possible_version[1],
];
}
return $update_packages;
} | [
"public",
"static",
"function",
"check_composer_updates",
"(",
")",
"{",
"$",
"composer_json",
"=",
"file_get_contents",
"(",
"ROOT_DIR",
".",
"'/composer.json'",
")",
";",
"$",
"composer_json",
"=",
"json_decode",
"(",
"$",
"composer_json",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"composer_json",
"[",
"'require'",
"]",
")",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'there are no required packages to check'",
")",
";",
"}",
"$",
"composer_lock",
"=",
"file_get_contents",
"(",
"ROOT_DIR",
".",
"'/composer.lock'",
")",
";",
"$",
"composer_lock",
"=",
"json_decode",
"(",
"$",
"composer_lock",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"composer_lock",
"[",
"'packages'",
"]",
")",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'lock file is missing its packages'",
")",
";",
"}",
"$",
"composer_executable",
"=",
"'composer'",
";",
"if",
"(",
"file_exists",
"(",
"ROOT_DIR",
".",
"'composer.phar'",
")",
")",
"{",
"$",
"composer_executable",
"=",
"'php composer.phar'",
";",
"}",
"$",
"required_packages",
"=",
"$",
"composer_json",
"[",
"'require'",
"]",
";",
"$",
"installed_packages",
"=",
"$",
"composer_lock",
"[",
"'packages'",
"]",
";",
"$",
"update_packages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"installed_packages",
"as",
"$",
"installed_package",
")",
"{",
"$",
"package_name",
"=",
"$",
"installed_package",
"[",
"'name'",
"]",
";",
"$",
"installed_version",
"=",
"preg_replace",
"(",
"'/v([0-9].*)/'",
",",
"'$1'",
",",
"$",
"installed_package",
"[",
"'version'",
"]",
")",
";",
"$",
"version_regex",
"=",
"'/versions\\s*:.+v?([0-9]+\\.[0-9]+(\\.[0-9]+)?)(,|$)/U'",
";",
"// skip dependencies of dependencies",
"if",
"(",
"empty",
"(",
"$",
"required_packages",
"[",
"$",
"package_name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"// check commit hash for dev-* versions",
"if",
"(",
"strpos",
"(",
"$",
"installed_version",
",",
"'dev-'",
")",
"===",
"0",
")",
"{",
"$",
"installed_version",
"=",
"$",
"installed_package",
"[",
"'source'",
"]",
"[",
"'reference'",
"]",
";",
"$",
"version_regex",
"=",
"'/source\\s*:.+ ([a-f0-9]{40})$/m'",
";",
"}",
"// find out the newest release",
"$",
"package_info",
"=",
"shell_exec",
"(",
"$",
"composer_executable",
".",
"' show -a '",
".",
"escapeshellarg",
"(",
"$",
"package_name",
")",
")",
";",
"preg_match",
"(",
"$",
"version_regex",
",",
"$",
"package_info",
",",
"$",
"possible_version",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"possible_version",
")",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'can not find out newest release for '",
".",
"$",
"package_name",
")",
";",
"}",
"if",
"(",
"ENVIRONMENT",
"==",
"'development'",
")",
"{",
"echo",
"'installed '",
".",
"$",
"package_name",
".",
"' at '",
".",
"$",
"installed_version",
".",
"', possible version is '",
".",
"$",
"possible_version",
"[",
"1",
"]",
".",
"PHP_EOL",
";",
"}",
"if",
"(",
"$",
"possible_version",
"[",
"1",
"]",
"==",
"$",
"installed_version",
")",
"{",
"continue",
";",
"}",
"$",
"update_packages",
"[",
"$",
"package_name",
"]",
"=",
"[",
"'required'",
"=>",
"$",
"required_packages",
"[",
"$",
"package_name",
"]",
",",
"'installed'",
"=>",
"$",
"installed_version",
",",
"'possible'",
"=>",
"$",
"possible_version",
"[",
"1",
"]",
",",
"]",
";",
"}",
"return",
"$",
"update_packages",
";",
"}"
]
| checks composer packages for new releases since the installed version
@todo check if the required version is significantly off
which would mean the json needs to change to be able to update
@return array {
@var $required
@var $installed
@var $possible
} | [
"checks",
"composer",
"packages",
"for",
"new",
"releases",
"since",
"the",
"installed",
"version"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/build.php#L49-L113 |
18,955 | alanpich/slender | src/Core/ModuleResolver/ResolverStack.php | ResolverStack.getConfig | public function getConfig($module)
{
if (!isset($this->cache['paths'][$module])) {
$path = $this->getPath($module);
$file = $path.DIRECTORY_SEPARATOR.'slender.yml';
$parsed = $this->parser->parseFile($file);
$parsed['path'] = $path;
$this->cache['paths'][$module] = $parsed;
}
return $this->cache['paths'][$module];
} | php | public function getConfig($module)
{
if (!isset($this->cache['paths'][$module])) {
$path = $this->getPath($module);
$file = $path.DIRECTORY_SEPARATOR.'slender.yml';
$parsed = $this->parser->parseFile($file);
$parsed['path'] = $path;
$this->cache['paths'][$module] = $parsed;
}
return $this->cache['paths'][$module];
} | [
"public",
"function",
"getConfig",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'paths'",
"]",
"[",
"$",
"module",
"]",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"module",
")",
";",
"$",
"file",
"=",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"'slender.yml'",
";",
"$",
"parsed",
"=",
"$",
"this",
"->",
"parser",
"->",
"parseFile",
"(",
"$",
"file",
")",
";",
"$",
"parsed",
"[",
"'path'",
"]",
"=",
"$",
"path",
";",
"$",
"this",
"->",
"cache",
"[",
"'paths'",
"]",
"[",
"$",
"module",
"]",
"=",
"$",
"parsed",
";",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'paths'",
"]",
"[",
"$",
"module",
"]",
";",
"}"
]
| Return parsed config file for module
@param $module
@return mixed | [
"Return",
"parsed",
"config",
"file",
"for",
"module"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleResolver/ResolverStack.php#L118-L129 |
18,956 | php-rise/rise | src/Request.php | Request.getHttpVersion | public function getHttpVersion() {
if (!isset($this->httpVersion)) {
$serverProtocol = $_SERVER['SERVER_PROTOCOL'];
$this->httpVersion = substr($serverProtocol, strpos($serverProtocol, '/') + 1);
}
return $this->httpVersion;
} | php | public function getHttpVersion() {
if (!isset($this->httpVersion)) {
$serverProtocol = $_SERVER['SERVER_PROTOCOL'];
$this->httpVersion = substr($serverProtocol, strpos($serverProtocol, '/') + 1);
}
return $this->httpVersion;
} | [
"public",
"function",
"getHttpVersion",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"httpVersion",
")",
")",
"{",
"$",
"serverProtocol",
"=",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
";",
"$",
"this",
"->",
"httpVersion",
"=",
"substr",
"(",
"$",
"serverProtocol",
",",
"strpos",
"(",
"$",
"serverProtocol",
",",
"'/'",
")",
"+",
"1",
")",
";",
"}",
"return",
"$",
"this",
"->",
"httpVersion",
";",
"}"
]
| Get request HTTP version.
@return string | [
"Get",
"request",
"HTTP",
"version",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Request.php#L80-L86 |
18,957 | php-rise/rise | src/Request.php | Request.getHost | public function getHost() {
if (!is_null($this->host)) {
return $this->host;
}
if ($_SERVER['HTTP_X_FORWARDED_HOST']) {
$elements = explode(',', $value);
$host = trim(end($elements));
} else if ($_SERVER['HTTP_HOST']) {
$host = $_SERVER['HTTP_HOST'];
} else if ($_SERVER['SERVER_NAME']) {
$host = $_SERVER['SERVER_NAME'];
}
if (isset($host)) {
$host = preg_replace('/:\d+$/', '', $host);
$this->host = $host;
}
return $this->host;
} | php | public function getHost() {
if (!is_null($this->host)) {
return $this->host;
}
if ($_SERVER['HTTP_X_FORWARDED_HOST']) {
$elements = explode(',', $value);
$host = trim(end($elements));
} else if ($_SERVER['HTTP_HOST']) {
$host = $_SERVER['HTTP_HOST'];
} else if ($_SERVER['SERVER_NAME']) {
$host = $_SERVER['SERVER_NAME'];
}
if (isset($host)) {
$host = preg_replace('/:\d+$/', '', $host);
$this->host = $host;
}
return $this->host;
} | [
"public",
"function",
"getHost",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"host",
")",
")",
"{",
"return",
"$",
"this",
"->",
"host",
";",
"}",
"if",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_HOST'",
"]",
")",
"{",
"$",
"elements",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"$",
"host",
"=",
"trim",
"(",
"end",
"(",
"$",
"elements",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
"{",
"$",
"host",
"=",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
")",
"{",
"$",
"host",
"=",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"host",
")",
")",
"{",
"$",
"host",
"=",
"preg_replace",
"(",
"'/:\\d+$/'",
",",
"''",
",",
"$",
"host",
")",
";",
"$",
"this",
"->",
"host",
"=",
"$",
"host",
";",
"}",
"return",
"$",
"this",
"->",
"host",
";",
"}"
]
| Get HTTP host.
@return string | [
"Get",
"HTTP",
"host",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Request.php#L130-L150 |
18,958 | php-rise/rise | src/Request.php | Request.getContentType | public function getContentType() {
if (!isset($this->contentType)) {
$numOfMatches = preg_match('/^([^;]*)/', $this->getHeader('Content-Type'), $matches);
if ($numOfMatches) {
$this->contentType = trim($matches[1]);
} else {
$this->contentType = '';
}
}
return $this->contentType;
} | php | public function getContentType() {
if (!isset($this->contentType)) {
$numOfMatches = preg_match('/^([^;]*)/', $this->getHeader('Content-Type'), $matches);
if ($numOfMatches) {
$this->contentType = trim($matches[1]);
} else {
$this->contentType = '';
}
}
return $this->contentType;
} | [
"public",
"function",
"getContentType",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"contentType",
")",
")",
"{",
"$",
"numOfMatches",
"=",
"preg_match",
"(",
"'/^([^;]*)/'",
",",
"$",
"this",
"->",
"getHeader",
"(",
"'Content-Type'",
")",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"numOfMatches",
")",
"{",
"$",
"this",
"->",
"contentType",
"=",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"contentType",
"=",
"''",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"contentType",
";",
"}"
]
| Get content type.
@return string | [
"Get",
"content",
"type",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Request.php#L174-L184 |
18,959 | php-rise/rise | src/Request.php | Request.getInput | public function getInput() {
if (!isset($this->input)) {
switch ($this->method) {
case 'POST':
switch ($this->getContentType()) {
case 'application/x-www-form-urlencoded':
case 'multipart/form-data':
$this->input = $_POST;
break;
default:
$this->input = $this->getParamsFromInput();
break;
}
break;
case 'PUT':
case 'DELETE':
$this->input = $this->getParamsFromInput();
break;
default:
$this->input = [];
break;
}
}
return $this->input;
} | php | public function getInput() {
if (!isset($this->input)) {
switch ($this->method) {
case 'POST':
switch ($this->getContentType()) {
case 'application/x-www-form-urlencoded':
case 'multipart/form-data':
$this->input = $_POST;
break;
default:
$this->input = $this->getParamsFromInput();
break;
}
break;
case 'PUT':
case 'DELETE':
$this->input = $this->getParamsFromInput();
break;
default:
$this->input = [];
break;
}
}
return $this->input;
} | [
"public",
"function",
"getInput",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"input",
")",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"method",
")",
"{",
"case",
"'POST'",
":",
"switch",
"(",
"$",
"this",
"->",
"getContentType",
"(",
")",
")",
"{",
"case",
"'application/x-www-form-urlencoded'",
":",
"case",
"'multipart/form-data'",
":",
"$",
"this",
"->",
"input",
"=",
"$",
"_POST",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"input",
"=",
"$",
"this",
"->",
"getParamsFromInput",
"(",
")",
";",
"break",
";",
"}",
"break",
";",
"case",
"'PUT'",
":",
"case",
"'DELETE'",
":",
"$",
"this",
"->",
"input",
"=",
"$",
"this",
"->",
"getParamsFromInput",
"(",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"input",
"=",
"[",
"]",
";",
"break",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"input",
";",
"}"
]
| Return HTTP POST, PUT or DELETE variables.
@return array | [
"Return",
"HTTP",
"POST",
"PUT",
"or",
"DELETE",
"variables",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Request.php#L217-L245 |
18,960 | alanpich/slender | src/Core/DependencyInjector/DependencyInjector.php | DependencyInjector.getDiRequirements | public function getDiRequirements($className)
{
if (!isset($this->classCache[$className])) {
$reflectionClass = new \ReflectionClass($className);
$injects = [];
// get all defined properties
$props = $reflectionClass->getProperties();
foreach ($props as $prop) {
$inject = $this->annotationReader->getPropertyAnnotation(
$prop,
'Slender\Core\DependencyInjector\Annotation\Inject'
);
if ($inject) {
// Get the DI identifier
$identifier = $inject->getIdentifier();
if (!$identifier) {
$identifier = Util::hyphenCase($prop->getName());
}
$data = array(
'identifier' => $identifier,
'isPublic' => $prop->isPublic(),
'setter' => false
);
// Is there a setter method (cos its still faster andrew...)
if (!$prop->isPublic()) {
$setter = Util::setterMethodName($prop->getName());
if (method_exists($className, $setter)) {
$data['hasSetter'] = $setter;
};
};
$injects[$prop->getName()] = $data;
}
}
$this->classCache[$className] = $injects;
}
return $this->classCache[$className];
} | php | public function getDiRequirements($className)
{
if (!isset($this->classCache[$className])) {
$reflectionClass = new \ReflectionClass($className);
$injects = [];
// get all defined properties
$props = $reflectionClass->getProperties();
foreach ($props as $prop) {
$inject = $this->annotationReader->getPropertyAnnotation(
$prop,
'Slender\Core\DependencyInjector\Annotation\Inject'
);
if ($inject) {
// Get the DI identifier
$identifier = $inject->getIdentifier();
if (!$identifier) {
$identifier = Util::hyphenCase($prop->getName());
}
$data = array(
'identifier' => $identifier,
'isPublic' => $prop->isPublic(),
'setter' => false
);
// Is there a setter method (cos its still faster andrew...)
if (!$prop->isPublic()) {
$setter = Util::setterMethodName($prop->getName());
if (method_exists($className, $setter)) {
$data['hasSetter'] = $setter;
};
};
$injects[$prop->getName()] = $data;
}
}
$this->classCache[$className] = $injects;
}
return $this->classCache[$className];
} | [
"public",
"function",
"getDiRequirements",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"classCache",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"injects",
"=",
"[",
"]",
";",
"// get all defined properties",
"$",
"props",
"=",
"$",
"reflectionClass",
"->",
"getProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"props",
"as",
"$",
"prop",
")",
"{",
"$",
"inject",
"=",
"$",
"this",
"->",
"annotationReader",
"->",
"getPropertyAnnotation",
"(",
"$",
"prop",
",",
"'Slender\\Core\\DependencyInjector\\Annotation\\Inject'",
")",
";",
"if",
"(",
"$",
"inject",
")",
"{",
"// Get the DI identifier",
"$",
"identifier",
"=",
"$",
"inject",
"->",
"getIdentifier",
"(",
")",
";",
"if",
"(",
"!",
"$",
"identifier",
")",
"{",
"$",
"identifier",
"=",
"Util",
"::",
"hyphenCase",
"(",
"$",
"prop",
"->",
"getName",
"(",
")",
")",
";",
"}",
"$",
"data",
"=",
"array",
"(",
"'identifier'",
"=>",
"$",
"identifier",
",",
"'isPublic'",
"=>",
"$",
"prop",
"->",
"isPublic",
"(",
")",
",",
"'setter'",
"=>",
"false",
")",
";",
"// Is there a setter method (cos its still faster andrew...)",
"if",
"(",
"!",
"$",
"prop",
"->",
"isPublic",
"(",
")",
")",
"{",
"$",
"setter",
"=",
"Util",
"::",
"setterMethodName",
"(",
"$",
"prop",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"className",
",",
"$",
"setter",
")",
")",
"{",
"$",
"data",
"[",
"'hasSetter'",
"]",
"=",
"$",
"setter",
";",
"}",
";",
"}",
";",
"$",
"injects",
"[",
"$",
"prop",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"data",
";",
"}",
"}",
"$",
"this",
"->",
"classCache",
"[",
"$",
"className",
"]",
"=",
"$",
"injects",
";",
"}",
"return",
"$",
"this",
"->",
"classCache",
"[",
"$",
"className",
"]",
";",
"}"
]
| Interrogate a class and see what dependencies
it wants to be passed into its constructor
@param string $className Name of class to inspece
@return array of DI container identifiers | [
"Interrogate",
"a",
"class",
"and",
"see",
"what",
"dependencies",
"it",
"wants",
"to",
"be",
"passed",
"into",
"its",
"constructor"
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/DependencyInjector/DependencyInjector.php#L84-L124 |
18,961 | alanpich/slender | src/Core/DependencyInjector/DependencyInjector.php | DependencyInjector.prepare | public function prepare(&$instance)
{
$requirements = $this->getDiRequirements(get_class($instance));
foreach ($requirements as $propertyName => $property) {
$dependencyIdentifier = $property['identifier'];
$dependency = $this->container[$dependencyIdentifier];
if (!isset($this->container[$dependencyIdentifier])) {
throw new \InvalidArgumentException("Unable to resolve dependency $dependencyIdentifier for injection");
}
if ($property['isPublic']) {
// If its public, just set it!
$instance->$propertyName = $dependency;
} else {
if ($property['setter']) {
// If there is a setter method, use that
call_user_func($instance, $property['setter'], $dependency);
} else {
// Otherwise set by brute force
$refl = new \ReflectionClass($instance);
$prop = $refl->getProperty($propertyName);
$prop->setAccessible(true);
$prop->setValue($instance, $this->container[$dependencyIdentifier]);
$prop->setAccessible(false);
}
}
}
} | php | public function prepare(&$instance)
{
$requirements = $this->getDiRequirements(get_class($instance));
foreach ($requirements as $propertyName => $property) {
$dependencyIdentifier = $property['identifier'];
$dependency = $this->container[$dependencyIdentifier];
if (!isset($this->container[$dependencyIdentifier])) {
throw new \InvalidArgumentException("Unable to resolve dependency $dependencyIdentifier for injection");
}
if ($property['isPublic']) {
// If its public, just set it!
$instance->$propertyName = $dependency;
} else {
if ($property['setter']) {
// If there is a setter method, use that
call_user_func($instance, $property['setter'], $dependency);
} else {
// Otherwise set by brute force
$refl = new \ReflectionClass($instance);
$prop = $refl->getProperty($propertyName);
$prop->setAccessible(true);
$prop->setValue($instance, $this->container[$dependencyIdentifier]);
$prop->setAccessible(false);
}
}
}
} | [
"public",
"function",
"prepare",
"(",
"&",
"$",
"instance",
")",
"{",
"$",
"requirements",
"=",
"$",
"this",
"->",
"getDiRequirements",
"(",
"get_class",
"(",
"$",
"instance",
")",
")",
";",
"foreach",
"(",
"$",
"requirements",
"as",
"$",
"propertyName",
"=>",
"$",
"property",
")",
"{",
"$",
"dependencyIdentifier",
"=",
"$",
"property",
"[",
"'identifier'",
"]",
";",
"$",
"dependency",
"=",
"$",
"this",
"->",
"container",
"[",
"$",
"dependencyIdentifier",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"container",
"[",
"$",
"dependencyIdentifier",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unable to resolve dependency $dependencyIdentifier for injection\"",
")",
";",
"}",
"if",
"(",
"$",
"property",
"[",
"'isPublic'",
"]",
")",
"{",
"// If its public, just set it!",
"$",
"instance",
"->",
"$",
"propertyName",
"=",
"$",
"dependency",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"property",
"[",
"'setter'",
"]",
")",
"{",
"// If there is a setter method, use that",
"call_user_func",
"(",
"$",
"instance",
",",
"$",
"property",
"[",
"'setter'",
"]",
",",
"$",
"dependency",
")",
";",
"}",
"else",
"{",
"// Otherwise set by brute force",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"instance",
")",
";",
"$",
"prop",
"=",
"$",
"refl",
"->",
"getProperty",
"(",
"$",
"propertyName",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"prop",
"->",
"setValue",
"(",
"$",
"instance",
",",
"$",
"this",
"->",
"container",
"[",
"$",
"dependencyIdentifier",
"]",
")",
";",
"$",
"prop",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}",
"}",
"}"
]
| Scan a class instance for injectable dependencies,
and inject them if found, then return prepared instance.
@param object $instance Class instance to prepare
@throws \RuntimeException
@throws \InvalidArgumentException | [
"Scan",
"a",
"class",
"instance",
"for",
"injectable",
"dependencies",
"and",
"inject",
"them",
"if",
"found",
"then",
"return",
"prepared",
"instance",
"."
]
| 247f5c08af20cda95b116eb5d9f6f623d61e8a8a | https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/DependencyInjector/DependencyInjector.php#L135-L167 |
18,962 | aedart/laravel-helpers | src/Traits/Auth/AuthFactoryTrait.php | AuthFactoryTrait.getAuthFactory | public function getAuthFactory(): ?Factory
{
if (!$this->hasAuthFactory()) {
$this->setAuthFactory($this->getDefaultAuthFactory());
}
return $this->authFactory;
} | php | public function getAuthFactory(): ?Factory
{
if (!$this->hasAuthFactory()) {
$this->setAuthFactory($this->getDefaultAuthFactory());
}
return $this->authFactory;
} | [
"public",
"function",
"getAuthFactory",
"(",
")",
":",
"?",
"Factory",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAuthFactory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setAuthFactory",
"(",
"$",
"this",
"->",
"getDefaultAuthFactory",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"authFactory",
";",
"}"
]
| Get auth factory
If no auth factory has been set, this method will
set and return a default auth factory, if any such
value is available
@see getDefaultAuthFactory()
@return Factory|null auth factory or null if none auth factory has been set | [
"Get",
"auth",
"factory"
]
| 8b81a2d6658f3f8cb62b6be2c34773aaa2df219a | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/AuthFactoryTrait.php#L53-L59 |
18,963 | tigris-php/telegram-bot-api | src/Types/Base/BaseObject.php | BaseObject.build | public static function build(array $values)
{
$result = new static;
foreach ($values as $field => $value) {
/** @var $className TypeInterface */
$result->$field = $value;
}
return $result;
} | php | public static function build(array $values)
{
$result = new static;
foreach ($values as $field => $value) {
/** @var $className TypeInterface */
$result->$field = $value;
}
return $result;
} | [
"public",
"static",
"function",
"build",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"result",
"=",
"new",
"static",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"/** @var $className TypeInterface */",
"$",
"result",
"->",
"$",
"field",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Builds object from array of field values indexed by field name.
@param array $values
@return static | [
"Builds",
"object",
"from",
"array",
"of",
"field",
"values",
"indexed",
"by",
"field",
"name",
"."
]
| 7350c81d571387005d58079d8c654ee44504cdcf | https://github.com/tigris-php/telegram-bot-api/blob/7350c81d571387005d58079d8c654ee44504cdcf/src/Types/Base/BaseObject.php#L40-L50 |
18,964 | steeffeen/FancyManiaLinks | FML/Script/Features/GraphSettings.php | GraphSettings.getOnInitScriptText | protected function getOnInitScriptText()
{
$scriptText = "";
if ($this->minimumCoordinates) {
$minimumCoordinatesValue = Builder::getVec2($this->minimumCoordinates);
$scriptText .= "
Graph.CoordsMin = {$minimumCoordinatesValue};";
}
if ($this->maximumCoordinates) {
$maximumCoordinatesValue = Builder::getVec2($this->maximumCoordinates);
$scriptText .= "
Graph.CoordsMax = {$maximumCoordinatesValue};";
}
return $scriptText;
} | php | protected function getOnInitScriptText()
{
$scriptText = "";
if ($this->minimumCoordinates) {
$minimumCoordinatesValue = Builder::getVec2($this->minimumCoordinates);
$scriptText .= "
Graph.CoordsMin = {$minimumCoordinatesValue};";
}
if ($this->maximumCoordinates) {
$maximumCoordinatesValue = Builder::getVec2($this->maximumCoordinates);
$scriptText .= "
Graph.CoordsMax = {$maximumCoordinatesValue};";
}
return $scriptText;
} | [
"protected",
"function",
"getOnInitScriptText",
"(",
")",
"{",
"$",
"scriptText",
"=",
"\"\"",
";",
"if",
"(",
"$",
"this",
"->",
"minimumCoordinates",
")",
"{",
"$",
"minimumCoordinatesValue",
"=",
"Builder",
"::",
"getVec2",
"(",
"$",
"this",
"->",
"minimumCoordinates",
")",
";",
"$",
"scriptText",
".=",
"\"\nGraph.CoordsMin = {$minimumCoordinatesValue};\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"maximumCoordinates",
")",
"{",
"$",
"maximumCoordinatesValue",
"=",
"Builder",
"::",
"getVec2",
"(",
"$",
"this",
"->",
"maximumCoordinates",
")",
";",
"$",
"scriptText",
".=",
"\"\nGraph.CoordsMax = {$maximumCoordinatesValue};\"",
";",
"}",
"return",
"$",
"scriptText",
";",
"}"
]
| Get the on init event script text
@return string | [
"Get",
"the",
"on",
"init",
"event",
"script",
"text"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/GraphSettings.php#L136-L150 |
18,965 | steeffeen/FancyManiaLinks | FML/ManiaLinks.php | ManiaLinks.addChild | public function addChild(ManiaLink $child)
{
if (!in_array($child, $this->children, true)) {
array_push($this->children, $child);
}
return $this;
} | php | public function addChild(ManiaLink $child)
{
if (!in_array($child, $this->children, true)) {
array_push($this->children, $child);
}
return $this;
} | [
"public",
"function",
"addChild",
"(",
"ManiaLink",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"child",
",",
"$",
"this",
"->",
"children",
",",
"true",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"child",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a child ManiaLink
@api
@param ManiaLink $child Child ManiaLink
@return static | [
"Add",
"a",
"child",
"ManiaLink"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLinks.php#L82-L88 |
18,966 | steeffeen/FancyManiaLinks | FML/ManiaLinks.php | ManiaLinks.getCustomUI | public function getCustomUI($createIfEmpty = true)
{
if (!$this->customUI && $createIfEmpty) {
$this->setCustomUI(new CustomUI());
}
return $this->customUI;
} | php | public function getCustomUI($createIfEmpty = true)
{
if (!$this->customUI && $createIfEmpty) {
$this->setCustomUI(new CustomUI());
}
return $this->customUI;
} | [
"public",
"function",
"getCustomUI",
"(",
"$",
"createIfEmpty",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"customUI",
"&&",
"$",
"createIfEmpty",
")",
"{",
"$",
"this",
"->",
"setCustomUI",
"(",
"new",
"CustomUI",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"customUI",
";",
"}"
]
| Get the CustomUI
@api
@param bool $createIfEmpty (optional) If the Custom UI should be created if it doesn't exist yet
@return CustomUI | [
"Get",
"the",
"CustomUI"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLinks.php#L150-L156 |
18,967 | steeffeen/FancyManiaLinks | FML/ManiaLinks.php | ManiaLinks.render | public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$maniaLinks = $domDocument->createElement("manialinks");
$domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) {
$childXml = $child->render(false, $domDocument);
$maniaLinks->appendChild($childXml);
}
if ($this->customUI) {
$customUIElement = $this->customUI->render($domDocument);
$maniaLinks->appendChild($customUIElement);
}
if ($echo) {
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
} | php | public function render($echo = false)
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$maniaLinks = $domDocument->createElement("manialinks");
$domDocument->appendChild($maniaLinks);
foreach ($this->children as $child) {
$childXml = $child->render(false, $domDocument);
$maniaLinks->appendChild($childXml);
}
if ($this->customUI) {
$customUIElement = $this->customUI->render($domDocument);
$maniaLinks->appendChild($customUIElement);
}
if ($echo) {
header("Content-Type: application/xml; charset=utf-8;");
echo $domDocument->saveXML();
}
return $domDocument;
} | [
"public",
"function",
"render",
"(",
"$",
"echo",
"=",
"false",
")",
"{",
"$",
"domDocument",
"=",
"new",
"\\",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
";",
"$",
"domDocument",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"maniaLinks",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"manialinks\"",
")",
";",
"$",
"domDocument",
"->",
"appendChild",
"(",
"$",
"maniaLinks",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"childXml",
"=",
"$",
"child",
"->",
"render",
"(",
"false",
",",
"$",
"domDocument",
")",
";",
"$",
"maniaLinks",
"->",
"appendChild",
"(",
"$",
"childXml",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"customUI",
")",
"{",
"$",
"customUIElement",
"=",
"$",
"this",
"->",
"customUI",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"maniaLinks",
"->",
"appendChild",
"(",
"$",
"customUIElement",
")",
";",
"}",
"if",
"(",
"$",
"echo",
")",
"{",
"header",
"(",
"\"Content-Type: application/xml; charset=utf-8;\"",
")",
";",
"echo",
"$",
"domDocument",
"->",
"saveXML",
"(",
")",
";",
"}",
"return",
"$",
"domDocument",
";",
"}"
]
| Render the ManiaLinks object
@param bool (optional) $echo If the XML text should be echoed and the Content-Type header should be set
@return \DOMDocument | [
"Render",
"the",
"ManiaLinks",
"object"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/ManiaLinks.php#L177-L200 |
18,968 | Double-Opt-in/php-client-api | src/Client/Commands/Responses/Response.php | Response.decoded | protected function decoded()
{
if ($this->json === null) {
/** @var \Guzzle\Http\Message\Header $contentType */
$contentType = (string)$this->response->getHeader('content-type');
if ($contentType === 'application/json')
$this->json = json_decode($this->response->getBody(true));
}
return $this->json;
} | php | protected function decoded()
{
if ($this->json === null) {
/** @var \Guzzle\Http\Message\Header $contentType */
$contentType = (string)$this->response->getHeader('content-type');
if ($contentType === 'application/json')
$this->json = json_decode($this->response->getBody(true));
}
return $this->json;
} | [
"protected",
"function",
"decoded",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"json",
"===",
"null",
")",
"{",
"/** @var \\Guzzle\\Http\\Message\\Header $contentType */",
"$",
"contentType",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"response",
"->",
"getHeader",
"(",
"'content-type'",
")",
";",
"if",
"(",
"$",
"contentType",
"===",
"'application/json'",
")",
"$",
"this",
"->",
"json",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
"true",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"json",
";",
"}"
]
| returns decoded object
@return null|stdClass | [
"returns",
"decoded",
"object"
]
| 2f17da58ec20a408bbd55b2cdd053bc689f995f4 | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Response.php#L82-L92 |
18,969 | Double-Opt-in/php-client-api | src/Client/Commands/Responses/Response.php | Response.errorMessage | public function errorMessage()
{
if ($this->decoded() === null) {
throw new \RuntimeException('No result from server.');
}
$decoded = $this->decoded();
if (isset($decoded->error))
return sprintf('%s (%s)', $decoded->error->message, $decoded->error->code);
$message = sprintf('%s (%s)', $decoded->message, $this->statusCode());
if (isset($this->decoded()->errors)) {
$errors = $this->decoded()->errors;
$message .= $this->resolveAttributes($errors);
}
return $message;
} | php | public function errorMessage()
{
if ($this->decoded() === null) {
throw new \RuntimeException('No result from server.');
}
$decoded = $this->decoded();
if (isset($decoded->error))
return sprintf('%s (%s)', $decoded->error->message, $decoded->error->code);
$message = sprintf('%s (%s)', $decoded->message, $this->statusCode());
if (isset($this->decoded()->errors)) {
$errors = $this->decoded()->errors;
$message .= $this->resolveAttributes($errors);
}
return $message;
} | [
"public",
"function",
"errorMessage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"decoded",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No result from server.'",
")",
";",
"}",
"$",
"decoded",
"=",
"$",
"this",
"->",
"decoded",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"decoded",
"->",
"error",
")",
")",
"return",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"decoded",
"->",
"error",
"->",
"message",
",",
"$",
"decoded",
"->",
"error",
"->",
"code",
")",
";",
"$",
"message",
"=",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"decoded",
"->",
"message",
",",
"$",
"this",
"->",
"statusCode",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"decoded",
"(",
")",
"->",
"errors",
")",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"decoded",
"(",
")",
"->",
"errors",
";",
"$",
"message",
".=",
"$",
"this",
"->",
"resolveAttributes",
"(",
"$",
"errors",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
]
| returns the error message
@return string | [
"returns",
"the",
"error",
"message"
]
| 2f17da58ec20a408bbd55b2cdd053bc689f995f4 | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Response.php#L99-L118 |
18,970 | Double-Opt-in/php-client-api | src/Client/Commands/Responses/Response.php | Response.resolveAttributes | private function resolveAttributes(stdClass $stdClass)
{
$attributes = array('action', 'hash', 'scope', 'data');
$message = '';
foreach ($attributes as $attribute) {
$message .= $this->resolveAttribute($stdClass, $attribute);
}
return $message;
} | php | private function resolveAttributes(stdClass $stdClass)
{
$attributes = array('action', 'hash', 'scope', 'data');
$message = '';
foreach ($attributes as $attribute) {
$message .= $this->resolveAttribute($stdClass, $attribute);
}
return $message;
} | [
"private",
"function",
"resolveAttributes",
"(",
"stdClass",
"$",
"stdClass",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'action'",
",",
"'hash'",
",",
"'scope'",
",",
"'data'",
")",
";",
"$",
"message",
"=",
"''",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"message",
".=",
"$",
"this",
"->",
"resolveAttribute",
"(",
"$",
"stdClass",
",",
"$",
"attribute",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
]
| resolves all known attributes
@param stdClass $stdClass
@return string | [
"resolves",
"all",
"known",
"attributes"
]
| 2f17da58ec20a408bbd55b2cdd053bc689f995f4 | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Response.php#L127-L137 |
18,971 | Double-Opt-in/php-client-api | src/Client/Commands/Responses/Response.php | Response.resolveAttribute | private function resolveAttribute(stdClass $stdClass, $attribute)
{
if (isset($stdClass->$attribute))
return PHP_EOL . sprintf(' %s: %s', $attribute, implode(', ', $stdClass->$attribute));
return '';
} | php | private function resolveAttribute(stdClass $stdClass, $attribute)
{
if (isset($stdClass->$attribute))
return PHP_EOL . sprintf(' %s: %s', $attribute, implode(', ', $stdClass->$attribute));
return '';
} | [
"private",
"function",
"resolveAttribute",
"(",
"stdClass",
"$",
"stdClass",
",",
"$",
"attribute",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"stdClass",
"->",
"$",
"attribute",
")",
")",
"return",
"PHP_EOL",
".",
"sprintf",
"(",
"' %s: %s'",
",",
"$",
"attribute",
",",
"implode",
"(",
"', '",
",",
"$",
"stdClass",
"->",
"$",
"attribute",
")",
")",
";",
"return",
"''",
";",
"}"
]
| resolves an attribute
@param stdClass $stdClass
@param string $attribute
@return string | [
"resolves",
"an",
"attribute"
]
| 2f17da58ec20a408bbd55b2cdd053bc689f995f4 | https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Response.php#L147-L153 |
18,972 | yuncms/framework | src/notifications/ChannelManager.php | ChannelManager.setChannels | public function setChannels($channels)
{
foreach ($channels as $id => $channel) {
$this->set($id, $channel);
}
} | php | public function setChannels($channels)
{
foreach ($channels as $id => $channel) {
$this->set($id, $channel);
}
} | [
"public",
"function",
"setChannels",
"(",
"$",
"channels",
")",
"{",
"foreach",
"(",
"$",
"channels",
"as",
"$",
"id",
"=>",
"$",
"channel",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"id",
",",
"$",
"channel",
")",
";",
"}",
"}"
]
| Registers a set of channel definitions in this locator.
This is the bulk version of [[set()]]. The parameter should be an array
whose keys are channel IDs and values the corresponding channel definitions.
For more details on how to specify channel IDs and definitions, please refer to [[set()]].
If a channel definition with the same ID already exists, it will be overwritten.
The following is an example for registering two channel definitions:
```php
[
'local' => [
'class' => 'yuncms\NotificationManager\channels\Local',
],
]
```
@param array $channels channel definitions or instances
@throws InvalidConfigException | [
"Registers",
"a",
"set",
"of",
"channel",
"definitions",
"in",
"this",
"locator",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/ChannelManager.php#L250-L255 |
18,973 | Chill-project/Main | Search/SearchProvider.php | SearchProvider.parse | public function parse($pattern)
{
//reset must be extracted
$this->mustBeExtracted = array();
//filter to lower and remove accentued
$filteredPattern = mb_strtolower($this->remove_accents($pattern));
$terms = $this->extractTerms($filteredPattern);
$terms['_domain'] = $this->extractDomain($filteredPattern);
$terms['_default'] = $this->extractDefault($filteredPattern);
return $terms;
} | php | public function parse($pattern)
{
//reset must be extracted
$this->mustBeExtracted = array();
//filter to lower and remove accentued
$filteredPattern = mb_strtolower($this->remove_accents($pattern));
$terms = $this->extractTerms($filteredPattern);
$terms['_domain'] = $this->extractDomain($filteredPattern);
$terms['_default'] = $this->extractDefault($filteredPattern);
return $terms;
} | [
"public",
"function",
"parse",
"(",
"$",
"pattern",
")",
"{",
"//reset must be extracted",
"$",
"this",
"->",
"mustBeExtracted",
"=",
"array",
"(",
")",
";",
"//filter to lower and remove accentued",
"$",
"filteredPattern",
"=",
"mb_strtolower",
"(",
"$",
"this",
"->",
"remove_accents",
"(",
"$",
"pattern",
")",
")",
";",
"$",
"terms",
"=",
"$",
"this",
"->",
"extractTerms",
"(",
"$",
"filteredPattern",
")",
";",
"$",
"terms",
"[",
"'_domain'",
"]",
"=",
"$",
"this",
"->",
"extractDomain",
"(",
"$",
"filteredPattern",
")",
";",
"$",
"terms",
"[",
"'_default'",
"]",
"=",
"$",
"this",
"->",
"extractDefault",
"(",
"$",
"filteredPattern",
")",
";",
"return",
"$",
"terms",
";",
"}"
]
| parse the search string to extract domain and terms
@param string $pattern
@return string[] an array where the keys are _domain, _default (residual terms) or term | [
"parse",
"the",
"search",
"string",
"to",
"extract",
"domain",
"and",
"terms"
]
| 384cb6c793072a4f1047dc5cafc2157ee2419f60 | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L52-L64 |
18,974 | Chill-project/Main | Search/SearchProvider.php | SearchProvider.getSearchResults | public function getSearchResults($pattern, $start = 0, $limit = 50)
{
$terms = $this->parse($pattern);
$results = array();
//sort searchServices by order
$sortedSearchServices = array();
foreach($this->searchServices as $service) {
$sortedSearchServices[$service->getOrder()] = $service;
}
if ($terms['_domain'] !== NULL) {
foreach ($sortedSearchServices as $service) {
if ($service->supports($terms['_domain'])) {
$results[] = $service->renderResult($terms, $start, $limit);
}
}
if (count($results) === 0) {
throw new UnknowSearchDomainException($terms['_domain']);
}
} else { // no domain provided, we use default search
foreach($sortedSearchServices as $service) {
if ($service->isActiveByDefault()) {
$results[] = $service->renderResult($terms, $start, $limit);
}
}
}
//sort array
ksort($results);
return $results;
} | php | public function getSearchResults($pattern, $start = 0, $limit = 50)
{
$terms = $this->parse($pattern);
$results = array();
//sort searchServices by order
$sortedSearchServices = array();
foreach($this->searchServices as $service) {
$sortedSearchServices[$service->getOrder()] = $service;
}
if ($terms['_domain'] !== NULL) {
foreach ($sortedSearchServices as $service) {
if ($service->supports($terms['_domain'])) {
$results[] = $service->renderResult($terms, $start, $limit);
}
}
if (count($results) === 0) {
throw new UnknowSearchDomainException($terms['_domain']);
}
} else { // no domain provided, we use default search
foreach($sortedSearchServices as $service) {
if ($service->isActiveByDefault()) {
$results[] = $service->renderResult($terms, $start, $limit);
}
}
}
//sort array
ksort($results);
return $results;
} | [
"public",
"function",
"getSearchResults",
"(",
"$",
"pattern",
",",
"$",
"start",
"=",
"0",
",",
"$",
"limit",
"=",
"50",
")",
"{",
"$",
"terms",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"pattern",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"//sort searchServices by order",
"$",
"sortedSearchServices",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"searchServices",
"as",
"$",
"service",
")",
"{",
"$",
"sortedSearchServices",
"[",
"$",
"service",
"->",
"getOrder",
"(",
")",
"]",
"=",
"$",
"service",
";",
"}",
"if",
"(",
"$",
"terms",
"[",
"'_domain'",
"]",
"!==",
"NULL",
")",
"{",
"foreach",
"(",
"$",
"sortedSearchServices",
"as",
"$",
"service",
")",
"{",
"if",
"(",
"$",
"service",
"->",
"supports",
"(",
"$",
"terms",
"[",
"'_domain'",
"]",
")",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"service",
"->",
"renderResult",
"(",
"$",
"terms",
",",
"$",
"start",
",",
"$",
"limit",
")",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"results",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"UnknowSearchDomainException",
"(",
"$",
"terms",
"[",
"'_domain'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"// no domain provided, we use default search",
"foreach",
"(",
"$",
"sortedSearchServices",
"as",
"$",
"service",
")",
"{",
"if",
"(",
"$",
"service",
"->",
"isActiveByDefault",
"(",
")",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"service",
"->",
"renderResult",
"(",
"$",
"terms",
",",
"$",
"start",
",",
"$",
"limit",
")",
";",
"}",
"}",
"}",
"//sort array",
"ksort",
"(",
"$",
"results",
")",
";",
"return",
"$",
"results",
";",
"}"
]
| search through services which supports domain and give
results as html string
@param string $pattern
@param number $start
@param number $limit
@return array of html results
@throws UnknowSearchDomainException if the domain is unknow | [
"search",
"through",
"services",
"which",
"supports",
"domain",
"and",
"give",
"results",
"as",
"html",
"string"
]
| 384cb6c793072a4f1047dc5cafc2157ee2419f60 | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L129-L162 |
18,975 | Chill-project/Main | Search/SearchProvider.php | SearchProvider.getByName | public function getByName($name)
{
if (isset($this->searchServices[$name])) {
return $this->searchServices[$name];
} else {
throw new UnknowSearchNameException($name);
}
} | php | public function getByName($name)
{
if (isset($this->searchServices[$name])) {
return $this->searchServices[$name];
} else {
throw new UnknowSearchNameException($name);
}
} | [
"public",
"function",
"getByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"searchServices",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"searchServices",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"UnknowSearchNameException",
"(",
"$",
"name",
")",
";",
"}",
"}"
]
| return search services with a specific name, defined in service
definition.
@return SearchInterface
@throws UnknowSearchNameException if not exists | [
"return",
"search",
"services",
"with",
"a",
"specific",
"name",
"defined",
"in",
"service",
"definition",
"."
]
| 384cb6c793072a4f1047dc5cafc2157ee2419f60 | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L184-L191 |
18,976 | studiowbe/html | src/Attributes.php | Attributes.addClass | public function addClass($classname)
{
$classArr = $this->getClassArray();
$classArr[] = $classname;
return $this->setClassArray($classArr);
} | php | public function addClass($classname)
{
$classArr = $this->getClassArray();
$classArr[] = $classname;
return $this->setClassArray($classArr);
} | [
"public",
"function",
"addClass",
"(",
"$",
"classname",
")",
"{",
"$",
"classArr",
"=",
"$",
"this",
"->",
"getClassArray",
"(",
")",
";",
"$",
"classArr",
"[",
"]",
"=",
"$",
"classname",
";",
"return",
"$",
"this",
"->",
"setClassArray",
"(",
"$",
"classArr",
")",
";",
"}"
]
| Add a class
@param string $classname
@return \Studiow\HTML\Attributes | [
"Add",
"a",
"class"
]
| 860a6d4ff85bc25df5b9e0293d7ff916db8e01af | https://github.com/studiowbe/html/blob/860a6d4ff85bc25df5b9e0293d7ff916db8e01af/src/Attributes.php#L43-L48 |
18,977 | studiowbe/html | src/Attributes.php | Attributes.removeClass | public function removeClass($classname)
{
$classArr = array_diff($this->getClassArray(), [$classname]);
return $this->setClassArray($classArr);
} | php | public function removeClass($classname)
{
$classArr = array_diff($this->getClassArray(), [$classname]);
return $this->setClassArray($classArr);
} | [
"public",
"function",
"removeClass",
"(",
"$",
"classname",
")",
"{",
"$",
"classArr",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"getClassArray",
"(",
")",
",",
"[",
"$",
"classname",
"]",
")",
";",
"return",
"$",
"this",
"->",
"setClassArray",
"(",
"$",
"classArr",
")",
";",
"}"
]
| Remove a class
@param string $classname
@return \Studiow\HTML\Attributes | [
"Remove",
"a",
"class"
]
| 860a6d4ff85bc25df5b9e0293d7ff916db8e01af | https://github.com/studiowbe/html/blob/860a6d4ff85bc25df5b9e0293d7ff916db8e01af/src/Attributes.php#L55-L59 |
18,978 | lode/fem | src/session.php | session.keep | public static function keep($type=null) {
$type = self::check_type($type);
if (self::cookie_exists($type)) {
self::start($type);
}
} | php | public static function keep($type=null) {
$type = self::check_type($type);
if (self::cookie_exists($type)) {
self::start($type);
}
} | [
"public",
"static",
"function",
"keep",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"check_type",
"(",
"$",
"type",
")",
";",
"if",
"(",
"self",
"::",
"cookie_exists",
"(",
"$",
"type",
")",
")",
"{",
"self",
"::",
"start",
"(",
"$",
"type",
")",
";",
"}",
"}"
]
| keep a current session active
use this when you want to start using a session in the current request
@note this does *not* create a new session if one doesn't already exist
@see ::start() if you always want to create a new one anyway
@param string $type one of the ::TYPE_* consts
optional, defaults to ::TYPE_CONTINUOUS
@return void | [
"keep",
"a",
"current",
"session",
"active",
"use",
"this",
"when",
"you",
"want",
"to",
"start",
"using",
"a",
"session",
"in",
"the",
"current",
"request"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L98-L104 |
18,979 | lode/fem | src/session.php | session.validate | private static function validate() {
if (self::is_active() == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('inactive session');
}
if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) {
return false;
}
// throw away expired (replaced) sessions
if (!empty($_SESSION['_session_expire_at']) && $_SESSION['_session_expire_at'] < time()) {
return false;
}
// last_active short enough ago
$type_duration = self::$type_durations[ $_SESSION['_session_type'] ];
$active_enough = ($_SESSION['_session_last_active'] > (time() - $type_duration));
if ($active_enough == false) {
return false;
}
return true;
} | php | private static function validate() {
if (self::is_active() == false) {
$exception = bootstrap::get_library('exception');
throw new $exception('inactive session');
}
if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) {
return false;
}
// throw away expired (replaced) sessions
if (!empty($_SESSION['_session_expire_at']) && $_SESSION['_session_expire_at'] < time()) {
return false;
}
// last_active short enough ago
$type_duration = self::$type_durations[ $_SESSION['_session_type'] ];
$active_enough = ($_SESSION['_session_last_active'] > (time() - $type_duration));
if ($active_enough == false) {
return false;
}
return true;
} | [
"private",
"static",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"is_active",
"(",
")",
"==",
"false",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'inactive session'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"_SESSION",
"[",
"'_session_type'",
"]",
")",
"||",
"empty",
"(",
"$",
"_SESSION",
"[",
"'_session_last_active'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// throw away expired (replaced) sessions",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SESSION",
"[",
"'_session_expire_at'",
"]",
")",
"&&",
"$",
"_SESSION",
"[",
"'_session_expire_at'",
"]",
"<",
"time",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// last_active short enough ago",
"$",
"type_duration",
"=",
"self",
"::",
"$",
"type_durations",
"[",
"$",
"_SESSION",
"[",
"'_session_type'",
"]",
"]",
";",
"$",
"active_enough",
"=",
"(",
"$",
"_SESSION",
"[",
"'_session_last_active'",
"]",
">",
"(",
"time",
"(",
")",
"-",
"$",
"type_duration",
")",
")",
";",
"if",
"(",
"$",
"active_enough",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| checks whether the session is still valid to continue on
this mainly checks the duration, and delayed deletions
@return boolean | [
"checks",
"whether",
"the",
"session",
"is",
"still",
"valid",
"to",
"continue",
"on",
"this",
"mainly",
"checks",
"the",
"duration",
"and",
"delayed",
"deletions"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L325-L348 |
18,980 | lode/fem | src/session.php | session.get_cookie_name | private static function get_cookie_name($type=null) {
if (is_null($type)) {
$type = $_SESSION['_session_type'];
}
return self::COOKIE_NAME_PREFIX.'-'.$type;
} | php | private static function get_cookie_name($type=null) {
if (is_null($type)) {
$type = $_SESSION['_session_type'];
}
return self::COOKIE_NAME_PREFIX.'-'.$type;
} | [
"private",
"static",
"function",
"get_cookie_name",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"$",
"_SESSION",
"[",
"'_session_type'",
"]",
";",
"}",
"return",
"self",
"::",
"COOKIE_NAME_PREFIX",
".",
"'-'",
".",
"$",
"type",
";",
"}"
]
| generates a key for the session cookie
@param string $type one of the ::TYPE_* consts
defaults to the type of the current session
@return string a concatenation of the base (see ::COOKIE_NAME_PREFIX) and the type
i.e. prefix + '-temporary' | [
"generates",
"a",
"key",
"for",
"the",
"session",
"cookie"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L449-L455 |
18,981 | lode/fem | src/session.php | session.get_cookie_settings | private static function get_cookie_settings($type) {
$name = self::get_cookie_name($type);
$duration = self::$type_durations[$type];
$domain = $_SERVER['SERVER_NAME'];
$path = '/';
$secure = !empty($_SERVER['HTTPS']) ? true : false;
$http_only = true;
return [
'name' => $name,
'duration' => $duration,
'domain' => $domain,
'path' => $path,
'secure' => $secure,
'http_only' => $http_only,
];
} | php | private static function get_cookie_settings($type) {
$name = self::get_cookie_name($type);
$duration = self::$type_durations[$type];
$domain = $_SERVER['SERVER_NAME'];
$path = '/';
$secure = !empty($_SERVER['HTTPS']) ? true : false;
$http_only = true;
return [
'name' => $name,
'duration' => $duration,
'domain' => $domain,
'path' => $path,
'secure' => $secure,
'http_only' => $http_only,
];
} | [
"private",
"static",
"function",
"get_cookie_settings",
"(",
"$",
"type",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"get_cookie_name",
"(",
"$",
"type",
")",
";",
"$",
"duration",
"=",
"self",
"::",
"$",
"type_durations",
"[",
"$",
"type",
"]",
";",
"$",
"domain",
"=",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
";",
"$",
"path",
"=",
"'/'",
";",
"$",
"secure",
"=",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"?",
"true",
":",
"false",
";",
"$",
"http_only",
"=",
"true",
";",
"return",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'duration'",
"=>",
"$",
"duration",
",",
"'domain'",
"=>",
"$",
"domain",
",",
"'path'",
"=>",
"$",
"path",
",",
"'secure'",
"=>",
"$",
"secure",
",",
"'http_only'",
"=>",
"$",
"http_only",
",",
"]",
";",
"}"
]
| returns all keys needed for session cookie management
@param string $type one of the ::TYPE_* consts
@return array keys 'name', 'duration', 'domain', 'path', 'secure', 'http_only' | [
"returns",
"all",
"keys",
"needed",
"for",
"session",
"cookie",
"management"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L463-L479 |
18,982 | lode/fem | src/session.php | session.destroy_cookie | private static function destroy_cookie($type=null) {
if (is_null($type)) {
foreach (self::$type_durations as $type => $null) {
self::destroy_cookie($type);
}
return;
}
if (self::cookie_exists($type) == false) {
return;
}
self::update_cookie_expiration($type, $expire_now=true);
$cookie_name = self::get_cookie_name($type);
unset($_COOKIE[$cookie_name]);
} | php | private static function destroy_cookie($type=null) {
if (is_null($type)) {
foreach (self::$type_durations as $type => $null) {
self::destroy_cookie($type);
}
return;
}
if (self::cookie_exists($type) == false) {
return;
}
self::update_cookie_expiration($type, $expire_now=true);
$cookie_name = self::get_cookie_name($type);
unset($_COOKIE[$cookie_name]);
} | [
"private",
"static",
"function",
"destroy_cookie",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"type_durations",
"as",
"$",
"type",
"=>",
"$",
"null",
")",
"{",
"self",
"::",
"destroy_cookie",
"(",
"$",
"type",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"self",
"::",
"cookie_exists",
"(",
"$",
"type",
")",
"==",
"false",
")",
"{",
"return",
";",
"}",
"self",
"::",
"update_cookie_expiration",
"(",
"$",
"type",
",",
"$",
"expire_now",
"=",
"true",
")",
";",
"$",
"cookie_name",
"=",
"self",
"::",
"get_cookie_name",
"(",
"$",
"type",
")",
";",
"unset",
"(",
"$",
"_COOKIE",
"[",
"$",
"cookie_name",
"]",
")",
";",
"}"
]
| throws away the session cookie
@param string $type one of the ::TYPE_* consts
if null, defaults to removing cookies for all possible types
@return void | [
"throws",
"away",
"the",
"session",
"cookie"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L500-L516 |
18,983 | lode/fem | src/session.php | session.update_cookie_expiration | private static function update_cookie_expiration($type, $expire_now=false) {
$params = self::get_cookie_settings($type);
$value = session_id();
$expire = (time() + $params['duration']);
if ($expire_now) {
$value = null;
$expire = (time() - 604800); // one week ago
}
setcookie($params['name'], $value, $expire, $params['path'], $params['domain'], $params['secure'], $params['http_only']);
} | php | private static function update_cookie_expiration($type, $expire_now=false) {
$params = self::get_cookie_settings($type);
$value = session_id();
$expire = (time() + $params['duration']);
if ($expire_now) {
$value = null;
$expire = (time() - 604800); // one week ago
}
setcookie($params['name'], $value, $expire, $params['path'], $params['domain'], $params['secure'], $params['http_only']);
} | [
"private",
"static",
"function",
"update_cookie_expiration",
"(",
"$",
"type",
",",
"$",
"expire_now",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"self",
"::",
"get_cookie_settings",
"(",
"$",
"type",
")",
";",
"$",
"value",
"=",
"session_id",
"(",
")",
";",
"$",
"expire",
"=",
"(",
"time",
"(",
")",
"+",
"$",
"params",
"[",
"'duration'",
"]",
")",
";",
"if",
"(",
"$",
"expire_now",
")",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"expire",
"=",
"(",
"time",
"(",
")",
"-",
"604800",
")",
";",
"// one week ago",
"}",
"setcookie",
"(",
"$",
"params",
"[",
"'name'",
"]",
",",
"$",
"value",
",",
"$",
"expire",
",",
"$",
"params",
"[",
"'path'",
"]",
",",
"$",
"params",
"[",
"'domain'",
"]",
",",
"$",
"params",
"[",
"'secure'",
"]",
",",
"$",
"params",
"[",
"'http_only'",
"]",
")",
";",
"}"
]
| updates the cookies expiration with the type's duration
useful to keep the cookie active after each user activity
set $expire_now to true to remove the cookie
@param string $type one of the ::TYPE_* consts
@param boolean $expire_now default false
@return void | [
"updates",
"the",
"cookies",
"expiration",
"with",
"the",
"type",
"s",
"duration",
"useful",
"to",
"keep",
"the",
"cookie",
"active",
"after",
"each",
"user",
"activity"
]
| c1c466c1a904d99452b341c5ae7cbc3e22b106e1 | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L528-L539 |
18,984 | sebastiaanluca/laravel-unbreakable-migrations | src/Migration.php | Migration.connect | protected function connect() : void
{
if (! $this->isLaravel()) {
throw new Exception('This migrator must be ran from inside a Laravel application.');
}
$this->manager = app('db');
$this->database = $this->manager->connection();
$this->schema = $this->database->getSchemaBuilder();
} | php | protected function connect() : void
{
if (! $this->isLaravel()) {
throw new Exception('This migrator must be ran from inside a Laravel application.');
}
$this->manager = app('db');
$this->database = $this->manager->connection();
$this->schema = $this->database->getSchemaBuilder();
} | [
"protected",
"function",
"connect",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLaravel",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'This migrator must be ran from inside a Laravel application.'",
")",
";",
"}",
"$",
"this",
"->",
"manager",
"=",
"app",
"(",
"'db'",
")",
";",
"$",
"this",
"->",
"database",
"=",
"$",
"this",
"->",
"manager",
"->",
"connection",
"(",
")",
";",
"$",
"this",
"->",
"schema",
"=",
"$",
"this",
"->",
"database",
"->",
"getSchemaBuilder",
"(",
")",
";",
"}"
]
| Check the database connection and use of the Laravel framework.
@return void
@throws \Exception | [
"Check",
"the",
"database",
"connection",
"and",
"use",
"of",
"the",
"Laravel",
"framework",
"."
]
| 3c831b204770b80c97351c3b881dcbf924236a13 | https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L93-L102 |
18,985 | sebastiaanluca/laravel-unbreakable-migrations | src/Migration.php | Migration.dropColumn | protected function dropColumn(string $tableName, string $column) : void
{
// Check for its existence before dropping
if (! $this->schema->hasColumn($tableName, $column)) {
return;
}
$this->schema->table($tableName, function (Blueprint $table) use ($column) {
$table->dropColumn($column);
});
} | php | protected function dropColumn(string $tableName, string $column) : void
{
// Check for its existence before dropping
if (! $this->schema->hasColumn($tableName, $column)) {
return;
}
$this->schema->table($tableName, function (Blueprint $table) use ($column) {
$table->dropColumn($column);
});
} | [
"protected",
"function",
"dropColumn",
"(",
"string",
"$",
"tableName",
",",
"string",
"$",
"column",
")",
":",
"void",
"{",
"// Check for its existence before dropping",
"if",
"(",
"!",
"$",
"this",
"->",
"schema",
"->",
"hasColumn",
"(",
"$",
"tableName",
",",
"$",
"column",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"schema",
"->",
"table",
"(",
"$",
"tableName",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"table",
"->",
"dropColumn",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}"
]
| Safely drop a column from a table.
@param string $tableName
@param string $column
@return void | [
"Safely",
"drop",
"a",
"column",
"from",
"a",
"table",
"."
]
| 3c831b204770b80c97351c3b881dcbf924236a13 | https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L130-L140 |
18,986 | sebastiaanluca/laravel-unbreakable-migrations | src/Migration.php | Migration.drop | protected function drop($tables, bool $ignoreKeyConstraints = false) : void
{
if ($ignoreKeyConstraints) {
$this->database->statement('SET FOREIGN_KEY_CHECKS=0;');
}
if (! is_array($tables)) {
$tables = [$tables];
}
foreach ($tables as $table) {
if ($this->tableExists($table)) {
$this->schema->drop($table);
}
}
if ($ignoreKeyConstraints) {
$this->database->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | php | protected function drop($tables, bool $ignoreKeyConstraints = false) : void
{
if ($ignoreKeyConstraints) {
$this->database->statement('SET FOREIGN_KEY_CHECKS=0;');
}
if (! is_array($tables)) {
$tables = [$tables];
}
foreach ($tables as $table) {
if ($this->tableExists($table)) {
$this->schema->drop($table);
}
}
if ($ignoreKeyConstraints) {
$this->database->statement('SET FOREIGN_KEY_CHECKS=1;');
}
} | [
"protected",
"function",
"drop",
"(",
"$",
"tables",
",",
"bool",
"$",
"ignoreKeyConstraints",
"=",
"false",
")",
":",
"void",
"{",
"if",
"(",
"$",
"ignoreKeyConstraints",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=0;'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tables",
")",
")",
"{",
"$",
"tables",
"=",
"[",
"$",
"tables",
"]",
";",
"}",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tableExists",
"(",
"$",
"table",
")",
")",
"{",
"$",
"this",
"->",
"schema",
"->",
"drop",
"(",
"$",
"table",
")",
";",
"}",
"}",
"if",
"(",
"$",
"ignoreKeyConstraints",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"statement",
"(",
"'SET FOREIGN_KEY_CHECKS=1;'",
")",
";",
"}",
"}"
]
| Safely drop a table.
@param array|string $tables
@param bool $ignoreKeyConstraints
@return void | [
"Safely",
"drop",
"a",
"table",
"."
]
| 3c831b204770b80c97351c3b881dcbf924236a13 | https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L150-L169 |
18,987 | sebastiaanluca/laravel-unbreakable-migrations | src/Migration.php | Migration.dropAllTables | protected function dropAllTables(bool $ignoreKeyConstraints = false) : void
{
$this->drop($this->tables, $ignoreKeyConstraints);
} | php | protected function dropAllTables(bool $ignoreKeyConstraints = false) : void
{
$this->drop($this->tables, $ignoreKeyConstraints);
} | [
"protected",
"function",
"dropAllTables",
"(",
"bool",
"$",
"ignoreKeyConstraints",
"=",
"false",
")",
":",
"void",
"{",
"$",
"this",
"->",
"drop",
"(",
"$",
"this",
"->",
"tables",
",",
"$",
"ignoreKeyConstraints",
")",
";",
"}"
]
| Safely drop all tables.
@param bool $ignoreKeyConstraints
@return void | [
"Safely",
"drop",
"all",
"tables",
"."
]
| 3c831b204770b80c97351c3b881dcbf924236a13 | https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L178-L181 |
18,988 | ClanCats/Core | src/classes/CCServer.php | CCServer._init | public static function _init()
{
// create new instance from default input
CCServer::$_instance = CCIn::create( $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER );
// unset default http holder to safe mem
//unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES );
} | php | public static function _init()
{
// create new instance from default input
CCServer::$_instance = CCIn::create( $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER );
// unset default http holder to safe mem
//unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES );
} | [
"public",
"static",
"function",
"_init",
"(",
")",
"{",
"// create new instance from default input",
"CCServer",
"::",
"$",
"_instance",
"=",
"CCIn",
"::",
"create",
"(",
"$",
"_GET",
",",
"$",
"_POST",
",",
"$",
"_COOKIE",
",",
"$",
"_FILES",
",",
"$",
"_SERVER",
")",
";",
"// unset default http holder to safe mem",
"//unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES );",
"}"
]
| The initial call of the CCServer get all Superglobals
and assigns them to itself as an holder.
@return void | [
"The",
"initial",
"call",
"of",
"the",
"CCServer",
"get",
"all",
"Superglobals",
"and",
"assigns",
"them",
"to",
"itself",
"as",
"an",
"holder",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCServer.php#L21-L28 |
18,989 | nooku/nooku-installer | src/Nooku/Composer/Installer/NookuComponent.php | NookuComponent._installAutoloader | protected function _installAutoloader(PackageInterface $package)
{
$path = $this->_getAutoloaderPath($package);
$manifest = $this->_getKoowaManifest($package);
if(!file_exists($path))
{
$platform = $this->_isPlatform();
$classname = $platform ? 'Nooku\Library\ObjectManager' : 'KObjectManager';
$bootstrap = $platform ? '' : 'KoowaAutoloader::bootstrap();';
list($vendor, ) = explode('/', $package->getPrettyName());
$component = (string) $manifest->name;
$contents = <<<EOL
<?php
/**
* This file has been generated automatically by Composer. Any changes to this file will not persist.
* You can override this autoloader by supplying an autoload.php file in the root of the relevant component.
**/
$bootstrap
$classname::getInstance()
->getObject('lib:object.bootstrapper')
->registerComponent(
'$component',
__DIR__,
'$vendor'
);
EOL;
file_put_contents($path, $contents);
}
} | php | protected function _installAutoloader(PackageInterface $package)
{
$path = $this->_getAutoloaderPath($package);
$manifest = $this->_getKoowaManifest($package);
if(!file_exists($path))
{
$platform = $this->_isPlatform();
$classname = $platform ? 'Nooku\Library\ObjectManager' : 'KObjectManager';
$bootstrap = $platform ? '' : 'KoowaAutoloader::bootstrap();';
list($vendor, ) = explode('/', $package->getPrettyName());
$component = (string) $manifest->name;
$contents = <<<EOL
<?php
/**
* This file has been generated automatically by Composer. Any changes to this file will not persist.
* You can override this autoloader by supplying an autoload.php file in the root of the relevant component.
**/
$bootstrap
$classname::getInstance()
->getObject('lib:object.bootstrapper')
->registerComponent(
'$component',
__DIR__,
'$vendor'
);
EOL;
file_put_contents($path, $contents);
}
} | [
"protected",
"function",
"_installAutoloader",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_getAutoloaderPath",
"(",
"$",
"package",
")",
";",
"$",
"manifest",
"=",
"$",
"this",
"->",
"_getKoowaManifest",
"(",
"$",
"package",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"platform",
"=",
"$",
"this",
"->",
"_isPlatform",
"(",
")",
";",
"$",
"classname",
"=",
"$",
"platform",
"?",
"'Nooku\\Library\\ObjectManager'",
":",
"'KObjectManager'",
";",
"$",
"bootstrap",
"=",
"$",
"platform",
"?",
"''",
":",
"'KoowaAutoloader::bootstrap();'",
";",
"list",
"(",
"$",
"vendor",
",",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
")",
";",
"$",
"component",
"=",
"(",
"string",
")",
"$",
"manifest",
"->",
"name",
";",
"$",
"contents",
"=",
" <<<EOL\n<?php\n/**\n * This file has been generated automatically by Composer. Any changes to this file will not persist.\n * You can override this autoloader by supplying an autoload.php file in the root of the relevant component.\n **/\n\n$bootstrap\n\n$classname::getInstance()\n ->getObject('lib:object.bootstrapper')\n ->registerComponent(\n '$component',\n __DIR__,\n '$vendor'\n );\nEOL",
";",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"contents",
")",
";",
"}",
"}"
]
| Installs the default autoloader if no autoloader is supplied.
@param PackageInterface $package | [
"Installs",
"the",
"default",
"autoloader",
"if",
"no",
"autoloader",
"is",
"supplied",
"."
]
| 2aa82ed08983bccd51905426cfff4980ba960d89 | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L58-L92 |
18,990 | nooku/nooku-installer | src/Nooku/Composer/Installer/NookuComponent.php | NookuComponent._removeAutoloader | protected function _removeAutoloader(PackageInterface $package)
{
$path = $this->_getAutoloaderPath($package);
if(file_exists($path))
{
$contents = file_get_contents($path);
if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) {
unlink($path);
}
}
} | php | protected function _removeAutoloader(PackageInterface $package)
{
$path = $this->_getAutoloaderPath($package);
if(file_exists($path))
{
$contents = file_get_contents($path);
if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) {
unlink($path);
}
}
} | [
"protected",
"function",
"_removeAutoloader",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_getAutoloaderPath",
"(",
"$",
"package",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"contents",
",",
"'This file has been generated automatically by Composer.'",
")",
"!==",
"false",
")",
"{",
"unlink",
"(",
"$",
"path",
")",
";",
"}",
"}",
"}"
]
| Removes the autoloader for the given package if it was generated automatically.
@param PackageInterface $package | [
"Removes",
"the",
"autoloader",
"for",
"the",
"given",
"package",
"if",
"it",
"was",
"generated",
"automatically",
"."
]
| 2aa82ed08983bccd51905426cfff4980ba960d89 | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L99-L111 |
18,991 | nooku/nooku-installer | src/Nooku/Composer/Installer/NookuComponent.php | NookuComponent._getKoowaManifest | protected function _getKoowaManifest(PackageInterface $package)
{
$path = $this->getInstallPath($package);
$directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \RegexIterator($iterator, '/koowa-component\.xml/', \RegexIterator::GET_MATCH);
$files = iterator_to_array($regex);
if (empty($files)) {
return false;
}
$manifests = array_keys($files);
$manifest = simplexml_load_file($manifests[0]);
if (!($manifest instanceof \SimpleXMLElement))
{
throw new \InvalidArgumentException(
'Failed to load `koowa-component.xml` manifest for package `'.$package->getPrettyName().'`.'
);
}
return $manifest;
} | php | protected function _getKoowaManifest(PackageInterface $package)
{
$path = $this->getInstallPath($package);
$directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \RegexIterator($iterator, '/koowa-component\.xml/', \RegexIterator::GET_MATCH);
$files = iterator_to_array($regex);
if (empty($files)) {
return false;
}
$manifests = array_keys($files);
$manifest = simplexml_load_file($manifests[0]);
if (!($manifest instanceof \SimpleXMLElement))
{
throw new \InvalidArgumentException(
'Failed to load `koowa-component.xml` manifest for package `'.$package->getPrettyName().'`.'
);
}
return $manifest;
} | [
"protected",
"function",
"_getKoowaManifest",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
";",
"$",
"directory",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"path",
",",
"\\",
"RecursiveDirectoryIterator",
"::",
"KEY_AS_PATHNAME",
")",
";",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"directory",
")",
";",
"$",
"regex",
"=",
"new",
"\\",
"RegexIterator",
"(",
"$",
"iterator",
",",
"'/koowa-component\\.xml/'",
",",
"\\",
"RegexIterator",
"::",
"GET_MATCH",
")",
";",
"$",
"files",
"=",
"iterator_to_array",
"(",
"$",
"regex",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"manifests",
"=",
"array_keys",
"(",
"$",
"files",
")",
";",
"$",
"manifest",
"=",
"simplexml_load_file",
"(",
"$",
"manifests",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"(",
"$",
"manifest",
"instanceof",
"\\",
"SimpleXMLElement",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Failed to load `koowa-component.xml` manifest for package `'",
".",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
".",
"'`.'",
")",
";",
"}",
"return",
"$",
"manifest",
";",
"}"
]
| Attempts to locate and initialize the koowa-component.xml manifest
@param PackageInterface $package
@return bool|\SimpleXMLElement Instance of SimpleXMLElement or false on failure
@throws `InvalidArgumentException` on failure to load the XML manifest | [
"Attempts",
"to",
"locate",
"and",
"initialize",
"the",
"koowa",
"-",
"component",
".",
"xml",
"manifest"
]
| 2aa82ed08983bccd51905426cfff4980ba960d89 | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L120-L143 |
18,992 | nooku/nooku-installer | src/Nooku/Composer/Installer/NookuComponent.php | NookuComponent._copyAssets | protected function _copyAssets(PackageInterface $package)
{
$path = rtrim($this->getInstallPath($package), '/');
$asset_path = $path.'/resources/assets';
$vendor_dir = dirname(dirname($path));
// Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+
$is_joomla = is_dir(dirname($vendor_dir).'/joomla') || is_dir(dirname($vendor_dir).'/libraries/joomla');
if ($is_joomla && is_dir($asset_path))
{
$manifest = $this->_getKoowaManifest($package);
$root = is_dir(dirname($vendor_dir).'/joomla') ? dirname(dirname($vendor_dir)) : dirname($vendor_dir);
$destination = $root.'/media/koowa/com_'.$manifest->name;
$this->_copyDirectory($asset_path, $destination);
}
} | php | protected function _copyAssets(PackageInterface $package)
{
$path = rtrim($this->getInstallPath($package), '/');
$asset_path = $path.'/resources/assets';
$vendor_dir = dirname(dirname($path));
// Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+
$is_joomla = is_dir(dirname($vendor_dir).'/joomla') || is_dir(dirname($vendor_dir).'/libraries/joomla');
if ($is_joomla && is_dir($asset_path))
{
$manifest = $this->_getKoowaManifest($package);
$root = is_dir(dirname($vendor_dir).'/joomla') ? dirname(dirname($vendor_dir)) : dirname($vendor_dir);
$destination = $root.'/media/koowa/com_'.$manifest->name;
$this->_copyDirectory($asset_path, $destination);
}
} | [
"protected",
"function",
"_copyAssets",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
",",
"'/'",
")",
";",
"$",
"asset_path",
"=",
"$",
"path",
".",
"'/resources/assets'",
";",
"$",
"vendor_dir",
"=",
"dirname",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"// Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+",
"$",
"is_joomla",
"=",
"is_dir",
"(",
"dirname",
"(",
"$",
"vendor_dir",
")",
".",
"'/joomla'",
")",
"||",
"is_dir",
"(",
"dirname",
"(",
"$",
"vendor_dir",
")",
".",
"'/libraries/joomla'",
")",
";",
"if",
"(",
"$",
"is_joomla",
"&&",
"is_dir",
"(",
"$",
"asset_path",
")",
")",
"{",
"$",
"manifest",
"=",
"$",
"this",
"->",
"_getKoowaManifest",
"(",
"$",
"package",
")",
";",
"$",
"root",
"=",
"is_dir",
"(",
"dirname",
"(",
"$",
"vendor_dir",
")",
".",
"'/joomla'",
")",
"?",
"dirname",
"(",
"dirname",
"(",
"$",
"vendor_dir",
")",
")",
":",
"dirname",
"(",
"$",
"vendor_dir",
")",
";",
"$",
"destination",
"=",
"$",
"root",
".",
"'/media/koowa/com_'",
".",
"$",
"manifest",
"->",
"name",
";",
"$",
"this",
"->",
"_copyDirectory",
"(",
"$",
"asset_path",
",",
"$",
"destination",
")",
";",
"}",
"}"
]
| Copy assets into the media folder if the installation is running in a Joomla context
@param PackageInterface $package | [
"Copy",
"assets",
"into",
"the",
"media",
"folder",
"if",
"the",
"installation",
"is",
"running",
"in",
"a",
"Joomla",
"context"
]
| 2aa82ed08983bccd51905426cfff4980ba960d89 | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L184-L202 |
18,993 | nooku/nooku-installer | src/Nooku/Composer/Installer/NookuComponent.php | NookuComponent._copyDirectory | protected function _copyDirectory($source, $target)
{
$result = false;
if (!is_dir($target)) {
$result = mkdir($target, 0755, true);
}
else
{
// Clear directory
$iter = new \RecursiveDirectoryIterator($target);
foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f)
{
if ($f->isDir())
{
if (!in_array($f->getFilename(), array('.', '..'))) {
rmdir($f->getPathname());
}
} else {
unlink($f->getPathname());
}
}
}
if (is_dir($target))
{
$result = true; // needed for empty directories
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $f)
{
if ($f->isDir()) {
$path = $target.'/'.$iterator->getSubPathName();
if (!is_dir($path)) {
$result = mkdir($path);
}
} else {
$result = copy($f, $target.'/'.$iterator->getSubPathName());
}
if ($result === false) {
break;
}
}
}
return $result;
} | php | protected function _copyDirectory($source, $target)
{
$result = false;
if (!is_dir($target)) {
$result = mkdir($target, 0755, true);
}
else
{
// Clear directory
$iter = new \RecursiveDirectoryIterator($target);
foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f)
{
if ($f->isDir())
{
if (!in_array($f->getFilename(), array('.', '..'))) {
rmdir($f->getPathname());
}
} else {
unlink($f->getPathname());
}
}
}
if (is_dir($target))
{
$result = true; // needed for empty directories
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $f)
{
if ($f->isDir()) {
$path = $target.'/'.$iterator->getSubPathName();
if (!is_dir($path)) {
$result = mkdir($path);
}
} else {
$result = copy($f, $target.'/'.$iterator->getSubPathName());
}
if ($result === false) {
break;
}
}
}
return $result;
} | [
"protected",
"function",
"_copyDirectory",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"target",
")",
")",
"{",
"$",
"result",
"=",
"mkdir",
"(",
"$",
"target",
",",
"0755",
",",
"true",
")",
";",
"}",
"else",
"{",
"// Clear directory",
"$",
"iter",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"target",
")",
";",
"foreach",
"(",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"iter",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"CHILD_FIRST",
")",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"->",
"isDir",
"(",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"f",
"->",
"getFilename",
"(",
")",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
")",
")",
"{",
"rmdir",
"(",
"$",
"f",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"unlink",
"(",
"$",
"f",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"target",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// needed for empty directories",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"source",
")",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"f",
")",
"{",
"if",
"(",
"$",
"f",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"path",
"=",
"$",
"target",
".",
"'/'",
".",
"$",
"iterator",
"->",
"getSubPathName",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"result",
"=",
"mkdir",
"(",
"$",
"path",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"copy",
"(",
"$",
"f",
",",
"$",
"target",
".",
"'/'",
".",
"$",
"iterator",
"->",
"getSubPathName",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Copy source folder into target. Clears the target folder first.
@param $source
@param $target
@return bool | [
"Copy",
"source",
"folder",
"into",
"target",
".",
"Clears",
"the",
"target",
"folder",
"first",
"."
]
| 2aa82ed08983bccd51905426cfff4980ba960d89 | https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L211-L257 |
18,994 | nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/File/Count.php | Zend_Validate_File_Count.setMin | public function setMin($min)
{
if (is_array($min) and isset($min['min'])) {
$min = $min['min'];
}
if (!is_string($min) and !is_numeric($min)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception ('Invalid options to validator provided');
}
$min = (integer) $min;
if (($this->_max !== null) && ($min > $this->_max)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >"
. " {$this->_max}");
}
$this->_min = $min;
return $this;
} | php | public function setMin($min)
{
if (is_array($min) and isset($min['min'])) {
$min = $min['min'];
}
if (!is_string($min) and !is_numeric($min)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception ('Invalid options to validator provided');
}
$min = (integer) $min;
if (($this->_max !== null) && ($min > $this->_max)) {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >"
. " {$this->_max}");
}
$this->_min = $min;
return $this;
} | [
"public",
"function",
"setMin",
"(",
"$",
"min",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"min",
")",
"and",
"isset",
"(",
"$",
"min",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"min",
"=",
"$",
"min",
"[",
"'min'",
"]",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"min",
")",
"and",
"!",
"is_numeric",
"(",
"$",
"min",
")",
")",
"{",
"require_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"'Invalid options to validator provided'",
")",
";",
"}",
"$",
"min",
"=",
"(",
"integer",
")",
"$",
"min",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"_max",
"!==",
"null",
")",
"&&",
"(",
"$",
"min",
">",
"$",
"this",
"->",
"_max",
")",
")",
"{",
"require_once",
"'Zend/Validate/Exception.php'",
";",
"throw",
"new",
"Zend_Validate_Exception",
"(",
"\"The minimum must be less than or equal to the maximum file count, but $min >\"",
".",
"\" {$this->_max}\"",
")",
";",
"}",
"$",
"this",
"->",
"_min",
"=",
"$",
"min",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the minimum file count
@param integer|array $min The minimum file count
@return Zend_Validate_File_Count Provides a fluent interface
@throws Zend_Validate_Exception When min is greater than max | [
"Sets",
"the",
"minimum",
"file",
"count"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Count.php#L150-L170 |
18,995 | webforge-labs/psc-cms | lib/PHPWord/PHPWord/Section/Table.php | PHPWord_Section_Table.addCell | public function addCell($width, $style = null) {
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
$i = count($this->_rows) - 1;
$this->_rows[$i][] = $cell;
return $cell;
} | php | public function addCell($width, $style = null) {
$cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style);
$i = count($this->_rows) - 1;
$this->_rows[$i][] = $cell;
return $cell;
} | [
"public",
"function",
"addCell",
"(",
"$",
"width",
",",
"$",
"style",
"=",
"null",
")",
"{",
"$",
"cell",
"=",
"new",
"PHPWord_Section_Table_Cell",
"(",
"$",
"this",
"->",
"_insideOf",
",",
"$",
"this",
"->",
"_pCount",
",",
"$",
"width",
",",
"$",
"style",
")",
";",
"$",
"i",
"=",
"count",
"(",
"$",
"this",
"->",
"_rows",
")",
"-",
"1",
";",
"$",
"this",
"->",
"_rows",
"[",
"$",
"i",
"]",
"[",
"]",
"=",
"$",
"cell",
";",
"return",
"$",
"cell",
";",
"}"
]
| Add a cell
@param int $width
@param mixed $style
@return PHPWord_Section_Table_Cell | [
"Add",
"a",
"cell"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table.php#L118-L123 |
18,996 | gevans/phaker | lib/Phaker/Generator/Internet.php | Internet.safe_email | public function safe_email($name = NULL)
{
$tlds = array('org', 'com', 'net');
return implode('@', array($this->user_name($name), 'example.'.$tlds[array_rand($tlds)]));
} | php | public function safe_email($name = NULL)
{
$tlds = array('org', 'com', 'net');
return implode('@', array($this->user_name($name), 'example.'.$tlds[array_rand($tlds)]));
} | [
"public",
"function",
"safe_email",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"$",
"tlds",
"=",
"array",
"(",
"'org'",
",",
"'com'",
",",
"'net'",
")",
";",
"return",
"implode",
"(",
"'@'",
",",
"array",
"(",
"$",
"this",
"->",
"user_name",
"(",
"$",
"name",
")",
",",
"'example.'",
".",
"$",
"tlds",
"[",
"array_rand",
"(",
"$",
"tlds",
")",
"]",
")",
")",
";",
"}"
]
| Generate a safe email address ending with example.tld, with a TLD of
org, com, or net only.
@param string $name User name
@return string | [
"Generate",
"a",
"safe",
"email",
"address",
"ending",
"with",
"example",
".",
"tld",
"with",
"a",
"TLD",
"of",
"org",
"com",
"or",
"net",
"only",
"."
]
| b99f4a20a09188c219649127655e980d1e983274 | https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Internet.php#L45-L49 |
18,997 | gevans/phaker | lib/Phaker/Generator/Internet.php | Internet.user_name | public function user_name($name = NULL)
{
$delim = array('.', '_');
if ($name)
{
$names = preg_split('/[^\w]+/', $name, NULL, PREG_SPLIT_NO_EMPTY);
shuffle($names);
return implode($delim[array_rand($delim)], $names);
}
if (mt_rand(0, 1))
{
$name = preg_replace('/\W/', '', \Phaker::name()->first_name);
}
else
{
$names = preg_replace('/\W/', '', array(\Phaker::name()->first_name, \Phaker::name()->last_name));
$name = implode($delim[array_rand($delim)], $names);
}
return static::fix_umlauts(strtolower($name));
} | php | public function user_name($name = NULL)
{
$delim = array('.', '_');
if ($name)
{
$names = preg_split('/[^\w]+/', $name, NULL, PREG_SPLIT_NO_EMPTY);
shuffle($names);
return implode($delim[array_rand($delim)], $names);
}
if (mt_rand(0, 1))
{
$name = preg_replace('/\W/', '', \Phaker::name()->first_name);
}
else
{
$names = preg_replace('/\W/', '', array(\Phaker::name()->first_name, \Phaker::name()->last_name));
$name = implode($delim[array_rand($delim)], $names);
}
return static::fix_umlauts(strtolower($name));
} | [
"public",
"function",
"user_name",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"$",
"delim",
"=",
"array",
"(",
"'.'",
",",
"'_'",
")",
";",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"names",
"=",
"preg_split",
"(",
"'/[^\\w]+/'",
",",
"$",
"name",
",",
"NULL",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"shuffle",
"(",
"$",
"names",
")",
";",
"return",
"implode",
"(",
"$",
"delim",
"[",
"array_rand",
"(",
"$",
"delim",
")",
"]",
",",
"$",
"names",
")",
";",
"}",
"if",
"(",
"mt_rand",
"(",
"0",
",",
"1",
")",
")",
"{",
"$",
"name",
"=",
"preg_replace",
"(",
"'/\\W/'",
",",
"''",
",",
"\\",
"Phaker",
"::",
"name",
"(",
")",
"->",
"first_name",
")",
";",
"}",
"else",
"{",
"$",
"names",
"=",
"preg_replace",
"(",
"'/\\W/'",
",",
"''",
",",
"array",
"(",
"\\",
"Phaker",
"::",
"name",
"(",
")",
"->",
"first_name",
",",
"\\",
"Phaker",
"::",
"name",
"(",
")",
"->",
"last_name",
")",
")",
";",
"$",
"name",
"=",
"implode",
"(",
"$",
"delim",
"[",
"array_rand",
"(",
"$",
"delim",
")",
"]",
",",
"$",
"names",
")",
";",
"}",
"return",
"static",
"::",
"fix_umlauts",
"(",
"strtolower",
"(",
"$",
"name",
")",
")",
";",
"}"
]
| Generate a lowercase user name from a full or partial name.
echo $internet->user_name('Dr. Seuss'); // => "dr.seuss"
@param string $name User name
@return string | [
"Generate",
"a",
"lowercase",
"user",
"name",
"from",
"a",
"full",
"or",
"partial",
"name",
"."
]
| b99f4a20a09188c219649127655e980d1e983274 | https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Internet.php#L59-L81 |
18,998 | ClanCats/Core | src/classes/CCLog.php | CCLog.write | public static function write()
{
if ( empty( static::$_data ) )
{
return;
}
$buffer = date("H:i:s")." - ".CCServer::method().' '.CCServer::server('REQUEST_URI')."\n";
$buffer .= implode( "\n", static::$_data );
CCFile::append( CCStorage::path( 'logs/'.date( 'Y-m' ).'/'.date( 'd' ).'.log' ), $buffer."\n" );
// clear
static::clear();
} | php | public static function write()
{
if ( empty( static::$_data ) )
{
return;
}
$buffer = date("H:i:s")." - ".CCServer::method().' '.CCServer::server('REQUEST_URI')."\n";
$buffer .= implode( "\n", static::$_data );
CCFile::append( CCStorage::path( 'logs/'.date( 'Y-m' ).'/'.date( 'd' ).'.log' ), $buffer."\n" );
// clear
static::clear();
} | [
"public",
"static",
"function",
"write",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"_data",
")",
")",
"{",
"return",
";",
"}",
"$",
"buffer",
"=",
"date",
"(",
"\"H:i:s\"",
")",
".",
"\" - \"",
".",
"CCServer",
"::",
"method",
"(",
")",
".",
"' '",
".",
"CCServer",
"::",
"server",
"(",
"'REQUEST_URI'",
")",
".",
"\"\\n\"",
";",
"$",
"buffer",
".=",
"implode",
"(",
"\"\\n\"",
",",
"static",
"::",
"$",
"_data",
")",
";",
"CCFile",
"::",
"append",
"(",
"CCStorage",
"::",
"path",
"(",
"'logs/'",
".",
"date",
"(",
"'Y-m'",
")",
".",
"'/'",
".",
"date",
"(",
"'d'",
")",
".",
"'.log'",
")",
",",
"$",
"buffer",
".",
"\"\\n\"",
")",
";",
"// clear",
"static",
"::",
"clear",
"(",
")",
";",
"}"
]
| write the log down to disk
@return void | [
"write",
"the",
"log",
"down",
"to",
"disk"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLog.php#L81-L95 |
18,999 | ClanCats/Core | src/bundles/UI/Table.php | Table.row | public function row( $data = array(), $attr = array() ) {
$this->data[] = $this->_repair_row( $data, $attr ); return $this;
} | php | public function row( $data = array(), $attr = array() ) {
$this->data[] = $this->_repair_row( $data, $attr ); return $this;
} | [
"public",
"function",
"row",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"attr",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"$",
"this",
"->",
"_repair_row",
"(",
"$",
"data",
",",
"$",
"attr",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| add a new row | [
"add",
"a",
"new",
"row"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Table.php#L52-L54 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.