repo stringclasses 21 values | path stringlengths 10 100 | func_name stringlengths 6 71 | original_string stringlengths 115 97k | language stringclasses 1 value | code stringlengths 115 97k | code_tokens sequencelengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens sequencelengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids sequencelengths 502 502 | token_type_ids sequencelengths 502 502 | attention_mask sequencelengths 502 502 | labels sequencelengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
octobercms/october | modules/system/classes/MailManager.php | MailManager.startTwig | protected function startTwig()
{
if ($this->isTwigStarted) {
return;
}
$this->isTwigStarted = true;
$markupManager = MarkupManager::instance();
$markupManager->beginTransaction();
$markupManager->registerTokenParsers([
new MailPartialTokenParser
]);
} | php | protected function startTwig()
{
if ($this->isTwigStarted) {
return;
}
$this->isTwigStarted = true;
$markupManager = MarkupManager::instance();
$markupManager->beginTransaction();
$markupManager->registerTokenParsers([
new MailPartialTokenParser
]);
} | [
"protected",
"function",
"startTwig",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isTwigStarted",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"isTwigStarted",
"=",
"true",
";",
"$",
"markupManager",
"=",
"MarkupManager",
"::",
"instance",
"(",
")"... | Temporarily registers mail based token parsers with Twig.
@return void | [
"Temporarily",
"registers",
"mail",
"based",
"token",
"parsers",
"with",
"Twig",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MailManager.php#L296-L309 | train | Starts Twig. | [
30522,
5123,
3853,
2707,
2102,
16279,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
21541,
16279,
14117,
3064,
1007,
1063,
2709,
1025,
1065,
1002,
2023,
1011,
1028,
21541,
16279,
14117,
3064,
1027,
2995,
1025,
1002,
2928,
6279,
2480... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php | CollectionType.buildView | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars = array_replace($view->vars, [
'allow_add' => $options['allow_add'],
'allow_delete' => $options['allow_delete'],
]);
if ($form->getConfig()->hasAttribute('prototype')) {
$prototype = $form->getConfig()->getAttribute('prototype');
$view->vars['prototype'] = $prototype->setParent($form)->createView($view);
}
} | php | public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars = array_replace($view->vars, [
'allow_add' => $options['allow_add'],
'allow_delete' => $options['allow_delete'],
]);
if ($form->getConfig()->hasAttribute('prototype')) {
$prototype = $form->getConfig()->getAttribute('prototype');
$view->vars['prototype'] = $prototype->setParent($form)->createView($view);
}
} | [
"public",
"function",
"buildView",
"(",
"FormView",
"$",
"view",
",",
"FormInterface",
"$",
"form",
",",
"array",
"$",
"options",
")",
"{",
"$",
"view",
"->",
"vars",
"=",
"array_replace",
"(",
"$",
"view",
"->",
"vars",
",",
"[",
"'allow_add'",
"=>",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Core/Type/CollectionType.php#L57-L68 | train | Build the view | [
30522,
2270,
3853,
3857,
8584,
1006,
2433,
8584,
1002,
3193,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
9140,
1002,
7047,
1007,
1063,
1002,
3193,
1011,
1028,
13075,
2015,
1027,
9140,
1035,
5672,
1006,
1002,
3193,
1011,
1028,
13075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
overtrue/wechat | src/OpenPlatform/Application.php | Application.getPreAuthorizationUrl | public function getPreAuthorizationUrl(string $callbackUrl, $optional = []): string
{
// 兼容旧版 API 设计
if (\is_string($optional)) {
$optional = [
'pre_auth_code' => $optional,
];
} else {
$optional['pre_auth_code'] = $this->createPreAuthorizationCode()['pre_auth_code'];
}
$queries = \array_merge($optional, [
'component_appid' => $this['config']['app_id'],
'redirect_uri' => $callbackUrl,
]);
return 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?'.http_build_query($queries);
} | php | public function getPreAuthorizationUrl(string $callbackUrl, $optional = []): string
{
// 兼容旧版 API 设计
if (\is_string($optional)) {
$optional = [
'pre_auth_code' => $optional,
];
} else {
$optional['pre_auth_code'] = $this->createPreAuthorizationCode()['pre_auth_code'];
}
$queries = \array_merge($optional, [
'component_appid' => $this['config']['app_id'],
'redirect_uri' => $callbackUrl,
]);
return 'https://mp.weixin.qq.com/cgi-bin/componentloginpage?'.http_build_query($queries);
} | [
"public",
"function",
"getPreAuthorizationUrl",
"(",
"string",
"$",
"callbackUrl",
",",
"$",
"optional",
"=",
"[",
"]",
")",
":",
"string",
"{",
"// 兼容旧版 API 设计",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"optional",
")",
")",
"{",
"$",
"optional",
"=",
"[... | Return the pre-authorization login page url.
@param string $callbackUrl
@param string|array|null $optional
@return string | [
"Return",
"the",
"pre",
"-",
"authorization",
"login",
"page",
"url",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenPlatform/Application.php#L119-L136 | train | Get pre authorization url | [
30522,
2270,
3853,
2131,
28139,
4887,
27844,
3989,
3126,
2140,
1006,
5164,
1002,
2655,
5963,
3126,
2140,
1010,
1002,
11887,
1027,
1031,
1033,
1007,
1024,
5164,
1063,
1013,
1013,
100,
100,
100,
1907,
17928,
100,
100,
2065,
1006,
1032,
2003... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Queue/Console/TableCommand.php | TableCommand.handle | public function handle()
{
$table = $this->laravel['config']['queue.connections.database.table'];
$this->replaceMigration(
$this->createBaseMigration($table), $table, Str::studly($table)
);
$this->info('Migration created successfully!');
$this->composer->dumpAutoloads();
} | php | public function handle()
{
$table = $this->laravel['config']['queue.connections.database.table'];
$this->replaceMigration(
$this->createBaseMigration($table), $table, Str::studly($table)
);
$this->info('Migration created successfully!');
$this->composer->dumpAutoloads();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'config'",
"]",
"[",
"'queue.connections.database.table'",
"]",
";",
"$",
"this",
"->",
"replaceMigration",
"(",
"$",
"this",
"->",
"createBaseMigration",
"... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Queue/Console/TableCommand.php#L58-L69 | train | Create base migration and dump autoloader | [
30522,
2270,
3853,
5047,
1006,
1007,
1063,
1002,
2795,
1027,
1002,
2023,
1011,
1028,
13679,
15985,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
1031,
1005,
24240,
1012,
7264,
1012,
7809,
1012,
2795,
1005,
1033,
1025,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Table/Row/Abstract.php | Zend_Db_Table_Row_Abstract.setFromArray | public function setFromArray(array $data)
{
$data = array_intersect_key($data, $this->_data);
foreach ($data as $columnName => $value) {
$this->__set($columnName, $value);
}
return $this;
} | php | public function setFromArray(array $data)
{
$data = array_intersect_key($data, $this->_data);
foreach ($data as $columnName => $value) {
$this->__set($columnName, $value);
}
return $this;
} | [
"public",
"function",
"setFromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"array_intersect_key",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"_data",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"columnName",
"=>",
"$",
"value",
... | Sets all data in the row from an array.
@param array $data
@return Zend_Db_Table_Row_Abstract Provides a fluent interface | [
"Sets",
"all",
"data",
"in",
"the",
"row",
"from",
"an",
"array",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Row/Abstract.php#L666-L675 | train | Set the values of the object from an array | [
30522,
2270,
3853,
2275,
19699,
9626,
11335,
2100,
1006,
9140,
1002,
2951,
1007,
1063,
1002,
2951,
1027,
9140,
1035,
29261,
1035,
3145,
1006,
1002,
2951,
1010,
1002,
2023,
1011,
1028,
1035,
2951,
1007,
1025,
18921,
6776,
1006,
1002,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/DomCrawler/Crawler.php | Crawler.xpathLiteral | public static function xpathLiteral($s)
{
if (false === strpos($s, "'")) {
return sprintf("'%s'", $s);
}
if (false === strpos($s, '"')) {
return sprintf('"%s"', $s);
}
$string = $s;
$parts = [];
while (true) {
if (false !== $pos = strpos($string, "'")) {
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
$parts[] = "\"'\"";
$string = substr($string, $pos + 1);
} else {
$parts[] = "'$string'";
break;
}
}
return sprintf('concat(%s)', implode(', ', $parts));
} | php | public static function xpathLiteral($s)
{
if (false === strpos($s, "'")) {
return sprintf("'%s'", $s);
}
if (false === strpos($s, '"')) {
return sprintf('"%s"', $s);
}
$string = $s;
$parts = [];
while (true) {
if (false !== $pos = strpos($string, "'")) {
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
$parts[] = "\"'\"";
$string = substr($string, $pos + 1);
} else {
$parts[] = "'$string'";
break;
}
}
return sprintf('concat(%s)', implode(', ', $parts));
} | [
"public",
"static",
"function",
"xpathLiteral",
"(",
"$",
"s",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"s",
",",
"\"'\"",
")",
")",
"{",
"return",
"sprintf",
"(",
"\"'%s'\"",
",",
"$",
"s",
")",
";",
"}",
"if",
"(",
"false",
"===... | Converts string for XPath expressions.
Escaped characters are: quotes (") and apostrophe (').
Examples:
echo Crawler::xpathLiteral('foo " bar');
//prints 'foo " bar'
echo Crawler::xpathLiteral("foo ' bar");
//prints "foo ' bar"
echo Crawler::xpathLiteral('a\'b"c');
//prints concat('a', "'", 'b"c')
@param string $s String to be escaped
@return string Converted string | [
"Converts",
"string",
"for",
"XPath",
"expressions",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DomCrawler/Crawler.php#L928-L952 | train | Converts a string like a xpath literal to a string | [
30522,
2270,
10763,
3853,
26726,
8988,
22779,
7941,
1006,
1002,
1055,
1007,
1063,
2065,
1006,
6270,
1027,
1027,
1027,
2358,
14536,
2891,
1006,
1002,
1055,
1010,
1000,
1005,
1000,
1007,
1007,
1063,
2709,
9043,
2546,
1006,
1000,
1005,
1003,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Framework/Flex/FlexForm.php | FlexForm.filterData | protected function filterData(\ArrayAccess $data): void
{
if ($data instanceof Data) {
$data->filter(true, true);
}
} | php | protected function filterData(\ArrayAccess $data): void
{
if ($data instanceof Data) {
$data->filter(true, true);
}
} | [
"protected",
"function",
"filterData",
"(",
"\\",
"ArrayAccess",
"$",
"data",
")",
":",
"void",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Data",
")",
"{",
"$",
"data",
"->",
"filter",
"(",
"true",
",",
"true",
")",
";",
"}",
"}"
] | Filter validated data.
@param \ArrayAccess $data | [
"Filter",
"validated",
"data",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexForm.php#L337-L342 | train | Filter data to avoid memory leaks | [
30522,
5123,
3853,
11307,
2850,
2696,
1006,
1032,
9140,
6305,
9623,
2015,
1002,
2951,
1007,
1024,
11675,
1063,
2065,
1006,
1002,
2951,
6013,
11253,
2951,
1007,
1063,
1002,
2951,
1011,
1028,
11307,
1006,
2995,
1010,
2995,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/UserCountry/LocationProvider/GeoIp/Pecl.php | Pecl.getInfo | public function getInfo()
{
$desc = Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl1') . '<br/><br/>'
. Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl2');
$installDocs = '<a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/how-to/#faq_164">'
. Piwik::translate('UserCountry_HowToInstallGeoIpPecl')
. '</a>';
$extraMessage = false;
if ($this->isAvailable()) {
$peclDir = ini_get('geoip.custom_directory');
if ($peclDir === false) {
$extraMessage = Piwik::translate('UserCountry_GeoIPPeclCustomDirNotSet', "'geoip.custom_directory'");
} else {
$extraMessage = 'The \'geoip.custom_directory\' PHP ini option is set to \'' . $peclDir . '\'.';
}
$availableDatabaseTypes = array();
if (self::isCityDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_City');
}
if (self::isRegionDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Region');
}
if (self::isCountryDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Country');
}
if (self::isISPDatabaseAvailable()) {
$availableDatabaseTypes[] = 'ISP';
}
if (self::isOrgDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Organization');
}
$extraMessage .= '<br/><br/>' . Piwik::translate('UserCountry_GeoIPImplHasAccessTo') . ': <strong>'
. implode(', ', $availableDatabaseTypes) . '</strong>.';
$extraMessage = '<strong>' . Piwik::translate('General_Note') . ': </strong>' . $extraMessage;
}
return array('id' => self::ID,
'title' => self::TITLE,
'description' => $desc,
'install_docs' => $installDocs,
'extra_message' => $extraMessage,
'order' => 13);
} | php | public function getInfo()
{
$desc = Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl1') . '<br/><br/>'
. Piwik::translate('UserCountry_GeoIpLocationProviderDesc_Pecl2');
$installDocs = '<a rel="noreferrer noopener" target="_blank" href="https://matomo.org/faq/how-to/#faq_164">'
. Piwik::translate('UserCountry_HowToInstallGeoIpPecl')
. '</a>';
$extraMessage = false;
if ($this->isAvailable()) {
$peclDir = ini_get('geoip.custom_directory');
if ($peclDir === false) {
$extraMessage = Piwik::translate('UserCountry_GeoIPPeclCustomDirNotSet', "'geoip.custom_directory'");
} else {
$extraMessage = 'The \'geoip.custom_directory\' PHP ini option is set to \'' . $peclDir . '\'.';
}
$availableDatabaseTypes = array();
if (self::isCityDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_City');
}
if (self::isRegionDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Region');
}
if (self::isCountryDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Country');
}
if (self::isISPDatabaseAvailable()) {
$availableDatabaseTypes[] = 'ISP';
}
if (self::isOrgDatabaseAvailable()) {
$availableDatabaseTypes[] = Piwik::translate('UserCountry_Organization');
}
$extraMessage .= '<br/><br/>' . Piwik::translate('UserCountry_GeoIPImplHasAccessTo') . ': <strong>'
. implode(', ', $availableDatabaseTypes) . '</strong>.';
$extraMessage = '<strong>' . Piwik::translate('General_Note') . ': </strong>' . $extraMessage;
}
return array('id' => self::ID,
'title' => self::TITLE,
'description' => $desc,
'install_docs' => $installDocs,
'extra_message' => $extraMessage,
'order' => 13);
} | [
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"desc",
"=",
"Piwik",
"::",
"translate",
"(",
"'UserCountry_GeoIpLocationProviderDesc_Pecl1'",
")",
".",
"'<br/><br/>'",
".",
"Piwik",
"::",
"translate",
"(",
"'UserCountry_GeoIpLocationProviderDesc_Pecl2'",
")",
";... | Returns information about this location provider. Contains an id, title & description:
array(
'id' => 'geoip_pecl',
'title' => '...',
'description' => '...'
);
@return array | [
"Returns",
"information",
"about",
"this",
"location",
"provider",
".",
"Contains",
"an",
"id",
"title",
"&",
"description",
":"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UserCountry/LocationProvider/GeoIp/Pecl.php#L216-L262 | train | Returns the info about the country | [
30522,
2270,
3853,
2131,
2378,
14876,
1006,
1007,
1063,
1002,
4078,
2278,
1027,
14255,
9148,
2243,
1024,
1024,
17637,
1006,
1005,
5310,
3597,
16671,
2854,
1035,
20248,
11514,
4135,
10719,
21572,
17258,
2121,
6155,
2278,
1035,
21877,
20464,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Config/Writer.php | Zend_Config_Writer.setOptions | public function setOptions(array $options)
{
foreach ($options as $key => $value) {
if (in_array(strtolower($key), $this->_skipOptions)) {
continue;
}
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
return $this;
} | php | public function setOptions(array $options)
{
foreach ($options as $key => $value) {
if (in_array(strtolower($key), $this->_skipOptions)) {
continue;
}
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"key",
")",
",",
"$",
"this",
"->",
"_sk... | Set options via an array
@param array $options
@return Zend_Config_Writer | [
"Set",
"options",
"via",
"an",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Config/Writer.php#L79-L93 | train | Set options for this object | [
30522,
2270,
3853,
2275,
30524,
1063,
3613,
1025,
1065,
1002,
4118,
1027,
1005,
2275,
1005,
1012,
15384,
8873,
12096,
1006,
1002,
3145,
1007,
1025,
2065,
1006,
4118,
1035,
6526,
1006,
1002,
2023,
1010,
1002,
4118,
1007,
1007,
1063,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Db/Adapter/Mysqli.php | Zend_Db_Adapter_Mysqli.prepare | public function prepare($sql)
{
$this->_connect();
if ($this->_stmt) {
$this->_stmt->close();
}
$stmtClass = $this->_defaultStmtClass;
if (!class_exists($stmtClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($stmtClass);
}
$stmt = new $stmtClass($this, $sql);
if ($stmt === false) {
return false;
}
$stmt->setFetchMode($this->_fetchMode);
$this->_stmt = $stmt;
return $stmt;
} | php | public function prepare($sql)
{
$this->_connect();
if ($this->_stmt) {
$this->_stmt->close();
}
$stmtClass = $this->_defaultStmtClass;
if (!class_exists($stmtClass)) {
// require_once 'Zend/Loader.php';
Zend_Loader::loadClass($stmtClass);
}
$stmt = new $stmtClass($this, $sql);
if ($stmt === false) {
return false;
}
$stmt->setFetchMode($this->_fetchMode);
$this->_stmt = $stmt;
return $stmt;
} | [
"public",
"function",
"prepare",
"(",
"$",
"sql",
")",
"{",
"$",
"this",
"->",
"_connect",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_stmt",
")",
"{",
"$",
"this",
"->",
"_stmt",
"->",
"close",
"(",
")",
";",
"}",
"$",
"stmtClass",
"=",
"$"... | Prepare a statement and return a PDOStatement-like object.
@param string $sql SQL query
@return Zend_Db_Statement_Mysqli | [
"Prepare",
"a",
"statement",
"and",
"return",
"a",
"PDOStatement",
"-",
"like",
"object",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Adapter/Mysqli.php#L406-L424 | train | Prepare statement for execution | [
30522,
2270,
3853,
7374,
1006,
1002,
29296,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
7532,
1006,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1011,
1028,
2485,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/View.php | View.assign | public function assign($var, $value = null)
{
if (is_string($var)) {
$this->$var = $value;
} elseif (is_array($var)) {
foreach ($var as $key => $value) {
$this->$key = $value;
}
}
} | php | public function assign($var, $value = null)
{
if (is_string($var)) {
$this->$var = $value;
} elseif (is_array($var)) {
foreach ($var as $key => $value) {
$this->$key = $value;
}
}
} | [
"public",
"function",
"assign",
"(",
"$",
"var",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"var",
")",
")",
"{",
"$",
"this",
"->",
"$",
"var",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
... | Assign value to a variable for use in a template
@param string|array $var
@param mixed $value
@ignore | [
"Assign",
"value",
"to",
"a",
"variable",
"for",
"use",
"in",
"a",
"template"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/View.php#L410-L419 | train | Assign a value to the class variables | [
30522,
2270,
3853,
23911,
1006,
1002,
13075,
1010,
1002,
3643,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
5164,
1006,
1002,
13075,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
1002,
13075,
1027,
1002,
3643,
1025,
1065,
2842,
10128,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Translation/Dumper/PhpFileDumper.php | PhpFileDumper.formatCatalogue | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
return "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
} | php | public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = [])
{
return "<?php\n\nreturn ".var_export($messages->all($domain), true).";\n";
} | [
"public",
"function",
"formatCatalogue",
"(",
"MessageCatalogue",
"$",
"messages",
",",
"$",
"domain",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"\"<?php\\n\\nreturn \"",
".",
"var_export",
"(",
"$",
"messages",
"->",
"all",
"(",
"$",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Dumper/PhpFileDumper.php#L26-L29 | train | Format the message catalogue into a PHP string | [
30522,
2270,
3853,
4289,
11266,
23067,
9077,
1006,
4471,
11266,
23067,
9077,
1002,
7696,
1010,
1002,
5884,
1010,
9140,
1002,
7047,
1027,
1031,
1033,
1007,
1063,
2709,
1000,
1026,
1029,
25718,
1032,
1050,
1032,
17212,
3388,
14287,
1000,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
barryvdh/laravel-debugbar | src/DataCollector/LaravelCollector.php | LaravelCollector.collect | public function collect()
{
// Fallback if not injected
$app = $this->app ?: app();
return [
"version" => $app::VERSION,
"environment" => $app->environment(),
"locale" => $app->getLocale(),
];
} | php | public function collect()
{
// Fallback if not injected
$app = $this->app ?: app();
return [
"version" => $app::VERSION,
"environment" => $app->environment(),
"locale" => $app->getLocale(),
];
} | [
"public",
"function",
"collect",
"(",
")",
"{",
"// Fallback if not injected",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
"?",
":",
"app",
"(",
")",
";",
"return",
"[",
"\"version\"",
"=>",
"$",
"app",
"::",
"VERSION",
",",
"\"environment\"",
"=>",
"$",
... | {@inheritDoc} | [
"{"
] | 2d195779ea4f809f69764a795e2ec371dbb76a96 | https://github.com/barryvdh/laravel-debugbar/blob/2d195779ea4f809f69764a795e2ec371dbb76a96/src/DataCollector/LaravelCollector.php#L25-L35 | train | Collect the array of all the configuration options | [
30522,
2270,
3853,
8145,
1006,
1007,
1063,
1013,
1013,
2991,
5963,
2065,
2025,
19737,
1002,
10439,
1027,
1002,
2023,
1011,
1028,
10439,
1029,
1024,
10439,
1006,
1007,
1025,
2709,
1031,
1000,
2544,
1000,
1027,
1028,
1002,
10439,
1024,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php | WorkflowExtension.canTransition | public function canTransition($subject, $transitionName, $name = null)
{
return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName);
} | php | public function canTransition($subject, $transitionName, $name = null)
{
return $this->workflowRegistry->get($subject, $name)->can($subject, $transitionName);
} | [
"public",
"function",
"canTransition",
"(",
"$",
"subject",
",",
"$",
"transitionName",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"workflowRegistry",
"->",
"get",
"(",
"$",
"subject",
",",
"$",
"name",
")",
"->",
"can",
"(",... | Returns true if the transition is enabled.
@param object $subject A subject
@param string $transitionName A transition
@param string $name A workflow name
@return bool true if the transition is enabled | [
"Returns",
"true",
"if",
"the",
"transition",
"is",
"enabled",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php#L55-L58 | train | Can transition a subject | [
30522,
2270,
3853,
2064,
6494,
3619,
22753,
1006,
1002,
3395,
1010,
1002,
6653,
18442,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
2147,
12314,
2890,
24063,
2854,
1011,
1028,
2131,
1006,
1002,
3395,
1010,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | BelongsToMany.updateOrCreate | public function updateOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true)
{
if (is_null($instance = $this->where($attributes)->first())) {
return $this->create($values, $joining, $touch);
}
$instance->fill($values);
$instance->save(['touch' => false]);
return $instance;
} | php | public function updateOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true)
{
if (is_null($instance = $this->where($attributes)->first())) {
return $this->create($values, $joining, $touch);
}
$instance->fill($values);
$instance->save(['touch' => false]);
return $instance;
} | [
"public",
"function",
"updateOrCreate",
"(",
"array",
"$",
"attributes",
",",
"array",
"$",
"values",
"=",
"[",
"]",
",",
"array",
"$",
"joining",
"=",
"[",
"]",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"instance",
... | Create or update a related record matching the attributes, and fill it with values.
@param array $attributes
@param array $values
@param array $joining
@param bool $touch
@return \Illuminate\Database\Eloquent\Model | [
"Create",
"or",
"update",
"a",
"related",
"record",
"matching",
"the",
"attributes",
"and",
"fill",
"it",
"with",
"values",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L485-L496 | train | Update or Create a record if it doesn t exist | [
30522,
2270,
3853,
10651,
2953,
16748,
3686,
1006,
9140,
1002,
12332,
1010,
9140,
1002,
5300,
1027,
1031,
1033,
1010,
9140,
1002,
5241,
1027,
1031,
1033,
1010,
1002,
3543,
1027,
2995,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Period/Range.php | Range.processOptimalSubperiods | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate) {
$endOfPeriod = null;
$month = new Month($startDate);
$endOfMonth = $month->getDateEnd();
$startOfMonth = $month->getDateStart();
$year = new Year($startDate);
$endOfYear = $year->getDateEnd();
$startOfYear = $year->getDateStart();
if ($startDate == $startOfYear
&& ($endOfYear->isEarlier($endDate)
|| $endOfYear == $endDate
|| $endOfYear->isLater($this->today)
)
// We don't use the year if
// the end day is in this year, is before today, and year not finished
&& !($endDate->isEarlier($this->today)
&& $this->today->toString('Y') == $endOfYear->toString('Y')
&& $this->today->compareYear($endOfYear) == 0)
) {
$this->addSubperiod($year);
$endOfPeriod = $endOfYear;
} elseif ($startDate == $startOfMonth
&& ($endOfMonth->isEarlier($endDate)
|| $endOfMonth == $endDate
|| $endOfMonth->isLater($this->today)
)
// We don't use the month if
// the end day is in this month, is before today, and month not finished
&& !($endDate->isEarlier($this->today)
&& $this->today->toString('Y') == $endOfMonth->toString('Y')
&& $this->today->compareMonth($endOfMonth) == 0)
) {
$this->addSubperiod($month);
$endOfPeriod = $endOfMonth;
} else {
// From start date,
// Process end of week
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
$firstDayNextMonth = $startDate->addPeriod(2, 'month')->setDay(1);
$useMonthsNextIteration = $firstDayNextMonth->isEarlier($endDate);
if ($useMonthsNextIteration
&& $endOfWeek->isLater($endOfMonth)
) {
$this->fillArraySubPeriods($startDate, $endOfMonth, 'day');
$endOfPeriod = $endOfMonth;
} // If end of this week is later than end date, we use days
elseif ($this->isEndOfWeekLaterThanEndDate($endDate, $endOfWeek) &&
($endOfWeek->isEarlier($this->today)
|| $startOfWeek->toString() != $startDate->toString()
|| $endDate->isEarlier($this->today))
) {
$this->fillArraySubPeriods($startDate, $endDate, 'day');
break 1;
} elseif ($startOfWeek->isEarlier($startDate)
&& $endOfWeek->isEarlier($this->today)
) {
$this->fillArraySubPeriods($startDate, $endOfWeek, 'day');
$endOfPeriod = $endOfWeek;
} else {
$this->addSubperiod($week);
$endOfPeriod = $endOfWeek;
}
}
$startDate = $endOfPeriod->addDay(1);
}
} | php | protected function processOptimalSubperiods($startDate, $endDate)
{
while ($startDate->isEarlier($endDate)
|| $startDate == $endDate) {
$endOfPeriod = null;
$month = new Month($startDate);
$endOfMonth = $month->getDateEnd();
$startOfMonth = $month->getDateStart();
$year = new Year($startDate);
$endOfYear = $year->getDateEnd();
$startOfYear = $year->getDateStart();
if ($startDate == $startOfYear
&& ($endOfYear->isEarlier($endDate)
|| $endOfYear == $endDate
|| $endOfYear->isLater($this->today)
)
// We don't use the year if
// the end day is in this year, is before today, and year not finished
&& !($endDate->isEarlier($this->today)
&& $this->today->toString('Y') == $endOfYear->toString('Y')
&& $this->today->compareYear($endOfYear) == 0)
) {
$this->addSubperiod($year);
$endOfPeriod = $endOfYear;
} elseif ($startDate == $startOfMonth
&& ($endOfMonth->isEarlier($endDate)
|| $endOfMonth == $endDate
|| $endOfMonth->isLater($this->today)
)
// We don't use the month if
// the end day is in this month, is before today, and month not finished
&& !($endDate->isEarlier($this->today)
&& $this->today->toString('Y') == $endOfMonth->toString('Y')
&& $this->today->compareMonth($endOfMonth) == 0)
) {
$this->addSubperiod($month);
$endOfPeriod = $endOfMonth;
} else {
// From start date,
// Process end of week
$week = new Week($startDate);
$startOfWeek = $week->getDateStart();
$endOfWeek = $week->getDateEnd();
$firstDayNextMonth = $startDate->addPeriod(2, 'month')->setDay(1);
$useMonthsNextIteration = $firstDayNextMonth->isEarlier($endDate);
if ($useMonthsNextIteration
&& $endOfWeek->isLater($endOfMonth)
) {
$this->fillArraySubPeriods($startDate, $endOfMonth, 'day');
$endOfPeriod = $endOfMonth;
} // If end of this week is later than end date, we use days
elseif ($this->isEndOfWeekLaterThanEndDate($endDate, $endOfWeek) &&
($endOfWeek->isEarlier($this->today)
|| $startOfWeek->toString() != $startDate->toString()
|| $endDate->isEarlier($this->today))
) {
$this->fillArraySubPeriods($startDate, $endDate, 'day');
break 1;
} elseif ($startOfWeek->isEarlier($startDate)
&& $endOfWeek->isEarlier($this->today)
) {
$this->fillArraySubPeriods($startDate, $endOfWeek, 'day');
$endOfPeriod = $endOfWeek;
} else {
$this->addSubperiod($week);
$endOfPeriod = $endOfWeek;
}
}
$startDate = $endOfPeriod->addDay(1);
}
} | [
"protected",
"function",
"processOptimalSubperiods",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
"{",
"while",
"(",
"$",
"startDate",
"->",
"isEarlier",
"(",
"$",
"endDate",
")",
"||",
"$",
"startDate",
"==",
"$",
"endDate",
")",
"{",
"$",
"endOfPerio... | Determine which kind of period is best to use.
See Range.test.php
@param Date $startDate
@param Date $endDate | [
"Determine",
"which",
"kind",
"of",
"period",
"is",
"best",
"to",
"use",
".",
"See",
"Range",
".",
"test",
".",
"php"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Period/Range.php#L325-L400 | train | Process Optimal Subperiods | [
30522,
5123,
3853,
2832,
7361,
3775,
9067,
6342,
2497,
4842,
3695,
5104,
1006,
1002,
2707,
13701,
1010,
1002,
2203,
13701,
1007,
1063,
2096,
1006,
1002,
2707,
13701,
1011,
1028,
2003,
14644,
14355,
1006,
1002,
2203,
13701,
1007,
1064,
1064,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getgrav/grav | system/src/Grav/Common/Page/Page.php | Page.getContentMeta | public function getContentMeta($name = null)
{
if ($name) {
if (isset($this->content_meta[$name])) {
return $this->content_meta[$name];
}
return null;
}
return $this->content_meta;
} | php | public function getContentMeta($name = null)
{
if ($name) {
if (isset($this->content_meta[$name])) {
return $this->content_meta[$name];
}
return null;
}
return $this->content_meta;
} | [
"public",
"function",
"getContentMeta",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content_meta",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"con... | Return the whole contentMeta array as it currently stands
@param string|null $name
@return string | [
"Return",
"the",
"whole",
"contentMeta",
"array",
"as",
"it",
"currently",
"stands"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Page.php#L789-L800 | train | Get content meta | [
30522,
2270,
3853,
2131,
8663,
6528,
21246,
12928,
1006,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2171,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
4180,
1035,
18804,
1031,
1002,
2171,
1033,
1007,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
symfony/symfony | src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php | NumberFormatter.create | public static function create($locale = 'en', $style = null, $pattern = null)
{
return new self($locale, $style, $pattern);
} | php | public static function create($locale = 'en', $style = null, $pattern = null)
{
return new self($locale, $style, $pattern);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"locale",
"=",
"'en'",
",",
"$",
"style",
"=",
"null",
",",
"$",
"pattern",
"=",
"null",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"locale",
",",
"$",
"style",
",",
"$",
"pattern",
")",
";",
... | Static constructor.
@param string $locale The locale code. The only supported locale is "en" (or null using the default locale, i.e. "en")
@param int $style Style of the formatting, one of the format style constants.
The only currently supported styles are NumberFormatter::DECIMAL
and NumberFormatter::CURRENCY.
@param string $pattern Not supported. A pattern string in case $style is NumberFormat::PATTERN_DECIMAL or
NumberFormat::PATTERN_RULEBASED. It must conform to the syntax
described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation
@return self
@see http://www.php.net/manual/en/numberformatter.create.php
@see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
@see http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details
@throws MethodArgumentValueNotImplementedException When $locale different than "en" or null is passed
@throws MethodArgumentValueNotImplementedException When the $style is not supported
@throws MethodArgumentNotImplementedException When the pattern value is different than null | [
"Static",
"constructor",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php#L299-L302 | train | Create a new Locale Style Pattern | [
30522,
2270,
10763,
3853,
3443,
1006,
1002,
2334,
2063,
1027,
1005,
4372,
1005,
1010,
1002,
2806,
1027,
19701,
1010,
1002,
5418,
1027,
19701,
1007,
1063,
2709,
2047,
2969,
1006,
1002,
2334,
2063,
1010,
1002,
2806,
1010,
1002,
5418,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | plugins/Annotations/AnnotationList.php | AnnotationList.augmentAnnotationData | private function augmentAnnotationData($idSite, $idNote, &$annotation)
{
$annotation['idNote'] = $idNote;
$annotation['canEditOrDelete'] = self::canUserModifyOrDelete($idSite, $annotation);
// we don't supply user info if the current user is anonymous
if (Piwik::isUserIsAnonymous()) {
unset($annotation['user']);
}
} | php | private function augmentAnnotationData($idSite, $idNote, &$annotation)
{
$annotation['idNote'] = $idNote;
$annotation['canEditOrDelete'] = self::canUserModifyOrDelete($idSite, $annotation);
// we don't supply user info if the current user is anonymous
if (Piwik::isUserIsAnonymous()) {
unset($annotation['user']);
}
} | [
"private",
"function",
"augmentAnnotationData",
"(",
"$",
"idSite",
",",
"$",
"idNote",
",",
"&",
"$",
"annotation",
")",
"{",
"$",
"annotation",
"[",
"'idNote'",
"]",
"=",
"$",
"idNote",
";",
"$",
"annotation",
"[",
"'canEditOrDelete'",
"]",
"=",
"self",
... | Adds extra data to an annotation, including the annotation's ID and whether
the current user can edit or delete it.
Also, if the current user is anonymous, the user attribute is removed.
@param int $idSite
@param int $idNote
@param array $annotation | [
"Adds",
"extra",
"data",
"to",
"an",
"annotation",
"including",
"the",
"annotation",
"s",
"ID",
"and",
"whether",
"the",
"current",
"user",
"can",
"edit",
"or",
"delete",
"it",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L408-L417 | train | augment the annotation data with the correct idNote and canEditOrDelete values | [
30522,
2797,
3853,
15476,
3672,
11639,
17287,
3508,
2850,
2696,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
22074,
1010,
1004,
30524,
5302,
4305,
12031,
8551,
12260,
2618,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
5754,
17287,
3508,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laravel/framework | src/Illuminate/Database/Concerns/ManagesTransactions.php | ManagesTransactions.commit | public function commit()
{
if ($this->transactions == 1) {
$this->getPdo()->commit();
}
$this->transactions = max(0, $this->transactions - 1);
$this->fireConnectionEvent('committed');
} | php | public function commit()
{
if ($this->transactions == 1) {
$this->getPdo()->commit();
}
$this->transactions = max(0, $this->transactions - 1);
$this->fireConnectionEvent('committed');
} | [
"public",
"function",
"commit",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"transactions",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"getPdo",
"(",
")",
"->",
"commit",
"(",
")",
";",
"}",
"$",
"this",
"->",
"transactions",
"=",
"max",
"(",
"0",
... | Commit the active database transaction.
@return void | [
"Commit",
"the",
"active",
"database",
"transaction",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Concerns/ManagesTransactions.php#L154-L163 | train | Commit all transactions | [
30522,
2270,
3853,
10797,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
11817,
1027,
1027,
1015,
1007,
1063,
1002,
2023,
1011,
1028,
2131,
17299,
2080,
1006,
1007,
1011,
1028,
10797,
1006,
1007,
1025,
1065,
1002,
2023,
1011,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | libs/Zend/Validate/File/Exists.php | Zend_Validate_File_Exists.getDirectory | public function getDirectory($asArray = false)
{
$asArray = (bool) $asArray;
$directory = (string) $this->_directory;
if ($asArray) {
$directory = explode(',', $directory);
}
return $directory;
} | php | public function getDirectory($asArray = false)
{
$asArray = (bool) $asArray;
$directory = (string) $this->_directory;
if ($asArray) {
$directory = explode(',', $directory);
}
return $directory;
} | [
"public",
"function",
"getDirectory",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"asArray",
"=",
"(",
"bool",
")",
"$",
"asArray",
";",
"$",
"directory",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_directory",
";",
"if",
"(",
"$",
"asArray",... | Returns the set file directories which are checked
@param boolean $asArray Returns the values as array, when false an concated string is returned
@return string | [
"Returns",
"the",
"set",
"file",
"directories",
"which",
"are",
"checked"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Validate/File/Exists.php#L88-L97 | train | Get directory of the file | [
30522,
2270,
3853,
2131,
4305,
2890,
16761,
2100,
1006,
1002,
17306,
11335,
2100,
1027,
6270,
1007,
1063,
1002,
17306,
11335,
2100,
1027,
1006,
22017,
2140,
1007,
1002,
17306,
11335,
2100,
1025,
1002,
14176,
1027,
1006,
5164,
1007,
1002,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
matomo-org/matomo | core/Plugin/ComponentFactory.php | ComponentFactory.factory | public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__, $pluginName, $componentClassSimpleName);
return null;
}
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
$desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
foreach ($components as $class) {
if ($class == $desiredComponentClass) {
return new $class();
}
}
Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);
return null;
} | php | public static function factory($pluginName, $componentClassSimpleName, $componentTypeClass)
{
if (empty($pluginName) || empty($componentClassSimpleName)) {
Log::debug("ComponentFactory::%s: empty plugin name or component simple name requested (%s, %s)",
__FUNCTION__, $pluginName, $componentClassSimpleName);
return null;
}
$plugin = self::getActivatedPlugin(__FUNCTION__, $pluginName);
if (empty($plugin)) {
return null;
}
$subnamespace = $componentTypeClass::COMPONENT_SUBNAMESPACE;
$desiredComponentClass = 'Piwik\\Plugins\\' . $pluginName . '\\' . $subnamespace . '\\' . $componentClassSimpleName;
$components = $plugin->findMultipleComponents($subnamespace, $componentTypeClass);
foreach ($components as $class) {
if ($class == $desiredComponentClass) {
return new $class();
}
}
Log::debug("ComponentFactory::%s: Could not find requested component (args = ['%s', '%s', '%s']).",
__FUNCTION__, $pluginName, $componentClassSimpleName, $componentTypeClass);
return null;
} | [
"public",
"static",
"function",
"factory",
"(",
"$",
"pluginName",
",",
"$",
"componentClassSimpleName",
",",
"$",
"componentTypeClass",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"pluginName",
")",
"||",
"empty",
"(",
"$",
"componentClassSimpleName",
")",
")",
... | Create a component instance that exists within a specific plugin. Uses the component's
unqualified class name and expected base type.
This method will only create a class if it is located within the component type's
associated subdirectory.
@param string $pluginName The name of the plugin the component is expected to belong to,
eg, `'DevicesDetection'`.
@param string $componentClassSimpleName The component's class name w/o namespace, eg,
`"GetKeywords"`.
@param string $componentTypeClass The fully qualified class name of the component type, eg,
`"Piwik\Plugin\Report"`.
@return mixed|null A new instance of the desired component or null if not found. If the
plugin is not loaded or activated or the component is not located in
in the sub-namespace specified by `$componentTypeClass::COMPONENT_SUBNAMESPACE`,
this method will return null. | [
"Create",
"a",
"component",
"instance",
"that",
"exists",
"within",
"a",
"specific",
"plugin",
".",
"Uses",
"the",
"component",
"s",
"unqualified",
"class",
"name",
"and",
"expected",
"base",
"type",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/ComponentFactory.php#L37-L65 | train | Factory method to create a new component | [
30522,
2270,
10763,
3853,
4713,
1006,
1002,
13354,
23111,
14074,
1010,
1002,
6922,
26266,
5332,
23344,
18442,
1010,
1002,
6922,
13874,
26266,
1007,
1063,
2065,
1006,
4064,
1006,
1002,
13354,
23111,
14074,
1007,
1064,
1064,
4064,
1006,
1002,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 8