repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
stripe/stripe-php | lib/Util/Util.php | Util.secureCompare | public static function secureCompare($a, $b)
{
if (self::$isHashEqualsAvailable === null) {
self::$isHashEqualsAvailable = function_exists('hash_equals');
}
if (self::$isHashEqualsAvailable) {
return hash_equals($a, $b);
} else {
if (strlen($a) !=... | php | public static function secureCompare($a, $b)
{
if (self::$isHashEqualsAvailable === null) {
self::$isHashEqualsAvailable = function_exists('hash_equals');
}
if (self::$isHashEqualsAvailable) {
return hash_equals($a, $b);
} else {
if (strlen($a) !=... | [
"public",
"static",
"function",
"secureCompare",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"isHashEqualsAvailable",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"isHashEqualsAvailable",
"=",
"function_exists",
"(",
"'hash_equals'",... | Compares two strings for equality. The time taken is independent of the
number of characters that match.
@param string $a one of the strings to compare.
@param string $b the other string to compare.
@return bool true if the strings are equal, false otherwise. | [
"Compares",
"two",
"strings",
"for",
"equality",
".",
"The",
"time",
"taken",
"is",
"independent",
"of",
"the",
"number",
"of",
"characters",
"that",
"match",
"."
] | 8f74cbe130f962d96d4ba92e75a44396a40cf41a | https://github.com/stripe/stripe-php/blob/8f74cbe130f962d96d4ba92e75a44396a40cf41a/lib/Util/Util.php#L201-L220 | train |
stripe/stripe-php | lib/Util/Util.php | Util.objectsToIds | public static function objectsToIds($h)
{
if ($h instanceof \Stripe\ApiResource) {
return $h->id;
} elseif (static::isList($h)) {
$results = [];
foreach ($h as $v) {
array_push($results, static::objectsToIds($v));
}
return $... | php | public static function objectsToIds($h)
{
if ($h instanceof \Stripe\ApiResource) {
return $h->id;
} elseif (static::isList($h)) {
$results = [];
foreach ($h as $v) {
array_push($results, static::objectsToIds($v));
}
return $... | [
"public",
"static",
"function",
"objectsToIds",
"(",
"$",
"h",
")",
"{",
"if",
"(",
"$",
"h",
"instanceof",
"\\",
"Stripe",
"\\",
"ApiResource",
")",
"{",
"return",
"$",
"h",
"->",
"id",
";",
"}",
"elseif",
"(",
"static",
"::",
"isList",
"(",
"$",
... | Recursively goes through an array of parameters. If a parameter is an instance of
ApiResource, then it is replaced by the resource's ID.
Also clears out null values.
@param mixed $h
@return mixed | [
"Recursively",
"goes",
"through",
"an",
"array",
"of",
"parameters",
".",
"If",
"a",
"parameter",
"is",
"an",
"instance",
"of",
"ApiResource",
"then",
"it",
"is",
"replaced",
"by",
"the",
"resource",
"s",
"ID",
".",
"Also",
"clears",
"out",
"null",
"values... | 8f74cbe130f962d96d4ba92e75a44396a40cf41a | https://github.com/stripe/stripe-php/blob/8f74cbe130f962d96d4ba92e75a44396a40cf41a/lib/Util/Util.php#L230-L252 | train |
stripe/stripe-php | lib/OAuth.php | OAuth.authorizeUrl | public static function authorizeUrl($params = null, $opts = null)
{
$params = $params ?: [];
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
$params['client_id'] = self::_getClientId($params);
if (!array_key_exists('respons... | php | public static function authorizeUrl($params = null, $opts = null)
{
$params = $params ?: [];
$base = ($opts && array_key_exists('connect_base', $opts)) ? $opts['connect_base'] : Stripe::$connectBase;
$params['client_id'] = self::_getClientId($params);
if (!array_key_exists('respons... | [
"public",
"static",
"function",
"authorizeUrl",
"(",
"$",
"params",
"=",
"null",
",",
"$",
"opts",
"=",
"null",
")",
"{",
"$",
"params",
"=",
"$",
"params",
"?",
":",
"[",
"]",
";",
"$",
"base",
"=",
"(",
"$",
"opts",
"&&",
"array_key_exists",
"(",... | Generates a URL to Stripe's OAuth form.
@param array|null $params
@param array|null $opts
@return string The URL to Stripe's OAuth form. | [
"Generates",
"a",
"URL",
"to",
"Stripe",
"s",
"OAuth",
"form",
"."
] | 8f74cbe130f962d96d4ba92e75a44396a40cf41a | https://github.com/stripe/stripe-php/blob/8f74cbe130f962d96d4ba92e75a44396a40cf41a/lib/OAuth.php#L15-L28 | train |
stripe/stripe-php | lib/Util/RequestOptions.php | RequestOptions.discardNonPersistentHeaders | public function discardNonPersistentHeaders()
{
foreach ($this->headers as $k => $v) {
if (!in_array($k, self::$HEADERS_TO_PERSIST)) {
unset($this->headers[$k]);
}
}
} | php | public function discardNonPersistentHeaders()
{
foreach ($this->headers as $k => $v) {
if (!in_array($k, self::$HEADERS_TO_PERSIST)) {
unset($this->headers[$k]);
}
}
} | [
"public",
"function",
"discardNonPersistentHeaders",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"k",
",",
"self",
"::",
"$",
"HEADERS_TO_PERSIST",
")",
... | Discards all headers that we don't want to persist across requests. | [
"Discards",
"all",
"headers",
"that",
"we",
"don",
"t",
"want",
"to",
"persist",
"across",
"requests",
"."
] | 8f74cbe130f962d96d4ba92e75a44396a40cf41a | https://github.com/stripe/stripe-php/blob/8f74cbe130f962d96d4ba92e75a44396a40cf41a/lib/Util/RequestOptions.php#L51-L58 | train |
stripe/stripe-php | lib/Util/RandomGenerator.php | RandomGenerator.uuid | public function uuid()
{
$arr = array_values(unpack('N1a/n4b/N1c', openssl_random_pseudo_bytes(16)));
$arr[2] = ($arr[2] & 0x0fff) | 0x4000;
$arr[3] = ($arr[3] & 0x3fff) | 0x8000;
return vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
} | php | public function uuid()
{
$arr = array_values(unpack('N1a/n4b/N1c', openssl_random_pseudo_bytes(16)));
$arr[2] = ($arr[2] & 0x0fff) | 0x4000;
$arr[3] = ($arr[3] & 0x3fff) | 0x8000;
return vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
} | [
"public",
"function",
"uuid",
"(",
")",
"{",
"$",
"arr",
"=",
"array_values",
"(",
"unpack",
"(",
"'N1a/n4b/N1c'",
",",
"openssl_random_pseudo_bytes",
"(",
"16",
")",
")",
")",
";",
"$",
"arr",
"[",
"2",
"]",
"=",
"(",
"$",
"arr",
"[",
"2",
"]",
"&... | Returns a v4 UUID.
@return string | [
"Returns",
"a",
"v4",
"UUID",
"."
] | 8f74cbe130f962d96d4ba92e75a44396a40cf41a | https://github.com/stripe/stripe-php/blob/8f74cbe130f962d96d4ba92e75a44396a40cf41a/lib/Util/RandomGenerator.php#L27-L33 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.scopeSearch | public function scopeSearch(Builder $q, $search, $threshold = null, $entireText = false, $entireTextOnly = false)
{
return $this->scopeSearchRestricted($q, $search, null, $threshold, $entireText, $entireTextOnly);
} | php | public function scopeSearch(Builder $q, $search, $threshold = null, $entireText = false, $entireTextOnly = false)
{
return $this->scopeSearchRestricted($q, $search, null, $threshold, $entireText, $entireTextOnly);
} | [
"public",
"function",
"scopeSearch",
"(",
"Builder",
"$",
"q",
",",
"$",
"search",
",",
"$",
"threshold",
"=",
"null",
",",
"$",
"entireText",
"=",
"false",
",",
"$",
"entireTextOnly",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"scopeSearchRest... | Creates the search scope.
@param \Illuminate\Database\Eloquent\Builder $q
@param string $search
@param float|null $threshold
@param boolean $entireText
@param boolean $entireTextOnly
@return \Illuminate\Database\Eloquent\Builder | [
"Creates",
"the",
"search",
"scope",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L33-L36 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.getColumns | protected function getColumns()
{
if (array_key_exists('columns', $this->searchable)) {
$driver = $this->getDatabaseDriver();
$prefix = Config::get("database.connections.$driver.prefix");
$columns = [];
foreach($this->searchable['columns'] as $column => $prior... | php | protected function getColumns()
{
if (array_key_exists('columns', $this->searchable)) {
$driver = $this->getDatabaseDriver();
$prefix = Config::get("database.connections.$driver.prefix");
$columns = [];
foreach($this->searchable['columns'] as $column => $prior... | [
"protected",
"function",
"getColumns",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'columns'",
",",
"$",
"this",
"->",
"searchable",
")",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"getDatabaseDriver",
"(",
")",
";",
"$",
"prefix",
"=",
"... | Returns the search columns.
@return array | [
"Returns",
"the",
"search",
"columns",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L121-L134 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.makeJoins | protected function makeJoins(Builder $query)
{
foreach ($this->getJoins() as $table => $keys) {
$query->leftJoin($table, function ($join) use ($keys) {
$join->on($keys[0], '=', $keys[1]);
if (array_key_exists(2, $keys) && array_key_exists(3, $keys)) {
... | php | protected function makeJoins(Builder $query)
{
foreach ($this->getJoins() as $table => $keys) {
$query->leftJoin($table, function ($join) use ($keys) {
$join->on($keys[0], '=', $keys[1]);
if (array_key_exists(2, $keys) && array_key_exists(3, $keys)) {
... | [
"protected",
"function",
"makeJoins",
"(",
"Builder",
"$",
"query",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getJoins",
"(",
")",
"as",
"$",
"table",
"=>",
"$",
"keys",
")",
"{",
"$",
"query",
"->",
"leftJoin",
"(",
"$",
"table",
",",
"function"... | Adds the sql joins to the query.
@param \Illuminate\Database\Eloquent\Builder $query | [
"Adds",
"the",
"sql",
"joins",
"to",
"the",
"query",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L175-L185 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.makeGroupBy | protected function makeGroupBy(Builder $query)
{
if ($groupBy = $this->getGroupBy()) {
$query->groupBy($groupBy);
} else {
$driver = $this->getDatabaseDriver();
if ($driver == 'sqlsrv') {
$columns = $this->getTableColumns();
} else {
... | php | protected function makeGroupBy(Builder $query)
{
if ($groupBy = $this->getGroupBy()) {
$query->groupBy($groupBy);
} else {
$driver = $this->getDatabaseDriver();
if ($driver == 'sqlsrv') {
$columns = $this->getTableColumns();
} else {
... | [
"protected",
"function",
"makeGroupBy",
"(",
"Builder",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"groupBy",
"=",
"$",
"this",
"->",
"getGroupBy",
"(",
")",
")",
"{",
"$",
"query",
"->",
"groupBy",
"(",
"$",
"groupBy",
")",
";",
"}",
"else",
"{",
"$"... | Makes the query not repeat the results.
@param \Illuminate\Database\Eloquent\Builder $query | [
"Makes",
"the",
"query",
"not",
"repeat",
"the",
"results",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L192-L217 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.getSearchQueriesForColumn | protected function getSearchQueriesForColumn(Builder $query, $column, $relevance, array $words)
{
$queries = [];
$queries[] = $this->getSearchQuery($query, $column, $relevance, $words, 15);
$queries[] = $this->getSearchQuery($query, $column, $relevance, $words, 5, '', '%');
$queries... | php | protected function getSearchQueriesForColumn(Builder $query, $column, $relevance, array $words)
{
$queries = [];
$queries[] = $this->getSearchQuery($query, $column, $relevance, $words, 15);
$queries[] = $this->getSearchQuery($query, $column, $relevance, $words, 5, '', '%');
$queries... | [
"protected",
"function",
"getSearchQueriesForColumn",
"(",
"Builder",
"$",
"query",
",",
"$",
"column",
",",
"$",
"relevance",
",",
"array",
"$",
"words",
")",
"{",
"$",
"queries",
"=",
"[",
"]",
";",
"$",
"queries",
"[",
"]",
"=",
"$",
"this",
"->",
... | Returns the search queries for the specified column.
@param \Illuminate\Database\Eloquent\Builder $query
@param string $column
@param float $relevance
@param array $words
@return array | [
"Returns",
"the",
"search",
"queries",
"for",
"the",
"specified",
"column",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L265-L274 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.getSearchQuery | protected function getSearchQuery(Builder $query, $column, $relevance, array $words, $relevance_multiplier, $pre_word = '', $post_word = '')
{
$like_comparator = $this->getDatabaseDriver() == 'pgsql' ? 'ILIKE' : 'LIKE';
$cases = [];
foreach ($words as $word)
{
$cases[] =... | php | protected function getSearchQuery(Builder $query, $column, $relevance, array $words, $relevance_multiplier, $pre_word = '', $post_word = '')
{
$like_comparator = $this->getDatabaseDriver() == 'pgsql' ? 'ILIKE' : 'LIKE';
$cases = [];
foreach ($words as $word)
{
$cases[] =... | [
"protected",
"function",
"getSearchQuery",
"(",
"Builder",
"$",
"query",
",",
"$",
"column",
",",
"$",
"relevance",
",",
"array",
"$",
"words",
",",
"$",
"relevance_multiplier",
",",
"$",
"pre_word",
"=",
"''",
",",
"$",
"post_word",
"=",
"''",
")",
"{",... | Returns the sql string for the given parameters.
@param \Illuminate\Database\Eloquent\Builder $query
@param string $column
@param string $relevance
@param array $words
@param string $compare
@param float $relevance_multiplier
@param string $pre_word
@param string $post_word
@return string | [
"Returns",
"the",
"sql",
"string",
"for",
"the",
"given",
"parameters",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L289-L301 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.getCaseCompare | protected function getCaseCompare($column, $compare, $relevance) {
if($this->getDatabaseDriver() == 'pgsql') {
$field = "LOWER(" . $column . ") " . $compare . " ?";
return '(case when ' . $field . ' then ' . $relevance . ' else 0 end)';
}
$column = str_replace('.', '`.`'... | php | protected function getCaseCompare($column, $compare, $relevance) {
if($this->getDatabaseDriver() == 'pgsql') {
$field = "LOWER(" . $column . ") " . $compare . " ?";
return '(case when ' . $field . ' then ' . $relevance . ' else 0 end)';
}
$column = str_replace('.', '`.`'... | [
"protected",
"function",
"getCaseCompare",
"(",
"$",
"column",
",",
"$",
"compare",
",",
"$",
"relevance",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getDatabaseDriver",
"(",
")",
"==",
"'pgsql'",
")",
"{",
"$",
"field",
"=",
"\"LOWER(\"",
".",
"$",
"col... | Returns the comparison string.
@param string $column
@param string $compare
@param float $relevance
@return string | [
"Returns",
"the",
"comparison",
"string",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L311-L320 | train |
nicolaslopezj/searchable | src/SearchableTrait.php | SearchableTrait.mergeQueries | protected function mergeQueries(Builder $clone, Builder $original) {
$tableName = DB::connection($this->connection)->getTablePrefix() . $this->getTable();
if ($this->getDatabaseDriver() == 'pgsql') {
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"... | php | protected function mergeQueries(Builder $clone, Builder $original) {
$tableName = DB::connection($this->connection)->getTablePrefix() . $this->getTable();
if ($this->getDatabaseDriver() == 'pgsql') {
$original->from(DB::connection($this->connection)->raw("({$clone->toSql()}) as {$tableName}"... | [
"protected",
"function",
"mergeQueries",
"(",
"Builder",
"$",
"clone",
",",
"Builder",
"$",
"original",
")",
"{",
"$",
"tableName",
"=",
"DB",
"::",
"connection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"getTablePrefix",
"(",
")",
".",
"$",
"thi... | Merge our cloned query builder with the original one.
@param \Illuminate\Database\Eloquent\Builder $clone
@param \Illuminate\Database\Eloquent\Builder $original | [
"Merge",
"our",
"cloned",
"query",
"builder",
"with",
"the",
"original",
"one",
"."
] | 69dfeb12ae283067288e4bc412235b1f3f13dcf4 | https://github.com/nicolaslopezj/searchable/blob/69dfeb12ae283067288e4bc412235b1f3f13dcf4/src/SearchableTrait.php#L328-L345 | train |
Eleirbag89/TelegramBotPHP | Telegram.php | Telegram.setWebhook | public function setWebhook($url, $certificate = '')
{
if ($certificate == '') {
$requestBody = ['url' => $url];
} else {
$requestBody = ['url' => $url, 'certificate' => "@$certificate"];
}
return $this->endpoint('setWebhook', $requestBody, true);
} | php | public function setWebhook($url, $certificate = '')
{
if ($certificate == '') {
$requestBody = ['url' => $url];
} else {
$requestBody = ['url' => $url, 'certificate' => "@$certificate"];
}
return $this->endpoint('setWebhook', $requestBody, true);
} | [
"public",
"function",
"setWebhook",
"(",
"$",
"url",
",",
"$",
"certificate",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"certificate",
"==",
"''",
")",
"{",
"$",
"requestBody",
"=",
"[",
"'url'",
"=>",
"$",
"url",
"]",
";",
"}",
"else",
"{",
"$",
"req... | Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
If you... | [
"Use",
"this",
"method",
"to",
"specify",
"a",
"url",
"and",
"receive",
"incoming",
"updates",
"via",
"an",
"outgoing",
"webhook",
".",
"Whenever",
"there",
"is",
"an",
"update",
"for",
"the",
"bot",
"we",
"will",
"send",
"an",
"HTTPS",
"POST",
"request",
... | 19ee63772ff3e13c57142b04a5e71e8bf34236bc | https://github.com/Eleirbag89/TelegramBotPHP/blob/19ee63772ff3e13c57142b04a5e71e8bf34236bc/Telegram.php#L1703-L1712 | train |
Eleirbag89/TelegramBotPHP | Telegram.php | Telegram.ChatID | public function ChatID()
{
$type = $this->getUpdateType();
if ($type == self::CALLBACK_QUERY) {
return @$this->data['callback_query']['message']['chat']['id'];
}
if ($type == self::CHANNEL_POST) {
return @$this->data['channel_post']['chat']['id'];
}
... | php | public function ChatID()
{
$type = $this->getUpdateType();
if ($type == self::CALLBACK_QUERY) {
return @$this->data['callback_query']['message']['chat']['id'];
}
if ($type == self::CHANNEL_POST) {
return @$this->data['channel_post']['chat']['id'];
}
... | [
"public",
"function",
"ChatID",
"(",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getUpdateType",
"(",
")",
";",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"CALLBACK_QUERY",
")",
"{",
"return",
"@",
"$",
"this",
"->",
"data",
"[",
"'callback_quer... | \return the String users's chat_id. | [
"\\",
"return",
"the",
"String",
"users",
"s",
"chat_id",
"."
] | 19ee63772ff3e13c57142b04a5e71e8bf34236bc | https://github.com/Eleirbag89/TelegramBotPHP/blob/19ee63772ff3e13c57142b04a5e71e8bf34236bc/Telegram.php#L1778-L1795 | train |
Eleirbag89/TelegramBotPHP | Telegram.php | Telegram.getUpdateType | public function getUpdateType()
{
$update = $this->data;
if (isset($update['inline_query'])) {
return self::INLINE_QUERY;
}
if (isset($update['callback_query'])) {
return self::CALLBACK_QUERY;
}
if (isset($update['edited_message'])) {
... | php | public function getUpdateType()
{
$update = $this->data;
if (isset($update['inline_query'])) {
return self::INLINE_QUERY;
}
if (isset($update['callback_query'])) {
return self::CALLBACK_QUERY;
}
if (isset($update['edited_message'])) {
... | [
"public",
"function",
"getUpdateType",
"(",
")",
"{",
"$",
"update",
"=",
"$",
"this",
"->",
"data",
";",
"if",
"(",
"isset",
"(",
"$",
"update",
"[",
"'inline_query'",
"]",
")",
")",
"{",
"return",
"self",
"::",
"INLINE_QUERY",
";",
"}",
"if",
"(",
... | Return current update type `False` on failure.
@return bool|string | [
"Return",
"current",
"update",
"type",
"False",
"on",
"failure",
"."
] | 19ee63772ff3e13c57142b04a5e71e8bf34236bc | https://github.com/Eleirbag89/TelegramBotPHP/blob/19ee63772ff3e13c57142b04a5e71e8bf34236bc/Telegram.php#L3097-L3144 | train |
unicodeveloper/laravel-paystack | src/TransRef.php | TransRef.getPool | private static function getPool($type = 'alnum')
{
switch ($type) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX... | php | private static function getPool($type = 'alnum')
{
switch ($type) {
case 'alnum':
$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case 'alpha':
$pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX... | [
"private",
"static",
"function",
"getPool",
"(",
"$",
"type",
"=",
"'alnum'",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'alnum'",
":",
"$",
"pool",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"break",
";",
"case",... | Get the pool to use based on the type of prefix hash
@param string $type
@return string | [
"Get",
"the",
"pool",
"to",
"use",
"based",
"on",
"the",
"type",
"of",
"prefix",
"hash"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/TransRef.php#L23-L50 | train |
unicodeveloper/laravel-paystack | src/TransRef.php | TransRef.getHashedToken | public static function getHashedToken($length = 25)
{
$token = "";
$max = strlen(static::getPool());
for ($i = 0; $i < $length; $i++) {
$token .= static::getPool()[static::secureCrypt(0, $max)];
}
return $token;
} | php | public static function getHashedToken($length = 25)
{
$token = "";
$max = strlen(static::getPool());
for ($i = 0; $i < $length; $i++) {
$token .= static::getPool()[static::secureCrypt(0, $max)];
}
return $token;
} | [
"public",
"static",
"function",
"getHashedToken",
"(",
"$",
"length",
"=",
"25",
")",
"{",
"$",
"token",
"=",
"\"\"",
";",
"$",
"max",
"=",
"strlen",
"(",
"static",
"::",
"getPool",
"(",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
... | Finally, generate a hashed token
@param integer $length
@return string | [
"Finally",
"generate",
"a",
"hashed",
"token"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/TransRef.php#L83-L92 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.setRequestOptions | private function setRequestOptions()
{
$authBearer = 'Bearer '. $this->secretKey;
$this->client = new Client(
[
'base_uri' => $this->baseUrl,
'headers' => [
'Authorization' => $authBearer,
'Content-Type' => 'applic... | php | private function setRequestOptions()
{
$authBearer = 'Bearer '. $this->secretKey;
$this->client = new Client(
[
'base_uri' => $this->baseUrl,
'headers' => [
'Authorization' => $authBearer,
'Content-Type' => 'applic... | [
"private",
"function",
"setRequestOptions",
"(",
")",
"{",
"$",
"authBearer",
"=",
"'Bearer '",
".",
"$",
"this",
"->",
"secretKey",
";",
"$",
"this",
"->",
"client",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"$",
"this",
"->",
"baseUrl",
",",
... | Set options for making the Client request | [
"Set",
"options",
"for",
"making",
"the",
"Client",
"request"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L87-L101 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.getAuthorizationResponse | public function getAuthorizationResponse($data)
{
$this->makePaymentRequest($data);
$this->url = $this->getResponse()['data']['authorization_url'];
return $this->getResponse();
} | php | public function getAuthorizationResponse($data)
{
$this->makePaymentRequest($data);
$this->url = $this->getResponse()['data']['authorization_url'];
return $this->getResponse();
} | [
"public",
"function",
"getAuthorizationResponse",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"makePaymentRequest",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"url",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"[",
"'data'",
"]",
"[",
"'aut... | Get the authorization callback response
In situations where Laravel serves as an backend for a detached UI, the api cannot redirect
and might need to take different actions based on the success or not of the transaction
@return array | [
"Get",
"the",
"authorization",
"callback",
"response",
"In",
"situations",
"where",
"Laravel",
"serves",
"as",
"an",
"backend",
"for",
"a",
"detached",
"UI",
"the",
"api",
"cannot",
"redirect",
"and",
"might",
"need",
"to",
"take",
"different",
"actions",
"bas... | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L189-L196 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.verifyTransactionAtGateway | private function verifyTransactionAtGateway()
{
$transactionRef = request()->query('trxref');
$relativeUrl = "/transaction/verify/{$transactionRef}";
$this->response = $this->client->get($this->baseUrl . $relativeUrl, []);
} | php | private function verifyTransactionAtGateway()
{
$transactionRef = request()->query('trxref');
$relativeUrl = "/transaction/verify/{$transactionRef}";
$this->response = $this->client->get($this->baseUrl . $relativeUrl, []);
} | [
"private",
"function",
"verifyTransactionAtGateway",
"(",
")",
"{",
"$",
"transactionRef",
"=",
"request",
"(",
")",
"->",
"query",
"(",
"'trxref'",
")",
";",
"$",
"relativeUrl",
"=",
"\"/transaction/verify/{$transactionRef}\"",
";",
"$",
"this",
"->",
"response",... | Hit Paystack Gateway to Verify that the transaction is valid | [
"Hit",
"Paystack",
"Gateway",
"to",
"Verify",
"that",
"the",
"transaction",
"is",
"valid"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L201-L208 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.isTransactionVerificationValid | public function isTransactionVerificationValid()
{
$this->verifyTransactionAtGateway();
$result = $this->getResponse()['message'];
switch ($result) {
case self::VS:
$validate = true;
break;
case self::ITF:
$validate = ... | php | public function isTransactionVerificationValid()
{
$this->verifyTransactionAtGateway();
$result = $this->getResponse()['message'];
switch ($result) {
case self::VS:
$validate = true;
break;
case self::ITF:
$validate = ... | [
"public",
"function",
"isTransactionVerificationValid",
"(",
")",
"{",
"$",
"this",
"->",
"verifyTransactionAtGateway",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"[",
"'message'",
"]",
";",
"switch",
"(",
"$",
"result",
... | True or false condition whether the transaction is verified
@return boolean | [
"True",
"or",
"false",
"condition",
"whether",
"the",
"transaction",
"is",
"verified"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L214-L233 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.createPlan | public function createPlan()
{
$data = [
"name" => request()->name,
"description" => request()->desc,
"amount" => intval(request()->amount),
"interval" => request()->interval,
"send_invoices" => request()->send_invoices,
"send_sms" => r... | php | public function createPlan()
{
$data = [
"name" => request()->name,
"description" => request()->desc,
"amount" => intval(request()->amount),
"interval" => request()->interval,
"send_invoices" => request()->send_invoices,
"send_sms" => r... | [
"public",
"function",
"createPlan",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"\"name\"",
"=>",
"request",
"(",
")",
"->",
"name",
",",
"\"description\"",
"=>",
"request",
"(",
")",
"->",
"desc",
",",
"\"amount\"",
"=>",
"intval",
"(",
"request",
"(",
")",... | Create a plan | [
"Create",
"a",
"plan"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L329-L345 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.updatePlan | public function updatePlan($plan_code)
{
$data = [
"name" => request()->name,
"description" => request()->desc,
"amount" => intval(request()->amount),
"interval" => request()->interval,
"send_invoices" => request()->send_invoices,
"send... | php | public function updatePlan($plan_code)
{
$data = [
"name" => request()->name,
"description" => request()->desc,
"amount" => intval(request()->amount),
"interval" => request()->interval,
"send_invoices" => request()->send_invoices,
"send... | [
"public",
"function",
"updatePlan",
"(",
"$",
"plan_code",
")",
"{",
"$",
"data",
"=",
"[",
"\"name\"",
"=>",
"request",
"(",
")",
"->",
"name",
",",
"\"description\"",
"=>",
"request",
"(",
")",
"->",
"desc",
",",
"\"amount\"",
"=>",
"intval",
"(",
"r... | Update any plan's details based on its id or code
@param $plan_code
@return array | [
"Update",
"any",
"plan",
"s",
"details",
"based",
"on",
"its",
"id",
"or",
"code"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L363-L377 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.updateCustomer | public function updateCustomer($customer_id)
{
$data = [
"email" => request()->email,
"first_name" => request()->fname,
"last_name" => request()->lname,
"phone" => request()->phone,
"metadata" => request()->additional_info /* key => value pairs arr... | php | public function updateCustomer($customer_id)
{
$data = [
"email" => request()->email,
"first_name" => request()->fname,
"last_name" => request()->lname,
"phone" => request()->phone,
"metadata" => request()->additional_info /* key => value pairs arr... | [
"public",
"function",
"updateCustomer",
"(",
"$",
"customer_id",
")",
"{",
"$",
"data",
"=",
"[",
"\"email\"",
"=>",
"request",
"(",
")",
"->",
"email",
",",
"\"first_name\"",
"=>",
"request",
"(",
")",
"->",
"fname",
",",
"\"last_name\"",
"=>",
"request",... | Update a customer's details based on their id or code
@param $customer_id
@return array | [
"Update",
"a",
"customer",
"s",
"details",
"based",
"on",
"their",
"id",
"or",
"code"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L413-L426 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.exportTransactions | public function exportTransactions()
{
$data = [
"from" => request()->from,
"to" => request()->to,
'settled' => request()->settled
];
$this->setRequestOptions();
return $this->setHttpResponse('/transaction/export', 'GET', $data)->getResponse();
... | php | public function exportTransactions()
{
$data = [
"from" => request()->from,
"to" => request()->to,
'settled' => request()->settled
];
$this->setRequestOptions();
return $this->setHttpResponse('/transaction/export', 'GET', $data)->getResponse();
... | [
"public",
"function",
"exportTransactions",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"\"from\"",
"=>",
"request",
"(",
")",
"->",
"from",
",",
"\"to\"",
"=>",
"request",
"(",
")",
"->",
"to",
",",
"'settled'",
"=>",
"request",
"(",
")",
"->",
"settled",
... | Export transactions in .CSV
@return array | [
"Export",
"transactions",
"in",
".",
"CSV"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L432-L442 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.createSubscription | public function createSubscription()
{
$data = [
"customer" => request()->customer, //Customer email or code
"plan" => request()->plan,
"authorization" => request()->authorization_code
];
$this->setRequestOptions();
$this->setHttpResponse('/subscr... | php | public function createSubscription()
{
$data = [
"customer" => request()->customer, //Customer email or code
"plan" => request()->plan,
"authorization" => request()->authorization_code
];
$this->setRequestOptions();
$this->setHttpResponse('/subscr... | [
"public",
"function",
"createSubscription",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"\"customer\"",
"=>",
"request",
"(",
")",
"->",
"customer",
",",
"//Customer email or code",
"\"plan\"",
"=>",
"request",
"(",
")",
"->",
"plan",
",",
"\"authorization\"",
"=>",... | Create a subscription to a plan from a customer. | [
"Create",
"a",
"subscription",
"to",
"a",
"plan",
"from",
"a",
"customer",
"."
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L447-L457 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.enableSubscription | public function enableSubscription()
{
$data = [
"code" => request()->code,
"token" => request()->token,
];
$this->setRequestOptions();
return $this->setHttpResponse('/subscription/enable', 'POST', $data)->getResponse();
} | php | public function enableSubscription()
{
$data = [
"code" => request()->code,
"token" => request()->token,
];
$this->setRequestOptions();
return $this->setHttpResponse('/subscription/enable', 'POST', $data)->getResponse();
} | [
"public",
"function",
"enableSubscription",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"\"code\"",
"=>",
"request",
"(",
")",
"->",
"code",
",",
"\"token\"",
"=>",
"request",
"(",
")",
"->",
"token",
",",
"]",
";",
"$",
"this",
"->",
"setRequestOptions",
"(... | Enable a subscription using the subscription code and token
@return array | [
"Enable",
"a",
"subscription",
"using",
"the",
"subscription",
"code",
"and",
"token"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L501-L510 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.createPage | public function createPage()
{
$data = [
"name" => request()->name,
"description" => request()->description,
"amount" => request()->amount
];
$this->setRequestOptions();
$this->setHttpResponse('/page', 'POST', $data);
} | php | public function createPage()
{
$data = [
"name" => request()->name,
"description" => request()->description,
"amount" => request()->amount
];
$this->setRequestOptions();
$this->setHttpResponse('/page', 'POST', $data);
} | [
"public",
"function",
"createPage",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"\"name\"",
"=>",
"request",
"(",
")",
"->",
"name",
",",
"\"description\"",
"=>",
"request",
"(",
")",
"->",
"description",
",",
"\"amount\"",
"=>",
"request",
"(",
")",
"->",
"... | Create pages you can share with users using the returned slug | [
"Create",
"pages",
"you",
"can",
"share",
"with",
"users",
"using",
"the",
"returned",
"slug"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L541-L551 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.updatePage | public function updatePage($page_id)
{
$data = [
"name" => request()->name,
"description" => request()->description,
"amount" => request()->amount
];
$this->setRequestOptions();
return $this->setHttpResponse('/page/'.$page_id, 'PUT', $data)->getRe... | php | public function updatePage($page_id)
{
$data = [
"name" => request()->name,
"description" => request()->description,
"amount" => request()->amount
];
$this->setRequestOptions();
return $this->setHttpResponse('/page/'.$page_id, 'PUT', $data)->getRe... | [
"public",
"function",
"updatePage",
"(",
"$",
"page_id",
")",
"{",
"$",
"data",
"=",
"[",
"\"name\"",
"=>",
"request",
"(",
")",
"->",
"name",
",",
"\"description\"",
"=>",
"request",
"(",
")",
"->",
"description",
",",
"\"amount\"",
"=>",
"request",
"("... | Update the details about a particular page
@param $page_id
@return array | [
"Update",
"the",
"details",
"about",
"a",
"particular",
"page"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L579-L589 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.listSubAccounts | public function listSubAccounts($per_page,$page){
$this->setRequestOptions();
return $this->setHttpResponse("/subaccount/?perPage=".(int) $per_page."&page=".(int) $page,"GET")->getResponse();
} | php | public function listSubAccounts($per_page,$page){
$this->setRequestOptions();
return $this->setHttpResponse("/subaccount/?perPage=".(int) $per_page."&page=".(int) $page,"GET")->getResponse();
} | [
"public",
"function",
"listSubAccounts",
"(",
"$",
"per_page",
",",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"setRequestOptions",
"(",
")",
";",
"return",
"$",
"this",
"->",
"setHttpResponse",
"(",
"\"/subaccount/?perPage=\"",
".",
"(",
"int",
")",
"$",
"... | Lists all the subaccounts associated with the account
@param $per_page - Specifies how many records to retrieve per page , $page - SPecifies exactly what page to retrieve
@return array | [
"Lists",
"all",
"the",
"subaccounts",
"associated",
"with",
"the",
"account"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L632-L637 | train |
unicodeveloper/laravel-paystack | src/Paystack.php | Paystack.updateSubAccount | public function updateSubAccount($subaccount_code){
$data = [
"business_name" => request()->business_name,
"settlement_bank" => request()->settlement_bank,
"account_number" => request()->account_number,
"percentage_charge" => request()->percentage_charge,
... | php | public function updateSubAccount($subaccount_code){
$data = [
"business_name" => request()->business_name,
"settlement_bank" => request()->settlement_bank,
"account_number" => request()->account_number,
"percentage_charge" => request()->percentage_charge,
... | [
"public",
"function",
"updateSubAccount",
"(",
"$",
"subaccount_code",
")",
"{",
"$",
"data",
"=",
"[",
"\"business_name\"",
"=>",
"request",
"(",
")",
"->",
"business_name",
",",
"\"settlement_bank\"",
"=>",
"request",
"(",
")",
"->",
"settlement_bank",
",",
... | Updates a subaccount to be used for split payments . Required params are business_name , settlement_bank , account_number , percentage_charge
@param subaccount code
@return array | [
"Updates",
"a",
"subaccount",
"to",
"be",
"used",
"for",
"split",
"payments",
".",
"Required",
"params",
"are",
"business_name",
"settlement_bank",
"account_number",
"percentage_charge"
] | 1150bf5f1be5cb765d1221fbc4489d27283538b1 | https://github.com/unicodeveloper/laravel-paystack/blob/1150bf5f1be5cb765d1221fbc4489d27283538b1/src/Paystack.php#L646-L663 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getAsciiContent | public function getAsciiContent(string $resource): string
{
$file = $this->config->getAsciiContentPath($resource);
// Disabled:
if (null === $file) {
return '';
}
// Specified by user:
if ($this->fileSystem->exists($file)) {
return $this->fil... | php | public function getAsciiContent(string $resource): string
{
$file = $this->config->getAsciiContentPath($resource);
// Disabled:
if (null === $file) {
return '';
}
// Specified by user:
if ($this->fileSystem->exists($file)) {
return $this->fil... | [
"public",
"function",
"getAsciiContent",
"(",
"string",
"$",
"resource",
")",
":",
"string",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"config",
"->",
"getAsciiContentPath",
"(",
"$",
"resource",
")",
";",
"// Disabled:",
"if",
"(",
"null",
"===",
"$",
"... | Load an ascii image. | [
"Load",
"an",
"ascii",
"image",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L83-L105 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getGitDir | public function getGitDir(): string
{
$gitDir = $this->config->getGitDir();
if (!$this->fileSystem->exists($gitDir)) {
throw new RuntimeException('The configured GIT directory could not be found.');
}
return $this->getRelativePath($gitDir);
} | php | public function getGitDir(): string
{
$gitDir = $this->config->getGitDir();
if (!$this->fileSystem->exists($gitDir)) {
throw new RuntimeException('The configured GIT directory could not be found.');
}
return $this->getRelativePath($gitDir);
} | [
"public",
"function",
"getGitDir",
"(",
")",
":",
"string",
"{",
"$",
"gitDir",
"=",
"$",
"this",
"->",
"config",
"->",
"getGitDir",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"gitDir",
")",
")",
"{",
... | Find the relative git directory. | [
"Find",
"the",
"relative",
"git",
"directory",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L119-L127 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getGitHookExecutionPath | public function getGitHookExecutionPath(): string
{
$gitPath = $this->getGitDir();
return $this->fileSystem->makePathRelative($this->getWorkingDir(), $this->getAbsolutePath($gitPath));
} | php | public function getGitHookExecutionPath(): string
{
$gitPath = $this->getGitDir();
return $this->fileSystem->makePathRelative($this->getWorkingDir(), $this->getAbsolutePath($gitPath));
} | [
"public",
"function",
"getGitHookExecutionPath",
"(",
")",
":",
"string",
"{",
"$",
"gitPath",
"=",
"$",
"this",
"->",
"getGitDir",
"(",
")",
";",
"return",
"$",
"this",
"->",
"fileSystem",
"->",
"makePathRelative",
"(",
"$",
"this",
"->",
"getWorkingDir",
... | Gets the path from where the command needs to be executed in the GIT hook. | [
"Gets",
"the",
"path",
"from",
"where",
"the",
"command",
"needs",
"to",
"be",
"executed",
"in",
"the",
"GIT",
"hook",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L132-L137 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getGitHooksDir | public function getGitHooksDir(): string
{
$gitPath = $this->getGitDir();
$absoluteGitPath = $this->getAbsolutePath($gitPath);
$gitRepoPath = $absoluteGitPath.'/.git';
if (is_file($gitRepoPath)) {
$fileContent = $this->fileSystem->readFromFileInfo(new SplFileInfo($gitRep... | php | public function getGitHooksDir(): string
{
$gitPath = $this->getGitDir();
$absoluteGitPath = $this->getAbsolutePath($gitPath);
$gitRepoPath = $absoluteGitPath.'/.git';
if (is_file($gitRepoPath)) {
$fileContent = $this->fileSystem->readFromFileInfo(new SplFileInfo($gitRep... | [
"public",
"function",
"getGitHooksDir",
"(",
")",
":",
"string",
"{",
"$",
"gitPath",
"=",
"$",
"this",
"->",
"getGitDir",
"(",
")",
";",
"$",
"absoluteGitPath",
"=",
"$",
"this",
"->",
"getAbsolutePath",
"(",
"$",
"gitPath",
")",
";",
"$",
"gitRepoPath"... | Returns the directory where the git hooks are installed. | [
"Returns",
"the",
"directory",
"where",
"the",
"git",
"hooks",
"are",
"installed",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L142-L157 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getBinDir | public function getBinDir(): string
{
$binDir = $this->config->getBinDir();
if (!$this->fileSystem->exists($binDir)) {
throw new RuntimeException('The configured BIN directory could not be found.');
}
return $this->getRelativePath($binDir);
} | php | public function getBinDir(): string
{
$binDir = $this->config->getBinDir();
if (!$this->fileSystem->exists($binDir)) {
throw new RuntimeException('The configured BIN directory could not be found.');
}
return $this->getRelativePath($binDir);
} | [
"public",
"function",
"getBinDir",
"(",
")",
":",
"string",
"{",
"$",
"binDir",
"=",
"$",
"this",
"->",
"config",
"->",
"getBinDir",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"binDir",
")",
")",
"{",
... | Find the relative bin directory. | [
"Find",
"the",
"relative",
"bin",
"directory",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L170-L178 | train |
phpro/grumphp | src/Console/Helper/PathsHelper.php | PathsHelper.getRelativeProjectPath | public function getRelativeProjectPath(string $path): string
{
$realPath = $this->getAbsolutePath($path);
$gitPath = $this->getAbsolutePath($this->getGitDir());
if (0 !== strpos($realPath, $gitPath)) {
return $realPath;
}
return rtrim($this->getRelativePath($rea... | php | public function getRelativeProjectPath(string $path): string
{
$realPath = $this->getAbsolutePath($path);
$gitPath = $this->getAbsolutePath($this->getGitDir());
if (0 !== strpos($realPath, $gitPath)) {
return $realPath;
}
return rtrim($this->getRelativePath($rea... | [
"public",
"function",
"getRelativeProjectPath",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"$",
"realPath",
"=",
"$",
"this",
"->",
"getAbsolutePath",
"(",
"$",
"path",
")",
";",
"$",
"gitPath",
"=",
"$",
"this",
"->",
"getAbsolutePath",
"(",
"... | This method will return a relative path to a file of directory if it lives in the current project.
When the file is not located in the current project, the absolute path to the file is returned.
@throws FileNotFoundException | [
"This",
"method",
"will",
"return",
"a",
"relative",
"path",
"to",
"a",
"file",
"of",
"directory",
"if",
"it",
"lives",
"in",
"the",
"current",
"project",
".",
"When",
"the",
"file",
"is",
"not",
"located",
"in",
"the",
"current",
"project",
"the",
"abso... | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Helper/PathsHelper.php#L206-L216 | train |
phpro/grumphp | src/Util/Str.php | Str.containsOneOf | public static function containsOneOf($haystack, array $needles)
{
foreach ($needles as $needle) {
if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
return false;
} | php | public static function containsOneOf($haystack, array $needles)
{
foreach ($needles as $needle) {
if ($needle !== '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"containsOneOf",
"(",
"$",
"haystack",
",",
"array",
"$",
"needles",
")",
"{",
"foreach",
"(",
"$",
"needles",
"as",
"$",
"needle",
")",
"{",
"if",
"(",
"$",
"needle",
"!==",
"''",
"&&",
"mb_strpos",
"(",
"$",
"haystack"... | String contains one of the provided needles
@param string $haystack
@param array $needles
@return bool | [
"String",
"contains",
"one",
"of",
"the",
"provided",
"needles"
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Util/Str.php#L14-L23 | train |
phpro/grumphp | src/Collection/ProcessArgumentsCollection.php | ProcessArgumentsCollection.addArgumentArrayWithSeparatedValue | public function addArgumentArrayWithSeparatedValue(string $argument, array $values)
{
foreach ($values as $value) {
$this->add(sprintf($argument, $value));
$this->add($value);
}
} | php | public function addArgumentArrayWithSeparatedValue(string $argument, array $values)
{
foreach ($values as $value) {
$this->add(sprintf($argument, $value));
$this->add($value);
}
} | [
"public",
"function",
"addArgumentArrayWithSeparatedValue",
"(",
"string",
"$",
"argument",
",",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"sprintf",
"(",
"$",
"argument",
... | Some CLI tools prefer to split the argument and the value. | [
"Some",
"CLI",
"tools",
"prefer",
"to",
"split",
"the",
"argument",
"and",
"the",
"value",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Collection/ProcessArgumentsCollection.php#L58-L64 | train |
phpro/grumphp | src/Configuration/Compiler/PhpParserCompilerPass.php | PhpParserCompilerPass.process | public function process(ContainerBuilder $container)
{
$traverserConfigurator = $container->findDefinition('grumphp.parser.php.configurator.traverser');
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
$definition = $container->findDefinition($id);
$thi... | php | public function process(ContainerBuilder $container)
{
$traverserConfigurator = $container->findDefinition('grumphp.parser.php.configurator.traverser');
foreach ($container->findTaggedServiceIds(self::TAG) as $id => $tags) {
$definition = $container->findDefinition($id);
$thi... | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"traverserConfigurator",
"=",
"$",
"container",
"->",
"findDefinition",
"(",
"'grumphp.parser.php.configurator.traverser'",
")",
";",
"foreach",
"(",
"$",
"container",
"->",
"... | Sets the visitors as non shared services.
This will make sure that the state of the visitor won't need to be reset after an iteration of the traverser.
All visitor Ids are registered in the traverser configurator.
The configurator will be used to apply the configured visitors to the traverser.
@throws \Symfony\Compo... | [
"Sets",
"the",
"visitors",
"as",
"non",
"shared",
"services",
".",
"This",
"will",
"make",
"sure",
"that",
"the",
"state",
"of",
"the",
"visitor",
"won",
"t",
"need",
"to",
"be",
"reset",
"after",
"an",
"iteration",
"of",
"the",
"traverser",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Configuration/Compiler/PhpParserCompilerPass.php#L27-L38 | train |
phpro/grumphp | src/Configuration/Compiler/PhpParserCompilerPass.php | PhpParserCompilerPass.markServiceAsPrototype | public function markServiceAsPrototype(Definition $definition)
{
if (method_exists($definition, 'setShared')) {
$definition->setShared(false);
return;
}
if (method_exists($definition, 'setScope')) {
$definition->setScope('prototype');
return... | php | public function markServiceAsPrototype(Definition $definition)
{
if (method_exists($definition, 'setShared')) {
$definition->setShared(false);
return;
}
if (method_exists($definition, 'setScope')) {
$definition->setScope('prototype');
return... | [
"public",
"function",
"markServiceAsPrototype",
"(",
"Definition",
"$",
"definition",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"definition",
",",
"'setShared'",
")",
")",
"{",
"$",
"definition",
"->",
"setShared",
"(",
"false",
")",
";",
"return",
";"... | This method can be used to make the service shared cross-version.
From Symfony 2.8 the setShared method was available.
The 2.7 version is the LTS, so we still need to support it.
@see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping
@throws \GrumPHP\Exception\RuntimeException | [
"This",
"method",
"can",
"be",
"used",
"to",
"make",
"the",
"service",
"shared",
"cross",
"-",
"version",
".",
"From",
"Symfony",
"2",
".",
"8",
"the",
"setShared",
"method",
"was",
"available",
".",
"The",
"2",
".",
"7",
"version",
"is",
"the",
"LTS",... | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Configuration/Compiler/PhpParserCompilerPass.php#L49-L64 | train |
phpro/grumphp | src/Composer/GrumPHPPlugin.php | GrumPHPPlugin.postPackageInstall | public function postPackageInstall(PackageEvent $event)
{
/** @var InstallOperation $operation */
$operation = $event->getOperation();
$package = $operation->getPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// Schedule init when com... | php | public function postPackageInstall(PackageEvent $event)
{
/** @var InstallOperation $operation */
$operation = $event->getOperation();
$package = $operation->getPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// Schedule init when com... | [
"public",
"function",
"postPackageInstall",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"/** @var InstallOperation $operation */",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"$",
"package",
"=",
"$",
"operation",
"->",
"getPackage",... | When this package is updated, the git hook is also initialized. | [
"When",
"this",
"package",
"is",
"updated",
"the",
"git",
"hook",
"is",
"also",
"initialized",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Composer/GrumPHPPlugin.php#L79-L92 | train |
phpro/grumphp | src/Composer/GrumPHPPlugin.php | GrumPHPPlugin.postPackageUpdate | public function postPackageUpdate(PackageEvent $event)
{
/** @var UpdateOperation $operation */
$operation = $event->getOperation();
$package = $operation->getTargetPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// Schedule init when... | php | public function postPackageUpdate(PackageEvent $event)
{
/** @var UpdateOperation $operation */
$operation = $event->getOperation();
$package = $operation->getTargetPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// Schedule init when... | [
"public",
"function",
"postPackageUpdate",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"/** @var UpdateOperation $operation */",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"$",
"package",
"=",
"$",
"operation",
"->",
"getTargetPacka... | When this package is updated, the git hook is also updated. | [
"When",
"this",
"package",
"is",
"updated",
"the",
"git",
"hook",
"is",
"also",
"updated",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Composer/GrumPHPPlugin.php#L97-L109 | train |
phpro/grumphp | src/Composer/GrumPHPPlugin.php | GrumPHPPlugin.prePackageUninstall | public function prePackageUninstall(PackageEvent $event)
{
/** @var UninstallOperation $operation */
$operation = $event->getOperation();
$package = $operation->getPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// First remove the ho... | php | public function prePackageUninstall(PackageEvent $event)
{
/** @var UninstallOperation $operation */
$operation = $event->getOperation();
$package = $operation->getPackage();
if (!$this->guardIsGrumPhpPackage($package)) {
return;
}
// First remove the ho... | [
"public",
"function",
"prePackageUninstall",
"(",
"PackageEvent",
"$",
"event",
")",
"{",
"/** @var UninstallOperation $operation */",
"$",
"operation",
"=",
"$",
"event",
"->",
"getOperation",
"(",
")",
";",
"$",
"package",
"=",
"$",
"operation",
"->",
"getPackag... | When this package is uninstalled, the generated git hooks need to be removed. | [
"When",
"this",
"package",
"is",
"uninstalled",
"the",
"generated",
"git",
"hooks",
"need",
"to",
"be",
"removed",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Composer/GrumPHPPlugin.php#L114-L126 | train |
phpro/grumphp | src/Console/Command/Git/InitCommand.php | InitCommand.useExoticConfigFile | protected function useExoticConfigFile()
{
try {
$configPath = $this->paths()->getAbsolutePath($this->input->getOption('config'));
if ($configPath !== $this->paths()->getDefaultConfigPath()) {
return $this->paths()->getRelativeProjectPath($configPath);
}
... | php | protected function useExoticConfigFile()
{
try {
$configPath = $this->paths()->getAbsolutePath($this->input->getOption('config'));
if ($configPath !== $this->paths()->getDefaultConfigPath()) {
return $this->paths()->getRelativeProjectPath($configPath);
}
... | [
"protected",
"function",
"useExoticConfigFile",
"(",
")",
"{",
"try",
"{",
"$",
"configPath",
"=",
"$",
"this",
"->",
"paths",
"(",
")",
"->",
"getAbsolutePath",
"(",
"$",
"this",
"->",
"input",
"->",
"getOption",
"(",
"'config'",
")",
")",
";",
"if",
... | This method will tell you which exotic configuration file should be used.
@return null|string | [
"This",
"method",
"will",
"tell",
"you",
"which",
"exotic",
"configuration",
"file",
"should",
"be",
"used",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Command/Git/InitCommand.php#L149-L161 | train |
phpro/grumphp | src/Composer/DevelopmentIntegrator.php | DevelopmentIntegrator.integrate | public static function integrate(Event $event)
{
$filesystem = new Filesystem();
$composerBinDir = $event->getComposer()->getConfig()->get('bin-dir');
$executable = getcwd().'/bin/grumphp';
$composerExecutable = $composerBinDir.'/grumphp';
$filesystem->copy(
self... | php | public static function integrate(Event $event)
{
$filesystem = new Filesystem();
$composerBinDir = $event->getComposer()->getConfig()->get('bin-dir');
$executable = getcwd().'/bin/grumphp';
$composerExecutable = $composerBinDir.'/grumphp';
$filesystem->copy(
self... | [
"public",
"static",
"function",
"integrate",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"$",
"composerBinDir",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
"->",
"getConfig",
"(",
")",
"->",
"... | This method makes sure that GrumPHP registers itself during development. | [
"This",
"method",
"makes",
"sure",
"that",
"GrumPHP",
"registers",
"itself",
"during",
"development",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Composer/DevelopmentIntegrator.php#L17-L44 | train |
phpro/grumphp | src/Configuration/GrumPHP.php | GrumPHP.getAsciiContentPath | public function getAsciiContentPath(string $resource)
{
if (null === $this->container->getParameter('ascii')) {
return null;
}
$paths = $this->container->getParameter('ascii');
if (!array_key_exists($resource, $paths)) {
return null;
}
// Dea... | php | public function getAsciiContentPath(string $resource)
{
if (null === $this->container->getParameter('ascii')) {
return null;
}
$paths = $this->container->getParameter('ascii');
if (!array_key_exists($resource, $paths)) {
return null;
}
// Dea... | [
"public",
"function",
"getAsciiContentPath",
"(",
"string",
"$",
"resource",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"container",
"->",
"getParameter",
"(",
"'ascii'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"paths",
"=",
"$",
"t... | Get ascii content path from grumphp.yml file.
@return string|null | [
"Get",
"ascii",
"content",
"path",
"from",
"grumphp",
".",
"yml",
"file",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Configuration/GrumPHP.php#L138-L156 | train |
phpro/grumphp | src/Console/Application.php | Application.updateUserConfigPath | private function updateUserConfigPath(string $configPath): string
{
if ($configPath !== $this->getDefaultConfigPath()) {
$configPath = getcwd().DIRECTORY_SEPARATOR.$configPath;
}
return $configPath;
} | php | private function updateUserConfigPath(string $configPath): string
{
if ($configPath !== $this->getDefaultConfigPath()) {
$configPath = getcwd().DIRECTORY_SEPARATOR.$configPath;
}
return $configPath;
} | [
"private",
"function",
"updateUserConfigPath",
"(",
"string",
"$",
"configPath",
")",
":",
"string",
"{",
"if",
"(",
"$",
"configPath",
"!==",
"$",
"this",
"->",
"getDefaultConfigPath",
"(",
")",
")",
"{",
"$",
"configPath",
"=",
"getcwd",
"(",
")",
".",
... | Prefixes the cwd to the path given by the user. | [
"Prefixes",
"the",
"cwd",
"to",
"the",
"path",
"given",
"by",
"the",
"user",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Application.php#L202-L209 | train |
phpro/grumphp | src/Task/Git/CommitMessage.php | CommitMessage.getSubjectLine | private function getSubjectLine($context)
{
$commitMessage = $context->getCommitMessage();
$lines = $this->getCommitMessageLinesWithoutComments($commitMessage);
return (string) $lines[0];
} | php | private function getSubjectLine($context)
{
$commitMessage = $context->getCommitMessage();
$lines = $this->getCommitMessageLinesWithoutComments($commitMessage);
return (string) $lines[0];
} | [
"private",
"function",
"getSubjectLine",
"(",
"$",
"context",
")",
"{",
"$",
"commitMessage",
"=",
"$",
"context",
"->",
"getCommitMessage",
"(",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"getCommitMessageLinesWithoutComments",
"(",
"$",
"commitMessage",
... | Gets a clean subject line from the commit message
@param $context
@return string | [
"Gets",
"a",
"clean",
"subject",
"line",
"from",
"the",
"commit",
"message"
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Task/Git/CommitMessage.php#L361-L366 | train |
phpro/grumphp | src/Event/Subscriber/StashUnstagedChangesSubscriber.php | StashUnstagedChangesSubscriber.doSaveStash | private function doSaveStash()
{
$pending = $this->repository->getWorkingCopy()->getDiffPending();
if (!\count($pending->getFiles())) {
return;
}
try {
$this->io->write(['<fg=yellow>Detected unstaged changes... Stashing them!</fg=yellow>']);
$this... | php | private function doSaveStash()
{
$pending = $this->repository->getWorkingCopy()->getDiffPending();
if (!\count($pending->getFiles())) {
return;
}
try {
$this->io->write(['<fg=yellow>Detected unstaged changes... Stashing them!</fg=yellow>']);
$this... | [
"private",
"function",
"doSaveStash",
"(",
")",
"{",
"$",
"pending",
"=",
"$",
"this",
"->",
"repository",
"->",
"getWorkingCopy",
"(",
")",
"->",
"getDiffPending",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"count",
"(",
"$",
"pending",
"->",
"getFiles",
"(... | Check if there is a pending diff and stash the changes.
@reurn void | [
"Check",
"if",
"there",
"is",
"a",
"pending",
"diff",
"and",
"stash",
"the",
"changes",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Event/Subscriber/StashUnstagedChangesSubscriber.php#L108-L127 | train |
phpro/grumphp | src/Event/Subscriber/StashUnstagedChangesSubscriber.php | StashUnstagedChangesSubscriber.registerShutdownHandler | private function registerShutdownHandler()
{
if ($this->shutdownFunctionRegistered) {
return;
}
$subscriber = $this;
register_shutdown_function(function () use ($subscriber) {
if (!$error = error_get_last()) {
return;
}
... | php | private function registerShutdownHandler()
{
if ($this->shutdownFunctionRegistered) {
return;
}
$subscriber = $this;
register_shutdown_function(function () use ($subscriber) {
if (!$error = error_get_last()) {
return;
}
... | [
"private",
"function",
"registerShutdownHandler",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shutdownFunctionRegistered",
")",
"{",
"return",
";",
"}",
"$",
"subscriber",
"=",
"$",
"this",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"use",... | Make sure to fetch errors and pop the stash before crashing. | [
"Make",
"sure",
"to",
"fetch",
"errors",
"and",
"pop",
"the",
"stash",
"before",
"crashing",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Event/Subscriber/StashUnstagedChangesSubscriber.php#L158-L179 | train |
phpro/grumphp | src/Linter/Yaml/YamlLinter.php | YamlLinter.supportsFlags | public static function supportsFlags(): bool
{
$rc = new ReflectionClass(Yaml::class);
$method = $rc->getMethod('parse');
$params = $method->getParameters();
return 'flags' === $params[1]->getName();
} | php | public static function supportsFlags(): bool
{
$rc = new ReflectionClass(Yaml::class);
$method = $rc->getMethod('parse');
$params = $method->getParameters();
return 'flags' === $params[1]->getName();
} | [
"public",
"static",
"function",
"supportsFlags",
"(",
")",
":",
"bool",
"{",
"$",
"rc",
"=",
"new",
"ReflectionClass",
"(",
"Yaml",
"::",
"class",
")",
";",
"$",
"method",
"=",
"$",
"rc",
"->",
"getMethod",
"(",
"'parse'",
")",
";",
"$",
"params",
"=... | This method can be used to determine the Symfony Linter version.
If this method returns true, you are using Symfony YAML > 3.1.
@see http://symfony.com/blog/new-in-symfony-3-1-customizable-yaml-parsing-and-dumping | [
"This",
"method",
"can",
"be",
"used",
"to",
"determine",
"the",
"Symfony",
"Linter",
"version",
".",
"If",
"this",
"method",
"returns",
"true",
"you",
"are",
"using",
"Symfony",
"YAML",
">",
"3",
".",
"1",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Linter/Yaml/YamlLinter.php#L80-L87 | train |
phpro/grumphp | src/Collection/TasksCollection.php | TasksCollection.sortByPriority | public function sortByPriority(GrumPHP $grumPHP): self
{
$priorityQueue = new SplPriorityQueue();
$stableSortIndex = PHP_INT_MAX;
foreach ($this->getIterator() as $task) {
$metadata = $grumPHP->getTaskMetadata($task->getName());
$priorityQueue->insert($task, [$metadat... | php | public function sortByPriority(GrumPHP $grumPHP): self
{
$priorityQueue = new SplPriorityQueue();
$stableSortIndex = PHP_INT_MAX;
foreach ($this->getIterator() as $task) {
$metadata = $grumPHP->getTaskMetadata($task->getName());
$priorityQueue->insert($task, [$metadat... | [
"public",
"function",
"sortByPriority",
"(",
"GrumPHP",
"$",
"grumPHP",
")",
":",
"self",
"{",
"$",
"priorityQueue",
"=",
"new",
"SplPriorityQueue",
"(",
")",
";",
"$",
"stableSortIndex",
"=",
"PHP_INT_MAX",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIterat... | This method sorts the tasks by highest priority first. | [
"This",
"method",
"sorts",
"the",
"tasks",
"by",
"highest",
"priority",
"first",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Collection/TasksCollection.php#L40-L50 | train |
phpro/grumphp | src/Util/Composer.php | Composer.ensureProjectBinDirInSystemPath | public static function ensureProjectBinDirInSystemPath(string $binDir)
{
$pathStr = 'PATH';
if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
$pathStr = 'Path';
}
if (!is_dir($binDir)) {
return;
}
// add the bin dir to the PATH to ... | php | public static function ensureProjectBinDirInSystemPath(string $binDir)
{
$pathStr = 'PATH';
if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
$pathStr = 'Path';
}
if (!is_dir($binDir)) {
return;
}
// add the bin dir to the PATH to ... | [
"public",
"static",
"function",
"ensureProjectBinDirInSystemPath",
"(",
"string",
"$",
"binDir",
")",
"{",
"$",
"pathStr",
"=",
"'PATH'",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"$",
"pathStr",
"]",
")",
"&&",
"isset",
"(",
"$",
"_SERVER"... | Composer contains some logic to prepend the current bin dir to the system PATH.
To make sure this application works the same in CLI and Composer modus,
we'll have to ensure that the bin path is always prefixed.
@see https://github.com/composer/composer/blob/1.1/src/Composer/EventDispatcher/EventDispatcher.php#L147-L16... | [
"Composer",
"contains",
"some",
"logic",
"to",
"prepend",
"the",
"current",
"bin",
"dir",
"to",
"the",
"system",
"PATH",
".",
"To",
"make",
"sure",
"this",
"application",
"works",
"the",
"same",
"in",
"CLI",
"and",
"Composer",
"modus",
"we",
"ll",
"have",
... | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Util/Composer.php#L57-L79 | train |
phpro/grumphp | src/Collection/FilesCollection.php | FilesCollection.paths | public function paths(array $patterns): self
{
$filter = new Iterator\PathFilterIterator($this->getIterator(), $patterns, []);
return new self(iterator_to_array($filter));
} | php | public function paths(array $patterns): self
{
$filter = new Iterator\PathFilterIterator($this->getIterator(), $patterns, []);
return new self(iterator_to_array($filter));
} | [
"public",
"function",
"paths",
"(",
"array",
"$",
"patterns",
")",
":",
"self",
"{",
"$",
"filter",
"=",
"new",
"Iterator",
"\\",
"PathFilterIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"patterns",
",",
"[",
"]",
")",
";",
"r... | Filter by paths.
$collection->paths(['/^spec\/','/^src\/']) | [
"Filter",
"by",
"paths",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Collection/FilesCollection.php#L80-L85 | train |
phpro/grumphp | src/Collection/FilesCollection.php | FilesCollection.notPaths | public function notPaths(array $pattern): self
{
$filter = new Iterator\PathFilterIterator($this->getIterator(), [], $pattern);
return new self(iterator_to_array($filter));
} | php | public function notPaths(array $pattern): self
{
$filter = new Iterator\PathFilterIterator($this->getIterator(), [], $pattern);
return new self(iterator_to_array($filter));
} | [
"public",
"function",
"notPaths",
"(",
"array",
"$",
"pattern",
")",
":",
"self",
"{",
"$",
"filter",
"=",
"new",
"Iterator",
"\\",
"PathFilterIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"[",
"]",
",",
"$",
"pattern",
")",
";",
"... | Adds rules that filenames must not match.
You can use patterns (delimited with / sign) or simple strings.
$collection->notPaths(['/^spec\/','/^src\/']) | [
"Adds",
"rules",
"that",
"filenames",
"must",
"not",
"match",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Collection/FilesCollection.php#L106-L111 | train |
phpro/grumphp | src/Collection/FilesCollection.php | FilesCollection.filter | public function filter(Closure $closure): self
{
$filter = new Iterator\CustomFilterIterator($this->getIterator(), [$closure]);
return new self(iterator_to_array($filter));
} | php | public function filter(Closure $closure): self
{
$filter = new Iterator\CustomFilterIterator($this->getIterator(), [$closure]);
return new self(iterator_to_array($filter));
} | [
"public",
"function",
"filter",
"(",
"Closure",
"$",
"closure",
")",
":",
"self",
"{",
"$",
"filter",
"=",
"new",
"Iterator",
"\\",
"CustomFilterIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"[",
"$",
"closure",
"]",
")",
";",
"retur... | Filters the iterator with an anonymous function.
The anonymous function receives a \SplFileInfo and must return false
to remove files.
@see CustomFilterIterator | [
"Filters",
"the",
"iterator",
"with",
"an",
"anonymous",
"function",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Collection/FilesCollection.php#L173-L178 | train |
phpro/grumphp | src/Console/Command/ConfigureCommand.php | ConfigureCommand.buildConfiguration | protected function buildConfiguration(InputInterface $input, OutputInterface $output): array
{
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$questionString = $this->createQuestionString(
'Do you want to create a grumphp.yml file?',
'Yes'... | php | protected function buildConfiguration(InputInterface $input, OutputInterface $output): array
{
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$questionString = $this->createQuestionString(
'Do you want to create a grumphp.yml file?',
'Yes'... | [
"protected",
"function",
"buildConfiguration",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
":",
"array",
"{",
"/** @var QuestionHelper $helper */",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";"... | This method will ask the developer for it's input and will result in a configuration array. | [
"This",
"method",
"will",
"ask",
"the",
"developer",
"for",
"it",
"s",
"input",
"and",
"will",
"result",
"in",
"a",
"configuration",
"array",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Command/ConfigureCommand.php#L113-L162 | train |
phpro/grumphp | src/Console/Command/ConfigureCommand.php | ConfigureCommand.guessBinDir | protected function guessBinDir(): string
{
$defaultBinDir = $this->config->getBinDir();
if (!$this->composer()->hasConfiguration()) {
return $defaultBinDir;
}
$config = $this->composer()->getConfiguration();
if (!$config->has('bin-dir')) {
return $def... | php | protected function guessBinDir(): string
{
$defaultBinDir = $this->config->getBinDir();
if (!$this->composer()->hasConfiguration()) {
return $defaultBinDir;
}
$config = $this->composer()->getConfiguration();
if (!$config->has('bin-dir')) {
return $def... | [
"protected",
"function",
"guessBinDir",
"(",
")",
":",
"string",
"{",
"$",
"defaultBinDir",
"=",
"$",
"this",
"->",
"config",
"->",
"getBinDir",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"composer",
"(",
")",
"->",
"hasConfiguration",
"(",
")",... | Make a guess to the bin dir. | [
"Make",
"a",
"guess",
"to",
"the",
"bin",
"dir",
"."
] | 362a7394a3f766c374b9062b6d393dd0d61ca87a | https://github.com/phpro/grumphp/blob/362a7394a3f766c374b9062b6d393dd0d61ca87a/src/Console/Command/ConfigureCommand.php#L189-L202 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.convert | public function convert($string, $option = PINYIN_DEFAULT)
{
$pinyin = $this->romanize($string, $option);
return $this->splitWords($pinyin, $option);
} | php | public function convert($string, $option = PINYIN_DEFAULT)
{
$pinyin = $this->romanize($string, $option);
return $this->splitWords($pinyin, $option);
} | [
"public",
"function",
"convert",
"(",
"$",
"string",
",",
"$",
"option",
"=",
"PINYIN_DEFAULT",
")",
"{",
"$",
"pinyin",
"=",
"$",
"this",
"->",
"romanize",
"(",
"$",
"string",
",",
"$",
"option",
")",
";",
"return",
"$",
"this",
"->",
"splitWords",
... | Convert string to pinyin.
@param string $string
@param int $option
@return array | [
"Convert",
"string",
"to",
"pinyin",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L76-L81 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.permalink | public function permalink($string, $delimiter = '-', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, '-');
}
if (!in_array($delimiter, array('_', '-', '.', ''), true)) {
throw new InvalidArgumentException("Delimite... | php | public function permalink($string, $delimiter = '-', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, '-');
}
if (!in_array($delimiter, array('_', '-', '.', ''), true)) {
throw new InvalidArgumentException("Delimite... | [
"public",
"function",
"permalink",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"'-'",
",",
"$",
"option",
"=",
"PINYIN_DEFAULT",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"delimiter",
")",
")",
"{",
"list",
"(",
"$",
"option",
",",
"$",
"d... | Return a pinyin permalink from string.
@param string $string
@param string $delimiter
@param int $option
@return string | [
"Return",
"a",
"pinyin",
"permalink",
"from",
"string",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L107-L118 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.abbr | public function abbr($string, $delimiter = '', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, '');
}
return implode($delimiter, array_map(function ($pinyin) {
return \is_numeric($pinyin) ? $pinyin : mb_substr($pin... | php | public function abbr($string, $delimiter = '', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, '');
}
return implode($delimiter, array_map(function ($pinyin) {
return \is_numeric($pinyin) ? $pinyin : mb_substr($pin... | [
"public",
"function",
"abbr",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"''",
",",
"$",
"option",
"=",
"PINYIN_DEFAULT",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"delimiter",
")",
")",
"{",
"list",
"(",
"$",
"option",
",",
"$",
"delimit... | Return first letters.
@param string $string
@param string $delimiter
@param int $option
@return string | [
"Return",
"first",
"letters",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L129-L138 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.phrase | public function phrase($string, $delimiter = ' ', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, ' ');
}
return implode($delimiter, $this->convert($string, $option));
} | php | public function phrase($string, $delimiter = ' ', $option = PINYIN_DEFAULT)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, ' ');
}
return implode($delimiter, $this->convert($string, $option));
} | [
"public",
"function",
"phrase",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"' '",
",",
"$",
"option",
"=",
"PINYIN_DEFAULT",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"delimiter",
")",
")",
"{",
"list",
"(",
"$",
"option",
",",
"$",
"deli... | Chinese phrase to pinyin.
@param string $string
@param string $delimiter
@param int $option
@return string | [
"Chinese",
"phrase",
"to",
"pinyin",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L149-L156 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.sentence | public function sentence($string, $delimiter = ' ', $option = \PINYIN_NO_TONE)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, ' ');
}
return implode($delimiter, $this->convert($string, $option | \PINYIN_KEEP_PUNCTUATION | \PINYIN_KEEP_ENGLISH | \PINYI... | php | public function sentence($string, $delimiter = ' ', $option = \PINYIN_NO_TONE)
{
if (\is_int($delimiter)) {
list($option, $delimiter) = array($delimiter, ' ');
}
return implode($delimiter, $this->convert($string, $option | \PINYIN_KEEP_PUNCTUATION | \PINYIN_KEEP_ENGLISH | \PINYI... | [
"public",
"function",
"sentence",
"(",
"$",
"string",
",",
"$",
"delimiter",
"=",
"' '",
",",
"$",
"option",
"=",
"\\",
"PINYIN_NO_TONE",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"delimiter",
")",
")",
"{",
"list",
"(",
"$",
"option",
",",
"$... | Chinese to pinyin sentence.
@param string $string
@param string $delimiter
@param int $option
@return string | [
"Chinese",
"to",
"pinyin",
"sentence",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L167-L174 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.getLoader | public function getLoader()
{
if (!($this->loader instanceof DictLoaderInterface)) {
$dataDir = dirname(__DIR__).'/data/';
$loaderName = $this->loader;
$this->loader = new $loaderName($dataDir);
}
return $this->loader;
} | php | public function getLoader()
{
if (!($this->loader instanceof DictLoaderInterface)) {
$dataDir = dirname(__DIR__).'/data/';
$loaderName = $this->loader;
$this->loader = new $loaderName($dataDir);
}
return $this->loader;
} | [
"public",
"function",
"getLoader",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"loader",
"instanceof",
"DictLoaderInterface",
")",
")",
"{",
"$",
"dataDir",
"=",
"dirname",
"(",
"__DIR__",
")",
".",
"'/data/'",
";",
"$",
"loaderName",
"=",
"... | Return dict loader,.
@return \Overtrue\Pinyin\DictLoaderInterface | [
"Return",
"dict",
"loader",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L195-L205 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.romanize | protected function romanize($string, $option = \PINYIN_DEFAULT)
{
$string = $this->prepare($string, $option);
$dictLoader = $this->getLoader();
if ($this->hasOption($option, \PINYIN_NAME)) {
$string = $this->convertSurname($string, $dictLoader);
}
$dictLoader->... | php | protected function romanize($string, $option = \PINYIN_DEFAULT)
{
$string = $this->prepare($string, $option);
$dictLoader = $this->getLoader();
if ($this->hasOption($option, \PINYIN_NAME)) {
$string = $this->convertSurname($string, $dictLoader);
}
$dictLoader->... | [
"protected",
"function",
"romanize",
"(",
"$",
"string",
",",
"$",
"option",
"=",
"\\",
"PINYIN_DEFAULT",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"string",
",",
"$",
"option",
")",
";",
"$",
"dictLoader",
"=",
"$",
"this... | Convert Chinese to pinyin.
@param string $string
@param int $option
@return string | [
"Convert",
"Chinese",
"to",
"pinyin",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L215-L230 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.convertSurname | protected function convertSurname($string, $dictLoader)
{
$dictLoader->mapSurname(function ($dictionary) use (&$string) {
foreach ($dictionary as $surname => $pinyin) {
if (0 === strpos($string, $surname)) {
$string = $pinyin.mb_substr($string, mb_strlen($surn... | php | protected function convertSurname($string, $dictLoader)
{
$dictLoader->mapSurname(function ($dictionary) use (&$string) {
foreach ($dictionary as $surname => $pinyin) {
if (0 === strpos($string, $surname)) {
$string = $pinyin.mb_substr($string, mb_strlen($surn... | [
"protected",
"function",
"convertSurname",
"(",
"$",
"string",
",",
"$",
"dictLoader",
")",
"{",
"$",
"dictLoader",
"->",
"mapSurname",
"(",
"function",
"(",
"$",
"dictionary",
")",
"use",
"(",
"&",
"$",
"string",
")",
"{",
"foreach",
"(",
"$",
"dictiona... | Convert Chinese Surname to pinyin.
@param string $string
@param \Overtrue\Pinyin\DictLoaderInterface $dictLoader
@return string | [
"Convert",
"Chinese",
"Surname",
"to",
"pinyin",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L240-L253 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.splitWords | protected function splitWords($pinyin, $option)
{
$split = array_filter(preg_split('/\s+/i', $pinyin));
if (!$this->hasOption($option, PINYIN_TONE)) {
foreach ($split as $index => $pinyin) {
$split[$index] = $this->formatTone($pinyin, $option);
}
}
... | php | protected function splitWords($pinyin, $option)
{
$split = array_filter(preg_split('/\s+/i', $pinyin));
if (!$this->hasOption($option, PINYIN_TONE)) {
foreach ($split as $index => $pinyin) {
$split[$index] = $this->formatTone($pinyin, $option);
}
}
... | [
"protected",
"function",
"splitWords",
"(",
"$",
"pinyin",
",",
"$",
"option",
")",
"{",
"$",
"split",
"=",
"array_filter",
"(",
"preg_split",
"(",
"'/\\s+/i'",
",",
"$",
"pinyin",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"... | Split pinyin string to words.
@param string $pinyin
@param string $option
@return array | [
"Split",
"pinyin",
"string",
"to",
"words",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L263-L274 | train |
overtrue/pinyin | src/Pinyin.php | Pinyin.prepare | protected function prepare($string, $option = \PINYIN_DEFAULT)
{
$string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) {
return "\t".$matches[0];
}, $string);
$regex = array('\p{Han}', '\p{Z}', '\p{M}', "\t");
if ($this->hasOption($option, \PINYIN_KEEP_N... | php | protected function prepare($string, $option = \PINYIN_DEFAULT)
{
$string = preg_replace_callback('~[a-z0-9_-]+~i', function ($matches) {
return "\t".$matches[0];
}, $string);
$regex = array('\p{Han}', '\p{Z}', '\p{M}', "\t");
if ($this->hasOption($option, \PINYIN_KEEP_N... | [
"protected",
"function",
"prepare",
"(",
"$",
"string",
",",
"$",
"option",
"=",
"\\",
"PINYIN_DEFAULT",
")",
"{",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"'~[a-z0-9_-]+~i'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"\"\\t\"",
".",... | Pre-process.
@param string $string
@param int $option
@return string | [
"Pre",
"-",
"process",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/Pinyin.php#L295-L319 | train |
overtrue/pinyin | src/GeneratorFileDictLoader.php | GeneratorFileDictLoader.getGenerator | protected function getGenerator(array $handles)
{
foreach ($handles as $handle) {
$handle->seek(0);
while (false === $handle->eof()) {
$string = str_replace(['\'', ' ', PHP_EOL, ','], '', $handle->fgets());
if (false === strpos($string, '=>')) {
... | php | protected function getGenerator(array $handles)
{
foreach ($handles as $handle) {
$handle->seek(0);
while (false === $handle->eof()) {
$string = str_replace(['\'', ' ', PHP_EOL, ','], '', $handle->fgets());
if (false === strpos($string, '=>')) {
... | [
"protected",
"function",
"getGenerator",
"(",
"array",
"$",
"handles",
")",
"{",
"foreach",
"(",
"$",
"handles",
"as",
"$",
"handle",
")",
"{",
"$",
"handle",
"->",
"seek",
"(",
"0",
")",
";",
"while",
"(",
"false",
"===",
"$",
"handle",
"->",
"eof",... | get Generator syntax.
@param array $handles SplFileObjects
@return Generator | [
"get",
"Generator",
"syntax",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/GeneratorFileDictLoader.php#L89-L105 | train |
overtrue/pinyin | src/GeneratorFileDictLoader.php | GeneratorFileDictLoader.traversing | protected function traversing(Generator $generator, Closure $callback)
{
foreach ($generator as $string => $pinyin) {
$callback([$string => $pinyin]);
}
} | php | protected function traversing(Generator $generator, Closure $callback)
{
foreach ($generator as $string => $pinyin) {
$callback([$string => $pinyin]);
}
} | [
"protected",
"function",
"traversing",
"(",
"Generator",
"$",
"generator",
",",
"Closure",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"generator",
"as",
"$",
"string",
"=>",
"$",
"pinyin",
")",
"{",
"$",
"callback",
"(",
"[",
"$",
"string",
"=>",
... | Traverse the stream.
@param Generator $generator
@param Closure $callback
@author Seven Du <shiweidu@outlook.com> | [
"Traverse",
"the",
"stream",
"."
] | a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5 | https://github.com/overtrue/pinyin/blob/a6b1f1ecd65b5a8f79460708d1b31d4dfe0ab9c5/src/GeneratorFileDictLoader.php#L115-L120 | train |
spipu/html2pdf | src/Parsing/TagParser.php | TagParser.extractTagAttributes | public function extractTagAttributes($code)
{
$param = array();
$regexes = array(
'([a-zA-Z0-9_]+)=([^"\'\s>]+)', // read the parameters : name=value
'([a-zA-Z0-9_]+)=["]([^"]*)["]', // read the parameters : name="value"
"([a-zA-Z0-9_]+)=[']([^']*)[']" // read t... | php | public function extractTagAttributes($code)
{
$param = array();
$regexes = array(
'([a-zA-Z0-9_]+)=([^"\'\s>]+)', // read the parameters : name=value
'([a-zA-Z0-9_]+)=["]([^"]*)["]', // read the parameters : name="value"
"([a-zA-Z0-9_]+)=[']([^']*)[']" // read t... | [
"public",
"function",
"extractTagAttributes",
"(",
"$",
"code",
")",
"{",
"$",
"param",
"=",
"array",
"(",
")",
";",
"$",
"regexes",
"=",
"array",
"(",
"'([a-zA-Z0-9_]+)=([^\"\\'\\s>]+)'",
",",
"// read the parameters : name=value",
"'([a-zA-Z0-9_]+)=[\"]([^\"]*)[\"]'",... | Extract the list of attribute => value inside an HTML tag
@param string $code The full HTML tag to parse
@return array | [
"Extract",
"the",
"list",
"of",
"attribute",
"=",
">",
"value",
"inside",
"an",
"HTML",
"tag"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/TagParser.php#L208-L226 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.getOldValues | public function getOldValues()
{
return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
} | php | public function getOldValues()
{
return isset($this->table[count($this->table)-1]) ? $this->table[count($this->table)-1] : $this->value;
} | [
"public",
"function",
"getOldValues",
"(",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"table",
"[",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
"]",
")",
"?",
"$",
"this",
"->",
"table",
"[",
"count",
"(",
"$",
"this",
"->"... | Get the vales of the parent, if exist
@return array CSS values | [
"Get",
"the",
"vales",
"of",
"the",
"parent",
"if",
"exist"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L88-L91 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.setDefaultFont | public function setDefaultFont($default = null)
{
$old = $this->defaultFont;
$this->defaultFont = $default;
if ($default) {
$this->value['font-family'] = $default;
}
return $old;
} | php | public function setDefaultFont($default = null)
{
$old = $this->defaultFont;
$this->defaultFont = $default;
if ($default) {
$this->value['font-family'] = $default;
}
return $old;
} | [
"public",
"function",
"setDefaultFont",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"defaultFont",
";",
"$",
"this",
"->",
"defaultFont",
"=",
"$",
"default",
";",
"if",
"(",
"$",
"default",
")",
"{",
"$",
"this",
... | Define the Default Font to use, if the font does not exist, or if no font asked
@param string default font-family. If null : Arial for no font asked, and error fot ont does not exist
@return string old default font-family | [
"Define",
"the",
"Default",
"Font",
"to",
"use",
"if",
"the",
"font",
"does",
"not",
"exist",
"or",
"if",
"no",
"font",
"asked"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L100-L108 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.setPosition | public function setPosition()
{
// get the current position
$currentX = $this->pdf->GetX();
$currentY = $this->pdf->GetY();
// save it
$this->value['xc'] = $currentX;
$this->value['yc'] = $currentY;
if ($this->value['position'] === 'relative' || $this->value... | php | public function setPosition()
{
// get the current position
$currentX = $this->pdf->GetX();
$currentY = $this->pdf->GetY();
// save it
$this->value['xc'] = $currentX;
$this->value['yc'] = $currentY;
if ($this->value['position'] === 'relative' || $this->value... | [
"public",
"function",
"setPosition",
"(",
")",
"{",
"// get the current position",
"$",
"currentX",
"=",
"$",
"this",
"->",
"pdf",
"->",
"GetX",
"(",
")",
";",
"$",
"currentY",
"=",
"$",
"this",
"->",
"pdf",
"->",
"GetY",
"(",
")",
";",
"// save it",
"... | Set the New position for the current Tag
@return void | [
"Set",
"the",
"New",
"position",
"for",
"the",
"current",
"Tag"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L419-L474 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.getLastHeight | public function getLastHeight($mode = false)
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['height']) {
$h = $this->table[$k]['height'];
if ($mode) {
$h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['paddi... | php | public function getLastHeight($mode = false)
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['height']) {
$h = $this->table[$k]['height'];
if ($mode) {
$h+= $this->table[$k]['border']['t']['width'] + $this->table[$k]['paddi... | [
"public",
"function",
"getLastHeight",
"(",
"$",
"mode",
"=",
"false",
")",
"{",
"for",
"(",
"$",
"k",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"$",
"k",
">=",
"0",
";",
"$",
"k",
"--",
")",
"{",
"if",
"(",
"$",
"t... | Get the height of the parent
@param boolean $mode true => adding padding and border
@return float height in mm | [
"Get",
"the",
"height",
"of",
"the",
"parent"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1335-L1348 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.getLastValue | public function getLastValue($key)
{
$nb = count($this->table);
if ($nb>0) {
return $this->table[$nb-1][$key];
} else {
return null;
}
} | php | public function getLastValue($key)
{
$nb = count($this->table);
if ($nb>0) {
return $this->table[$nb-1][$key];
} else {
return null;
}
} | [
"public",
"function",
"getLastValue",
"(",
"$",
"key",
")",
"{",
"$",
"nb",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
";",
"if",
"(",
"$",
"nb",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"table",
"[",
"$",
"nb",
"-",
"1",
"]"... | Get the last value for a specific key
@param string $key
@return mixed | [
"Get",
"the",
"last",
"value",
"for",
"a",
"specific",
"key"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1373-L1381 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.getLastAbsoluteX | protected function getLastAbsoluteX()
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['x'] && $this->table[$k]['position']) {
return $this->table[$k]['x'];
}
}
return $this->pdf->getlMargin();
} | php | protected function getLastAbsoluteX()
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['x'] && $this->table[$k]['position']) {
return $this->table[$k]['x'];
}
}
return $this->pdf->getlMargin();
} | [
"protected",
"function",
"getLastAbsoluteX",
"(",
")",
"{",
"for",
"(",
"$",
"k",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"$",
"k",
">=",
"0",
";",
"$",
"k",
"--",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"table",
"[... | Get the last absolute X
@return float x | [
"Get",
"the",
"last",
"absolute",
"X"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1388-L1396 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.getLastAbsoluteY | protected function getLastAbsoluteY()
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['y'] && $this->table[$k]['position']) {
return $this->table[$k]['y'];
}
}
return $this->pdf->gettMargin();
} | php | protected function getLastAbsoluteY()
{
for ($k=count($this->table)-1; $k>=0; $k--) {
if ($this->table[$k]['y'] && $this->table[$k]['position']) {
return $this->table[$k]['y'];
}
}
return $this->pdf->gettMargin();
} | [
"protected",
"function",
"getLastAbsoluteY",
"(",
")",
"{",
"for",
"(",
"$",
"k",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"$",
"k",
">=",
"0",
";",
"$",
"k",
"--",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"table",
"[... | Get the last absolute Y
@return float y | [
"Get",
"the",
"last",
"absolute",
"Y"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1403-L1411 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.duplicateBorder | protected function duplicateBorder(&$val)
{
// 1 value => L => RTB
if (count($val) == 1) {
$val[1] = $val[0];
$val[2] = $val[0];
$val[3] = $val[0];
// 2 values => L => R & T => B
} elseif (count($val) == 2) {
$val[2] = $val[0];
... | php | protected function duplicateBorder(&$val)
{
// 1 value => L => RTB
if (count($val) == 1) {
$val[1] = $val[0];
$val[2] = $val[0];
$val[3] = $val[0];
// 2 values => L => R & T => B
} elseif (count($val) == 2) {
$val[2] = $val[0];
... | [
"protected",
"function",
"duplicateBorder",
"(",
"&",
"$",
"val",
")",
"{",
"// 1 value => L => RTB",
"if",
"(",
"count",
"(",
"$",
"val",
")",
"==",
"1",
")",
"{",
"$",
"val",
"[",
"1",
"]",
"=",
"$",
"val",
"[",
"0",
"]",
";",
"$",
"val",
"[",
... | Duplicate the borders if needed
@param &array $val
@return void | [
"Duplicate",
"the",
"borders",
"if",
"needed"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1571-L1586 | train |
spipu/html2pdf | src/Parsing/Css.php | Css.analyseStyle | protected function analyseStyle($code)
{
// clean the spaces
$code = preg_replace('/[\s]+/', ' ', $code);
// remove the comments
$code = preg_replace('/\/\*.*?\*\//s', '', $code);
// split each CSS code "selector { value }"
preg_match_all('/([^{}]+){([^}]*)}/isU', $... | php | protected function analyseStyle($code)
{
// clean the spaces
$code = preg_replace('/[\s]+/', ' ', $code);
// remove the comments
$code = preg_replace('/\/\*.*?\*\//s', '', $code);
// split each CSS code "selector { value }"
preg_match_all('/([^{}]+){([^}]*)}/isU', $... | [
"protected",
"function",
"analyseStyle",
"(",
"$",
"code",
")",
"{",
"// clean the spaces",
"$",
"code",
"=",
"preg_replace",
"(",
"'/[\\s]+/'",
",",
"' '",
",",
"$",
"code",
")",
";",
"// remove the comments",
"$",
"code",
"=",
"preg_replace",
"(",
"'/\\/\\*.... | Read a css content
@param &string $code
@return void | [
"Read",
"a",
"css",
"content"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Parsing/Css.php#L1596-L1657 | train |
spipu/html2pdf | src/Tag/AbstractSvgTag.php | AbstractSvgTag.openSvg | protected function openSvg($properties)
{
if (!$this->svgDrawer->isDrawing()) {
$e = new HtmlParsingException('The asked ['.$this->getName().'] tag is not in a [DRAW] tag');
$e->setInvalidTag($this->getName());
throw $e;
}
$transform = null;
if (a... | php | protected function openSvg($properties)
{
if (!$this->svgDrawer->isDrawing()) {
$e = new HtmlParsingException('The asked ['.$this->getName().'] tag is not in a [DRAW] tag');
$e->setInvalidTag($this->getName());
throw $e;
}
$transform = null;
if (a... | [
"protected",
"function",
"openSvg",
"(",
"$",
"properties",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"svgDrawer",
"->",
"isDrawing",
"(",
")",
")",
"{",
"$",
"e",
"=",
"new",
"HtmlParsingException",
"(",
"'The asked ['",
".",
"$",
"this",
"->",
"ge... | Open the SVG tag
@param array $properties
@throws HtmlParsingException | [
"Open",
"the",
"SVG",
"tag"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Tag/AbstractSvgTag.php#L65-L80 | train |
spipu/html2pdf | src/Tag/AbstractHtmlTag.php | AbstractHtmlTag.open | public function open($properties)
{
$this->parsingCss->save();
$this->overrideStyles();
$this->parsingCss->analyse($this->getName(), $properties);
$this->parsingCss->setPosition();
$this->parsingCss->fontSet();
return true;
} | php | public function open($properties)
{
$this->parsingCss->save();
$this->overrideStyles();
$this->parsingCss->analyse($this->getName(), $properties);
$this->parsingCss->setPosition();
$this->parsingCss->fontSet();
return true;
} | [
"public",
"function",
"open",
"(",
"$",
"properties",
")",
"{",
"$",
"this",
"->",
"parsingCss",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"overrideStyles",
"(",
")",
";",
"$",
"this",
"->",
"parsingCss",
"->",
"analyse",
"(",
"$",
"this",
"->"... | Open the HTML tag
@param array $properties properties of the HTML tag
@return boolean | [
"Open",
"the",
"HTML",
"tag"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Tag/AbstractHtmlTag.php#L27-L36 | train |
spipu/html2pdf | src/Debug/Debug.php | Debug.displayLine | protected function displayLine($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak)
{
$output =
str_pad($name, 30, ' ', STR_PAD_RIGHT).
str_pad($timeTotal, 12, ' ', STR_PAD_LEFT).
str_pad($timeStep, 12, ' ', STR_PAD_LEFT).
str_pad($memoryUsage, 15, ' ', ST... | php | protected function displayLine($name, $timeTotal, $timeStep, $memoryUsage, $memoryPeak)
{
$output =
str_pad($name, 30, ' ', STR_PAD_RIGHT).
str_pad($timeTotal, 12, ' ', STR_PAD_LEFT).
str_pad($timeStep, 12, ' ', STR_PAD_LEFT).
str_pad($memoryUsage, 15, ' ', ST... | [
"protected",
"function",
"displayLine",
"(",
"$",
"name",
",",
"$",
"timeTotal",
",",
"$",
"timeStep",
",",
"$",
"memoryUsage",
",",
"$",
"memoryPeak",
")",
"{",
"$",
"output",
"=",
"str_pad",
"(",
"$",
"name",
",",
"30",
",",
"' '",
",",
"STR_PAD_RIGH... | display a debug line
@param string $name
@param string $timeTotal
@param string $timeStep
@param string $memoryUsage
@param string $memoryPeak
@return void | [
"display",
"a",
"debug",
"line"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Debug/Debug.php#L61-L75 | train |
spipu/html2pdf | src/Debug/Debug.php | Debug.start | public function start()
{
$time = microtime(true);
$this->startTime = $time;
$this->lastTime = $time;
$this->displayLine('step', 'time', 'delta', 'memory', 'peak');
$this->addStep('Init debug');
return $this;
} | php | public function start()
{
$time = microtime(true);
$this->startTime = $time;
$this->lastTime = $time;
$this->displayLine('step', 'time', 'delta', 'memory', 'peak');
$this->addStep('Init debug');
return $this;
} | [
"public",
"function",
"start",
"(",
")",
"{",
"$",
"time",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"startTime",
"=",
"$",
"time",
";",
"$",
"this",
"->",
"lastTime",
"=",
"$",
"time",
";",
"$",
"this",
"->",
"displayLine",
"(",
... | Start the debugger
@return Debug | [
"Start",
"the",
"debugger"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Debug/Debug.php#L82-L93 | train |
spipu/html2pdf | src/Debug/Debug.php | Debug.addStep | public function addStep($name, $level = null)
{
// if true : UP
if ($level === true) {
$this->level++;
}
$time = microtime(true);
$usage = memory_get_usage();
$peak = memory_get_peak_usage();
$type = ($level === true ? ' Begin' : ($level === fa... | php | public function addStep($name, $level = null)
{
// if true : UP
if ($level === true) {
$this->level++;
}
$time = microtime(true);
$usage = memory_get_usage();
$peak = memory_get_peak_usage();
$type = ($level === true ? ' Begin' : ($level === fa... | [
"public",
"function",
"addStep",
"(",
"$",
"name",
",",
"$",
"level",
"=",
"null",
")",
"{",
"// if true : UP",
"if",
"(",
"$",
"level",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"level",
"++",
";",
"}",
"$",
"time",
"=",
"microtime",
"(",
"true"... | add a debug step
@param string $name step name
@param boolean $level (true=up, false=down, null=nothing to do)
@return Debug | [
"add",
"a",
"debug",
"step"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Debug/Debug.php#L114-L142 | train |
spipu/html2pdf | src/CssConverter.php | CssConverter.convertBackground | public function convertBackground($css, &$value)
{
// is there a image ?
$text = '/url\(([^)]*)\)/isU';
if (preg_match($text, $css, $match)) {
// get the image
$value['image'] = $this->convertBackgroundImage($match[0]);
// remove if from the css propertie... | php | public function convertBackground($css, &$value)
{
// is there a image ?
$text = '/url\(([^)]*)\)/isU';
if (preg_match($text, $css, $match)) {
// get the image
$value['image'] = $this->convertBackgroundImage($match[0]);
// remove if from the css propertie... | [
"public",
"function",
"convertBackground",
"(",
"$",
"css",
",",
"&",
"$",
"value",
")",
"{",
"// is there a image ?",
"$",
"text",
"=",
"'/url\\(([^)]*)\\)/isU'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"text",
",",
"$",
"css",
",",
"$",
"match",
")",
"... | Analyse a background
@param string $css css background properties
@param &array $value parsed values (by reference, because, ther is a legacy of the parent CSS properties)
@return void | [
"Analyse",
"a",
"background"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/CssConverter.php#L214-L271 | train |
spipu/html2pdf | src/CssConverter.php | CssConverter.convertBackgroundColor | public function convertBackgroundColor($css)
{
$res = null;
if ($css === 'transparent') {
return null;
}
return $this->convertToColor($css, $res);
} | php | public function convertBackgroundColor($css)
{
$res = null;
if ($css === 'transparent') {
return null;
}
return $this->convertToColor($css, $res);
} | [
"public",
"function",
"convertBackgroundColor",
"(",
"$",
"css",
")",
"{",
"$",
"res",
"=",
"null",
";",
"if",
"(",
"$",
"css",
"===",
"'transparent'",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"convertToColor",
"(",
"$",
"css"... | Parse a background color
@param string $css
@return string|null $value | [
"Parse",
"a",
"background",
"color"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/CssConverter.php#L280-L288 | train |
spipu/html2pdf | src/CssConverter.php | CssConverter.convertBackgroundRepeat | public function convertBackgroundRepeat($css)
{
switch ($css) {
case 'repeat':
return array(true, true);
case 'repeat-x':
return array(true, false);
case 'repeat-y':
return array(false, true);
case 'no-repeat':
... | php | public function convertBackgroundRepeat($css)
{
switch ($css) {
case 'repeat':
return array(true, true);
case 'repeat-x':
return array(true, false);
case 'repeat-y':
return array(false, true);
case 'no-repeat':
... | [
"public",
"function",
"convertBackgroundRepeat",
"(",
"$",
"css",
")",
"{",
"switch",
"(",
"$",
"css",
")",
"{",
"case",
"'repeat'",
":",
"return",
"array",
"(",
"true",
",",
"true",
")",
";",
"case",
"'repeat-x'",
":",
"return",
"array",
"(",
"true",
... | Parse a background repeat
@param string $css
@return array|null background repeat as array | [
"Parse",
"a",
"background",
"repeat"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/CssConverter.php#L391-L404 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.loadExtensions | protected function loadExtensions()
{
if ($this->extensionsLoaded) {
return;
}
foreach ($this->extensions as $extension) {
foreach ($extension->getTags() as $tag) {
if (!$tag instanceof TagInterface) {
throw new Html2PdfException('T... | php | protected function loadExtensions()
{
if ($this->extensionsLoaded) {
return;
}
foreach ($this->extensions as $extension) {
foreach ($extension->getTags() as $tag) {
if (!$tag instanceof TagInterface) {
throw new Html2PdfException('T... | [
"protected",
"function",
"loadExtensions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"extensionsLoaded",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"extensions",
"as",
"$",
"extension",
")",
"{",
"foreach",
"(",
"$",
"extension",... | Initialize the registered extensions
@throws Html2PdfException | [
"Initialize",
"the",
"registered",
"extensions"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L320-L335 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.addTagObject | protected function addTagObject(TagInterface $tagObject)
{
$tagName = strtolower($tagObject->getName());
$this->tagObjects[$tagName] = $tagObject;
} | php | protected function addTagObject(TagInterface $tagObject)
{
$tagName = strtolower($tagObject->getName());
$this->tagObjects[$tagName] = $tagObject;
} | [
"protected",
"function",
"addTagObject",
"(",
"TagInterface",
"$",
"tagObject",
")",
"{",
"$",
"tagName",
"=",
"strtolower",
"(",
"$",
"tagObject",
"->",
"getName",
"(",
")",
")",
";",
"$",
"this",
"->",
"tagObjects",
"[",
"$",
"tagName",
"]",
"=",
"$",
... | register a tag object
@param TagInterface $tagObject the object | [
"register",
"a",
"tag",
"object"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L342-L346 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.getTagObject | protected function getTagObject($tagName)
{
if (!$this->extensionsLoaded) {
$this->loadExtensions();
}
if (!array_key_exists($tagName, $this->tagObjects)) {
return null;
}
$tagObject = $this->tagObjects[$tagName];
$tagObject->setParsingCssObj... | php | protected function getTagObject($tagName)
{
if (!$this->extensionsLoaded) {
$this->loadExtensions();
}
if (!array_key_exists($tagName, $this->tagObjects)) {
return null;
}
$tagObject = $this->tagObjects[$tagName];
$tagObject->setParsingCssObj... | [
"protected",
"function",
"getTagObject",
"(",
"$",
"tagName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"extensionsLoaded",
")",
"{",
"$",
"this",
"->",
"loadExtensions",
"(",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"tagName",
"... | get the tag object from a tag name
@param string $tagName tag name to load
@return TagInterface|null | [
"get",
"the",
"tag",
"object",
"from",
"a",
"tag",
"name"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L355-L374 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.setModeDebug | public function setModeDebug(DebugInterface $debugObject = null)
{
if (is_null($debugObject)) {
$this->debug = new Debug();
} else {
$this->debug = $debugObject;
}
$this->debug->start();
return $this;
} | php | public function setModeDebug(DebugInterface $debugObject = null)
{
if (is_null($debugObject)) {
$this->debug = new Debug();
} else {
$this->debug = $debugObject;
}
$this->debug->start();
return $this;
} | [
"public",
"function",
"setModeDebug",
"(",
"DebugInterface",
"$",
"debugObject",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"debugObject",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"=",
"new",
"Debug",
"(",
")",
";",
"}",
"else",
"{",
"$... | set the debug mode to On
@param DebugInterface $debugObject
@return Html2Pdf $this | [
"set",
"the",
"debug",
"mode",
"to",
"On"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L383-L393 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.addFont | public function addFont($family, $style = '', $file = '')
{
$this->pdf->AddFont($family, $style, $file);
return $this;
} | php | public function addFont($family, $style = '', $file = '')
{
$this->pdf->AddFont($family, $style, $file);
return $this;
} | [
"public",
"function",
"addFont",
"(",
"$",
"family",
",",
"$",
"style",
"=",
"''",
",",
"$",
"file",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"pdf",
"->",
"AddFont",
"(",
"$",
"family",
",",
"$",
"style",
",",
"$",
"file",
")",
";",
"return",
"$... | add a font, see TCPDF function addFont
@access public
@param string $family Font family. The name can be chosen arbitrarily. If it is a standard family name, it will override the corresponding font.
@param string $style Font style. Possible values are (case insensitive):<ul><li>empty string: regular (default)</li><li>... | [
"add",
"a",
"font",
"see",
"TCPDF",
"function",
"addFont"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L462-L467 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.createIndex | public function createIndex(
$titre = 'Index',
$sizeTitle = 20,
$sizeBookmark = 15,
$bookmarkTitle = true,
$displayPage = true,
$onPage = null,
$fontName = null,
$marginTop = null
) {
if ($fontName === null) {
$fontName = 'helvetica... | php | public function createIndex(
$titre = 'Index',
$sizeTitle = 20,
$sizeBookmark = 15,
$bookmarkTitle = true,
$displayPage = true,
$onPage = null,
$fontName = null,
$marginTop = null
) {
if ($fontName === null) {
$fontName = 'helvetica... | [
"public",
"function",
"createIndex",
"(",
"$",
"titre",
"=",
"'Index'",
",",
"$",
"sizeTitle",
"=",
"20",
",",
"$",
"sizeBookmark",
"=",
"15",
",",
"$",
"bookmarkTitle",
"=",
"true",
",",
"$",
"displayPage",
"=",
"true",
",",
"$",
"onPage",
"=",
"null"... | display a automatic index, from the bookmarks
@access public
@param string $titre index title
@param int $sizeTitle font size of the index title, in mm
@param int $sizeBookmark font size of the index, in mm
@param boolean $bookmarkTitle add a bookmark for the index, at his beginning
@param b... | [
"display",
"a",
"automatic",
"index",
"from",
"the",
"bookmarks"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L483-L508 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.writeHTML | public function writeHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = $this->parsingCss->extractStyle($html);
$this->parsingHtml->parse($this->lexer->tokenize($html));
$this->_makeHTMLcode();
return $this;
} | php | public function writeHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = $this->parsingCss->extractStyle($html);
$this->parsingHtml->parse($this->lexer->tokenize($html));
$this->_makeHTMLcode();
return $this;
} | [
"public",
"function",
"writeHTML",
"(",
"$",
"html",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"parsingHtml",
"->",
"prepareHtml",
"(",
"$",
"html",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"parsingCss",
"->",
"extractStyle",
"(",
"$",
"ht... | convert HTML to PDF
@param string $html
@return Html2Pdf | [
"convert",
"HTML",
"to",
"PDF"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L590-L598 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.previewHTML | public function previewHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = preg_replace('/<page([^>]*)>/isU', '<hr>Page : $1<hr><div$1>', $html);
$html = preg_replace('/<page_header([^>]*)>/isU', '<hr>Page Header : $1<hr><div$1>', $html);
$html = preg_replace('/<pa... | php | public function previewHTML($html)
{
$html = $this->parsingHtml->prepareHtml($html);
$html = preg_replace('/<page([^>]*)>/isU', '<hr>Page : $1<hr><div$1>', $html);
$html = preg_replace('/<page_header([^>]*)>/isU', '<hr>Page Header : $1<hr><div$1>', $html);
$html = preg_replace('/<pa... | [
"public",
"function",
"previewHTML",
"(",
"$",
"html",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"parsingHtml",
"->",
"prepareHtml",
"(",
"$",
"html",
")",
";",
"$",
"html",
"=",
"preg_replace",
"(",
"'/<page([^>]*)>/isU'",
",",
"'<hr>Page : $1<hr><div$... | Preview the HTML before conversion
@param string $html
@return void | [
"Preview",
"the",
"HTML",
"before",
"conversion"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L608-L638 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.initSubHtml | public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb)
{
$this->_isSubPart = true;
$this->parsingCss->setOnlyLeft();
$this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null));
$this->_saveMargin(0,... | php | public function initSubHtml($format, $orientation, $marge, $page, $defLIST, $myLastPageGroup, $myLastPageGroupNb)
{
$this->_isSubPart = true;
$this->parsingCss->setOnlyLeft();
$this->_setNewPage($format, $orientation, null, null, ($myLastPageGroup !== null));
$this->_saveMargin(0,... | [
"public",
"function",
"initSubHtml",
"(",
"$",
"format",
",",
"$",
"orientation",
",",
"$",
"marge",
",",
"$",
"page",
",",
"$",
"defLIST",
",",
"$",
"myLastPageGroup",
",",
"$",
"myLastPageGroupNb",
")",
"{",
"$",
"this",
"->",
"_isSubPart",
"=",
"true"... | init a sub Html2Pdf. do not use it directly. Only the method createSubHTML must use it
@access public
@param string $format
@param string $orientation
@param array $marge
@param integer $page
@param array $defLIST
@param integer $myLastPageGroup
@param integer $myLastPageGroupNb | [
"init",
"a",
"sub",
"Html2Pdf",
".",
"do",
"not",
"use",
"it",
"directly",
".",
"Only",
"the",
"method",
"createSubHTML",
"must",
"use",
"it"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L652-L668 | train |
spipu/html2pdf | src/Html2Pdf.php | Html2Pdf.setDefaultMargins | protected function setDefaultMargins($margins)
{
if (!is_array($margins)) {
$margins = array($margins, $margins, $margins, $margins);
}
if (!isset($margins[2])) {
$margins[2] = $margins[0];
}
if (!isset($margins[3])) {
$margins[3] = 8;
... | php | protected function setDefaultMargins($margins)
{
if (!is_array($margins)) {
$margins = array($margins, $margins, $margins, $margins);
}
if (!isset($margins[2])) {
$margins[2] = $margins[0];
}
if (!isset($margins[3])) {
$margins[3] = 8;
... | [
"protected",
"function",
"setDefaultMargins",
"(",
"$",
"margins",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"margins",
")",
")",
"{",
"$",
"margins",
"=",
"array",
"(",
"$",
"margins",
",",
"$",
"margins",
",",
"$",
"margins",
",",
"$",
"margi... | set the default margins of the page
@param array|int $margins (mm, left top right bottom) | [
"set",
"the",
"default",
"margins",
"of",
"the",
"page"
] | 83c9bd942e8520681808b70584e01d17157335ba | https://github.com/spipu/html2pdf/blob/83c9bd942e8520681808b70584e01d17157335ba/src/Html2Pdf.php#L675-L692 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.