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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
koolkode/context | src/Bind/ContainerInitializerLoader.php | ContainerInitializerLoader.getHash | public function getHash()
{
$names = array_keys($this->initializers);
sort($names);
return md5(implode('|', $names));
} | php | public function getHash()
{
$names = array_keys($this->initializers);
sort($names);
return md5(implode('|', $names));
} | [
"public",
"function",
"getHash",
"(",
")",
"{",
"$",
"names",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"initializers",
")",
";",
"sort",
"(",
"$",
"names",
")",
";",
"return",
"md5",
"(",
"implode",
"(",
"'|'",
",",
"$",
"names",
")",
")",
";",
... | Get an MD5 hash computed from the sorted type names of all initializers.
@return string | [
"Get",
"an",
"MD5",
"hash",
"computed",
"from",
"the",
"sorted",
"type",
"names",
"of",
"all",
"initializers",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerInitializerLoader.php#L63-L69 | train |
koolkode/context | src/Bind/ContainerInitializerLoader.php | ContainerInitializerLoader.getLastModified | public function getLastModified()
{
$mtime = 0;
foreach($this->initializers as $initializer)
{
$mtime = max($mtime, filemtime((new \ReflectionClass(get_class($initializer)))->getFileName()));
}
return $mtime;
} | php | public function getLastModified()
{
$mtime = 0;
foreach($this->initializers as $initializer)
{
$mtime = max($mtime, filemtime((new \ReflectionClass(get_class($initializer)))->getFileName()));
}
return $mtime;
} | [
"public",
"function",
"getLastModified",
"(",
")",
"{",
"$",
"mtime",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"initializers",
"as",
"$",
"initializer",
")",
"{",
"$",
"mtime",
"=",
"max",
"(",
"$",
"mtime",
",",
"filemtime",
"(",
"(",
"new"... | Get the time of the most recent modification to an initializer.
@return integer | [
"Get",
"the",
"time",
"of",
"the",
"most",
"recent",
"modification",
"to",
"an",
"initializer",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerInitializerLoader.php#L76-L86 | train |
koolkode/context | src/Bind/ContainerInitializerLoader.php | ContainerInitializerLoader.registerInitializer | public function registerInitializer(ContainerInitializerInterface $initializer)
{
$key = get_class($initializer);
if(empty($this->initializers[$key]))
{
$this->initializers[$key] = $initializer;
}
return $this;
} | php | public function registerInitializer(ContainerInitializerInterface $initializer)
{
$key = get_class($initializer);
if(empty($this->initializers[$key]))
{
$this->initializers[$key] = $initializer;
}
return $this;
} | [
"public",
"function",
"registerInitializer",
"(",
"ContainerInitializerInterface",
"$",
"initializer",
")",
"{",
"$",
"key",
"=",
"get_class",
"(",
"$",
"initializer",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"initializers",
"[",
"$",
"key",
"]"... | Register a container initializer if it has not been registered yet.
@param ContainerInitializerInterface $initializer
@return ContainerInitializerLoader | [
"Register",
"a",
"container",
"initializer",
"if",
"it",
"has",
"not",
"been",
"registered",
"yet",
"."
] | f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36 | https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/Bind/ContainerInitializerLoader.php#L94-L104 | train |
larapulse/support | src/Helpers/Regex.php | Regex.fetchQuantifier | public static function fetchQuantifier($min = null, $max = INF, bool $lazyLoad = false) : string
{
$lazy = $lazyLoad ? '?' : '';
switch (true) {
case ($min === 0 && $max === 1):
return '?'.$lazy;
case ($min === 0 && $max === INF):
return '*'.$... | php | public static function fetchQuantifier($min = null, $max = INF, bool $lazyLoad = false) : string
{
$lazy = $lazyLoad ? '?' : '';
switch (true) {
case ($min === 0 && $max === 1):
return '?'.$lazy;
case ($min === 0 && $max === INF):
return '*'.$... | [
"public",
"static",
"function",
"fetchQuantifier",
"(",
"$",
"min",
"=",
"null",
",",
"$",
"max",
"=",
"INF",
",",
"bool",
"$",
"lazyLoad",
"=",
"false",
")",
":",
"string",
"{",
"$",
"lazy",
"=",
"$",
"lazyLoad",
"?",
"'?'",
":",
"''",
";",
"switc... | Build quantifier from parameters
@param int|null $min
@param float|int $max
@param bool $lazyLoad
@return string | [
"Build",
"quantifier",
"from",
"parameters"
] | 601ee3fd6967be669afe081322340c82c7edf32d | https://github.com/larapulse/support/blob/601ee3fd6967be669afe081322340c82c7edf32d/src/Helpers/Regex.php#L23-L42 | train |
locomotivemtl/charcoal-translator | src/Charcoal/Translator/Script/TranslationParserScript.php | TranslationParserScript.displayInformations | protected function displayInformations()
{
$this->climate()->underline()->out(
'Initializing translations parser script...'
);
$this->climate()->green()->out(
'CSV file output: <white>'.$this->filePath().'</white>'
);
$this->climate()->green()->out(
... | php | protected function displayInformations()
{
$this->climate()->underline()->out(
'Initializing translations parser script...'
);
$this->climate()->green()->out(
'CSV file output: <white>'.$this->filePath().'</white>'
);
$this->climate()->green()->out(
... | [
"protected",
"function",
"displayInformations",
"(",
")",
"{",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"underline",
"(",
")",
"->",
"out",
"(",
"'Initializing translations parser script...'",
")",
";",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"gre... | Give feedback about what's going on.
@return self Chainable. | [
"Give",
"feedback",
"about",
"what",
"s",
"going",
"on",
"."
] | 0a64432baef223dcccbfecf057015440dfa76e49 | https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Script/TranslationParserScript.php#L205-L228 | train |
locomotivemtl/charcoal-translator | src/Charcoal/Translator/Script/TranslationParserScript.php | TranslationParserScript.filePath | protected function filePath()
{
if ($this->filePath) {
return $this->filePath;
}
$base = $this->appConfig->get('base_path');
$output = $this->output();
$this->filePath = str_replace('/', DIRECTORY_SEPARATOR, $base.$output);
return $this->filePath;
} | php | protected function filePath()
{
if ($this->filePath) {
return $this->filePath;
}
$base = $this->appConfig->get('base_path');
$output = $this->output();
$this->filePath = str_replace('/', DIRECTORY_SEPARATOR, $base.$output);
return $this->filePath;
} | [
"protected",
"function",
"filePath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"filePath",
")",
"{",
"return",
"$",
"this",
"->",
"filePath",
";",
"}",
"$",
"base",
"=",
"$",
"this",
"->",
"appConfig",
"->",
"get",
"(",
"'base_path'",
")",
";",
... | Complete filepath to the CSV location.
@return string Filepath to the csv. | [
"Complete",
"filepath",
"to",
"the",
"CSV",
"location",
"."
] | 0a64432baef223dcccbfecf057015440dfa76e49 | https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Script/TranslationParserScript.php#L234-L244 | train |
locomotivemtl/charcoal-translator | src/Charcoal/Translator/Script/TranslationParserScript.php | TranslationParserScript.regEx | public function regEx($type)
{
switch ($type) {
case 'php':
$f = $this->phpFunction();
$regex = '/->'.$f.'\(\s*\n*\r*(["\'])(?<text>(.|\n|\r|\n\r)*?)\s*\n*\r*\1\)/i';
break;
case 'mustache':
$tag = $this->mustacheTag();... | php | public function regEx($type)
{
switch ($type) {
case 'php':
$f = $this->phpFunction();
$regex = '/->'.$f.'\(\s*\n*\r*(["\'])(?<text>(.|\n|\r|\n\r)*?)\s*\n*\r*\1\)/i';
break;
case 'mustache':
$tag = $this->mustacheTag();... | [
"public",
"function",
"regEx",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'php'",
":",
"$",
"f",
"=",
"$",
"this",
"->",
"phpFunction",
"(",
")",
";",
"$",
"regex",
"=",
"'/->'",
".",
"$",
"f",
".",
"'\\(\\s*\\n*\\... | Regex to match in files.
@param string $type File type (mustache|php).
@return string Regex string. | [
"Regex",
"to",
"match",
"in",
"files",
"."
] | 0a64432baef223dcccbfecf057015440dfa76e49 | https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Script/TranslationParserScript.php#L291-L310 | train |
OxfordInfoLabs/kinikit-core | src/Util/Caching/FileCache.php | FileCache.getCachedFile | public function getCachedFile($cacheKey) {
// Get directory and filename
list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);
if (file_exists($directory . "/" . $filename) && !is_dir($directory . "/" . $filename)) {
return file_get_contents($directory . "... | php | public function getCachedFile($cacheKey) {
// Get directory and filename
list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);
if (file_exists($directory . "/" . $filename) && !is_dir($directory . "/" . $filename)) {
return file_get_contents($directory . "... | [
"public",
"function",
"getCachedFile",
"(",
"$",
"cacheKey",
")",
"{",
"// Get directory and filename",
"list",
"(",
"$",
"directory",
",",
"$",
"filename",
")",
"=",
"$",
"this",
"->",
"getDirectoryAndFilenameFromKey",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(... | Get a cached file using the cache key - either a string or an array of keys
@param mixed $cacheKey | [
"Get",
"a",
"cached",
"file",
"using",
"the",
"cache",
"key",
"-",
"either",
"a",
"string",
"or",
"an",
"array",
"of",
"keys"
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Caching/FileCache.php#L31-L43 | train |
OxfordInfoLabs/kinikit-core | src/Util/Caching/FileCache.php | FileCache.cacheFile | public function cacheFile($cacheKey, $fileContents) {
// Get directory and filename
list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);
// Make the cache directory
if (!file_exists($directory)) mkdir($directory, 0777, true);
// Save the file
... | php | public function cacheFile($cacheKey, $fileContents) {
// Get directory and filename
list($directory, $filename) = $this->getDirectoryAndFilenameFromKey($cacheKey);
// Make the cache directory
if (!file_exists($directory)) mkdir($directory, 0777, true);
// Save the file
... | [
"public",
"function",
"cacheFile",
"(",
"$",
"cacheKey",
",",
"$",
"fileContents",
")",
"{",
"// Get directory and filename",
"list",
"(",
"$",
"directory",
",",
"$",
"filename",
")",
"=",
"$",
"this",
"->",
"getDirectoryAndFilenameFromKey",
"(",
"$",
"cacheKey"... | Cache a file using the file contents - overwrite if necessary.
@param $cacheKey
@param $fileContents | [
"Cache",
"a",
"file",
"using",
"the",
"file",
"contents",
"-",
"overwrite",
"if",
"necessary",
"."
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Caching/FileCache.php#L51-L62 | train |
OxfordInfoLabs/kinikit-core | src/Util/Caching/FileCache.php | FileCache.getDirectoryAndFilenameFromKey | private function getDirectoryAndFilenameFromKey($cacheKey) {
if (!is_array($cacheKey)) {
$cacheKey = array($cacheKey);
}
$filename = array_pop($cacheKey);
$dir = $this->cacheBaseDir . "/" . join("/", $cacheKey);
// Return dir and filename
return array($dir... | php | private function getDirectoryAndFilenameFromKey($cacheKey) {
if (!is_array($cacheKey)) {
$cacheKey = array($cacheKey);
}
$filename = array_pop($cacheKey);
$dir = $this->cacheBaseDir . "/" . join("/", $cacheKey);
// Return dir and filename
return array($dir... | [
"private",
"function",
"getDirectoryAndFilenameFromKey",
"(",
"$",
"cacheKey",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cacheKey",
")",
")",
"{",
"$",
"cacheKey",
"=",
"array",
"(",
"$",
"cacheKey",
")",
";",
"}",
"$",
"filename",
"=",
"array_pop... | Get the filename and directory from a key | [
"Get",
"the",
"filename",
"and",
"directory",
"from",
"a",
"key"
] | edc1b2e6ffabd595c4c7d322279b3dd1e59ef359 | https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/Caching/FileCache.php#L82-L95 | train |
miBadger/miBadger.Enum | src/Enum.php | Enum.getOrdinal | public function getOrdinal()
{
$ordinal = array_search($this->value, array_values(static::toArray()));
return $ordinal !== false ? $ordinal : -1;
} | php | public function getOrdinal()
{
$ordinal = array_search($this->value, array_values(static::toArray()));
return $ordinal !== false ? $ordinal : -1;
} | [
"public",
"function",
"getOrdinal",
"(",
")",
"{",
"$",
"ordinal",
"=",
"array_search",
"(",
"$",
"this",
"->",
"value",
",",
"array_values",
"(",
"static",
"::",
"toArray",
"(",
")",
")",
")",
";",
"return",
"$",
"ordinal",
"!==",
"false",
"?",
"$",
... | Returns the ordinal.
@return int the ordinal. | [
"Returns",
"the",
"ordinal",
"."
] | e0ed0e9c69630442b498ce2900021440224a4a15 | https://github.com/miBadger/miBadger.Enum/blob/e0ed0e9c69630442b498ce2900021440224a4a15/src/Enum.php#L54-L59 | train |
TiMESPLiNTER/tsFramework | src/ch/timesplinter/auth/AuthHandlerHttp.php | AuthHandlerHttp.http_digest_parse | private function http_digest_parse($txt) {
// gegen fehlende Daten schützen
$noetige_teile = array('nonce' => 1
,'nc' => 1
,'cnonce' => 1
,'qop' => 1
,'username' => 1
,'uri' => 1
,'response' => 1
);
$daten = array();
$schluessel = implode('|', array_key... | php | private function http_digest_parse($txt) {
// gegen fehlende Daten schützen
$noetige_teile = array('nonce' => 1
,'nc' => 1
,'cnonce' => 1
,'qop' => 1
,'username' => 1
,'uri' => 1
,'response' => 1
);
$daten = array();
$schluessel = implode('|', array_key... | [
"private",
"function",
"http_digest_parse",
"(",
"$",
"txt",
")",
"{",
"// gegen fehlende Daten schützen",
"$",
"noetige_teile",
"=",
"array",
"(",
"'nonce'",
"=>",
"1",
",",
"'nc'",
"=>",
"1",
",",
"'cnonce'",
"=>",
"1",
",",
"'qop'",
"=>",
"1",
",",
"'us... | Funktion zum analysieren der HTTP-Auth-Header | [
"Funktion",
"zum",
"analysieren",
"der",
"HTTP",
"-",
"Auth",
"-",
"Header"
] | b3b9fd98f6d456a9e571015877ecca203786fd0c | https://github.com/TiMESPLiNTER/tsFramework/blob/b3b9fd98f6d456a9e571015877ecca203786fd0c/src/ch/timesplinter/auth/AuthHandlerHttp.php#L93-L115 | train |
loevgaard/dandomain-foundation-entities | src/Entity/QueueItem.php | QueueItem.create | public static function create(string $identifier, string $type): QueueItemInterface
{
$queueItem = new self();
$queueItem
->setIdentifier($identifier)
->setType($type);
return $queueItem;
} | php | public static function create(string $identifier, string $type): QueueItemInterface
{
$queueItem = new self();
$queueItem
->setIdentifier($identifier)
->setType($type);
return $queueItem;
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"identifier",
",",
"string",
"$",
"type",
")",
":",
"QueueItemInterface",
"{",
"$",
"queueItem",
"=",
"new",
"self",
"(",
")",
";",
"$",
"queueItem",
"->",
"setIdentifier",
"(",
"$",
"identifier... | The create method creates a valid queue item object.
@param string $identifier
@param string $type
@return QueueItemInterface | [
"The",
"create",
"method",
"creates",
"a",
"valid",
"queue",
"item",
"object",
"."
] | 256f7aa8b40d2bd9488046c3c2b1e04e982d78ad | https://github.com/loevgaard/dandomain-foundation-entities/blob/256f7aa8b40d2bd9488046c3c2b1e04e982d78ad/src/Entity/QueueItem.php#L110-L118 | train |
rzajac/phptools | src/Helper/Str.php | Str.getRandomWeightedElement | public static function getRandomWeightedElement(array $weightedValues, $default = 1)
{
$sum = (int) array_sum($weightedValues);
$min = 1;
$rand = mt_rand(min($min, $sum), max($min, $sum));
$ret = $default;
foreach ($weightedValues as $key => $value) {
$rand -= ... | php | public static function getRandomWeightedElement(array $weightedValues, $default = 1)
{
$sum = (int) array_sum($weightedValues);
$min = 1;
$rand = mt_rand(min($min, $sum), max($min, $sum));
$ret = $default;
foreach ($weightedValues as $key => $value) {
$rand -= ... | [
"public",
"static",
"function",
"getRandomWeightedElement",
"(",
"array",
"$",
"weightedValues",
",",
"$",
"default",
"=",
"1",
")",
"{",
"$",
"sum",
"=",
"(",
"int",
")",
"array_sum",
"(",
"$",
"weightedValues",
")",
";",
"$",
"min",
"=",
"1",
";",
"$... | Get random weighted element.
Utility function for getting random values with weighting.
Pass in an associative array, such as array('A'=>5, 'B'=>45, 'C'=>50)
An array like this means that "A" has a 5% chance of being selected, "B" 45%, and "C" 50%.
The return value is the array key, A, B, or C in this case. Note tha... | [
"Get",
"random",
"weighted",
"element",
"."
] | 3cbece7645942d244603c14ba897d8a676ee3088 | https://github.com/rzajac/phptools/blob/3cbece7645942d244603c14ba897d8a676ee3088/src/Helper/Str.php#L95-L114 | train |
rzajac/phptools | src/Helper/Str.php | Str.toString | public static function toString($value)
{
if (is_null($value)) {
$ret = 'null';
} elseif (is_bool($value)) {
$ret = $value ? 'true' : 'false';
} elseif (is_array($value)) {
$ret = '[' . implode(',', $value) . ']';
} else if ((!is_object($value) && ... | php | public static function toString($value)
{
if (is_null($value)) {
$ret = 'null';
} elseif (is_bool($value)) {
$ret = $value ? 'true' : 'false';
} elseif (is_array($value)) {
$ret = '[' . implode(',', $value) . ']';
} else if ((!is_object($value) && ... | [
"public",
"static",
"function",
"toString",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"ret",
"=",
"'null'",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"ret",
"=",
"... | Cast anything to string.
@param mixed $value The value to cast to string.
@return string | [
"Cast",
"anything",
"to",
"string",
"."
] | 3cbece7645942d244603c14ba897d8a676ee3088 | https://github.com/rzajac/phptools/blob/3cbece7645942d244603c14ba897d8a676ee3088/src/Helper/Str.php#L227-L244 | train |
rzajac/phptools | src/Helper/Str.php | Str.contains | public static function contains($haystack, $needle, $ignoreCase = false)
{
if ($ignoreCase) {
$needle = strtolower($needle);
$haystack = strtolower($haystack);
}
$pos = strpos($haystack, $needle);
return !($pos === false);
} | php | public static function contains($haystack, $needle, $ignoreCase = false)
{
if ($ignoreCase) {
$needle = strtolower($needle);
$haystack = strtolower($haystack);
}
$pos = strpos($haystack, $needle);
return !($pos === false);
} | [
"public",
"static",
"function",
"contains",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"$",
"ignoreCase",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"ignoreCase",
")",
"{",
"$",
"needle",
"=",
"strtolower",
"(",
"$",
"needle",
")",
";",
"$",
"haysta... | Return true if haystack contains needle.
@param string $haystack The string to check for needle existence.
@param string $needle The string to find in the haystack.
@param bool $ignoreCase Set to true to ignore case.
@return bool | [
"Return",
"true",
"if",
"haystack",
"contains",
"needle",
"."
] | 3cbece7645942d244603c14ba897d8a676ee3088 | https://github.com/rzajac/phptools/blob/3cbece7645942d244603c14ba897d8a676ee3088/src/Helper/Str.php#L255-L264 | train |
frameworkwtf/core | src/Root.php | Root.setData | public function setData(array $data): self
{
$this->data = \array_merge($this->data, $data);
return $this;
} | php | public function setData(array $data): self
{
$this->data = \array_merge($this->data, $data);
return $this;
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set all data to entity.
@param array $data
@return Root | [
"Set",
"all",
"data",
"to",
"entity",
"."
] | 8104ca140ec287c26724389780e5e1dba57a030a | https://github.com/frameworkwtf/core/blob/8104ca140ec287c26724389780e5e1dba57a030a/src/Root.php#L127-L132 | train |
jonesiscoding/xq-sassy | src/AbstractSassDriver.php | AbstractSassDriver.setOutputStyle | public function setOutputStyle( $style )
{
$possibleStyles = array(
self::STYLE_NESTED,
self::STYLE_EXPANDED,
self::STYLE_COMPACT,
self::STYLE_COMPRESSED
);
if ( !in_array( $style, $possibleStyles ) )
{
throw new \Exception( 'Invalid output style specified.' );
}
... | php | public function setOutputStyle( $style )
{
$possibleStyles = array(
self::STYLE_NESTED,
self::STYLE_EXPANDED,
self::STYLE_COMPACT,
self::STYLE_COMPRESSED
);
if ( !in_array( $style, $possibleStyles ) )
{
throw new \Exception( 'Invalid output style specified.' );
}
... | [
"public",
"function",
"setOutputStyle",
"(",
"$",
"style",
")",
"{",
"$",
"possibleStyles",
"=",
"array",
"(",
"self",
"::",
"STYLE_NESTED",
",",
"self",
"::",
"STYLE_EXPANDED",
",",
"self",
"::",
"STYLE_COMPACT",
",",
"self",
"::",
"STYLE_COMPRESSED",
")",
... | Sets the output style between the various output styles supported by SASS.
@param int $style One of the output style constants from this class.
@return $this
@throws \Exception If an invalid output style is specified. | [
"Sets",
"the",
"output",
"style",
"between",
"the",
"various",
"output",
"styles",
"supported",
"by",
"SASS",
"."
] | cad2575ac54c997f9bf13233775fb4738dee4bbf | https://github.com/jonesiscoding/xq-sassy/blob/cad2575ac54c997f9bf13233775fb4738dee4bbf/src/AbstractSassDriver.php#L69-L86 | train |
jonesiscoding/xq-sassy | src/AbstractSassDriver.php | AbstractSassDriver.setDefaults | protected function setDefaults()
{
$this->importPaths = array();
$this->pluginPaths = array();
$this->sourceMap = self::DEFAULT_SOURCEMAP;
$this->mapComment = self::DEFAULT_MAPCOMMENT;
$this->lineNumbers = self::DEFAULT_LINENUMBERS;
$this->precision = self::DEFAULT_PRECISION;
$this->style ... | php | protected function setDefaults()
{
$this->importPaths = array();
$this->pluginPaths = array();
$this->sourceMap = self::DEFAULT_SOURCEMAP;
$this->mapComment = self::DEFAULT_MAPCOMMENT;
$this->lineNumbers = self::DEFAULT_LINENUMBERS;
$this->precision = self::DEFAULT_PRECISION;
$this->style ... | [
"protected",
"function",
"setDefaults",
"(",
")",
"{",
"$",
"this",
"->",
"importPaths",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"pluginPaths",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"sourceMap",
"=",
"self",
"::",
"DEFAULT_SOURCEMAP",
... | Sets the object's properties back to their defaults. | [
"Sets",
"the",
"object",
"s",
"properties",
"back",
"to",
"their",
"defaults",
"."
] | cad2575ac54c997f9bf13233775fb4738dee4bbf | https://github.com/jonesiscoding/xq-sassy/blob/cad2575ac54c997f9bf13233775fb4738dee4bbf/src/AbstractSassDriver.php#L207-L216 | train |
kaiohken1982/Neobazaar | src/Neobazaar/Doctrine/ORM/EntityRepository.php | EntityRepository.findByEncryptedId | public function findByEncryptedId($id, $field = 'id')
{
$hashids = $this->getServiceLocator()->get('neobazaar.service.hashid');
$id = $hashids->decrypt($id);
$id = is_array($id) ? reset($id) : $id;
$options = array();
$qb = $this->_em->createQueryBuilder();
$qb->select(ar... | php | public function findByEncryptedId($id, $field = 'id')
{
$hashids = $this->getServiceLocator()->get('neobazaar.service.hashid');
$id = $hashids->decrypt($id);
$id = is_array($id) ? reset($id) : $id;
$options = array();
$qb = $this->_em->createQueryBuilder();
$qb->select(ar... | [
"public",
"function",
"findByEncryptedId",
"(",
"$",
"id",
",",
"$",
"field",
"=",
"'id'",
")",
"{",
"$",
"hashids",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'neobazaar.service.hashid'",
")",
";",
"$",
"id",
"=",
"$",
"... | Get an entity using the encrypted ID
@param string $id
@param string $field
@return unknown | [
"Get",
"an",
"entity",
"using",
"the",
"encrypted",
"ID"
] | 288c972dea981d715c4e136edb5dba0318c9e6cb | https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Doctrine/ORM/EntityRepository.php#L47-L62 | train |
kaiohken1982/Neobazaar | src/Neobazaar/Doctrine/ORM/EntityRepository.php | EntityRepository.getEncryptedId | public function getEncryptedId($id)
{
$hashids = $this->getServiceLocator()->get('neobazaar.service.hashid');
$hash = $hashids->encrypt($id);
return $hash;
} | php | public function getEncryptedId($id)
{
$hashids = $this->getServiceLocator()->get('neobazaar.service.hashid');
$hash = $hashids->encrypt($id);
return $hash;
} | [
"public",
"function",
"getEncryptedId",
"(",
"$",
"id",
")",
"{",
"$",
"hashids",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'neobazaar.service.hashid'",
")",
";",
"$",
"hash",
"=",
"$",
"hashids",
"->",
"encrypt",
"(",
"$"... | Return the encrypted id using hash id service
@param int $id
@return string | [
"Return",
"the",
"encrypted",
"id",
"using",
"hash",
"id",
"service"
] | 288c972dea981d715c4e136edb5dba0318c9e6cb | https://github.com/kaiohken1982/Neobazaar/blob/288c972dea981d715c4e136edb5dba0318c9e6cb/src/Neobazaar/Doctrine/ORM/EntityRepository.php#L70-L76 | train |
xZ1mEFx/yii2-base | helpers/Url.php | Url.removeUrlSegment | public static function removeUrlSegment($url, $segment, $replacement = '/')
{
$preparedSegment = trim($segment, '/');
if (empty($preparedSegment)) {
return $url;
}
preg_match('/^([^?]+?)(\?.+?)?$/', $url, $matches); // get url and get apart
return preg_replace(
... | php | public static function removeUrlSegment($url, $segment, $replacement = '/')
{
$preparedSegment = trim($segment, '/');
if (empty($preparedSegment)) {
return $url;
}
preg_match('/^([^?]+?)(\?.+?)?$/', $url, $matches); // get url and get apart
return preg_replace(
... | [
"public",
"static",
"function",
"removeUrlSegment",
"(",
"$",
"url",
",",
"$",
"segment",
",",
"$",
"replacement",
"=",
"'/'",
")",
"{",
"$",
"preparedSegment",
"=",
"trim",
"(",
"$",
"segment",
",",
"'/'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"pr... | Try to remove URL segment
@param string $url Subject URL
@param string $segment Search segment
@param string $replacement Replacement string
@return string Results URL | [
"Try",
"to",
"remove",
"URL",
"segment"
] | f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a | https://github.com/xZ1mEFx/yii2-base/blob/f6633c08ccccb7eb5ac000dfae0db26cb2e0a76a/helpers/Url.php#L20-L32 | train |
ekyna/MediaBundle | Browser/Browser.php | Browser.findMedias | public function findMedias(array $types = [])
{
if (null === $this->folder) {
throw new \RuntimeException('No folder selected.');
}
$criteria = ['folder' => $this->folder];
if (count($types)) {
$criteria['type'] = $types;
}
/** @var MediaInte... | php | public function findMedias(array $types = [])
{
if (null === $this->folder) {
throw new \RuntimeException('No folder selected.');
}
$criteria = ['folder' => $this->folder];
if (count($types)) {
$criteria['type'] = $types;
}
/** @var MediaInte... | [
"public",
"function",
"findMedias",
"(",
"array",
"$",
"types",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"folder",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No folder selected.'",
")",
";",
"}",
"$",
"crite... | Returns the media found in the current folder.
@param array $types
@return MediaInterface[] | [
"Returns",
"the",
"media",
"found",
"in",
"the",
"current",
"folder",
"."
] | 512cf86c801a130a9f17eba8b48d646d23acdbab | https://github.com/ekyna/MediaBundle/blob/512cf86c801a130a9f17eba8b48d646d23acdbab/Browser/Browser.php#L72-L94 | train |
koolkode/lexer | src/AbstractLexer.php | AbstractLexer.tokenizeUrl | public function tokenizeUrl($url)
{
if(!is_file($url))
{
throw new \RuntimeException(sprintf('URL does not point to a valid file: "%s"', $url));
}
$source = @file_get_contents($url);
if($source === false)
{
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to tokenize c... | php | public function tokenizeUrl($url)
{
if(!is_file($url))
{
throw new \RuntimeException(sprintf('URL does not point to a valid file: "%s"', $url));
}
$source = @file_get_contents($url);
if($source === false)
{
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to tokenize c... | [
"public",
"function",
"tokenizeUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'URL does not point to a valid file: \"%s\"'",
",",
"$",
"url",
")",
... | Tokenize the resource at the given url and return the
resulting token sequence.
@param string $url
@return AbstractTokenSequence
@throws \RuntimeException | [
"Tokenize",
"the",
"resource",
"at",
"the",
"given",
"url",
"and",
"return",
"the",
"resulting",
"token",
"sequence",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractLexer.php#L39-L56 | train |
koolkode/lexer | src/AbstractLexer.php | AbstractLexer.readLiteral | protected function readLiteral($input, $delim = '"', $escaper = NULL)
{
$literal = '';
$escaped = false;
$terminated = false;
for($size = strlen($input), $i = 1; $i < $size; $i++)
{
if($input[$i] == $escaper)
{
if($escaped)
{
$literal .= $escaper;
$escaped = false;
conti... | php | protected function readLiteral($input, $delim = '"', $escaper = NULL)
{
$literal = '';
$escaped = false;
$terminated = false;
for($size = strlen($input), $i = 1; $i < $size; $i++)
{
if($input[$i] == $escaper)
{
if($escaped)
{
$literal .= $escaper;
$escaped = false;
conti... | [
"protected",
"function",
"readLiteral",
"(",
"$",
"input",
",",
"$",
"delim",
"=",
"'\"'",
",",
"$",
"escaper",
"=",
"NULL",
")",
"{",
"$",
"literal",
"=",
"''",
";",
"$",
"escaped",
"=",
"false",
";",
"$",
"terminated",
"=",
"false",
";",
"for",
"... | Reads a literal from the input delimited by the given delimiter.
@param string $input
@param string $delim The delimiter character.
@param string $escaper An escaping character.
@return string Parsed literal value without delimters.
@throws \RuntimeException When an unterminated literal is detected. | [
"Reads",
"a",
"literal",
"from",
"the",
"input",
"delimited",
"by",
"the",
"given",
"delimiter",
"."
] | 1f33fb4e95bf3b6b21c63187e503bbe612a1646c | https://github.com/koolkode/lexer/blob/1f33fb4e95bf3b6b21c63187e503bbe612a1646c/src/AbstractLexer.php#L68-L116 | train |
bkstg/schedule-bundle | Entity/Event.php | Event.addGroup | public function addGroup(GroupInterface $group): self
{
if (!$group instanceof Production) {
throw new Exception('Group type not supported.');
}
$this->groups[] = $group;
return $this;
} | php | public function addGroup(GroupInterface $group): self
{
if (!$group instanceof Production) {
throw new Exception('Group type not supported.');
}
$this->groups[] = $group;
return $this;
} | [
"public",
"function",
"addGroup",
"(",
"GroupInterface",
"$",
"group",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"group",
"instanceof",
"Production",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Group type not supported.'",
")",
";",
"}",
"$",
"this",
"... | Add group.
@param Production $group The production.
@return Event | [
"Add",
"group",
"."
] | e64ac897aa7b28bc48319470d65de13cd4788afe | https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Entity/Event.php#L257-L265 | train |
bkstg/schedule-bundle | Entity/Event.php | Event.addInvitation | public function addInvitation(Invitation $invitation): self
{
$invitation->setEvent($this);
$this->invitations[] = $invitation;
return $this;
} | php | public function addInvitation(Invitation $invitation): self
{
$invitation->setEvent($this);
$this->invitations[] = $invitation;
return $this;
} | [
"public",
"function",
"addInvitation",
"(",
"Invitation",
"$",
"invitation",
")",
":",
"self",
"{",
"$",
"invitation",
"->",
"setEvent",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"invitations",
"[",
"]",
"=",
"$",
"invitation",
";",
"return",
"$",
... | Add invitation.
@param Invitation $invitation The invitation.
@return Event | [
"Add",
"invitation",
"."
] | e64ac897aa7b28bc48319470d65de13cd4788afe | https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Entity/Event.php#L314-L320 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.getConnection | public static function getConnection($filter = ''){
switch ($filter) {
case 'host':
return self::$_host;
break;
case 'port':
return self::$_port;
break;
case 'dbname':
return self::$_dbname;
break;
case 'user':
return self::$_user;
break;
default... | php | public static function getConnection($filter = ''){
switch ($filter) {
case 'host':
return self::$_host;
break;
case 'port':
return self::$_port;
break;
case 'dbname':
return self::$_dbname;
break;
case 'user':
return self::$_user;
break;
default... | [
"public",
"static",
"function",
"getConnection",
"(",
"$",
"filter",
"=",
"''",
")",
"{",
"switch",
"(",
"$",
"filter",
")",
"{",
"case",
"'host'",
":",
"return",
"self",
"::",
"$",
"_host",
";",
"break",
";",
"case",
"'port'",
":",
"return",
"self",
... | Get specific connection parameters. Unfortunately the password is used during the
connection phase and is not stored therefore not returnable.
@method getConnection
@param string $filter A database connection parameter (host, port, dbname, user).
If none is supplied, the PDO object is returned instead.
@retu... | [
"Get",
"specific",
"connection",
"parameters",
".",
"Unfortunately",
"the",
"password",
"is",
"used",
"during",
"the",
"connection",
"phase",
"and",
"is",
"not",
"stored",
"therefore",
"not",
"returnable",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L207-L229 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.table | public function table($t){
if(is_array($t)){
$tArray = $t;
$t = $t_alias = array_shift(array_keys($tArray));
$driver = get_called_class();
if(($tArray[$t_alias] instanceof $driver) === true){
$this->_placeholders = array_merge($this->_placeholders, $tArray[$t_alias]->queryData());
$t = $tAr... | php | public function table($t){
if(is_array($t)){
$tArray = $t;
$t = $t_alias = array_shift(array_keys($tArray));
$driver = get_called_class();
if(($tArray[$t_alias] instanceof $driver) === true){
$this->_placeholders = array_merge($this->_placeholders, $tArray[$t_alias]->queryData());
$t = $tAr... | [
"public",
"function",
"table",
"(",
"$",
"t",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"t",
")",
")",
"{",
"$",
"tArray",
"=",
"$",
"t",
";",
"$",
"t",
"=",
"$",
"t_alias",
"=",
"array_shift",
"(",
"array_keys",
"(",
"$",
"tArray",
")",
")",
... | Set a table or subquery to execute the query on.
@param mixed $t Can be a string defining the table to execute the query on or an array
whose key is a subquery alias and the value is a Squibble object.
@return object returns the current squibble object. | [
"Set",
"a",
"table",
"or",
"subquery",
"to",
"execute",
"the",
"query",
"on",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L276-L296 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.select | public function select($t, $c = array()){
if(!is_array($c)){
$c = array($c);
}
if(is_array($t)){
$c = $t;
}elseif(is_string($t)){
$this->table($t);
}
$columns = [];
foreach($c as $i => $s){
$column = [];
if(!is_array($s)){
$column = \Dorsataio\Squibble\Resource\Extract::fro... | php | public function select($t, $c = array()){
if(!is_array($c)){
$c = array($c);
}
if(is_array($t)){
$c = $t;
}elseif(is_string($t)){
$this->table($t);
}
$columns = [];
foreach($c as $i => $s){
$column = [];
if(!is_array($s)){
$column = \Dorsataio\Squibble\Resource\Extract::fro... | [
"public",
"function",
"select",
"(",
"$",
"t",
",",
"$",
"c",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"c",
")",
")",
"{",
"$",
"c",
"=",
"array",
"(",
"$",
"c",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$... | Start a new SELECT query.
@param array $c Array containing columns that the SELECT query will return.
@return object returns the current squibble object. | [
"Start",
"a",
"new",
"SELECT",
"query",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L305-L328 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.insert | public function insert($t, $nvp = array()){
$nvps = $nvp;
if(is_array($t)){
$nvps = $t;
}elseif(is_string($t)){
$this->table($t);
}
if(!isset($nvps[0])){
$nvps = array($nvps);
}
$columns = [];
foreach($nvps as $i => $nvp){
$columns[$i] = [];
foreach(array_keys($nvp) as $s){
... | php | public function insert($t, $nvp = array()){
$nvps = $nvp;
if(is_array($t)){
$nvps = $t;
}elseif(is_string($t)){
$this->table($t);
}
if(!isset($nvps[0])){
$nvps = array($nvps);
}
$columns = [];
foreach($nvps as $i => $nvp){
$columns[$i] = [];
foreach(array_keys($nvp) as $s){
... | [
"public",
"function",
"insert",
"(",
"$",
"t",
",",
"$",
"nvp",
"=",
"array",
"(",
")",
")",
"{",
"$",
"nvps",
"=",
"$",
"nvp",
";",
"if",
"(",
"is_array",
"(",
"$",
"t",
")",
")",
"{",
"$",
"nvps",
"=",
"$",
"t",
";",
"}",
"elseif",
"(",
... | Start a new INSERT query.
@param array $nvp An NVP array containing columns their value to be inserted.
@return object returns the current squibble object. | [
"Start",
"a",
"new",
"INSERT",
"query",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L337-L358 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.update | public function update($t, $nvp = array()){
if(is_array($t)){
$nvp = $t;
}elseif(is_string($t)){
$this->table($t);
}
$columns = [];
foreach(array_keys($nvp) as $s){
$column = \Dorsataio\Squibble\Resource\Extract::fromColumn($s);
$column['value'] = $nvp[$s];
array_push($columns, $colum... | php | public function update($t, $nvp = array()){
if(is_array($t)){
$nvp = $t;
}elseif(is_string($t)){
$this->table($t);
}
$columns = [];
foreach(array_keys($nvp) as $s){
$column = \Dorsataio\Squibble\Resource\Extract::fromColumn($s);
$column['value'] = $nvp[$s];
array_push($columns, $colum... | [
"public",
"function",
"update",
"(",
"$",
"t",
",",
"$",
"nvp",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"t",
")",
")",
"{",
"$",
"nvp",
"=",
"$",
"t",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"t",
")",
")",... | Start a new UPDATE query.
@param array $nvp An NVP array containing columns their value to be updated.
@return object returns the current squibble object. | [
"Start",
"a",
"new",
"UPDATE",
"query",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L367-L381 | train |
dorsataio/Squibble | src/SquibbleDriver.php | SquibbleDriver.delete | public function delete($t, $conditions = array()){
if(is_array($t)){
$conditions = $t;
}elseif(is_string($t)){
$this->table($t);
}
if(!empty($conditions)){
$this->where($conditions);
}
$this->_sql = $this->getDeleteStatement();
return $this;
} | php | public function delete($t, $conditions = array()){
if(is_array($t)){
$conditions = $t;
}elseif(is_string($t)){
$this->table($t);
}
if(!empty($conditions)){
$this->where($conditions);
}
$this->_sql = $this->getDeleteStatement();
return $this;
} | [
"public",
"function",
"delete",
"(",
"$",
"t",
",",
"$",
"conditions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"t",
")",
")",
"{",
"$",
"conditions",
"=",
"$",
"t",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"t",... | Start a new DELETE query.
@param array $conditions An NVP array containing WHERE conditions.
@return object returns the current squibble object. | [
"Start",
"a",
"new",
"DELETE",
"query",
"."
] | 77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9 | https://github.com/dorsataio/Squibble/blob/77f3e8049c11b6cb56baac4686c0bd2a82e5b6e9/src/SquibbleDriver.php#L390-L401 | train |
TeaLabs/collections | src/Forest.php | Forest.get | public function get($path, $default = null)
{
return Arr::get($this->items, $this->keyFor($path), $default);
} | php | public function get($path, $default = null)
{
return Arr::get($this->items, $this->keyFor($path), $default);
} | [
"public",
"function",
"get",
"(",
"$",
"path",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"this",
"->",
"keyFor",
"(",
"$",
"path",
")",
",",
"$",
"default",
")",
";",
"}... | Get an item from the collection by path.
@param mixed $path
@param mixed $default
@return mixed | [
"Get",
"an",
"item",
"from",
"the",
"collection",
"by",
"path",
"."
] | 5d8885b2799791c0bcbff4e6cbacddb270b4288e | https://github.com/TeaLabs/collections/blob/5d8885b2799791c0bcbff4e6cbacddb270b4288e/src/Forest.php#L94-L97 | train |
hiqdev/minii-validators | src/IpValidator.php | IpValidator.inRange | private function inRange($ip, $cidr, $range)
{
$ipVersion = $this->getIpVersion($ip);
$binIp = $this->ip2bin($ip);
$parts = explode('/', $range);
$net = array_shift($parts);
$range_cidr = array_shift($parts);
$netVersion = $this->getIpVersion($net);
if ($ip... | php | private function inRange($ip, $cidr, $range)
{
$ipVersion = $this->getIpVersion($ip);
$binIp = $this->ip2bin($ip);
$parts = explode('/', $range);
$net = array_shift($parts);
$range_cidr = array_shift($parts);
$netVersion = $this->getIpVersion($net);
if ($ip... | [
"private",
"function",
"inRange",
"(",
"$",
"ip",
",",
"$",
"cidr",
",",
"$",
"range",
")",
"{",
"$",
"ipVersion",
"=",
"$",
"this",
"->",
"getIpVersion",
"(",
"$",
"ip",
")",
";",
"$",
"binIp",
"=",
"$",
"this",
"->",
"ip2bin",
"(",
"$",
"ip",
... | Checks whether the IP is in subnet range
@param string $ip an IPv4 or IPv6 address
@param integer $cidr
@param string $range subnet in CIDR format e.g. `10.0.0.0/8` or `2001:af::/64`
@return bool | [
"Checks",
"whether",
"the",
"IP",
"is",
"in",
"subnet",
"range"
] | 3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741 | https://github.com/hiqdev/minii-validators/blob/3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741/src/IpValidator.php#L511-L534 | train |
hiqdev/minii-validators | src/IpValidator.php | IpValidator.ip2bin | private function ip2bin($ip)
{
if ($this->getIpVersion($ip) === 4) {
return str_pad(base_convert(ip2long($ip), 10, 2), static::IPV4_ADDRESS_LENGTH, '0', STR_PAD_LEFT);
} else {
$unpack = unpack('A16', inet_pton($ip));
$binStr = array_shift($unpack);
$b... | php | private function ip2bin($ip)
{
if ($this->getIpVersion($ip) === 4) {
return str_pad(base_convert(ip2long($ip), 10, 2), static::IPV4_ADDRESS_LENGTH, '0', STR_PAD_LEFT);
} else {
$unpack = unpack('A16', inet_pton($ip));
$binStr = array_shift($unpack);
$b... | [
"private",
"function",
"ip2bin",
"(",
"$",
"ip",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIpVersion",
"(",
"$",
"ip",
")",
"===",
"4",
")",
"{",
"return",
"str_pad",
"(",
"base_convert",
"(",
"ip2long",
"(",
"$",
"ip",
")",
",",
"10",
",",
"2"... | Converts IP address to bits representation
@param string $ip
@return string bits as a string | [
"Converts",
"IP",
"address",
"to",
"bits",
"representation"
] | 3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741 | https://github.com/hiqdev/minii-validators/blob/3e32ccf5d0dadc070bc5a9bd6ebe98f778a1f741/src/IpValidator.php#L542-L556 | train |
kambalabs/KmbDomain | src/KmbDomain/Model/Group.php | Group.dump | public function dump()
{
$dump = [];
if ($this->hasClasses()) {
foreach ($this->classes as $class) {
$dump[$class->getName()] = $class->dump();
}
}
return $dump;
} | php | public function dump()
{
$dump = [];
if ($this->hasClasses()) {
foreach ($this->classes as $class) {
$dump[$class->getName()] = $class->dump();
}
}
return $dump;
} | [
"public",
"function",
"dump",
"(",
")",
"{",
"$",
"dump",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"hasClasses",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"dump",
"[",
"$",
"... | Dump group classes.
@return array | [
"Dump",
"group",
"classes",
"."
] | b1631bd936c6c6798076b51dfaebd706e1bdc8c2 | https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Model/Group.php#L374-L383 | train |
kambalabs/KmbDomain | src/KmbDomain/Model/Group.php | Group.extract | public function extract()
{
return [
'name' => $this->getName(),
'ordering' => $this->getOrdering(),
'type' => $this->getType(),
'include_pattern' => $this->getIncludePattern(),
'exclude_pattern' => $this->getExcludePattern(),
'classes'... | php | public function extract()
{
return [
'name' => $this->getName(),
'ordering' => $this->getOrdering(),
'type' => $this->getType(),
'include_pattern' => $this->getIncludePattern(),
'exclude_pattern' => $this->getExcludePattern(),
'classes'... | [
"public",
"function",
"extract",
"(",
")",
"{",
"return",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'ordering'",
"=>",
"$",
"this",
"->",
"getOrdering",
"(",
")",
",",
"'type'",
"=>",
"$",
"this",
"->",
"getType",
"(",
")",
... | Extract all group's data in array.
@return array | [
"Extract",
"all",
"group",
"s",
"data",
"in",
"array",
"."
] | b1631bd936c6c6798076b51dfaebd706e1bdc8c2 | https://github.com/kambalabs/KmbDomain/blob/b1631bd936c6c6798076b51dfaebd706e1bdc8c2/src/KmbDomain/Model/Group.php#L390-L400 | train |
OliverMonneke/pennePHP | src/Datatype/Boolean.php | Boolean.isValid | public static function isValid($expression, $translate = false)
{
if ($translate) {
$expression = self::translate($expression);
}
return is_bool($expression);
} | php | public static function isValid($expression, $translate = false)
{
if ($translate) {
$expression = self::translate($expression);
}
return is_bool($expression);
} | [
"public",
"static",
"function",
"isValid",
"(",
"$",
"expression",
",",
"$",
"translate",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"translate",
")",
"{",
"$",
"expression",
"=",
"self",
"::",
"translate",
"(",
"$",
"expression",
")",
";",
"}",
"return",... | Check if expression is valid
@param mixed $expression The expression to check
@param bool $translate
@return bool | [
"Check",
"if",
"expression",
"is",
"valid"
] | dd0de7944685a3f1947157e1254fc54b55ff9942 | https://github.com/OliverMonneke/pennePHP/blob/dd0de7944685a3f1947157e1254fc54b55ff9942/src/Datatype/Boolean.php#L37-L44 | train |
libgraviton/analytics-mongoshell-converter | src/Parser.php | Parser.parse | public function parse()
{
$this->lexer->moveNext();
while (true) {
if (!$this->lexer->lookahead) {
break;
}
$this->lexer->moveNext();
$thisLine = null;
switch ($this->lexer->token['type']) {
case Lexer::T_... | php | public function parse()
{
$this->lexer->moveNext();
while (true) {
if (!$this->lexer->lookahead) {
break;
}
$this->lexer->moveNext();
$thisLine = null;
switch ($this->lexer->token['type']) {
case Lexer::T_... | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"this",
"->",
"lexer",
"->",
"moveNext",
"(",
")",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"lexer",
"->",
"lookahead",
")",
"{",
"break",
";",
"}",
"$",
"this",
... | parses our stuff
@return string parsed pipeline as a script | [
"parses",
"our",
"stuff"
] | 437731c353c58978d39bcd40ac5a741a0b106667 | https://github.com/libgraviton/analytics-mongoshell-converter/blob/437731c353c58978d39bcd40ac5a741a0b106667/src/Parser.php#L46-L133 | train |
FusePump/cli.php | lib/FusePump/Cli/Colours.php | Colours.string | public static function string($string, $foreground_colour = null, $background_colour = null)
{
$coloured_string = "";
// Check if given foreground colour found
if (isset(self::$foreground_colours[$foreground_colour])) {
$coloured_string .= self::getForegroundCode($foreground_col... | php | public static function string($string, $foreground_colour = null, $background_colour = null)
{
$coloured_string = "";
// Check if given foreground colour found
if (isset(self::$foreground_colours[$foreground_colour])) {
$coloured_string .= self::getForegroundCode($foreground_col... | [
"public",
"static",
"function",
"string",
"(",
"$",
"string",
",",
"$",
"foreground_colour",
"=",
"null",
",",
"$",
"background_colour",
"=",
"null",
")",
"{",
"$",
"coloured_string",
"=",
"\"\"",
";",
"// Check if given foreground colour found",
"if",
"(",
"iss... | Adds colouring control codes to a string.
@param string $string String to format.
@param string $foreground_colour Optional foreground colour for string.
@param string $background_colour Optional background colour for string.
@return string Formatted string. | [
"Adds",
"colouring",
"control",
"codes",
"to",
"a",
"string",
"."
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Colours.php#L69-L86 | train |
FusePump/cli.php | lib/FusePump/Cli/Colours.php | Colours.getForegroundCode | public static function getForegroundCode($foregroundColour)
{
if (!isset(self::$foreground_colours[$foregroundColour])) {
throw new \Exception('Invalid foreground colour.');
}
return "\033[" . self::$foreground_colours[$foregroundColour] . 'm';
} | php | public static function getForegroundCode($foregroundColour)
{
if (!isset(self::$foreground_colours[$foregroundColour])) {
throw new \Exception('Invalid foreground colour.');
}
return "\033[" . self::$foreground_colours[$foregroundColour] . 'm';
} | [
"public",
"static",
"function",
"getForegroundCode",
"(",
"$",
"foregroundColour",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"foreground_colours",
"[",
"$",
"foregroundColour",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'... | Returns the code for a foreground colour.
@param string $foregroundColour Foreground colour to set.
@return string Foreground colour code.
@throws \Exception if the colour code is invalid. | [
"Returns",
"the",
"code",
"for",
"a",
"foreground",
"colour",
"."
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Colours.php#L97-L103 | train |
FusePump/cli.php | lib/FusePump/Cli/Colours.php | Colours.getBackgroundCode | public static function getBackgroundCode($backgroundColour)
{
if (!isset(self::$background_colours[$backgroundColour])) {
throw new \Exception('Invalid background colour.');
}
return "\033[" . self::$background_colours[$backgroundColour] . 'm';
} | php | public static function getBackgroundCode($backgroundColour)
{
if (!isset(self::$background_colours[$backgroundColour])) {
throw new \Exception('Invalid background colour.');
}
return "\033[" . self::$background_colours[$backgroundColour] . 'm';
} | [
"public",
"static",
"function",
"getBackgroundCode",
"(",
"$",
"backgroundColour",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"background_colours",
"[",
"$",
"backgroundColour",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'... | Returns the code for a background colour.
@param string $backgroundColour Background colour to set.
@return string Background colour code.
@throws \Exception if the colour code is invalid. | [
"Returns",
"the",
"code",
"for",
"a",
"background",
"colour",
"."
] | 2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4 | https://github.com/FusePump/cli.php/blob/2cc92f09ce7b2f73d5cbc09f5ae4f31f3f9ae3b4/lib/FusePump/Cli/Colours.php#L114-L120 | train |
dms-org/common.structure | src/Table/Form/Builder/TableRowFieldDefiner.php | TableRowFieldDefiner.withPredefinedRowValues | public function withPredefinedRowValues(FieldBuilderBase $field, array $rowValues) : TableCellValueFieldDefiner
{
$this->fieldBuilder->attr(TableType::ATTR_PREDEFINED_ROWS, array_values($rowValues));
return $this->withRowKeyAs($field);
} | php | public function withPredefinedRowValues(FieldBuilderBase $field, array $rowValues) : TableCellValueFieldDefiner
{
$this->fieldBuilder->attr(TableType::ATTR_PREDEFINED_ROWS, array_values($rowValues));
return $this->withRowKeyAs($field);
} | [
"public",
"function",
"withPredefinedRowValues",
"(",
"FieldBuilderBase",
"$",
"field",
",",
"array",
"$",
"rowValues",
")",
":",
"TableCellValueFieldDefiner",
"{",
"$",
"this",
"->",
"fieldBuilder",
"->",
"attr",
"(",
"TableType",
"::",
"ATTR_PREDEFINED_ROWS",
",",... | Defines the rows as predefined set of values.
@param FieldBuilderBase $field
@param array $rowValues
@return TableCellValueFieldDefiner | [
"Defines",
"the",
"rows",
"as",
"predefined",
"set",
"of",
"values",
"."
] | 23f122182f60df5ec847047a81a39c8aab019ff1 | https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/Form/Builder/TableRowFieldDefiner.php#L53-L57 | train |
dms-org/common.structure | src/Table/Form/Builder/TableRowFieldDefiner.php | TableRowFieldDefiner.withRowKeyAsField | public function withRowKeyAsField(IField $field) : TableCellValueFieldDefiner
{
return new TableCellValueFieldDefiner($this->fieldBuilder, $this->cellClassName, $this->columnField, $field);
} | php | public function withRowKeyAsField(IField $field) : TableCellValueFieldDefiner
{
return new TableCellValueFieldDefiner($this->fieldBuilder, $this->cellClassName, $this->columnField, $field);
} | [
"public",
"function",
"withRowKeyAsField",
"(",
"IField",
"$",
"field",
")",
":",
"TableCellValueFieldDefiner",
"{",
"return",
"new",
"TableCellValueFieldDefiner",
"(",
"$",
"this",
"->",
"fieldBuilder",
",",
"$",
"this",
"->",
"cellClassName",
",",
"$",
"this",
... | Defines the row key as the supplied field.
@param IField $field
@return TableCellValueFieldDefiner | [
"Defines",
"the",
"row",
"key",
"as",
"the",
"supplied",
"field",
"."
] | 23f122182f60df5ec847047a81a39c8aab019ff1 | https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Table/Form/Builder/TableRowFieldDefiner.php#L78-L81 | train |
Wayn0/Log | src/Log/Log.php | Log.log | private function log($line, $log_level)
{
// Write all events less than log verbosity
if ($log_level <= $this->log_verbosity) {
$line = $this->prepend($log_level) . $line . "\n";
$this->writeLine($line);
}
} | php | private function log($line, $log_level)
{
// Write all events less than log verbosity
if ($log_level <= $this->log_verbosity) {
$line = $this->prepend($log_level) . $line . "\n";
$this->writeLine($line);
}
} | [
"private",
"function",
"log",
"(",
"$",
"line",
",",
"$",
"log_level",
")",
"{",
"// Write all events less than log verbosity",
"if",
"(",
"$",
"log_level",
"<=",
"$",
"this",
"->",
"log_verbosity",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"prepend",
... | Write the log entry | [
"Write",
"the",
"log",
"entry"
] | d049c9a2188b9684faa29be9a920cc4216c747bd | https://github.com/Wayn0/Log/blob/d049c9a2188b9684faa29be9a920cc4216c747bd/src/Log/Log.php#L138-L145 | train |
Wayn0/Log | src/Log/Log.php | Log.prepend | private function prepend($log_level)
{
$time = date('Y-m-d G:i:s');
switch ($log_level) {
case self::FATAL:
return $time . ' - FATAL - ';
break;
case self::ERROR:
return $time . ' - ERROR - ';
break;
case self::WARN:
return $time . ' - WARN - ';
break;
case self::INFO:... | php | private function prepend($log_level)
{
$time = date('Y-m-d G:i:s');
switch ($log_level) {
case self::FATAL:
return $time . ' - FATAL - ';
break;
case self::ERROR:
return $time . ' - ERROR - ';
break;
case self::WARN:
return $time . ' - WARN - ';
break;
case self::INFO:... | [
"private",
"function",
"prepend",
"(",
"$",
"log_level",
")",
"{",
"$",
"time",
"=",
"date",
"(",
"'Y-m-d G:i:s'",
")",
";",
"switch",
"(",
"$",
"log_level",
")",
"{",
"case",
"self",
"::",
"FATAL",
":",
"return",
"$",
"time",
".",
"' - FATAL - '",
";"... | format the line prefix | [
"format",
"the",
"line",
"prefix"
] | d049c9a2188b9684faa29be9a920cc4216c747bd | https://github.com/Wayn0/Log/blob/d049c9a2188b9684faa29be9a920cc4216c747bd/src/Log/Log.php#L154-L187 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.all | public function all($dotify = false)
{
return $dotify ? $this->dotify($this->data) : $this->data;
} | php | public function all($dotify = false)
{
return $dotify ? $this->dotify($this->data) : $this->data;
} | [
"public",
"function",
"all",
"(",
"$",
"dotify",
"=",
"false",
")",
"{",
"return",
"$",
"dotify",
"?",
"$",
"this",
"->",
"dotify",
"(",
"$",
"this",
"->",
"data",
")",
":",
"$",
"this",
"->",
"data",
";",
"}"
] | Returns all the stored configurations.
@param boolean $dotify
@return array | [
"Returns",
"all",
"the",
"stored",
"configurations",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L34-L37 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.get | public function get($key, $default = null, $dotify = false)
{
$items = $this->data;
$keys = array_filter(explode('.', $key));
$length = count($keys);
for ($i = 0; $i < $length; $i++)
{
$index = $keys[(int) $i];
$items = &$items[$index];
}
... | php | public function get($key, $default = null, $dotify = false)
{
$items = $this->data;
$keys = array_filter(explode('.', $key));
$length = count($keys);
for ($i = 0; $i < $length; $i++)
{
$index = $keys[(int) $i];
$items = &$items[$index];
}
... | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"dotify",
"=",
"false",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"keys",
"=",
"array_filter",
"(",
"explode",
"(",
"'.'",
",",
"$",... | Returns the value from the specified key.
@param string $key
@param mixed|null $default
@param boolean $dotify
@return mixed | [
"Returns",
"the",
"value",
"from",
"the",
"specified",
"key",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L47-L73 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.load | public function load($path)
{
list($data, $items) = array(array(), array($path));
if (substr((string) $path, -4) !== '.php')
{
$directory = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \Reg... | php | public function load($path)
{
list($data, $items) = array(array(), array($path));
if (substr((string) $path, -4) !== '.php')
{
$directory = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($directory);
$regex = new \Reg... | [
"public",
"function",
"load",
"(",
"$",
"path",
")",
"{",
"list",
"(",
"$",
"data",
",",
"$",
"items",
")",
"=",
"array",
"(",
"array",
"(",
")",
",",
"array",
"(",
"$",
"path",
")",
")",
";",
"if",
"(",
"substr",
"(",
"(",
"string",
")",
"$"... | Loads an array of values from a specified file or directory.
@param string $path
@return void | [
"Loads",
"an",
"array",
"of",
"values",
"from",
"a",
"specified",
"file",
"or",
"directory",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L81-L104 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.dotify | protected function dotify(array $data, $result = array(), $key = '')
{
foreach ((array) $data as $name => $value)
{
if (is_array($value) && empty($value) === false)
{
$text = (string) $key . $name . '.';
$item = $this->dotify($value, $result, ... | php | protected function dotify(array $data, $result = array(), $key = '')
{
foreach ((array) $data as $name => $value)
{
if (is_array($value) && empty($value) === false)
{
$text = (string) $key . $name . '.';
$item = $this->dotify($value, $result, ... | [
"protected",
"function",
"dotify",
"(",
"array",
"$",
"data",
",",
"$",
"result",
"=",
"array",
"(",
")",
",",
"$",
"key",
"=",
"''",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if... | Converts the data into dot notation values.
@param array $data
@param array $result
@param string $key
@return array | [
"Converts",
"the",
"data",
"into",
"dot",
"notation",
"values",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L114-L133 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.rename | protected function rename($item, $path)
{
$name = str_replace($path, '', (string) $item);
$name = str_replace(array('\\', '/'), '.', $name);
$regex = preg_replace('/^./i', '', $name);
return basename(strtolower($regex), '.php');
} | php | protected function rename($item, $path)
{
$name = str_replace($path, '', (string) $item);
$name = str_replace(array('\\', '/'), '.', $name);
$regex = preg_replace('/^./i', '', $name);
return basename(strtolower($regex), '.php');
} | [
"protected",
"function",
"rename",
"(",
"$",
"item",
",",
"$",
"path",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"$",
"path",
",",
"''",
",",
"(",
"string",
")",
"$",
"item",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"array",
"(",
"'\... | Renames the item into a dot notation one.
@param string $item
@param string $path
@return string | [
"Renames",
"the",
"item",
"into",
"a",
"dot",
"notation",
"one",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L158-L167 | train |
zapheus/zapheus | src/Provider/Configuration.php | Configuration.save | protected function save(array &$keys, &$data, $value)
{
$key = array_shift($keys);
if (! isset($data[$key]))
{
$data[$key] = array();
}
if (empty($keys))
{
return $data[$key] = $value;
}
return $this->save($keys, $data[$key],... | php | protected function save(array &$keys, &$data, $value)
{
$key = array_shift($keys);
if (! isset($data[$key]))
{
$data[$key] = array();
}
if (empty($keys))
{
return $data[$key] = $value;
}
return $this->save($keys, $data[$key],... | [
"protected",
"function",
"save",
"(",
"array",
"&",
"$",
"keys",
",",
"&",
"$",
"data",
",",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
... | Saves the specified key in the list of data.
@param array &$keys
@param array &$data
@param mixed $value
@return mixed | [
"Saves",
"the",
"specified",
"key",
"in",
"the",
"list",
"of",
"data",
"."
] | 96618b5cee7d20b6700d0475e4334ae4b5163a6b | https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Provider/Configuration.php#L177-L192 | train |
agentmedia/phine-builtin | src/BuiltIn/Modules/Backend/LogoutForm.php | LogoutForm.InitForm | protected function InitForm()
{
$this->logout = $this->LoadElement();
$this->AddNextUrlField();
$this->AddCssIDField();
$this->AddCssClassField();
$this->AddTemplateField();
$this->AddSubmit();
} | php | protected function InitForm()
{
$this->logout = $this->LoadElement();
$this->AddNextUrlField();
$this->AddCssIDField();
$this->AddCssClassField();
$this->AddTemplateField();
$this->AddSubmit();
} | [
"protected",
"function",
"InitForm",
"(",
")",
"{",
"$",
"this",
"->",
"logout",
"=",
"$",
"this",
"->",
"LoadElement",
"(",
")",
";",
"$",
"this",
"->",
"AddNextUrlField",
"(",
")",
";",
"$",
"this",
"->",
"AddCssIDField",
"(",
")",
";",
"$",
"this"... | Intializes the form | [
"Intializes",
"the",
"form"
] | 4dd05bc406a71e997bd4eaa16b12e23dbe62a456 | https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Backend/LogoutForm.php#L47-L55 | train |
agentmedia/phine-builtin | src/BuiltIn/Modules/Backend/LogoutForm.php | LogoutForm.SaveElement | protected function SaveElement()
{
$this->logout->SetNextUrl($this->selectorNext->Save($this->logout->GetNextUrl()));
return $this->logout;
} | php | protected function SaveElement()
{
$this->logout->SetNextUrl($this->selectorNext->Save($this->logout->GetNextUrl()));
return $this->logout;
} | [
"protected",
"function",
"SaveElement",
"(",
")",
"{",
"$",
"this",
"->",
"logout",
"->",
"SetNextUrl",
"(",
"$",
"this",
"->",
"selectorNext",
"->",
"Save",
"(",
"$",
"this",
"->",
"logout",
"->",
"GetNextUrl",
"(",
")",
")",
")",
";",
"return",
"$",
... | Saves the element and returns it
@return ContentLogout | [
"Saves",
"the",
"element",
"and",
"returns",
"it"
] | 4dd05bc406a71e997bd4eaa16b12e23dbe62a456 | https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Backend/LogoutForm.php#L72-L76 | train |
nativgames-old/pegase | src/Pegase/Extension/Form/Service/FormBuilder.php | FormBuilder.generate | public function generate($target, $type = 'post') {
$form = new \Pegase\Extension\Form\Objects\Form(
$target,
$this->sm->get('pegase.security.token_csrf_container'),
$type);
return $form;
} | php | public function generate($target, $type = 'post') {
$form = new \Pegase\Extension\Form\Objects\Form(
$target,
$this->sm->get('pegase.security.token_csrf_container'),
$type);
return $form;
} | [
"public",
"function",
"generate",
"(",
"$",
"target",
",",
"$",
"type",
"=",
"'post'",
")",
"{",
"$",
"form",
"=",
"new",
"\\",
"Pegase",
"\\",
"Extension",
"\\",
"Form",
"\\",
"Objects",
"\\",
"Form",
"(",
"$",
"target",
",",
"$",
"this",
"->",
"s... | generate a form | [
"generate",
"a",
"form"
] | 9a00e09a26f391c988aadecd7640c72316eaa521 | https://github.com/nativgames-old/pegase/blob/9a00e09a26f391c988aadecd7640c72316eaa521/src/Pegase/Extension/Form/Service/FormBuilder.php#L22-L30 | train |
cubicmushroom/valueobjects | src/Geography/Street.php | Street.fromNative | public static function fromNative()
{
$args = func_get_args();
if (\count($args) < 2) {
throw new \BadMethodCallException('You must provide from 2 to 4 arguments: 1) street name, 2) street number, 3) elements, 4) format (optional)');
}
$nameString = $args[0];
... | php | public static function fromNative()
{
$args = func_get_args();
if (\count($args) < 2) {
throw new \BadMethodCallException('You must provide from 2 to 4 arguments: 1) street name, 2) street number, 3) elements, 4) format (optional)');
}
$nameString = $args[0];
... | [
"public",
"static",
"function",
"fromNative",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"args",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'You must provide fr... | Returns a new Street from native PHP string name and number.
@param string $name
@param string $number
@param string $elements
@return Street
@throws \BadFunctionCallException | [
"Returns",
"a",
"new",
"Street",
"from",
"native",
"PHP",
"string",
"name",
"and",
"number",
"."
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Street.php#L35-L54 | train |
cubicmushroom/valueobjects | src/Geography/Street.php | Street.sameValueAs | public function sameValueAs(ValueObjectInterface $street)
{
if (false === Util::classEquals($this, $street)) {
return false;
}
return $this->getName()->sameValueAs($street->getName()) &&
$this->getNumber()->sameValueAs($street->getNumber()) &&
$this... | php | public function sameValueAs(ValueObjectInterface $street)
{
if (false === Util::classEquals($this, $street)) {
return false;
}
return $this->getName()->sameValueAs($street->getName()) &&
$this->getNumber()->sameValueAs($street->getNumber()) &&
$this... | [
"public",
"function",
"sameValueAs",
"(",
"ValueObjectInterface",
"$",
"street",
")",
"{",
"if",
"(",
"false",
"===",
"Util",
"::",
"classEquals",
"(",
"$",
"this",
",",
"$",
"street",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
... | Tells whether two Street objects are equal
@param ValueObjectInterface $street
@return bool | [
"Tells",
"whether",
"two",
"Street",
"objects",
"are",
"equal"
] | 4554239ab75d65eeb9773219aa5b07e9fbfabb92 | https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Geography/Street.php#L83-L93 | train |
rafrsr/generic-api | src/GenericApi.php | GenericApi.validate | protected function validate(ApiServiceInterface $service)
{
$validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
$violations = $validator->validate($service);
/** @var ConstraintViolation $violation */
foreach ($violations as $violation) {
... | php | protected function validate(ApiServiceInterface $service)
{
$validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
$violations = $validator->validate($service);
/** @var ConstraintViolation $violation */
foreach ($violations as $violation) {
... | [
"protected",
"function",
"validate",
"(",
"ApiServiceInterface",
"$",
"service",
")",
"{",
"$",
"validator",
"=",
"Validation",
"::",
"createValidatorBuilder",
"(",
")",
"->",
"enableAnnotationMapping",
"(",
")",
"->",
"getValidator",
"(",
")",
";",
"$",
"violat... | Validate a service data using Symfony validation component
@param ApiServiceInterface $service
@throws InvalidApiDataException | [
"Validate",
"a",
"service",
"data",
"using",
"Symfony",
"validation",
"component"
] | 2572d3dcc32e03914cf710f0229d72e1c09ea65b | https://github.com/rafrsr/generic-api/blob/2572d3dcc32e03914cf710f0229d72e1c09ea65b/src/GenericApi.php#L235-L247 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.factory | public static function factory($time = null, $timezone = null) {
$timezone = static::timezone($timezone);
if ($time instanceof DateTime) {
return $time->setTimezone($timezone);
}
if (is_numeric($time)) {
$time = '@' . $time;
}
$dt = new DateTime... | php | public static function factory($time = null, $timezone = null) {
$timezone = static::timezone($timezone);
if ($time instanceof DateTime) {
return $time->setTimezone($timezone);
}
if (is_numeric($time)) {
$time = '@' . $time;
}
$dt = new DateTime... | [
"public",
"static",
"function",
"factory",
"(",
"$",
"time",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"$",
"timezone",
"=",
"static",
"::",
"timezone",
"(",
"$",
"timezone",
")",
";",
"if",
"(",
"$",
"time",
"instanceof",
"DateTime",
... | Return a DateTime object based on the current time and timezone.
@param string|int $time
@param string $timezone
@return \DateTime | [
"Return",
"a",
"DateTime",
"object",
"based",
"on",
"the",
"current",
"time",
"and",
"timezone",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L49-L64 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.isWithinNext | public static function isWithinNext($time, $span) {
$span = static::factory($span);
$time = static::factory($time);
$now = static::factory();
return ($time <= $span && $time >= $now);
} | php | public static function isWithinNext($time, $span) {
$span = static::factory($span);
$time = static::factory($time);
$now = static::factory();
return ($time <= $span && $time >= $now);
} | [
"public",
"static",
"function",
"isWithinNext",
"(",
"$",
"time",
",",
"$",
"span",
")",
"{",
"$",
"span",
"=",
"static",
"::",
"factory",
"(",
"$",
"span",
")",
";",
"$",
"time",
"=",
"static",
"::",
"factory",
"(",
"$",
"time",
")",
";",
"$",
"... | Returns true if the date passed will be within the next time frame span.
@param string|int $time
@param int $span
@return bool
static | [
"Returns",
"true",
"if",
"the",
"date",
"passed",
"will",
"be",
"within",
"the",
"next",
"time",
"frame",
"span",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L124-L130 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.toUnix | public static function toUnix($time) {
if (!$time) {
return time();
} else if ($time instanceof DateTime) {
return $time->format('U');
}
return is_string($time) ? strtotime($time) : (int) $time;
} | php | public static function toUnix($time) {
if (!$time) {
return time();
} else if ($time instanceof DateTime) {
return $time->format('U');
}
return is_string($time) ? strtotime($time) : (int) $time;
} | [
"public",
"static",
"function",
"toUnix",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"$",
"time",
")",
"{",
"return",
"time",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"time",
"instanceof",
"DateTime",
")",
"{",
"return",
"$",
"time",
"->",
"f... | Return a unix timestamp. If the time is a string convert it, else cast to int.
@param int|string $time
@return int | [
"Return",
"a",
"unix",
"timestamp",
".",
"If",
"the",
"time",
"is",
"a",
"string",
"convert",
"it",
"else",
"cast",
"to",
"int",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L156-L165 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.wasLastWeek | public static function wasLastWeek($time) {
$start = static::factory('last week 00:00:00');
$end = clone $start;
$end->modify('next week -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | php | public static function wasLastWeek($time) {
$start = static::factory('last week 00:00:00');
$end = clone $start;
$end->modify('next week -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | [
"public",
"static",
"function",
"wasLastWeek",
"(",
"$",
"time",
")",
"{",
"$",
"start",
"=",
"static",
"::",
"factory",
"(",
"'last week 00:00:00'",
")",
";",
"$",
"end",
"=",
"clone",
"$",
"start",
";",
"$",
"end",
"->",
"modify",
"(",
"'next week -1 s... | Returns true if date passed was within last week.
@param string|int $time
@return bool | [
"Returns",
"true",
"if",
"date",
"passed",
"was",
"within",
"last",
"week",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L173-L182 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.wasLastMonth | public static function wasLastMonth($time) {
$start = static::factory('first day of last month 00:00:00');
$end = clone $start;
$end->modify('next month -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | php | public static function wasLastMonth($time) {
$start = static::factory('first day of last month 00:00:00');
$end = clone $start;
$end->modify('next month -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | [
"public",
"static",
"function",
"wasLastMonth",
"(",
"$",
"time",
")",
"{",
"$",
"start",
"=",
"static",
"::",
"factory",
"(",
"'first day of last month 00:00:00'",
")",
";",
"$",
"end",
"=",
"clone",
"$",
"start",
";",
"$",
"end",
"->",
"modify",
"(",
"... | Returns true if date passed was within last month.
@param string|int $time
@return bool | [
"Returns",
"true",
"if",
"date",
"passed",
"was",
"within",
"last",
"month",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L190-L199 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.wasLastYear | public static function wasLastYear($time) {
$start = static::factory('last year January 1st 00:00:00');
$end = clone $start;
$end->modify('next year -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | php | public static function wasLastYear($time) {
$start = static::factory('last year January 1st 00:00:00');
$end = clone $start;
$end->modify('next year -1 second');
$time = static::factory($time);
return ($time >= $start && $time <= $end);
} | [
"public",
"static",
"function",
"wasLastYear",
"(",
"$",
"time",
")",
"{",
"$",
"start",
"=",
"static",
"::",
"factory",
"(",
"'last year January 1st 00:00:00'",
")",
";",
"$",
"end",
"=",
"clone",
"$",
"start",
";",
"$",
"end",
"->",
"modify",
"(",
"'ne... | Returns true if date passed was within last year.
@param string|int $time
@return bool | [
"Returns",
"true",
"if",
"date",
"passed",
"was",
"within",
"last",
"year",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L207-L216 | train |
vpg/titon.utility | src/Titon/Utility/Time.php | Time.wasWithinLast | public static function wasWithinLast($time, $span) {
$span = static::factory($span);
$time = static::factory($time);
$now = static::factory();
return ($time >= $span && $time <= $now);
} | php | public static function wasWithinLast($time, $span) {
$span = static::factory($span);
$time = static::factory($time);
$now = static::factory();
return ($time >= $span && $time <= $now);
} | [
"public",
"static",
"function",
"wasWithinLast",
"(",
"$",
"time",
",",
"$",
"span",
")",
"{",
"$",
"span",
"=",
"static",
"::",
"factory",
"(",
"$",
"span",
")",
";",
"$",
"time",
"=",
"static",
"::",
"factory",
"(",
"$",
"time",
")",
";",
"$",
... | Returns true if the date passed was within the last time frame span.
@param string|int $time
@param int $span
@return bool | [
"Returns",
"true",
"if",
"the",
"date",
"passed",
"was",
"within",
"the",
"last",
"time",
"frame",
"span",
"."
] | 8a77eb9e7b8baacf41cc25487289779d8319cd3a | https://github.com/vpg/titon.utility/blob/8a77eb9e7b8baacf41cc25487289779d8319cd3a/src/Titon/Utility/Time.php#L235-L241 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Persister/CollectionPersister.php | CollectionPersister.delete | public function delete(PersistentCollectionInterface $coll)
{
$mapping = $coll->getMapping();
if ($mapping->isInverseSide) {
return; // ignore inverse side
}
if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ATOMIC_SET) {
throw new \UnexpectedValue... | php | public function delete(PersistentCollectionInterface $coll)
{
$mapping = $coll->getMapping();
if ($mapping->isInverseSide) {
return; // ignore inverse side
}
if ($mapping->strategy === PropertyMetadata::STORAGE_STRATEGY_ATOMIC_SET) {
throw new \UnexpectedValue... | [
"public",
"function",
"delete",
"(",
"PersistentCollectionInterface",
"$",
"coll",
")",
"{",
"$",
"mapping",
"=",
"$",
"coll",
"->",
"getMapping",
"(",
")",
";",
"if",
"(",
"$",
"mapping",
"->",
"isInverseSide",
")",
"{",
"return",
";",
"// ignore inverse si... | Deletes a PersistentCollection instance completely from a document using REMOVE.
@param PersistentCollectionInterface $coll | [
"Deletes",
"a",
"PersistentCollection",
"instance",
"completely",
"from",
"a",
"document",
"using",
"REMOVE",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/CollectionPersister.php#L75-L89 | train |
cloudtek/dynamodm | lib/Cloudtek/DynamoDM/Persister/CollectionPersister.php | CollectionPersister.getQueryPathAndParent | public function getQueryPathAndParent(PersistentCollectionInterface $coll, QueryBuilder $qb = null)
{
$collMapping = $coll->getMapping();
$parent = $coll->getOwner();
$paths[] = [$collMapping->name, null];
while (($association = $this->uow->getParentAssociation($parent)) !=... | php | public function getQueryPathAndParent(PersistentCollectionInterface $coll, QueryBuilder $qb = null)
{
$collMapping = $coll->getMapping();
$parent = $coll->getOwner();
$paths[] = [$collMapping->name, null];
while (($association = $this->uow->getParentAssociation($parent)) !=... | [
"public",
"function",
"getQueryPathAndParent",
"(",
"PersistentCollectionInterface",
"$",
"coll",
",",
"QueryBuilder",
"$",
"qb",
"=",
"null",
")",
"{",
"$",
"collMapping",
"=",
"$",
"coll",
"->",
"getMapping",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"coll",... | Create and return a QueryBuilder and Path instance representing the provided
collection's document path, along with the top-level document.
@param PersistentCollectionInterface $coll
@param QueryBuilder|null $qb
@return mixed[] list($qb, $path, $parent) | [
"Create",
"and",
"return",
"a",
"QueryBuilder",
"and",
"Path",
"instance",
"representing",
"the",
"provided",
"collection",
"s",
"document",
"path",
"along",
"with",
"the",
"top",
"-",
"level",
"document",
"."
] | 119d355e2c5cbaef1f867970349b4432f5704fcd | https://github.com/cloudtek/dynamodm/blob/119d355e2c5cbaef1f867970349b4432f5704fcd/lib/Cloudtek/DynamoDM/Persister/CollectionPersister.php#L176-L215 | train |
iqg/UtilsBundle | Utils/StringUtil.php | StringUtil.randomStr | public function randomStr( $length = 16 )
{
$arr = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$str = '';
$arr_len = count($arr);
for ($i = 0; $i < $length; $i++)
{
$rand = mt_rand(0, $arr_len-1);
$str.=$arr[$rand];
}
... | php | public function randomStr( $length = 16 )
{
$arr = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
$str = '';
$arr_len = count($arr);
for ($i = 0; $i < $length; $i++)
{
$rand = mt_rand(0, $arr_len-1);
$str.=$arr[$rand];
}
... | [
"public",
"function",
"randomStr",
"(",
"$",
"length",
"=",
"16",
")",
"{",
"$",
"arr",
"=",
"array_merge",
"(",
"range",
"(",
"0",
",",
"9",
")",
",",
"range",
"(",
"'a'",
",",
"'z'",
")",
",",
"range",
"(",
"'A'",
",",
"'Z'",
")",
")",
";",
... | generate a random string include uppercase and lowercase letters and numbers | [
"generate",
"a",
"random",
"string",
"include",
"uppercase",
"and",
"lowercase",
"letters",
"and",
"numbers"
] | ef1ed67fc5dc8605d9828f8ecba0e4645faf8bc8 | https://github.com/iqg/UtilsBundle/blob/ef1ed67fc5dc8605d9828f8ecba0e4645faf8bc8/Utils/StringUtil.php#L78-L91 | train |
stubbles/stubbles-dbal | src/main/php/config/ArrayBasedDatabaseConfigurations.php | ArrayBasedDatabaseConfigurations.get | public function get(string $id): DatabaseConfiguration
{
if (isset($this->configurations[$id])) {
return $this->configurations[$id];
}
throw new \OutOfBoundsException(
'No database configuration known for database requested with id '
. $id
... | php | public function get(string $id): DatabaseConfiguration
{
if (isset($this->configurations[$id])) {
return $this->configurations[$id];
}
throw new \OutOfBoundsException(
'No database configuration known for database requested with id '
. $id
... | [
"public",
"function",
"get",
"(",
"string",
"$",
"id",
")",
":",
"DatabaseConfiguration",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"configurations",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configurations",
"[",
"$",
... | returns database configuration for given id
@param string $id id of configuration to return
@return \stubbles\db\config\DatabaseConfiguration
@throws \OutOfBoundsException in case no config for given id exists | [
"returns",
"database",
"configuration",
"for",
"given",
"id"
] | b42a589025a9e511b40a2798ac84df94d6451c36 | https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/config/ArrayBasedDatabaseConfigurations.php#L54-L64 | train |
Zazalt/Databaser | src/Engine/PostgreSQL.php | PostgreSQL.getTables | public function getTables()
{
$statement = $this->connection->prepare("SELECT * FROM information_schema.tables WHERE table_catalog = :database AND table_schema = 'public'");
$statement->execute([
':database' => $this->Databaser->database
]);
return $statement->fetchAll(\... | php | public function getTables()
{
$statement = $this->connection->prepare("SELECT * FROM information_schema.tables WHERE table_catalog = :database AND table_schema = 'public'");
$statement->execute([
':database' => $this->Databaser->database
]);
return $statement->fetchAll(\... | [
"public",
"function",
"getTables",
"(",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"SELECT * FROM information_schema.tables WHERE table_catalog = :database AND table_schema = 'public'\"",
")",
";",
"$",
"statement",
"->",
"ex... | Get all tables for a database | [
"Get",
"all",
"tables",
"for",
"a",
"database"
] | 245eccd6ee960435b1c7fa5031d8f3db4ef557f2 | https://github.com/Zazalt/Databaser/blob/245eccd6ee960435b1c7fa5031d8f3db4ef557f2/src/Engine/PostgreSQL.php#L69-L77 | train |
Zazalt/Databaser | src/Engine/PostgreSQL.php | PostgreSQL.getTableRows | public function getTableRows(string $tableName)
{
$statement = $this->connection->prepare("SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table");
$statement->execute([
':database' => $this->Databaser->database,
':table' => $tabl... | php | public function getTableRows(string $tableName)
{
$statement = $this->connection->prepare("SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table");
$statement->execute([
':database' => $this->Databaser->database,
':table' => $tabl... | [
"public",
"function",
"getTableRows",
"(",
"string",
"$",
"tableName",
")",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"connection",
"->",
"prepare",
"(",
"\"SELECT * FROM information_schema.columns WHERE table_catalog = :database AND table_name = :table\"",
")",
";",
... | Get all rows for all tables | [
"Get",
"all",
"rows",
"for",
"all",
"tables"
] | 245eccd6ee960435b1c7fa5031d8f3db4ef557f2 | https://github.com/Zazalt/Databaser/blob/245eccd6ee960435b1c7fa5031d8f3db4ef557f2/src/Engine/PostgreSQL.php#L82-L91 | train |
Erebot/CallableWrapper | src/CallableWrapper.php | CallableWrapper.wrap | public static function wrap($callable)
{
$parts = explode('::', static::represent($callable));
if (count($parts) == 1) {
// We wrapped a function.
$reflector = new \ReflectionFunction($callable);
} else {
if (!is_array($callable)) {
... | php | public static function wrap($callable)
{
$parts = explode('::', static::represent($callable));
if (count($parts) == 1) {
// We wrapped a function.
$reflector = new \ReflectionFunction($callable);
} else {
if (!is_array($callable)) {
... | [
"public",
"static",
"function",
"wrap",
"(",
"$",
"callable",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'::'",
",",
"static",
"::",
"represent",
"(",
"$",
"callable",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"==",
"1",
")",
... | Wraps an existing callable piece of code.
\param mixed $callable
Callable piece of code to wrap.
\retval Erebot::CallableInterface
An object of a class implementing the
Erebot::CallableInterface is returned.
The precise type of the object will usually vary
between calls as new types are created on-the-fly
if needed. | [
"Wraps",
"an",
"existing",
"callable",
"piece",
"of",
"code",
"."
] | 28b427e7471d21ed60d9feee3886ff3b43b78d33 | https://github.com/Erebot/CallableWrapper/blob/28b427e7471d21ed60d9feee3886ff3b43b78d33/src/CallableWrapper.php#L90-L157 | train |
Erebot/CallableWrapper | src/CallableWrapper.php | CallableWrapper.initialize | public static function initialize()
{
static $initialized = false;
static $structures = array();
if (defined('T_CALLABLE')) {
return;
}
if (!$initialized) {
spl_autoload_register(
function ($class) {
$parts = arr... | php | public static function initialize()
{
static $initialized = false;
static $structures = array();
if (defined('T_CALLABLE')) {
return;
}
if (!$initialized) {
spl_autoload_register(
function ($class) {
$parts = arr... | [
"public",
"static",
"function",
"initialize",
"(",
")",
"{",
"static",
"$",
"initialized",
"=",
"false",
";",
"static",
"$",
"structures",
"=",
"array",
"(",
")",
";",
"if",
"(",
"defined",
"(",
"'T_CALLABLE'",
")",
")",
"{",
"return",
";",
"}",
"if",
... | Initialize the wrapper.
\param bool $existing
(optional) Whether to inject the wrapper inside existing
namespaces. You don't need to pass this argument: the wrapper
already does so internally when needed.
\note
This method must be called before using any of the wrapper's
other methods. It registers an autoloader that... | [
"Initialize",
"the",
"wrapper",
"."
] | 28b427e7471d21ed60d9feee3886ff3b43b78d33 | https://github.com/Erebot/CallableWrapper/blob/28b427e7471d21ed60d9feee3886ff3b43b78d33/src/CallableWrapper.php#L180-L235 | train |
zeageorge/php-object | src/Object/Event.php | Event.subscribe | public function subscribe($handler, $priority = Event::DEFAULT_CALLBACKS_PRIORITY)
{
$_priority = \is_int($priority) ? $priority : self::DEFAULT_CALLBACKS_PRIORITY;
if (!($_priority >= self::DEFAULT_CALLBACKS_MAX_PRIORITY && $_priority <= self::DEFAULT_CALLBACKS_MIN_PRIORITY)) {
$_pr... | php | public function subscribe($handler, $priority = Event::DEFAULT_CALLBACKS_PRIORITY)
{
$_priority = \is_int($priority) ? $priority : self::DEFAULT_CALLBACKS_PRIORITY;
if (!($_priority >= self::DEFAULT_CALLBACKS_MAX_PRIORITY && $_priority <= self::DEFAULT_CALLBACKS_MIN_PRIORITY)) {
$_pr... | [
"public",
"function",
"subscribe",
"(",
"$",
"handler",
",",
"$",
"priority",
"=",
"Event",
"::",
"DEFAULT_CALLBACKS_PRIORITY",
")",
"{",
"$",
"_priority",
"=",
"\\",
"is_int",
"(",
"$",
"priority",
")",
"?",
"$",
"priority",
":",
"self",
"::",
"DEFAULT_CA... | Subscribe to this event.
The event handler must be a valid PHP callback. The following are
some examples:
~~~
function ($event) { ... } // anonymous function
[$object, 'handleClick'] // $object->handleClick()
['Page', 'handleClick'] // Page::handleClick()
'handleClick' // global function handleClick()
... | [
"Subscribe",
"to",
"this",
"event",
"."
] | 760bffd226c67ea3b9d898f0c6d76fb209ade72f | https://github.com/zeageorge/php-object/blob/760bffd226c67ea3b9d898f0c6d76fb209ade72f/src/Object/Event.php#L145-L181 | train |
Weblab-nl/curl | src/Request.php | Request.setPostFields | public function setPostFields($value) {
if (is_array($value)) {
return $this->setOption(CURLOPT_POSTFIELDS, http_build_query($value));
} else {
return $this->setOption(CURLOPT_POSTFIELDS, $value);
}
} | php | public function setPostFields($value) {
if (is_array($value)) {
return $this->setOption(CURLOPT_POSTFIELDS, http_build_query($value));
} else {
return $this->setOption(CURLOPT_POSTFIELDS, $value);
}
} | [
"public",
"function",
"setPostFields",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_POSTFIELDS",
",",
"http_build_query",
"(",
"$",
"value",
")",
")",
";",
... | Set post fields
@param array|string $value Array should be in key => value format. String === json
@return Request | [
"Set",
"post",
"fields"
] | e2879ab970e0d8161d5a49b46805bc36a8ba94a9 | https://github.com/Weblab-nl/curl/blob/e2879ab970e0d8161d5a49b46805bc36a8ba94a9/src/Request.php#L78-L84 | train |
Weblab-nl/curl | src/Request.php | Request.doesFileExist | public function doesFileExist($url) {
// Setup connection
$ch = curl_init($url);
// We don't want to download the file, we just want to know if the file exists
curl_setopt($ch, CURLOPT_NOBODY, true);
// Execute cURL
curl_exec($ch);
// Get the HTTP status code
... | php | public function doesFileExist($url) {
// Setup connection
$ch = curl_init($url);
// We don't want to download the file, we just want to know if the file exists
curl_setopt($ch, CURLOPT_NOBODY, true);
// Execute cURL
curl_exec($ch);
// Get the HTTP status code
... | [
"public",
"function",
"doesFileExist",
"(",
"$",
"url",
")",
"{",
"// Setup connection",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"// We don't want to download the file, we just want to know if the file exists",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURL... | Checks if a file exists
@return bool | [
"Checks",
"if",
"a",
"file",
"exists"
] | e2879ab970e0d8161d5a49b46805bc36a8ba94a9 | https://github.com/Weblab-nl/curl/blob/e2879ab970e0d8161d5a49b46805bc36a8ba94a9/src/Request.php#L273-L291 | train |
Weblab-nl/curl | src/Request.php | Request.getStatus | public function getStatus(string $url) {
// Setup connection
$resource = curl_init($url);
// Setup cURL options
curl_setopt($resource, CURLOPT_NOBODY, true);
curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($resource,CURLOPT_HEADER,true);
curl_seto... | php | public function getStatus(string $url) {
// Setup connection
$resource = curl_init($url);
// Setup cURL options
curl_setopt($resource, CURLOPT_NOBODY, true);
curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($resource,CURLOPT_HEADER,true);
curl_seto... | [
"public",
"function",
"getStatus",
"(",
"string",
"$",
"url",
")",
"{",
"// Setup connection",
"$",
"resource",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"// Setup cURL options",
"curl_setopt",
"(",
"$",
"resource",
",",
"CURLOPT_NOBODY",
",",
"true",
")",
... | Get the response code of a url
@return bool | [
"Get",
"the",
"response",
"code",
"of",
"a",
"url"
] | e2879ab970e0d8161d5a49b46805bc36a8ba94a9 | https://github.com/Weblab-nl/curl/blob/e2879ab970e0d8161d5a49b46805bc36a8ba94a9/src/Request.php#L298-L327 | train |
Weblab-nl/curl | src/Request.php | Request.run | public function run() {
// Setup connection
$resource = curl_init();
// Set cURL options
foreach ($this->settings as $option => $setting) {
curl_setopt($resource, $option, $setting);
}
// Process headers
$headers = [];
foreach ($this->headers... | php | public function run() {
// Setup connection
$resource = curl_init();
// Set cURL options
foreach ($this->settings as $option => $setting) {
curl_setopt($resource, $option, $setting);
}
// Process headers
$headers = [];
foreach ($this->headers... | [
"public",
"function",
"run",
"(",
")",
"{",
"// Setup connection",
"$",
"resource",
"=",
"curl_init",
"(",
")",
";",
"// Set cURL options",
"foreach",
"(",
"$",
"this",
"->",
"settings",
"as",
"$",
"option",
"=>",
"$",
"setting",
")",
"{",
"curl_setopt",
"... | Actually executes the cURL request
@return Result | [
"Actually",
"executes",
"the",
"cURL",
"request"
] | e2879ab970e0d8161d5a49b46805bc36a8ba94a9 | https://github.com/Weblab-nl/curl/blob/e2879ab970e0d8161d5a49b46805bc36a8ba94a9/src/Request.php#L334-L379 | train |
werx/core | src/Database.php | Database.init | public static function init($config = null)
{
$defaults = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'mysql',
'username' => 'root',
'password' => null,
'log_queries' => true,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' ... | php | public static function init($config = null)
{
$defaults = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'mysql',
'username' => 'root',
'password' => null,
'log_queries' => true,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' ... | [
"public",
"static",
"function",
"init",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"$",
"defaults",
"=",
"[",
"'driver'",
"=>",
"'mysql'",
",",
"'host'",
"=>",
"'localhost'",
",",
"'database'",
"=>",
"'mysql'",
",",
"'username'",
"=>",
"'root'",
",",
"'p... | Initialize the connection to the database.
@param null $config | [
"Initialize",
"the",
"connection",
"to",
"the",
"database",
"."
] | 9ab7a9f7a8c02e1d41ca40301afada8129ea0a79 | https://github.com/werx/core/blob/9ab7a9f7a8c02e1d41ca40301afada8129ea0a79/src/Database.php#L18-L77 | train |
werx/core | src/Database.php | Database.parseDsn | public static function parseDsn($string = null)
{
$opts = null;
if (!empty($string)) {
$dsn = new DSN($string);
$port = empty($dsn->getFirstPort()) ? '' : (':' . $dsn->getFirstPort());
$password = empty($dsn->getPassword()) ? null : $dsn->getPassword();
$opts = [
'driver' => $dsn->getProtocol(),... | php | public static function parseDsn($string = null)
{
$opts = null;
if (!empty($string)) {
$dsn = new DSN($string);
$port = empty($dsn->getFirstPort()) ? '' : (':' . $dsn->getFirstPort());
$password = empty($dsn->getPassword()) ? null : $dsn->getPassword();
$opts = [
'driver' => $dsn->getProtocol(),... | [
"public",
"static",
"function",
"parseDsn",
"(",
"$",
"string",
"=",
"null",
")",
"{",
"$",
"opts",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"$",
"dsn",
"=",
"new",
"DSN",
"(",
"$",
"string",
")",
";",
"$",
... | Take a string DSN and parse it into an array of its pieces
@param null $string
@return array|null | [
"Take",
"a",
"string",
"DSN",
"and",
"parse",
"it",
"into",
"an",
"array",
"of",
"its",
"pieces"
] | 9ab7a9f7a8c02e1d41ca40301afada8129ea0a79 | https://github.com/werx/core/blob/9ab7a9f7a8c02e1d41ca40301afada8129ea0a79/src/Database.php#L100-L120 | train |
wb-crowdfusion/crowdfusion | system/core/classes/nodedb/events/AbstractBulkCountsHandler.php | AbstractBulkCountsHandler.commit | public function commit() {
if(empty($this->NodeCounts)) {
$this->Logger->debug(__FUNCTION__ .'-> No nodes to change counts on.');
return;
}
foreach($this->NodeCounts as $nodeRefUrl => $count) {
$nodeRef = $this->NodeRefService->parseFromString($nodeRefUrl);
... | php | public function commit() {
if(empty($this->NodeCounts)) {
$this->Logger->debug(__FUNCTION__ .'-> No nodes to change counts on.');
return;
}
foreach($this->NodeCounts as $nodeRefUrl => $count) {
$nodeRef = $this->NodeRefService->parseFromString($nodeRefUrl);
... | [
"public",
"function",
"commit",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"NodeCounts",
")",
")",
"{",
"$",
"this",
"->",
"Logger",
"->",
"debug",
"(",
"__FUNCTION__",
".",
"'-> No nodes to change counts on.'",
")",
";",
"return",
";",
"... | Update all meta on nodes queued
@return void | [
"Update",
"all",
"meta",
"on",
"nodes",
"queued"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/events/AbstractBulkCountsHandler.php#L34-L53 | train |
wb-crowdfusion/crowdfusion | system/core/classes/nodedb/events/AbstractBulkCountsHandler.php | AbstractBulkCountsHandler.increment | public function increment(NodeRef $nodeRef, NodeRef $extNodeRef, $tag)
{
$nodeRefUrl = $nodeRef->getRefURL();
if(!isset($this->NodeCounts[$nodeRefUrl]))
$this->NodeCounts[$nodeRefUrl] = 0;
$this->NodeCounts[$nodeRefUrl]++;
$this->Logger->debug(__FUNCTION__ ."-> Incremen... | php | public function increment(NodeRef $nodeRef, NodeRef $extNodeRef, $tag)
{
$nodeRefUrl = $nodeRef->getRefURL();
if(!isset($this->NodeCounts[$nodeRefUrl]))
$this->NodeCounts[$nodeRefUrl] = 0;
$this->NodeCounts[$nodeRefUrl]++;
$this->Logger->debug(__FUNCTION__ ."-> Incremen... | [
"public",
"function",
"increment",
"(",
"NodeRef",
"$",
"nodeRef",
",",
"NodeRef",
"$",
"extNodeRef",
",",
"$",
"tag",
")",
"{",
"$",
"nodeRefUrl",
"=",
"$",
"nodeRef",
"->",
"getRefURL",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->"... | Queue a node to have its meta incremented
@param NodeRef $nodeRef
@param NodeRef $extNodeRef
@param $tag | [
"Queue",
"a",
"node",
"to",
"have",
"its",
"meta",
"incremented"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/events/AbstractBulkCountsHandler.php#L62-L71 | train |
arrounded/core | src/Composers/AbstractComposer.php | AbstractComposer.getWebpackAssets | protected function getWebpackAssets()
{
$assets = public_path('builds/manifest.json');
$assets = file_get_contents($assets);
$assets = json_decode($assets, true);
return $assets;
} | php | protected function getWebpackAssets()
{
$assets = public_path('builds/manifest.json');
$assets = file_get_contents($assets);
$assets = json_decode($assets, true);
return $assets;
} | [
"protected",
"function",
"getWebpackAssets",
"(",
")",
"{",
"$",
"assets",
"=",
"public_path",
"(",
"'builds/manifest.json'",
")",
";",
"$",
"assets",
"=",
"file_get_contents",
"(",
"$",
"assets",
")",
";",
"$",
"assets",
"=",
"json_decode",
"(",
"$",
"asset... | Get the manifest of assets compiled by Webpack.
@return array | [
"Get",
"the",
"manifest",
"of",
"assets",
"compiled",
"by",
"Webpack",
"."
] | 9573d9ae63f5173bdfd51077ce065e9e8c176ac4 | https://github.com/arrounded/core/blob/9573d9ae63f5173bdfd51077ce065e9e8c176ac4/src/Composers/AbstractComposer.php#L28-L35 | train |
arrounded/core | src/Composers/AbstractComposer.php | AbstractComposer.makeMenu | protected function makeMenu($menu)
{
$links = [];
foreach ($menu as $key => $item) {
// Rebuild from associative array
if (is_string($item)) {
$item = [$key, $item];
}
list($endpoint, $label) = $item;
$attributes = array_ge... | php | protected function makeMenu($menu)
{
$links = [];
foreach ($menu as $key => $item) {
// Rebuild from associative array
if (is_string($item)) {
$item = [$key, $item];
}
list($endpoint, $label) = $item;
$attributes = array_ge... | [
"protected",
"function",
"makeMenu",
"(",
"$",
"menu",
")",
"{",
"$",
"links",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"menu",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"// Rebuild from associative array",
"if",
"(",
"is_string",
"(",
"$",
"item"... | Make a menu from a list of links.
@param array $menu
@return array | [
"Make",
"a",
"menu",
"from",
"a",
"list",
"of",
"links",
"."
] | 9573d9ae63f5173bdfd51077ce065e9e8c176ac4 | https://github.com/arrounded/core/blob/9573d9ae63f5173bdfd51077ce065e9e8c176ac4/src/Composers/AbstractComposer.php#L44-L78 | train |
arrounded/core | src/Composers/AbstractComposer.php | AbstractComposer.isOnPage | protected function isOnPage($page, $loose = true)
{
$page = $loose ? $page : '^'.$page.'$';
$page = str_replace('#', '\#', $page);
return (bool) preg_match('#'.$page.'#', $this->request->path());
} | php | protected function isOnPage($page, $loose = true)
{
$page = $loose ? $page : '^'.$page.'$';
$page = str_replace('#', '\#', $page);
return (bool) preg_match('#'.$page.'#', $this->request->path());
} | [
"protected",
"function",
"isOnPage",
"(",
"$",
"page",
",",
"$",
"loose",
"=",
"true",
")",
"{",
"$",
"page",
"=",
"$",
"loose",
"?",
"$",
"page",
":",
"'^'",
".",
"$",
"page",
".",
"'$'",
";",
"$",
"page",
"=",
"str_replace",
"(",
"'#'",
",",
... | Check if a string matches the given url.
@param string $page
@param bool $loose
@return bool | [
"Check",
"if",
"a",
"string",
"matches",
"the",
"given",
"url",
"."
] | 9573d9ae63f5173bdfd51077ce065e9e8c176ac4 | https://github.com/arrounded/core/blob/9573d9ae63f5173bdfd51077ce065e9e8c176ac4/src/Composers/AbstractComposer.php#L88-L94 | train |
arrounded/core | src/Composers/AbstractComposer.php | AbstractComposer.translate | protected function translate($string)
{
$translated = $this->app['translator']->get($string);
return is_string($translated) ? $translated : $string;
} | php | protected function translate($string)
{
$translated = $this->app['translator']->get($string);
return is_string($translated) ? $translated : $string;
} | [
"protected",
"function",
"translate",
"(",
"$",
"string",
")",
"{",
"$",
"translated",
"=",
"$",
"this",
"->",
"app",
"[",
"'translator'",
"]",
"->",
"get",
"(",
"$",
"string",
")",
";",
"return",
"is_string",
"(",
"$",
"translated",
")",
"?",
"$",
"... | Act on a string to translate it.
@param string $string
@return string | [
"Act",
"on",
"a",
"string",
"to",
"translate",
"it",
"."
] | 9573d9ae63f5173bdfd51077ce065e9e8c176ac4 | https://github.com/arrounded/core/blob/9573d9ae63f5173bdfd51077ce065e9e8c176ac4/src/Composers/AbstractComposer.php#L103-L108 | train |
squareproton/Bond | src/Bond/Container/FindFilterComponentMulti.php | FindFilterComponentMulti.check | public function check( $obj )
{
foreach( $this->findFilterComponents as $findFilterComponent ) {
if( $findFilterComponent->check($obj) ) {
return true;
}
}
return false;
} | php | public function check( $obj )
{
foreach( $this->findFilterComponents as $findFilterComponent ) {
if( $findFilterComponent->check($obj) ) {
return true;
}
}
return false;
} | [
"public",
"function",
"check",
"(",
"$",
"obj",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"findFilterComponents",
"as",
"$",
"findFilterComponent",
")",
"{",
"if",
"(",
"$",
"findFilterComponent",
"->",
"check",
"(",
"$",
"obj",
")",
")",
"{",
"return... | Pass a entity through a filter. Does it match?
@param mixed $object we're going to filter on
@return bool | [
"Pass",
"a",
"entity",
"through",
"a",
"filter",
".",
"Does",
"it",
"match?"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Container/FindFilterComponentMulti.php#L56-L64 | train |
gplcart/cli | controllers/commands/Cache.php | Cache.cmdGetCache | public function cmdGetCache()
{
$id = $this->getParam(0);
if (empty($id)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = $this->cache->get($id);
if (!isset($result)) {
$this->errorAndExit($this->text('Unexpected result'));
... | php | public function cmdGetCache()
{
$id = $this->getParam(0);
if (empty($id)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = $this->cache->get($id);
if (!isset($result)) {
$this->errorAndExit($this->text('Unexpected result'));
... | [
"public",
"function",
"cmdGetCache",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"this",
"->",
"errorAndExit",
"(",
"$",
"this",
"->",
"text",
"(",
"'... | Callback for "cache-get" command | [
"Callback",
"for",
"cache",
"-",
"get",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Cache.php#L40-L56 | train |
gplcart/cli | controllers/commands/Cache.php | Cache.cmdClearCache | public function cmdClearCache()
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
$pattern = $this->getParam... | php | public function cmdClearCache()
{
$id = $this->getParam(0);
$all = $this->getParam('all');
if (!isset($id) && empty($all)) {
$this->errorAndExit($this->text('Invalid command'));
}
$result = false;
if (isset($id)) {
$pattern = $this->getParam... | [
"public",
"function",
"cmdClearCache",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getParam",
"(",
"0",
")",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"getParam",
"(",
"'all'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
"&&",... | Callback for "cache-clear" command | [
"Callback",
"for",
"cache",
"-",
"clear",
"command"
] | e57dba53e291a225b4bff0c0d9b23d685dd1c125 | https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Cache.php#L61-L88 | train |
synaq/SynaqCurlBundle | Curl/Wrapper.php | Wrapper.setRequestOptions | private function setRequestOptions($url, $vars, $options = array())
{
curl_setopt($this->request, CURLOPT_URL, $url);
if (!empty($vars)) {
curl_setopt($this->request, CURLOPT_POSTFIELDS, $vars);
}
# Set some default CURL options
curl_setopt($this->request, CURLOP... | php | private function setRequestOptions($url, $vars, $options = array())
{
curl_setopt($this->request, CURLOPT_URL, $url);
if (!empty($vars)) {
curl_setopt($this->request, CURLOPT_POSTFIELDS, $vars);
}
# Set some default CURL options
curl_setopt($this->request, CURLOP... | [
"private",
"function",
"setRequestOptions",
"(",
"$",
"url",
",",
"$",
"vars",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"this",
"->",
"request",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"if",
"(",
"!",
"... | Sets the CURLOPT options for the current request
@param string $url
@param string $vars
@return void
@access protected | [
"Sets",
"the",
"CURLOPT",
"options",
"for",
"the",
"current",
"request"
] | 3bfb4ef7693ea621c31b9a32565a23c7d99f8a14 | https://github.com/synaq/SynaqCurlBundle/blob/3bfb4ef7693ea621c31b9a32565a23c7d99f8a14/Curl/Wrapper.php#L316-L343 | train |
synaq/SynaqCurlBundle | Curl/Wrapper.php | Wrapper.setRequestHeaders | private function setRequestHeaders($headers = array()) {
foreach ($this->headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
} | php | private function setRequestHeaders($headers = array()) {
foreach ($this->headers as $key => $value) {
$headers[] = $key . ': ' . $value;
}
curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
} | [
"private",
"function",
"setRequestHeaders",
"(",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"]",
"=",
"$",
"key",
".",
"': '",... | Formats and adds custom headers to the current request
@param array $headers
@return void
@access protected | [
"Formats",
"and",
"adds",
"custom",
"headers",
"to",
"the",
"current",
"request"
] | 3bfb4ef7693ea621c31b9a32565a23c7d99f8a14 | https://github.com/synaq/SynaqCurlBundle/blob/3bfb4ef7693ea621c31b9a32565a23c7d99f8a14/Curl/Wrapper.php#L352-L357 | train |
story75/Bonefish-Router | src/FastRoute.php | FastRoute.addRoutes | public function addRoutes(array $routes = [])
{
foreach($routes as $route)
{
if ($route instanceof RouteInterface) $this->routes[] = $route;
}
} | php | public function addRoutes(array $routes = [])
{
foreach($routes as $route)
{
if ($route instanceof RouteInterface) $this->routes[] = $route;
}
} | [
"public",
"function",
"addRoutes",
"(",
"array",
"$",
"routes",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"routes",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"instanceof",
"RouteInterface",
")",
"$",
"this",
"->",
"routes",
"[",
"]",... | Add all routes which are available
@param RouteInterface[] $routes
@return void | [
"Add",
"all",
"routes",
"which",
"are",
"available"
] | bb16960c9442303ceeb0c9d14b14be62018de05d | https://github.com/story75/Bonefish-Router/blob/bb16960c9442303ceeb0c9d14b14be62018de05d/src/FastRoute.php#L69-L75 | train |
story75/Bonefish-Router | src/FastRoute.php | FastRoute.dispatch | public function dispatch(Request $request)
{
if (ltrim($_SERVER['REQUEST_URI'], '/') === '') {
return new DispatcherResult(200, $this->defaultHandler);
}
$dispatcher = $this->getDispatcher();
$match = $dispatcher->dispatch($request->getMethod(), $_SERVER['REQUEST_URI'])... | php | public function dispatch(Request $request)
{
if (ltrim($_SERVER['REQUEST_URI'], '/') === '') {
return new DispatcherResult(200, $this->defaultHandler);
}
$dispatcher = $this->getDispatcher();
$match = $dispatcher->dispatch($request->getMethod(), $_SERVER['REQUEST_URI'])... | [
"public",
"function",
"dispatch",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"ltrim",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"'/'",
")",
"===",
"''",
")",
"{",
"return",
"new",
"DispatcherResult",
"(",
"200",
",",
"$",
"this",
... | Once called the router should examine the current request by request method and url
and find a matching route. If no route was find dispatch a http error instead.
Dispatch means in this context that the router will use the RouteCallbackDTO in the Route
and call the controller with the correct action and pass the param... | [
"Once",
"called",
"the",
"router",
"should",
"examine",
"the",
"current",
"request",
"by",
"request",
"method",
"and",
"url",
"and",
"find",
"a",
"matching",
"route",
".",
"If",
"no",
"route",
"was",
"find",
"dispatch",
"a",
"http",
"error",
"instead",
"."... | bb16960c9442303ceeb0c9d14b14be62018de05d | https://github.com/story75/Bonefish-Router/blob/bb16960c9442303ceeb0c9d14b14be62018de05d/src/FastRoute.php#L110-L146 | train |
netlogix/Netlogix.Crud | Classes/Netlogix/Crud/Utility/ArrayUtility.php | ArrayUtility.flatten | static public function flatten(array $array, $prefix = '', $keepEmptyArrayNode = TRUE, $segmentationCharacter = self::SEGMENTATION_CHARACTER) {
$flatArray = array();
foreach ($array as $key => $value) {
// Ensure there is no trailling dot:
$key = rtrim($key, $segmentationCharacter);
if (!is_array($value) |... | php | static public function flatten(array $array, $prefix = '', $keepEmptyArrayNode = TRUE, $segmentationCharacter = self::SEGMENTATION_CHARACTER) {
$flatArray = array();
foreach ($array as $key => $value) {
// Ensure there is no trailling dot:
$key = rtrim($key, $segmentationCharacter);
if (!is_array($value) |... | [
"static",
"public",
"function",
"flatten",
"(",
"array",
"$",
"array",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"keepEmptyArrayNode",
"=",
"TRUE",
",",
"$",
"segmentationCharacter",
"=",
"self",
"::",
"SEGMENTATION_CHARACTER",
")",
"{",
"$",
"flatArray",
"="... | Converts a multidimensional array to a flat representation.
See unit tests for more details
Example:
- array:
array(
'first.' => array(
'second' => 1
)
)
- result:
array(
'first.second' => 1
)
Example:
- array:
array(
'first' => array(
'second' => 1
)
)
- result:
array(
'first.second' => 1
)
@param array $array The... | [
"Converts",
"a",
"multidimensional",
"array",
"to",
"a",
"flat",
"representation",
"."
] | 61438827ba6b0a7a63cd2f08a294967ed5928144 | https://github.com/netlogix/Netlogix.Crud/blob/61438827ba6b0a7a63cd2f08a294967ed5928144/Classes/Netlogix/Crud/Utility/ArrayUtility.php#L61-L73 | train |
Saritasa/php-eloquent-custom | src/Entity.php | Entity.getAttributeValue | public function getAttributeValue($key)
{
$value = $this->getAttributeFromArray($key);
// check if it's a enum
if (isset($this->enums[$key]) && is_scalar($value)) {
$enumClass = $this->enums[$key];
return new $enumClass($value);
}
return parent::getAtt... | php | public function getAttributeValue($key)
{
$value = $this->getAttributeFromArray($key);
// check if it's a enum
if (isset($this->enums[$key]) && is_scalar($value)) {
$enumClass = $this->enums[$key];
return new $enumClass($value);
}
return parent::getAtt... | [
"public",
"function",
"getAttributeValue",
"(",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getAttributeFromArray",
"(",
"$",
"key",
")",
";",
"// check if it's a enum",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"enums",
"[",
"$",
"key... | Gets the value of attribute,
taking enums typecast into consideration
@param string $key Name of attribute
@return mixed | [
"Gets",
"the",
"value",
"of",
"attribute",
"taking",
"enums",
"typecast",
"into",
"consideration"
] | 54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a | https://github.com/Saritasa/php-eloquent-custom/blob/54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a/src/Entity.php#L41-L50 | train |
Saritasa/php-eloquent-custom | src/Entity.php | Entity.setAttribute | public function setAttribute($key, $value)
{
// check if it's a enum
if (isset($this->enums[$key]) && is_scalar($value)) {
$enumClass = $this->enums[$key];
$this->attributes[$key] = new $enumClass($value);
} else {
parent::setAttribute($key, $value);
... | php | public function setAttribute($key, $value)
{
// check if it's a enum
if (isset($this->enums[$key]) && is_scalar($value)) {
$enumClass = $this->enums[$key];
$this->attributes[$key] = new $enumClass($value);
} else {
parent::setAttribute($key, $value);
... | [
"public",
"function",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// check if it's a enum",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"enums",
"[",
"$",
"key",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
... | Sets the value of attribute,
taking enums typecast into consideration
@param string $key Name of the attribute
@param mixed $value Value of the attribute to set
@return $this | [
"Sets",
"the",
"value",
"of",
"attribute",
"taking",
"enums",
"typecast",
"into",
"consideration"
] | 54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a | https://github.com/Saritasa/php-eloquent-custom/blob/54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a/src/Entity.php#L60-L70 | train |
Saritasa/php-eloquent-custom | src/Entity.php | Entity.getEnumValidationRule | protected static function getEnumValidationRule(string $enumClass) : array
{
if (!is_a($enumClass, Enum::class, true)) {
throw new \UnexpectedValueException('Class is not enum');
}
return array_merge(['in'], $enumClass::getConstants());
} | php | protected static function getEnumValidationRule(string $enumClass) : array
{
if (!is_a($enumClass, Enum::class, true)) {
throw new \UnexpectedValueException('Class is not enum');
}
return array_merge(['in'], $enumClass::getConstants());
} | [
"protected",
"static",
"function",
"getEnumValidationRule",
"(",
"string",
"$",
"enumClass",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"enumClass",
",",
"Enum",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedV... | Gets validation rule for given enum class
@deprecated Should use Rule::enum($enumClass)
@param string $enumClass Enum class name
@return array | [
"Gets",
"validation",
"rule",
"for",
"given",
"enum",
"class"
] | 54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a | https://github.com/Saritasa/php-eloquent-custom/blob/54a2479f1d6e9cddac14dd8e473ab6a99dc6a82a/src/Entity.php#L80-L87 | train |
stubbles/stubbles-dbal | src/main/php/DatabaseConnections.php | DatabaseConnections.get | public function get(string $name = null): DatabaseConnection
{
if (null == $name) {
$name = DatabaseConfiguration::DEFAULT_ID;
}
if (isset($this->connections[$name])) {
return $this->connections[$name];
}
$this->connections[$name] = new PdoDatabaseCo... | php | public function get(string $name = null): DatabaseConnection
{
if (null == $name) {
$name = DatabaseConfiguration::DEFAULT_ID;
}
if (isset($this->connections[$name])) {
return $this->connections[$name];
}
$this->connections[$name] = new PdoDatabaseCo... | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"DatabaseConnection",
"{",
"if",
"(",
"null",
"==",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"DatabaseConfiguration",
"::",
"DEFAULT_ID",
";",
"}",
"if",
"(",
"isset",
"(",... | returns the connection
If a name is provided and a connection with this name exists this
connection will be returned. If fallback is enabled and the named
connection does not exist the default connection will be returned, if
fallback is disabled a DatabaseException will be thrown.
If no name is provided the default c... | [
"returns",
"the",
"connection"
] | b42a589025a9e511b40a2798ac84df94d6451c36 | https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/DatabaseConnections.php#L58-L72 | train |
geniv/nette-identity-authorizator | src/Drivers/ArrayDriver.php | ArrayDriver.init | protected function init()
{
if ($this->policy != self::POLICY_NONE) {
// set role
foreach ($this->_role as $role) {
$this->role[$role] = ['id' => $role, 'role' => $role];
$this->permission->addRole($role);
}
// set resource
... | php | protected function init()
{
if ($this->policy != self::POLICY_NONE) {
// set role
foreach ($this->_role as $role) {
$this->role[$role] = ['id' => $role, 'role' => $role];
$this->permission->addRole($role);
}
// set resource
... | [
"protected",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"policy",
"!=",
"self",
"::",
"POLICY_NONE",
")",
"{",
"// set role",
"foreach",
"(",
"$",
"this",
"->",
"_role",
"as",
"$",
"role",
")",
"{",
"$",
"this",
"->",
"role",
... | Init data. | [
"Init",
"data",
"."
] | f7db1cd589d022b6443f24a59432098a343d4639 | https://github.com/geniv/nette-identity-authorizator/blob/f7db1cd589d022b6443f24a59432098a343d4639/src/Drivers/ArrayDriver.php#L44-L124 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.