repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
dotzero/amocrm-php | src/Request/ParamsBag.php | ParamsBag.addGet | public function addGet($name, $value = null)
{
if (is_array($name) && $value === null) {
$this->getParams = array_merge($this->getParams, $name);
} else {
$this->getParams[$name] = $value;
}
return $this;
} | php | public function addGet($name, $value = null)
{
if (is_array($name) && $value === null) {
$this->getParams = array_merge($this->getParams, $name);
} else {
$this->getParams[$name] = $value;
}
return $this;
} | [
"public",
"function",
"addGet",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
"&&",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"getParams",
"=",
"array_merge",
"(",
"$",
"... | Добавление значений GET параметров
@param string|array $name Название параметра
@param mixed $value Значение параметра
@return $this | [
"Добавление",
"значений",
"GET",
"параметров"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Request/ParamsBag.php#L90-L99 |
dotzero/amocrm-php | src/Request/ParamsBag.php | ParamsBag.getGet | public function getGet($name = null)
{
if ($name !== null) {
return isset($this->getParams[$name]) ? $this->getParams[$name] : null;
}
return $this->getParams;
} | php | public function getGet($name = null)
{
if ($name !== null) {
return isset($this->getParams[$name]) ? $this->getParams[$name] : null;
}
return $this->getParams;
} | [
"public",
"function",
"getGet",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"getParams",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"getParams",
"["... | Получение GET параметра по ключу или список параметров
@param string $name Название параметра
@return array|null Значение параметра или список параметров | [
"Получение",
"GET",
"параметра",
"по",
"ключу",
"или",
"список",
"параметров"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Request/ParamsBag.php#L107-L114 |
dotzero/amocrm-php | src/Request/ParamsBag.php | ParamsBag.addPost | public function addPost($name, $value = null)
{
if (is_array($name) && $value === null) {
$this->postParams = array_merge($this->postParams, $name);
} else {
$this->postParams[$name] = $value;
}
return $this;
} | php | public function addPost($name, $value = null)
{
if (is_array($name) && $value === null) {
$this->postParams = array_merge($this->postParams, $name);
} else {
$this->postParams[$name] = $value;
}
return $this;
} | [
"public",
"function",
"addPost",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
"&&",
"$",
"value",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"postParams",
"=",
"array_merge",
"(",
"$",
... | Добавление значений POST параметров
@param string|array $name Название параметра
@param mixed $value Значение параметра
@return $this | [
"Добавление",
"значений",
"POST",
"параметров"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Request/ParamsBag.php#L145-L154 |
dotzero/amocrm-php | src/Request/ParamsBag.php | ParamsBag.getPost | public function getPost($name = null)
{
if ($name !== null) {
return isset($this->postParams[$name]) ? $this->postParams[$name] : null;
}
return $this->postParams;
} | php | public function getPost($name = null)
{
if ($name !== null) {
return isset($this->postParams[$name]) ? $this->postParams[$name] : null;
}
return $this->postParams;
} | [
"public",
"function",
"getPost",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"postParams",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"postParams",
... | Получение POST параметра по ключу или список параметров
@param string $name Название параметра
@return array|null Значение параметра или список параметров | [
"Получение",
"POST",
"параметра",
"по",
"ключу",
"или",
"список",
"параметров"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Request/ParamsBag.php#L162-L169 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.login | public function login()
{
$response = $this->request(self::METHOD_POST, '/user/login', [
'appkey' => $this->parameters->getAuth('appkey'),
'email' => $this->parameters->getAuth('email'),
'password' => $this->parameters->getAuth('password'),
'hash' => $this->pa... | php | public function login()
{
$response = $this->request(self::METHOD_POST, '/user/login', [
'appkey' => $this->parameters->getAuth('appkey'),
'email' => $this->parameters->getAuth('email'),
'password' => $this->parameters->getAuth('password'),
'hash' => $this->pa... | [
"public",
"function",
"login",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"self",
"::",
"METHOD_POST",
",",
"'/user/login'",
",",
"[",
"'appkey'",
"=>",
"$",
"this",
"->",
"parameters",
"->",
"getAuth",
"(",
"'appkey'",
")",
... | Авторизация в сервисе B2BFamily
@return array | [
"Авторизация",
"в",
"сервисе",
"B2BFamily"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L78-L92 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.subscribe | public function subscribe()
{
if ($this->apikey === null) {
$this->login();
}
return $this->request(self::METHOD_PUT, '/subscribers/add', [
'apikey' => $this->apikey,
'path' => 'http://b2bf.cloudapp.net/post/',
]);
} | php | public function subscribe()
{
if ($this->apikey === null) {
$this->login();
}
return $this->request(self::METHOD_PUT, '/subscribers/add', [
'apikey' => $this->apikey,
'path' => 'http://b2bf.cloudapp.net/post/',
]);
} | [
"public",
"function",
"subscribe",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"apikey",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"login",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"request",
"(",
"self",
"::",
"METHOD_PUT",
",",
"'/subs... | Подписка amoCRM на получение Web Hook от B2BFamily
@return array | [
"Подписка",
"amoCRM",
"на",
"получение",
"Web",
"Hook",
"от",
"B2BFamily"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L99-L109 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.unsubscribe | public function unsubscribe($id)
{
if ($this->apikey === null) {
$this->login();
}
return $this->request(self::METHOD_DELETE, '/subscribers/delete', [
'apikey' => $this->apikey,
'id' => $id,
]);
} | php | public function unsubscribe($id)
{
if ($this->apikey === null) {
$this->login();
}
return $this->request(self::METHOD_DELETE, '/subscribers/delete', [
'apikey' => $this->apikey,
'id' => $id,
]);
} | [
"public",
"function",
"unsubscribe",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"apikey",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"login",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"request",
"(",
"self",
"::",
"METHOD_DELET... | Отписка amoCRM на получение Web Hook от B2BFamily
@param integer $id Номер подписки для отключения
@return mixed | [
"Отписка",
"amoCRM",
"на",
"получение",
"Web",
"Hook",
"от",
"B2BFamily"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L117-L127 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.mail | public function mail($lead_id = 0, $params)
{
if ($this->apikey === null) {
$this->login();
}
$parameters = array_merge($params, [
'apikey' => $this->apikey,
'notification_settings' => [
'sms_enable' => false,
'email_enable... | php | public function mail($lead_id = 0, $params)
{
if ($this->apikey === null) {
$this->login();
}
$parameters = array_merge($params, [
'apikey' => $this->apikey,
'notification_settings' => [
'sms_enable' => false,
'email_enable... | [
"public",
"function",
"mail",
"(",
"$",
"lead_id",
"=",
"0",
",",
"$",
"params",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"apikey",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"login",
"(",
")",
";",
"}",
"$",
"parameters",
"=",
"array_merge",
"("... | Отправка письма через B2BFamily с привязкой к сделке в amoCRM
@param integer $lead_id Номер сделки в amoCRM
@param array $params Список дополнительных параметров
@return mixed | [
"Отправка",
"письма",
"через",
"B2BFamily",
"с",
"привязкой",
"к",
"сделке",
"в",
"amoCRM"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L136-L162 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.request | protected function request($method, $url, $parameters = [])
{
$endpoint = 'https://api.b2bfamily.com' . $url;
if (in_array($method, [self::METHOD_GET, self::METHOD_DELETE])) {
$endpoint .= '?' . http_build_query($parameters, null, '&');
}
$ch = curl_init();
cur... | php | protected function request($method, $url, $parameters = [])
{
$endpoint = 'https://api.b2bfamily.com' . $url;
if (in_array($method, [self::METHOD_GET, self::METHOD_DELETE])) {
$endpoint .= '?' . http_build_query($parameters, null, '&');
}
$ch = curl_init();
cur... | [
"protected",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"endpoint",
"=",
"'https://api.b2bfamily.com'",
".",
"$",
"url",
";",
"if",
"(",
"in_array",
"(",
"$",
"method",
",",
"[",
... | Выполнить HTTP запрос и вернуть тело ответа
@param $method
@param string $url Запрашиваемый URL
@param array $parameters
@return mixed
@throws B2BFamilyException | [
"Выполнить",
"HTTP",
"запрос",
"и",
"вернуть",
"тело",
"ответа"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L173-L211 |
dotzero/amocrm-php | src/Helpers/B2BFamily.php | B2BFamily.getHash | private function getHash()
{
return md5(implode('&', [
'appkey=' . $this->parameters->getAuth('appkey'),
'secret=' . $this->parameters->getAuth('secret'),
'email=' . $this->parameters->getAuth('email'),
'password=' . $this->parameters->getAuth('password'),
... | php | private function getHash()
{
return md5(implode('&', [
'appkey=' . $this->parameters->getAuth('appkey'),
'secret=' . $this->parameters->getAuth('secret'),
'email=' . $this->parameters->getAuth('email'),
'password=' . $this->parameters->getAuth('password'),
... | [
"private",
"function",
"getHash",
"(",
")",
"{",
"return",
"md5",
"(",
"implode",
"(",
"'&'",
",",
"[",
"'appkey='",
".",
"$",
"this",
"->",
"parameters",
"->",
"getAuth",
"(",
"'appkey'",
")",
",",
"'secret='",
".",
"$",
"this",
"->",
"parameters",
"-... | Возвращает md5 хеш параметров для авторизации
@return string | [
"Возвращает",
"md5",
"хеш",
"параметров",
"для",
"авторизации"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Helpers/B2BFamily.php#L218-L226 |
dotzero/amocrm-php | src/Models/Traits/SetTags.php | SetTags.setTags | public function setTags($value)
{
if (!is_array($value)) {
$value = [$value];
}
$this->values['tags'] = implode(',', $value);
return $this;
} | php | public function setTags($value)
{
if (!is_array($value)) {
$value = [$value];
}
$this->values['tags'] = implode(',', $value);
return $this;
} | [
"public",
"function",
"setTags",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"$",
"this",
"->",
"values",
"[",
"'tags'",
"]",
"=",
"implode",
"(... | Сеттер для списка тегов
@param int|array $value Название тегов через запятую или массив тегов
@return $this | [
"Сеттер",
"для",
"списка",
"тегов"
] | train | https://github.com/dotzero/amocrm-php/blob/d9f818acaf010fffdfe095f15c5e0ee4587a9385/src/Models/Traits/SetTags.php#L13-L22 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addFile | public function addFile(string $name, string $data, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processData($data);
} | php | public function addFile(string $name, string $data, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processData($data);
} | [
"public",
"function",
"addFile",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"data",
",",
"?",
"FileOptions",
"$",
"options",
"=",
"null",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"options",
"?",
":",
"new",
"FileOptions",
"(",
")",
";",
... | addFile
Add a file to the archive.
@param String $name - path of file in archive (including directory).
@param String $data - contents of file
@param FileOptions $options
File Options:
time - Last-modified timestamp (seconds since the epoch) of
this file. Defaults to the current time.
comment - Comment related... | [
"addFile"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L210-L217 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addFileFromPath | public function addFileFromPath(string $name, string $path, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processPath($path);
} | php | public function addFileFromPath(string $name, string $path, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processPath($path);
} | [
"public",
"function",
"addFileFromPath",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"path",
",",
"?",
"FileOptions",
"$",
"options",
"=",
"null",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"options",
"?",
":",
"new",
"FileOptions",
"(",
")",... | addFileFromPath
Add a file at path to the archive.
Note that large files may be compressed differently than smaller
files; see the "Large File Support" section above for more
information.
@param String $name - name of file in archive (including directory path).
@param String $path - path to file on disk (note: paths... | [
"addFileFromPath"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L256-L263 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addFileFromStream | public function addFileFromStream(string $name, $stream, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processStream(new DeflateStream($stream));
} | php | public function addFileFromStream(string $name, $stream, ?FileOptions $options = null): void
{
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processStream(new DeflateStream($stream));
} | [
"public",
"function",
"addFileFromStream",
"(",
"string",
"$",
"name",
",",
"$",
"stream",
",",
"?",
"FileOptions",
"$",
"options",
"=",
"null",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"options",
"?",
":",
"new",
"FileOptions",
"(",
")",
";",
... | addFileFromStream
Add an open stream to the archive.
@param String $name - path of file in archive (including directory).
@param Resource $stream - contents of file as a stream resource
@param FileOptions $options
File Options:
time - Last-modified timestamp (seconds since the epoch) of
this file. Defaults to t... | [
"addFileFromStream"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L290-L297 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addFileFromPsr7Stream | public function addFileFromPsr7Stream(
string $name,
StreamInterface $stream,
?FileOptions $options = null
): void {
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processStream($str... | php | public function addFileFromPsr7Stream(
string $name,
StreamInterface $stream,
?FileOptions $options = null
): void {
$options = $options ?: new FileOptions();
$options->defaultTo($this->opt);
$file = new File($this, $name, $options);
$file->processStream($str... | [
"public",
"function",
"addFileFromPsr7Stream",
"(",
"string",
"$",
"name",
",",
"StreamInterface",
"$",
"stream",
",",
"?",
"FileOptions",
"$",
"options",
"=",
"null",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"options",
"?",
":",
"new",
"FileOption... | addFileFromPsr7Stream
Add an open stream to the archive.
@param String $name - path of file in archive (including directory).
@param StreamInterface $stream - contents of file as a stream resource
@param FileOptions $options
File Options:
time - Last-modified timestamp (seconds since the epoch) of
this file. De... | [
"addFileFromPsr7Stream"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L324-L334 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.finish | public function finish(): void
{
// add trailing cdr file records
foreach ($this->files as $cdrFile) {
$this->send($cdrFile);
$this->cdr_ofs = $this->cdr_ofs->add(Bigint::init(strlen($cdrFile)));
}
// Add 64bit headers (if applicable)
if (count($this-... | php | public function finish(): void
{
// add trailing cdr file records
foreach ($this->files as $cdrFile) {
$this->send($cdrFile);
$this->cdr_ofs = $this->cdr_ofs->add(Bigint::init(strlen($cdrFile)));
}
// Add 64bit headers (if applicable)
if (count($this-... | [
"public",
"function",
"finish",
"(",
")",
":",
"void",
"{",
"// add trailing cdr file records",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"cdrFile",
")",
"{",
"$",
"this",
"->",
"send",
"(",
"$",
"cdrFile",
")",
";",
"$",
"this",
"->",
"cd... | finish
Write zip footer to stream.
Example:
// add a list of files to the archive
$files = array('foo.txt', 'bar.jpg');
foreach ($files as $path)
$zip->addFile($path, file_get_contents($path));
// write footer to stream
$zip->finish();
@return void
@throws OverflowException | [
"finish"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L354-L379 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addCdr64Eof | protected function addCdr64Eof(): void
{
$num_files = count($this->files);
$cdr_length = $this->cdr_ofs;
$cdr_offset = $this->ofs;
$fields = [
['V', static::ZIP64_CDR_EOF_SIGNATURE], // ZIP64 end of central file header signature
['P', 44], ... | php | protected function addCdr64Eof(): void
{
$num_files = count($this->files);
$cdr_length = $this->cdr_ofs;
$cdr_offset = $this->ofs;
$fields = [
['V', static::ZIP64_CDR_EOF_SIGNATURE], // ZIP64 end of central file header signature
['P', 44], ... | [
"protected",
"function",
"addCdr64Eof",
"(",
")",
":",
"void",
"{",
"$",
"num_files",
"=",
"count",
"(",
"$",
"this",
"->",
"files",
")",
";",
"$",
"cdr_length",
"=",
"$",
"this",
"->",
"cdr_ofs",
";",
"$",
"cdr_offset",
"=",
"$",
"this",
"->",
"ofs"... | Send ZIP64 CDR EOF (Central Directory Record End-of-File) record.
@return void | [
"Send",
"ZIP64",
"CDR",
"EOF",
"(",
"Central",
"Directory",
"Record",
"End",
"-",
"of",
"-",
"File",
")",
"record",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L386-L407 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.packFields | public static function packFields(array $fields): string
{
$fmt = '';
$args = [];
// populate format string and argument list
foreach ($fields as [$format, $value]) {
if ($format === 'P') {
$fmt .= 'VV';
if ($value instanceof Bigint) {
... | php | public static function packFields(array $fields): string
{
$fmt = '';
$args = [];
// populate format string and argument list
foreach ($fields as [$format, $value]) {
if ($format === 'P') {
$fmt .= 'VV';
if ($value instanceof Bigint) {
... | [
"public",
"static",
"function",
"packFields",
"(",
"array",
"$",
"fields",
")",
":",
"string",
"{",
"$",
"fmt",
"=",
"''",
";",
"$",
"args",
"=",
"[",
"]",
";",
"// populate format string and argument list",
"foreach",
"(",
"$",
"fields",
"as",
"[",
"$",
... | Create a format string and argument list for pack(), then call
pack() and return the result.
@param array $fields
@return string | [
"Create",
"a",
"format",
"string",
"and",
"argument",
"list",
"for",
"pack",
"()",
"then",
"call",
"pack",
"()",
"and",
"return",
"the",
"result",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L416-L446 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.send | public function send(string $str): void
{
if ($this->need_headers) {
$this->sendHttpHeaders();
}
$this->need_headers = false;
fwrite($this->opt->getOutputStream(), $str);
} | php | public function send(string $str): void
{
if ($this->need_headers) {
$this->sendHttpHeaders();
}
$this->need_headers = false;
fwrite($this->opt->getOutputStream(), $str);
} | [
"public",
"function",
"send",
"(",
"string",
"$",
"str",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"need_headers",
")",
"{",
"$",
"this",
"->",
"sendHttpHeaders",
"(",
")",
";",
"}",
"$",
"this",
"->",
"need_headers",
"=",
"false",
";",
... | Send string, sending HTTP headers if necessary.
@param String $str
@return void | [
"Send",
"string",
"sending",
"HTTP",
"headers",
"if",
"necessary",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L454-L462 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.sendHttpHeaders | protected function sendHttpHeaders(): void
{
// grab content disposition
$disposition = $this->opt->getContentDisposition();
if ($this->output_name) {
// Various different browsers dislike various characters here. Strip them all for safety.
$safe_output = trim(str_re... | php | protected function sendHttpHeaders(): void
{
// grab content disposition
$disposition = $this->opt->getContentDisposition();
if ($this->output_name) {
// Various different browsers dislike various characters here. Strip them all for safety.
$safe_output = trim(str_re... | [
"protected",
"function",
"sendHttpHeaders",
"(",
")",
":",
"void",
"{",
"// grab content disposition",
"$",
"disposition",
"=",
"$",
"this",
"->",
"opt",
"->",
"getContentDisposition",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"output_name",
")",
"{",
"//... | Send HTTP headers for this stream.
@return void | [
"Send",
"HTTP",
"headers",
"for",
"this",
"stream",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L469-L495 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addCdr64Locator | protected function addCdr64Locator(): void
{
$cdr_offset = $this->ofs->add($this->cdr_ofs);
$fields = [
['V', static::ZIP64_CDR_LOCATOR_SIGNATURE], // ZIP64 end of central file header signature
['V', 0x00], // Disc number containing CDR64EOF
... | php | protected function addCdr64Locator(): void
{
$cdr_offset = $this->ofs->add($this->cdr_ofs);
$fields = [
['V', static::ZIP64_CDR_LOCATOR_SIGNATURE], // ZIP64 end of central file header signature
['V', 0x00], // Disc number containing CDR64EOF
... | [
"protected",
"function",
"addCdr64Locator",
"(",
")",
":",
"void",
"{",
"$",
"cdr_offset",
"=",
"$",
"this",
"->",
"ofs",
"->",
"add",
"(",
"$",
"this",
"->",
"cdr_ofs",
")",
";",
"$",
"fields",
"=",
"[",
"[",
"'V'",
",",
"static",
"::",
"ZIP64_CDR_L... | Send ZIP64 CDR Locator (Central Directory Record Locator) record.
@return void | [
"Send",
"ZIP64",
"CDR",
"Locator",
"(",
"Central",
"Directory",
"Record",
"Locator",
")",
"record",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L502-L515 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addCdrEof | protected function addCdrEof(): void
{
$num_files = count($this->files);
$cdr_length = $this->cdr_ofs;
$cdr_offset = $this->ofs;
// grab comment (if specified)
$comment = $this->opt->getComment();
$fields = [
['V', static::CDR_EOF_SIGNATURE], // end of... | php | protected function addCdrEof(): void
{
$num_files = count($this->files);
$cdr_length = $this->cdr_ofs;
$cdr_offset = $this->ofs;
// grab comment (if specified)
$comment = $this->opt->getComment();
$fields = [
['V', static::CDR_EOF_SIGNATURE], // end of... | [
"protected",
"function",
"addCdrEof",
"(",
")",
":",
"void",
"{",
"$",
"num_files",
"=",
"count",
"(",
"$",
"this",
"->",
"files",
")",
";",
"$",
"cdr_length",
"=",
"$",
"this",
"->",
"cdr_ofs",
";",
"$",
"cdr_offset",
"=",
"$",
"this",
"->",
"ofs",
... | Send CDR EOF (Central Directory Record End-of-File) record.
@return void | [
"Send",
"CDR",
"EOF",
"(",
"Central",
"Directory",
"Record",
"End",
"-",
"of",
"-",
"File",
")",
"record",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L522-L544 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.clear | protected function clear(): void
{
$this->files = [];
$this->ofs = new Bigint();
$this->cdr_ofs = new Bigint();
$this->opt = new ArchiveOptions();
} | php | protected function clear(): void
{
$this->files = [];
$this->ofs = new Bigint();
$this->cdr_ofs = new Bigint();
$this->opt = new ArchiveOptions();
} | [
"protected",
"function",
"clear",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"files",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"ofs",
"=",
"new",
"Bigint",
"(",
")",
";",
"$",
"this",
"->",
"cdr_ofs",
"=",
"new",
"Bigint",
"(",
")",
";",
"$",... | Clear all internal variables. Note that the stream object is not
usable after this.
@return void | [
"Clear",
"all",
"internal",
"variables",
".",
"Note",
"that",
"the",
"stream",
"object",
"is",
"not",
"usable",
"after",
"this",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L552-L558 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.isLargeFile | public function isLargeFile(string $path): bool
{
if (!$this->opt->isStatFiles()) {
return false;
}
$stat = stat($path);
return $stat['size'] > $this->opt->getLargeFileSize();
} | php | public function isLargeFile(string $path): bool
{
if (!$this->opt->isStatFiles()) {
return false;
}
$stat = stat($path);
return $stat['size'] > $this->opt->getLargeFileSize();
} | [
"public",
"function",
"isLargeFile",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"opt",
"->",
"isStatFiles",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"stat",
"=",
"stat",
"(",
"$",
"path",
")... | Is this file larger than large_file_size?
@param string $path
@return bool | [
"Is",
"this",
"file",
"larger",
"than",
"large_file_size?"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L566-L573 |
maennchen/ZipStream-PHP | src/ZipStream.php | ZipStream.addToCdr | public function addToCdr(File $file): void
{
$file->ofs = $this->ofs;
$this->ofs = $this->ofs->add($file->getTotalLength());
$this->files[] = $file->getCdrFile();
} | php | public function addToCdr(File $file): void
{
$file->ofs = $this->ofs;
$this->ofs = $this->ofs->add($file->getTotalLength());
$this->files[] = $file->getCdrFile();
} | [
"public",
"function",
"addToCdr",
"(",
"File",
"$",
"file",
")",
":",
"void",
"{",
"$",
"file",
"->",
"ofs",
"=",
"$",
"this",
"->",
"ofs",
";",
"$",
"this",
"->",
"ofs",
"=",
"$",
"this",
"->",
"ofs",
"->",
"add",
"(",
"$",
"file",
"->",
"getT... | Save file attributes for trailing CDR record.
@param File $file
@return void | [
"Save",
"file",
"attributes",
"for",
"trailing",
"CDR",
"record",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/ZipStream.php#L581-L586 |
maennchen/ZipStream-PHP | src/File.php | File.addFileHeader | public function addFileHeader(): void
{
$name = static::filterFilename($this->name);
// calculate name length
$nameLength = strlen($name);
// create dos timestamp
$time = static::dosTime($this->opt->getTime()->getTimestamp());
$comment = $this->opt->getComment();
... | php | public function addFileHeader(): void
{
$name = static::filterFilename($this->name);
// calculate name length
$nameLength = strlen($name);
// create dos timestamp
$time = static::dosTime($this->opt->getTime()->getTimestamp());
$comment = $this->opt->getComment();
... | [
"public",
"function",
"addFileHeader",
"(",
")",
":",
"void",
"{",
"$",
"name",
"=",
"static",
"::",
"filterFilename",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// calculate name length",
"$",
"nameLength",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"//... | Create and send zip header for this file.
@return void
@throws \ZipStream\Exception\EncodingException | [
"Create",
"and",
"send",
"zip",
"header",
"for",
"this",
"file",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/File.php#L145-L210 |
maennchen/ZipStream-PHP | src/File.php | File.dosTime | final protected static function dosTime(int $when): int
{
// get date array for timestamp
$d = getdate($when);
// set lower-bound on dates
if ($d['year'] < 1980) {
$d = array(
'year' => 1980,
'mon' => 1,
'mday' => 1,
... | php | final protected static function dosTime(int $when): int
{
// get date array for timestamp
$d = getdate($when);
// set lower-bound on dates
if ($d['year'] < 1980) {
$d = array(
'year' => 1980,
'mon' => 1,
'mday' => 1,
... | [
"final",
"protected",
"static",
"function",
"dosTime",
"(",
"int",
"$",
"when",
")",
":",
"int",
"{",
"// get date array for timestamp",
"$",
"d",
"=",
"getdate",
"(",
"$",
"when",
")",
";",
"// set lower-bound on dates",
"if",
"(",
"$",
"d",
"[",
"'year'",
... | Convert a UNIX timestamp to a DOS timestamp.
@param int $when
@return int DOS Timestamp | [
"Convert",
"a",
"UNIX",
"timestamp",
"to",
"a",
"DOS",
"timestamp",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/File.php#L234-L262 |
maennchen/ZipStream-PHP | src/File.php | File.addFileFooter | public function addFileFooter(): void
{
if ($this->bits & self::BIT_ZERO_HEADER) {
$fields = [
['V', ZipStream::DATA_DESCRIPTOR_SIGNATURE],
['V', $this->crc], // CRC32
['V', $this->zlen], // Length of compressed data
... | php | public function addFileFooter(): void
{
if ($this->bits & self::BIT_ZERO_HEADER) {
$fields = [
['V', ZipStream::DATA_DESCRIPTOR_SIGNATURE],
['V', $this->crc], // CRC32
['V', $this->zlen], // Length of compressed data
... | [
"public",
"function",
"addFileFooter",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"bits",
"&",
"self",
"::",
"BIT_ZERO_HEADER",
")",
"{",
"$",
"fields",
"=",
"[",
"[",
"'V'",
",",
"ZipStream",
"::",
"DATA_DESCRIPTOR_SIGNATURE",
"]",
",",
... | Create and send data descriptor footer for this file.
@return void | [
"Create",
"and",
"send",
"data",
"descriptor",
"footer",
"for",
"this",
"file",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/File.php#L302-L329 |
maennchen/ZipStream-PHP | src/File.php | File.getCdrFile | public function getCdrFile(): string
{
$name = static::filterFilename($this->name);
// get attributes
$comment = $this->opt->getComment();
// get dos timestamp
$time = static::dosTime($this->opt->getTime()->getTimestamp());
$footer = $this->buildZip64ExtraBlock();
... | php | public function getCdrFile(): string
{
$name = static::filterFilename($this->name);
// get attributes
$comment = $this->opt->getComment();
// get dos timestamp
$time = static::dosTime($this->opt->getTime()->getTimestamp());
$footer = $this->buildZip64ExtraBlock();
... | [
"public",
"function",
"getCdrFile",
"(",
")",
":",
"string",
"{",
"$",
"name",
"=",
"static",
"::",
"filterFilename",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// get attributes",
"$",
"comment",
"=",
"$",
"this",
"->",
"opt",
"->",
"getComment",
"(",
... | Send CDR record for specified file.
@return string | [
"Send",
"CDR",
"record",
"for",
"specified",
"file",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/File.php#L436-L471 |
maennchen/ZipStream-PHP | src/Stream.php | Stream.write | public function write($string): int
{
if (!$this->isWritable()) {
throw new RuntimeException;
}
if (fwrite($this->stream, $string) === false) {
throw new RuntimeException;
}
return \mb_strlen($string);
} | php | public function write($string): int
{
if (!$this->isWritable()) {
throw new RuntimeException;
}
if (fwrite($this->stream, $string) === false) {
throw new RuntimeException;
}
return \mb_strlen($string);
} | [
"public",
"function",
"write",
"(",
"$",
"string",
")",
":",
"int",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isWritable",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
";",
"}",
"if",
"(",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",
... | Write data to the stream.
@param string $string The string that is to be written.
@return int Returns the number of bytes written to the stream.
@throws \RuntimeException on failure. | [
"Write",
"data",
"to",
"the",
"stream",
"."
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Stream.php#L187-L196 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.fillBytes | protected function fillBytes(int $value, int $start, int $count): void
{
for ($i = 0; $i < $count; $i++) {
$this->bytes[$start + $i] = $i >= PHP_INT_SIZE ? 0 : $value & 0xFF;
$value >>= 8;
}
} | php | protected function fillBytes(int $value, int $start, int $count): void
{
for ($i = 0; $i < $count; $i++) {
$this->bytes[$start + $i] = $i >= PHP_INT_SIZE ? 0 : $value & 0xFF;
$value >>= 8;
}
} | [
"protected",
"function",
"fillBytes",
"(",
"int",
"$",
"value",
",",
"int",
"$",
"start",
",",
"int",
"$",
"count",
")",
":",
"void",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
... | Fill the bytes field with int
@param int $value
@param int $start
@param int $count
@return void | [
"Fill",
"the",
"bytes",
"field",
"with",
"int"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L33-L39 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.fromLowHigh | public static function fromLowHigh(int $low, int $high): self
{
$bigint = new Bigint();
$bigint->fillBytes($low, 0, 4);
$bigint->fillBytes($high, 4, 4);
return $bigint;
} | php | public static function fromLowHigh(int $low, int $high): self
{
$bigint = new Bigint();
$bigint->fillBytes($low, 0, 4);
$bigint->fillBytes($high, 4, 4);
return $bigint;
} | [
"public",
"static",
"function",
"fromLowHigh",
"(",
"int",
"$",
"low",
",",
"int",
"$",
"high",
")",
":",
"self",
"{",
"$",
"bigint",
"=",
"new",
"Bigint",
"(",
")",
";",
"$",
"bigint",
"->",
"fillBytes",
"(",
"$",
"low",
",",
"0",
",",
"4",
")",... | Fill bytes from low to high
@param int $low
@param int $high
@return Bigint | [
"Fill",
"bytes",
"from",
"low",
"to",
"high"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L59-L65 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.getValue | public function getValue(int $end = 0, int $length = 8): int
{
$result = 0;
for ($i = $end + $length - 1; $i >= $end; $i--) {
$result <<= 8;
$result |= $this->bytes[$i];
}
return $result;
} | php | public function getValue(int $end = 0, int $length = 8): int
{
$result = 0;
for ($i = $end + $length - 1; $i >= $end; $i--) {
$result <<= 8;
$result |= $this->bytes[$i];
}
return $result;
} | [
"public",
"function",
"getValue",
"(",
"int",
"$",
"end",
"=",
"0",
",",
"int",
"$",
"length",
"=",
"8",
")",
":",
"int",
"{",
"$",
"result",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"end",
"+",
"$",
"length",
"-",
"1",
";",
"$",
"i",... | Get value from bytes array
@param int $end
@param int $length
@return int | [
"Get",
"value",
"from",
"bytes",
"array"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L84-L92 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.getLowFF | public function getLowFF(bool $force = false): int
{
if ($force || $this->isOver32()) {
return 0xFFFFFFFF;
}
return $this->getLow32();
} | php | public function getLowFF(bool $force = false): int
{
if ($force || $this->isOver32()) {
return 0xFFFFFFFF;
}
return $this->getLow32();
} | [
"public",
"function",
"getLowFF",
"(",
"bool",
"$",
"force",
"=",
"false",
")",
":",
"int",
"{",
"if",
"(",
"$",
"force",
"||",
"$",
"this",
"->",
"isOver32",
"(",
")",
")",
"{",
"return",
"0xFFFFFFFF",
";",
"}",
"return",
"$",
"this",
"->",
"getLo... | Get low FF
@param bool $force
@return int | [
"Get",
"low",
"FF"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L100-L106 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.isOver32 | public function isOver32(bool $force = false): bool
{
// value 0xFFFFFFFF already needs a Zip64 header
return $force ||
max(array_slice($this->bytes, 4, 4)) > 0 ||
min(array_slice($this->bytes, 0, 4)) === 0xFF;
} | php | public function isOver32(bool $force = false): bool
{
// value 0xFFFFFFFF already needs a Zip64 header
return $force ||
max(array_slice($this->bytes, 4, 4)) > 0 ||
min(array_slice($this->bytes, 0, 4)) === 0xFF;
} | [
"public",
"function",
"isOver32",
"(",
"bool",
"$",
"force",
"=",
"false",
")",
":",
"bool",
"{",
"// value 0xFFFFFFFF already needs a Zip64 header",
"return",
"$",
"force",
"||",
"max",
"(",
"array_slice",
"(",
"$",
"this",
"->",
"bytes",
",",
"4",
",",
"4"... | Check if is over 32
@param bool $force
@return bool | [
"Check",
"if",
"is",
"over",
"32"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L114-L120 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.getHex64 | public function getHex64(): string
{
$result = '0x';
for ($i = 7; $i >= 0; $i--) {
$result .= sprintf('%02X', $this->bytes[$i]);
}
return $result;
} | php | public function getHex64(): string
{
$result = '0x';
for ($i = 7; $i >= 0; $i--) {
$result .= sprintf('%02X', $this->bytes[$i]);
}
return $result;
} | [
"public",
"function",
"getHex64",
"(",
")",
":",
"string",
"{",
"$",
"result",
"=",
"'0x'",
";",
"for",
"(",
"$",
"i",
"=",
"7",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"result",
".=",
"sprintf",
"(",
"'%02X'",
",",
"$",... | Get hexadecimal
@return string | [
"Get",
"hexadecimal"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L137-L144 |
maennchen/ZipStream-PHP | src/Bigint.php | Bigint.add | public function add(Bigint $other): Bigint
{
$result = clone $this;
$overflow = false;
for ($i = 0; $i < 8; $i++) {
$result->bytes[$i] += $other->bytes[$i];
if ($overflow) {
$result->bytes[$i]++;
$overflow = false;
}
... | php | public function add(Bigint $other): Bigint
{
$result = clone $this;
$overflow = false;
for ($i = 0; $i < 8; $i++) {
$result->bytes[$i] += $other->bytes[$i];
if ($overflow) {
$result->bytes[$i]++;
$overflow = false;
}
... | [
"public",
"function",
"add",
"(",
"Bigint",
"$",
"other",
")",
":",
"Bigint",
"{",
"$",
"result",
"=",
"clone",
"$",
"this",
";",
"$",
"overflow",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"8",
";",
"$",
"i",
"++"... | Add
@param Bigint $other
@return Bigint | [
"Add"
] | train | https://github.com/maennchen/ZipStream-PHP/blob/272cab6f9b7a7e80248ec59a8d114ca197458623/src/Bigint.php#L152-L171 |
soundasleep/html2text | src/Html2Text.php | Html2Text.convert | public static function convert($html, $options = array()) {
if ($options === false || $options === true) {
// Using old style (< 1.0) of passing in options
$options = array('ignore_errors' => $options);
}
$options = array_merge(static::defaultOptions(), $options);
// check all options are valid
forea... | php | public static function convert($html, $options = array()) {
if ($options === false || $options === true) {
// Using old style (< 1.0) of passing in options
$options = array('ignore_errors' => $options);
}
$options = array_merge(static::defaultOptions(), $options);
// check all options are valid
forea... | [
"public",
"static",
"function",
"convert",
"(",
"$",
"html",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"options",
"===",
"false",
"||",
"$",
"options",
"===",
"true",
")",
"{",
"// Using old style (< 1.0) of passing in options",
... | Tries to convert the given HTML into a plain text format - best suited for
e-mail display, etc.
<p>In particular, it tries to maintain the following features:
<ul>
<li>Links are maintained, with the 'href' copied over
<li>Information in the <head> is lost
</ul>
@param string $html the input HTML
@param boolean ... | [
"Tries",
"to",
"convert",
"the",
"given",
"HTML",
"into",
"a",
"plain",
"text",
"format",
"-",
"best",
"suited",
"for",
"e",
"-",
"mail",
"display",
"etc",
"."
] | train | https://github.com/soundasleep/html2text/blob/3243a7107878a61685d2eccf99918d6479e039fc/src/Html2Text.php#L29-L65 |
soundasleep/html2text | src/Html2Text.php | Html2Text.processWhitespaceNewlines | static function processWhitespaceNewlines($text) {
// remove excess spaces around tabs
$text = preg_replace("/ *\t */im", "\t", $text);
// remove leading whitespace
$text = ltrim($text);
// remove leading spaces on each line
$text = preg_replace("/\n[ \t]*/im", "\n", $text);
// convert non-breaking sp... | php | static function processWhitespaceNewlines($text) {
// remove excess spaces around tabs
$text = preg_replace("/ *\t */im", "\t", $text);
// remove leading whitespace
$text = ltrim($text);
// remove leading spaces on each line
$text = preg_replace("/\n[ \t]*/im", "\n", $text);
// convert non-breaking sp... | [
"static",
"function",
"processWhitespaceNewlines",
"(",
"$",
"text",
")",
"{",
"// remove excess spaces around tabs",
"$",
"text",
"=",
"preg_replace",
"(",
"\"/ *\\t */im\"",
",",
"\"\\t\"",
",",
"$",
"text",
")",
";",
"// remove leading whitespace",
"$",
"text",
"... | Remove leading or trailing spaces and excess empty lines from provided multiline text
@param string $text multiline text any number of leading or trailing spaces or excess lines
@return string the fixed text | [
"Remove",
"leading",
"or",
"trailing",
"spaces",
"and",
"excess",
"empty",
"lines",
"from",
"provided",
"multiline",
"text"
] | train | https://github.com/soundasleep/html2text/blob/3243a7107878a61685d2eccf99918d6479e039fc/src/Html2Text.php#L104-L133 |
soundasleep/html2text | src/Html2Text.php | Html2Text.getDocument | static function getDocument($html, $ignore_error = false) {
$doc = new \DOMDocument();
$html = trim($html);
if (!$html) {
// DOMDocument doesn't support empty value and throws an error
// Return empty document instead
return $doc;
}
if ($html[0] !== '<') {
// If HTML does not begin with a tag,... | php | static function getDocument($html, $ignore_error = false) {
$doc = new \DOMDocument();
$html = trim($html);
if (!$html) {
// DOMDocument doesn't support empty value and throws an error
// Return empty document instead
return $doc;
}
if ($html[0] !== '<') {
// If HTML does not begin with a tag,... | [
"static",
"function",
"getDocument",
"(",
"$",
"html",
",",
"$",
"ignore_error",
"=",
"false",
")",
"{",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"html",
"=",
"trim",
"(",
"$",
"html",
")",
";",
"if",
"(",
"!",
"$",
"html"... | Parse HTML into a DOMDocument
@param string $html the input HTML
@param boolean $ignore_error Ignore xml parsing errors
@return \DOMDocument the parsed document tree | [
"Parse",
"HTML",
"into",
"a",
"DOMDocument"
] | train | https://github.com/soundasleep/html2text/blob/3243a7107878a61685d2eccf99918d6479e039fc/src/Html2Text.php#L142-L179 |
soundasleep/html2text | src/Html2Text.php | Html2Text.renderText | static function renderText($text) {
$text = str_replace(static::nbspCodes(), " ", $text);
$text = str_replace(static::zwnjCodes(), "", $text);
return $text;
} | php | static function renderText($text) {
$text = str_replace(static::nbspCodes(), " ", $text);
$text = str_replace(static::zwnjCodes(), "", $text);
return $text;
} | [
"static",
"function",
"renderText",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"static",
"::",
"nbspCodes",
"(",
")",
",",
"\" \"",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"static",
"::",
"zwnjCodes",
... | Replace any special characters with simple text versions, to prevent output issues:
- Convert non-breaking spaces to regular spaces; and
- Convert zero-width non-joiners to '' (nothing).
This is to match our goal of rendering documents as they would be rendered
by a browser. | [
"Replace",
"any",
"special",
"characters",
"with",
"simple",
"text",
"versions",
"to",
"prevent",
"output",
"issues",
":",
"-",
"Convert",
"non",
"-",
"breaking",
"spaces",
"to",
"regular",
"spaces",
";",
"and",
"-",
"Convert",
"zero",
"-",
"width",
"non",
... | train | https://github.com/soundasleep/html2text/blob/3243a7107878a61685d2eccf99918d6479e039fc/src/Html2Text.php#L196-L200 |
maknz/slack | src/Message.php | Message.attach | public function attach($attachment)
{
if ($attachment instanceof Attachment) {
$this->attachments[] = $attachment;
return $this;
} elseif (is_array($attachment)) {
$attachmentObject = new Attachment($attachment);
if (! isset($attachment['mrkdwn_in'])... | php | public function attach($attachment)
{
if ($attachment instanceof Attachment) {
$this->attachments[] = $attachment;
return $this;
} elseif (is_array($attachment)) {
$attachmentObject = new Attachment($attachment);
if (! isset($attachment['mrkdwn_in'])... | [
"public",
"function",
"attach",
"(",
"$",
"attachment",
")",
"{",
"if",
"(",
"$",
"attachment",
"instanceof",
"Attachment",
")",
"{",
"$",
"this",
"->",
"attachments",
"[",
"]",
"=",
"$",
"attachment",
";",
"return",
"$",
"this",
";",
"}",
"elseif",
"(... | Add an attachment to the message.
@param mixed $attachment
@return $this | [
"Add",
"an",
"attachment",
"to",
"the",
"message",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Message.php#L329-L348 |
maknz/slack | src/Message.php | Message.send | public function send($text = null)
{
if ($text) {
$this->setText($text);
}
$this->client->sendMessage($this);
return $this;
} | php | public function send($text = null)
{
if ($text) {
$this->setText($text);
}
$this->client->sendMessage($this);
return $this;
} | [
"public",
"function",
"send",
"(",
"$",
"text",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"text",
")",
"{",
"$",
"this",
"->",
"setText",
"(",
"$",
"text",
")",
";",
"}",
"$",
"this",
"->",
"client",
"->",
"sendMessage",
"(",
"$",
"this",
")",
";"... | Send the message.
@param string $text The text to send
@return void | [
"Send",
"the",
"message",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Message.php#L395-L404 |
maknz/slack | src/AttachmentAction.php | AttachmentAction.toArray | public function toArray()
{
return [
'name' => $this->getName(),
'text' => $this->getText(),
'style' => $this->getStyle(),
'type' => $this->getType(),
'value' => $this->getValue(),
'confirm' => $this->getConfirm()->toArray(),
];... | php | public function toArray()
{
return [
'name' => $this->getName(),
'text' => $this->getText(),
'style' => $this->getStyle(),
'type' => $this->getType(),
'value' => $this->getValue(),
'confirm' => $this->getConfirm()->toArray(),
];... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'text'",
"=>",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"'style'",
"=>",
"$",
"this",
"->",
"getStyle",
"(",
")",
",",
... | Get the array representation of this attachment action.
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"this",
"attachment",
"action",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/AttachmentAction.php#L217-L227 |
maknz/slack | src/Attachment.php | Attachment.setFields | public function setFields(array $fields)
{
$this->clearFields();
foreach ($fields as $field) {
$this->addField($field);
}
return $this;
} | php | public function setFields(array $fields)
{
$this->clearFields();
foreach ($fields as $field) {
$this->addField($field);
}
return $this;
} | [
"public",
"function",
"setFields",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"clearFields",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"addField",
"(",
"$",
"field",
")",
";",
"}",... | Set the fields for the attachment.
@param array $fields
@return $this | [
"Set",
"the",
"fields",
"for",
"the",
"attachment",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Attachment.php#L545-L554 |
maknz/slack | src/Attachment.php | Attachment.addField | public function addField($field)
{
if ($field instanceof AttachmentField) {
$this->fields[] = $field;
return $this;
} elseif (is_array($field)) {
$this->fields[] = new AttachmentField($field);
return $this;
}
throw new InvalidArgumen... | php | public function addField($field)
{
if ($field instanceof AttachmentField) {
$this->fields[] = $field;
return $this;
} elseif (is_array($field)) {
$this->fields[] = new AttachmentField($field);
return $this;
}
throw new InvalidArgumen... | [
"public",
"function",
"addField",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"instanceof",
"AttachmentField",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"]",
"=",
"$",
"field",
";",
"return",
"$",
"this",
";",
"}",
"elseif",
"(",
"is_arra... | Add a field to the attachment.
@param mixed $field
@return $this | [
"Add",
"a",
"field",
"to",
"the",
"attachment",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Attachment.php#L562-L575 |
maknz/slack | src/Attachment.php | Attachment.toArray | public function toArray()
{
$data = [
'fallback' => $this->getFallback(),
'text' => $this->getText(),
'pretext' => $this->getPretext(),
'color' => $this->getColor(),
'footer' => $this->getFooter(),
'footer_icon' => $this->getFooterIcon(... | php | public function toArray()
{
$data = [
'fallback' => $this->getFallback(),
'text' => $this->getText(),
'pretext' => $this->getPretext(),
'color' => $this->getColor(),
'footer' => $this->getFooter(),
'footer_icon' => $this->getFooterIcon(... | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'fallback'",
"=>",
"$",
"this",
"->",
"getFallback",
"(",
")",
",",
"'text'",
"=>",
"$",
"this",
"->",
"getText",
"(",
")",
",",
"'pretext'",
"=>",
"$",
"this",
"->",
"getPretext... | Convert this attachment to its array representation.
@return array | [
"Convert",
"this",
"attachment",
"to",
"its",
"array",
"representation",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Attachment.php#L679-L703 |
maknz/slack | src/Attachment.php | Attachment.getFieldsAsArrays | protected function getFieldsAsArrays()
{
$fields = [];
foreach ($this->getFields() as $field) {
$fields[] = $field->toArray();
}
return $fields;
} | php | protected function getFieldsAsArrays()
{
$fields = [];
foreach ($this->getFields() as $field) {
$fields[] = $field->toArray();
}
return $fields;
} | [
"protected",
"function",
"getFieldsAsArrays",
"(",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"field",
"->",
"toArray",
"("... | Iterates over all fields in this attachment and returns
them in their array form.
@return array | [
"Iterates",
"over",
"all",
"fields",
"in",
"this",
"attachment",
"and",
"returns",
"them",
"in",
"their",
"array",
"form",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Attachment.php#L711-L720 |
maknz/slack | src/Attachment.php | Attachment.getActionsAsArrays | protected function getActionsAsArrays()
{
$actions = [];
foreach ($this->getActions() as $action) {
$actions[] = $action->toArray();
}
return $actions;
} | php | protected function getActionsAsArrays()
{
$actions = [];
foreach ($this->getActions() as $action) {
$actions[] = $action->toArray();
}
return $actions;
} | [
"protected",
"function",
"getActionsAsArrays",
"(",
")",
"{",
"$",
"actions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getActions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"action",
"->",
"toArray",... | Iterates over all actions in this attachment and returns
them in their array form.
@return array | [
"Iterates",
"over",
"all",
"actions",
"in",
"this",
"attachment",
"and",
"returns",
"them",
"in",
"their",
"array",
"form",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Attachment.php#L728-L737 |
maknz/slack | src/Client.php | Client.createMessage | public function createMessage()
{
$message = new Message($this);
$message->setChannel($this->getDefaultChannel());
$message->setUsername($this->getDefaultUsername());
$message->setIcon($this->getDefaultIcon());
$message->setAllowMarkdown($this->getAllowMarkdown());
... | php | public function createMessage()
{
$message = new Message($this);
$message->setChannel($this->getDefaultChannel());
$message->setUsername($this->getDefaultUsername());
$message->setIcon($this->getDefaultIcon());
$message->setAllowMarkdown($this->getAllowMarkdown());
... | [
"public",
"function",
"createMessage",
"(",
")",
"{",
"$",
"message",
"=",
"new",
"Message",
"(",
"$",
"this",
")",
";",
"$",
"message",
"->",
"setChannel",
"(",
"$",
"this",
"->",
"getDefaultChannel",
"(",
")",
")",
";",
"$",
"message",
"->",
"setUser... | Create a new message with defaults.
@return \Maknz\Slack\Message | [
"Create",
"a",
"new",
"message",
"with",
"defaults",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Client.php#L342-L357 |
maknz/slack | src/Client.php | Client.sendMessage | public function sendMessage(Message $message)
{
$payload = $this->preparePayload($message);
$encoded = json_encode($payload, JSON_UNESCAPED_UNICODE);
if ($encoded === false) {
throw new RuntimeException(sprintf('JSON encoding error %s: %s', json_last_error(), json_last_error_ms... | php | public function sendMessage(Message $message)
{
$payload = $this->preparePayload($message);
$encoded = json_encode($payload, JSON_UNESCAPED_UNICODE);
if ($encoded === false) {
throw new RuntimeException(sprintf('JSON encoding error %s: %s', json_last_error(), json_last_error_ms... | [
"public",
"function",
"sendMessage",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"preparePayload",
"(",
"$",
"message",
")",
";",
"$",
"encoded",
"=",
"json_encode",
"(",
"$",
"payload",
",",
"JSON_UNESCAPED_UNICODE",
... | Send a message.
@param \Maknz\Slack\Message $message
@return void | [
"Send",
"a",
"message",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Client.php#L365-L376 |
maknz/slack | src/Client.php | Client.preparePayload | public function preparePayload(Message $message)
{
$payload = [
'text' => $message->getText(),
'channel' => $message->getChannel(),
'username' => $message->getUsername(),
'link_names' => $this->getLinkNames() ? 1 : 0,
'unfurl_links' => $this->getUn... | php | public function preparePayload(Message $message)
{
$payload = [
'text' => $message->getText(),
'channel' => $message->getChannel(),
'username' => $message->getUsername(),
'link_names' => $this->getLinkNames() ? 1 : 0,
'unfurl_links' => $this->getUn... | [
"public",
"function",
"preparePayload",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"payload",
"=",
"[",
"'text'",
"=>",
"$",
"message",
"->",
"getText",
"(",
")",
",",
"'channel'",
"=>",
"$",
"message",
"->",
"getChannel",
"(",
")",
",",
"'username'"... | Prepares the payload to be sent to the webhook.
@param \Maknz\Slack\Message $message The message to send
@return array | [
"Prepares",
"the",
"payload",
"to",
"be",
"sent",
"to",
"the",
"webhook",
"."
] | train | https://github.com/maknz/slack/blob/89ff7b2a75379a326f48f3db839912f38511a44e/src/Client.php#L384-L403 |
johnbillion/query-monitor | wp-content/db.php | QM_DB.query | public function query( $query ) {
if ( ! $this->ready ) {
if ( isset( $this->check_current_query ) ) {
// This property was introduced in WP 4.2
$this->check_current_query = true;
}
return false;
}
if ( $this->show_errors ) {
$this->hide_errors();
}
$result = parent::query( $query );
... | php | public function query( $query ) {
if ( ! $this->ready ) {
if ( isset( $this->check_current_query ) ) {
// This property was introduced in WP 4.2
$this->check_current_query = true;
}
return false;
}
if ( $this->show_errors ) {
$this->hide_errors();
}
$result = parent::query( $query );
... | [
"public",
"function",
"query",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ready",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"check_current_query",
")",
")",
"{",
"// This property was introduced in WP 4.2",
"$",
"this",
... | Perform a MySQL database query, using current database connection.
@see wpdb::query()
@param string $query Database query
@return int|false Number of rows affected/selected or false on error | [
"Perform",
"a",
"MySQL",
"database",
"query",
"using",
"current",
"database",
"connection",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/wp-content/db.php#L87-L134 |
johnbillion/query-monitor | collectors/http.php | QM_Collector_HTTP.filter_http_request_args | public function filter_http_request_args( array $args, $url ) {
$trace = new QM_Backtrace();
if ( isset( $args['_qm_key'] ) ) {
// Something has triggered another HTTP request from within the `pre_http_request` filter
// (eg. WordPress Beta Tester does this). This allows for one level of nested queries.
$a... | php | public function filter_http_request_args( array $args, $url ) {
$trace = new QM_Backtrace();
if ( isset( $args['_qm_key'] ) ) {
// Something has triggered another HTTP request from within the `pre_http_request` filter
// (eg. WordPress Beta Tester does this). This allows for one level of nested queries.
$a... | [
"public",
"function",
"filter_http_request_args",
"(",
"array",
"$",
"args",
",",
"$",
"url",
")",
"{",
"$",
"trace",
"=",
"new",
"QM_Backtrace",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"'_qm_key'",
"]",
")",
")",
"{",
"// Something h... | Filter the arguments used in an HTTP request.
Used to log the request, and to add the logging key to the arguments array.
@param array $args HTTP request arguments.
@param string $url The request URL.
@return array HTTP request arguments. | [
"Filter",
"the",
"arguments",
"used",
"in",
"an",
"HTTP",
"request",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/http.php#L100-L119 |
johnbillion/query-monitor | collectors/http.php | QM_Collector_HTTP.filter_pre_http_request | public function filter_pre_http_request( $response, array $args, $url ) {
// All is well:
if ( false === $response ) {
return $response;
}
// Something's filtering the response, so we'll log it
$this->log_http_response( $response, $args, $url );
return $response;
} | php | public function filter_pre_http_request( $response, array $args, $url ) {
// All is well:
if ( false === $response ) {
return $response;
}
// Something's filtering the response, so we'll log it
$this->log_http_response( $response, $args, $url );
return $response;
} | [
"public",
"function",
"filter_pre_http_request",
"(",
"$",
"response",
",",
"array",
"$",
"args",
",",
"$",
"url",
")",
"{",
"// All is well:",
"if",
"(",
"false",
"===",
"$",
"response",
")",
"{",
"return",
"$",
"response",
";",
"}",
"// Something's filteri... | Log the HTTP request's response if it's being short-circuited by another plugin.
This is necessary due to https://core.trac.wordpress.org/ticket/25747
$response should be one of boolean false, an array, or a `WP_Error`, but be aware that plugins
which short-circuit the request using this filter may (incorrectly) retur... | [
"Log",
"the",
"HTTP",
"request",
"s",
"response",
"if",
"it",
"s",
"being",
"short",
"-",
"circuited",
"by",
"another",
"plugin",
".",
"This",
"is",
"necessary",
"due",
"to",
"https",
":",
"//",
"core",
".",
"trac",
".",
"wordpress",
".",
"org",
"/",
... | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/http.php#L133-L144 |
johnbillion/query-monitor | collectors/http.php | QM_Collector_HTTP.action_http_api_debug | public function action_http_api_debug( $response, $action, $class, $args, $url ) {
switch ( $action ) {
case 'response':
if ( ! empty( $class ) ) {
$this->data['http'][ $args['_qm_key'] ]['transport'] = str_replace( 'wp_http_', '', strtolower( $class ) );
} else {
$this->data['http'][ $args['_q... | php | public function action_http_api_debug( $response, $action, $class, $args, $url ) {
switch ( $action ) {
case 'response':
if ( ! empty( $class ) ) {
$this->data['http'][ $args['_qm_key'] ]['transport'] = str_replace( 'wp_http_', '', strtolower( $class ) );
} else {
$this->data['http'][ $args['_q... | [
"public",
"function",
"action_http_api_debug",
"(",
"$",
"response",
",",
"$",
"action",
",",
"$",
"class",
",",
"$",
"args",
",",
"$",
"url",
")",
"{",
"switch",
"(",
"$",
"action",
")",
"{",
"case",
"'response'",
":",
"if",
"(",
"!",
"empty",
"(",
... | Debugging action for the HTTP API.
@param mixed $response A parameter which varies depending on $action.
@param string $action The debug action. Currently one of 'response' or 'transports_list'.
@param string $class The HTTP transport class name.
@param array $args HTTP request arguments.
@param string $url... | [
"Debugging",
"action",
"for",
"the",
"HTTP",
"API",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/http.php#L155-L176 |
johnbillion/query-monitor | collectors/http.php | QM_Collector_HTTP.log_http_response | public function log_http_response( $response, array $args, $url ) {
$this->data['http'][ $args['_qm_key'] ]['end'] = microtime( true );
$this->data['http'][ $args['_qm_key'] ]['response'] = $response;
$this->data['http'][ $args['_qm_key'] ]['args'] = $args;
if ( isset( $args['_qm_original_key'] ) ) {
... | php | public function log_http_response( $response, array $args, $url ) {
$this->data['http'][ $args['_qm_key'] ]['end'] = microtime( true );
$this->data['http'][ $args['_qm_key'] ]['response'] = $response;
$this->data['http'][ $args['_qm_key'] ]['args'] = $args;
if ( isset( $args['_qm_original_key'] ) ) {
... | [
"public",
"function",
"log_http_response",
"(",
"$",
"response",
",",
"array",
"$",
"args",
",",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'http'",
"]",
"[",
"$",
"args",
"[",
"'_qm_key'",
"]",
"]",
"[",
"'end'",
"]",
"=",
"microtime",
... | Log an HTTP response.
@param array|WP_Error $response The HTTP response.
@param array $args HTTP request arguments.
@param string $url The request URL. | [
"Log",
"an",
"HTTP",
"response",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/http.php#L201-L218 |
johnbillion/query-monitor | dispatchers/REST.php | QM_Dispatcher_REST.filter_rest_post_dispatch | public function filter_rest_post_dispatch( WP_HTTP_Response $result, WP_REST_Server $server, WP_REST_Request $request ) {
if ( ! $this->should_dispatch() ) {
return $result;
}
$this->before_output();
/* @var QM_Output_Headers[] */
foreach ( $this->get_outputters( 'headers' ) as $id => $output ) {
$ou... | php | public function filter_rest_post_dispatch( WP_HTTP_Response $result, WP_REST_Server $server, WP_REST_Request $request ) {
if ( ! $this->should_dispatch() ) {
return $result;
}
$this->before_output();
/* @var QM_Output_Headers[] */
foreach ( $this->get_outputters( 'headers' ) as $id => $output ) {
$ou... | [
"public",
"function",
"filter_rest_post_dispatch",
"(",
"WP_HTTP_Response",
"$",
"result",
",",
"WP_REST_Server",
"$",
"server",
",",
"WP_REST_Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"should_dispatch",
"(",
")",
")",
"{",
"return... | Filters a REST API response in order to add QM's headers.
@param WP_HTTP_Response $result Result to send to the client. Usually a WP_REST_Response.
@param WP_REST_Server $server Server instance.
@param WP_REST_Request $request Request used to generate the response.
@return WP_HTTP_Response Result to send to the c... | [
"Filters",
"a",
"REST",
"API",
"response",
"in",
"order",
"to",
"add",
"QM",
"s",
"headers",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/dispatchers/REST.php#L27-L44 |
johnbillion/query-monitor | collectors/languages.php | QM_Collector_Languages.log_file_load | public function log_file_load( $override, $domain, $mofile ) {
if ( 'query-monitor' === $domain && self::hide_qm() ) {
return $override;
}
$trace = new QM_Backtrace();
$filtered = $trace->get_filtered_trace();
$caller = array();
foreach ( $filtered as $i => $item ) {
if ( in_array( $item['fun... | php | public function log_file_load( $override, $domain, $mofile ) {
if ( 'query-monitor' === $domain && self::hide_qm() ) {
return $override;
}
$trace = new QM_Backtrace();
$filtered = $trace->get_filtered_trace();
$caller = array();
foreach ( $filtered as $i => $item ) {
if ( in_array( $item['fun... | [
"public",
"function",
"log_file_load",
"(",
"$",
"override",
",",
"$",
"domain",
",",
"$",
"mofile",
")",
"{",
"if",
"(",
"'query-monitor'",
"===",
"$",
"domain",
"&&",
"self",
"::",
"hide_qm",
"(",
")",
")",
"{",
"return",
"$",
"override",
";",
"}",
... | Store log data.
@param bool $override Whether to override the text domain. Default false.
@param string $domain Text domain. Unique identifier for retrieving translated strings.
@param string $mofile Path to the MO file.
@return bool | [
"Store",
"log",
"data",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/languages.php#L79-L131 |
johnbillion/query-monitor | collectors/languages.php | QM_Collector_Languages.log_script_file_load | public function log_script_file_load( $file, $handle, $domain ) {
$trace = new QM_Backtrace();
$filtered = $trace->get_filtered_trace();
$caller = $filtered[0];
$this->data['languages'][ $domain ][] = array(
'caller' => $caller,
'domain' => $domain,
'file' => $file,
'found' => ( $file && fi... | php | public function log_script_file_load( $file, $handle, $domain ) {
$trace = new QM_Backtrace();
$filtered = $trace->get_filtered_trace();
$caller = $filtered[0];
$this->data['languages'][ $domain ][] = array(
'caller' => $caller,
'domain' => $domain,
'file' => $file,
'found' => ( $file && fi... | [
"public",
"function",
"log_script_file_load",
"(",
"$",
"file",
",",
"$",
"handle",
",",
"$",
"domain",
")",
"{",
"$",
"trace",
"=",
"new",
"QM_Backtrace",
"(",
")",
";",
"$",
"filtered",
"=",
"$",
"trace",
"->",
"get_filtered_trace",
"(",
")",
";",
"$... | Filters the file path for loading script translations for the given script handle and textdomain.
@param string|false $file Path to the translation file to load. False if there isn't one.
@param string $handle Name of the script to register a translation domain to.
@param string $domain The textdomain.
... | [
"Filters",
"the",
"file",
"path",
"for",
"loading",
"script",
"translations",
"for",
"the",
"given",
"script",
"handle",
"and",
"textdomain",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/languages.php#L142-L157 |
johnbillion/query-monitor | dispatchers/Redirect.php | QM_Dispatcher_Redirect.filter_wp_redirect | public function filter_wp_redirect( $location, $status ) {
if ( ! $this->should_dispatch() ) {
return $location;
}
$this->before_output();
/* @var QM_Output_Headers[] */
foreach ( $this->get_outputters( 'headers' ) as $id => $output ) {
$output->output();
}
$this->after_output();
return $loca... | php | public function filter_wp_redirect( $location, $status ) {
if ( ! $this->should_dispatch() ) {
return $location;
}
$this->before_output();
/* @var QM_Output_Headers[] */
foreach ( $this->get_outputters( 'headers' ) as $id => $output ) {
$output->output();
}
$this->after_output();
return $loca... | [
"public",
"function",
"filter_wp_redirect",
"(",
"$",
"location",
",",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"should_dispatch",
"(",
")",
")",
"{",
"return",
"$",
"location",
";",
"}",
"$",
"this",
"->",
"before_output",
"(",
")",... | Filters a redirect location in order to output QM's headers.
@param string $location The path to redirect to.
@param int $status Status code to use. | [
"Filters",
"a",
"redirect",
"location",
"in",
"order",
"to",
"output",
"QM",
"s",
"headers",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/dispatchers/Redirect.php#L25-L42 |
johnbillion/query-monitor | collectors/theme.php | QM_Collector_Theme.action_template_redirect | public function action_template_redirect() {
add_filter( 'template_include', array( $this, 'filter_template_include' ), PHP_INT_MAX );
foreach ( self::get_query_template_names() as $template => $conditional ) {
// If a matching theme-compat file is found, further conditional checks won't occur in template-load... | php | public function action_template_redirect() {
add_filter( 'template_include', array( $this, 'filter_template_include' ), PHP_INT_MAX );
foreach ( self::get_query_template_names() as $template => $conditional ) {
// If a matching theme-compat file is found, further conditional checks won't occur in template-load... | [
"public",
"function",
"action_template_redirect",
"(",
")",
"{",
"add_filter",
"(",
"'template_include'",
",",
"array",
"(",
"$",
"this",
",",
"'filter_template_include'",
")",
",",
"PHP_INT_MAX",
")",
";",
"foreach",
"(",
"self",
"::",
"get_query_template_names",
... | https://core.trac.wordpress.org/ticket/14310 | [
"https",
":",
"//",
"core",
".",
"trac",
".",
"wordpress",
".",
"org",
"/",
"ticket",
"/",
"14310"
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/theme.php#L87-L107 |
johnbillion/query-monitor | output/Html.php | QM_Output_Html.build_filter | protected function build_filter( $name, array $values, $label, $args = array() ) {
if ( empty( $values ) ) {
return esc_html( $label ); // Return label text, without being marked up as a label element.
}
if ( ! is_array( $args ) ) {
$args = array(
'highlight' => $args,
);
}
$args = array_merge... | php | protected function build_filter( $name, array $values, $label, $args = array() ) {
if ( empty( $values ) ) {
return esc_html( $label ); // Return label text, without being marked up as a label element.
}
if ( ! is_array( $args ) ) {
$args = array(
'highlight' => $args,
);
}
$args = array_merge... | [
"protected",
"function",
"build_filter",
"(",
"$",
"name",
",",
"array",
"$",
"values",
",",
"$",
"label",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"return",
"esc_html",
"(",
"$",
... | Returns the table filter controls. Safe for output.
@param string $name The name for the `data-` attributes that get filtered by this control.
@param string[] $values Option values for this control.
@param string $label Label text for the filter control.
@param array $args {
@type string $highlight The n... | [
"Returns",
"the",
"table",
"filter",
"controls",
".",
"Safe",
"for",
"output",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/output/Html.php#L232-L287 |
johnbillion/query-monitor | output/Html.php | QM_Output_Html.build_sorter | protected function build_sorter( $heading = '' ) {
$out = '';
$out .= '<label class="qm-th">';
$out .= '<span class="qm-sort-heading">';
if ( '#' === $heading ) {
$out .= '<span class="qm-screen-reader-text">' . esc_html__( 'Sequence', 'query-monitor' ) . '</span>';
} elseif ( $heading ) {
$out .= esc_... | php | protected function build_sorter( $heading = '' ) {
$out = '';
$out .= '<label class="qm-th">';
$out .= '<span class="qm-sort-heading">';
if ( '#' === $heading ) {
$out .= '<span class="qm-screen-reader-text">' . esc_html__( 'Sequence', 'query-monitor' ) . '</span>';
} elseif ( $heading ) {
$out .= esc_... | [
"protected",
"function",
"build_sorter",
"(",
"$",
"heading",
"=",
"''",
")",
"{",
"$",
"out",
"=",
"''",
";",
"$",
"out",
".=",
"'<label class=\"qm-th\">'",
";",
"$",
"out",
".=",
"'<span class=\"qm-sort-heading\">'",
";",
"if",
"(",
"'#'",
"===",
"$",
"h... | Returns the column sorter controls. Safe for output.
@param string $heading Heading text for the column. Optional.
@return string Markup for the column sorter controls. | [
"Returns",
"the",
"column",
"sorter",
"controls",
".",
"Safe",
"for",
"output",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/output/Html.php#L295-L312 |
johnbillion/query-monitor | output/Html.php | QM_Output_Html.format_sql | public static function format_sql( $sql ) {
$sql = str_replace( array( "\r\n", "\r", "\n", "\t" ), ' ', $sql );
$sql = esc_html( $sql );
$sql = trim( $sql );
$regex = 'ADD|AFTER|ALTER|AND|BEGIN|COMMIT|CREATE|DELETE|DESCRIBE|DO|DROP|ELSE|END|EXCEPT|EXPLAIN|FROM|GROUP|HAVING|INNER|INSERT|INTERSECT|LEFT|LIMIT|ON... | php | public static function format_sql( $sql ) {
$sql = str_replace( array( "\r\n", "\r", "\n", "\t" ), ' ', $sql );
$sql = esc_html( $sql );
$sql = trim( $sql );
$regex = 'ADD|AFTER|ALTER|AND|BEGIN|COMMIT|CREATE|DELETE|DESCRIBE|DO|DROP|ELSE|END|EXCEPT|EXPLAIN|FROM|GROUP|HAVING|INNER|INSERT|INTERSECT|LEFT|LIMIT|ON... | [
"public",
"static",
"function",
"format_sql",
"(",
"$",
"sql",
")",
"{",
"$",
"sql",
"=",
"str_replace",
"(",
"array",
"(",
"\"\\r\\n\"",
",",
"\"\\r\"",
",",
"\"\\n\"",
",",
"\"\\t\"",
")",
",",
"' '",
",",
"$",
"sql",
")",
";",
"$",
"sql",
"=",
"... | Returns the given SQL string in a nicely presented format. Safe for output.
@param string $sql An SQL query string.
@return string The SQL formatted with markup. | [
"Returns",
"the",
"given",
"SQL",
"string",
"in",
"a",
"nicely",
"presented",
"format",
".",
"Safe",
"for",
"output",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/output/Html.php#L339-L353 |
johnbillion/query-monitor | output/Html.php | QM_Output_Html.output_filename | public static function output_filename( $text, $file, $line = 0, $is_filename = false ) {
if ( empty( $file ) ) {
if ( $is_filename ) {
return esc_html( $text );
} else {
return '<code>' . esc_html( $text ) . '</code>';
}
}
$link_line = ( $line ) ? $line : 1;
if ( ! self::has_clickable_links... | php | public static function output_filename( $text, $file, $line = 0, $is_filename = false ) {
if ( empty( $file ) ) {
if ( $is_filename ) {
return esc_html( $text );
} else {
return '<code>' . esc_html( $text ) . '</code>';
}
}
$link_line = ( $line ) ? $line : 1;
if ( ! self::has_clickable_links... | [
"public",
"static",
"function",
"output_filename",
"(",
"$",
"text",
",",
"$",
"file",
",",
"$",
"line",
"=",
"0",
",",
"$",
"is_filename",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"if",
"(",
"$",
"is_filename",
... | Returns a file path, name, and line number, or a clickable link to the file. Safe for output.
@link https://querymonitor.com/blog/2019/02/clickable-stack-traces-and-function-names-in-query-monitor/
@param string $text The display text, such as a function name or file name.
@param string $file The full... | [
"Returns",
"a",
"file",
"path",
"name",
"and",
"line",
"number",
"or",
"a",
"clickable",
"link",
"to",
"the",
"file",
".",
"Safe",
"for",
"output",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/output/Html.php#L376-L425 |
johnbillion/query-monitor | classes/QueryMonitor.php | QueryMonitor.filter_user_has_cap | public function filter_user_has_cap( array $user_caps, array $required_caps, array $args, WP_User $user ) {
if ( 'view_query_monitor' !== $args[0] ) {
return $user_caps;
}
if ( array_key_exists( 'view_query_monitor', $user_caps ) ) {
return $user_caps;
}
if ( ! is_multisite() && user_can( $args[1], 'm... | php | public function filter_user_has_cap( array $user_caps, array $required_caps, array $args, WP_User $user ) {
if ( 'view_query_monitor' !== $args[0] ) {
return $user_caps;
}
if ( array_key_exists( 'view_query_monitor', $user_caps ) ) {
return $user_caps;
}
if ( ! is_multisite() && user_can( $args[1], 'm... | [
"public",
"function",
"filter_user_has_cap",
"(",
"array",
"$",
"user_caps",
",",
"array",
"$",
"required_caps",
",",
"array",
"$",
"args",
",",
"WP_User",
"$",
"user",
")",
"{",
"if",
"(",
"'view_query_monitor'",
"!==",
"$",
"args",
"[",
"0",
"]",
")",
... | Filter a user's capabilities so they can be altered at runtime.
This is used to:
- Grant the 'view_query_monitor' capability to the user if they have the ability to manage options.
This does not get called for Super Admins.
@param bool[] $user_caps Array of key/value pairs where keys represent a capability nam... | [
"Filter",
"a",
"user",
"s",
"capabilities",
"so",
"they",
"can",
"be",
"altered",
"at",
"runtime",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/classes/QueryMonitor.php#L76-L90 |
johnbillion/query-monitor | collectors/php_errors.php | QM_Collector_PHP_Errors.process | public function process() {
$this->types = array(
'errors' => array(
'warning' => _x( 'Warning', 'PHP error level', 'query-monitor' ),
'notice' => _x( 'Notice', 'PHP error level', 'query-monitor' ),
'strict' => _x( 'Strict', 'PHP error level', 'query-monitor' ),
'deprecated' => _x( '... | php | public function process() {
$this->types = array(
'errors' => array(
'warning' => _x( 'Warning', 'PHP error level', 'query-monitor' ),
'notice' => _x( 'Notice', 'PHP error level', 'query-monitor' ),
'strict' => _x( 'Strict', 'PHP error level', 'query-monitor' ),
'deprecated' => _x( '... | [
"public",
"function",
"process",
"(",
")",
"{",
"$",
"this",
"->",
"types",
"=",
"array",
"(",
"'errors'",
"=>",
"array",
"(",
"'warning'",
"=>",
"_x",
"(",
"'Warning'",
",",
"'PHP error level'",
",",
"'query-monitor'",
")",
",",
"'notice'",
"=>",
"_x",
... | Runs post-processing on the collected errors and updates the
errors collected in the data->errors property.
Any unreportable errors are placed in the data->filtered_errors
property. | [
"Runs",
"post",
"-",
"processing",
"on",
"the",
"collected",
"errors",
"and",
"updates",
"the",
"errors",
"collected",
"in",
"the",
"data",
"-",
">",
"errors",
"property",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/php_errors.php#L195-L287 |
johnbillion/query-monitor | collectors/php_errors.php | QM_Collector_PHP_Errors.filter_reportable_errors | public function filter_reportable_errors( array $components, $component_type ) {
$all_errors = $this->data['errors'];
foreach ( $components as $component_context => $allowed_level ) {
foreach ( $all_errors as $error_level => $errors ) {
foreach ( $errors as $error_id => $error ) {
if ( $this->is_report... | php | public function filter_reportable_errors( array $components, $component_type ) {
$all_errors = $this->data['errors'];
foreach ( $components as $component_context => $allowed_level ) {
foreach ( $all_errors as $error_level => $errors ) {
foreach ( $errors as $error_id => $error ) {
if ( $this->is_report... | [
"public",
"function",
"filter_reportable_errors",
"(",
"array",
"$",
"components",
",",
"$",
"component_type",
")",
"{",
"$",
"all_errors",
"=",
"$",
"this",
"->",
"data",
"[",
"'errors'",
"]",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component_co... | Filters the reportable PHP errors using the table specified. Users can customize the levels
using the `qm/collect/php_error_levels` filter.
@param int[] $components The error levels keyed by component name.
@param string $component_type The component type, for example 'plugin' or 'theme'. | [
"Filters",
"the",
"reportable",
"PHP",
"errors",
"using",
"the",
"table",
"specified",
".",
"Users",
"can",
"customize",
"the",
"levels",
"using",
"the",
"qm",
"/",
"collect",
"/",
"php_error_levels",
"filter",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/php_errors.php#L296-L321 |
johnbillion/query-monitor | collectors/php_errors.php | QM_Collector_PHP_Errors.is_affected_component | public function is_affected_component( $component, $component_type, $component_context ) {
if ( empty( $component ) ) {
return false;
}
return ( $component->type === $component_type && $component->context === $component_context );
} | php | public function is_affected_component( $component, $component_type, $component_context ) {
if ( empty( $component ) ) {
return false;
}
return ( $component->type === $component_type && $component->context === $component_context );
} | [
"public",
"function",
"is_affected_component",
"(",
"$",
"component",
",",
"$",
"component_type",
",",
"$",
"component_context",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"component",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"$",
"component... | Checks if the component is of the given type and has the given context. This is
used to scope an error to a plugin or theme.
@param object $component The component.
@param string $component_type The component type for comparison.
@param string $component_context The component context for comparison.
@return... | [
"Checks",
"if",
"the",
"component",
"is",
"of",
"the",
"given",
"type",
"and",
"has",
"the",
"given",
"context",
".",
"This",
"is",
"used",
"to",
"scope",
"an",
"error",
"to",
"a",
"plugin",
"or",
"theme",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/php_errors.php#L332-L337 |
johnbillion/query-monitor | collectors/php_errors.php | QM_Collector_PHP_Errors.is_reportable_error | public function is_reportable_error( $error_no, $flags ) {
if ( ! is_null( $flags ) ) {
$result = $error_no & $flags;
} else {
$result = 1;
}
return (bool) $result;
} | php | public function is_reportable_error( $error_no, $flags ) {
if ( ! is_null( $flags ) ) {
$result = $error_no & $flags;
} else {
$result = 1;
}
return (bool) $result;
} | [
"public",
"function",
"is_reportable_error",
"(",
"$",
"error_no",
",",
"$",
"flags",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"flags",
")",
")",
"{",
"$",
"result",
"=",
"$",
"error_no",
"&",
"$",
"flags",
";",
"}",
"else",
"{",
"$",
"result... | Checks if the error number specified is viewable based on the
flags specified.
@param int $error_no The errno from PHP
@param int $flags The config flags specified by users
@return int Truthy int value if reportable else 0.
Eg:- If a plugin had the config flags,
E_ALL & ~E_NOTICE
then,
is_reportable_error( E_NOTIC... | [
"Checks",
"if",
"the",
"error",
"number",
"specified",
"is",
"viewable",
"based",
"on",
"the",
"flags",
"specified",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/php_errors.php#L359-L367 |
johnbillion/query-monitor | collectors/caps.php | QM_Collector_Caps.filter_user_has_cap | public function filter_user_has_cap( array $user_caps, array $caps, array $args ) {
$trace = new QM_Backtrace();
$result = true;
foreach ( $caps as $cap ) {
if ( empty( $user_caps[ $cap ] ) ) {
$result = false;
break;
}
}
$this->data['caps'][] = array(
'args' => $args,
'trace' => $tr... | php | public function filter_user_has_cap( array $user_caps, array $caps, array $args ) {
$trace = new QM_Backtrace();
$result = true;
foreach ( $caps as $cap ) {
if ( empty( $user_caps[ $cap ] ) ) {
$result = false;
break;
}
}
$this->data['caps'][] = array(
'args' => $args,
'trace' => $tr... | [
"public",
"function",
"filter_user_has_cap",
"(",
"array",
"$",
"user_caps",
",",
"array",
"$",
"caps",
",",
"array",
"$",
"args",
")",
"{",
"$",
"trace",
"=",
"new",
"QM_Backtrace",
"(",
")",
";",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
... | Logs user capability checks.
This does not get called for Super Admins. See filter_map_meta_cap() below.
@param bool[] $user_caps Concerned user's capabilities.
@param string[] $required_caps Required primitive capabilities for the requested capability.
@param array $args {
Arguments that accompany the reque... | [
"Logs",
"user",
"capability",
"checks",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/caps.php#L76-L94 |
johnbillion/query-monitor | collectors/caps.php | QM_Collector_Caps.filter_map_meta_cap | public function filter_map_meta_cap( array $required_caps, $cap, $user_id, array $args ) {
if ( ! is_multisite() ) {
return $required_caps;
}
if ( ! is_super_admin( $user_id ) ) {
return $required_caps;
}
$trace = new QM_Backtrace();
$result = ( ! in_array( 'do_not_allow', $required_caps, true ) );... | php | public function filter_map_meta_cap( array $required_caps, $cap, $user_id, array $args ) {
if ( ! is_multisite() ) {
return $required_caps;
}
if ( ! is_super_admin( $user_id ) ) {
return $required_caps;
}
$trace = new QM_Backtrace();
$result = ( ! in_array( 'do_not_allow', $required_caps, true ) );... | [
"public",
"function",
"filter_map_meta_cap",
"(",
"array",
"$",
"required_caps",
",",
"$",
"cap",
",",
"$",
"user_id",
",",
"array",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"is_multisite",
"(",
")",
")",
"{",
"return",
"$",
"required_caps",
";",
"}",
"i... | Logs user capability checks for Super Admins on Multisite.
This is needed because the `user_has_cap` filter doesn't fire for Super Admins.
@param string[] $required_caps Required primitive capabilities for the requested capability.
@param string $cap Capability or meta capability being checked.
@param int... | [
"Logs",
"user",
"capability",
"checks",
"for",
"Super",
"Admins",
"on",
"Multisite",
"."
] | train | https://github.com/johnbillion/query-monitor/blob/f45006680bc6518f869958007388d9bd3cb37b62/collectors/caps.php#L111-L133 |
SocialiteProviders/Manager | src/OAuth1/AbstractProvider.php | AbstractProvider.user | public function user()
{
if (!$this->hasNecessaryVerifier()) {
throw new \InvalidArgumentException('Invalid request. Missing OAuth verifier.');
}
$token = $this->getToken();
$tokenCredentials = $token['tokenCredentials'];
$user = $this->mapUserToObject((array) $... | php | public function user()
{
if (!$this->hasNecessaryVerifier()) {
throw new \InvalidArgumentException('Invalid request. Missing OAuth verifier.');
}
$token = $this->getToken();
$tokenCredentials = $token['tokenCredentials'];
$user = $this->mapUserToObject((array) $... | [
"public",
"function",
"user",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasNecessaryVerifier",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid request. Missing OAuth verifier.'",
")",
";",
"}",
"$",
"token",
"=",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/AbstractProvider.php#L42-L66 |
SocialiteProviders/Manager | src/OAuth1/AbstractProvider.php | AbstractProvider.userFromTokenAndSecret | public function userFromTokenAndSecret($token, $secret)
{
$tokenCredentials = new TokenCredentials();
$tokenCredentials->setIdentifier($token);
$tokenCredentials->setSecret($secret);
$user = $this->mapUserToObject((array) $this->server->getUserDetails($tokenCredentials));
... | php | public function userFromTokenAndSecret($token, $secret)
{
$tokenCredentials = new TokenCredentials();
$tokenCredentials->setIdentifier($token);
$tokenCredentials->setSecret($secret);
$user = $this->mapUserToObject((array) $this->server->getUserDetails($tokenCredentials));
... | [
"public",
"function",
"userFromTokenAndSecret",
"(",
"$",
"token",
",",
"$",
"secret",
")",
"{",
"$",
"tokenCredentials",
"=",
"new",
"TokenCredentials",
"(",
")",
";",
"$",
"tokenCredentials",
"->",
"setIdentifier",
"(",
"$",
"token",
")",
";",
"$",
"tokenC... | {@inheritdoc} | [
"{"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/AbstractProvider.php#L71-L83 |
SocialiteProviders/Manager | src/OAuth1/AbstractProvider.php | AbstractProvider.redirect | public function redirect()
{
if (!$this->isStateless()) {
$this->request->getSession()->put(
'oauth.temp', $temp = $this->server->getTemporaryCredentials()
);
} else {
$temp = $this->server->getTemporaryCredentials();
$this->request->se... | php | public function redirect()
{
if (!$this->isStateless()) {
$this->request->getSession()->put(
'oauth.temp', $temp = $this->server->getTemporaryCredentials()
);
} else {
$temp = $this->server->getTemporaryCredentials();
$this->request->se... | [
"public",
"function",
"redirect",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isStateless",
"(",
")",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"put",
"(",
"'oauth.temp'",
",",
"$",
"temp",
"=",
"$",
"this",... | Redirect the user to the authentication page for the provider.
@return RedirectResponse | [
"Redirect",
"the",
"user",
"to",
"the",
"authentication",
"page",
"for",
"the",
"provider",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/AbstractProvider.php#L90-L102 |
SocialiteProviders/Manager | src/OAuth1/AbstractProvider.php | AbstractProvider.setConfig | public function setConfig(Config $config)
{
$this->config = $this->server->setConfig($config);
return $this;
} | php | public function setConfig(Config $config)
{
$this->config = $this->server->setConfig($config);
return $this;
} | [
"public",
"function",
"setConfig",
"(",
"Config",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"server",
"->",
"setConfig",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
";",
"}"
] | @param Config $config
@return $this | [
"@param",
"Config",
"$config"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/AbstractProvider.php#L151-L156 |
SocialiteProviders/Manager | src/OAuth1/AbstractProvider.php | AbstractProvider.getToken | protected function getToken()
{
if (!$this->isStateless()) {
$temp = $this->request->getSession()->get('oauth.temp');
return $this->server->getTokenCredentials(
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);
}
... | php | protected function getToken()
{
if (!$this->isStateless()) {
$temp = $this->request->getSession()->get('oauth.temp');
return $this->server->getTokenCredentials(
$temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
);
}
... | [
"protected",
"function",
"getToken",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isStateless",
"(",
")",
")",
"{",
"$",
"temp",
"=",
"$",
"this",
"->",
"request",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"'oauth.temp'",
")",
";",
"ret... | Get the token credentials for the request.
@return \League\OAuth1\Client\Credentials\TokenCredentials | [
"Get",
"the",
"token",
"credentials",
"for",
"the",
"request",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/AbstractProvider.php#L163-L177 |
SocialiteProviders/Manager | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
parent::register();
if (class_exists('Laravel\Lumen\Application') && !defined('SOCIALITEPROVIDERS_STATELESS')) {
define('SOCIALITEPROVIDERS_STATELESS', true);
}
$this->app->singleton(ConfigRetrieverInterface::class, function () {
... | php | public function register()
{
parent::register();
if (class_exists('Laravel\Lumen\Application') && !defined('SOCIALITEPROVIDERS_STATELESS')) {
define('SOCIALITEPROVIDERS_STATELESS', true);
}
$this->app->singleton(ConfigRetrieverInterface::class, function () {
... | [
"public",
"function",
"register",
"(",
")",
"{",
"parent",
"::",
"register",
"(",
")",
";",
"if",
"(",
"class_exists",
"(",
"'Laravel\\Lumen\\Application'",
")",
"&&",
"!",
"defined",
"(",
"'SOCIALITEPROVIDERS_STATELESS'",
")",
")",
"{",
"define",
"(",
"'SOCIA... | Register the provider services. | [
"Register",
"the",
"provider",
"services",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/ServiceProvider.php#L24-L35 |
SocialiteProviders/Manager | src/Helpers/ConfigRetriever.php | ConfigRetriever.fromServices | public function fromServices($providerName, array $additionalConfigKeys = [])
{
$this->providerName = $providerName;
$this->getConfigFromServicesArray($providerName);
$this->additionalConfigKeys = $additionalConfigKeys = array_unique($additionalConfigKeys + ['guzzle']);
return new ... | php | public function fromServices($providerName, array $additionalConfigKeys = [])
{
$this->providerName = $providerName;
$this->getConfigFromServicesArray($providerName);
$this->additionalConfigKeys = $additionalConfigKeys = array_unique($additionalConfigKeys + ['guzzle']);
return new ... | [
"public",
"function",
"fromServices",
"(",
"$",
"providerName",
",",
"array",
"$",
"additionalConfigKeys",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"providerName",
"=",
"$",
"providerName",
";",
"$",
"this",
"->",
"getConfigFromServicesArray",
"(",
"$",
"... | @param string $providerName
@param array $additionalConfigKeys
@return \SocialiteProviders\Manager\Contracts\ConfigInterface
@throws \SocialiteProviders\Manager\Exception\MissingConfigException | [
"@param",
"string",
"$providerName",
"@param",
"array",
"$additionalConfigKeys"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/Helpers/ConfigRetriever.php#L40-L55 |
SocialiteProviders/Manager | src/Helpers/ConfigRetriever.php | ConfigRetriever.retrieveItemsFromConfig | protected function retrieveItemsFromConfig(array $keys, Closure $keyRetrievalClosure)
{
$out = [];
foreach ($keys as $key) {
$out[$key] = $keyRetrievalClosure($key);
}
return $out;
} | php | protected function retrieveItemsFromConfig(array $keys, Closure $keyRetrievalClosure)
{
$out = [];
foreach ($keys as $key) {
$out[$key] = $keyRetrievalClosure($key);
}
return $out;
} | [
"protected",
"function",
"retrieveItemsFromConfig",
"(",
"array",
"$",
"keys",
",",
"Closure",
"$",
"keyRetrievalClosure",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"out",
"[",
"$",
"key",
... | @param array $keys
@param \Closure $keyRetrievalClosure
@return array | [
"@param",
"array",
"$keys",
"@param",
"\\",
"Closure",
"$keyRetrievalClosure"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/Helpers/ConfigRetriever.php#L74-L83 |
SocialiteProviders/Manager | src/Helpers/ConfigRetriever.php | ConfigRetriever.getFromServices | protected function getFromServices($key)
{
$keyExists = array_key_exists($key, $this->servicesArray);
// ADDITIONAL value is empty
if (!$keyExists && $this->isAdditionalConfig($key)) {
return $key == 'guzzle' ? [] : null ;
}
// REQUIRED value is empty
if... | php | protected function getFromServices($key)
{
$keyExists = array_key_exists($key, $this->servicesArray);
// ADDITIONAL value is empty
if (!$keyExists && $this->isAdditionalConfig($key)) {
return $key == 'guzzle' ? [] : null ;
}
// REQUIRED value is empty
if... | [
"protected",
"function",
"getFromServices",
"(",
"$",
"key",
")",
"{",
"$",
"keyExists",
"=",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"servicesArray",
")",
";",
"// ADDITIONAL value is empty",
"if",
"(",
"!",
"$",
"keyExists",
"&&",
"$",... | @param string $key
@return string
@throws \SocialiteProviders\Manager\Exception\MissingConfigException | [
"@param",
"string",
"$key"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/Helpers/ConfigRetriever.php#L92-L107 |
SocialiteProviders/Manager | src/Helpers/ConfigRetriever.php | ConfigRetriever.getConfigFromServicesArray | protected function getConfigFromServicesArray($providerName)
{
$configArray = config("services.{$providerName}");
if (empty($configArray)) {
// If we are running in console we should spoof values to make Socialite happy...
if (app()->runningInConsole()) {
$co... | php | protected function getConfigFromServicesArray($providerName)
{
$configArray = config("services.{$providerName}");
if (empty($configArray)) {
// If we are running in console we should spoof values to make Socialite happy...
if (app()->runningInConsole()) {
$co... | [
"protected",
"function",
"getConfigFromServicesArray",
"(",
"$",
"providerName",
")",
"{",
"$",
"configArray",
"=",
"config",
"(",
"\"services.{$providerName}\"",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"configArray",
")",
")",
"{",
"// If we are running in console ... | @param string $providerName
@return array
@throws \SocialiteProviders\Manager\Exception\MissingConfigException | [
"@param",
"string",
"$providerName"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/Helpers/ConfigRetriever.php#L116-L134 |
SocialiteProviders/Manager | src/OAuth1/Server.php | Server.getTokenCredentials | public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verifier)
{
if ($temporaryIdentifier !== $temporaryCredentials->getIdentifier()) {
throw new \InvalidArgumentException(
'Temporary identifier passed back by server does not matc... | php | public function getTokenCredentials(TemporaryCredentials $temporaryCredentials, $temporaryIdentifier, $verifier)
{
if ($temporaryIdentifier !== $temporaryCredentials->getIdentifier()) {
throw new \InvalidArgumentException(
'Temporary identifier passed back by server does not matc... | [
"public",
"function",
"getTokenCredentials",
"(",
"TemporaryCredentials",
"$",
"temporaryCredentials",
",",
"$",
"temporaryIdentifier",
",",
"$",
"verifier",
")",
"{",
"if",
"(",
"$",
"temporaryIdentifier",
"!==",
"$",
"temporaryCredentials",
"->",
"getIdentifier",
"(... | Retrieves token credentials by passing in the temporary credentials,
the temporary credentials identifier as passed back by the server
and finally the verifier code.
@param \League\OAuth1\Client\Credentials\TemporaryCredentials $temporaryCredentials
@param string $tempor... | [
"Retrieves",
"token",
"credentials",
"by",
"passing",
"in",
"the",
"temporary",
"credentials",
"the",
"temporary",
"credentials",
"identifier",
"as",
"passed",
"back",
"by",
"the",
"server",
"and",
"finally",
"the",
"verifier",
"code",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/OAuth1/Server.php#L47-L80 |
SocialiteProviders/Manager | src/SocialiteWasCalled.php | SocialiteWasCalled.extendSocialite | public function extendSocialite($providerName, $providerClass, $oauth1Server = null)
{
/** @var SocialiteManager $socialite */
$socialite = $this->app->make(SocialiteFactory::class);
$this->classExists($providerClass);
if ($this->isOAuth1($oauth1Server)) {
$this->classEx... | php | public function extendSocialite($providerName, $providerClass, $oauth1Server = null)
{
/** @var SocialiteManager $socialite */
$socialite = $this->app->make(SocialiteFactory::class);
$this->classExists($providerClass);
if ($this->isOAuth1($oauth1Server)) {
$this->classEx... | [
"public",
"function",
"extendSocialite",
"(",
"$",
"providerName",
",",
"$",
"providerClass",
",",
"$",
"oauth1Server",
"=",
"null",
")",
"{",
"/** @var SocialiteManager $socialite */",
"$",
"socialite",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"Sociali... | @param string $providerName 'meetup'
@param string $providerClass 'Your\Name\Space\ClassNameProvider' must extend
either Laravel\Socialite\Two\AbstractProvider or
Laravel\Socialite\One\AbstractProvider
@param string $oauth1Server 'Your\Name\Space\ClassNameServer' must extend League\OAuth1\Client\Server\Server
@retur... | [
"@param",
"string",
"$providerName",
"meetup",
"@param",
"string",
"$providerClass",
"Your",
"\\",
"Name",
"\\",
"Space",
"\\",
"ClassNameProvider",
"must",
"extend",
"either",
"Laravel",
"\\",
"Socialite",
"\\",
"Two",
"\\",
"AbstractProvider",
"or",
"Laravel",
"... | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/SocialiteWasCalled.php#L58-L80 |
SocialiteProviders/Manager | src/SocialiteWasCalled.php | SocialiteWasCalled.buildProvider | protected function buildProvider(SocialiteManager $socialite, $providerName, $providerClass, $oauth1Server)
{
if ($this->isOAuth1($oauth1Server)) {
return $this->buildOAuth1Provider($socialite, $providerClass, $providerName, $oauth1Server);
}
return $this->buildOAuth2Provider($s... | php | protected function buildProvider(SocialiteManager $socialite, $providerName, $providerClass, $oauth1Server)
{
if ($this->isOAuth1($oauth1Server)) {
return $this->buildOAuth1Provider($socialite, $providerClass, $providerName, $oauth1Server);
}
return $this->buildOAuth2Provider($s... | [
"protected",
"function",
"buildProvider",
"(",
"SocialiteManager",
"$",
"socialite",
",",
"$",
"providerName",
",",
"$",
"providerClass",
",",
"$",
"oauth1Server",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOAuth1",
"(",
"$",
"oauth1Server",
")",
")",
"{",
... | @param \Laravel\Socialite\SocialiteManager $socialite
@param string $providerName
@param string $providerClass
@param null|string $oauth1Server
@return \Laravel\Socialite\One\AbstractProvider|\Laravel\Socialite\Two\AbstractProvider
@thr... | [
"@param",
"\\",
"Laravel",
"\\",
"Socialite",
"\\",
"SocialiteManager",
"$socialite",
"@param",
"string",
"$providerName",
"@param",
"string",
"$providerClass",
"@param",
"null|string",
"$oauth1Server"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/SocialiteWasCalled.php#L92-L99 |
SocialiteProviders/Manager | src/SocialiteWasCalled.php | SocialiteWasCalled.buildOAuth1Provider | protected function buildOAuth1Provider(SocialiteManager $socialite, $providerClass, $providerName, $oauth1Server)
{
$this->classExtends($oauth1Server, OAuth1Server::class);
$config = $this->getConfig($providerClass, $providerName);
$configServer = $socialite->formatConfig($config->get());
... | php | protected function buildOAuth1Provider(SocialiteManager $socialite, $providerClass, $providerName, $oauth1Server)
{
$this->classExtends($oauth1Server, OAuth1Server::class);
$config = $this->getConfig($providerClass, $providerName);
$configServer = $socialite->formatConfig($config->get());
... | [
"protected",
"function",
"buildOAuth1Provider",
"(",
"SocialiteManager",
"$",
"socialite",
",",
"$",
"providerClass",
",",
"$",
"providerName",
",",
"$",
"oauth1Server",
")",
"{",
"$",
"this",
"->",
"classExtends",
"(",
"$",
"oauth1Server",
",",
"OAuth1Server",
... | Build an OAuth 1 provider instance.
@param \Laravel\Socialite\SocialiteManager $socialite
@param string $providerClass must extend Laravel\Socialite\One\AbstractProvider
@param string $providerName
@param string $oauth1Server must extend League\OAuth1\Client\Server\Server
@return \Laravel\Socialite\One\AbstractProvi... | [
"Build",
"an",
"OAuth",
"1",
"provider",
"instance",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/SocialiteWasCalled.php#L113-L128 |
SocialiteProviders/Manager | src/SocialiteWasCalled.php | SocialiteWasCalled.buildOAuth2Provider | protected function buildOAuth2Provider(SocialiteManager $socialite, $providerClass, $providerName)
{
$this->classExtends($providerClass, SocialiteOAuth2AbstractProvider::class);
$config = $this->getConfig($providerClass, $providerName);
$provider = $socialite->buildProvider($providerClass,... | php | protected function buildOAuth2Provider(SocialiteManager $socialite, $providerClass, $providerName)
{
$this->classExtends($providerClass, SocialiteOAuth2AbstractProvider::class);
$config = $this->getConfig($providerClass, $providerName);
$provider = $socialite->buildProvider($providerClass,... | [
"protected",
"function",
"buildOAuth2Provider",
"(",
"SocialiteManager",
"$",
"socialite",
",",
"$",
"providerClass",
",",
"$",
"providerName",
")",
"{",
"$",
"this",
"->",
"classExtends",
"(",
"$",
"providerClass",
",",
"SocialiteOAuth2AbstractProvider",
"::",
"cla... | Build an OAuth 2 provider instance.
@param SocialiteManager $socialite
@param string $providerClass must extend Laravel\Socialite\Two\AbstractProvider
@param string $providerName
@return \Laravel\Socialite\Two\AbstractProvider
@throws \SocialiteProviders\Manager\Exception\MissingConfigException | [
"Build",
"an",
"OAuth",
"2",
"provider",
"instance",
"."
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/SocialiteWasCalled.php#L141-L152 |
SocialiteProviders/Manager | src/ConfigTrait.php | ConfigTrait.getConfig | protected function getConfig($key = null, $default = null)
{
// check manually if a key is given and if it exists in the config
// this has to be done to check for spoofed additional config keys so that null isn't returned
if (!empty($key) && empty($this->config[$key])) {
return ... | php | protected function getConfig($key = null, $default = null)
{
// check manually if a key is given and if it exists in the config
// this has to be done to check for spoofed additional config keys so that null isn't returned
if (!empty($key) && empty($this->config[$key])) {
return ... | [
"protected",
"function",
"getConfig",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"// check manually if a key is given and if it exists in the config",
"// this has to be done to check for spoofed additional config keys so that null isn't returned",
"i... | @param string $key
@param mixed $default
@return mixed|array | [
"@param",
"string",
"$key",
"@param",
"mixed",
"$default"
] | train | https://github.com/SocialiteProviders/Manager/blob/f9fc2d8b454f7b44b5f1d70d1769a76bebfea972/src/ConfigTrait.php#L43-L52 |
fico7489/laravel-pivot | src/Traits/ExtendFireModelEventTrait.php | ExtendFireModelEventTrait.fireModelEvent | public function fireModelEvent($event, $halt = true, $relationName = null, $ids = [], $idsAttributes = [])
{
if (!isset(static::$dispatcher)) {
return true;
}
// First, we will get the proper method to call on the event dispatcher, and then we
// will attempt to fire a c... | php | public function fireModelEvent($event, $halt = true, $relationName = null, $ids = [], $idsAttributes = [])
{
if (!isset(static::$dispatcher)) {
return true;
}
// First, we will get the proper method to call on the event dispatcher, and then we
// will attempt to fire a c... | [
"public",
"function",
"fireModelEvent",
"(",
"$",
"event",
",",
"$",
"halt",
"=",
"true",
",",
"$",
"relationName",
"=",
"null",
",",
"$",
"ids",
"=",
"[",
"]",
",",
"$",
"idsAttributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"st... | Fire the given event for the model.
@param string $event
@param bool $halt
@return mixed | [
"Fire",
"the",
"given",
"event",
"for",
"the",
"model",
"."
] | train | https://github.com/fico7489/laravel-pivot/blob/5de4a1d95c035282b7291c8e43341b2284ca9053/src/Traits/ExtendFireModelEventTrait.php#L15-L39 |
fico7489/laravel-pivot | src/Traits/FiresPivotEventsTrait.php | FiresPivotEventsTrait.attach | public function attach($ids, array $attributes = [], $touch = true)
{
list($idsOnly, $idsAttributes) = $this->getIdsWithAttributes($ids, $attributes);
$this->parent->fireModelEvent('pivotAttaching', true, $this->getRelationName(), $idsOnly, $idsAttributes);
$parentResult = parent::attach($i... | php | public function attach($ids, array $attributes = [], $touch = true)
{
list($idsOnly, $idsAttributes) = $this->getIdsWithAttributes($ids, $attributes);
$this->parent->fireModelEvent('pivotAttaching', true, $this->getRelationName(), $idsOnly, $idsAttributes);
$parentResult = parent::attach($i... | [
"public",
"function",
"attach",
"(",
"$",
"ids",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"list",
"(",
"$",
"idsOnly",
",",
"$",
"idsAttributes",
")",
"=",
"$",
"this",
"->",
"getIdsWithAttributes",
"(... | Attach a model to the parent.
@param mixed $id
@param array $attributes
@param bool $touch | [
"Attach",
"a",
"model",
"to",
"the",
"parent",
"."
] | train | https://github.com/fico7489/laravel-pivot/blob/5de4a1d95c035282b7291c8e43341b2284ca9053/src/Traits/FiresPivotEventsTrait.php#L17-L26 |
fico7489/laravel-pivot | src/Traits/FiresPivotEventsTrait.php | FiresPivotEventsTrait.detach | public function detach($ids = null, $touch = true)
{
if (is_null($ids)) {
$ids = $this->query->pluck($this->query->qualifyColumn($this->relatedKey))->toArray();
}
list($idsOnly) = $this->getIdsWithAttributes($ids);
$this->parent->fireModelEvent('pivotDetaching', true, $... | php | public function detach($ids = null, $touch = true)
{
if (is_null($ids)) {
$ids = $this->query->pluck($this->query->qualifyColumn($this->relatedKey))->toArray();
}
list($idsOnly) = $this->getIdsWithAttributes($ids);
$this->parent->fireModelEvent('pivotDetaching', true, $... | [
"public",
"function",
"detach",
"(",
"$",
"ids",
"=",
"null",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"ids",
")",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"query",
"->",
"pluck",
"(",
"$",
"this",
"->",
... | Detach models from the relationship.
@param mixed $ids
@param bool $touch
@return int | [
"Detach",
"models",
"from",
"the",
"relationship",
"."
] | train | https://github.com/fico7489/laravel-pivot/blob/5de4a1d95c035282b7291c8e43341b2284ca9053/src/Traits/FiresPivotEventsTrait.php#L36-L49 |
fico7489/laravel-pivot | src/Traits/FiresPivotEventsTrait.php | FiresPivotEventsTrait.updateExistingPivot | public function updateExistingPivot($id, array $attributes, $touch = true)
{
list($idsOnly, $idsAttributes) = $this->getIdsWithAttributes($id, $attributes);
$this->parent->fireModelEvent('pivotUpdating', true, $this->getRelationName(), $idsOnly, $idsAttributes);
$parentResult = parent::upda... | php | public function updateExistingPivot($id, array $attributes, $touch = true)
{
list($idsOnly, $idsAttributes) = $this->getIdsWithAttributes($id, $attributes);
$this->parent->fireModelEvent('pivotUpdating', true, $this->getRelationName(), $idsOnly, $idsAttributes);
$parentResult = parent::upda... | [
"public",
"function",
"updateExistingPivot",
"(",
"$",
"id",
",",
"array",
"$",
"attributes",
",",
"$",
"touch",
"=",
"true",
")",
"{",
"list",
"(",
"$",
"idsOnly",
",",
"$",
"idsAttributes",
")",
"=",
"$",
"this",
"->",
"getIdsWithAttributes",
"(",
"$",... | Update an existing pivot record on the table.
@param mixed $id
@param array $attributes
@param bool $touch
@return int | [
"Update",
"an",
"existing",
"pivot",
"record",
"on",
"the",
"table",
"."
] | train | https://github.com/fico7489/laravel-pivot/blob/5de4a1d95c035282b7291c8e43341b2284ca9053/src/Traits/FiresPivotEventsTrait.php#L60-L69 |
fico7489/laravel-pivot | src/Traits/FiresPivotEventsTrait.php | FiresPivotEventsTrait.getIdsWithAttributes | private function getIdsWithAttributes($id, $attributes = [])
{
$ids = [];
if ($id instanceof Model) {
$ids[$id->getKey()] = $attributes;
} elseif ($id instanceof Collection) {
foreach ($id as $model) {
$ids[$model->getKey()] = $attributes;
... | php | private function getIdsWithAttributes($id, $attributes = [])
{
$ids = [];
if ($id instanceof Model) {
$ids[$id->getKey()] = $attributes;
} elseif ($id instanceof Collection) {
foreach ($id as $model) {
$ids[$model->getKey()] = $attributes;
... | [
"private",
"function",
"getIdsWithAttributes",
"(",
"$",
"id",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"id",
"instanceof",
"Model",
")",
"{",
"$",
"ids",
"[",
"$",
"id",
"->",
"getKey",
"("... | Cleans the ids and ids with attributes
Returns an array with and array of ids and array of id => attributes.
@param mixed $id
@param array $attributes
@return array | [
"Cleans",
"the",
"ids",
"and",
"ids",
"with",
"attributes",
"Returns",
"an",
"array",
"with",
"and",
"array",
"of",
"ids",
"and",
"array",
"of",
"id",
"=",
">",
"attributes",
"."
] | train | https://github.com/fico7489/laravel-pivot/blob/5de4a1d95c035282b7291c8e43341b2284ca9053/src/Traits/FiresPivotEventsTrait.php#L80-L105 |
ActiveCampaign/activecampaign-api-php | includes/ActiveCampaign.class.php | ActiveCampaign.version | function version($version) {
$this->version = (int)$version;
if ($version == 2) {
$this->url_base = $this->url_base . "/2";
}
} | php | function version($version) {
$this->version = (int)$version;
if ($version == 2) {
$this->url_base = $this->url_base . "/2";
}
} | [
"function",
"version",
"(",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"version",
"=",
"(",
"int",
")",
"$",
"version",
";",
"if",
"(",
"$",
"version",
"==",
"2",
")",
"{",
"$",
"this",
"->",
"url_base",
"=",
"$",
"this",
"->",
"url_base",
".",... | Set the version on the url
@param $version | [
"Set",
"the",
"version",
"on",
"the",
"url"
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/ActiveCampaign.class.php#L78-L83 |
ActiveCampaign/activecampaign-api-php | includes/ActiveCampaign.class.php | ActiveCampaign.api | function api($path, $post_data = array()) {
// IE: "contact/view"
$components = explode("/", $path);
$component = $components[0];
if (count($components) > 2) {
// IE: "contact/tag/add?whatever"
// shift off the first item (the component, IE: "contact").
array_shift($components);
// IE: convert to "... | php | function api($path, $post_data = array()) {
// IE: "contact/view"
$components = explode("/", $path);
$component = $components[0];
if (count($components) > 2) {
// IE: "contact/tag/add?whatever"
// shift off the first item (the component, IE: "contact").
array_shift($components);
// IE: convert to "... | [
"function",
"api",
"(",
"$",
"path",
",",
"$",
"post_data",
"=",
"array",
"(",
")",
")",
"{",
"// IE: \"contact/view\"",
"$",
"components",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"path",
")",
";",
"$",
"component",
"=",
"$",
"components",
"[",
"0",
... | Make api calls
@param $path
@param array $post_data
@return mixed | [
"Make",
"api",
"calls"
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/ActiveCampaign.class.php#L93-L171 |
ActiveCampaign/activecampaign-api-php | includes/Connector.class.php | AC_Connector.dbg | public function dbg($var, $continue = 0, $element = "pre", $extra = "") {
echo "<" . $element . ">";
echo "Vartype: " . gettype($var) . "\n";
if ( is_array($var) ) echo "Elements: " . count($var) . "\n";
elseif ( is_string($var) ) echo "Length: " . strlen($var) . "\n";
if ($extra) {
echo $extra... | php | public function dbg($var, $continue = 0, $element = "pre", $extra = "") {
echo "<" . $element . ">";
echo "Vartype: " . gettype($var) . "\n";
if ( is_array($var) ) echo "Elements: " . count($var) . "\n";
elseif ( is_string($var) ) echo "Length: " . strlen($var) . "\n";
if ($extra) {
echo $extra... | [
"public",
"function",
"dbg",
"(",
"$",
"var",
",",
"$",
"continue",
"=",
"0",
",",
"$",
"element",
"=",
"\"pre\"",
",",
"$",
"extra",
"=",
"\"\"",
")",
"{",
"echo",
"\"<\"",
".",
"$",
"element",
".",
"\">\"",
";",
"echo",
"\"Vartype: \"",
".",
"get... | Debug helper function
@param $var
@param int $continue
@param string $element
@param string $extra | [
"Debug",
"helper",
"function"
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/Connector.class.php#L91-L103 |
ActiveCampaign/activecampaign-api-php | includes/Connector.class.php | AC_Connector.curl | public function curl($url, $params_data = array(), $verb = "", $custom_method = "") {
if ($this->version == 1) {
// find the method from the URL.
$method = preg_match("/api_action=[^&]*/i", $url, $matches);
if ($matches) {
$method = preg_match("/[^=]*$/i", $matches[0], $matches2);
$method = $ma... | php | public function curl($url, $params_data = array(), $verb = "", $custom_method = "") {
if ($this->version == 1) {
// find the method from the URL.
$method = preg_match("/api_action=[^&]*/i", $url, $matches);
if ($matches) {
$method = preg_match("/[^=]*$/i", $matches[0], $matches2);
$method = $ma... | [
"public",
"function",
"curl",
"(",
"$",
"url",
",",
"$",
"params_data",
"=",
"array",
"(",
")",
",",
"$",
"verb",
"=",
"\"\"",
",",
"$",
"custom_method",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"version",
"==",
"1",
")",
"{",
"// fin... | Make the curl request
@param $url
@param array $params_data
@param string $verb
@param string $custom_method
@return mixed
@throws \RequestException | [
"Make",
"the",
"curl",
"request"
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/Connector.class.php#L134-L346 |
ActiveCampaign/activecampaign-api-php | includes/Tracking.class.php | AC_Tracking.site_status | function site_status($params, $post_data) {
// version 2 only.
$request_url = "{$this->url_base}/track/site";
$response = $this->curl($request_url, $post_data, "POST", "tracking_site_status");
return $response;
} | php | function site_status($params, $post_data) {
// version 2 only.
$request_url = "{$this->url_base}/track/site";
$response = $this->curl($request_url, $post_data, "POST", "tracking_site_status");
return $response;
} | [
"function",
"site_status",
"(",
"$",
"params",
",",
"$",
"post_data",
")",
"{",
"// version 2 only.",
"$",
"request_url",
"=",
"\"{$this->url_base}/track/site\"",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"curl",
"(",
"$",
"request_url",
",",
"$",
"post_da... | /*
Update the status (enabled or disabled) for site tracking. | [
"/",
"*",
"Update",
"the",
"status",
"(",
"enabled",
"or",
"disabled",
")",
"for",
"site",
"tracking",
"."
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/Tracking.class.php#L20-L25 |
ActiveCampaign/activecampaign-api-php | includes/Tracking.class.php | AC_Tracking.event_status | function event_status($params, $post_data) {
// version 2 only.
$request_url = "{$this->url_base}/track/event";
$response = $this->curl($request_url, $post_data, "POST", "tracking_event_status");
return $response;
} | php | function event_status($params, $post_data) {
// version 2 only.
$request_url = "{$this->url_base}/track/event";
$response = $this->curl($request_url, $post_data, "POST", "tracking_event_status");
return $response;
} | [
"function",
"event_status",
"(",
"$",
"params",
",",
"$",
"post_data",
")",
"{",
"// version 2 only.",
"$",
"request_url",
"=",
"\"{$this->url_base}/track/event\"",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"curl",
"(",
"$",
"request_url",
",",
"$",
"post_... | /*
Update the status (enabled or disabled) for event tracking. | [
"/",
"*",
"Update",
"the",
"status",
"(",
"enabled",
"or",
"disabled",
")",
"for",
"event",
"tracking",
"."
] | train | https://github.com/ActiveCampaign/activecampaign-api-php/blob/2bf5b72ba8668de8dcb27e194948028276e748c5/includes/Tracking.class.php#L30-L35 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.