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 listlengths 27 7.5k | docstring stringlengths 6 1.88k | docstring_tokens listlengths 1 177 | sha stringclasses 21 values | url stringlengths 100 189 | partition stringclasses 1 value | summary stringlengths 9 340 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
symfony/symfony | src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php | LocaleBundle.getLocaleName | public function getLocaleName($locale, $displayLocale = null)
{
try {
return $this->getName($locale, $displayLocale);
} catch (MissingResourceException $e) {
return;
}
} | php | public function getLocaleName($locale, $displayLocale = null)
{
try {
return $this->getName($locale, $displayLocale);
} catch (MissingResourceException $e) {
return;
}
} | [
"public",
"function",
"getLocaleName",
"(",
"$",
"locale",
",",
"$",
"displayLocale",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getName",
"(",
"$",
"locale",
",",
"$",
"displayLocale",
")",
";",
"}",
"catch",
"(",
"MissingResourceE... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Intl/ResourceBundle/LocaleBundle.php#L41-L48 | train | Get Locale Name | [
30522,
2270,
3853,
2131,
4135,
9289,
8189,
4168,
1006,
1002,
2334,
2063,
1010,
1002,
4653,
4135,
9289,
2063,
1027,
19701,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
2131,
18442,
1006,
1002,
2334,
2063,
1010,
1002,
4653,
4135,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Kernel/Log/LogManager.php | LogManager.formatter | protected function formatter()
{
$formatter = new LineFormatter(null, null, true, true);
$formatter->includeStacktraces();
return $formatter;
} | php | protected function formatter()
{
$formatter = new LineFormatter(null, null, true, true);
$formatter->includeStacktraces();
return $formatter;
} | [
"protected",
"function",
"formatter",
"(",
")",
"{",
"$",
"formatter",
"=",
"new",
"LineFormatter",
"(",
"null",
",",
"null",
",",
"true",
",",
"true",
")",
";",
"$",
"formatter",
"->",
"includeStacktraces",
"(",
")",
";",
"return",
"$",
"formatter",
";"... | Get a Monolog formatter instance.
@return \Monolog\Formatter\FormatterInterface | [
"Get",
"a",
"Monolog",
"formatter",
"instance",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Kernel/Log/LogManager.php#L328-L334 | train | Returns LineFormatter instance | [
30522,
5123,
3853,
4289,
3334,
1006,
1007,
1063,
1002,
4289,
3334,
1027,
2047,
2240,
14192,
20097,
1006,
19701,
1010,
19701,
1010,
2995,
1010,
2995,
1007,
1025,
1002,
4289,
3334,
1011,
1028,
2950,
2696,
3600,
6494,
9623,
1006,
1007,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Statement/Pdo.php | Zend_Db_Statement_Pdo.closeCursor | public function closeCursor()
{
try {
return $this->_stmt->closeCursor();
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | php | public function closeCursor()
{
try {
return $this->_stmt->closeCursor();
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
}
} | [
"public",
"function",
"closeCursor",
"(",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"_stmt",
"->",
"closeCursor",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"// require_once 'Zend/Db/Statement/Exception.php';",
"throw",
"new... | Closes the cursor, allowing the statement to be executed again.
@return bool
@throws Zend_Db_Statement_Exception | [
"Closes",
"the",
"cursor",
"allowing",
"the",
"statement",
"to",
"be",
"executed",
"again",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Pdo.php#L156-L164 | train | Close cursor and return true if statement was executed successfully | [
30522,
2270,
3853,
2485,
10841,
25301,
2099,
1006,
1007,
1063,
3046,
1063,
2709,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1011,
1028,
2485,
10841,
25301,
2099,
1006,
1007,
1025,
1065,
4608,
1006,
22851,
8913,
2595,
24422,
1002,
1041,
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... |
laravel/framework | src/Illuminate/Database/Concerns/ManagesTransactions.php | ManagesTransactions.rollBack | public function rollBack($toLevel = null)
{
// We allow developers to rollback to a certain transaction level. We will verify
// that this given transaction level is valid before attempting to rollback to
// that level. If it's not we will just return out and not attempt anything.
$toLevel = is_null($toLevel)
? $this->transactions - 1
: $toLevel;
if ($toLevel < 0 || $toLevel >= $this->transactions) {
return;
}
// Next, we will actually perform this rollback within this database and fire the
// rollback event. We will also set the current transaction level to the given
// level that was passed into this method so it will be right from here out.
try {
$this->performRollBack($toLevel);
} catch (Exception $e) {
$this->handleRollBackException($e);
}
$this->transactions = $toLevel;
$this->fireConnectionEvent('rollingBack');
} | php | public function rollBack($toLevel = null)
{
// We allow developers to rollback to a certain transaction level. We will verify
// that this given transaction level is valid before attempting to rollback to
// that level. If it's not we will just return out and not attempt anything.
$toLevel = is_null($toLevel)
? $this->transactions - 1
: $toLevel;
if ($toLevel < 0 || $toLevel >= $this->transactions) {
return;
}
// Next, we will actually perform this rollback within this database and fire the
// rollback event. We will also set the current transaction level to the given
// level that was passed into this method so it will be right from here out.
try {
$this->performRollBack($toLevel);
} catch (Exception $e) {
$this->handleRollBackException($e);
}
$this->transactions = $toLevel;
$this->fireConnectionEvent('rollingBack');
} | [
"public",
"function",
"rollBack",
"(",
"$",
"toLevel",
"=",
"null",
")",
"{",
"// We allow developers to rollback to a certain transaction level. We will verify",
"// that this given transaction level is valid before attempting to rollback to",
"// that level. If it's not we will just return... | Rollback the active database transaction.
@param int|null $toLevel
@return void
@throws \Exception | [
"Rollback",
"the",
"active",
"database",
"transaction",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Concerns/ManagesTransactions.php#L173-L198 | train | Rollbacks the current transaction to a specific level. | [
30522,
2270,
3853,
4897,
5963,
1006,
1002,
2000,
20414,
2884,
1027,
19701,
1007,
1063,
1013,
1013,
2057,
3499,
9797,
2000,
4897,
5963,
2000,
1037,
3056,
12598,
2504,
1012,
2057,
2097,
20410,
1013,
1013,
2008,
2023,
2445,
12598,
2504,
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... |
z-song/laravel-admin | src/Console/ResourceGenerator.php | ResourceGenerator.getTableColumns | protected function getTableColumns()
{
if (!$this->model->getConnection()->isDoctrineAvailable()) {
throw new \Exception(
'You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. '
);
}
$table = $this->model->getConnection()->getTablePrefix().$this->model->getTable();
/** @var \Doctrine\DBAL\Schema\MySqlSchemaManager $schema */
$schema = $this->model->getConnection()->getDoctrineSchemaManager($table);
// custom mapping the types that doctrine/dbal does not support
$databasePlatform = $schema->getDatabasePlatform();
foreach ($this->doctrineTypeMapping as $doctrineType => $dbTypes) {
foreach ($dbTypes as $dbType) {
$databasePlatform->registerDoctrineTypeMapping($dbType, $doctrineType);
}
}
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
}
return $schema->listTableColumns($table, $database);
} | php | protected function getTableColumns()
{
if (!$this->model->getConnection()->isDoctrineAvailable()) {
throw new \Exception(
'You need to require doctrine/dbal: ~2.3 in your own composer.json to get database columns. '
);
}
$table = $this->model->getConnection()->getTablePrefix().$this->model->getTable();
/** @var \Doctrine\DBAL\Schema\MySqlSchemaManager $schema */
$schema = $this->model->getConnection()->getDoctrineSchemaManager($table);
// custom mapping the types that doctrine/dbal does not support
$databasePlatform = $schema->getDatabasePlatform();
foreach ($this->doctrineTypeMapping as $doctrineType => $dbTypes) {
foreach ($dbTypes as $dbType) {
$databasePlatform->registerDoctrineTypeMapping($dbType, $doctrineType);
}
}
$database = null;
if (strpos($table, '.')) {
list($database, $table) = explode('.', $table);
}
return $schema->listTableColumns($table, $database);
} | [
"protected",
"function",
"getTableColumns",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"model",
"->",
"getConnection",
"(",
")",
"->",
"isDoctrineAvailable",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'You need to require doctrine/dbal... | Get columns of a giving model.
@throws \Exception
@return \Doctrine\DBAL\Schema\Column[] | [
"Get",
"columns",
"of",
"a",
"giving",
"model",
"."
] | 3e65086f806b54699145f58af53843e5dbbb7994 | https://github.com/z-song/laravel-admin/blob/3e65086f806b54699145f58af53843e5dbbb7994/src/Console/ResourceGenerator.php#L214-L241 | train | Get table columns | [
30522,
5123,
3853,
2131,
10880,
25778,
2819,
3619,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2944,
1011,
1028,
2131,
8663,
2638,
7542,
1006,
1007,
1011,
1028,
2003,
3527,
6593,
11467,
12462,
11733,
3468,
1006,
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... |
matomo-org/matomo | core/DataTable/Filter/Pattern.php | Pattern.filterArray | public function filterArray($array)
{
$newArray = array();
foreach ($array as $key => $row) {
foreach ($this->columnToFilter as $column) {
if (!array_key_exists($column, $row)) {
continue;
}
if (self::match($this->patternToSearchQuoted, $row[$column], $this->invertedMatch)) {
$newArray[$key] = $row;
continue 2;
}
}
}
return $newArray;
} | php | public function filterArray($array)
{
$newArray = array();
foreach ($array as $key => $row) {
foreach ($this->columnToFilter as $column) {
if (!array_key_exists($column, $row)) {
continue;
}
if (self::match($this->patternToSearchQuoted, $row[$column], $this->invertedMatch)) {
$newArray[$key] = $row;
continue 2;
}
}
}
return $newArray;
} | [
"public",
"function",
"filterArray",
"(",
"$",
"array",
")",
"{",
"$",
"newArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"columnToFilter",
"as",
"... | See {@link Pattern}.
@param array $array
@return array | [
"See",
"{",
"@link",
"Pattern",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable/Filter/Pattern.php#L106-L124 | train | Filter array by column to filter | [
30522,
2270,
3853,
11307,
2906,
9447,
1006,
1002,
9140,
1007,
1063,
1002,
2047,
2906,
9447,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
9140,
2004,
1002,
3145,
1027,
1028,
1002,
5216,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Statement/Oracle.php | Zend_Db_Statement_Oracle.closeCursor | public function closeCursor()
{
if (!$this->_stmt) {
return false;
}
oci_free_statement($this->_stmt);
$this->_stmt = false;
return true;
} | php | public function closeCursor()
{
if (!$this->_stmt) {
return false;
}
oci_free_statement($this->_stmt);
$this->_stmt = false;
return true;
} | [
"public",
"function",
"closeCursor",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_stmt",
")",
"{",
"return",
"false",
";",
"}",
"oci_free_statement",
"(",
"$",
"this",
"->",
"_stmt",
")",
";",
"$",
"this",
"->",
"_stmt",
"=",
"false",
";",
"... | Closes the cursor, allowing the statement to be executed again.
@return bool | [
"Closes",
"the",
"cursor",
"allowing",
"the",
"statement",
"to",
"be",
"executed",
"again",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Statement/Oracle.php#L140-L149 | train | Closes the cursor and frees the statement | [
30522,
2270,
3853,
2485,
10841,
25301,
2099,
1006,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
1035,
2358,
20492,
1007,
1063,
2709,
6270,
1025,
1065,
1051,
6895,
1035,
2489,
1035,
4861,
1006,
1002,
2023,
1011,
1028,
1035,
2358,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Model.php | Model.finishSave | protected function finishSave(array $options)
{
$this->fireModelEvent('saved', false);
if ($this->isDirty() && ($options['touch'] ?? true)) {
$this->touchOwners();
}
$this->syncOriginal();
} | php | protected function finishSave(array $options)
{
$this->fireModelEvent('saved', false);
if ($this->isDirty() && ($options['touch'] ?? true)) {
$this->touchOwners();
}
$this->syncOriginal();
} | [
"protected",
"function",
"finishSave",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"fireModelEvent",
"(",
"'saved'",
",",
"false",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDirty",
"(",
")",
"&&",
"(",
"$",
"options",
"[",
"'touch'",
... | Perform any actions that are necessary after the model is saved.
@param array $options
@return void | [
"Perform",
"any",
"actions",
"that",
"are",
"necessary",
"after",
"the",
"model",
"is",
"saved",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Model.php#L702-L711 | train | Finish save. | [
30522,
5123,
3853,
3926,
3736,
3726,
1006,
9140,
1002,
7047,
1007,
1063,
1002,
2023,
1011,
1028,
2543,
5302,
9247,
18697,
3372,
1006,
1005,
5552,
1005,
1010,
6270,
1007,
1025,
2065,
1006,
1002,
2023,
1011,
1028,
2003,
4305,
5339,
2100,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Routing/PendingResourceRegistration.php | PendingResourceRegistration.register | public function register()
{
$this->registered = true;
return $this->registrar->register(
$this->name, $this->controller, $this->options
);
} | php | public function register()
{
$this->registered = true;
return $this->registrar->register(
$this->name, $this->controller, $this->options
);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registered",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"registrar",
"->",
"register",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"controller",
",",
"$",
"this",
"-... | Register the resource route.
@return \Illuminate\Routing\RouteCollection | [
"Register",
"the",
"resource",
"route",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/PendingResourceRegistration.php#L161-L168 | train | Register the controller and options into the Registrar | [
30522,
2270,
3853,
4236,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
5068,
1027,
2995,
1025,
2709,
1002,
2023,
1011,
1028,
24580,
1011,
1028,
4236,
1006,
1002,
2023,
1011,
1028,
2171,
1010,
1002,
2023,
1011,
1028,
11486,
1010,
1002,
2023,
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/Cache/Console/ClearCommand.php | ClearCommand.cache | protected function cache()
{
$cache = $this->cache->store($this->argument('store'));
return empty($this->tags()) ? $cache : $cache->tags($this->tags());
} | php | protected function cache()
{
$cache = $this->cache->store($this->argument('store'));
return empty($this->tags()) ? $cache : $cache->tags($this->tags());
} | [
"protected",
"function",
"cache",
"(",
")",
"{",
"$",
"cache",
"=",
"$",
"this",
"->",
"cache",
"->",
"store",
"(",
"$",
"this",
"->",
"argument",
"(",
"'store'",
")",
")",
";",
"return",
"empty",
"(",
"$",
"this",
"->",
"tags",
"(",
")",
")",
"?... | Get the cache instance for the command.
@return \Illuminate\Cache\Repository | [
"Get",
"the",
"cache",
"instance",
"for",
"the",
"command",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Cache/Console/ClearCommand.php#L105-L110 | train | Cache the result of the current request | [
30522,
5123,
3853,
17053,
1006,
1007,
1063,
1002,
17053,
1027,
1002,
2023,
1011,
1028,
17053,
1011,
1028,
3573,
1006,
1002,
2023,
1011,
1028,
6685,
1006,
1005,
3573,
1005,
1007,
1007,
1025,
2709,
4064,
1006,
1002,
2023,
1011,
1028,
22073,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/API.php | API.save | public function save($idSite, $idNote, $date = null, $note = null, $starred = null)
{
$this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot modify more than one note at a time.");
$this->checkDateIsValid($date, $canBeNull = true);
// get the annotations for the site
$annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
// modify the annotation, and save the whole list
$annotations->update($idSite, $idNote, $date, $note, $starred);
$annotations->save($idSite);
return $annotations->get($idSite, $idNote);
} | php | public function save($idSite, $idNote, $date = null, $note = null, $starred = null)
{
$this->checkSingleIdSite($idSite, $extraMessage = "Note: Cannot modify more than one note at a time.");
$this->checkDateIsValid($date, $canBeNull = true);
// get the annotations for the site
$annotations = new AnnotationList($idSite);
// check permissions
$this->checkUserCanModifyOrDelete($idSite, $annotations->get($idSite, $idNote));
// modify the annotation, and save the whole list
$annotations->update($idSite, $idNote, $date, $note, $starred);
$annotations->save($idSite);
return $annotations->get($idSite, $idNote);
} | [
"public",
"function",
"save",
"(",
"$",
"idSite",
",",
"$",
"idNote",
",",
"$",
"date",
"=",
"null",
",",
"$",
"note",
"=",
"null",
",",
"$",
"starred",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"checkSingleIdSite",
"(",
"$",
"idSite",
",",
"$",
... | Modifies an annotation for a site and returns the modified annotation
and its ID.
If the current user is not allowed to modify an annotation, an exception
will be thrown. A user can modify a note if:
- the user has admin access for the site, OR
- the user has view access, is not the anonymous user and is the user that
created the note
@param string $idSite The site ID to add the annotation to.
@param string $idNote The ID of the note.
@param string|null $date The date the annotation is attached to. If null, the annotation's
date is not modified.
@param string|null $note The text of the annotation. If null, the annotation's text
is not modified.
@param string|null $starred Either 0 or 1. Whether the annotation should be starred.
If null, the annotation is not starred/un-starred.
@return array Returns an array of two elements. The first element (indexed by
'annotation') is the new annotation. The second element (indexed
by 'idNote' is the new note's ID). | [
"Modifies",
"an",
"annotation",
"for",
"a",
"site",
"and",
"returns",
"the",
"modified",
"annotation",
"and",
"its",
"ID",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/API.php#L79-L95 | train | Save an annotation | [
30522,
2270,
3853,
3828,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
22074,
1010,
1002,
3058,
1027,
19701,
1010,
1002,
3602,
1027,
19701,
1010,
1002,
5652,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
14148,
2075,
23057,
5104,
4221... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/backend/classes/Controller.php | Controller.run | public function run($action = null, $params = [])
{
$this->action = $action;
$this->params = $params;
/*
* Check security token.
*/
if (!$this->verifyCsrfToken()) {
return Response::make(Lang::get('backend::lang.page.invalid_token.label'), 403);
}
/*
* Check forced HTTPS protocol.
*/
if (!$this->verifyForceSecure()) {
return Redirect::secure(Request::path());
}
/*
* Determine if this request is a public action.
*/
$isPublicAction = in_array($action, $this->publicActions);
/*
* Check that user is logged in and has permission to view this page
*/
if (!$isPublicAction) {
/*
* Not logged in, redirect to login screen or show ajax error.
*/
if (!BackendAuth::check()) {
return Request::ajax()
? Response::make(Lang::get('backend::lang.page.access_denied.label'), 403)
: Backend::redirectGuest('backend/auth');
}
/*
* Check access groups against the page definition
*/
if ($this->requiredPermissions && !$this->user->hasAnyAccess($this->requiredPermissions)) {
return Response::make(View::make('backend::access_denied'), 403);
}
}
/*
* Extensibility
*/
if ($event = $this->fireSystemEvent('backend.page.beforeDisplay', [$action, $params])) {
return $event;
}
/*
* Set the admin preference locale
*/
BackendPreference::setAppLocale();
BackendPreference::setAppFallbackLocale();
/*
* Execute AJAX event
*/
if ($ajaxResponse = $this->execAjaxHandlers()) {
return $ajaxResponse;
}
/*
* Execute postback handler
*/
if (
($handler = post('_handler')) &&
($handlerResponse = $this->runAjaxHandler($handler)) &&
$handlerResponse !== true
) {
return $handlerResponse;
}
/*
* Execute page action
*/
$result = $this->execPageAction($action, $params);
if (!is_string($result)) {
return $result;
}
return Response::make($result, $this->statusCode);
} | php | public function run($action = null, $params = [])
{
$this->action = $action;
$this->params = $params;
/*
* Check security token.
*/
if (!$this->verifyCsrfToken()) {
return Response::make(Lang::get('backend::lang.page.invalid_token.label'), 403);
}
/*
* Check forced HTTPS protocol.
*/
if (!$this->verifyForceSecure()) {
return Redirect::secure(Request::path());
}
/*
* Determine if this request is a public action.
*/
$isPublicAction = in_array($action, $this->publicActions);
/*
* Check that user is logged in and has permission to view this page
*/
if (!$isPublicAction) {
/*
* Not logged in, redirect to login screen or show ajax error.
*/
if (!BackendAuth::check()) {
return Request::ajax()
? Response::make(Lang::get('backend::lang.page.access_denied.label'), 403)
: Backend::redirectGuest('backend/auth');
}
/*
* Check access groups against the page definition
*/
if ($this->requiredPermissions && !$this->user->hasAnyAccess($this->requiredPermissions)) {
return Response::make(View::make('backend::access_denied'), 403);
}
}
/*
* Extensibility
*/
if ($event = $this->fireSystemEvent('backend.page.beforeDisplay', [$action, $params])) {
return $event;
}
/*
* Set the admin preference locale
*/
BackendPreference::setAppLocale();
BackendPreference::setAppFallbackLocale();
/*
* Execute AJAX event
*/
if ($ajaxResponse = $this->execAjaxHandlers()) {
return $ajaxResponse;
}
/*
* Execute postback handler
*/
if (
($handler = post('_handler')) &&
($handlerResponse = $this->runAjaxHandler($handler)) &&
$handlerResponse !== true
) {
return $handlerResponse;
}
/*
* Execute page action
*/
$result = $this->execPageAction($action, $params);
if (!is_string($result)) {
return $result;
}
return Response::make($result, $this->statusCode);
} | [
"public",
"function",
"run",
"(",
"$",
"action",
"=",
"null",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"$",
"action",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"params",
";",
"/*\n * Check security token.... | Execute the controller action.
@param string $action The action name.
@param array $params Routing parameters to pass to the action.
@return mixed The action result. | [
"Execute",
"the",
"controller",
"action",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/Controller.php#L166-L253 | train | Runs the action | [
30522,
2270,
3853,
2448,
1006,
1002,
2895,
1027,
19701,
1010,
1002,
11498,
5244,
1027,
1031,
1033,
1007,
1063,
1002,
2023,
1011,
1028,
2895,
1027,
1002,
2895,
1025,
1002,
2023,
1011,
1028,
11498,
5244,
1027,
1002,
11498,
5244,
1025,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Http/Concerns/InteractsWithContentTypes.php | InteractsWithContentTypes.acceptsAnyContentType | public function acceptsAnyContentType()
{
$acceptable = $this->getAcceptableContentTypes();
return count($acceptable) === 0 || (
isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*')
);
} | php | public function acceptsAnyContentType()
{
$acceptable = $this->getAcceptableContentTypes();
return count($acceptable) === 0 || (
isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*')
);
} | [
"public",
"function",
"acceptsAnyContentType",
"(",
")",
"{",
"$",
"acceptable",
"=",
"$",
"this",
"->",
"getAcceptableContentTypes",
"(",
")",
";",
"return",
"count",
"(",
"$",
"acceptable",
")",
"===",
"0",
"||",
"(",
"isset",
"(",
"$",
"acceptable",
"["... | Determine if the current request accepts any content type.
@return bool | [
"Determine",
"if",
"the",
"current",
"request",
"accepts",
"any",
"content",
"type",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Http/Concerns/InteractsWithContentTypes.php#L126-L133 | train | Returns true if the request accepts any content type | [
30522,
2270,
3853,
13385,
19092,
8663,
6528,
15353,
5051,
1006,
1007,
1063,
1002,
11701,
1027,
1002,
2023,
1011,
1028,
2131,
6305,
3401,
22799,
3468,
8663,
6528,
15353,
10374,
1006,
1007,
1025,
2709,
4175,
1006,
1002,
11701,
1007,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Metric.php | Metric.getMetric | public static function getMetric($row, $columnName, $mappingNameToId = null)
{
if ($row instanceof Row) {
$value = $row->getColumn($columnName);
if ($value === false) {
if (empty($mappingNameToId)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (isset($mappingNameToId[$columnName])) {
return $row->getColumn($mappingNameToId[$columnName]);
}
}
return $value;
} elseif (!empty($row)) {
if (array_key_exists($columnName, $row)) {
return $row[$columnName];
} else {
if (empty($mappingNameToId)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (isset($mappingNameToId[$columnName])) {
$columnName = $mappingNameToId[$columnName];
if (array_key_exists($columnName, $row)) {
return $row[$columnName];
}
}
}
}
return null;
} | php | public static function getMetric($row, $columnName, $mappingNameToId = null)
{
if ($row instanceof Row) {
$value = $row->getColumn($columnName);
if ($value === false) {
if (empty($mappingNameToId)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (isset($mappingNameToId[$columnName])) {
return $row->getColumn($mappingNameToId[$columnName]);
}
}
return $value;
} elseif (!empty($row)) {
if (array_key_exists($columnName, $row)) {
return $row[$columnName];
} else {
if (empty($mappingNameToId)) {
$mappingNameToId = Metrics::getMappingFromNameToId();
}
if (isset($mappingNameToId[$columnName])) {
$columnName = $mappingNameToId[$columnName];
if (array_key_exists($columnName, $row)) {
return $row[$columnName];
}
}
}
}
return null;
} | [
"public",
"static",
"function",
"getMetric",
"(",
"$",
"row",
",",
"$",
"columnName",
",",
"$",
"mappingNameToId",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"row",
"instanceof",
"Row",
")",
"{",
"$",
"value",
"=",
"$",
"row",
"->",
"getColumn",
"(",
"$"... | Helper method that will access a metric in a {@link Piwik\DataTable\Row} or array either by
its name or by its special numerical index value.
@param Row|array $row
@param string $columnName
@param int[]|null $mappingNameToId A custom mapping of metric names to special index values. By
default {@link Metrics::getMappingFromNameToId()} is used.
@return mixed The metric value or false if none exists. | [
"Helper",
"method",
"that",
"will",
"access",
"a",
"metric",
"in",
"a",
"{",
"@link",
"Piwik",
"\\",
"DataTable",
"\\",
"Row",
"}",
"or",
"array",
"either",
"by",
"its",
"name",
"or",
"by",
"its",
"special",
"numerical",
"index",
"value",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/Metric.php#L119-L154 | train | Returns the value of a column in the row | [
30522,
2270,
10763,
3853,
2131,
12589,
1006,
1002,
5216,
1010,
1002,
5930,
18442,
1010,
1002,
12375,
18442,
3406,
3593,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
5216,
6013,
11253,
5216,
1007,
1063,
1002,
3643,
1027,
1002,
5216,
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/HTML/Common2.php | HTML_Common2.getAttributesString | protected static function getAttributesString($attributes)
{
$str = '';
if (is_array($attributes)) {
$charset = self::getOption('charset');
foreach ($attributes as $key => $value) {
$str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES, $charset) . '"';
}
}
return $str;
} | php | protected static function getAttributesString($attributes)
{
$str = '';
if (is_array($attributes)) {
$charset = self::getOption('charset');
foreach ($attributes as $key => $value) {
$str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES, $charset) . '"';
}
}
return $str;
} | [
"protected",
"static",
"function",
"getAttributesString",
"(",
"$",
"attributes",
")",
"{",
"$",
"str",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"charset",
"=",
"self",
"::",
"getOption",
"(",
"'charset'",
")",
... | Creates HTML attribute string from array
@param array Attribute array
@return string Attribute string | [
"Creates",
"HTML",
"attribute",
"string",
"from",
"array"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/HTML/Common2.php#L213-L223 | train | Returns the attributes string | [
30522,
5123,
10763,
3853,
2131,
19321,
3089,
8569,
4570,
3367,
4892,
1006,
1002,
12332,
1007,
1063,
1002,
2358,
2099,
1027,
1005,
1005,
1025,
2065,
1006,
2003,
1035,
9140,
1006,
1002,
12332,
1007,
1007,
1063,
1002,
25869,
13462,
1027,
2969,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Security/Core/Authentication/AuthenticationTrustResolver.php | AuthenticationTrustResolver.isRememberMe | public function isRememberMe(TokenInterface $token = null)
{
if (null === $token) {
return false;
}
if (null !== $this->rememberMeClass) {
return $token instanceof $this->rememberMeClass;
}
return $token instanceof RememberMeToken;
} | php | public function isRememberMe(TokenInterface $token = null)
{
if (null === $token) {
return false;
}
if (null !== $this->rememberMeClass) {
return $token instanceof $this->rememberMeClass;
}
return $token instanceof RememberMeToken;
} | [
"public",
"function",
"isRememberMe",
"(",
"TokenInterface",
"$",
"token",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"token",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"rememberMeClass",
")",
"{",
... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php#L61-L72 | train | Checks if the token is a RememberMeToken | [
30522,
2270,
3853,
2003,
28578,
6633,
5677,
4168,
1006,
19204,
18447,
2121,
12172,
1002,
19204,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
19204,
1007,
1063,
2709,
6270,
1025,
1065,
2065,
1006,
19701,
999,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/UsersManager/API.php | API.getUsersLogin | public function getUsersLogin()
{
Piwik::checkUserHasSomeAdminAccess();
$logins = $this->model->getUsersLogin();
$logins = $this->userFilter->filterLogins($logins);
return $logins;
} | php | public function getUsersLogin()
{
Piwik::checkUserHasSomeAdminAccess();
$logins = $this->model->getUsersLogin();
$logins = $this->userFilter->filterLogins($logins);
return $logins;
} | [
"public",
"function",
"getUsersLogin",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeAdminAccess",
"(",
")",
";",
"$",
"logins",
"=",
"$",
"this",
"->",
"model",
"->",
"getUsersLogin",
"(",
")",
";",
"$",
"logins",
"=",
"$",
"this",
"->",
"userFilter",
... | Returns the list of all the users login
@return array the list of all the users login | [
"Returns",
"the",
"list",
"of",
"all",
"the",
"users",
"login"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/UsersManager/API.php#L384-L392 | train | Returns the users login | [
30522,
2270,
30524,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
4215,
22311,
9468,
7971,
1006,
1007,
1025,
1002,
8833,
7076,
1027,
1002,
2023,
1011,
1028,
2944,
1011,
1028,
2131,
20330,
14540,
8649,
2378,
1006,
1007,
1025,
1002,
8833... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Notifications/Messages/MailMessage.php | MailMessage.bcc | public function bcc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->bcc += $this->parseAddresses($address);
} else {
$this->bcc[] = [$address, $name];
}
return $this;
} | php | public function bcc($address, $name = null)
{
if ($this->arrayOfAddresses($address)) {
$this->bcc += $this->parseAddresses($address);
} else {
$this->bcc[] = [$address, $name];
}
return $this;
} | [
"public",
"function",
"bcc",
"(",
"$",
"address",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"arrayOfAddresses",
"(",
"$",
"address",
")",
")",
"{",
"$",
"this",
"->",
"bcc",
"+=",
"$",
"this",
"->",
"parseAddresses",
"(... | Set the bcc address for the mail message.
@param array|string $address
@param string|null $name
@return $this | [
"Set",
"the",
"bcc",
"address",
"for",
"the",
"mail",
"message",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Notifications/Messages/MailMessage.php#L187-L196 | train | Add BCC Address | [
30522,
2270,
3853,
4647,
2278,
1006,
1002,
4769,
1010,
1002,
2171,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
9140,
11253,
4215,
16200,
11393,
2015,
1006,
1002,
4769,
1007,
1007,
1063,
1002,
2023,
1011,
1028,
4647,
2278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php | RemoveUnusedDefinitionsPass.process | public function process(ContainerBuilder $container)
{
try {
$this->enableExpressionProcessing();
$this->container = $container;
$connectedIds = [];
$aliases = $container->getAliases();
foreach ($aliases as $id => $alias) {
if ($alias->isPublic()) {
$this->connectedIds[] = (string) $aliases[$id];
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isPublic()) {
$connectedIds[$id] = true;
$this->processValue($definition);
}
}
while ($this->connectedIds) {
$ids = $this->connectedIds;
$this->connectedIds = [];
foreach ($ids as $id) {
if (!isset($connectedIds[$id]) && $container->hasDefinition($id)) {
$connectedIds[$id] = true;
$this->processValue($container->getDefinition($id));
}
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if (!isset($connectedIds[$id])) {
$container->removeDefinition($id);
$container->resolveEnvPlaceholders(!$definition->hasErrors() ? serialize($definition) : $definition);
$container->log($this, sprintf('Removed service "%s"; reason: unused.', $id));
}
}
} finally {
$this->container = null;
$this->connectedIds = [];
}
} | php | public function process(ContainerBuilder $container)
{
try {
$this->enableExpressionProcessing();
$this->container = $container;
$connectedIds = [];
$aliases = $container->getAliases();
foreach ($aliases as $id => $alias) {
if ($alias->isPublic()) {
$this->connectedIds[] = (string) $aliases[$id];
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if ($definition->isPublic()) {
$connectedIds[$id] = true;
$this->processValue($definition);
}
}
while ($this->connectedIds) {
$ids = $this->connectedIds;
$this->connectedIds = [];
foreach ($ids as $id) {
if (!isset($connectedIds[$id]) && $container->hasDefinition($id)) {
$connectedIds[$id] = true;
$this->processValue($container->getDefinition($id));
}
}
}
foreach ($container->getDefinitions() as $id => $definition) {
if (!isset($connectedIds[$id])) {
$container->removeDefinition($id);
$container->resolveEnvPlaceholders(!$definition->hasErrors() ? serialize($definition) : $definition);
$container->log($this, sprintf('Removed service "%s"; reason: unused.', $id));
}
}
} finally {
$this->container = null;
$this->connectedIds = [];
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"enableExpressionProcessing",
"(",
")",
";",
"$",
"this",
"->",
"container",
"=",
"$",
"container",
";",
"$",
"connectedIds",
"=",
"[",
"]"... | Processes the ContainerBuilder to remove unused definitions. | [
"Processes",
"the",
"ContainerBuilder",
"to",
"remove",
"unused",
"definitions",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/DependencyInjection/Compiler/RemoveUnusedDefinitionsPass.php#L38-L81 | train | Processes the container builder | [
30522,
2270,
3853,
2832,
1006,
11661,
8569,
23891,
2099,
1002,
11661,
1007,
1063,
3046,
1063,
1002,
2023,
1011,
1028,
9585,
10288,
20110,
3258,
21572,
9623,
7741,
1006,
1007,
1025,
1002,
2023,
1011,
1028,
11661,
1027,
1002,
11661,
1025,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Connectors/ConnectionFactory.php | ConnectionFactory.getReadWriteConfig | protected function getReadWriteConfig(array $config, $type)
{
return isset($config[$type][0])
? Arr::random($config[$type])
: $config[$type];
} | php | protected function getReadWriteConfig(array $config, $type)
{
return isset($config[$type][0])
? Arr::random($config[$type])
: $config[$type];
} | [
"protected",
"function",
"getReadWriteConfig",
"(",
"array",
"$",
"config",
",",
"$",
"type",
")",
"{",
"return",
"isset",
"(",
"$",
"config",
"[",
"$",
"type",
"]",
"[",
"0",
"]",
")",
"?",
"Arr",
"::",
"random",
"(",
"$",
"config",
"[",
"$",
"typ... | Get a read / write level configuration.
@param array $config
@param string $type
@return array | [
"Get",
"a",
"read",
"/",
"write",
"level",
"configuration",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Connectors/ConnectionFactory.php#L137-L142 | train | Get read write config | [
30522,
5123,
3853,
2131,
16416,
2094,
26373,
8663,
8873,
2290,
1006,
9140,
1002,
9530,
8873,
2290,
1010,
1002,
2828,
1007,
1063,
2709,
26354,
3388,
1006,
1002,
9530,
8873,
2290,
1031,
1002,
2828,
1033,
1031,
1014,
1033,
1007,
1029,
12098,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Actions/Archiver.php | Archiver.archiveDayExitActions | protected function archiveDayExitActions($rankingQueryLimit)
{
$rankingQuery = false;
if ($rankingQueryLimit > 0) {
$rankingQuery = new RankingQuery($rankingQueryLimit);
$rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW);
$rankingQuery->addLabelColumn('idaction');
$rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS);
$rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS, 'sum');
$rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($this->actionsTablesByType));
$extraSelects = 'log_action.type, log_action.name,';
$from = array(
"log_visit",
array(
"table" => "log_action",
"joinOn" => "log_visit.%s = log_action.idaction"
)
);
$orderBy = "`" . PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS . "` DESC, log_action.name ASC";
} else {
$extraSelects = false;
$from = "log_visit";
$orderBy = false;
}
$select = "log_visit.%s as idaction, $extraSelects
count(distinct log_visit.idvisitor) as `" . PiwikMetrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS . "`,
count(*) as `" . PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS . "`";
$where = $this->getLogAggregator()->getWhereStatement('log_visit', 'visit_last_action_time');
$where .= " AND log_visit.%s > 0";
$groupBy = "log_visit.%s";
$this->archiveDayQueryProcess($select, $from, $where, $groupBy, $orderBy, "visit_exit_idaction_url", $rankingQuery);
$this->archiveDayQueryProcess($select, $from, $where, $groupBy, $orderBy, "visit_exit_idaction_name", $rankingQuery);
return array($rankingQuery, $extraSelects, $from, $orderBy, $select, $where, $groupBy);
} | php | protected function archiveDayExitActions($rankingQueryLimit)
{
$rankingQuery = false;
if ($rankingQueryLimit > 0) {
$rankingQuery = new RankingQuery($rankingQueryLimit);
$rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW);
$rankingQuery->addLabelColumn('idaction');
$rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS);
$rankingQuery->addColumn(PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS, 'sum');
$rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($this->actionsTablesByType));
$extraSelects = 'log_action.type, log_action.name,';
$from = array(
"log_visit",
array(
"table" => "log_action",
"joinOn" => "log_visit.%s = log_action.idaction"
)
);
$orderBy = "`" . PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS . "` DESC, log_action.name ASC";
} else {
$extraSelects = false;
$from = "log_visit";
$orderBy = false;
}
$select = "log_visit.%s as idaction, $extraSelects
count(distinct log_visit.idvisitor) as `" . PiwikMetrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS . "`,
count(*) as `" . PiwikMetrics::INDEX_PAGE_EXIT_NB_VISITS . "`";
$where = $this->getLogAggregator()->getWhereStatement('log_visit', 'visit_last_action_time');
$where .= " AND log_visit.%s > 0";
$groupBy = "log_visit.%s";
$this->archiveDayQueryProcess($select, $from, $where, $groupBy, $orderBy, "visit_exit_idaction_url", $rankingQuery);
$this->archiveDayQueryProcess($select, $from, $where, $groupBy, $orderBy, "visit_exit_idaction_name", $rankingQuery);
return array($rankingQuery, $extraSelects, $from, $orderBy, $select, $where, $groupBy);
} | [
"protected",
"function",
"archiveDayExitActions",
"(",
"$",
"rankingQueryLimit",
")",
"{",
"$",
"rankingQuery",
"=",
"false",
";",
"if",
"(",
"$",
"rankingQueryLimit",
">",
"0",
")",
"{",
"$",
"rankingQuery",
"=",
"new",
"RankingQuery",
"(",
"$",
"rankingQuery... | Exit actions | [
"Exit",
"actions"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/Archiver.php#L328-L367 | train | Archives all exit actions for the day | [
30522,
5123,
3853,
9749,
4710,
10288,
6590,
22014,
1006,
1002,
5464,
4226,
23320,
27605,
2102,
1007,
1063,
1002,
5464,
4226,
2854,
1027,
6270,
1025,
2065,
1006,
1002,
5464,
4226,
23320,
27605,
2102,
1028,
1014,
1007,
1063,
1002,
5464,
4226,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/system/classes/MediaLibrary.php | MediaLibrary.folderExists | public function folderExists($path)
{
$folderName = basename($path);
$folderPath = dirname($path);
$path = self::validatePath($folderPath);
$fullPath = $this->getMediaPath($path);
$folders = $this->getStorageDisk()->directories($fullPath);
foreach ($folders as $folder) {
if (basename($folder) == $folderName) {
return true;
}
}
return false;
} | php | public function folderExists($path)
{
$folderName = basename($path);
$folderPath = dirname($path);
$path = self::validatePath($folderPath);
$fullPath = $this->getMediaPath($path);
$folders = $this->getStorageDisk()->directories($fullPath);
foreach ($folders as $folder) {
if (basename($folder) == $folderName) {
return true;
}
}
return false;
} | [
"public",
"function",
"folderExists",
"(",
"$",
"path",
")",
"{",
"$",
"folderName",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"$",
"folderPath",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"self",
"::",
"validatePath",
"(",
"$",... | Determines if a folder with the specified path exists in the library.
@param string $path Specifies the folder path relative the the Library root.
@return boolean Returns TRUE if the folder exists. | [
"Determines",
"if",
"a",
"folder",
"with",
"the",
"specified",
"path",
"exists",
"in",
"the",
"library",
"."
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/classes/MediaLibrary.php#L250-L266 | train | Checks if a folder exists in the media folder | [
30522,
2270,
3853,
19622,
10288,
5130,
1006,
1002,
4130,
1007,
1063,
1002,
19622,
18442,
1027,
2918,
18442,
1006,
1002,
4130,
1007,
1025,
1002,
19622,
15069,
1027,
16101,
18442,
1006,
1002,
4130,
1007,
1025,
1002,
4130,
1027,
2969,
1024,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Archive/ArchiveInvalidator.php | ArchiveInvalidator.buildRememberArchivedReportIdProcessSafe | private function buildRememberArchivedReportIdProcessSafe($idSite, $date)
{
$id = $this->buildRememberArchivedReportIdForSiteAndDate($idSite, $date);
$id .= '_' . getmypid();
return $id;
} | php | private function buildRememberArchivedReportIdProcessSafe($idSite, $date)
{
$id = $this->buildRememberArchivedReportIdForSiteAndDate($idSite, $date);
$id .= '_' . getmypid();
return $id;
} | [
"private",
"function",
"buildRememberArchivedReportIdProcessSafe",
"(",
"$",
"idSite",
",",
"$",
"date",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"buildRememberArchivedReportIdForSiteAndDate",
"(",
"$",
"idSite",
",",
"$",
"date",
")",
";",
"$",
"id",
".="... | This version is multi process safe on the insert of a new date to invalidate. | [
"This",
"version",
"is",
"multi",
"process",
"safe",
"on",
"the",
"insert",
"of",
"a",
"new",
"date",
"to",
"invalidate",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/ArchiveInvalidator.php#L122-L127 | train | Build a report id for the given site and date | [
30522,
2797,
3853,
3857,
28578,
6633,
5677,
2906,
5428,
7178,
2890,
6442,
3593,
21572,
9623,
11488,
7959,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
3058,
1007,
1063,
1002,
8909,
1027,
1002,
2023,
1011,
1028,
3857,
28578,
6633,
5677,
2906,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/PrivacyManager/ReportsPurger.php | ReportsPurger.make | public static function make($settings, $metricsToKeep)
{
return new ReportsPurger(
$settings['delete_reports_older_than'],
$settings['delete_reports_keep_basic_metrics'] == 1,
self::getReportPeriodsToKeep($settings),
$settings['delete_reports_keep_segment_reports'] == 1,
$metricsToKeep,
$settings['delete_logs_max_rows_per_query']
);
} | php | public static function make($settings, $metricsToKeep)
{
return new ReportsPurger(
$settings['delete_reports_older_than'],
$settings['delete_reports_keep_basic_metrics'] == 1,
self::getReportPeriodsToKeep($settings),
$settings['delete_reports_keep_segment_reports'] == 1,
$metricsToKeep,
$settings['delete_logs_max_rows_per_query']
);
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"settings",
",",
"$",
"metricsToKeep",
")",
"{",
"return",
"new",
"ReportsPurger",
"(",
"$",
"settings",
"[",
"'delete_reports_older_than'",
"]",
",",
"$",
"settings",
"[",
"'delete_reports_keep_basic_metrics'",
"]... | Utility function. Creates a new instance of ReportsPurger with the supplied array
of settings.
$settings must contain the following keys:
-'delete_reports_older_than': The number of months after which reports/metrics are
considered old.
-'delete_reports_keep_basic_metrics': 1 if basic metrics should be kept, 0 if otherwise.
-'delete_reports_keep_day_reports': 1 if daily reports should be kept, 0 if otherwise.
-'delete_reports_keep_week_reports': 1 if weekly reports should be kept, 0 if otherwise.
-'delete_reports_keep_month_reports': 1 if monthly reports should be kept, 0 if otherwise.
-'delete_reports_keep_year_reports': 1 if yearly reports should be kept, 0 if otherwise.
-'delete_reports_keep_range_reports': 1 if range reports should be kept, 0 if otherwise.
-'delete_reports_keep_segment_reports': 1 if reports for segments should be kept, 0 if otherwise.
-'delete_logs_max_rows_per_query': Maximum number of rows to delete in one DELETE query. | [
"Utility",
"function",
".",
"Creates",
"a",
"new",
"instance",
"of",
"ReportsPurger",
"with",
"the",
"supplied",
"array",
"of",
"settings",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/PrivacyManager/ReportsPurger.php#L359-L369 | train | Create a new ReportsPurger | [
30522,
2270,
10763,
3853,
2191,
1006,
1002,
10906,
1010,
1002,
12046,
16033,
20553,
2361,
1007,
1063,
2709,
2047,
4311,
5311,
4590,
1006,
1002,
10906,
1031,
1005,
3972,
12870,
1035,
4311,
1035,
3080,
1035,
2084,
1005,
1033,
1010,
1002,
1090... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Collection/ArrayCollection.php | ArrayCollection.shuffle | public function shuffle()
{
$keys = $this->getKeys();
shuffle($keys);
return $this->createFrom(array_replace(array_flip($keys), $this->toArray()));
} | php | public function shuffle()
{
$keys = $this->getKeys();
shuffle($keys);
return $this->createFrom(array_replace(array_flip($keys), $this->toArray()));
} | [
"public",
"function",
"shuffle",
"(",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"shuffle",
"(",
"$",
"keys",
")",
";",
"return",
"$",
"this",
"->",
"createFrom",
"(",
"array_replace",
"(",
"array_flip",
"(",
"$",
"keys"... | Shuffle items.
@return static | [
"Shuffle",
"items",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Collection/ArrayCollection.php#L36-L42 | train | Shuffle the array and return a new array with the keys of the array | [
30522,
2270,
3853,
23046,
1006,
1007,
1063,
1002,
6309,
1027,
1002,
2023,
1011,
1028,
2131,
14839,
2015,
1006,
1007,
1025,
23046,
1006,
1002,
6309,
1007,
1025,
2709,
1002,
2023,
1011,
30524,
6309,
1007,
1010,
1002,
2023,
1011,
1028,
2000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Mail/Protocol/Smtp/Auth/Crammd5.php | Zend_Mail_Protocol_Smtp_Auth_Crammd5._hmacMd5 | protected function _hmacMd5($key, $data, $block = 64)
{
if (strlen($key) > 64) {
$key = pack('H32', md5($key));
} elseif (strlen($key) < 64) {
$key = str_pad($key, $block, "\0");
}
$k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64);
$inner = pack('H32', md5($k_ipad . $data));
$digest = md5($k_opad . $inner);
return $digest;
} | php | protected function _hmacMd5($key, $data, $block = 64)
{
if (strlen($key) > 64) {
$key = pack('H32', md5($key));
} elseif (strlen($key) < 64) {
$key = str_pad($key, $block, "\0");
}
$k_ipad = substr($key, 0, 64) ^ str_repeat(chr(0x36), 64);
$k_opad = substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64);
$inner = pack('H32', md5($k_ipad . $data));
$digest = md5($k_opad . $inner);
return $digest;
} | [
"protected",
"function",
"_hmacMd5",
"(",
"$",
"key",
",",
"$",
"data",
",",
"$",
"block",
"=",
"64",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"key",
")",
">",
"64",
")",
"{",
"$",
"key",
"=",
"pack",
"(",
"'H32'",
",",
"md5",
"(",
"$",
"key"... | Prepare CRAM-MD5 response to server's ticket
@param string $key Challenge key (usually password)
@param string $data Challenge data
@param string $block Length of blocks
@return string | [
"Prepare",
"CRAM",
"-",
"MD5",
"response",
"to",
"server",
"s",
"ticket"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail/Protocol/Smtp/Auth/Crammd5.php#L92-L107 | train | HMAC MD5 - Fucking | [
30522,
5123,
3853,
1035,
20287,
6305,
26876,
2629,
1006,
1002,
3145,
1010,
1002,
2951,
1010,
1002,
3796,
1027,
4185,
1007,
1063,
2065,
1006,
2358,
20927,
2078,
1006,
1002,
3145,
1007,
1028,
4185,
1007,
1063,
1002,
3145,
1027,
5308,
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... |
matomo-org/matomo | plugins/Actions/API.php | API.getSiteSearchCategories | public function getSiteSearchCategories($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
Actions::checkCustomVariablesPluginEnabled();
$customVariables = APICustomVariables::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
$customVarNameToLookFor = ActionSiteSearch::CVAR_KEY_SEARCH_CATEGORY;
$dataTable = new DataTable();
// Handle case where date=last30&period=day
// FIXMEA: this logic should really be refactored somewhere, this is ugly!
if ($customVariables instanceof DataTable\Map) {
$dataTable = $customVariables->getEmptyClone();
$customVariableDatatables = $customVariables->getDataTables();
foreach ($customVariableDatatables as $key => $customVariableTableForDate) {
// we do not enter the IF, in the case idSite=1,3 AND period=day&date=datefrom,dateto,
if ($customVariableTableForDate instanceof DataTable
&& $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)
) {
$row = $customVariableTableForDate->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$dateRewrite = $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->toString();
$idSubtable = $row->getIdSubDataTable();
$categories = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
$dataTable->addTable($categories, $key);
}
}
}
} elseif ($customVariables instanceof DataTable) {
$row = $customVariables->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$idSubtable = $row->getIdSubDataTable();
$dataTable = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
}
}
$this->filterActionsDataTable($dataTable, $isPageTitleType = false);
$dataTable->filter('ReplaceColumnNames');
$this->addPagesPerSearchColumn($dataTable, $columnToRead = 'nb_actions');
return $dataTable;
} | php | public function getSiteSearchCategories($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
Actions::checkCustomVariablesPluginEnabled();
$customVariables = APICustomVariables::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true);
$customVarNameToLookFor = ActionSiteSearch::CVAR_KEY_SEARCH_CATEGORY;
$dataTable = new DataTable();
// Handle case where date=last30&period=day
// FIXMEA: this logic should really be refactored somewhere, this is ugly!
if ($customVariables instanceof DataTable\Map) {
$dataTable = $customVariables->getEmptyClone();
$customVariableDatatables = $customVariables->getDataTables();
foreach ($customVariableDatatables as $key => $customVariableTableForDate) {
// we do not enter the IF, in the case idSite=1,3 AND period=day&date=datefrom,dateto,
if ($customVariableTableForDate instanceof DataTable
&& $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)
) {
$row = $customVariableTableForDate->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$dateRewrite = $customVariableTableForDate->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->toString();
$idSubtable = $row->getIdSubDataTable();
$categories = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $dateRewrite, $idSubtable, $segment);
$dataTable->addTable($categories, $key);
}
}
}
} elseif ($customVariables instanceof DataTable) {
$row = $customVariables->getRowFromLabel($customVarNameToLookFor);
if ($row) {
$idSubtable = $row->getIdSubDataTable();
$dataTable = APICustomVariables::getInstance()->getCustomVariablesValuesFromNameId($idSite, $period, $date, $idSubtable, $segment);
}
}
$this->filterActionsDataTable($dataTable, $isPageTitleType = false);
$dataTable->filter('ReplaceColumnNames');
$this->addPagesPerSearchColumn($dataTable, $columnToRead = 'nb_actions');
return $dataTable;
} | [
"public",
"function",
"getSiteSearchCategories",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
")",
"{",
"Piwik",
"::",
"checkUserHasViewAccess",
"(",
"$",
"idSite",
")",
";",
"Actions",
"::",
"checkCustomVariab... | @param int $idSite
@param string $period
@param Date $date
@param bool $segment
@return DataTable|DataTable\Map | [
"@param",
"int",
"$idSite",
"@param",
"string",
"$period",
"@param",
"Date",
"$date",
"@param",
"bool",
"$segment"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Actions/API.php#L351-L392 | train | Returns all categories in the search table for the given site & period | [
30522,
2270,
3853,
4152,
7616,
14644,
2818,
16280,
20255,
3111,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
8584,
6305,
9623... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Archive/Chunk.php | Chunk.getRecordNameWithoutChunkAppendix | public function getRecordNameWithoutChunkAppendix($recordName)
{
if (!$this->isRecordNameAChunk($recordName)) {
return $recordName;
}
$posAppendix = $this->getStartPosOfChunkAppendix($recordName);
if (false === $posAppendix) {
return $recordName;
}
return substr($recordName, 0, $posAppendix);
} | php | public function getRecordNameWithoutChunkAppendix($recordName)
{
if (!$this->isRecordNameAChunk($recordName)) {
return $recordName;
}
$posAppendix = $this->getStartPosOfChunkAppendix($recordName);
if (false === $posAppendix) {
return $recordName;
}
return substr($recordName, 0, $posAppendix);
} | [
"public",
"function",
"getRecordNameWithoutChunkAppendix",
"(",
"$",
"recordName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRecordNameAChunk",
"(",
"$",
"recordName",
")",
")",
"{",
"return",
"$",
"recordName",
";",
"}",
"$",
"posAppendix",
"=",
"$",
... | When having a record like 'Actions_ActionUrls_chunk_0_99" it will return the raw recordName 'Actions_ActionUrls'.
@param string $recordName
@return string | [
"When",
"having",
"a",
"record",
"like",
"Actions_ActionUrls_chunk_0_99",
"it",
"will",
"return",
"the",
"raw",
"recordName",
"Actions_ActionUrls",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/Chunk.php#L104-L117 | train | Get Record Name without Chunk Appendix | [
30522,
2270,
3853,
2131,
2890,
27108,
28911,
4168,
24415,
5833,
20760,
25804,
21512,
16089,
2595,
1006,
1002,
2501,
18442,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
2003,
2890,
27108,
28911,
4168,
6776,
16814,
1006,
1002,
2501,
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... |
matomo-org/matomo | core/Plugin/SettingsProvider.php | SettingsProvider.getAllMeasurableSettings | public function getAllMeasurableSettings($idSite, $idMeasurableType = null)
{
$pluginNames = $this->pluginManager->getActivatedPlugins();
$byPluginName = array();
foreach ($pluginNames as $plugin) {
$component = $this->getMeasurableSettings($plugin, $idSite, $idMeasurableType);
if (!empty($component)) {
$byPluginName[$plugin] = $component;
}
}
return $byPluginName;
} | php | public function getAllMeasurableSettings($idSite, $idMeasurableType = null)
{
$pluginNames = $this->pluginManager->getActivatedPlugins();
$byPluginName = array();
foreach ($pluginNames as $plugin) {
$component = $this->getMeasurableSettings($plugin, $idSite, $idMeasurableType);
if (!empty($component)) {
$byPluginName[$plugin] = $component;
}
}
return $byPluginName;
} | [
"public",
"function",
"getAllMeasurableSettings",
"(",
"$",
"idSite",
",",
"$",
"idMeasurableType",
"=",
"null",
")",
"{",
"$",
"pluginNames",
"=",
"$",
"this",
"->",
"pluginManager",
"->",
"getActivatedPlugins",
"(",
")",
";",
"$",
"byPluginName",
"=",
"array... | @api
Get all available measurable settings implemented by loaded and activated plugins.
@param int $idSite The ID of a site. If a site is about to be created pass idSite = 0.
@param string|null $idMeasurableType If null, idType will be detected automatically if the site already exists.
Only needed to set a value when idSite = 0 (this is the case when a site
is about) to be created.
@return MeasurableSettings[] | [
"@api"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Plugin/SettingsProvider.php#L179-L193 | train | Get all the measurable settings for a specific site | [
30522,
2270,
3853,
2131,
8095,
4168,
28329,
21678,
8613,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
8909,
4168,
28329,
13874,
1027,
19701,
1007,
1063,
1002,
13354,
23111,
14074,
2015,
1027,
1002,
2023,
1011,
1028,
13354,
2378,
24805,
4590,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
PHPMailer/PHPMailer | src/PHPMailer.php | PHPMailer.clearQueuedAddresses | public function clearQueuedAddresses($kind)
{
$this->RecipientsQueue = array_filter(
$this->RecipientsQueue,
function ($params) use ($kind) {
return $params[0] != $kind;
}
);
} | php | public function clearQueuedAddresses($kind)
{
$this->RecipientsQueue = array_filter(
$this->RecipientsQueue,
function ($params) use ($kind) {
return $params[0] != $kind;
}
);
} | [
"public",
"function",
"clearQueuedAddresses",
"(",
"$",
"kind",
")",
"{",
"$",
"this",
"->",
"RecipientsQueue",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"RecipientsQueue",
",",
"function",
"(",
"$",
"params",
")",
"use",
"(",
"$",
"kind",
")",
"{",
"... | Clear queued addresses of given kind.
@param string $kind 'to', 'cc', or 'bcc' | [
"Clear",
"queued",
"addresses",
"of",
"given",
"kind",
"."
] | 3d7132341659a8a201adbc3ba11b1e202ee2857c | https://github.com/PHPMailer/PHPMailer/blob/3d7132341659a8a201adbc3ba11b1e202ee2857c/src/PHPMailer.php#L3504-L3512 | train | Clear all recipients that are queued for a certain kind | [
30522,
2270,
3853,
3154,
4226,
5657,
14697,
16200,
11393,
2015,
1006,
1002,
2785,
1007,
1063,
1002,
2023,
1011,
1028,
15991,
4226,
5657,
1027,
9140,
1035,
11307,
1006,
1002,
2023,
1011,
1028,
15991,
30524,
1002,
11498,
5244,
1007,
2224,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataAccess/RawLogDao.php | RawLogDao.forAllLogs | public function forAllLogs($logTable, $fields, $conditions, $iterationStep, $callback)
{
$idField = $this->getIdFieldForLogTable($logTable);
list($query, $bind) = $this->createLogIterationQuery($logTable, $idField, $fields, $conditions, $iterationStep);
$lastId = 0;
do {
$rows = Db::fetchAll($query, array_merge(array($lastId), $bind));
if (!empty($rows)) {
$lastId = $rows[count($rows) - 1][$idField];
$callback($rows);
}
} while (count($rows) == $iterationStep);
} | php | public function forAllLogs($logTable, $fields, $conditions, $iterationStep, $callback)
{
$idField = $this->getIdFieldForLogTable($logTable);
list($query, $bind) = $this->createLogIterationQuery($logTable, $idField, $fields, $conditions, $iterationStep);
$lastId = 0;
do {
$rows = Db::fetchAll($query, array_merge(array($lastId), $bind));
if (!empty($rows)) {
$lastId = $rows[count($rows) - 1][$idField];
$callback($rows);
}
} while (count($rows) == $iterationStep);
} | [
"public",
"function",
"forAllLogs",
"(",
"$",
"logTable",
",",
"$",
"fields",
",",
"$",
"conditions",
",",
"$",
"iterationStep",
",",
"$",
"callback",
")",
"{",
"$",
"idField",
"=",
"$",
"this",
"->",
"getIdFieldForLogTable",
"(",
"$",
"logTable",
")",
"... | Iterates over logs in a log table in chunks. Parameters to this function are as backend agnostic
as possible w/o dramatically increasing code complexity.
@param string $logTable The log table name. Unprefixed, eg, `log_visit`.
@param array[] $conditions An array describing the conditions logs must match in the query. Translates to
the WHERE part of a SELECT statement. Each element must contain three elements:
* the column name
* the operator (ie, '=', '<>', '<', etc.)
* the operand (ie, a value)
The elements are AND-ed together.
Example:
```
array(
array('visit_first_action_time', '>=', ...),
array('visit_first_action_time', '<', ...)
)
```
@param int $iterationStep The number of rows to query at a time.
@param callable $callback The callback that processes each chunk of rows. | [
"Iterates",
"over",
"logs",
"in",
"a",
"log",
"table",
"in",
"chunks",
".",
"Parameters",
"to",
"this",
"function",
"are",
"as",
"backend",
"agnostic",
"as",
"possible",
"w",
"/",
"o",
"dramatically",
"increasing",
"code",
"complexity",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/RawLogDao.php#L107-L121 | train | This method is used to iterate over all logs in the hierarchy. | [
30522,
2270,
3853,
2005,
8095,
21197,
2015,
1006,
1002,
8833,
10880,
1010,
1002,
4249,
1010,
1002,
3785,
1010,
1002,
27758,
13473,
2361,
1010,
1002,
2655,
5963,
1007,
1063,
1002,
24011,
12891,
1027,
1002,
2023,
1011,
1028,
2131,
3593,
3790,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Console/Helper/Table.php | Table.setStyleDefinition | public static function setStyleDefinition($name, TableStyle $style)
{
if (!self::$styles) {
self::$styles = self::initStyles();
}
self::$styles[$name] = $style;
} | php | public static function setStyleDefinition($name, TableStyle $style)
{
if (!self::$styles) {
self::$styles = self::initStyles();
}
self::$styles[$name] = $style;
} | [
"public",
"static",
"function",
"setStyleDefinition",
"(",
"$",
"name",
",",
"TableStyle",
"$",
"style",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"styles",
")",
"{",
"self",
"::",
"$",
"styles",
"=",
"self",
"::",
"initStyles",
"(",
")",
";",
"}"... | Sets a style definition.
@param string $name The style name
@param TableStyle $style A TableStyle instance | [
"Sets",
"a",
"style",
"definition",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Console/Helper/Table.php#L108-L115 | train | Set a table style definition | [
30522,
2270,
10763,
3853,
4520,
27983,
3207,
16294,
22753,
1006,
1002,
2171,
1010,
7251,
27983,
1002,
2806,
1007,
1063,
2065,
1006,
999,
2969,
1024,
1024,
1002,
6782,
1007,
1063,
2969,
1024,
1024,
1002,
6782,
1027,
2969,
1024,
1024,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Routing/Route.php | Route.where | public function where($name, $expression = null)
{
foreach ($this->parseWhere($name, $expression) as $name => $expression) {
$this->wheres[$name] = $expression;
}
return $this;
} | php | public function where($name, $expression = null)
{
foreach ($this->parseWhere($name, $expression) as $name => $expression) {
$this->wheres[$name] = $expression;
}
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"name",
",",
"$",
"expression",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"parseWhere",
"(",
"$",
"name",
",",
"$",
"expression",
")",
"as",
"$",
"name",
"=>",
"$",
"expression",
")",
"{",
"$... | Set a regular expression requirement on the route.
@param array|string $name
@param string $expression
@return $this | [
"Set",
"a",
"regular",
"expression",
"requirement",
"on",
"the",
"route",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Routing/Route.php#L495-L502 | train | Adds a where clause to the list of where clauses | [
30522,
2270,
3853,
2073,
1006,
1002,
2171,
1010,
1002,
3670,
1027,
19701,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
11968,
3366,
2860,
5886,
2063,
1006,
1002,
2171,
1010,
1002,
3670,
1007,
2004,
1002,
2171,
1027,
1028,
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/Archive.php | Archive.factory | public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false,
$isMultipleDate = false)
{
return StaticContainer::get(ArchiveQueryFactory::class)->factory($segment, $periods, $idSites, $idSiteIsAll,
$isMultipleDate);
} | php | public static function factory(Segment $segment, array $periods, array $idSites, $idSiteIsAll = false,
$isMultipleDate = false)
{
return StaticContainer::get(ArchiveQueryFactory::class)->factory($segment, $periods, $idSites, $idSiteIsAll,
$isMultipleDate);
} | [
"public",
"static",
"function",
"factory",
"(",
"Segment",
"$",
"segment",
",",
"array",
"$",
"periods",
",",
"array",
"$",
"idSites",
",",
"$",
"idSiteIsAll",
"=",
"false",
",",
"$",
"isMultipleDate",
"=",
"false",
")",
"{",
"return",
"StaticContainer",
"... | Returns a new Archive instance that will query archive data for the given set of
sites and periods, using an optional segment.
This method uses an array of Period instances and a Segment instance, instead of strings
like {@link build()}.
If you want to create an Archive instance using data found in query parameters,
use {@link build()}.
@param Segment $segment The segment to use. For no segment, use `new Segment('', $idSites)`.
@param array $periods An array of Period instances.
@param array $idSites An array of site IDs (eg, `array(1, 2, 3)`).
@param bool $idSiteIsAll Whether `'all'` sites are being queried or not. If true, then
the result of querying functions will be indexed by site, regardless
of whether `count($idSites) == 1`.
@param bool $isMultipleDate Whether multiple dates are being queried or not. If true, then
the result of querying functions will be indexed by period,
regardless of whether `count($periods) == 1`.
@return ArchiveQuery | [
"Returns",
"a",
"new",
"Archive",
"instance",
"that",
"will",
"query",
"archive",
"data",
"for",
"the",
"given",
"set",
"of",
"sites",
"and",
"periods",
"using",
"an",
"optional",
"segment",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive.php#L237-L242 | train | Create a new archive query instance | [
30522,
2270,
10763,
3853,
4713,
1006,
6903,
1002,
6903,
1010,
9140,
1002,
6993,
1010,
9140,
1002,
8909,
28032,
2229,
1010,
1002,
8909,
28032,
17580,
8095,
1027,
6270,
1010,
1002,
2003,
12274,
7096,
11514,
3709,
3686,
1027,
6270,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
opencart/opencart | upload/system/engine/loader.php | Loader.model | public function model($route) {
// Sanitize the call
$route = preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route);
if (!$this->registry->has('model_' . str_replace('/', '_', $route))) {
$file = DIR_APPLICATION . 'model/' . $route . '.php';
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $route);
if (is_file($file)) {
include_once($file);
$proxy = new Proxy();
// Overriding models is a little harder so we have to use PHP's magic methods
// In future version we can use runkit
foreach (get_class_methods($class) as $method) {
$function = $this->callback($route . '/' . $method);
$proxy->attach($method, $function);
}
$this->registry->set('model_' . str_replace('/', '_', (string)$route), $proxy);
} else {
throw new \Exception('Error: Could not load model ' . $route . '!');
}
}
} | php | public function model($route) {
// Sanitize the call
$route = preg_replace('/[^a-zA-Z0-9_\/]/', '', (string)$route);
if (!$this->registry->has('model_' . str_replace('/', '_', $route))) {
$file = DIR_APPLICATION . 'model/' . $route . '.php';
$class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $route);
if (is_file($file)) {
include_once($file);
$proxy = new Proxy();
// Overriding models is a little harder so we have to use PHP's magic methods
// In future version we can use runkit
foreach (get_class_methods($class) as $method) {
$function = $this->callback($route . '/' . $method);
$proxy->attach($method, $function);
}
$this->registry->set('model_' . str_replace('/', '_', (string)$route), $proxy);
} else {
throw new \Exception('Error: Could not load model ' . $route . '!');
}
}
} | [
"public",
"function",
"model",
"(",
"$",
"route",
")",
"{",
"// Sanitize the call",
"$",
"route",
"=",
"preg_replace",
"(",
"'/[^a-zA-Z0-9_\\/]/'",
",",
"''",
",",
"(",
"string",
")",
"$",
"route",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"registry",... | Model
@param string $route | [
"Model"
] | e7933b56ba05aafb3655c6b490c9733cd18b5c69 | https://github.com/opencart/opencart/blob/e7933b56ba05aafb3655c6b490c9733cd18b5c69/upload/system/engine/loader.php#L71-L97 | train | Load the model | [
30522,
2270,
3853,
2944,
1006,
1002,
2799,
1007,
1063,
1013,
1013,
2624,
25090,
4371,
1996,
2655,
1002,
2799,
1027,
3653,
2290,
1035,
5672,
1006,
1005,
1013,
1031,
1034,
1037,
1011,
23564,
1011,
1062,
2692,
1011,
1023,
1035,
1032,
1013,
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... |
symfony/symfony | src/Symfony/Component/Messenger/Transport/RedisExt/RedisSender.php | RedisSender.send | public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
$this->connection->add($encodedMessage['body'], $encodedMessage['headers'] ?? []);
return $envelope;
} | php | public function send(Envelope $envelope): Envelope
{
$encodedMessage = $this->serializer->encode($envelope);
$this->connection->add($encodedMessage['body'], $encodedMessage['headers'] ?? []);
return $envelope;
} | [
"public",
"function",
"send",
"(",
"Envelope",
"$",
"envelope",
")",
":",
"Envelope",
"{",
"$",
"encodedMessage",
"=",
"$",
"this",
"->",
"serializer",
"->",
"encode",
"(",
"$",
"envelope",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"add",
"(",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Messenger/Transport/RedisExt/RedisSender.php#L38-L45 | train | Send an Envelope to the server | [
30522,
2270,
3853,
4604,
1006,
11255,
1002,
11255,
1007,
1024,
11255,
1063,
1002,
12359,
7834,
3736,
3351,
1027,
1002,
2023,
1011,
1028,
7642,
17629,
1011,
1028,
4372,
16044,
1006,
1002,
11255,
1007,
1025,
1002,
2023,
1011,
1028,
4434,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/backend/behaviors/UserPreferencesModel.php | UserPreferencesModel.instance | public function instance()
{
if (isset(self::$instances[$this->recordCode])) {
return self::$instances[$this->recordCode];
}
if (!$item = $this->getSettingsRecord()) {
$this->model->initSettingsData();
$item = $this->model;
}
return self::$instances[$this->recordCode] = $item;
} | php | public function instance()
{
if (isset(self::$instances[$this->recordCode])) {
return self::$instances[$this->recordCode];
}
if (!$item = $this->getSettingsRecord()) {
$this->model->initSettingsData();
$item = $this->model;
}
return self::$instances[$this->recordCode] = $item;
} | [
"public",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"this",
"->",
"recordCode",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"this",
"->",
"recordCode",
"]",
... | Create an instance of the settings model, intended as a static method | [
"Create",
"an",
"instance",
"of",
"the",
"settings",
"model",
"intended",
"as",
"a",
"static",
"method"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/UserPreferencesModel.php#L37-L49 | train | Return the instance of the record | [
30522,
2270,
3853,
6013,
1006,
1007,
1063,
2065,
1006,
26354,
3388,
1006,
2969,
1024,
1024,
1002,
12107,
1031,
1002,
2023,
1011,
1028,
2501,
16044,
1033,
1007,
1007,
1063,
2709,
2969,
1024,
1024,
1002,
12107,
1031,
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... |
laravel/framework | src/Illuminate/Database/Eloquent/Builder.php | Builder.hydrate | public function hydrate(array $items)
{
$instance = $this->newModelInstance();
return $instance->newCollection(array_map(function ($item) use ($instance) {
return $instance->newFromBuilder($item);
}, $items));
} | php | public function hydrate(array $items)
{
$instance = $this->newModelInstance();
return $instance->newCollection(array_map(function ($item) use ($instance) {
return $instance->newFromBuilder($item);
}, $items));
} | [
"public",
"function",
"hydrate",
"(",
"array",
"$",
"items",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"newModelInstance",
"(",
")",
";",
"return",
"$",
"instance",
"->",
"newCollection",
"(",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",... | Create a collection of models from plain arrays.
@param array $items
@return \Illuminate\Database\Eloquent\Collection | [
"Create",
"a",
"collection",
"of",
"models",
"from",
"plain",
"arrays",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Eloquent/Builder.php#L293-L300 | train | Hydrate an array of taxonomy items into a taxonomy object | [
30522,
2270,
3853,
26018,
2618,
1006,
9140,
1002,
5167,
1007,
1063,
1002,
6013,
1027,
1002,
2023,
1011,
1028,
2047,
5302,
9247,
7076,
26897,
1006,
1007,
1025,
2709,
1002,
6013,
1011,
1028,
2047,
26895,
18491,
1006,
9140,
1035,
4949,
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... |
getgrav/grav | system/src/Grav/Common/Page/Collection.php | Collection.routable | public function routable()
{
$routable = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->routable()) {
$routable[$path] = $slug;
}
}
$this->items = $routable;
return $this;
} | php | public function routable()
{
$routable = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->routable()) {
$routable[$path] = $slug;
}
}
$this->items = $routable;
return $this;
} | [
"public",
"function",
"routable",
"(",
")",
"{",
"$",
"routable",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"path",
"=>",
"$",
"slug",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"pages",
"->",
"get",
"(",
"$... | Creates new collection with only routable pages
@return Collection The collection with only routable pages | [
"Creates",
"new",
"collection",
"with",
"only",
"routable",
"pages"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Collection.php#L479-L494 | train | Return all pages that are routable | [
30522,
2270,
3853,
20996,
23056,
1006,
1007,
1063,
1002,
20996,
23056,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
5167,
2004,
1002,
4130,
1027,
1028,
1002,
23667,
1007,
1063,
1002,
3931,
1027,
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... |
symfony/symfony | src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php | AccessDecisionManager.decideAffirmative | private function decideAffirmative(TokenInterface $token, array $attributes, $object = null)
{
$deny = 0;
foreach ($this->voters as $voter) {
$result = $voter->vote($token, $object, $attributes);
switch ($result) {
case VoterInterface::ACCESS_GRANTED:
return true;
case VoterInterface::ACCESS_DENIED:
++$deny;
break;
default:
break;
}
}
if ($deny > 0) {
return false;
}
return $this->allowIfAllAbstainDecisions;
} | php | private function decideAffirmative(TokenInterface $token, array $attributes, $object = null)
{
$deny = 0;
foreach ($this->voters as $voter) {
$result = $voter->vote($token, $object, $attributes);
switch ($result) {
case VoterInterface::ACCESS_GRANTED:
return true;
case VoterInterface::ACCESS_DENIED:
++$deny;
break;
default:
break;
}
}
if ($deny > 0) {
return false;
}
return $this->allowIfAllAbstainDecisions;
} | [
"private",
"function",
"decideAffirmative",
"(",
"TokenInterface",
"$",
"token",
",",
"array",
"$",
"attributes",
",",
"$",
"object",
"=",
"null",
")",
"{",
"$",
"deny",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"voters",
"as",
"$",
"voter",
")... | Grants access if any voter returns an affirmative response.
If all voters abstained from voting, the decision will be based on the
allowIfAllAbstainDecisions property value (defaults to false). | [
"Grants",
"access",
"if",
"any",
"voter",
"returns",
"an",
"affirmative",
"response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php#L69-L93 | train | Decides whether the user is affirmative | [
30522,
2797,
3853,
5630,
10354,
27972,
8082,
1006,
19204,
18447,
2121,
12172,
1002,
19204,
1010,
9140,
1002,
12332,
1010,
1002,
4874,
1027,
19701,
1007,
1063,
1002,
9772,
1027,
1014,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
7206,
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... |
symfony/symfony | src/Symfony/Component/Form/FormConfigBuilder.php | FormConfigBuilder.setPropertyPath | public function setPropertyPath($propertyPath)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) {
$propertyPath = new PropertyPath($propertyPath);
}
$this->propertyPath = $propertyPath;
return $this;
} | php | public function setPropertyPath($propertyPath)
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
}
if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) {
$propertyPath = new PropertyPath($propertyPath);
}
$this->propertyPath = $propertyPath;
return $this;
} | [
"public",
"function",
"setPropertyPath",
"(",
"$",
"propertyPath",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locked",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"'FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInt... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormConfigBuilder.php#L568-L581 | train | Set the property path | [
30522,
2270,
3853,
2275,
21572,
4842,
3723,
15069,
1006,
1002,
3200,
15069,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
5299,
1007,
1063,
5466,
2047,
2919,
11368,
6806,
16409,
24164,
2595,
24422,
1006,
1005,
2433,
8663,
8873,
18259,
192... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Security/Guard/GuardAuthenticatorHandler.php | GuardAuthenticatorHandler.authenticateWithToken | public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null)
{
$this->migrateSession($request, $token, $providerKey);
$this->tokenStorage->setToken($token);
if (null !== $this->dispatcher) {
$loginEvent = new InteractiveLoginEvent($request, $token);
$this->dispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN);
}
} | php | public function authenticateWithToken(TokenInterface $token, Request $request, string $providerKey = null)
{
$this->migrateSession($request, $token, $providerKey);
$this->tokenStorage->setToken($token);
if (null !== $this->dispatcher) {
$loginEvent = new InteractiveLoginEvent($request, $token);
$this->dispatcher->dispatch($loginEvent, SecurityEvents::INTERACTIVE_LOGIN);
}
} | [
"public",
"function",
"authenticateWithToken",
"(",
"TokenInterface",
"$",
"token",
",",
"Request",
"$",
"request",
",",
"string",
"$",
"providerKey",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"migrateSession",
"(",
"$",
"request",
",",
"$",
"token",
",",
... | Authenticates the given token in the system.
@param string $providerKey The name of the provider/firewall being used for authentication | [
"Authenticates",
"the",
"given",
"token",
"in",
"the",
"system",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php#L58-L67 | train | Authenticate with a token | [
30522,
2270,
3853,
14469,
3686,
24415,
18715,
2368,
1006,
19204,
18447,
2121,
12172,
1002,
19204,
1010,
5227,
1002,
5227,
1010,
5164,
1002,
10802,
14839,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
22806,
8583,
10992,
1006,
1002,
5227,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/backend/behaviors/FormController.php | FormController.initForm | public function initForm($model, $context = null)
{
if ($context !== null) {
$this->context = $context;
}
$context = $this->formGetContext();
/*
* Each page can supply a unique form definition, if desired
*/
$formFields = $this->getConfig("{$context}[form]", $this->config->form);
$config = $this->makeConfig($formFields);
$config->model = $model;
$config->arrayName = class_basename($model);
$config->context = $context;
/*
* Form Widget with extensibility
*/
$this->formWidget = $this->makeWidget('Backend\Widgets\Form', $config);
// Setup the default preview mode on form initialization if the context is preview
if ($config->context === 'preview') {
$this->formWidget->previewMode = true;
}
$this->formWidget->bindEvent('form.extendFieldsBefore', function () {
$this->controller->formExtendFieldsBefore($this->formWidget);
});
$this->formWidget->bindEvent('form.extendFields', function ($fields) {
$this->controller->formExtendFields($this->formWidget, $fields);
});
$this->formWidget->bindEvent('form.beforeRefresh', function ($holder) {
$result = $this->controller->formExtendRefreshData($this->formWidget, $holder->data);
if (is_array($result)) $holder->data = $result;
});
$this->formWidget->bindEvent('form.refreshFields', function ($fields) {
return $this->controller->formExtendRefreshFields($this->formWidget, $fields);
});
$this->formWidget->bindEvent('form.refresh', function ($result) {
return $this->controller->formExtendRefreshResults($this->formWidget, $result);
});
$this->formWidget->bindToController();
/*
* Detected Relation controller behavior
*/
if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController')) {
$this->controller->initRelation($model);
}
$this->prepareVars($model);
$this->model = $model;
} | php | public function initForm($model, $context = null)
{
if ($context !== null) {
$this->context = $context;
}
$context = $this->formGetContext();
/*
* Each page can supply a unique form definition, if desired
*/
$formFields = $this->getConfig("{$context}[form]", $this->config->form);
$config = $this->makeConfig($formFields);
$config->model = $model;
$config->arrayName = class_basename($model);
$config->context = $context;
/*
* Form Widget with extensibility
*/
$this->formWidget = $this->makeWidget('Backend\Widgets\Form', $config);
// Setup the default preview mode on form initialization if the context is preview
if ($config->context === 'preview') {
$this->formWidget->previewMode = true;
}
$this->formWidget->bindEvent('form.extendFieldsBefore', function () {
$this->controller->formExtendFieldsBefore($this->formWidget);
});
$this->formWidget->bindEvent('form.extendFields', function ($fields) {
$this->controller->formExtendFields($this->formWidget, $fields);
});
$this->formWidget->bindEvent('form.beforeRefresh', function ($holder) {
$result = $this->controller->formExtendRefreshData($this->formWidget, $holder->data);
if (is_array($result)) $holder->data = $result;
});
$this->formWidget->bindEvent('form.refreshFields', function ($fields) {
return $this->controller->formExtendRefreshFields($this->formWidget, $fields);
});
$this->formWidget->bindEvent('form.refresh', function ($result) {
return $this->controller->formExtendRefreshResults($this->formWidget, $result);
});
$this->formWidget->bindToController();
/*
* Detected Relation controller behavior
*/
if ($this->controller->isClassExtendedWith('Backend.Behaviors.RelationController')) {
$this->controller->initRelation($model);
}
$this->prepareVars($model);
$this->model = $model;
} | [
"public",
"function",
"initForm",
"(",
"$",
"model",
",",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"context",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"context",
"=",
"$",
"context",
";",
"}",
"$",
"context",
"=",
"$",
"this",
"-... | Initialize the form configuration against a model and context value.
This will process the configuration found in the `$formConfig` property
and prepare the Form widget, which is the underlying tool used for
actually rendering the form. The model used by this form is passed
to this behavior via this method as the first argument.
@see Backend\Widgets\Form
@param October\Rain\Database\Model $model
@param string $context Form context
@return void | [
"Initialize",
"the",
"form",
"configuration",
"against",
"a",
"model",
"and",
"context",
"value",
".",
"This",
"will",
"process",
"the",
"configuration",
"found",
"in",
"the",
"$formConfig",
"property",
"and",
"prepare",
"the",
"Form",
"widget",
"which",
"is",
... | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/behaviors/FormController.php#L119-L179 | train | Initializes the form | [
30522,
2270,
3853,
1999,
4183,
14192,
1006,
1002,
2944,
1010,
1002,
6123,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
6123,
999,
1027,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
6123,
1027,
1002,
6123,
1025,
1065,
1002,
6123,
1027,
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... |
matomo-org/matomo | core/Updates/2.6.0-b1.php | Updates_2_6_0_b1.doUpdate | public function doUpdate(Updater $updater)
{
$config = Config::getInstance();
$config->Plugins_Tracker = array();
$config->forceSave();
} | php | public function doUpdate(Updater $updater)
{
$config = Config::getInstance();
$config->Plugins_Tracker = array();
$config->forceSave();
} | [
"public",
"function",
"doUpdate",
"(",
"Updater",
"$",
"updater",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"getInstance",
"(",
")",
";",
"$",
"config",
"->",
"Plugins_Tracker",
"=",
"array",
"(",
")",
";",
"$",
"config",
"->",
"forceSave",
"(",
")... | Here you can define any action that should be performed during the update. For instance executing SQL statements,
renaming config entries, updating files, etc. | [
"Here",
"you",
"can",
"define",
"any",
"action",
"that",
"should",
"be",
"performed",
"during",
"the",
"update",
".",
"For",
"instance",
"executing",
"SQL",
"statements",
"renaming",
"config",
"entries",
"updating",
"files",
"etc",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Updates/2.6.0-b1.php#L25-L30 | train | This method is called by the update method. It will force the update of the plugin list. | [
30522,
2270,
3853,
2079,
6279,
13701,
1006,
10651,
2099,
1002,
10651,
2099,
1007,
1063,
1002,
9530,
8873,
2290,
1027,
9530,
8873,
2290,
1024,
1024,
2131,
7076,
26897,
1006,
1007,
1025,
1002,
9530,
8873,
2290,
1011,
1028,
13354,
7076,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/HttpKernel/HttpKernelBrowser.php | HttpKernelBrowser.filterResponse | protected function filterResponse($response)
{
// this is needed to support StreamedResponse
ob_start();
$response->sendContent();
$content = ob_get_clean();
return new DomResponse($content, $response->getStatusCode(), $response->headers->all());
} | php | protected function filterResponse($response)
{
// this is needed to support StreamedResponse
ob_start();
$response->sendContent();
$content = ob_get_clean();
return new DomResponse($content, $response->getStatusCode(), $response->headers->all());
} | [
"protected",
"function",
"filterResponse",
"(",
"$",
"response",
")",
"{",
"// this is needed to support StreamedResponse",
"ob_start",
"(",
")",
";",
"$",
"response",
"->",
"sendContent",
"(",
")",
";",
"$",
"content",
"=",
"ob_get_clean",
"(",
")",
";",
"retur... | Converts the HttpKernel response to a BrowserKit response.
@return DomResponse A DomResponse instance | [
"Converts",
"the",
"HttpKernel",
"response",
"to",
"a",
"BrowserKit",
"response",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpKernel/HttpKernelBrowser.php#L195-L203 | train | Filter the response to DomResponse | [
30522,
5123,
3853,
11307,
6072,
26029,
3366,
1006,
1002,
3433,
1007,
1063,
1013,
1013,
2023,
2003,
2734,
2000,
2490,
18498,
6072,
26029,
3366,
27885,
1035,
2707,
1006,
1007,
1025,
1002,
3433,
1011,
1028,
4604,
8663,
6528,
2102,
1006,
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... |
getgrav/grav | system/src/Grav/Common/User/DataUser/UserCollection.php | UserCollection.find | public function find($query, $fields = ['username', 'email']): UserInterface
{
$fields = (array)$fields;
$account_dir = Grav::instance()['locator']->findResource('account://');
$files = $account_dir ? array_diff(scandir($account_dir), ['.', '..']) : [];
// Try with username first, you never know!
if (in_array('username', $fields, true)) {
$user = $this->load($query);
unset($fields[array_search('username', $fields, true)]);
} else {
$user = $this->load('');
}
// If not found, try the fields
if (!$user->exists()) {
foreach ($files as $file) {
if (Utils::endsWith($file, YAML_EXT)) {
$find_user = $this->load(trim(pathinfo($file, PATHINFO_FILENAME)));
foreach ($fields as $field) {
if ($find_user[$field] === $query) {
return $find_user;
}
}
}
}
}
return $user;
} | php | public function find($query, $fields = ['username', 'email']): UserInterface
{
$fields = (array)$fields;
$account_dir = Grav::instance()['locator']->findResource('account://');
$files = $account_dir ? array_diff(scandir($account_dir), ['.', '..']) : [];
// Try with username first, you never know!
if (in_array('username', $fields, true)) {
$user = $this->load($query);
unset($fields[array_search('username', $fields, true)]);
} else {
$user = $this->load('');
}
// If not found, try the fields
if (!$user->exists()) {
foreach ($files as $file) {
if (Utils::endsWith($file, YAML_EXT)) {
$find_user = $this->load(trim(pathinfo($file, PATHINFO_FILENAME)));
foreach ($fields as $field) {
if ($find_user[$field] === $query) {
return $find_user;
}
}
}
}
}
return $user;
} | [
"public",
"function",
"find",
"(",
"$",
"query",
",",
"$",
"fields",
"=",
"[",
"'username'",
",",
"'email'",
"]",
")",
":",
"UserInterface",
"{",
"$",
"fields",
"=",
"(",
"array",
")",
"$",
"fields",
";",
"$",
"account_dir",
"=",
"Grav",
"::",
"insta... | Find a user by username, email, etc
@param string $query the query to search for
@param array $fields the fields to search
@return UserInterface | [
"Find",
"a",
"user",
"by",
"username",
"email",
"etc"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/DataUser/UserCollection.php#L77-L106 | train | Find user by username or email | [
30522,
2270,
3853,
2424,
1006,
1002,
23032,
1010,
1002,
4249,
1027,
1031,
1005,
5310,
18442,
1005,
1010,
1005,
10373,
1005,
1033,
1007,
1024,
5310,
18447,
2121,
12172,
1063,
1002,
4249,
1027,
1006,
9140,
1007,
1002,
4249,
1025,
1002,
4070,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/CoreVisualizations/Visualizations/Sparklines/Config.php | Config.addSparkline | public function addSparkline($requestParamsForSparkline, $value, $description, $evolution = null, $order = null)
{
$metrics = array();
if (is_array($value)) {
$values = $value;
} else {
$values = array($value);
}
if (!is_array($description)) {
$description = array($description);
}
if (!empty($requestParamsForSparkline['columns'])
&& is_array($requestParamsForSparkline['columns'])
&& count($requestParamsForSparkline['columns']) === count($values)) {
$columns = array_values($requestParamsForSparkline['columns']);
} elseif (!empty($requestParamsForSparkline['columns'])
&& is_string($requestParamsForSparkline['columns'])
&& count($values) === 1) {
$columns = array($requestParamsForSparkline['columns']);
} else{
$columns = array();
}
if (count($values) === count($description)) {
foreach ($values as $index => $value) {
$metrics[] = array(
'column' => isset($columns[$index]) ? $columns[$index] : '',
'value' => $value,
'description' => $description[$index]
);
}
} else {
$msg = 'The number of values and descriptions need to be the same to add a sparkline. ';
$msg .= 'Values: ' . implode(', ', $values). ' Descriptions: ' . implode(', ', $description);
throw new \Exception($msg);
}
if (empty($metrics)) {
return;
}
$sparkline = array(
'url' => $this->getUrlSparkline($requestParamsForSparkline),
'metrics' => $metrics,
'order' => $this->getSparklineOrder($order)
);
if (!empty($evolution)) {
if (!is_array($evolution) ||
!array_key_exists('currentValue', $evolution) ||
!array_key_exists('pastValue', $evolution)) {
throw new \Exception('In order to show an evolution in the sparklines view a currentValue and pastValue array key needs to be present');
}
$evolutionPercent = CalculateEvolutionFilter::calculate($evolution['currentValue'], $evolution['pastValue'], $precision = 1);
// do not display evolution if evolution percent is 0 and current value is 0
if ($evolutionPercent != 0 || $evolution['currentValue'] != 0) {
$sparkline['evolution'] = array(
'percent' => $evolutionPercent,
'tooltip' => !empty($evolution['tooltip']) ? $evolution['tooltip'] : null
);
}
}
$this->sparklines[] = $sparkline;
} | php | public function addSparkline($requestParamsForSparkline, $value, $description, $evolution = null, $order = null)
{
$metrics = array();
if (is_array($value)) {
$values = $value;
} else {
$values = array($value);
}
if (!is_array($description)) {
$description = array($description);
}
if (!empty($requestParamsForSparkline['columns'])
&& is_array($requestParamsForSparkline['columns'])
&& count($requestParamsForSparkline['columns']) === count($values)) {
$columns = array_values($requestParamsForSparkline['columns']);
} elseif (!empty($requestParamsForSparkline['columns'])
&& is_string($requestParamsForSparkline['columns'])
&& count($values) === 1) {
$columns = array($requestParamsForSparkline['columns']);
} else{
$columns = array();
}
if (count($values) === count($description)) {
foreach ($values as $index => $value) {
$metrics[] = array(
'column' => isset($columns[$index]) ? $columns[$index] : '',
'value' => $value,
'description' => $description[$index]
);
}
} else {
$msg = 'The number of values and descriptions need to be the same to add a sparkline. ';
$msg .= 'Values: ' . implode(', ', $values). ' Descriptions: ' . implode(', ', $description);
throw new \Exception($msg);
}
if (empty($metrics)) {
return;
}
$sparkline = array(
'url' => $this->getUrlSparkline($requestParamsForSparkline),
'metrics' => $metrics,
'order' => $this->getSparklineOrder($order)
);
if (!empty($evolution)) {
if (!is_array($evolution) ||
!array_key_exists('currentValue', $evolution) ||
!array_key_exists('pastValue', $evolution)) {
throw new \Exception('In order to show an evolution in the sparklines view a currentValue and pastValue array key needs to be present');
}
$evolutionPercent = CalculateEvolutionFilter::calculate($evolution['currentValue'], $evolution['pastValue'], $precision = 1);
// do not display evolution if evolution percent is 0 and current value is 0
if ($evolutionPercent != 0 || $evolution['currentValue'] != 0) {
$sparkline['evolution'] = array(
'percent' => $evolutionPercent,
'tooltip' => !empty($evolution['tooltip']) ? $evolution['tooltip'] : null
);
}
}
$this->sparklines[] = $sparkline;
} | [
"public",
"function",
"addSparkline",
"(",
"$",
"requestParamsForSparkline",
",",
"$",
"value",
",",
"$",
"description",
",",
"$",
"evolution",
"=",
"null",
",",
"$",
"order",
"=",
"null",
")",
"{",
"$",
"metrics",
"=",
"array",
"(",
")",
";",
"if",
"(... | Add a new sparkline to be displayed to the view.
Each sparkline can consist of one or multiple metrics. One metric consists of a value and a description. By
default the value is shown first, then the description. The description can optionally contain a '%s' in case
the value shall be displayed within the description. If multiple metrics are given, they will be separated by
a comma.
@param array $requestParamsForSparkline You need to at least set a module / action eg
array('columns' => array('nb_visit'), 'module' => '', 'action' => '')
@param int|float|string|array $value Either the metric value or an array of values.
@param string|array $description Either one description or an array of descriptions. If an array, both
$value and $description need the same amount of array entries.
$description[0] should be the description for $value[0].
$description should be already translated. If $value should appear
somewhere within the text a `%s` can be used in the translation.
@param array|null $evolution Optional array containing at least the array keys 'currentValue' and
'pastValue' which are needed to calculate the correct percentage.
An optional 'tooltip' can be set as well. Eg
array('currentValue' => 10, 'pastValue' => 20,
'tooltip' => '10 visits in 2015-07-26 compared to 20 visits in 2015-07-25')
@param int $order Defines the order. The lower the order the earlier the sparkline will be
displayed. By default the sparkline will be appended to the end.
@throws \Exception In case an evolution parameter is set but has wrong data structure | [
"Add",
"a",
"new",
"sparkline",
"to",
"be",
"displayed",
"to",
"the",
"view",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreVisualizations/Visualizations/Sparklines/Config.php#L199-L269 | train | Add a sparkline to the database | [
30522,
2270,
3853,
9909,
14432,
4179,
1006,
1002,
5227,
28689,
5244,
29278,
27694,
2243,
4179,
1010,
1002,
3643,
1010,
1002,
6412,
1010,
1002,
6622,
1027,
19701,
1010,
1002,
2344,
1027,
19701,
1007,
1063,
1002,
12046,
2015,
1027,
9140,
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/Finder/Finder.php | Finder.in | public function in($dirs)
{
$resolvedDirs = [];
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $this->normalizeDir($dir);
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
} else {
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
}
}
$this->dirs = array_merge($this->dirs, $resolvedDirs);
return $this;
} | php | public function in($dirs)
{
$resolvedDirs = [];
foreach ((array) $dirs as $dir) {
if (is_dir($dir)) {
$resolvedDirs[] = $this->normalizeDir($dir);
} elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
$resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
} else {
throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
}
}
$this->dirs = array_merge($this->dirs, $resolvedDirs);
return $this;
} | [
"public",
"function",
"in",
"(",
"$",
"dirs",
")",
"{",
"$",
"resolvedDirs",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"dirs",
"as",
"$",
"dir",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"resolvedDirs... | Searches files and directories which match defined rules.
@param string|array $dirs A directory path or an array of directories
@return $this
@throws DirectoryNotFoundException if one of the directories does not exist | [
"Searches",
"files",
"and",
"directories",
"which",
"match",
"defined",
"rules",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Finder/Finder.php#L591-L608 | train | Adds directories to the list of directories to search for | [
30522,
2270,
3853,
1999,
1006,
1002,
16101,
2015,
1007,
1063,
1002,
10395,
4305,
2869,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1006,
9140,
1007,
1002,
16101,
2015,
2004,
1002,
16101,
1007,
1063,
2065,
1006,
2003,
1035,
16101,
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/Metrics/Sorter.php | Sorter.getSecondaryColumnToSort | public function getSecondaryColumnToSort(Row $row, $primaryColumnToSort)
{
$defaultSecondaryColumn = array(Metrics::INDEX_NB_VISITS, 'nb_visits');
if (in_array($primaryColumnToSort, $defaultSecondaryColumn)) {
// if sorted by visits, then sort by label as a secondary column
$column = 'label';
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
return null;
}
if ($primaryColumnToSort !== 'label') {
// we do not add this by default to make sure we do not sort by label as a first and secondary column
$defaultSecondaryColumn[] = 'label';
}
foreach ($defaultSecondaryColumn as $column) {
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
}
} | php | public function getSecondaryColumnToSort(Row $row, $primaryColumnToSort)
{
$defaultSecondaryColumn = array(Metrics::INDEX_NB_VISITS, 'nb_visits');
if (in_array($primaryColumnToSort, $defaultSecondaryColumn)) {
// if sorted by visits, then sort by label as a secondary column
$column = 'label';
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
return null;
}
if ($primaryColumnToSort !== 'label') {
// we do not add this by default to make sure we do not sort by label as a first and secondary column
$defaultSecondaryColumn[] = 'label';
}
foreach ($defaultSecondaryColumn as $column) {
$value = $row->hasColumn($column);
if ($value !== false) {
return $column;
}
}
} | [
"public",
"function",
"getSecondaryColumnToSort",
"(",
"Row",
"$",
"row",
",",
"$",
"primaryColumnToSort",
")",
"{",
"$",
"defaultSecondaryColumn",
"=",
"array",
"(",
"Metrics",
"::",
"INDEX_NB_VISITS",
",",
"'nb_visits'",
")",
";",
"if",
"(",
"in_array",
"(",
... | Detect the secondary sort column to be used for sorting
@param Row $row
@param int|string $primaryColumnToSort
@return int | [
"Detect",
"the",
"secondary",
"sort",
"column",
"to",
"be",
"used",
"for",
"sorting"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Metrics/Sorter.php#L167-L193 | train | Get secondary column to sort | [
30522,
2270,
3853,
4152,
8586,
29067,
2854,
25778,
2819,
13663,
21748,
2102,
1006,
5216,
1002,
5216,
1010,
1002,
3078,
25778,
2819,
13663,
21748,
2102,
1007,
1063,
1002,
12398,
3366,
8663,
7662,
2100,
25778,
2819,
2078,
1027,
9140,
1006,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Collection.php | Collection.visible | public function visible()
{
$visible = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->visible()) {
$visible[$path] = $slug;
}
}
$this->items = $visible;
return $this;
} | php | public function visible()
{
$visible = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
if ($page !== null && $page->visible()) {
$visible[$path] = $slug;
}
}
$this->items = $visible;
return $this;
} | [
"public",
"function",
"visible",
"(",
")",
"{",
"$",
"visible",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"path",
"=>",
"$",
"slug",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"pages",
"->",
"get",
"(",
"$",... | Creates new collection with only visible pages
@return Collection The collection with only visible pages | [
"Creates",
"new",
"collection",
"with",
"only",
"visible",
"pages"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Collection.php#L359-L372 | train | Return all visible pages | [
30522,
2270,
3853,
5710,
1006,
1007,
1063,
1002,
5710,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
5167,
2004,
1002,
4130,
1027,
1028,
1002,
23667,
1007,
1063,
1002,
3931,
1027,
1002,
2023,
1011,
1028,
5530,
1011,
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... |
getgrav/grav | system/src/Grav/Common/Page/Medium/StaticResizeTrait.php | StaticResizeTrait.resize | public function resize($width = null, $height = null)
{
$this->styleAttributes['width'] = $width . 'px';
$this->styleAttributes['height'] = $height . 'px';
return $this;
} | php | public function resize($width = null, $height = null)
{
$this->styleAttributes['width'] = $width . 'px';
$this->styleAttributes['height'] = $height . 'px';
return $this;
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"styleAttributes",
"[",
"'width'",
"]",
"=",
"$",
"width",
".",
"'px'",
";",
"$",
"this",
"->",
"styleAttributes",
"[",
"'he... | Resize media by setting attributes
@param int $width
@param int $height
@return $this | [
"Resize",
"media",
"by",
"setting",
"attributes"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/StaticResizeTrait.php#L21-L27 | train | Resizes the page to the specified width and height | [
30522,
2270,
3853,
24501,
4697,
1006,
1002,
9381,
1027,
19701,
1010,
1002,
4578,
1027,
19701,
1007,
1063,
1002,
2023,
1011,
1028,
2806,
19321,
3089,
8569,
4570,
1031,
1005,
9381,
1005,
1033,
1027,
1002,
9381,
1012,
1005,
1052,
2595,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Mail/Mailer.php | Mailer.sendMailable | protected function sendMailable(MailableContract $mailable)
{
return $mailable instanceof ShouldQueue
? $mailable->queue($this->queue)
: $mailable->send($this);
} | php | protected function sendMailable(MailableContract $mailable)
{
return $mailable instanceof ShouldQueue
? $mailable->queue($this->queue)
: $mailable->send($this);
} | [
"protected",
"function",
"sendMailable",
"(",
"MailableContract",
"$",
"mailable",
")",
"{",
"return",
"$",
"mailable",
"instanceof",
"ShouldQueue",
"?",
"$",
"mailable",
"->",
"queue",
"(",
"$",
"this",
"->",
"queue",
")",
":",
"$",
"mailable",
"->",
"send"... | Send the given mailable.
@param \Illuminate\Contracts\Mail\Mailable $mailable
@return mixed | [
"Send",
"the",
"given",
"mailable",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Mail/Mailer.php#L271-L276 | train | Send the given mailable to the queue | [
30522,
5123,
3853,
4604,
21397,
3085,
1006,
5653,
3085,
8663,
6494,
6593,
1002,
5653,
3085,
1007,
1063,
2709,
1002,
5653,
3085,
6013,
11253,
2323,
4226,
5657,
1029,
1002,
5653,
3085,
1011,
1028,
24240,
1006,
1002,
2023,
1011,
1028,
24240,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Config/CompiledBase.php | CompiledBase.checksum | public function checksum()
{
if (null === $this->checksum) {
$this->checksum = md5(json_encode($this->files) . $this->version);
}
return $this->checksum;
} | php | public function checksum()
{
if (null === $this->checksum) {
$this->checksum = md5(json_encode($this->files) . $this->version);
}
return $this->checksum;
} | [
"public",
"function",
"checksum",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"checksum",
")",
"{",
"$",
"this",
"->",
"checksum",
"=",
"md5",
"(",
"json_encode",
"(",
"$",
"this",
"->",
"files",
")",
".",
"$",
"this",
"->",
"versio... | Returns checksum from the configuration files.
You can set $this->checksum = false to disable this check.
@return bool|string | [
"Returns",
"checksum",
"from",
"the",
"configuration",
"files",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Config/CompiledBase.php#L130-L137 | train | checksum - Returns the checksum of the files | [
30522,
2270,
3853,
14148,
2819,
1006,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
14148,
2819,
1007,
1063,
1002,
2023,
1011,
1028,
14148,
2819,
1027,
9108,
2629,
1006,
1046,
3385,
1035,
4372,
16044,
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... |
symfony/symfony | src/Symfony/Contracts/Cache/CacheTrait.php | CacheTrait.get | public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
return $this->doGet($this, $key, $callback, $beta, $metadata);
} | php | public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
return $this->doGet($this, $key, $callback, $beta, $metadata);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
",",
"callable",
"$",
"callback",
",",
"float",
"$",
"beta",
"=",
"null",
",",
"array",
"&",
"$",
"metadata",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"doGet",
"(",
"$",
"this",
","... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Contracts/Cache/CacheTrait.php#L28-L31 | train | Get a value from the cache | [
30522,
2270,
3853,
2131,
1006,
5164,
1002,
3145,
1010,
2655,
3085,
1002,
2655,
5963,
1010,
14257,
1002,
8247,
1027,
19701,
1010,
9140,
1004,
1002,
27425,
1027,
19701,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
3899,
3388,
1006,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Archive/DataTableFactory.php | DataTableFactory.makeMerged | public function makeMerged($index, $resultIndices)
{
if (!$this->isNumericDataType()) {
throw new \Exception('This method is supposed to work with non-numeric data types but it is not tested. To use it, remove this exception and write tests to be sure it works.');
}
$hasSiteIndex = isset($resultIndices[self::TABLE_METADATA_SITE_INDEX]);
$hasPeriodIndex = isset($resultIndices[self::TABLE_METADATA_PERIOD_INDEX]);
$isNumeric = $this->isNumericDataType();
// to be backwards compatible use a Simple table if needed as it will be formatted differently
$useSimpleDataTable = !$hasSiteIndex && $isNumeric;
if (!$hasSiteIndex) {
$firstIdSite = reset($this->sitesId);
$index = array($firstIdSite => $index);
}
if ($hasPeriodIndex) {
$dataTable = $this->makeMergedTableWithPeriodAndSiteIndex($index, $resultIndices, $useSimpleDataTable, $isNumeric);
} else {
$dataTable = $this->makeMergedWithSiteIndex($index, $useSimpleDataTable, $isNumeric);
}
return $dataTable;
} | php | public function makeMerged($index, $resultIndices)
{
if (!$this->isNumericDataType()) {
throw new \Exception('This method is supposed to work with non-numeric data types but it is not tested. To use it, remove this exception and write tests to be sure it works.');
}
$hasSiteIndex = isset($resultIndices[self::TABLE_METADATA_SITE_INDEX]);
$hasPeriodIndex = isset($resultIndices[self::TABLE_METADATA_PERIOD_INDEX]);
$isNumeric = $this->isNumericDataType();
// to be backwards compatible use a Simple table if needed as it will be formatted differently
$useSimpleDataTable = !$hasSiteIndex && $isNumeric;
if (!$hasSiteIndex) {
$firstIdSite = reset($this->sitesId);
$index = array($firstIdSite => $index);
}
if ($hasPeriodIndex) {
$dataTable = $this->makeMergedTableWithPeriodAndSiteIndex($index, $resultIndices, $useSimpleDataTable, $isNumeric);
} else {
$dataTable = $this->makeMergedWithSiteIndex($index, $useSimpleDataTable, $isNumeric);
}
return $dataTable;
} | [
"public",
"function",
"makeMerged",
"(",
"$",
"index",
",",
"$",
"resultIndices",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNumericDataType",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'This method is supposed to work with non-numeric dat... | Creates a merged DataTable|Map instance using an index of archive data similar to {@link make()}.
Whereas {@link make()} creates a Map for each result index (period and|or site), this will only create a Map
for a period result index and move all site related indices into one dataTable. This is the same as doing
`$dataTableFactory->make()->mergeChildren()` just much faster. It is mainly useful for reports across many sites
eg `MultiSites.getAll`. Was done as part of https://github.com/piwik/piwik/issues/6809
@param array $index @see DataCollection
@param array $resultIndices an array mapping metadata names with pretty metadata labels.
@return DataTable|DataTable\Map
@throws \Exception | [
"Creates",
"a",
"merged",
"DataTable|Map",
"instance",
"using",
"an",
"index",
"of",
"archive",
"data",
"similar",
"to",
"{",
"@link",
"make",
"()",
"}",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataTableFactory.php#L198-L223 | train | Returns the merged data table | [
30522,
2270,
3853,
2191,
5017,
5999,
1006,
1002,
5950,
1010,
1002,
2765,
22254,
23522,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
3475,
17897,
7277,
2850,
29336,
18863,
1006,
1007,
1007,
1063,
5466,
2047,
1032,
6453,
1006,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Foundation/Console/RouteListCommand.php | RouteListCommand.sortRoutes | protected function sortRoutes($sort, array $routes)
{
return Arr::sort($routes, function ($route) use ($sort) {
return $route[$sort];
});
} | php | protected function sortRoutes($sort, array $routes)
{
return Arr::sort($routes, function ($route) use ($sort) {
return $route[$sort];
});
} | [
"protected",
"function",
"sortRoutes",
"(",
"$",
"sort",
",",
"array",
"$",
"routes",
")",
"{",
"return",
"Arr",
"::",
"sort",
"(",
"$",
"routes",
",",
"function",
"(",
"$",
"route",
")",
"use",
"(",
"$",
"sort",
")",
"{",
"return",
"$",
"route",
"... | Sort the routes by a given element.
@param string $sort
@param array $routes
@return array | [
"Sort",
"the",
"routes",
"by",
"a",
"given",
"element",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/RouteListCommand.php#L128-L133 | train | Sort routes by given sort | [
30522,
5123,
3853,
4066,
22494,
4570,
1006,
1002,
4066,
1010,
9140,
1002,
5847,
1007,
1063,
2709,
12098,
2099,
1024,
1024,
4066,
1006,
1002,
5847,
1010,
3853,
1006,
1002,
2799,
1007,
2224,
1006,
1002,
4066,
1007,
1063,
2709,
1002,
2799,
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... |
symfony/symfony | src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php | AbstractComparisonValidator.validate | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof AbstractComparison) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\AbstractComparison');
}
if (null === $value) {
return;
}
if ($path = $constraint->propertyPath) {
if (null === $object = $this->context->getObject()) {
return;
}
try {
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
} catch (NoSuchPropertyException $e) {
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s', $path, \get_class($constraint), $e->getMessage()), 0, $e);
}
} else {
$comparedValue = $constraint->value;
}
// Convert strings to DateTimes if comparing another DateTime
// This allows to compare with any date/time value supported by
// the DateTime constructor:
// http://php.net/manual/en/datetime.formats.php
if (\is_string($comparedValue)) {
if ($value instanceof \DateTimeImmutable) {
// If $value is immutable, convert the compared value to a
// DateTimeImmutable too
$comparedValue = new \DateTimeImmutable($comparedValue);
} elseif ($value instanceof \DateTimeInterface) {
// Otherwise use DateTime
$comparedValue = new \DateTime($comparedValue);
}
}
if (!$this->compareValues($value, $comparedValue)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE))
->setParameter('{{ compared_value }}', $this->formatValue($comparedValue, self::OBJECT_TO_STRING | self::PRETTY_DATE))
->setParameter('{{ compared_value_type }}', $this->formatTypeOf($comparedValue))
->setCode($this->getErrorCode())
->addViolation();
}
} | php | public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof AbstractComparison) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\AbstractComparison');
}
if (null === $value) {
return;
}
if ($path = $constraint->propertyPath) {
if (null === $object = $this->context->getObject()) {
return;
}
try {
$comparedValue = $this->getPropertyAccessor()->getValue($object, $path);
} catch (NoSuchPropertyException $e) {
throw new ConstraintDefinitionException(sprintf('Invalid property path "%s" provided to "%s" constraint: %s', $path, \get_class($constraint), $e->getMessage()), 0, $e);
}
} else {
$comparedValue = $constraint->value;
}
// Convert strings to DateTimes if comparing another DateTime
// This allows to compare with any date/time value supported by
// the DateTime constructor:
// http://php.net/manual/en/datetime.formats.php
if (\is_string($comparedValue)) {
if ($value instanceof \DateTimeImmutable) {
// If $value is immutable, convert the compared value to a
// DateTimeImmutable too
$comparedValue = new \DateTimeImmutable($comparedValue);
} elseif ($value instanceof \DateTimeInterface) {
// Otherwise use DateTime
$comparedValue = new \DateTime($comparedValue);
}
}
if (!$this->compareValues($value, $comparedValue)) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value, self::OBJECT_TO_STRING | self::PRETTY_DATE))
->setParameter('{{ compared_value }}', $this->formatValue($comparedValue, self::OBJECT_TO_STRING | self::PRETTY_DATE))
->setParameter('{{ compared_value_type }}', $this->formatTypeOf($comparedValue))
->setCode($this->getErrorCode())
->addViolation();
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"Constraint",
"$",
"constraint",
")",
"{",
"if",
"(",
"!",
"$",
"constraint",
"instanceof",
"AbstractComparison",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"constraint",
",",
"__NAM... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Constraints/AbstractComparisonValidator.php#L40-L87 | train | Checks if the provided value is a valid comparison value | [
30522,
2270,
3853,
9398,
3686,
1006,
1002,
3643,
1010,
27142,
1002,
27142,
1007,
1063,
2065,
1006,
999,
1002,
27142,
6013,
11253,
10061,
9006,
19362,
10929,
1007,
1063,
5466,
2047,
9223,
13874,
10288,
24422,
1006,
1002,
27142,
1010,
1035,
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... |
getgrav/grav | system/src/Grav/Common/File/CompiledFile.php | CompiledFile.content | public function content($var = null)
{
try {
// If nothing has been loaded, attempt to get pre-compiled version of the file first.
if ($var === null && $this->raw === null && $this->content === null) {
$key = md5($this->filename);
$file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php");
$modified = $this->modified();
if (!$modified) {
return $this->decode($this->raw());
}
$class = get_class($this);
$cache = $file->exists() ? $file->content() : null;
// Load real file if cache isn't up to date (or is invalid).
if (
!isset($cache['@class'])
|| $cache['@class'] !== $class
|| $cache['modified'] !== $modified
|| $cache['filename'] !== $this->filename
) {
// Attempt to lock the file for writing.
try {
$file->lock(false);
} catch (\Exception $e) {
// Another process has locked the file; we will check this in a bit.
}
// Decode RAW file into compiled array.
$data = (array)$this->decode($this->raw());
$cache = [
'@class' => $class,
'filename' => $this->filename,
'modified' => $modified,
'data' => $data
];
// If compiled file wasn't already locked by another process, save it.
if ($file->locked() !== false) {
$file->save($cache);
$file->unlock();
// Compile cached file into bytecode cache
if (function_exists('opcache_invalidate')) {
// Silence error if function exists, but is restricted.
@opcache_invalidate($file->filename(), true);
}
}
}
$file->free();
$this->content = $cache['data'];
}
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e);
}
return parent::content($var);
} | php | public function content($var = null)
{
try {
// If nothing has been loaded, attempt to get pre-compiled version of the file first.
if ($var === null && $this->raw === null && $this->content === null) {
$key = md5($this->filename);
$file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php");
$modified = $this->modified();
if (!$modified) {
return $this->decode($this->raw());
}
$class = get_class($this);
$cache = $file->exists() ? $file->content() : null;
// Load real file if cache isn't up to date (or is invalid).
if (
!isset($cache['@class'])
|| $cache['@class'] !== $class
|| $cache['modified'] !== $modified
|| $cache['filename'] !== $this->filename
) {
// Attempt to lock the file for writing.
try {
$file->lock(false);
} catch (\Exception $e) {
// Another process has locked the file; we will check this in a bit.
}
// Decode RAW file into compiled array.
$data = (array)$this->decode($this->raw());
$cache = [
'@class' => $class,
'filename' => $this->filename,
'modified' => $modified,
'data' => $data
];
// If compiled file wasn't already locked by another process, save it.
if ($file->locked() !== false) {
$file->save($cache);
$file->unlock();
// Compile cached file into bytecode cache
if (function_exists('opcache_invalidate')) {
// Silence error if function exists, but is restricted.
@opcache_invalidate($file->filename(), true);
}
}
}
$file->free();
$this->content = $cache['data'];
}
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e);
}
return parent::content($var);
} | [
"public",
"function",
"content",
"(",
"$",
"var",
"=",
"null",
")",
"{",
"try",
"{",
"// If nothing has been loaded, attempt to get pre-compiled version of the file first.",
"if",
"(",
"$",
"var",
"===",
"null",
"&&",
"$",
"this",
"->",
"raw",
"===",
"null",
"&&",... | Get/set parsed file contents.
@param mixed $var
@return string | [
"Get",
"/",
"set",
"parsed",
"file",
"contents",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/File/CompiledFile.php#L22-L85 | train | Returns the compiled content of the file | [
30522,
2270,
3853,
4180,
1006,
1002,
13075,
1027,
19701,
1007,
1063,
3046,
1063,
1013,
1013,
2065,
2498,
2038,
2042,
8209,
1010,
3535,
2000,
2131,
3653,
1011,
9227,
2544,
1997,
1996,
5371,
2034,
1012,
2065,
1006,
1002,
13075,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Auth/Access/Gate.php | Gate.has | public function has($ability)
{
$abilities = is_array($ability) ? $ability : func_get_args();
foreach ($abilities as $ability) {
if (! isset($this->abilities[$ability])) {
return false;
}
}
return true;
} | php | public function has($ability)
{
$abilities = is_array($ability) ? $ability : func_get_args();
foreach ($abilities as $ability) {
if (! isset($this->abilities[$ability])) {
return false;
}
}
return true;
} | [
"public",
"function",
"has",
"(",
"$",
"ability",
")",
"{",
"$",
"abilities",
"=",
"is_array",
"(",
"$",
"ability",
")",
"?",
"$",
"ability",
":",
"func_get_args",
"(",
")",
";",
"foreach",
"(",
"$",
"abilities",
"as",
"$",
"ability",
")",
"{",
"if",... | Determine if a given ability has been defined.
@param string|array $ability
@return bool | [
"Determine",
"if",
"a",
"given",
"ability",
"has",
"been",
"defined",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Access/Gate.php#L105-L116 | train | Has the terms of the given ability | [
30522,
2270,
3853,
2038,
1006,
1002,
3754,
1007,
1063,
1002,
7590,
1027,
2003,
1035,
9140,
1006,
1002,
3754,
1007,
1029,
1002,
3754,
1024,
4569,
2278,
1035,
2131,
1035,
12098,
5620,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
7590,
2004,
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... |
matomo-org/matomo | plugins/Installation/FormDatabaseSetup.php | Rule_checkUserPrivileges.getRequiredPrivileges | public static function getRequiredPrivileges()
{
return array(
'CREATE' => 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' (
id INT AUTO_INCREMENT,
value INT,
PRIMARY KEY (id),
KEY index_value (value)
)',
'ALTER' => 'ALTER TABLE ' . self::TEST_TABLE_NAME . '
ADD COLUMN other_value INT DEFAULT 0',
'SELECT' => 'SELECT * FROM ' . self::TEST_TABLE_NAME,
'INSERT' => 'INSERT INTO ' . self::TEST_TABLE_NAME . ' (value) VALUES (123)',
'UPDATE' => 'UPDATE ' . self::TEST_TABLE_NAME . ' SET value = 456 WHERE id = 1',
'DELETE' => 'DELETE FROM ' . self::TEST_TABLE_NAME . ' WHERE id = 1',
'DROP' => 'DROP TABLE ' . self::TEST_TABLE_NAME,
'CREATE TEMPORARY TABLES' => 'CREATE TEMPORARY TABLE ' . self::TEST_TEMP_TABLE_NAME . ' (
id INT AUTO_INCREMENT,
PRIMARY KEY (id)
)',
);
} | php | public static function getRequiredPrivileges()
{
return array(
'CREATE' => 'CREATE TABLE ' . self::TEST_TABLE_NAME . ' (
id INT AUTO_INCREMENT,
value INT,
PRIMARY KEY (id),
KEY index_value (value)
)',
'ALTER' => 'ALTER TABLE ' . self::TEST_TABLE_NAME . '
ADD COLUMN other_value INT DEFAULT 0',
'SELECT' => 'SELECT * FROM ' . self::TEST_TABLE_NAME,
'INSERT' => 'INSERT INTO ' . self::TEST_TABLE_NAME . ' (value) VALUES (123)',
'UPDATE' => 'UPDATE ' . self::TEST_TABLE_NAME . ' SET value = 456 WHERE id = 1',
'DELETE' => 'DELETE FROM ' . self::TEST_TABLE_NAME . ' WHERE id = 1',
'DROP' => 'DROP TABLE ' . self::TEST_TABLE_NAME,
'CREATE TEMPORARY TABLES' => 'CREATE TEMPORARY TABLE ' . self::TEST_TEMP_TABLE_NAME . ' (
id INT AUTO_INCREMENT,
PRIMARY KEY (id)
)',
);
} | [
"public",
"static",
"function",
"getRequiredPrivileges",
"(",
")",
"{",
"return",
"array",
"(",
"'CREATE'",
"=>",
"'CREATE TABLE '",
".",
"self",
"::",
"TEST_TABLE_NAME",
".",
"' (\n id INT AUTO_INCREMENT,\n value INT,\n... | Returns an array describing the database privileges required for Matomo to run. The
array maps privilege names with one or more SQL queries that can be used to test
if the current user has the privilege.
NOTE: LOAD DATA INFILE & LOCK TABLES privileges are not **required** so they're
not checked.
@return array | [
"Returns",
"an",
"array",
"describing",
"the",
"database",
"privileges",
"required",
"for",
"Matomo",
"to",
"run",
".",
"The",
"array",
"maps",
"privilege",
"names",
"with",
"one",
"or",
"more",
"SQL",
"queries",
"that",
"can",
"be",
"used",
"to",
"test",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Installation/FormDatabaseSetup.php#L258-L279 | train | Returns an array of required privileges | [
30522,
2270,
10763,
3853,
2131,
2890,
15549,
5596,
18098,
12848,
9463,
8449,
1006,
1007,
1063,
2709,
9140,
1006,
1005,
3443,
1005,
1027,
1028,
1005,
3443,
2795,
1005,
1012,
2969,
1024,
1024,
3231,
1035,
2795,
1035,
2171,
1012,
1005,
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... |
matomo-org/matomo | core/Archive/DataTableFactory.php | DataTableFactory.createDataTableMapFromIndex | private function createDataTableMapFromIndex($index, $resultIndices, $keyMetadata)
{
$result = new DataTable\Map();
$result->setKeyName(reset($resultIndices));
$resultIndex = key($resultIndices);
array_shift($resultIndices);
$hasIndices = !empty($resultIndices);
foreach ($index as $label => $value) {
$keyMetadata[$resultIndex] = $this->createTableIndexMetadata($resultIndex, $label);
if ($hasIndices) {
$newTable = $this->createDataTableMapFromIndex($value, $resultIndices, $keyMetadata);
} else {
$newTable = $this->createDataTable($value, $keyMetadata);
}
$result->addTable($newTable, $this->prettifyIndexLabel($resultIndex, $label));
}
return $result;
} | php | private function createDataTableMapFromIndex($index, $resultIndices, $keyMetadata)
{
$result = new DataTable\Map();
$result->setKeyName(reset($resultIndices));
$resultIndex = key($resultIndices);
array_shift($resultIndices);
$hasIndices = !empty($resultIndices);
foreach ($index as $label => $value) {
$keyMetadata[$resultIndex] = $this->createTableIndexMetadata($resultIndex, $label);
if ($hasIndices) {
$newTable = $this->createDataTableMapFromIndex($value, $resultIndices, $keyMetadata);
} else {
$newTable = $this->createDataTable($value, $keyMetadata);
}
$result->addTable($newTable, $this->prettifyIndexLabel($resultIndex, $label));
}
return $result;
} | [
"private",
"function",
"createDataTableMapFromIndex",
"(",
"$",
"index",
",",
"$",
"resultIndices",
",",
"$",
"keyMetadata",
")",
"{",
"$",
"result",
"=",
"new",
"DataTable",
"\\",
"Map",
"(",
")",
";",
"$",
"result",
"->",
"setKeyName",
"(",
"reset",
"(",... | Creates a Set from an array index.
@param array $index @see DataCollection
@param array $resultIndices @see make
@param array $keyMetadata The metadata to add to the table when it's created.
@return DataTable\Map | [
"Creates",
"a",
"Set",
"from",
"an",
"array",
"index",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/Archive/DataTableFactory.php#L316-L339 | train | Create a DataTable \ Map from an index | [
30522,
2797,
3853,
2580,
6790,
10880,
2863,
14376,
21716,
22254,
10288,
1006,
1002,
5950,
1010,
1002,
2765,
22254,
23522,
1010,
1002,
3145,
11368,
8447,
2696,
1007,
1063,
1002,
2765,
1027,
2047,
2951,
10880,
1032,
4949,
1006,
1007,
1025,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/FormErrorIterator.php | FormErrorIterator.offsetGet | public function offsetGet($position)
{
if (!isset($this->errors[$position])) {
throw new OutOfBoundsException('The offset '.$position.' does not exist.');
}
return $this->errors[$position];
} | php | public function offsetGet($position)
{
if (!isset($this->errors[$position])) {
throw new OutOfBoundsException('The offset '.$position.' does not exist.');
}
return $this->errors[$position];
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"position",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"errors",
"[",
"$",
"position",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'The offset '",
".",
"$",
"position",
... | Returns the element at a position in the iterator.
@param int $position The position
@return FormError|FormErrorIterator The element at the given position
@throws OutOfBoundsException If the given position does not exist | [
"Returns",
"the",
"element",
"at",
"a",
"position",
"in",
"the",
"iterator",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/FormErrorIterator.php#L162-L169 | train | Get the error at the given position | [
30522,
2270,
3853,
16396,
18150,
1006,
1002,
2597,
1007,
1063,
2065,
1006,
999,
26354,
3388,
1006,
1002,
2023,
1011,
1028,
10697,
1031,
1002,
2597,
1033,
1007,
1007,
1063,
5466,
2047,
2041,
11253,
15494,
3366,
2595,
24422,
1006,
1005,
1996,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/API/API.php | API.getRowEvolution | public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true, $idDimension = false)
{
// check if site exists
$idSite = (int) $idSite;
$site = new Site($idSite);
Piwik::checkUserHasViewAccess($idSite);
$apiParameters = array();
$entityNames = StaticContainer::get('entities.idNames');
foreach ($entityNames as $entityName) {
if ($entityName === 'idGoal' && is_numeric($idGoal)) {
$apiParameters['idGoal'] = $idGoal;
} elseif ($entityName === 'idDimension' && $idDimension) {
$apiParameters['idDimension'] = $idDimension;
} else {
// ideally it would get the value from API params but dynamic params is not possible yet in API. If this
// method is called eg in Request::processRequest, it could in theory pick up a param from the original request
// and not from the API request within the original request.
$idEntity = Common::getRequestVar($entityName, 0, 'int');
if ($idEntity > 0) {
$apiParameters[$entityName] = $idEntity;
}
}
}
$rowEvolution = new RowEvolution();
return $rowEvolution->getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label, $segment, $column,
$language, $apiParameters, $legendAppendMetric, $labelUseAbsoluteUrl);
} | php | public function getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label = false, $segment = false, $column = false, $language = false, $idGoal = false, $legendAppendMetric = true, $labelUseAbsoluteUrl = true, $idDimension = false)
{
// check if site exists
$idSite = (int) $idSite;
$site = new Site($idSite);
Piwik::checkUserHasViewAccess($idSite);
$apiParameters = array();
$entityNames = StaticContainer::get('entities.idNames');
foreach ($entityNames as $entityName) {
if ($entityName === 'idGoal' && is_numeric($idGoal)) {
$apiParameters['idGoal'] = $idGoal;
} elseif ($entityName === 'idDimension' && $idDimension) {
$apiParameters['idDimension'] = $idDimension;
} else {
// ideally it would get the value from API params but dynamic params is not possible yet in API. If this
// method is called eg in Request::processRequest, it could in theory pick up a param from the original request
// and not from the API request within the original request.
$idEntity = Common::getRequestVar($entityName, 0, 'int');
if ($idEntity > 0) {
$apiParameters[$entityName] = $idEntity;
}
}
}
$rowEvolution = new RowEvolution();
return $rowEvolution->getRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $label, $segment, $column,
$language, $apiParameters, $legendAppendMetric, $labelUseAbsoluteUrl);
} | [
"public",
"function",
"getRowEvolution",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"apiModule",
",",
"$",
"apiAction",
",",
"$",
"label",
"=",
"false",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"column",
"=",
"false",
","... | Given an API report to query (eg. "Referrers.getKeywords", and a Label (eg. "free%20software"),
this function will query the API for the previous days/weeks/etc. and will return
a ready to use data structure containing the metrics for the requested Label, along with enriched information (min/max values, etc.)
@param int $idSite
@param string $period
@param Date $date
@param string $apiModule
@param string $apiAction
@param bool|string $label
@param bool|string $segment
@param bool|string $column
@param bool|string $language
@param bool|int $idGoal
@param bool|string $legendAppendMetric
@param bool|string $labelUseAbsoluteUrl
@param bool|int $idDimension
@return array | [
"Given",
"an",
"API",
"report",
"to",
"query",
"(",
"eg",
".",
"Referrers",
".",
"getKeywords",
"and",
"a",
"Label",
"(",
"eg",
".",
"free%20software",
")",
"this",
"function",
"will",
"query",
"the",
"API",
"for",
"the",
"previous",
"days",
"/",
"weeks"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/API/API.php#L479-L508 | train | This method is used to get the row evolution of the site | [
30522,
2270,
3853,
2131,
10524,
6777,
4747,
13700,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
17928,
5302,
8566,
2571,
1010,
1002,
17928,
18908,
3258,
1010,
1002,
3830,
1027,
6270,
1010,
1002,
6903,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataTable.php | DataTable.walkPath | public function walkPath($path, $missingRowColumns = false, $maxSubtableRows = 0)
{
$pathLength = count($path);
$table = $this;
$next = false;
for ($i = 0; $i < $pathLength; ++$i) {
$segment = $path[$i];
$next = $table->getRowFromLabel($segment);
if ($next === false) {
// if there is no table to advance to, and we're not adding missing rows, return false
if ($missingRowColumns === false) {
return array(false, $i);
} else {
// if we're adding missing rows, add a new row
$row = new DataTableSummaryRow();
$row->setColumns(array('label' => $segment) + $missingRowColumns);
$next = $table->addRow($row);
if ($next !== $row) {
// if the row wasn't added, the table is full
// Summary row, has no metadata
$next->deleteMetadata();
return array($next, $i);
}
}
}
$table = $next->getSubtable();
if ($table === false) {
// if the row has no table (and thus no child rows), and we're not adding
// missing rows, return false
if ($missingRowColumns === false) {
return array(false, $i);
} elseif ($i != $pathLength - 1) {
// create subtable if missing, but only if not on the last segment
$table = new DataTable();
$table->setMaximumAllowedRows($maxSubtableRows);
$table->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME]
= $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$next->setSubtable($table);
// Summary row, has no metadata
$next->deleteMetadata();
}
}
}
return array($next, $i);
} | php | public function walkPath($path, $missingRowColumns = false, $maxSubtableRows = 0)
{
$pathLength = count($path);
$table = $this;
$next = false;
for ($i = 0; $i < $pathLength; ++$i) {
$segment = $path[$i];
$next = $table->getRowFromLabel($segment);
if ($next === false) {
// if there is no table to advance to, and we're not adding missing rows, return false
if ($missingRowColumns === false) {
return array(false, $i);
} else {
// if we're adding missing rows, add a new row
$row = new DataTableSummaryRow();
$row->setColumns(array('label' => $segment) + $missingRowColumns);
$next = $table->addRow($row);
if ($next !== $row) {
// if the row wasn't added, the table is full
// Summary row, has no metadata
$next->deleteMetadata();
return array($next, $i);
}
}
}
$table = $next->getSubtable();
if ($table === false) {
// if the row has no table (and thus no child rows), and we're not adding
// missing rows, return false
if ($missingRowColumns === false) {
return array(false, $i);
} elseif ($i != $pathLength - 1) {
// create subtable if missing, but only if not on the last segment
$table = new DataTable();
$table->setMaximumAllowedRows($maxSubtableRows);
$table->metadata[self::COLUMN_AGGREGATION_OPS_METADATA_NAME]
= $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$next->setSubtable($table);
// Summary row, has no metadata
$next->deleteMetadata();
}
}
}
return array($next, $i);
} | [
"public",
"function",
"walkPath",
"(",
"$",
"path",
",",
"$",
"missingRowColumns",
"=",
"false",
",",
"$",
"maxSubtableRows",
"=",
"0",
")",
"{",
"$",
"pathLength",
"=",
"count",
"(",
"$",
"path",
")",
";",
"$",
"table",
"=",
"$",
"this",
";",
"$",
... | Traverses a DataTable tree using an array of labels and returns the row
it finds or `false` if it cannot find one. The number of path segments that
were successfully walked is also returned.
If `$missingRowColumns` is supplied, the specified path is created. When
a subtable is encountered w/o the required label, a new row is created
with the label, and a new subtable is added to the row.
Read [http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods](http://en.wikipedia.org/wiki/Tree_(data_structure)#Traversal_methods)
for more information about tree walking.
@param array $path The path to walk. An array of label values. The first element
refers to a row in this DataTable, the second in a subtable of
the first row, the third a subtable of the second row, etc.
@param array|bool $missingRowColumns The default columns to use when creating new rows.
If this parameter is supplied, new rows will be
created for path labels that cannot be found.
@param int $maxSubtableRows The maximum number of allowed rows in new subtables. New
subtables are only created if `$missingRowColumns` is provided.
@return array First element is the found row or `false`. Second element is
the number of path segments walked. If a row is found, this
will be == to `count($path)`. Otherwise, it will be the index
of the path segment that we could not find. | [
"Traverses",
"a",
"DataTable",
"tree",
"using",
"an",
"array",
"of",
"labels",
"and",
"returns",
"the",
"row",
"it",
"finds",
"or",
"false",
"if",
"it",
"cannot",
"find",
"one",
".",
"The",
"number",
"of",
"path",
"segments",
"that",
"were",
"successfully"... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataTable.php#L1693-L1746 | train | Walks through the path and returns the next row | [
30522,
2270,
3853,
3328,
15069,
1006,
1002,
4130,
1010,
1002,
4394,
10524,
25778,
2819,
3619,
1027,
6270,
1010,
1002,
4098,
6342,
19279,
3085,
10524,
2015,
1027,
1014,
1007,
1063,
1002,
4130,
7770,
13512,
2232,
1027,
4175,
1006,
1002,
4130,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Foundation/Http/Middleware/CheckForMaintenanceMode.php | CheckForMaintenanceMode.handle | public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
$data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true);
if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
return $next($request);
}
if ($this->inExceptArray($request)) {
return $next($request);
}
throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
}
return $next($request);
} | php | public function handle($request, Closure $next)
{
if ($this->app->isDownForMaintenance()) {
$data = json_decode(file_get_contents($this->app->storagePath().'/framework/down'), true);
if (isset($data['allowed']) && IpUtils::checkIp($request->ip(), (array) $data['allowed'])) {
return $next($request);
}
if ($this->inExceptArray($request)) {
return $next($request);
}
throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"$",
"request",
",",
"Closure",
"$",
"next",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"isDownForMaintenance",
"(",
")",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"thi... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed
@throws \Symfony\Component\HttpKernel\Exception\HttpException | [
"Handle",
"an",
"incoming",
"request",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php#L46-L63 | train | Handle the request | [
30522,
2270,
3853,
5047,
1006,
1002,
5227,
1010,
8503,
1002,
2279,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
10439,
1011,
1028,
2003,
7698,
14192,
22325,
8189,
5897,
1006,
1007,
1007,
1063,
1002,
2951,
1027,
1046,
3385,
1035,
21933,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Validator/ViolationMapper/ViolationMapper.php | ViolationMapper.mapViolation | public function mapViolation(ConstraintViolation $violation, FormInterface $form, $allowNonSynchronized = false)
{
$this->allowNonSynchronized = $allowNonSynchronized;
// The scope is the currently found most specific form that
// an error should be mapped to. After setting the scope, the
// mapper will try to continue to find more specific matches in
// the children of scope. If it cannot, the error will be
// mapped to this scope.
$scope = null;
$violationPath = null;
$relativePath = null;
$match = false;
// Don't create a ViolationPath instance for empty property paths
if (\strlen($violation->getPropertyPath()) > 0) {
$violationPath = new ViolationPath($violation->getPropertyPath());
$relativePath = $this->reconstructPath($violationPath, $form);
}
// This case happens if the violation path is empty and thus
// the violation should be mapped to the root form
if (null === $violationPath) {
$scope = $form;
}
// In general, mapping happens from the root form to the leaf forms
// First, the rules of the root form are applied to determine
// the subsequent descendant. The rules of this descendant are then
// applied to find the next and so on, until we have found the
// most specific form that matches the violation.
// If any of the forms found in this process is not synchronized,
// mapping is aborted. Non-synchronized forms could not reverse
// transform the value entered by the user, thus any further violations
// caused by the (invalid) reverse transformed value should be
// ignored.
if (null !== $relativePath) {
// Set the scope to the root of the relative path
// This root will usually be $form. If the path contains
// an unmapped form though, the last unmapped form found
// will be the root of the path.
$scope = $relativePath->getRoot();
$it = new PropertyPathIterator($relativePath);
while ($this->acceptsErrors($scope) && null !== ($child = $this->matchChild($scope, $it))) {
$scope = $child;
$it->next();
$match = true;
}
}
// This case happens if an error happened in the data under a
// form inheriting its parent data that does not match any of the
// children of that form.
if (null !== $violationPath && !$match) {
// If we could not map the error to anything more specific
// than the root element, map it to the innermost directly
// mapped form of the violation path
// e.g. "children[foo].children[bar].data.baz"
// Here the innermost directly mapped child is "bar"
$scope = $form;
$it = new ViolationPathIterator($violationPath);
// Note: acceptsErrors() will always return true for forms inheriting
// their parent data, because these forms can never be non-synchronized
// (they don't do any data transformation on their own)
while ($this->acceptsErrors($scope) && $it->valid() && $it->mapsForm()) {
if (!$scope->has($it->current())) {
// Break if we find a reference to a non-existing child
break;
}
$scope = $scope->get($it->current());
$it->next();
}
}
// Follow dot rules until we have the final target
$mapping = $scope->getConfig()->getOption('error_mapping');
while ($this->acceptsErrors($scope) && isset($mapping['.'])) {
$dotRule = new MappingRule($scope, '.', $mapping['.']);
$scope = $dotRule->getTarget();
$mapping = $scope->getConfig()->getOption('error_mapping');
}
// Only add the error if the form is synchronized
if ($this->acceptsErrors($scope)) {
$scope->addError(new FormError(
$violation->getMessage(),
$violation->getMessageTemplate(),
$violation->getParameters(),
$violation->getPlural(),
$violation
));
}
} | php | public function mapViolation(ConstraintViolation $violation, FormInterface $form, $allowNonSynchronized = false)
{
$this->allowNonSynchronized = $allowNonSynchronized;
// The scope is the currently found most specific form that
// an error should be mapped to. After setting the scope, the
// mapper will try to continue to find more specific matches in
// the children of scope. If it cannot, the error will be
// mapped to this scope.
$scope = null;
$violationPath = null;
$relativePath = null;
$match = false;
// Don't create a ViolationPath instance for empty property paths
if (\strlen($violation->getPropertyPath()) > 0) {
$violationPath = new ViolationPath($violation->getPropertyPath());
$relativePath = $this->reconstructPath($violationPath, $form);
}
// This case happens if the violation path is empty and thus
// the violation should be mapped to the root form
if (null === $violationPath) {
$scope = $form;
}
// In general, mapping happens from the root form to the leaf forms
// First, the rules of the root form are applied to determine
// the subsequent descendant. The rules of this descendant are then
// applied to find the next and so on, until we have found the
// most specific form that matches the violation.
// If any of the forms found in this process is not synchronized,
// mapping is aborted. Non-synchronized forms could not reverse
// transform the value entered by the user, thus any further violations
// caused by the (invalid) reverse transformed value should be
// ignored.
if (null !== $relativePath) {
// Set the scope to the root of the relative path
// This root will usually be $form. If the path contains
// an unmapped form though, the last unmapped form found
// will be the root of the path.
$scope = $relativePath->getRoot();
$it = new PropertyPathIterator($relativePath);
while ($this->acceptsErrors($scope) && null !== ($child = $this->matchChild($scope, $it))) {
$scope = $child;
$it->next();
$match = true;
}
}
// This case happens if an error happened in the data under a
// form inheriting its parent data that does not match any of the
// children of that form.
if (null !== $violationPath && !$match) {
// If we could not map the error to anything more specific
// than the root element, map it to the innermost directly
// mapped form of the violation path
// e.g. "children[foo].children[bar].data.baz"
// Here the innermost directly mapped child is "bar"
$scope = $form;
$it = new ViolationPathIterator($violationPath);
// Note: acceptsErrors() will always return true for forms inheriting
// their parent data, because these forms can never be non-synchronized
// (they don't do any data transformation on their own)
while ($this->acceptsErrors($scope) && $it->valid() && $it->mapsForm()) {
if (!$scope->has($it->current())) {
// Break if we find a reference to a non-existing child
break;
}
$scope = $scope->get($it->current());
$it->next();
}
}
// Follow dot rules until we have the final target
$mapping = $scope->getConfig()->getOption('error_mapping');
while ($this->acceptsErrors($scope) && isset($mapping['.'])) {
$dotRule = new MappingRule($scope, '.', $mapping['.']);
$scope = $dotRule->getTarget();
$mapping = $scope->getConfig()->getOption('error_mapping');
}
// Only add the error if the form is synchronized
if ($this->acceptsErrors($scope)) {
$scope->addError(new FormError(
$violation->getMessage(),
$violation->getMessageTemplate(),
$violation->getParameters(),
$violation->getPlural(),
$violation
));
}
} | [
"public",
"function",
"mapViolation",
"(",
"ConstraintViolation",
"$",
"violation",
",",
"FormInterface",
"$",
"form",
",",
"$",
"allowNonSynchronized",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"allowNonSynchronized",
"=",
"$",
"allowNonSynchronized",
";",
"// T... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php#L35-L135 | train | Map a constraint violation to the most specific form that the user has found. | [
30522,
2270,
3853,
4949,
25500,
13490,
1006,
27142,
25500,
13490,
1002,
11371,
1010,
2433,
18447,
2121,
12172,
1002,
2433,
1010,
1002,
3499,
8540,
6508,
12680,
4948,
3550,
1027,
6270,
1007,
1063,
1002,
2023,
1011,
1028,
3499,
8540,
6508,
12... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/CoreAdminHome/Model/DuplicateActionRemover.php | DuplicateActionRemover.getSitesAndDatesOfRowsUsingDuplicates | public function getSitesAndDatesOfRowsUsingDuplicates($table, $duplicateIdActions)
{
$idactionColumns = $this->getIdActionTableColumnsFromMetadata();
$idactionColumns = array_values($idactionColumns[$table]);
$table = Common::prefixTable($table);
$sql = "SELECT idsite, DATE(server_time) as server_time FROM $table ";
$sql .= $this->getWhereToGetRowsUsingDuplicateActions($idactionColumns, $duplicateIdActions);
return Db::fetchAll($sql);
} | php | public function getSitesAndDatesOfRowsUsingDuplicates($table, $duplicateIdActions)
{
$idactionColumns = $this->getIdActionTableColumnsFromMetadata();
$idactionColumns = array_values($idactionColumns[$table]);
$table = Common::prefixTable($table);
$sql = "SELECT idsite, DATE(server_time) as server_time FROM $table ";
$sql .= $this->getWhereToGetRowsUsingDuplicateActions($idactionColumns, $duplicateIdActions);
return Db::fetchAll($sql);
} | [
"public",
"function",
"getSitesAndDatesOfRowsUsingDuplicates",
"(",
"$",
"table",
",",
"$",
"duplicateIdActions",
")",
"{",
"$",
"idactionColumns",
"=",
"$",
"this",
"->",
"getIdActionTableColumnsFromMetadata",
"(",
")",
";",
"$",
"idactionColumns",
"=",
"array_values... | Returns the server time and idsite of rows in a log table that reference at least one action
in a set.
@param string $table
@param int[] $duplicateIdActions
@return array with two elements **idsite** and **server_time**. idsite is the site ID and server_time
is the date of the log. | [
"Returns",
"the",
"server",
"time",
"and",
"idsite",
"of",
"rows",
"in",
"a",
"log",
"table",
"that",
"reference",
"at",
"least",
"one",
"action",
"in",
"a",
"set",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/Model/DuplicateActionRemover.php#L142-L151 | train | Returns the idsite and server_time of rows from a table that are not already in a duplicate action list. | [
30522,
2270,
3853,
4152,
7616,
5685,
27122,
11253,
10524,
13203,
2075,
8566,
24759,
24695,
2015,
1006,
1002,
2795,
1010,
1002,
24473,
8524,
22014,
1007,
1063,
1002,
16096,
7542,
25778,
2819,
3619,
1027,
1002,
2023,
30524,
10880,
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... |
getgrav/grav | system/src/Grav/Framework/File/Formatter/YamlFormatter.php | YamlFormatter.encode | public function encode($data, $inline = null, $indent = null): string
{
try {
return YamlParser::dump(
$data,
$inline ? (int) $inline : $this->getInlineOption(),
$indent ? (int) $indent : $this->getIndentOption(),
YamlParser::DUMP_EXCEPTION_ON_INVALID_TYPE
);
} catch (DumpException $e) {
throw new \RuntimeException('Encoding YAML failed: ' . $e->getMessage(), 0, $e);
}
} | php | public function encode($data, $inline = null, $indent = null): string
{
try {
return YamlParser::dump(
$data,
$inline ? (int) $inline : $this->getInlineOption(),
$indent ? (int) $indent : $this->getIndentOption(),
YamlParser::DUMP_EXCEPTION_ON_INVALID_TYPE
);
} catch (DumpException $e) {
throw new \RuntimeException('Encoding YAML failed: ' . $e->getMessage(), 0, $e);
}
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"inline",
"=",
"null",
",",
"$",
"indent",
"=",
"null",
")",
":",
"string",
"{",
"try",
"{",
"return",
"YamlParser",
"::",
"dump",
"(",
"$",
"data",
",",
"$",
"inline",
"?",
"(",
"int",
... | {@inheritdoc}
@see FileFormatterInterface::encode() | [
"{"
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/File/Formatter/YamlFormatter.php#L71-L83 | train | Encodes data in YAML format | [
30522,
2270,
3853,
4372,
16044,
1006,
1002,
2951,
1010,
1002,
23881,
1027,
19701,
1010,
1002,
27427,
4765,
1027,
19701,
1007,
1024,
5164,
1063,
3046,
1063,
2709,
8038,
19968,
19362,
8043,
1024,
1024,
15653,
1006,
1002,
2951,
1010,
1002,
238... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Goals/API.php | API.getDaysToConversion | public function getDaysToConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true, false));
$dataTable->queueFilter(
'BeautifyRangeLabels', array(Piwik::translate('Intl_OneDay'), Piwik::translate('Intl_NDays')));
return $dataTable;
} | php | public function getDaysToConversion($idSite, $period, $date, $segment = false, $idGoal = false)
{
$dataTable = $this->getGoalSpecificDataTable(
Archiver::DAYS_UNTIL_CONV_RECORD_NAME, $idSite, $period, $date, $segment, $idGoal);
$dataTable->queueFilter('Sort', array('label', 'asc', true, false));
$dataTable->queueFilter(
'BeautifyRangeLabels', array(Piwik::translate('Intl_OneDay'), Piwik::translate('Intl_NDays')));
return $dataTable;
} | [
"public",
"function",
"getDaysToConversion",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"idGoal",
"=",
"false",
")",
"{",
"$",
"dataTable",
"=",
"$",
"this",
"->",
"getGoalSpecificDataTable",
"(... | Gets a DataTable that maps ranges of days to the number of conversions that occurred
within those ranges, for the specified site, date range, segment and goal.
@param int $idSite The site to select data from.
@param string $period The period type.
@param string $date The date type.
@param string|bool $segment The segment.
@param int|bool $idGoal The id of the goal to get data for. If this is set to false,
data for every goal that belongs to $idSite is returned.
@return false|DataTable | [
"Gets",
"a",
"DataTable",
"that",
"maps",
"ranges",
"of",
"days",
"to",
"the",
"number",
"of",
"conversions",
"that",
"occurred",
"within",
"those",
"ranges",
"for",
"the",
"specified",
"site",
"date",
"range",
"segment",
"and",
"goal",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Goals/API.php#L674-L684 | train | Returns the days to conversion table for the given site period date segment and goal. | [
30522,
2270,
3853,
2131,
10259,
16033,
8663,
27774,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
8909,
3995,
2389,
1027,
6270,
1007,
1063,
1002,
2951,
10880,
1027,
1002,
2023,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Support/Arr.php | Arr.prepend | public static function prepend($array, $value, $key = null)
{
if (is_null($key)) {
array_unshift($array, $value);
} else {
$array = [$key => $value] + $array;
}
return $array;
} | php | public static function prepend($array, $value, $key = null)
{
if (is_null($key)) {
array_unshift($array, $value);
} else {
$array = [$key => $value] + $array;
}
return $array;
} | [
"public",
"static",
"function",
"prepend",
"(",
"$",
"array",
",",
"$",
"value",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"array_unshift",
"(",
"$",
"array",
",",
"$",
"value",
")",
";",
"}",
... | Push an item onto the beginning of an array.
@param array $array
@param mixed $value
@param mixed $key
@return array | [
"Push",
"an",
"item",
"onto",
"the",
"beginning",
"of",
"an",
"array",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Support/Arr.php#L428-L437 | train | Prepends a value to the beginning of an array | [
30522,
2270,
10763,
3853,
17463,
10497,
1006,
1002,
9140,
1010,
1002,
3643,
1010,
1002,
3145,
1027,
19701,
1007,
1063,
2065,
1006,
2003,
1035,
19701,
1006,
1002,
3145,
1007,
1007,
1063,
9140,
1035,
4895,
6182,
6199,
1006,
1002,
9140,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.getAnnotationsForSite | private function getAnnotationsForSite()
{
$result = array();
foreach ($this->idSites as $id) {
$optionName = self::getAnnotationCollectionOptionName($id);
$serialized = Option::get($optionName);
if ($serialized !== false) {
$result[$id] = Common::safe_unserialize($serialized);
if (empty($result[$id])) {
// in case unserialize failed
$result[$id] = array();
}
} else {
$result[$id] = array();
}
}
return $result;
} | php | private function getAnnotationsForSite()
{
$result = array();
foreach ($this->idSites as $id) {
$optionName = self::getAnnotationCollectionOptionName($id);
$serialized = Option::get($optionName);
if ($serialized !== false) {
$result[$id] = Common::safe_unserialize($serialized);
if (empty($result[$id])) {
// in case unserialize failed
$result[$id] = array();
}
} else {
$result[$id] = array();
}
}
return $result;
} | [
"private",
"function",
"getAnnotationsForSite",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"idSites",
"as",
"$",
"id",
")",
"{",
"$",
"optionName",
"=",
"self",
"::",
"getAnnotationCollectionOptionName",
"... | Retrieves annotations from the database for the sites supplied to the
constructor.
@return array Lists of annotations mapped by site ID. | [
"Retrieves",
"annotations",
"from",
"the",
"database",
"for",
"the",
"sites",
"supplied",
"to",
"the",
"constructor",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Annotations/AnnotationList.php#L326-L344 | train | Returns all annotations for all sites | [
30522,
2797,
3853,
2131,
11639,
17287,
9285,
29278,
28032,
2063,
1006,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
8909,
28032,
2229,
2004,
1002,
8909,
1007,
1063,
1002,
5724,
18442,
1027... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Pages.php | Pages.buildPages | protected function buildPages()
{
$this->sort = [];
/** @var Config $config */
$config = $this->grav['config'];
/** @var Language $language */
$language = $this->grav['language'];
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$pages_dir = $locator->findResource('page://');
if ($config->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $this->grav['cache'];
/** @var Taxonomy $taxonomy */
$taxonomy = $this->grav['taxonomy'];
// how should we check for last modified? Default is by file
switch ($this->check_method) {
case 'none':
case 'off':
$hash = 0;
break;
case 'folder':
$hash = Folder::lastModifiedFolder($pages_dir);
break;
case 'hash':
$hash = Folder::hashAllFiles($pages_dir);
break;
default:
$hash = Folder::lastModifiedFile($pages_dir);
}
$this->pages_cache_id = md5($pages_dir . $hash . $language->getActive() . $config->checksum());
list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cache->fetch($this->pages_cache_id);
if (!$this->instances) {
$this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
// recurse pages and cache result
$this->resetPages($pages_dir);
} else {
// If pages was found in cache, set the taxonomy
$this->grav['debugger']->addMessage('Page cache hit.');
$taxonomy->taxonomy($taxonomy_map);
}
} else {
$this->recurse($pages_dir);
$this->buildRoutes();
}
} | php | protected function buildPages()
{
$this->sort = [];
/** @var Config $config */
$config = $this->grav['config'];
/** @var Language $language */
$language = $this->grav['language'];
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$pages_dir = $locator->findResource('page://');
if ($config->get('system.cache.enabled')) {
/** @var Cache $cache */
$cache = $this->grav['cache'];
/** @var Taxonomy $taxonomy */
$taxonomy = $this->grav['taxonomy'];
// how should we check for last modified? Default is by file
switch ($this->check_method) {
case 'none':
case 'off':
$hash = 0;
break;
case 'folder':
$hash = Folder::lastModifiedFolder($pages_dir);
break;
case 'hash':
$hash = Folder::hashAllFiles($pages_dir);
break;
default:
$hash = Folder::lastModifiedFile($pages_dir);
}
$this->pages_cache_id = md5($pages_dir . $hash . $language->getActive() . $config->checksum());
list($this->instances, $this->routes, $this->children, $taxonomy_map, $this->sort) = $cache->fetch($this->pages_cache_id);
if (!$this->instances) {
$this->grav['debugger']->addMessage('Page cache missed, rebuilding pages..');
// recurse pages and cache result
$this->resetPages($pages_dir);
} else {
// If pages was found in cache, set the taxonomy
$this->grav['debugger']->addMessage('Page cache hit.');
$taxonomy->taxonomy($taxonomy_map);
}
} else {
$this->recurse($pages_dir);
$this->buildRoutes();
}
} | [
"protected",
"function",
"buildPages",
"(",
")",
"{",
"$",
"this",
"->",
"sort",
"=",
"[",
"]",
";",
"/** @var Config $config */",
"$",
"config",
"=",
"$",
"this",
"->",
"grav",
"[",
"'config'",
"]",
";",
"/** @var Language $language */",
"$",
"language",
"=... | Builds pages.
@internal | [
"Builds",
"pages",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Pages.php#L940-L995 | train | Build pages from page locations | [
30522,
5123,
3853,
3857,
13704,
2015,
1006,
1007,
1063,
1002,
2023,
1011,
1028,
4066,
1027,
1031,
1033,
1025,
1013,
1008,
1008,
1030,
13075,
9530,
8873,
2290,
1002,
9530,
8873,
2290,
1008,
1013,
1002,
9530,
8873,
2290,
1027,
1002,
2023,
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... |
overtrue/wechat | src/Payment/Application.php | Application.scheme | public function scheme(string $productId): string
{
$params = [
'appid' => $this['config']->app_id,
'mch_id' => $this['config']->mch_id,
'time_stamp' => time(),
'nonce_str' => uniqid(),
'product_id' => $productId,
];
$params['sign'] = Support\generate_sign($params, $this['config']->key);
return 'weixin://wxpay/bizpayurl?'.http_build_query($params);
} | php | public function scheme(string $productId): string
{
$params = [
'appid' => $this['config']->app_id,
'mch_id' => $this['config']->mch_id,
'time_stamp' => time(),
'nonce_str' => uniqid(),
'product_id' => $productId,
];
$params['sign'] = Support\generate_sign($params, $this['config']->key);
return 'weixin://wxpay/bizpayurl?'.http_build_query($params);
} | [
"public",
"function",
"scheme",
"(",
"string",
"$",
"productId",
")",
":",
"string",
"{",
"$",
"params",
"=",
"[",
"'appid'",
"=>",
"$",
"this",
"[",
"'config'",
"]",
"->",
"app_id",
",",
"'mch_id'",
"=>",
"$",
"this",
"[",
"'config'",
"]",
"->",
"mc... | Build payment scheme for product.
@param string $productId
@return string | [
"Build",
"payment",
"scheme",
"for",
"product",
"."
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/Payment/Application.php#L79-L92 | train | Generate a URL to Bizpay. | [
30522,
2270,
3853,
5679,
1006,
5164,
1002,
4031,
3593,
1007,
1024,
5164,
1063,
1002,
11498,
5244,
1027,
1031,
1005,
10439,
3593,
1005,
1027,
1028,
1002,
2023,
1031,
1005,
9530,
8873,
2290,
1005,
1033,
1011,
1028,
10439,
1035,
8909,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/DataAccess/LogAggregator.php | LogAggregator.queryEcommerceItems | public function queryEcommerceItems($dimension)
{
$query = $this->generateQuery(
// SELECT ...
implode(
', ',
array(
"log_action.name AS label",
sprintf("log_conversion_item.%s AS labelIdAction", $dimension),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.quantity * log_conversion_item.price)'),
Metrics::INDEX_ECOMMERCE_ITEM_REVENUE
),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.quantity)'),
Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY
),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.price)'),
Metrics::INDEX_ECOMMERCE_ITEM_PRICE
),
sprintf(
'COUNT(distinct log_conversion_item.idorder) AS `%d`',
Metrics::INDEX_ECOMMERCE_ORDERS
),
sprintf(
'COUNT(distinct log_conversion_item.idvisit) AS `%d`',
Metrics::INDEX_NB_VISITS
),
sprintf(
'CASE log_conversion_item.idorder WHEN \'0\' THEN %d ELSE %d END AS ecommerceType',
GoalManager::IDGOAL_CART,
GoalManager::IDGOAL_ORDER
)
)
),
// FROM ...
array(
"log_conversion_item",
array(
"table" => "log_action",
"joinOn" => sprintf("log_conversion_item.%s = log_action.idaction", $dimension)
)
),
// WHERE ... AND ...
implode(
' AND ',
array(
'log_conversion_item.server_time >= ?',
'log_conversion_item.server_time <= ?',
'log_conversion_item.idsite IN (' . Common::getSqlStringFieldsArray($this->sites) . ')',
'log_conversion_item.deleted = 0'
)
),
// GROUP BY ...
sprintf(
"ecommerceType, log_conversion_item.%s",
$dimension
),
// ORDER ...
false
);
return $this->getDb()->query($query['sql'], $query['bind']);
} | php | public function queryEcommerceItems($dimension)
{
$query = $this->generateQuery(
// SELECT ...
implode(
', ',
array(
"log_action.name AS label",
sprintf("log_conversion_item.%s AS labelIdAction", $dimension),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.quantity * log_conversion_item.price)'),
Metrics::INDEX_ECOMMERCE_ITEM_REVENUE
),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.quantity)'),
Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY
),
sprintf(
'%s AS `%d`',
self::getSqlRevenue('SUM(log_conversion_item.price)'),
Metrics::INDEX_ECOMMERCE_ITEM_PRICE
),
sprintf(
'COUNT(distinct log_conversion_item.idorder) AS `%d`',
Metrics::INDEX_ECOMMERCE_ORDERS
),
sprintf(
'COUNT(distinct log_conversion_item.idvisit) AS `%d`',
Metrics::INDEX_NB_VISITS
),
sprintf(
'CASE log_conversion_item.idorder WHEN \'0\' THEN %d ELSE %d END AS ecommerceType',
GoalManager::IDGOAL_CART,
GoalManager::IDGOAL_ORDER
)
)
),
// FROM ...
array(
"log_conversion_item",
array(
"table" => "log_action",
"joinOn" => sprintf("log_conversion_item.%s = log_action.idaction", $dimension)
)
),
// WHERE ... AND ...
implode(
' AND ',
array(
'log_conversion_item.server_time >= ?',
'log_conversion_item.server_time <= ?',
'log_conversion_item.idsite IN (' . Common::getSqlStringFieldsArray($this->sites) . ')',
'log_conversion_item.deleted = 0'
)
),
// GROUP BY ...
sprintf(
"ecommerceType, log_conversion_item.%s",
$dimension
),
// ORDER ...
false
);
return $this->getDb()->query($query['sql'], $query['bind']);
} | [
"public",
"function",
"queryEcommerceItems",
"(",
"$",
"dimension",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"generateQuery",
"(",
"// SELECT ...",
"implode",
"(",
"', '",
",",
"array",
"(",
"\"log_action.name AS label\"",
",",
"sprintf",
"(",
"\"log_conv... | Executes and returns a query aggregating ecommerce item data (everything stored in the
**log\_conversion\_item** table) and returns a DB statement that can be used to iterate over the result
<a name="queryEcommerceItems-result-set"></a>
**Result Set**
Each row of the result set represents an aggregated group of ecommerce items. The following
columns are in each row of the result set:
- **{@link Piwik\Metrics::INDEX_ECOMMERCE_ITEM_REVENUE}**: The total revenue for the group of items.
- **{@link Piwik\Metrics::INDEX_ECOMMERCE_ITEM_QUANTITY}**: The total number of items in this group.
- **{@link Piwik\Metrics::INDEX_ECOMMERCE_ITEM_PRICE}**: The total price for the group of items.
- **{@link Piwik\Metrics::INDEX_ECOMMERCE_ORDERS}**: The total number of orders this group of items
belongs to. This will be <= to the total number
of items in this group.
- **{@link Piwik\Metrics::INDEX_NB_VISITS}**: The total number of visits that caused these items to be logged.
- **ecommerceType**: Either {@link Piwik\Tracker\GoalManager::IDGOAL_CART} if the items in this group were
abandoned by a visitor, or {@link Piwik\Tracker\GoalManager::IDGOAL_ORDER} if they
were ordered by a visitor.
**Limitations**
Segmentation is not yet supported for this aggregation method.
@param string $dimension One or more **log\_conversion\_item** columns to group aggregated data by.
Eg, `'idaction_sku'` or `'idaction_sku, idaction_category'`.
@return \Zend_Db_Statement A statement object that can be used to iterate through the query's
result set. See [above](#queryEcommerceItems-result-set) to learn more
about what this query selects.
@api | [
"Executes",
"and",
"returns",
"a",
"query",
"aggregating",
"ecommerce",
"item",
"data",
"(",
"everything",
"stored",
"in",
"the",
"**",
"log",
"\\",
"_conversion",
"\\",
"_item",
"**",
"table",
")",
"and",
"returns",
"a",
"DB",
"statement",
"that",
"can",
... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/core/DataAccess/LogAggregator.php#L568-L639 | train | Returns the query for ecommerce items | [
30522,
2270,
3853,
23032,
8586,
5358,
5017,
3401,
4221,
5244,
1006,
1002,
9812,
1007,
1063,
1002,
23032,
1027,
1002,
2023,
1011,
1028,
9699,
4226,
2854,
1006,
1013,
1013,
7276,
1012,
1012,
1012,
17727,
4135,
3207,
1006,
1005,
1010,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/CoreAdminHome/Controller.php | Controller.trackingCodeGenerator | public function trackingCodeGenerator()
{
Piwik::checkUserHasSomeViewAccess();
$view = new View('@CoreAdminHome/trackingCodeGenerator');
$this->setBasicVariablesView($view);
$view->topMenu = MenuTop::getInstance()->getMenu();
$viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = $this->idSite ?: $defaultIdSite;
if ($view->idSite) {
try {
$view->siteName = Site::getNameFor($view->idSite);
} catch (Exception $e) {
// ignore if site no longer exists
}
}
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = Site::getCurrencySymbolFor($view->idSite);
$view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
$view->defaultSite = array('id' => $view->idSite, 'name' => $view->defaultReportSiteName);
$allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
$aliasUrl = 'x.domain.com';
}
$view->defaultReportSiteAlias = $aliasUrl;
$mainUrl = Site::getMainUrlFor($view->idSite);
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
$dntChecker = new DoNotTrackHeaderChecker();
$view->serverSideDoNotTrackEnabled = $dntChecker->isActive();
return $view->render();
} | php | public function trackingCodeGenerator()
{
Piwik::checkUserHasSomeViewAccess();
$view = new View('@CoreAdminHome/trackingCodeGenerator');
$this->setBasicVariablesView($view);
$view->topMenu = MenuTop::getInstance()->getMenu();
$viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
$defaultIdSite = reset($viewableIdSites);
$view->idSite = $this->idSite ?: $defaultIdSite;
if ($view->idSite) {
try {
$view->siteName = Site::getNameFor($view->idSite);
} catch (Exception $e) {
// ignore if site no longer exists
}
}
$view->defaultReportSiteName = Site::getNameFor($view->idSite);
$view->defaultSiteRevenue = Site::getCurrencySymbolFor($view->idSite);
$view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
$view->defaultSite = array('id' => $view->idSite, 'name' => $view->defaultReportSiteName);
$allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
if (isset($allUrls[1])) {
$aliasUrl = $allUrls[1];
} else {
$aliasUrl = 'x.domain.com';
}
$view->defaultReportSiteAlias = $aliasUrl;
$mainUrl = Site::getMainUrlFor($view->idSite);
$view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
$dntChecker = new DoNotTrackHeaderChecker();
$view->serverSideDoNotTrackEnabled = $dntChecker->isActive();
return $view->render();
} | [
"public",
"function",
"trackingCodeGenerator",
"(",
")",
"{",
"Piwik",
"::",
"checkUserHasSomeViewAccess",
"(",
")",
";",
"$",
"view",
"=",
"new",
"View",
"(",
"'@CoreAdminHome/trackingCodeGenerator'",
")",
";",
"$",
"this",
"->",
"setBasicVariablesView",
"(",
"$"... | Renders and echo's an admin page that lets users generate custom JavaScript
tracking code and custom image tracker links. | [
"Renders",
"and",
"echo",
"s",
"an",
"admin",
"page",
"that",
"lets",
"users",
"generate",
"custom",
"JavaScript",
"tracking",
"code",
"and",
"custom",
"image",
"tracker",
"links",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/CoreAdminHome/Controller.php#L173-L215 | train | Returns the tracking code generator | [
30522,
2270,
3853,
9651,
16044,
6914,
6906,
4263,
1006,
1007,
1063,
14255,
9148,
2243,
1024,
1024,
4638,
20330,
14949,
14045,
8584,
6305,
9623,
2015,
1006,
1007,
1025,
1002,
3193,
1027,
2047,
3193,
1006,
1005,
1030,
4563,
4215,
10020,
23393... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php | AbstractPhpFileCacheWarmer.warmUp | public function warmUp($cacheDir)
{
$arrayAdapter = new ArrayAdapter();
spl_autoload_register([PhpArrayAdapter::class, 'throwOnRequiredClass']);
try {
if (!$this->doWarmUp($cacheDir, $arrayAdapter)) {
return;
}
} finally {
spl_autoload_unregister([PhpArrayAdapter::class, 'throwOnRequiredClass']);
}
// the ArrayAdapter stores the values serialized
// to avoid mutation of the data after it was written to the cache
// so here we un-serialize the values first
$values = array_map(function ($val) { return null !== $val ? unserialize($val) : null; }, $arrayAdapter->getValues());
$this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, new NullAdapter()), $values);
} | php | public function warmUp($cacheDir)
{
$arrayAdapter = new ArrayAdapter();
spl_autoload_register([PhpArrayAdapter::class, 'throwOnRequiredClass']);
try {
if (!$this->doWarmUp($cacheDir, $arrayAdapter)) {
return;
}
} finally {
spl_autoload_unregister([PhpArrayAdapter::class, 'throwOnRequiredClass']);
}
// the ArrayAdapter stores the values serialized
// to avoid mutation of the data after it was written to the cache
// so here we un-serialize the values first
$values = array_map(function ($val) { return null !== $val ? unserialize($val) : null; }, $arrayAdapter->getValues());
$this->warmUpPhpArrayAdapter(new PhpArrayAdapter($this->phpArrayFile, new NullAdapter()), $values);
} | [
"public",
"function",
"warmUp",
"(",
"$",
"cacheDir",
")",
"{",
"$",
"arrayAdapter",
"=",
"new",
"ArrayAdapter",
"(",
")",
";",
"spl_autoload_register",
"(",
"[",
"PhpArrayAdapter",
"::",
"class",
",",
"'throwOnRequiredClass'",
"]",
")",
";",
"try",
"{",
"if... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php#L45-L64 | train | Warms up the array adapter | [
30522,
2270,
3853,
4010,
6279,
1006,
1002,
17053,
4305,
2099,
1007,
1063,
1002,
9140,
8447,
13876,
2121,
1027,
2047,
9140,
8447,
13876,
2121,
1006,
1007,
1025,
11867,
2140,
1035,
8285,
11066,
1035,
4236,
1006,
1031,
25718,
2906,
29539,
2850... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Mime.php | Zend_Mime._encodeQuotedPrintable | private static function _encodeQuotedPrintable($str)
{
$str = str_replace('=', '=3D', $str);
$str = str_replace(self::$qpKeys, self::$qpReplaceValues, $str);
$str = rtrim($str);
return $str;
} | php | private static function _encodeQuotedPrintable($str)
{
$str = str_replace('=', '=3D', $str);
$str = str_replace(self::$qpKeys, self::$qpReplaceValues, $str);
$str = rtrim($str);
return $str;
} | [
"private",
"static",
"function",
"_encodeQuotedPrintable",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"'='",
",",
"'=3D'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"qpKeys",
",",
"self",
... | Converts a string into quoted printable format.
@param string $str
@return string | [
"Converts",
"a",
"string",
"into",
"quoted",
"printable",
"format",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mime.php#L166-L172 | train | Encode a string with quoted - printable values. | [
30522,
2797,
10763,
3853,
1035,
4372,
16044,
28940,
27428,
16550,
3085,
1006,
1002,
2358,
2099,
1007,
1063,
1002,
2358,
2099,
1027,
2358,
2099,
1035,
5672,
1006,
1005,
1027,
1005,
1010,
1005,
1027,
7605,
1005,
1010,
1002,
2358,
2099,
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... |
dompdf/dompdf | src/Css/Stylesheet.php | Stylesheet._selector_an_plus_b | protected function _selector_an_plus_b($expr, $last = false)
{
$expr = preg_replace("/\s/", "", $expr);
if (!preg_match("/^(?P<a>-?[0-9]*)?n(?P<b>[-+]?[0-9]+)?$/", $expr, $matches)) {
return "false()";
}
$a = ((isset($matches["a"]) && $matches["a"] !== "") ? intval($matches["a"]) : 1);
$b = ((isset($matches["b"]) && $matches["b"] !== "") ? intval($matches["b"]) : 0);
$position = ($last ? "(last()-position()+1)" : "position()");
if ($b == 0) {
return "($position mod $a) = 0";
} else {
$compare = (($a < 0) ? "<=" : ">=");
$b2 = -$b;
if ($b2 >= 0) {
$b2 = "+$b2";
}
return "($position $compare $b) and ((($position $b2) mod " . abs($a) . ") = 0)";
}
} | php | protected function _selector_an_plus_b($expr, $last = false)
{
$expr = preg_replace("/\s/", "", $expr);
if (!preg_match("/^(?P<a>-?[0-9]*)?n(?P<b>[-+]?[0-9]+)?$/", $expr, $matches)) {
return "false()";
}
$a = ((isset($matches["a"]) && $matches["a"] !== "") ? intval($matches["a"]) : 1);
$b = ((isset($matches["b"]) && $matches["b"] !== "") ? intval($matches["b"]) : 0);
$position = ($last ? "(last()-position()+1)" : "position()");
if ($b == 0) {
return "($position mod $a) = 0";
} else {
$compare = (($a < 0) ? "<=" : ">=");
$b2 = -$b;
if ($b2 >= 0) {
$b2 = "+$b2";
}
return "($position $compare $b) and ((($position $b2) mod " . abs($a) . ") = 0)";
}
} | [
"protected",
"function",
"_selector_an_plus_b",
"(",
"$",
"expr",
",",
"$",
"last",
"=",
"false",
")",
"{",
"$",
"expr",
"=",
"preg_replace",
"(",
"\"/\\s/\"",
",",
"\"\"",
",",
"$",
"expr",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"/^(?P<a>-?[0-9]... | https://github.com/tenderlove/nokogiri/blob/master/lib/nokogiri/css/xpath_visitor.rb
@param $expr
@param bool $last
@return string | [
"https",
":",
"//",
"github",
".",
"com",
"/",
"tenderlove",
"/",
"nokogiri",
"/",
"blob",
"/",
"master",
"/",
"lib",
"/",
"nokogiri",
"/",
"css",
"/",
"xpath_visitor",
".",
"rb"
] | 75f13c700009be21a1965dc2c5b68a8708c22ba2 | https://github.com/dompdf/dompdf/blob/75f13c700009be21a1965dc2c5b68a8708c22ba2/src/Css/Stylesheet.php#L902-L924 | train | Returns the selector for an + b | [
30522,
5123,
3853,
1035,
27000,
1035,
2019,
1035,
4606,
1035,
1038,
1006,
1002,
4654,
18098,
1010,
1002,
2197,
1027,
6270,
1007,
1063,
1002,
4654,
18098,
1027,
3653,
2290,
1035,
5672,
1006,
1000,
1013,
1032,
1055,
1013,
1000,
1010,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Redis/Connections/PhpRedisConnection.php | PhpRedisConnection.subscribe | public function subscribe($channels, Closure $callback)
{
$this->client->subscribe((array) $channels, function ($redis, $channel, $message) use ($callback) {
$callback($message, $channel);
});
} | php | public function subscribe($channels, Closure $callback)
{
$this->client->subscribe((array) $channels, function ($redis, $channel, $message) use ($callback) {
$callback($message, $channel);
});
} | [
"public",
"function",
"subscribe",
"(",
"$",
"channels",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"client",
"->",
"subscribe",
"(",
"(",
"array",
")",
"$",
"channels",
",",
"function",
"(",
"$",
"redis",
",",
"$",
"channel",
",",
... | Subscribe to a set of given channels for messages.
@param array|string $channels
@param \Closure $callback
@return void | [
"Subscribe",
"to",
"a",
"set",
"of",
"given",
"channels",
"for",
"messages",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Redis/Connections/PhpRedisConnection.php#L357-L362 | train | Subscribe to a list of channels | [
30522,
2270,
3853,
4942,
29234,
1006,
1002,
6833,
1010,
8503,
1002,
2655,
5963,
1007,
1063,
1002,
2023,
1011,
1028,
7396,
1011,
1028,
4942,
29234,
1006,
1006,
9140,
1007,
1002,
6833,
1010,
3853,
1006,
1002,
2417,
2483,
1010,
1002,
3149,
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... |
symfony/symfony | src/Symfony/Component/Debug/ErrorHandler.php | ErrorHandler.throwAt | public function throwAt($levels, $replace = false)
{
$prev = $this->thrownErrors;
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
if (!$replace) {
$this->thrownErrors |= $prev;
}
$this->reRegister($prev | $this->loggedErrors);
return $prev;
} | php | public function throwAt($levels, $replace = false)
{
$prev = $this->thrownErrors;
$this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
if (!$replace) {
$this->thrownErrors |= $prev;
}
$this->reRegister($prev | $this->loggedErrors);
return $prev;
} | [
"public",
"function",
"throwAt",
"(",
"$",
"levels",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"prev",
"=",
"$",
"this",
"->",
"thrownErrors",
";",
"$",
"this",
"->",
"thrownErrors",
"=",
"(",
"$",
"levels",
"|",
"E_RECOVERABLE_ERROR",
"|",
"E_... | Sets the PHP error levels that throw an exception when a PHP error occurs.
@param int $levels A bit field of E_* constants for thrown errors
@param bool $replace Replace or amend the previous value
@return int The previous value | [
"Sets",
"the",
"PHP",
"error",
"levels",
"that",
"throw",
"an",
"exception",
"when",
"a",
"PHP",
"error",
"occurs",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Debug/ErrorHandler.php#L280-L290 | train | Throw all errors at the specified levels | [
30522,
2270,
3853,
5466,
4017,
1006,
1002,
3798,
1010,
1002,
5672,
1027,
6270,
1007,
1063,
1002,
3653,
2615,
1027,
1002,
2023,
1011,
1028,
6908,
2121,
29165,
2015,
1025,
1002,
2023,
1011,
1028,
6908,
2121,
29165,
2015,
1027,
1006,
1002,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Translator.php | Translator.addResource | public function addResource($format, $resource, $locale, $domain = null)
{
if (null === $domain) {
$domain = 'messages';
}
$this->assertValidLocale($locale);
$this->resources[$locale][] = [$format, $resource, $domain];
if (\in_array($locale, $this->fallbackLocales)) {
$this->catalogues = [];
} else {
unset($this->catalogues[$locale]);
}
} | php | public function addResource($format, $resource, $locale, $domain = null)
{
if (null === $domain) {
$domain = 'messages';
}
$this->assertValidLocale($locale);
$this->resources[$locale][] = [$format, $resource, $domain];
if (\in_array($locale, $this->fallbackLocales)) {
$this->catalogues = [];
} else {
unset($this->catalogues[$locale]);
}
} | [
"public",
"function",
"addResource",
"(",
"$",
"format",
",",
"$",
"resource",
",",
"$",
"locale",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"domain",
")",
"{",
"$",
"domain",
"=",
"'messages'",
";",
"}",
"$",
"this"... | Adds a Resource.
@param string $format The name of the loader (@see addLoader())
@param mixed $resource The resource name
@param string $locale The locale
@param string $domain The domain
@throws InvalidArgumentException If the locale contains invalid characters | [
"Adds",
"a",
"Resource",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Translation/Translator.php#L129-L144 | train | Adds a resource to the list of resources | [
30522,
2270,
3853,
5587,
6072,
8162,
3401,
1006,
1002,
4289,
1010,
1002,
7692,
1010,
1002,
2334,
2063,
1010,
1002,
5884,
1027,
19701,
1007,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
5884,
1007,
1063,
1002,
5884,
1027,
1005,
7696,
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... |
symfony/symfony | src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php | SessionHandlerProxy.updateTimestamp | public function updateTimestamp($sessionId, $data)
{
return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data);
} | php | public function updateTimestamp($sessionId, $data)
{
return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data);
} | [
"public",
"function",
"updateTimestamp",
"(",
"$",
"sessionId",
",",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"handler",
"instanceof",
"\\",
"SessionUpdateTimestampHandlerInterface",
"?",
"$",
"this",
"->",
"handler",
"->",
"updateTimestamp",
"(",
"$"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php#L97-L100 | train | Update the timestamp of the session | [
30522,
2270,
3853,
10651,
7292,
9153,
8737,
1006,
1002,
5219,
3593,
1010,
1002,
2951,
1007,
1063,
2709,
1002,
2023,
1011,
1028,
28213,
6013,
11253,
1032,
5219,
6279,
13701,
7292,
9153,
8737,
11774,
3917,
18447,
2121,
12172,
1029,
1002,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Foundation/Console/VendorPublishCommand.php | VendorPublishCommand.createParentDirectory | protected function createParentDirectory($directory)
{
if (! $this->files->isDirectory($directory)) {
$this->files->makeDirectory($directory, 0755, true);
}
} | php | protected function createParentDirectory($directory)
{
if (! $this->files->isDirectory($directory)) {
$this->files->makeDirectory($directory, 0755, true);
}
} | [
"protected",
"function",
"createParentDirectory",
"(",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"isDirectory",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"makeDirectory",
"(",
"$",
"direct... | Create the directory to house the published files if needed.
@param string $directory
@return void | [
"Create",
"the",
"directory",
"to",
"house",
"the",
"published",
"files",
"if",
"needed",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Foundation/Console/VendorPublishCommand.php#L252-L257 | train | Create parent directory if not exists | [
30522,
5123,
3853,
3443,
19362,
4765,
4305,
2890,
16761,
2100,
1006,
1002,
14176,
1007,
1063,
2065,
1006,
999,
1002,
2023,
1011,
1028,
6764,
1011,
1028,
2003,
4305,
2890,
16761,
2100,
1006,
1002,
14176,
1007,
1007,
1063,
1002,
2023,
1011,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/OpenWork/Application.php | Application.work | public function work(string $authCorpId, string $permanentCode): Work
{
return new Work($authCorpId, $permanentCode, $this);
} | php | public function work(string $authCorpId, string $permanentCode): Work
{
return new Work($authCorpId, $permanentCode, $this);
} | [
"public",
"function",
"work",
"(",
"string",
"$",
"authCorpId",
",",
"string",
"$",
"permanentCode",
")",
":",
"Work",
"{",
"return",
"new",
"Work",
"(",
"$",
"authCorpId",
",",
"$",
"permanentCode",
",",
"$",
"this",
")",
";",
"}"
] | @param string $authCorpId 企业 corp_id
@param string $permanentCode 企业永久授权码
@return Work | [
"@param",
"string",
"$authCorpId",
"企业",
"corp_id",
"@param",
"string",
"$permanentCode",
"企业永久授权码"
] | 120c72faaa93c270365bc75c73c362d5fd583209 | https://github.com/overtrue/wechat/blob/120c72faaa93c270365bc75c73c362d5fd583209/src/OpenWork/Application.php#L55-L58 | train | Work the page | [
30522,
2270,
3853,
2147,
1006,
5164,
1002,
8740,
2705,
24586,
3593,
1010,
5164,
1002,
4568,
16044,
1007,
1024,
2147,
1063,
2709,
2047,
2147,
1006,
1002,
8740,
2705,
24586,
3593,
1010,
1002,
4568,
16044,
1010,
1002,
2023,
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... |
getgrav/grav | system/src/Grav/Framework/Flex/Storage/SimpleStorage.php | SimpleStorage.buildIndex | protected function buildIndex(): array
{
$file = $this->getFile($this->getStoragePath());
$modified = $file->modified();
$this->data = (array) $file->content();
$list = [];
foreach ($this->data as $key => $info) {
$list[$key] = [
'storage_key' => $key,
'storage_timestamp' => $modified
];
}
return $list;
} | php | protected function buildIndex(): array
{
$file = $this->getFile($this->getStoragePath());
$modified = $file->modified();
$this->data = (array) $file->content();
$list = [];
foreach ($this->data as $key => $info) {
$list[$key] = [
'storage_key' => $key,
'storage_timestamp' => $modified
];
}
return $list;
} | [
"protected",
"function",
"buildIndex",
"(",
")",
":",
"array",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getFile",
"(",
"$",
"this",
"->",
"getStoragePath",
"(",
")",
")",
";",
"$",
"modified",
"=",
"$",
"file",
"->",
"modified",
"(",
")",
";",
"$... | Returns list of all stored keys in [key => timestamp] pairs.
@return array | [
"Returns",
"list",
"of",
"all",
"stored",
"keys",
"in",
"[",
"key",
"=",
">",
"timestamp",
"]",
"pairs",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/Storage/SimpleStorage.php#L284-L300 | train | Build the index array | [
30522,
5123,
3853,
3857,
22254,
10288,
1006,
1007,
1024,
9140,
1063,
1002,
5371,
1027,
1002,
2023,
1011,
1028,
2131,
8873,
2571,
1006,
1002,
2023,
1011,
1028,
4152,
4263,
4270,
15069,
1006,
1007,
1007,
1025,
1002,
6310,
1027,
1002,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Form.php | Form.getPropertyPath | public function getPropertyPath()
{
if ($this->propertyPath || $this->propertyPath = $this->config->getPropertyPath()) {
return $this->propertyPath;
}
if (null === $this->name || '' === $this->name) {
return null;
}
$parent = $this->parent;
while ($parent && $parent->getConfig()->getInheritData()) {
$parent = $parent->getParent();
}
if ($parent && null === $parent->getConfig()->getDataClass()) {
$this->propertyPath = new PropertyPath('['.$this->name.']');
} else {
$this->propertyPath = new PropertyPath($this->name);
}
return $this->propertyPath;
} | php | public function getPropertyPath()
{
if ($this->propertyPath || $this->propertyPath = $this->config->getPropertyPath()) {
return $this->propertyPath;
}
if (null === $this->name || '' === $this->name) {
return null;
}
$parent = $this->parent;
while ($parent && $parent->getConfig()->getInheritData()) {
$parent = $parent->getParent();
}
if ($parent && null === $parent->getConfig()->getDataClass()) {
$this->propertyPath = new PropertyPath('['.$this->name.']');
} else {
$this->propertyPath = new PropertyPath($this->name);
}
return $this->propertyPath;
} | [
"public",
"function",
"getPropertyPath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"propertyPath",
"||",
"$",
"this",
"->",
"propertyPath",
"=",
"$",
"this",
"->",
"config",
"->",
"getPropertyPath",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"... | {@inheritdoc} | [
"{"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Form/Form.php#L214-L237 | train | Get PropertyPath. | [
30522,
2270,
3853,
2131,
21572,
4842,
3723,
15069,
1006,
1007,
1063,
2065,
1006,
1002,
2023,
1011,
1028,
3200,
15069,
1064,
1064,
1002,
2023,
1011,
1028,
3200,
15069,
1027,
1002,
2023,
1011,
1028,
9530,
8873,
2290,
1011,
1028,
2131,
21572,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Routing/Matcher/Dumper/StaticPrefixCollection.php | StaticPrefixCollection.populateCollection | public function populateCollection(RouteCollection $routes): RouteCollection
{
foreach ($this->items as $route) {
if ($route instanceof self) {
$route->populateCollection($routes);
} else {
$routes->add(...$route);
}
}
return $routes;
} | php | public function populateCollection(RouteCollection $routes): RouteCollection
{
foreach ($this->items as $route) {
if ($route instanceof self) {
$route->populateCollection($routes);
} else {
$routes->add(...$route);
}
}
return $routes;
} | [
"public",
"function",
"populateCollection",
"(",
"RouteCollection",
"$",
"routes",
")",
":",
"RouteCollection",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"instanceof",
"self",
")",
"{",
"$",
"... | Linearizes back a set of nested routes into a collection. | [
"Linearizes",
"back",
"a",
"set",
"of",
"nested",
"routes",
"into",
"a",
"collection",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Routing/Matcher/Dumper/StaticPrefixCollection.php#L129-L140 | train | Populates RouteCollection with Route objects | [
30522,
2270,
3853,
3769,
9869,
26895,
18491,
1006,
2799,
26895,
18491,
1002,
5847,
1007,
1024,
2799,
26895,
30524,
1011,
1028,
5167,
2004,
1002,
2799,
1007,
1063,
2065,
1006,
1002,
2799,
6013,
11253,
2969,
1007,
1063,
1002,
2799,
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 | plugins/Insights/API.php | API.getInsights | public function getInsights(
$idSite, $period, $date, $reportUniqueId, $segment = false, $limitIncreaser = 5, $limitDecreaser = 5,
$filterBy = '', $minImpactPercent = 2, $minGrowthPercent = 20,
$comparedToXPeriods = 1, $orderBy = 'absolute')
{
Piwik::checkUserHasViewAccess(array($idSite));
$metric = 'nb_visits';
$reportMetadata = $this->model->getReportByUniqueId($idSite, $reportUniqueId);
if (empty($reportMetadata)) {
throw new \Exception('A report having the ID ' . $reportUniqueId . ' does not exist');
}
$totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric, $segment);
$currentReport = $this->model->requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($currentReport);
$lastDate = $this->model->getLastDate($date, $period, $comparedToXPeriods);
$lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric, $segment);
$lastReport = $this->model->requestReport($idSite, $period, $lastDate, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($lastReport);
$minGrowthPercentPositive = abs($minGrowthPercent);
$minGrowthPercentNegative = -1 * $minGrowthPercentPositive;
$relevantTotal = $this->model->getRelevantTotalValue($currentReport, $metric, $totalValue);
$minMoversPercent = -1;
$minNewPercent = -1;
$minDisappearedPercent = -1;
switch ($filterBy) {
case self::FILTER_BY_MOVERS:
$minMoversPercent = $minImpactPercent;
break;
case self::FILTER_BY_NEW:
$minNewPercent = $minImpactPercent;
break;
case self::FILTER_BY_DISAPPEARED:
$minDisappearedPercent = $minImpactPercent;
break;
default:
$minMoversPercent = $minImpactPercent;
$minNewPercent = $minImpactPercent;
$minDisappearedPercent = $minImpactPercent;
}
$insight = new InsightReport();
$table = $insight->generateInsight($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $relevantTotal, $minMoversPercent, $minNewPercent, $minDisappearedPercent, $minGrowthPercentPositive, $minGrowthPercentNegative, $orderBy, $limitIncreaser, $limitDecreaser);
$insight->markMoversAndShakers($table, $currentReport, $lastReport, $totalValue, $lastTotalValue);
return $table;
} | php | public function getInsights(
$idSite, $period, $date, $reportUniqueId, $segment = false, $limitIncreaser = 5, $limitDecreaser = 5,
$filterBy = '', $minImpactPercent = 2, $minGrowthPercent = 20,
$comparedToXPeriods = 1, $orderBy = 'absolute')
{
Piwik::checkUserHasViewAccess(array($idSite));
$metric = 'nb_visits';
$reportMetadata = $this->model->getReportByUniqueId($idSite, $reportUniqueId);
if (empty($reportMetadata)) {
throw new \Exception('A report having the ID ' . $reportUniqueId . ' does not exist');
}
$totalValue = $this->model->getTotalValue($idSite, $period, $date, $metric, $segment);
$currentReport = $this->model->requestReport($idSite, $period, $date, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($currentReport);
$lastDate = $this->model->getLastDate($date, $period, $comparedToXPeriods);
$lastTotalValue = $this->model->getTotalValue($idSite, $period, $lastDate, $metric, $segment);
$lastReport = $this->model->requestReport($idSite, $period, $lastDate, $reportUniqueId, $metric, $segment);
$this->checkReportIsValid($lastReport);
$minGrowthPercentPositive = abs($minGrowthPercent);
$minGrowthPercentNegative = -1 * $minGrowthPercentPositive;
$relevantTotal = $this->model->getRelevantTotalValue($currentReport, $metric, $totalValue);
$minMoversPercent = -1;
$minNewPercent = -1;
$minDisappearedPercent = -1;
switch ($filterBy) {
case self::FILTER_BY_MOVERS:
$minMoversPercent = $minImpactPercent;
break;
case self::FILTER_BY_NEW:
$minNewPercent = $minImpactPercent;
break;
case self::FILTER_BY_DISAPPEARED:
$minDisappearedPercent = $minImpactPercent;
break;
default:
$minMoversPercent = $minImpactPercent;
$minNewPercent = $minImpactPercent;
$minDisappearedPercent = $minImpactPercent;
}
$insight = new InsightReport();
$table = $insight->generateInsight($reportMetadata, $period, $date, $lastDate, $metric, $currentReport, $lastReport, $relevantTotal, $minMoversPercent, $minNewPercent, $minDisappearedPercent, $minGrowthPercentPositive, $minGrowthPercentNegative, $orderBy, $limitIncreaser, $limitDecreaser);
$insight->markMoversAndShakers($table, $currentReport, $lastReport, $totalValue, $lastTotalValue);
return $table;
} | [
"public",
"function",
"getInsights",
"(",
"$",
"idSite",
",",
"$",
"period",
",",
"$",
"date",
",",
"$",
"reportUniqueId",
",",
"$",
"segment",
"=",
"false",
",",
"$",
"limitIncreaser",
"=",
"5",
",",
"$",
"limitDecreaser",
"=",
"5",
",",
"$",
"filterB... | Generates insights by comparing the report for a given date/period with a different date and calculating the
difference. The API can exclude rows which growth is not good enough or did not have enough impact.
@param int $idSite
@param string $period
@param string $date
@param string $reportUniqueId eg 'Actions_getPageUrls'. An id like 'Goals_getVisitsUntilConversion_idGoal--4' works as well.
@param bool|string $segment
@param int $limitIncreaser Value '0' ignores all increasers
@param int $limitDecreaser Value '0' ignores all decreasers
@param string $filterBy By default all rows will be ignored. If given only 'movers', 'new' or 'disappeared' will be returned.
@param int $minImpactPercent The minimum impact in percent. Eg '2%' of 1000 visits means the change /
increase / decrease has to be at least 20 visits. Usually the '2%' are based on the total
amount of visits but for reports having way less visits the metric total is used. Eg A page
has 1000 visits but only 100 visits having keywords. In this case a minimum impact of '2%' evaluates to 2 and not 20.
@param int $minGrowthPercent The amount of percent a row has to increase or decrease at least compared to the previous period.
If value is '20' the growth has to be either at least '+20%' or '-20%' and lower.
@param int $comparedToXPeriods The report will be compared to X periods before.
@param string $orderBy Orders the rows by 'absolute', 'relative' or 'importance'.
@return DataTable
@throws \Exception In case a report having the given ID does not exist
@throws \Exception In case the report exists but does not return a dataTable | [
"Generates",
"insights",
"by",
"comparing",
"the",
"report",
"for",
"a",
"given",
"date",
"/",
"period",
"with",
"a",
"different",
"date",
"and",
"calculating",
"the",
"difference",
".",
"The",
"API",
"can",
"exclude",
"rows",
"which",
"growth",
"is",
"not",... | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/Insights/API.php#L254-L308 | train | Returns the list of all the insights for a report | [
30522,
2270,
3853,
2131,
7076,
18743,
2015,
1006,
1002,
8909,
28032,
2063,
1010,
1002,
2558,
1010,
1002,
3058,
1010,
1002,
3189,
19496,
4226,
3593,
1010,
1002,
6903,
1027,
6270,
1010,
1002,
5787,
2378,
16748,
11022,
2099,
1027,
1019,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/backend/classes/FormField.php | FormField.resolveModelAttribute | public function resolveModelAttribute($model, $attribute = null)
{
if ($attribute === null) {
$attribute = $this->valueFrom ?: $this->fieldName;
}
$parts = is_array($attribute) ? $attribute : HtmlHelper::nameToArray($attribute);
$last = array_pop($parts);
foreach ($parts as $part) {
$model = $model->{$part};
}
return [$model, $last];
} | php | public function resolveModelAttribute($model, $attribute = null)
{
if ($attribute === null) {
$attribute = $this->valueFrom ?: $this->fieldName;
}
$parts = is_array($attribute) ? $attribute : HtmlHelper::nameToArray($attribute);
$last = array_pop($parts);
foreach ($parts as $part) {
$model = $model->{$part};
}
return [$model, $last];
} | [
"public",
"function",
"resolveModelAttribute",
"(",
"$",
"model",
",",
"$",
"attribute",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"attribute",
"===",
"null",
")",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"valueFrom",
"?",
":",
"$",
"this",
"->",
... | Returns the final model and attribute name of a nested attribute. Eg:
list($model, $attribute) = $this->resolveAttribute('person[phone]');
@param string $attribute.
@return array | [
"Returns",
"the",
"final",
"model",
"and",
"attribute",
"name",
"of",
"a",
"nested",
"attribute",
".",
"Eg",
":"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/backend/classes/FormField.php#L653-L667 | train | Resolves the value of the attribute of the model | [
30522,
2270,
3853,
10663,
5302,
9247,
19321,
3089,
8569,
2618,
1006,
1002,
2944,
1010,
1002,
17961,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
17961,
1027,
1027,
1027,
19701,
1007,
1063,
1002,
17961,
1027,
1002,
2023,
1011,
1028,
3643,
1969... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/GeoIp2/LocationProvider/GeoIp2/Php.php | Php.getSupportedLocationInfo | public function getSupportedLocationInfo()
{
$result = array();
// country & continent info always available
$result[self::CONTINENT_CODE_KEY] = true;
$result[self::CONTINENT_NAME_KEY] = true;
$result[self::COUNTRY_CODE_KEY] = true;
$result[self::COUNTRY_NAME_KEY] = true;
$reader = $this->getGeoIpInstance($key = 'loc');
if ($reader) {
switch ($reader->metadata()->databaseType) {
case 'GeoIP2-Enterprise':
case 'GeoLite2-City':
case 'GeoIP2-City':
case 'GeoIP2-City-Africa':
case 'GeoIP2-City-Asia-Pacific':
case 'GeoIP2-City-Europe':
case 'GeoIP2-City-North-America':
case 'GeoIP2-City-South-America':
$result[self::REGION_CODE_KEY] = true;
$result[self::REGION_NAME_KEY] = true;
$result[self::CITY_NAME_KEY] = true;
$result[self::POSTAL_CODE_KEY] = true;
$result[self::LATITUDE_KEY] = true;
$result[self::LONGITUDE_KEY] = true;
break;
}
}
// check if isp info is available
if ($this->getGeoIpInstance($key = 'isp')) {
$result[self::ISP_KEY] = true;
$result[self::ORG_KEY] = true;
}
return $result;
} | php | public function getSupportedLocationInfo()
{
$result = array();
// country & continent info always available
$result[self::CONTINENT_CODE_KEY] = true;
$result[self::CONTINENT_NAME_KEY] = true;
$result[self::COUNTRY_CODE_KEY] = true;
$result[self::COUNTRY_NAME_KEY] = true;
$reader = $this->getGeoIpInstance($key = 'loc');
if ($reader) {
switch ($reader->metadata()->databaseType) {
case 'GeoIP2-Enterprise':
case 'GeoLite2-City':
case 'GeoIP2-City':
case 'GeoIP2-City-Africa':
case 'GeoIP2-City-Asia-Pacific':
case 'GeoIP2-City-Europe':
case 'GeoIP2-City-North-America':
case 'GeoIP2-City-South-America':
$result[self::REGION_CODE_KEY] = true;
$result[self::REGION_NAME_KEY] = true;
$result[self::CITY_NAME_KEY] = true;
$result[self::POSTAL_CODE_KEY] = true;
$result[self::LATITUDE_KEY] = true;
$result[self::LONGITUDE_KEY] = true;
break;
}
}
// check if isp info is available
if ($this->getGeoIpInstance($key = 'isp')) {
$result[self::ISP_KEY] = true;
$result[self::ORG_KEY] = true;
}
return $result;
} | [
"public",
"function",
"getSupportedLocationInfo",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// country & continent info always available",
"$",
"result",
"[",
"self",
"::",
"CONTINENT_CODE_KEY",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"self"... | Returns an array describing the types of location information this provider will
return.
The location info this provider supports depends on what GeoIP databases it can
find.
This provider will always support country & continent information.
If a region database is found, then region code & name information will be
supported.
If a city database is found, then region code, region name, city name,
area code, latitude, longitude & postal code are all supported.
If an ISP/organization database is found, ISP/organization information is supported.
@return array | [
"Returns",
"an",
"array",
"describing",
"the",
"types",
"of",
"location",
"information",
"this",
"provider",
"will",
"return",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/plugins/GeoIp2/LocationProvider/GeoIp2/Php.php#L221-L259 | train | Returns the list of location information available in the database | [
30522,
2270,
3853,
4152,
6279,
6442,
2098,
4135,
10719,
2378,
14876,
1006,
1007,
1063,
1002,
2765,
1027,
9140,
1006,
1007,
1025,
1013,
1013,
2406,
1004,
9983,
18558,
2467,
2800,
1002,
2765,
1031,
2969,
1024,
1024,
9983,
1035,
3642,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Auth/Access/Gate.php | Gate.callBeforeCallbacks | protected function callBeforeCallbacks($user, $ability, array $arguments)
{
foreach ($this->beforeCallbacks as $before) {
if (! $this->canBeCalledWithUser($user, $before)) {
continue;
}
if (! is_null($result = $before($user, $ability, $arguments))) {
return $result;
}
}
} | php | protected function callBeforeCallbacks($user, $ability, array $arguments)
{
foreach ($this->beforeCallbacks as $before) {
if (! $this->canBeCalledWithUser($user, $before)) {
continue;
}
if (! is_null($result = $before($user, $ability, $arguments))) {
return $result;
}
}
} | [
"protected",
"function",
"callBeforeCallbacks",
"(",
"$",
"user",
",",
"$",
"ability",
",",
"array",
"$",
"arguments",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"beforeCallbacks",
"as",
"$",
"before",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ca... | Call all of the before callbacks and return if a result is given.
@param \Illuminate\Contracts\Auth\Authenticatable|null $user
@param string $ability
@param array $arguments
@return bool|null | [
"Call",
"all",
"of",
"the",
"before",
"callbacks",
"and",
"return",
"if",
"a",
"result",
"is",
"given",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Auth/Access/Gate.php#L463-L474 | train | Call all the before callbacks | [
30522,
5123,
3853,
2655,
4783,
29278,
19281,
3363,
12221,
1006,
1002,
5310,
1010,
1002,
3754,
1010,
9140,
1002,
9918,
1007,
1063,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2077,
9289,
20850,
8684,
2015,
2004,
1002,
2077,
1007,
1063,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
octobercms/october | modules/system/ServiceProvider.php | ServiceProvider.registerBackendNavigation | protected function registerBackendNavigation()
{
BackendMenu::registerCallback(function ($manager) {
$manager->registerMenuItems('October.System', [
'system' => [
'label' => 'system::lang.settings.menu_label',
'icon' => 'icon-cog',
'iconSvg' => 'modules/system/assets/images/cog-icon.svg',
'url' => Backend::url('system/settings'),
'permissions' => [],
'order' => 1000
]
]);
});
/*
* Register the sidebar for the System main menu
*/
BackendMenu::registerContextSidenavPartial(
'October.System',
'system',
'~/modules/system/partials/_system_sidebar.htm'
);
/*
* Remove the October.System.system main menu item if there is no subpages to display
*/
Event::listen('backend.menu.extendItems', function ($manager) {
$systemSettingItems = SettingsManager::instance()->listItems('system');
$systemMenuItems = $manager->listSideMenuItems('October.System', 'system');
if (empty($systemSettingItems) && empty($systemMenuItems)) {
$manager->removeMainMenuItem('October.System', 'system');
}
}, -9999);
} | php | protected function registerBackendNavigation()
{
BackendMenu::registerCallback(function ($manager) {
$manager->registerMenuItems('October.System', [
'system' => [
'label' => 'system::lang.settings.menu_label',
'icon' => 'icon-cog',
'iconSvg' => 'modules/system/assets/images/cog-icon.svg',
'url' => Backend::url('system/settings'),
'permissions' => [],
'order' => 1000
]
]);
});
/*
* Register the sidebar for the System main menu
*/
BackendMenu::registerContextSidenavPartial(
'October.System',
'system',
'~/modules/system/partials/_system_sidebar.htm'
);
/*
* Remove the October.System.system main menu item if there is no subpages to display
*/
Event::listen('backend.menu.extendItems', function ($manager) {
$systemSettingItems = SettingsManager::instance()->listItems('system');
$systemMenuItems = $manager->listSideMenuItems('October.System', 'system');
if (empty($systemSettingItems) && empty($systemMenuItems)) {
$manager->removeMainMenuItem('October.System', 'system');
}
}, -9999);
} | [
"protected",
"function",
"registerBackendNavigation",
"(",
")",
"{",
"BackendMenu",
"::",
"registerCallback",
"(",
"function",
"(",
"$",
"manager",
")",
"{",
"$",
"manager",
"->",
"registerMenuItems",
"(",
"'October.System'",
",",
"[",
"'system'",
"=>",
"[",
"'l... | /*
Register navigation | [
"/",
"*",
"Register",
"navigation"
] | 3118660d834f161d513da08477be92281a2eb96a | https://github.com/octobercms/october/blob/3118660d834f161d513da08477be92281a2eb96a/modules/system/ServiceProvider.php#L341-L376 | train | Register the backend navigation | [
30522,
5123,
3853,
4236,
5963,
10497,
2532,
5737,
12540,
1006,
1007,
1063,
2067,
10497,
3549,
2226,
1024,
1024,
4236,
9289,
20850,
8684,
1006,
3853,
1006,
1002,
3208,
1007,
1063,
1002,
3208,
1011,
1028,
4236,
3549,
14663,
6633,
2015,
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/Validator/Validator/RecursiveContextualValidator.php | RecursiveContextualValidator.validateEachObjectIn | private function validateEachObjectIn($collection, $propertyPath, array $groups, ExecutionContextInterface $context)
{
foreach ($collection as $key => $value) {
if (\is_array($value)) {
// Also traverse nested arrays
$this->validateEachObjectIn(
$value,
$propertyPath.'['.$key.']',
$groups,
$context
);
continue;
}
// Scalar and null values in the collection are ignored
if (\is_object($value)) {
$this->validateObject(
$value,
$propertyPath.'['.$key.']',
$groups,
TraversalStrategy::IMPLICIT,
$context
);
}
}
} | php | private function validateEachObjectIn($collection, $propertyPath, array $groups, ExecutionContextInterface $context)
{
foreach ($collection as $key => $value) {
if (\is_array($value)) {
// Also traverse nested arrays
$this->validateEachObjectIn(
$value,
$propertyPath.'['.$key.']',
$groups,
$context
);
continue;
}
// Scalar and null values in the collection are ignored
if (\is_object($value)) {
$this->validateObject(
$value,
$propertyPath.'['.$key.']',
$groups,
TraversalStrategy::IMPLICIT,
$context
);
}
}
} | [
"private",
"function",
"validateEachObjectIn",
"(",
"$",
"collection",
",",
"$",
"propertyPath",
",",
"array",
"$",
"groups",
",",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"key",
"=>",
"$",
"value",
... | Validates each object in a collection against the constraints defined
for their classes.
Nested arrays are also iterated.
@param iterable $collection The collection
@param string $propertyPath The current property path
@param (string|GroupSequence)[] $groups The validated groups
@param ExecutionContextInterface $context The current execution context | [
"Validates",
"each",
"object",
"in",
"a",
"collection",
"against",
"the",
"constraints",
"defined",
"for",
"their",
"classes",
"."
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php#L363-L389 | train | Validate each object in the collection | [
30522,
2797,
3853,
9398,
3686,
5243,
9905,
2497,
20614,
2378,
1006,
1002,
3074,
1010,
1002,
3200,
15069,
1010,
9140,
1002,
2967,
1010,
7781,
8663,
18209,
18447,
2121,
12172,
1002,
6123,
1007,
1063,
18921,
6776,
1006,
1002,
3074,
2004,
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/Mail.php | Zend_Mail.addBcc | public function addBcc($email)
{
if (!is_array($email)) {
$email = array($email);
}
foreach ($email as $recipient) {
$this->_addRecipientAndHeader('Bcc', $recipient, '');
}
return $this;
} | php | public function addBcc($email)
{
if (!is_array($email)) {
$email = array($email);
}
foreach ($email as $recipient) {
$this->_addRecipientAndHeader('Bcc', $recipient, '');
}
return $this;
} | [
"public",
"function",
"addBcc",
"(",
"$",
"email",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"email",
")",
")",
"{",
"$",
"email",
"=",
"array",
"(",
"$",
"email",
")",
";",
"}",
"foreach",
"(",
"$",
"email",
"as",
"$",
"recipient",
")",
... | Adds Bcc recipient, $email can be an array, or a single string address
@param string|array $email
@return Zend_Mail Provides fluent interface | [
"Adds",
"Bcc",
"recipient",
"$email",
"can",
"be",
"an",
"array",
"or",
"a",
"single",
"string",
"address"
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Mail.php#L611-L622 | train | Adds Bcc recipients to the message | [
30522,
2270,
3853,
5587,
9818,
2278,
1006,
1002,
10373,
1007,
1063,
2065,
1006,
999,
2003,
1035,
9140,
1006,
1002,
10373,
1007,
1007,
1063,
1002,
10373,
1027,
9140,
1006,
1002,
10373,
1007,
1025,
1065,
18921,
6776,
1006,
1002,
10373,
2004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Form/Traits/FormTrait.php | FormTrait.getFlash | public function getFlash(): FormFlash
{
if (null === $this->flash) {
/** @var Grav $grav */
$grav = Grav::instance();
$id = null;
$user = $grav['user'] ?? null;
if (isset($user)) {
$rememberState = $this->getBlueprint()->get('form/remember_state');
if ($rememberState === 'user') {
$id = $user->username;
}
}
// Session Required for flash form
$session = $grav['session'] ?? null;
if (isset($session)) {
// By default store flash by the session id.
if (null === $id) {
$id = $session->getId();
}
$this->flash = new FormFlash($id, $this->getUniqueId(), $this->getName());
$this->flash->setUrl($grav['uri']->url)->setUser($user);
}
}
return $this->flash;
} | php | public function getFlash(): FormFlash
{
if (null === $this->flash) {
/** @var Grav $grav */
$grav = Grav::instance();
$id = null;
$user = $grav['user'] ?? null;
if (isset($user)) {
$rememberState = $this->getBlueprint()->get('form/remember_state');
if ($rememberState === 'user') {
$id = $user->username;
}
}
// Session Required for flash form
$session = $grav['session'] ?? null;
if (isset($session)) {
// By default store flash by the session id.
if (null === $id) {
$id = $session->getId();
}
$this->flash = new FormFlash($id, $this->getUniqueId(), $this->getName());
$this->flash->setUrl($grav['uri']->url)->setUser($user);
}
}
return $this->flash;
} | [
"public",
"function",
"getFlash",
"(",
")",
":",
"FormFlash",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"flash",
")",
"{",
"/** @var Grav $grav */",
"$",
"grav",
"=",
"Grav",
"::",
"instance",
"(",
")",
";",
"$",
"id",
"=",
"null",
";",
"$",
... | Get form flash object.
@return FormFlash | [
"Get",
"form",
"flash",
"object",
"."
] | 1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72 | https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/Traits/FormTrait.php#L336-L366 | train | Get FormFlash instance | [
30522,
2270,
3853,
2131,
10258,
11823,
1006,
1007,
1024,
2433,
10258,
11823,
1063,
2065,
1006,
19701,
1027,
1027,
1027,
1002,
2023,
1011,
1028,
5956,
1007,
1063,
1013,
1008,
1008,
1030,
13075,
24665,
11431,
1002,
24665,
11431,
1008,
1013,
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... |
symfony/symfony | src/Symfony/Component/Workflow/Registry.php | Registry.all | public function all($subject): array
{
$matched = [];
foreach ($this->workflows as list($workflow, $supportStrategy)) {
if ($supportStrategy->supports($workflow, $subject)) {
$matched[] = $workflow;
}
}
return $matched;
} | php | public function all($subject): array
{
$matched = [];
foreach ($this->workflows as list($workflow, $supportStrategy)) {
if ($supportStrategy->supports($workflow, $subject)) {
$matched[] = $workflow;
}
}
return $matched;
} | [
"public",
"function",
"all",
"(",
"$",
"subject",
")",
":",
"array",
"{",
"$",
"matched",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"workflows",
"as",
"list",
"(",
"$",
"workflow",
",",
"$",
"supportStrategy",
")",
")",
"{",
"if",
"(",... | @param object $subject
@return Workflow[] | [
"@param",
"object",
"$subject"
] | b82b09eefb084e487997f4af753400d721edd0a8 | https://github.com/symfony/symfony/blob/b82b09eefb084e487997f4af753400d721edd0a8/src/Symfony/Component/Workflow/Registry.php#L74-L84 | train | Returns all workflows that support the subject | [
30522,
2270,
3853,
2035,
1006,
1002,
3395,
1007,
1024,
9140,
1063,
1002,
10349,
1027,
1031,
1033,
1025,
18921,
6776,
1006,
1002,
2023,
1011,
1028,
2147,
12314,
2015,
2004,
2862,
1006,
1002,
2147,
12314,
1010,
1002,
6753,
6494,
2618,
6292,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/BuildsQueries.php | BuildsQueries.when | public function when($value, $callback, $default = null)
{
if ($value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {
return $default($this, $value) ?: $this;
}
return $this;
} | php | public function when($value, $callback, $default = null)
{
if ($value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {
return $default($this, $value) ?: $this;
}
return $this;
} | [
"public",
"function",
"when",
"(",
"$",
"value",
",",
"$",
"callback",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
")",
"{",
"return",
"$",
"callback",
"(",
"$",
"this",
",",
"$",
"value",
")",
"?",
":",
"$",
"this",
";... | Apply the callback's query changes if the given "value" is true.
@param mixed $value
@param callable $callback
@param callable $default
@return mixed|$this | [
"Apply",
"the",
"callback",
"s",
"query",
"changes",
"if",
"the",
"given",
"value",
"is",
"true",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Database/Concerns/BuildsQueries.php#L88-L97 | train | When - Callback - Callback | [
30522,
2270,
3853,
2043,
1006,
1002,
3643,
1010,
1002,
2655,
5963,
1010,
1002,
12398,
1027,
19701,
1007,
1063,
2065,
1006,
1002,
3643,
1007,
1063,
2709,
1002,
2655,
5963,
1006,
1002,
2023,
1010,
1002,
3643,
1007,
1029,
1024,
1002,
2023,
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... |
matomo-org/matomo | libs/Zend/Db/Table/Rowset/Abstract.php | Zend_Db_Table_Rowset_Abstract.setTable | public function setTable(Zend_Db_Table_Abstract $table)
{
$this->_table = $table;
$this->_connected = false;
// @todo This works only if we have iterated through
// the result set once to instantiate the rows.
foreach ($this as $row) {
$connected = $row->setTable($table);
if ($connected == true) {
$this->_connected = true;
}
}
return $this->_connected;
} | php | public function setTable(Zend_Db_Table_Abstract $table)
{
$this->_table = $table;
$this->_connected = false;
// @todo This works only if we have iterated through
// the result set once to instantiate the rows.
foreach ($this as $row) {
$connected = $row->setTable($table);
if ($connected == true) {
$this->_connected = true;
}
}
return $this->_connected;
} | [
"public",
"function",
"setTable",
"(",
"Zend_Db_Table_Abstract",
"$",
"table",
")",
"{",
"$",
"this",
"->",
"_table",
"=",
"$",
"table",
";",
"$",
"this",
"->",
"_connected",
"=",
"false",
";",
"// @todo This works only if we have iterated through",
"// the result s... | Set the table object, to re-establish a live connection
to the database for a Rowset that has been de-serialized.
@param Zend_Db_Table_Abstract $table
@return boolean
@throws Zend_Db_Table_Row_Exception | [
"Set",
"the",
"table",
"object",
"to",
"re",
"-",
"establish",
"a",
"live",
"connection",
"to",
"the",
"database",
"for",
"a",
"Rowset",
"that",
"has",
"been",
"de",
"-",
"serialized",
"."
] | 72df150735664275a60a7861e468c6ff3b152a14 | https://github.com/matomo-org/matomo/blob/72df150735664275a60a7861e468c6ff3b152a14/libs/Zend/Db/Table/Rowset/Abstract.php#L196-L209 | train | Set the table | [
30522,
2270,
3853,
2275,
10880,
1006,
16729,
2094,
1035,
16962,
1035,
2795,
1035,
10061,
1002,
2795,
1007,
1063,
1002,
2023,
1011,
1028,
1035,
2795,
1027,
1002,
2795,
1025,
1002,
2023,
1011,
1028,
1035,
4198,
1027,
6270,
1025,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Validation/Concerns/ValidatesAttributes.php | ValidatesAttributes.prepareUniqueId | protected function prepareUniqueId($id)
{
if (preg_match('/\[(.*)\]/', $id, $matches)) {
$id = $this->getValue($matches[1]);
}
if (strtolower($id) === 'null') {
$id = null;
}
if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
$id = (int) $id;
}
return $id;
} | php | protected function prepareUniqueId($id)
{
if (preg_match('/\[(.*)\]/', $id, $matches)) {
$id = $this->getValue($matches[1]);
}
if (strtolower($id) === 'null') {
$id = null;
}
if (filter_var($id, FILTER_VALIDATE_INT) !== false) {
$id = (int) $id;
}
return $id;
} | [
"protected",
"function",
"prepareUniqueId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\[(.*)\\]/'",
",",
"$",
"id",
",",
"$",
"matches",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"matches",
"[",
"1",
... | Prepare the given ID for querying.
@param mixed $id
@return int | [
"Prepare",
"the",
"given",
"ID",
"for",
"querying",
"."
] | 0e0a428a50fc8378e3f77d18f3caae76c19e8c7a | https://github.com/laravel/framework/blob/0e0a428a50fc8378e3f77d18f3caae76c19e8c7a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L755-L770 | train | Prepare Unique ID | [
30522,
5123,
3853,
7374,
19496,
4226,
3593,
1006,
1002,
8909,
1007,
1063,
2065,
1006,
3653,
2290,
1035,
2674,
1006,
1005,
1013,
1032,
1031,
1006,
1012,
1008,
1007,
1032,
1033,
1013,
1005,
1010,
1002,
8909,
1010,
1002,
3503,
1007,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
guzzle/guzzle | src/Middleware.php | Middleware.tap | public static function tap(callable $before = null, callable $after = null)
{
return function (callable $handler) use ($before, $after) {
return function ($request, array $options) use ($handler, $before, $after) {
if ($before) {
$before($request, $options);
}
$response = $handler($request, $options);
if ($after) {
$after($request, $options, $response);
}
return $response;
};
};
} | php | public static function tap(callable $before = null, callable $after = null)
{
return function (callable $handler) use ($before, $after) {
return function ($request, array $options) use ($handler, $before, $after) {
if ($before) {
$before($request, $options);
}
$response = $handler($request, $options);
if ($after) {
$after($request, $options, $response);
}
return $response;
};
};
} | [
"public",
"static",
"function",
"tap",
"(",
"callable",
"$",
"before",
"=",
"null",
",",
"callable",
"$",
"after",
"=",
"null",
")",
"{",
"return",
"function",
"(",
"callable",
"$",
"handler",
")",
"use",
"(",
"$",
"before",
",",
"$",
"after",
")",
"... | Middleware that invokes a callback before and after sending a request.
The provided listener cannot modify or alter the response. It simply
"taps" into the chain to be notified before returning the promise. The
before listener accepts a request and options array, and the after
listener accepts a request, options array, and response promise.
@param callable $before Function to invoke before forwarding the request.
@param callable $after Function invoked after forwarding.
@return callable Returns a function that accepts the next handler. | [
"Middleware",
"that",
"invokes",
"a",
"callback",
"before",
"and",
"after",
"sending",
"a",
"request",
"."
] | bf595424e4d442a190582e088985dc835a789071 | https://github.com/guzzle/guzzle/blob/bf595424e4d442a190582e088985dc835a789071/src/Middleware.php#L126-L140 | train | Returns a closure that will be used to tap the request | [
30522,
2270,
10763,
3853,
11112,
1006,
2655,
3085,
30524,
1010,
1002,
2077,
1010,
1002,
2044,
1007,
1063,
2065,
1006,
1002,
2077,
1007,
1063,
1002,
2077,
1006,
1002,
5227,
1010,
1002,
7047,
1007,
1025,
1065,
1002,
3433,
1027,
1002,
28213,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.