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
solspace/craft3-commons
src/Helpers/StringHelper.php
StringHelper.compileAttributeStringFromArray
public static function compileAttributeStringFromArray(array $array): string { $attributeString = ''; foreach ($array as $key => $value) { if (null === $value || (\is_bool($value) && $value)) { $attributeString .= "$key "; } else if (!\is_bool($value)) { $attributeString .= "$key=\"$value\" "; } } return $attributeString ? ' ' . $attributeString : ''; }
php
public static function compileAttributeStringFromArray(array $array): string { $attributeString = ''; foreach ($array as $key => $value) { if (null === $value || (\is_bool($value) && $value)) { $attributeString .= "$key "; } else if (!\is_bool($value)) { $attributeString .= "$key=\"$value\" "; } } return $attributeString ? ' ' . $attributeString : ''; }
[ "public", "static", "function", "compileAttributeStringFromArray", "(", "array", "$", "array", ")", ":", "string", "{", "$", "attributeString", "=", "''", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "null...
Walk through the array and create an HTML tag attribute string @param array $array @return string
[ "Walk", "through", "the", "array", "and", "create", "an", "HTML", "tag", "attribute", "string" ]
2de20a76e83efe3ed615a2a102dfef18e2295420
https://github.com/solspace/craft3-commons/blob/2de20a76e83efe3ed615a2a102dfef18e2295420/src/Helpers/StringHelper.php#L91-L104
train
avto-dev/identity-laravel
src/Types/IDEntityGrz.php
IDEntityGrz.getFormatPatternByGostType
public static function getFormatPatternByGostType($gost_type) { foreach (static::$patterns_and_types_map as $format_pattern => $gost_types) { foreach ((array) $gost_types as $iterated_gost_type) { if ($iterated_gost_type === $gost_type) { return $format_pattern; } } } }
php
public static function getFormatPatternByGostType($gost_type) { foreach (static::$patterns_and_types_map as $format_pattern => $gost_types) { foreach ((array) $gost_types as $iterated_gost_type) { if ($iterated_gost_type === $gost_type) { return $format_pattern; } } } }
[ "public", "static", "function", "getFormatPatternByGostType", "(", "$", "gost_type", ")", "{", "foreach", "(", "static", "::", "$", "patterns_and_types_map", "as", "$", "format_pattern", "=>", "$", "gost_types", ")", "{", "foreach", "(", "(", "array", ")", "$"...
Get pattern format by passed GOST type. @param string $gost_type @return string|null
[ "Get", "pattern", "format", "by", "passed", "GOST", "type", "." ]
ea01e4fda4bf41723f6206a5921aba2f1a159061
https://github.com/avto-dev/identity-laravel/blob/ea01e4fda4bf41723f6206a5921aba2f1a159061/src/Types/IDEntityGrz.php#L101-L110
train
avto-dev/identity-laravel
src/Types/IDEntityGrz.php
IDEntityGrz.getFormatPattern
public function getFormatPattern() { static $kyr = self::KYR_CHARS; switch (true) { // X000XX77_OR_X000XX777 case \preg_match("~^[{$kyr}]{1}\d{3}[{$kyr}]{2}\d{2,3}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_1; // X000XX case \preg_match("~^[{$kyr}]{1}\d{3}[{$kyr}]{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_2; // XX00077 case \preg_match("~^[{$kyr}]{2}\d{3}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_3; // 0000XX77 case \preg_match("~^\d{4}[{$kyr}]{2}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_4; // XX000077 case \preg_match("~^[{$kyr}]{2}\d{4}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_5; // X000077 case \preg_match("~^[{$kyr}]{1}\d{4}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_6; // 000X77 case \preg_match("~^\d{3}[{$kyr}]{1}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_7; // 0000X77 case \preg_match("~^\d{4}[{$kyr}]{1}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_8; } }
php
public function getFormatPattern() { static $kyr = self::KYR_CHARS; switch (true) { // X000XX77_OR_X000XX777 case \preg_match("~^[{$kyr}]{1}\d{3}[{$kyr}]{2}\d{2,3}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_1; // X000XX case \preg_match("~^[{$kyr}]{1}\d{3}[{$kyr}]{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_2; // XX00077 case \preg_match("~^[{$kyr}]{2}\d{3}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_3; // 0000XX77 case \preg_match("~^\d{4}[{$kyr}]{2}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_4; // XX000077 case \preg_match("~^[{$kyr}]{2}\d{4}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_5; // X000077 case \preg_match("~^[{$kyr}]{1}\d{4}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_6; // 000X77 case \preg_match("~^\d{3}[{$kyr}]{1}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_7; // 0000X77 case \preg_match("~^\d{4}[{$kyr}]{1}\d{2}$~iu", $this->value) === 1: return self::FORMAT_PATTERN_8; } }
[ "public", "function", "getFormatPattern", "(", ")", "{", "static", "$", "kyr", "=", "self", "::", "KYR_CHARS", ";", "switch", "(", "true", ")", "{", "// X000XX77_OR_X000XX777", "case", "\\", "preg_match", "(", "\"~^[{$kyr}]{1}\\d{3}[{$kyr}]{2}\\d{2,3}$~iu\"", ",", ...
Returns value format pattern. @return string|null
[ "Returns", "value", "format", "pattern", "." ]
ea01e4fda4bf41723f6206a5921aba2f1a159061
https://github.com/avto-dev/identity-laravel/blob/ea01e4fda4bf41723f6206a5921aba2f1a159061/src/Types/IDEntityGrz.php#L139-L176
train
krystal-framework/krystal.framework
src/Krystal/Image/Tool/ImageBag.php
ImageBag.getPath
public function getPath($size) { if ($this->isProvided()) { return $this->locationBuilder->buildPath($this->id, $this->cover, $size); } else { throw new RuntimeException('You gotta provide both id and cover to use this method'); } }
php
public function getPath($size) { if ($this->isProvided()) { return $this->locationBuilder->buildPath($this->id, $this->cover, $size); } else { throw new RuntimeException('You gotta provide both id and cover to use this method'); } }
[ "public", "function", "getPath", "(", "$", "size", ")", "{", "if", "(", "$", "this", "->", "isProvided", "(", ")", ")", "{", "return", "$", "this", "->", "locationBuilder", "->", "buildPath", "(", "$", "this", "->", "id", ",", "$", "this", "->", "c...
Returns image path on the file-system filtered by provided size @param string $size @throws RuntimeException when not ready to be used @return string
[ "Returns", "image", "path", "on", "the", "file", "-", "system", "filtered", "by", "provided", "size" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/ImageBag.php#L94-L101
train
krystal-framework/krystal.framework
src/Krystal/Image/Tool/ImageBag.php
ImageBag.getUrl
public function getUrl($size) { if ($this->isProvided()) { return $this->locationBuilder->buildUrl($this->id, $this->cover, $size); } else { throw new RuntimeException('You gotta provide both id and cover to use this method'); } }
php
public function getUrl($size) { if ($this->isProvided()) { return $this->locationBuilder->buildUrl($this->id, $this->cover, $size); } else { throw new RuntimeException('You gotta provide both id and cover to use this method'); } }
[ "public", "function", "getUrl", "(", "$", "size", ")", "{", "if", "(", "$", "this", "->", "isProvided", "(", ")", ")", "{", "return", "$", "this", "->", "locationBuilder", "->", "buildUrl", "(", "$", "this", "->", "id", ",", "$", "this", "->", "cov...
Returns image URL filtered by provided size @param string $size @throws RuntimeException when not ready to be used @return string
[ "Returns", "image", "URL", "filtered", "by", "provided", "size" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/ImageBag.php#L110-L117
train
krystal-framework/krystal.framework
src/Krystal/Validate/Input/Constraint/Between.php
Between.isValid
public function isValid($target) { if ($target >= $this->start && $target <= $this->end) { return true; } else { $this->violate(sprintf($this->message, $this->start, $this->end)); return false; } }
php
public function isValid($target) { if ($target >= $this->start && $target <= $this->end) { return true; } else { $this->violate(sprintf($this->message, $this->start, $this->end)); return false; } }
[ "public", "function", "isValid", "(", "$", "target", ")", "{", "if", "(", "$", "target", ">=", "$", "this", "->", "start", "&&", "$", "target", "<=", "$", "this", "->", "end", ")", "{", "return", "true", ";", "}", "else", "{", "$", "this", "->", ...
Checks whether values @param string $target @return boolean
[ "Checks", "whether", "values" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Validate/Input/Constraint/Between.php#L54-L62
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.deployBuild
public function deployBuild($opts = [ 'build-path' => null, 'deploy-type' => 'git', 'include-asset' => [], ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $build_path = $this->buildPath($opts); $deploy_type = $opts['deploy-type']; if (!file_exists($build_path)) { $this->_mkdir($build_path); } $this->executeBuild(__FUNCTION__, $build_path); $this->executeIncludeAssets($opts['include-asset'], $build_path); $this->executeCommandHook(__FUNCTION__, 'after'); $continue = !is_null($deploy_type) ? $this->doAsk(new ConfirmationQuestion('Run deployment? (y/n) [yes] ', true)) : false; if (!$continue) { return; } $this->deployPush([ 'build-path' => $build_path, 'deploy-type' => $deploy_type ]); }
php
public function deployBuild($opts = [ 'build-path' => null, 'deploy-type' => 'git', 'include-asset' => [], ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $build_path = $this->buildPath($opts); $deploy_type = $opts['deploy-type']; if (!file_exists($build_path)) { $this->_mkdir($build_path); } $this->executeBuild(__FUNCTION__, $build_path); $this->executeIncludeAssets($opts['include-asset'], $build_path); $this->executeCommandHook(__FUNCTION__, 'after'); $continue = !is_null($deploy_type) ? $this->doAsk(new ConfirmationQuestion('Run deployment? (y/n) [yes] ', true)) : false; if (!$continue) { return; } $this->deployPush([ 'build-path' => $build_path, 'deploy-type' => $deploy_type ]); }
[ "public", "function", "deployBuild", "(", "$", "opts", "=", "[", "'build-path'", "=>", "null", ",", "'deploy-type'", "=>", "'git'", ",", "'include-asset'", "=>", "[", "]", ",", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",...
Run the deployment build process. @param array $opts @option $build-path The build path it should be built at. @option $deploy-type The deployment type that should be used. @option $include-asset Include directory/file to the build. @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Run", "the", "deployment", "build", "process", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L25-L54
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.deployPush
public function deployPush($opts = [ 'build-path' => null, 'deploy-type' => 'git', ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $build_path = $this->buildPath($opts); if (!file_exists($build_path)) { throw new DeploymentRuntimeException( 'Build directory does not exist.' ); } /** @var DeployBase $deploy */ $deploy = $this->loadDeployTask( $opts['deploy-type'], $build_path ); $this->executeDeploy(__FUNCTION__, $deploy); $this->executeCommandHook(__FUNCTION__, 'after'); }
php
public function deployPush($opts = [ 'build-path' => null, 'deploy-type' => 'git', ]) { $this->executeCommandHook(__FUNCTION__, 'before'); $build_path = $this->buildPath($opts); if (!file_exists($build_path)) { throw new DeploymentRuntimeException( 'Build directory does not exist.' ); } /** @var DeployBase $deploy */ $deploy = $this->loadDeployTask( $opts['deploy-type'], $build_path ); $this->executeDeploy(__FUNCTION__, $deploy); $this->executeCommandHook(__FUNCTION__, 'after'); }
[ "public", "function", "deployPush", "(", "$", "opts", "=", "[", "'build-path'", "=>", "null", ",", "'deploy-type'", "=>", "'git'", ",", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "build_path...
Run the deployment push process. @param array $opts @option $build-path The path that the build was built at. @option $deploy-type The deployment type that should be used. @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Run", "the", "deployment", "push", "process", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L65-L86
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.executeIncludeAssets
protected function executeIncludeAssets(array $assets, $build_path) { $root_path = ProjectX::projectRoot(); foreach ($assets as $asset) { $file_info = new \splFileInfo("{$root_path}/{$asset}"); if (!file_exists($file_info)) { continue; } $file_path = $file_info->getRealPath(); $file_method = $file_info->isFile() ? '_copy' : '_mirrorDir'; call_user_func_array([$this, $file_method], [ $file_path, "{$build_path}/{$file_info->getFilename()}" ]); } }
php
protected function executeIncludeAssets(array $assets, $build_path) { $root_path = ProjectX::projectRoot(); foreach ($assets as $asset) { $file_info = new \splFileInfo("{$root_path}/{$asset}"); if (!file_exists($file_info)) { continue; } $file_path = $file_info->getRealPath(); $file_method = $file_info->isFile() ? '_copy' : '_mirrorDir'; call_user_func_array([$this, $file_method], [ $file_path, "{$build_path}/{$file_info->getFilename()}" ]); } }
[ "protected", "function", "executeIncludeAssets", "(", "array", "$", "assets", ",", "$", "build_path", ")", "{", "$", "root_path", "=", "ProjectX", "::", "projectRoot", "(", ")", ";", "foreach", "(", "$", "assets", "as", "$", "asset", ")", "{", "$", "file...
Execute including assets to the build directory. @param array $assets @param $build_path
[ "Execute", "including", "assets", "to", "the", "build", "directory", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L94-L111
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.executeBuild
protected function executeBuild($method, $build_path) { $this->say('Build has initialized!'); $this->executeCommandHook($method, 'before_build'); $this->projectInstance()->onDeployBuild($build_path); $this->executeCommandHook($method, 'after_build'); $this->say('Build has completed!'); return $this; }
php
protected function executeBuild($method, $build_path) { $this->say('Build has initialized!'); $this->executeCommandHook($method, 'before_build'); $this->projectInstance()->onDeployBuild($build_path); $this->executeCommandHook($method, 'after_build'); $this->say('Build has completed!'); return $this; }
[ "protected", "function", "executeBuild", "(", "$", "method", ",", "$", "build_path", ")", "{", "$", "this", "->", "say", "(", "'Build has initialized!'", ")", ";", "$", "this", "->", "executeCommandHook", "(", "$", "method", ",", "'before_build'", ")", ";", ...
Execute build process. @param $method @param $build_path @return self @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Execute", "build", "process", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L123-L132
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.executeDeploy
protected function executeDeploy($method, DeployBase $deploy) { $this->say('Deploy has initialized!'); $deploy->beforeDeploy(); $this->executeCommandHook($method, 'before_deploy'); $deploy->onDeploy(); $this->executeCommandHook($method, 'after_deploy'); $deploy->afterDeploy(); $this->say('Deploy has completed!'); return $this; }
php
protected function executeDeploy($method, DeployBase $deploy) { $this->say('Deploy has initialized!'); $deploy->beforeDeploy(); $this->executeCommandHook($method, 'before_deploy'); $deploy->onDeploy(); $this->executeCommandHook($method, 'after_deploy'); $deploy->afterDeploy(); $this->say('Deploy has completed!'); return $this; }
[ "protected", "function", "executeDeploy", "(", "$", "method", ",", "DeployBase", "$", "deploy", ")", "{", "$", "this", "->", "say", "(", "'Deploy has initialized!'", ")", ";", "$", "deploy", "->", "beforeDeploy", "(", ")", ";", "$", "this", "->", "executeC...
Execute deployment process. @param $method @param DeployBase $deploy @return self @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Execute", "deployment", "process", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L144-L155
train
droath/project-x
src/Task/DeployTasks.php
DeployTasks.loadDeployTask
protected function loadDeployTask($type, $build_path, array $configurations = []) { $definitions = $this->deployDefinitions(); $classname = isset($definitions[$type]) && class_exists($definitions[$type]) ? $definitions[$type] : 'Droath\ProjectX\Deploy\NullDeploy'; return (new $classname($build_path, $configurations)) ->setInput($this->input()) ->setOutput($this->output()) ->setBuilder($this->getBuilder()) ->setContainer($this->getContainer()); }
php
protected function loadDeployTask($type, $build_path, array $configurations = []) { $definitions = $this->deployDefinitions(); $classname = isset($definitions[$type]) && class_exists($definitions[$type]) ? $definitions[$type] : 'Droath\ProjectX\Deploy\NullDeploy'; return (new $classname($build_path, $configurations)) ->setInput($this->input()) ->setOutput($this->output()) ->setBuilder($this->getBuilder()) ->setContainer($this->getContainer()); }
[ "protected", "function", "loadDeployTask", "(", "$", "type", ",", "$", "build_path", ",", "array", "$", "configurations", "=", "[", "]", ")", "{", "$", "definitions", "=", "$", "this", "->", "deployDefinitions", "(", ")", ";", "$", "classname", "=", "iss...
Load deployment task. @param $type @param $build_path @param array $configurations @return DeployBase
[ "Load", "deployment", "task", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Task/DeployTasks.php#L166-L179
train
phpcq/author-validation
src/AuthorExtractor/GitProjectAuthorExtractor.php
GitProjectAuthorExtractor.hasUncommittedChanges
private function hasUncommittedChanges($git) { $status = $git->status()->short()->getIndexStatus(); if (empty($status)) { return false; } return true; }
php
private function hasUncommittedChanges($git) { $status = $git->status()->short()->getIndexStatus(); if (empty($status)) { return false; } return true; }
[ "private", "function", "hasUncommittedChanges", "(", "$", "git", ")", "{", "$", "status", "=", "$", "git", "->", "status", "(", ")", "->", "short", "(", ")", "->", "getIndexStatus", "(", ")", ";", "if", "(", "empty", "(", "$", "status", ")", ")", "...
Check if git repository has uncommitted modifications. @param GitRepository $git The repository to extract all files from. @return bool
[ "Check", "if", "git", "repository", "has", "uncommitted", "modifications", "." ]
1e22f6133dcadea486a7961274f4e611b5ef4c0c
https://github.com/phpcq/author-validation/blob/1e22f6133dcadea486a7961274f4e611b5ef4c0c/src/AuthorExtractor/GitProjectAuthorExtractor.php#L73-L82
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.sslRedirect
public function sslRedirect() { if (!$this->isSecure()) { $redirect = 'https://' . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI']; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirect); exit(); } }
php
public function sslRedirect() { if (!$this->isSecure()) { $redirect = 'https://' . $this->server['HTTP_HOST'] . $this->server['REQUEST_URI']; header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $redirect); exit(); } }
[ "public", "function", "sslRedirect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isSecure", "(", ")", ")", "{", "$", "redirect", "=", "'https://'", ".", "$", "this", "->", "server", "[", "'HTTP_HOST'", "]", ".", "$", "this", "->", "server", ...
Run HTTP to HTTPs redirect @return void
[ "Run", "HTTP", "to", "HTTPs", "redirect" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L78-L87
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getAll
public function getAll($separate = true) { if ($this->isPost()) { $data = $this->getPost(); } if ($this->isGet()) { $data = $this->getQuery(); } // Append files also, if we have them if ($this->hasFiles()) { $files = $this->getFiles(); } else { $files = array(); } if ($separate === false) { return array_merge($data, $files); } else { $result = array(); $result['data'] = $data; $result['files'] = !empty($files) ? $files : array(); return $result; } }
php
public function getAll($separate = true) { if ($this->isPost()) { $data = $this->getPost(); } if ($this->isGet()) { $data = $this->getQuery(); } // Append files also, if we have them if ($this->hasFiles()) { $files = $this->getFiles(); } else { $files = array(); } if ($separate === false) { return array_merge($data, $files); } else { $result = array(); $result['data'] = $data; $result['files'] = !empty($files) ? $files : array(); return $result; } }
[ "public", "function", "getAll", "(", "$", "separate", "=", "true", ")", "{", "if", "(", "$", "this", "->", "isPost", "(", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getPost", "(", ")", ";", "}", "if", "(", "$", "this", "->", "isGet", ...
Returns all request data @param boolean $separate Whether to separate data from files into distinct resulting array keys @return array
[ "Returns", "all", "request", "data" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L157-L183
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.buildQuery
public function buildQuery(array $params, $includeCurrent = true) { if ($includeCurrent == true) { $params = array_replace_recursive($this->getQuery(), $params); } return $this->serialize($params); }
php
public function buildQuery(array $params, $includeCurrent = true) { if ($includeCurrent == true) { $params = array_replace_recursive($this->getQuery(), $params); } return $this->serialize($params); }
[ "public", "function", "buildQuery", "(", "array", "$", "params", ",", "$", "includeCurrent", "=", "true", ")", "{", "if", "(", "$", "includeCurrent", "==", "true", ")", "{", "$", "params", "=", "array_replace_recursive", "(", "$", "this", "->", "getQuery",...
Builds query string @param array $params @param boolean $includeCurrent Whether to include current data from query string @return array
[ "Builds", "query", "string" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L192-L199
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getFile
public function getFile($name = null, $index = 0, $default = false) { $files = $this->getFiles($name); if (isset($files[$index])) { return $files[$index]; } else { return $default; } }
php
public function getFile($name = null, $index = 0, $default = false) { $files = $this->getFiles($name); if (isset($files[$index])) { return $files[$index]; } else { return $default; } }
[ "public", "function", "getFile", "(", "$", "name", "=", "null", ",", "$", "index", "=", "0", ",", "$", "default", "=", "false", ")", "{", "$", "files", "=", "$", "this", "->", "getFiles", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$"...
Returns a single file bag from uploaded collection @param string $name Optional field name @param string $index File key index. 0 - means return first @param mixed $default Default value to be returned in case $index doesn't exist @return array
[ "Returns", "a", "single", "file", "bag", "from", "uploaded", "collection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L264-L273
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.hasFiles
public function hasFiles($name = null) { if (!empty($this->files)) { // if $name is null, then a global checking must be done return $this->getFilesbag()->hasFiles($name); } // By default return false; }
php
public function hasFiles($name = null) { if (!empty($this->files)) { // if $name is null, then a global checking must be done return $this->getFilesbag()->hasFiles($name); } // By default return false; }
[ "public", "function", "hasFiles", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "files", ")", ")", "{", "// if $name is null, then a global checking must be done", "return", "$", "this", "->", "getFilesbag", "(", "...
Checks whether we at least one file @param string $name Can be optionally filtered by a name @return boolean Depending on success
[ "Checks", "whether", "we", "at", "least", "one", "file" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L281-L290
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getFilesbag
private function getFilesbag() { static $filesBag = null; if (is_null($filesBag)) { $filesBag = new FileInput($this->files); } return $filesBag; }
php
private function getFilesbag() { static $filesBag = null; if (is_null($filesBag)) { $filesBag = new FileInput($this->files); } return $filesBag; }
[ "private", "function", "getFilesbag", "(", ")", "{", "static", "$", "filesBag", "=", "null", ";", "if", "(", "is_null", "(", "$", "filesBag", ")", ")", "{", "$", "filesBag", "=", "new", "FileInput", "(", "$", "this", "->", "files", ")", ";", "}", "...
Returns files bag For internal usage only @return \Krystal\Http\FileTransfer\Input
[ "Returns", "files", "bag", "For", "internal", "usage", "only" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L298-L307
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getSubdomains
public function getSubdomains() { $current = $this->server['HTTP_HOST']; $parts = explode('.', $current); // two steps back array_pop($parts); array_pop($parts); return $parts; }
php
public function getSubdomains() { $current = $this->server['HTTP_HOST']; $parts = explode('.', $current); // two steps back array_pop($parts); array_pop($parts); return $parts; }
[ "public", "function", "getSubdomains", "(", ")", "{", "$", "current", "=", "$", "this", "->", "server", "[", "'HTTP_HOST'", "]", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "current", ")", ";", "// two steps back", "array_pop", "(", "$", "...
Returns all sub-domains @return array
[ "Returns", "all", "sub", "-", "domains" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L422-L432
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getDomain
public function getDomain() { $current = $this->server['HTTP_HOST']; $parts = explode('.', $current); $zone = array_pop($parts); $provider = array_pop($parts); return $provider . '.' . $zone; }
php
public function getDomain() { $current = $this->server['HTTP_HOST']; $parts = explode('.', $current); $zone = array_pop($parts); $provider = array_pop($parts); return $provider . '.' . $zone; }
[ "public", "function", "getDomain", "(", ")", "{", "$", "current", "=", "$", "this", "->", "server", "[", "'HTTP_HOST'", "]", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "current", ")", ";", "$", "zone", "=", "array_pop", "(", "$", "par...
Returns base domain @return string
[ "Returns", "base", "domain" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L439-L448
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getLanguages
public function getLanguages() { $source = $this->server['HTTP_ACCEPT_LANGUAGE']; if (strpos($source, ',') !== false) { $langs = explode(',', $source); return $langs; } else { return array($source); } }
php
public function getLanguages() { $source = $this->server['HTTP_ACCEPT_LANGUAGE']; if (strpos($source, ',') !== false) { $langs = explode(',', $source); return $langs; } else { return array($source); } }
[ "public", "function", "getLanguages", "(", ")", "{", "$", "source", "=", "$", "this", "->", "server", "[", "'HTTP_ACCEPT_LANGUAGE'", "]", ";", "if", "(", "strpos", "(", "$", "source", ",", "','", ")", "!==", "false", ")", "{", "$", "langs", "=", "exp...
Returns all available languages supported by browser @return array
[ "Returns", "all", "available", "languages", "supported", "by", "browser" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L455-L465
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.isSecure
public function isSecure() { return ( (!empty($this->server['HTTPS']) && $this->server['HTTPS'] != 'off') || (!empty($this->server['HTTP_HTTPS']) && $this->server['HTTP_HTTPS'] != 'off') || $this->server['REQUEST_SCHEME'] == 'https' || $this->server['SERVER_PORT'] == 443 ); }
php
public function isSecure() { return ( (!empty($this->server['HTTPS']) && $this->server['HTTPS'] != 'off') || (!empty($this->server['HTTP_HTTPS']) && $this->server['HTTP_HTTPS'] != 'off') || $this->server['REQUEST_SCHEME'] == 'https' || $this->server['SERVER_PORT'] == 443 ); }
[ "public", "function", "isSecure", "(", ")", "{", "return", "(", "(", "!", "empty", "(", "$", "this", "->", "server", "[", "'HTTPS'", "]", ")", "&&", "$", "this", "->", "server", "[", "'HTTPS'", "]", "!=", "'off'", ")", "||", "(", "!", "empty", "(...
Checks whether requested from secured connection @return boolean
[ "Checks", "whether", "requested", "from", "secured", "connection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L542-L549
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.hasQueryNs
public function hasQueryNs($ns, $key) { $data = $this->getQuery($ns); // If there's no such key, then $data isn't an array, so just make sure if (is_array($data)) { return array_key_exists($key, $data); } else { // If $data isn't an array, then there's no such key return false; } }
php
public function hasQueryNs($ns, $key) { $data = $this->getQuery($ns); // If there's no such key, then $data isn't an array, so just make sure if (is_array($data)) { return array_key_exists($key, $data); } else { // If $data isn't an array, then there's no such key return false; } }
[ "public", "function", "hasQueryNs", "(", "$", "ns", ",", "$", "key", ")", "{", "$", "data", "=", "$", "this", "->", "getQuery", "(", "$", "ns", ")", ";", "// If there's no such key, then $data isn't an array, so just make sure", "if", "(", "is_array", "(", "$"...
Checks whether there's a key in namespaced query @param string $ns Namespace (Group) @param string $key @return boolean
[ "Checks", "whether", "there", "s", "a", "key", "in", "namespaced", "query" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L638-L649
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getQueryNs
public function getQueryNs($ns, $key, $default) { if ($this->hasQueryNs($ns, $key)) { $data = $this->getQuery($ns); if (isset($data[$key])) { return $data[$key]; } } return $default; }
php
public function getQueryNs($ns, $key, $default) { if ($this->hasQueryNs($ns, $key)) { $data = $this->getQuery($ns); if (isset($data[$key])) { return $data[$key]; } } return $default; }
[ "public", "function", "getQueryNs", "(", "$", "ns", ",", "$", "key", ",", "$", "default", ")", "{", "if", "(", "$", "this", "->", "hasQueryNs", "(", "$", "ns", ",", "$", "key", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getQuery", "("...
Returns key's value from a namespace @param string $ns Target namespace (Group) @param string $key Target key @param mixed $default Default value to be returned on failure @return mixed
[ "Returns", "key", "s", "value", "from", "a", "namespace" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L659-L670
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getWithNsQuery
public function getWithNsQuery($ns, array $data, $mark = true) { if ($this->hasQuery($ns)) { $query = $this->getQuery($ns); $url = null; if ($mark === true) { $url = '?'; } $url .= http_build_query(array($ns => array_merge($query, $data))); $url = str_replace('%25s', '%s', $url); return $url; } else { return null; } }
php
public function getWithNsQuery($ns, array $data, $mark = true) { if ($this->hasQuery($ns)) { $query = $this->getQuery($ns); $url = null; if ($mark === true) { $url = '?'; } $url .= http_build_query(array($ns => array_merge($query, $data))); $url = str_replace('%25s', '%s', $url); return $url; } else { return null; } }
[ "public", "function", "getWithNsQuery", "(", "$", "ns", ",", "array", "$", "data", ",", "$", "mark", "=", "true", ")", "{", "if", "(", "$", "this", "->", "hasQuery", "(", "$", "ns", ")", ")", "{", "$", "query", "=", "$", "this", "->", "getQuery",...
Merges and returns current query data with defined data and returns as query string @param string $ns Target namespace (Group) @param array $data Data to be merged @param boolean $mark Whether to prepend question mark @return string
[ "Merges", "and", "returns", "current", "query", "data", "with", "defined", "data", "and", "returns", "as", "query", "string" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L680-L697
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getWithQuery
public function getWithQuery(array $data, $mark = true) { if ($this->hasQuery()) { $url = null; if ($mark === true) { $url = '?'; } $url .= http_build_query(array_merge($this->getQuery(), $data)); $url = str_replace('%25s', '%s', $url); return $url; } else { return null; } }
php
public function getWithQuery(array $data, $mark = true) { if ($this->hasQuery()) { $url = null; if ($mark === true) { $url = '?'; } $url .= http_build_query(array_merge($this->getQuery(), $data)); $url = str_replace('%25s', '%s', $url); return $url; } else { return null; } }
[ "public", "function", "getWithQuery", "(", "array", "$", "data", ",", "$", "mark", "=", "true", ")", "{", "if", "(", "$", "this", "->", "hasQuery", "(", ")", ")", "{", "$", "url", "=", "null", ";", "if", "(", "$", "mark", "===", "true", ")", "{...
Returns current query with merged data @param array $data Data to be merged with current query @param boolean $mark Whether to prepend question mark @return string
[ "Returns", "current", "query", "with", "merged", "data" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L706-L723
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.hasQuery
public function hasQuery() { if (func_num_args() == 0) { return !empty($this->query); } foreach (func_get_args() as $key) { if (!$this->hasParam($this->query, $key)) { return false; } } return true; }
php
public function hasQuery() { if (func_num_args() == 0) { return !empty($this->query); } foreach (func_get_args() as $key) { if (!$this->hasParam($this->query, $key)) { return false; } } return true; }
[ "public", "function", "hasQuery", "(", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "0", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "query", ")", ";", "}", "foreach", "(", "func_get_args", "(", ")", "as", "$", "key", ")", ...
Checks whether query has a parameter or its empty @param string $key, [...] @return boolean
[ "Checks", "whether", "query", "has", "a", "parameter", "or", "its", "empty" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L731-L744
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.hasPost
public function hasPost() { if (func_num_args() == 0) { return !empty($this->post); } foreach (func_get_args() as $key) { if (!$this->hasParam($this->post, $key)) { return false; } } return true; }
php
public function hasPost() { if (func_num_args() == 0) { return !empty($this->post); } foreach (func_get_args() as $key) { if (!$this->hasParam($this->post, $key)) { return false; } } return true; }
[ "public", "function", "hasPost", "(", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "0", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "post", ")", ";", "}", "foreach", "(", "func_get_args", "(", ")", "as", "$", "key", ")", "{...
Checks whether post parameter exists or the whole array isn't empty @param string $key, [...] @return boolean
[ "Checks", "whether", "post", "parameter", "exists", "or", "the", "whole", "array", "isn", "t", "empty" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L752-L765
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getPost
public function getPost($key = null, $default = false) { if ($key !== null) { if (array_key_exists($key, $this->post)) { return $this->post[$key]; } else { return $default; } } else { return $this->post; } }
php
public function getPost($key = null, $default = false) { if ($key !== null) { if (array_key_exists($key, $this->post)) { return $this->post[$key]; } else { return $default; } } else { return $this->post; } }
[ "public", "function", "getPost", "(", "$", "key", "=", "null", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "key", "!==", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "post", ")", ")", ...
Returns post parameter @param string $key @param mixed $default Default value to be returned on absence @return string|array
[ "Returns", "post", "parameter" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L790-L802
train
krystal-framework/krystal.framework
src/Krystal/Http/Request.php
Request.getQuery
public function getQuery($key = null, $default = false) { if ($key !== null) { if (array_key_exists($key, $this->query)) { return $this->query[$key]; } else { return $default; } } else { return $this->query; } }
php
public function getQuery($key = null, $default = false) { if ($key !== null) { if (array_key_exists($key, $this->query)) { return $this->query[$key]; } else { return $default; } } else { return $this->query; } }
[ "public", "function", "getQuery", "(", "$", "key", "=", "null", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "key", "!==", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "query", ")", ")"...
Returns query parameter @param string $key @param mixed $default Default value to be returned on absence @return string
[ "Returns", "query", "parameter" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Http/Request.php#L811-L822
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/SqlCacheEngine.php
SqlCacheEngine.isOutdated
private function isOutdated($key, $time) { return ($this->getTouchByKey($key) + $this->getKeyTtl($key)) < $time; }
php
private function isOutdated($key, $time) { return ($this->getTouchByKey($key) + $this->getKeyTtl($key)) < $time; }
[ "private", "function", "isOutdated", "(", "$", "key", ",", "$", "time", ")", "{", "return", "(", "$", "this", "->", "getTouchByKey", "(", "$", "key", ")", "+", "$", "this", "->", "getKeyTtl", "(", "$", "key", ")", ")", "<", "$", "time", ";", "}" ...
Check whether key is outdated @param string $key @param integer $time Current timestamp @return boolean
[ "Check", "whether", "key", "is", "outdated" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/SqlCacheEngine.php#L153-L156
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/SqlCacheEngine.php
SqlCacheEngine.set
public function set($key, $value, $ttl) { $this->initializeOnDemand(); if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Argument #1 must be a string and only, received "%s"', gettype($key))); } $time = time(); if ($this->has($key)) { $this->cacheMapper->update($key, $value, $ttl); } else { $this->cacheMapper->insert($key, $value, $ttl, $time); } // For the current request $this->cache[$key] = array( ConstProviderInterface::CACHE_PARAM_VALUE => $value, ConstProviderInterface::CACHE_PARAM_CREATED_ON => $time, ConstProviderInterface::CACHE_PARAM_TTL => $ttl ); return true; }
php
public function set($key, $value, $ttl) { $this->initializeOnDemand(); if (!is_string($key)) { throw new InvalidArgumentException(sprintf('Argument #1 must be a string and only, received "%s"', gettype($key))); } $time = time(); if ($this->has($key)) { $this->cacheMapper->update($key, $value, $ttl); } else { $this->cacheMapper->insert($key, $value, $ttl, $time); } // For the current request $this->cache[$key] = array( ConstProviderInterface::CACHE_PARAM_VALUE => $value, ConstProviderInterface::CACHE_PARAM_CREATED_ON => $time, ConstProviderInterface::CACHE_PARAM_TTL => $ttl ); return true; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", ")", "{", "$", "this", "->", "initializeOnDemand", "(", ")", ";", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException...
Write data to the cache @param string $key @param mixed $value @param integer $ttl The lifetime in seconds @return boolean
[ "Write", "data", "to", "the", "cache" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/SqlCacheEngine.php#L188-L212
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/SqlCacheEngine.php
SqlCacheEngine.getAll
public function getAll() { $this->initializeOnDemand(); $result = array(); foreach ($this->cache as $key => $options) { $result[$key] = $options[ConstProviderInterface::CACHE_PARAM_VALUE]; } return $result; }
php
public function getAll() { $this->initializeOnDemand(); $result = array(); foreach ($this->cache as $key => $options) { $result[$key] = $options[ConstProviderInterface::CACHE_PARAM_VALUE]; } return $result; }
[ "public", "function", "getAll", "(", ")", "{", "$", "this", "->", "initializeOnDemand", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "cache", "as", "$", "key", "=>", "$", "options", ")", "{", "$", ...
Returns cache data @return array
[ "Returns", "cache", "data" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/SqlCacheEngine.php#L219-L229
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/SqlCacheEngine.php
SqlCacheEngine.get
public function get($key, $default = false) { $this->initializeOnDemand(); if ($this->has($key)) { return $this->cache[$key][ConstProviderInterface::CACHE_PARAM_VALUE]; } else { return $default; } }
php
public function get($key, $default = false) { $this->initializeOnDemand(); if ($this->has($key)) { return $this->cache[$key][ConstProviderInterface::CACHE_PARAM_VALUE]; } else { return $default; } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "false", ")", "{", "$", "this", "->", "initializeOnDemand", "(", ")", ";", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", ...
Reads cache item by its key @param string $key @param mixed $default Default value to be returned in $key doesn't exist @return mixed
[ "Reads", "cache", "item", "by", "its", "key" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/SqlCacheEngine.php#L250-L259
train
fxpio/fxp-bootstrap
Block/Extension/ResponsiveExtension.php
ResponsiveExtension.normaliseViewport
protected function normaliseViewport($prefix, array $valid, $value) { $value = $this->convertToArray($value); foreach ($value as $i => $viewport) { if (!\in_array($viewport, $valid)) { throw new InvalidConfigurationException(sprintf('The "%s" %s viewport option does not exist. Known options are: "%s"', $viewport, $prefix, implode('", "', $valid))); } $value[$i] = sprintf('%s-%s', $prefix, $viewport); } return $value; }
php
protected function normaliseViewport($prefix, array $valid, $value) { $value = $this->convertToArray($value); foreach ($value as $i => $viewport) { if (!\in_array($viewport, $valid)) { throw new InvalidConfigurationException(sprintf('The "%s" %s viewport option does not exist. Known options are: "%s"', $viewport, $prefix, implode('", "', $valid))); } $value[$i] = sprintf('%s-%s', $prefix, $viewport); } return $value; }
[ "protected", "function", "normaliseViewport", "(", "$", "prefix", ",", "array", "$", "valid", ",", "$", "value", ")", "{", "$", "value", "=", "$", "this", "->", "convertToArray", "(", "$", "value", ")", ";", "foreach", "(", "$", "value", "as", "$", "...
Normalises the viewport. @param string $prefix @param array $valid @param string|null $value @return array The valid formatted viewport @throws InvalidConfigurationException When viewport value does not exist
[ "Normalises", "the", "viewport", "." ]
4ff1408018c71d18b6951b1f8d7c5ad0b684eadb
https://github.com/fxpio/fxp-bootstrap/blob/4ff1408018c71d18b6951b1f8d7c5ad0b684eadb/Block/Extension/ResponsiveExtension.php#L106-L119
train
Bludata/base
src/Audit/Libs/ElasticsearchAudit.php
ElasticsearchAudit.createIndex
public function createIndex($index = null) { if (!$this->elasticsearch->indices()->exists(['index' => $index['index']])) { return $this->elasticsearch->indices()->create($index); } }
php
public function createIndex($index = null) { if (!$this->elasticsearch->indices()->exists(['index' => $index['index']])) { return $this->elasticsearch->indices()->create($index); } }
[ "public", "function", "createIndex", "(", "$", "index", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "elasticsearch", "->", "indices", "(", ")", "->", "exists", "(", "[", "'index'", "=>", "$", "index", "[", "'index'", "]", "]", ")", ")...
Gerar em uma migration com os templates criados.
[ "Gerar", "em", "uma", "migration", "com", "os", "templates", "criados", "." ]
c6936581a36defa04881d9c8f199aaed319ad1d0
https://github.com/Bludata/base/blob/c6936581a36defa04881d9c8f199aaed319ad1d0/src/Audit/Libs/ElasticsearchAudit.php#L35-L40
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.phpTravisCi
public function phpTravisCi() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupTravisCi(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function phpTravisCi() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupTravisCi(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "phpTravisCi", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "getProjectInstance", "(", ")", "->", "setupTravisCi", "(", ")", ";", "$", "this", "->", "execut...
Setup TravisCi configurations. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Setup", "TravisCi", "configurations", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L28-L36
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.phpBehat
public function phpBehat() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupBehat() ->saveComposer() ->updateComposer() ->initBehat(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function phpBehat() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupBehat() ->saveComposer() ->updateComposer() ->initBehat(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "phpBehat", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "getProjectInstance", "(", ")", "->", "setupBehat", "(", ")", "->", "saveComposer", "(", ")", "->",...
Setup Behat configurations and initialize. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Setup", "Behat", "configurations", "and", "initialize", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L64-L75
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.phpPhpCs
public function phpPhpCs() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupPhpCodeSniffer() ->saveComposer() ->updateComposer(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
php
public function phpPhpCs() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->getProjectInstance() ->setupPhpCodeSniffer() ->saveComposer() ->updateComposer(); $this->executeCommandHook(__FUNCTION__, 'after'); return $this; }
[ "public", "function", "phpPhpCs", "(", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", "'before'", ")", ";", "$", "this", "->", "getProjectInstance", "(", ")", "->", "setupPhpCodeSniffer", "(", ")", "->", "saveComposer", "(", ")"...
Setup PHPcs configurations. @return self @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Setup", "PHPcs", "configurations", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L105-L115
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.phpComposer
public function phpComposer(array $composer_command, $opts = [ 'remote-binary-path' => 'composer', 'remote-working-dir' => '/var/www/html', ]) { /** @var DrupalProjectType $project */ $instance = $this->getProjectInstance(); $engine = ProjectX::getEngineType(); $binary = $opts['remote-binary-path']; $command_str = escapeshellcmd(implode(' ', $composer_command)); $working_dir = escapeshellarg($opts['remote-working-dir']); $command = $this->taskExec("{$binary} --working-dir={$working_dir} {$command_str}"); if ($engine instanceof DockerEngineType) { $container = $instance->getPhpServiceName('php'); $result = $this->taskDockerComposeExecute() ->setContainer($container) ->exec($command) ->run(); } else { $result = $command->run(); } $this->validateTaskResult($result); return $this; }
php
public function phpComposer(array $composer_command, $opts = [ 'remote-binary-path' => 'composer', 'remote-working-dir' => '/var/www/html', ]) { /** @var DrupalProjectType $project */ $instance = $this->getProjectInstance(); $engine = ProjectX::getEngineType(); $binary = $opts['remote-binary-path']; $command_str = escapeshellcmd(implode(' ', $composer_command)); $working_dir = escapeshellarg($opts['remote-working-dir']); $command = $this->taskExec("{$binary} --working-dir={$working_dir} {$command_str}"); if ($engine instanceof DockerEngineType) { $container = $instance->getPhpServiceName('php'); $result = $this->taskDockerComposeExecute() ->setContainer($container) ->exec($command) ->run(); } else { $result = $command->run(); } $this->validateTaskResult($result); return $this; }
[ "public", "function", "phpComposer", "(", "array", "$", "composer_command", ",", "$", "opts", "=", "[", "'remote-binary-path'", "=>", "'composer'", ",", "'remote-working-dir'", "=>", "'/var/www/html'", ",", "]", ")", "{", "/** @var DrupalProjectType $project */", "$",...
Php composer command. @aliases composer @param array $composer_command The composer command to execute. @param array $opts @option string $remote-binary-path The path to the Drush binary. @option string $remote-working-dir The remote Drupal root directory. @return $this @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Php", "composer", "command", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L132-L159
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.phpImportDatabase
public function phpImportDatabase($opts = [ 'service' => null, 'import_path' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var PhpProjectType $instance */ $instance = $this->getProjectInstance(); $service = isset($opts['service']) ? $opts['service'] : $instance->getPhpServiceName(); $instance->importDatabaseToService( $service, $opts['import_path'], true, $opts['localhost'] ); $this->executeCommandHook(__FUNCTION__, 'after'); }
php
public function phpImportDatabase($opts = [ 'service' => null, 'import_path' => null, 'localhost' => false, ]) { $this->executeCommandHook(__FUNCTION__, 'before'); /** @var PhpProjectType $instance */ $instance = $this->getProjectInstance(); $service = isset($opts['service']) ? $opts['service'] : $instance->getPhpServiceName(); $instance->importDatabaseToService( $service, $opts['import_path'], true, $opts['localhost'] ); $this->executeCommandHook(__FUNCTION__, 'after'); }
[ "public", "function", "phpImportDatabase", "(", "$", "opts", "=", "[", "'service'", "=>", "null", ",", "'import_path'", "=>", "null", ",", "'localhost'", "=>", "false", ",", "]", ")", "{", "$", "this", "->", "executeCommandHook", "(", "__FUNCTION__", ",", ...
Import PHP project database. @param array $opts @option string $service The database service name. @option string $import_path The path to the database exported file. @option bool $localhost Run the database import command from localhost. @throws \Exception
[ "Import", "PHP", "project", "database", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L171-L192
train
droath/project-x
src/Project/Task/PHP/PhpTasks.php
PhpTasks.getProjectInstance
protected function getProjectInstance() { $project = ProjectX::getProjectType(); if (!$project instanceof PhpProjectType) { throw new \Exception( 'These tasks can only be ran for PHP based projects.' ); } $project->setBuilder($this->getBuilder()); return $project; }
php
protected function getProjectInstance() { $project = ProjectX::getProjectType(); if (!$project instanceof PhpProjectType) { throw new \Exception( 'These tasks can only be ran for PHP based projects.' ); } $project->setBuilder($this->getBuilder()); return $project; }
[ "protected", "function", "getProjectInstance", "(", ")", "{", "$", "project", "=", "ProjectX", "::", "getProjectType", "(", ")", ";", "if", "(", "!", "$", "project", "instanceof", "PhpProjectType", ")", "{", "throw", "new", "\\", "Exception", "(", "'These ta...
Get the project instance. @return \Droath\ProjectX\Project\ProjectTypeInterface @throws \Exception @throws \Psr\Container\ContainerExceptionInterface @throws \Psr\Container\NotFoundExceptionInterface
[ "Get", "the", "project", "instance", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Project/Task/PHP/PhpTasks.php#L202-L214
train
krystal-framework/krystal.framework
src/Krystal/Db/Sql/LazyPDO.php
LazyPDO.getPdo
private function getPdo() { static $pdo = null; if (is_null($pdo)) { $builder = new InstanceBuilder(); $pdo = $builder->build('PDO', $this->args); } return $pdo; }
php
private function getPdo() { static $pdo = null; if (is_null($pdo)) { $builder = new InstanceBuilder(); $pdo = $builder->build('PDO', $this->args); } return $pdo; }
[ "private", "function", "getPdo", "(", ")", "{", "static", "$", "pdo", "=", "null", ";", "if", "(", "is_null", "(", "$", "pdo", ")", ")", "{", "$", "builder", "=", "new", "InstanceBuilder", "(", ")", ";", "$", "pdo", "=", "$", "builder", "->", "bu...
Lazily returns PDO instance @return \PDO
[ "Lazily", "returns", "PDO", "instance" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/LazyPDO.php#L45-L55
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.startConversation
protected function startConversation(\KeythKatz\TelegramBotCore\Conversation $conversation): void { $conversation->setBot($this->bot); $conversation->setMessage($this->message); $conversation->start(); }
php
protected function startConversation(\KeythKatz\TelegramBotCore\Conversation $conversation): void { $conversation->setBot($this->bot); $conversation->setMessage($this->message); $conversation->start(); }
[ "protected", "function", "startConversation", "(", "\\", "KeythKatz", "\\", "TelegramBotCore", "\\", "Conversation", "$", "conversation", ")", ":", "void", "{", "$", "conversation", "->", "setBot", "(", "$", "this", "->", "bot", ")", ";", "$", "conversation", ...
Start a new Conversation. @param \KeythKatz\TelegramBotCore\Conversation $conversation instance of a conversation.
[ "Start", "a", "new", "Conversation", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L68-L73
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendMessageReply
public function sendMessageReply(bool $quoteOriginal = false): SendMessage { $m = $this->bot->sendMessage(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendMessageReply(bool $quoteOriginal = false): SendMessage { $m = $this->bot->sendMessage(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendMessageReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendMessage", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendMessage", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",...
Create a new blank message sending back to the chat @param boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendMessage new message.
[ "Create", "a", "new", "blank", "message", "sending", "back", "to", "the", "chat" ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L96-L101
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendPhotoReply
public function sendPhotoReply(bool $quoteOriginal = false): SendPhoto { $m = $this->bot->sendPhoto(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendPhotoReply(bool $quoteOriginal = false): SendPhoto { $m = $this->bot->sendPhoto(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendPhotoReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendPhoto", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendPhoto", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "...
Send a photo back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendPhoto New SendPhoto.
[ "Send", "a", "photo", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L117-L122
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendAudioReply
public function sendAudioReply(bool $quoteOriginal = false): SendAudio { $m = $this->bot->sendAudio(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendAudioReply(bool $quoteOriginal = false): SendAudio { $m = $this->bot->sendAudio(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendAudioReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendAudio", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendAudio", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "...
Send a audio file back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendAudio New SendAudio.
[ "Send", "a", "audio", "file", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L138-L143
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendDocumentReply
public function sendDocumentReply(bool $quoteOriginal = false): SendDocument { $m = $this->bot->sendDocument(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendDocumentReply(bool $quoteOriginal = false): SendDocument { $m = $this->bot->sendDocument(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendDocumentReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendDocument", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendDocument", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ...
Send a document back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendDocument New SendDocument.
[ "Send", "a", "document", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L159-L164
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendVideoReply
public function sendVideoReply(bool $quoteOriginal = false): SendVideo { $m = $this->bot->sendVideo(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendVideoReply(bool $quoteOriginal = false): SendVideo { $m = $this->bot->sendVideo(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendVideoReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendVideo", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendVideo", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "...
Send a video back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendVideo New SendVideo.
[ "Send", "a", "video", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L180-L185
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendVoiceReply
public function sendVoiceReply(bool $quoteOriginal = false): SendVoice { $m = $this->bot->sendVoice(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendVoiceReply(bool $quoteOriginal = false): SendVoice { $m = $this->bot->sendVoice(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendVoiceReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendVoice", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendVoice", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "...
Send a voice message back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendVoice New SendVoice.
[ "Send", "a", "voice", "message", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L201-L206
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendVideoNoteReply
public function sendVideoNoteReply(bool $quoteOriginal = false): SendVideoNote { $m = $this->bot->sendVideoNote(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendVideoNoteReply(bool $quoteOriginal = false): SendVideoNote { $m = $this->bot->sendVideoNote(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendVideoNoteReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendVideoNote", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendVideoNote", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m"...
Send a video note back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendVideoNote New SendVideoNote.
[ "Send", "a", "video", "note", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L222-L227
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendMediaGroupReply
public function sendMediaGroupReply(bool $quoteOriginal = false): SendMediaGroup { $m = $this->bot->sendMediaGroup(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendMediaGroupReply(bool $quoteOriginal = false): SendMediaGroup { $m = $this->bot->sendMediaGroup(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendMediaGroupReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendMediaGroup", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendMediaGroup", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", ...
Send a media group back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendMediaGroup New SendMediaGroup.
[ "Send", "a", "media", "group", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L243-L248
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendLocationReply
public function sendLocationReply(bool $quoteOriginal = false): SendLocation { $m = $this->bot->sendLocation(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendLocationReply(bool $quoteOriginal = false): SendLocation { $m = $this->bot->sendLocation(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendLocationReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendLocation", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendLocation", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ...
Send a location back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendLocation New SendLocation.
[ "Send", "a", "location", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L264-L269
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.editMessageLiveLocationReply
public function editMessageLiveLocationReply(): EditMessageLiveLocation { $m = $this->bot->editMessageLiveLocation(); $this->setReplyMarkup($m, false); return $m; }
php
public function editMessageLiveLocationReply(): EditMessageLiveLocation { $m = $this->bot->editMessageLiveLocation(); $this->setReplyMarkup($m, false); return $m; }
[ "public", "function", "editMessageLiveLocationReply", "(", ")", ":", "EditMessageLiveLocation", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "editMessageLiveLocation", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "false", ")...
Edit a location in the chat. @return EditMessageLiveLocation New EditMessageLiveLocation.
[ "Edit", "a", "location", "in", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L284-L289
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.stopMessageLiveLocationReply
public function stopMessageLiveLocationReply(): StopMessageLiveLocation { $m = $this->bot->stopMessageLiveLocation(); $this->setReplyMarkup($m, false); return $m; }
php
public function stopMessageLiveLocationReply(): StopMessageLiveLocation { $m = $this->bot->stopMessageLiveLocation(); $this->setReplyMarkup($m, false); return $m; }
[ "public", "function", "stopMessageLiveLocationReply", "(", ")", ":", "StopMessageLiveLocation", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "stopMessageLiveLocation", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "false", ")...
Stop a live location in the chat. @return StopMessageLiveLocation New StopMessageLiveLocation.
[ "Stop", "a", "live", "location", "in", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L304-L309
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendVenueReply
public function sendVenueReply(bool $quoteOriginal = false): SendVenue { $m = $this->bot->sendVenue(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendVenueReply(bool $quoteOriginal = false): SendVenue { $m = $this->bot->sendVenue(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendVenueReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendVenue", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendVenue", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "...
Send a venue back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendVenue New SendVenue.
[ "Send", "a", "venue", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L325-L330
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendContactReply
public function sendContactReply(bool $quoteOriginal = false): SendContact { $m = $this->bot->sendContact(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
php
public function sendContactReply(bool $quoteOriginal = false): SendContact { $m = $this->bot->sendContact(); $this->setReplyMarkup($m, $quoteOriginal); return $m; }
[ "public", "function", "sendContactReply", "(", "bool", "$", "quoteOriginal", "=", "false", ")", ":", "SendContact", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendContact", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",...
Send a contact back to the chat. @param bool|boolean $quoteOriginal If the original message should be quoted when replying. False by default. @return SendContact New SendContact.
[ "Send", "a", "contact", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L346-L351
train
jer-lim/Telegram-Bot-Core
src/BaseHandler.php
BaseHandler.sendChatActionReply
public function sendChatActionReply(): SendChatAction { $m = $this->bot->sendChatAction(); $this->setReplyMarkup($m, false); return $m; }
php
public function sendChatActionReply(): SendChatAction { $m = $this->bot->sendChatAction(); $this->setReplyMarkup($m, false); return $m; }
[ "public", "function", "sendChatActionReply", "(", ")", ":", "SendChatAction", "{", "$", "m", "=", "$", "this", "->", "bot", "->", "sendChatAction", "(", ")", ";", "$", "this", "->", "setReplyMarkup", "(", "$", "m", ",", "false", ")", ";", "return", "$"...
Send a chat action back to the chat. @return SendChatAction New SendChatAction.
[ "Send", "a", "chat", "action", "back", "to", "the", "chat", "." ]
49a184aef0922d1b70ade91204738fe40a1ea5ae
https://github.com/jer-lim/Telegram-Bot-Core/blob/49a184aef0922d1b70ade91204738fe40a1ea5ae/src/BaseHandler.php#L366-L371
train
droath/project-x
src/TaskSubType.php
TaskSubType.copyTemplateFilesToProject
protected function copyTemplateFilesToProject(array $filenames, $overwrite = false) { try { $filesystem = $this->taskFilesystemStack(); foreach ($filenames as $template_path => $target_path) { $target_file = ProjectX::projectRoot() . "/{$target_path}"; $template_file = $this ->templateManager() ->getTemplateFilePath($template_path); $filesystem->copy($template_file, $target_file, $overwrite); } $filesystem->run(); } catch (\Exception $e) { throw new \Exception( sprintf('Failed to copy template file(s) into project!') ); } return $this; }
php
protected function copyTemplateFilesToProject(array $filenames, $overwrite = false) { try { $filesystem = $this->taskFilesystemStack(); foreach ($filenames as $template_path => $target_path) { $target_file = ProjectX::projectRoot() . "/{$target_path}"; $template_file = $this ->templateManager() ->getTemplateFilePath($template_path); $filesystem->copy($template_file, $target_file, $overwrite); } $filesystem->run(); } catch (\Exception $e) { throw new \Exception( sprintf('Failed to copy template file(s) into project!') ); } return $this; }
[ "protected", "function", "copyTemplateFilesToProject", "(", "array", "$", "filenames", ",", "$", "overwrite", "=", "false", ")", "{", "try", "{", "$", "filesystem", "=", "$", "this", "->", "taskFilesystemStack", "(", ")", ";", "foreach", "(", "$", "filenames...
Copy template files to project root. @param array $filenames An array of template filenames, keyed by target path. @param bool $overwrite A flag to determine if the file should be overwritten if exists. @return self @throws \Exception
[ "Copy", "template", "files", "to", "project", "root", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/TaskSubType.php#L130-L151
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayDropdown
public static function arrayDropdown(array $raw, $partition, $key, $value) { $output = array(); foreach (self::arrayPartition($raw, $partition) as $target => $data) { foreach ($data as $innerKey => $innerValue) { if (isset($innerValue[$key], $innerValue[$value])) { $output[$target][$innerValue[$key]] = $innerValue[$value]; } } } return $output; }
php
public static function arrayDropdown(array $raw, $partition, $key, $value) { $output = array(); foreach (self::arrayPartition($raw, $partition) as $target => $data) { foreach ($data as $innerKey => $innerValue) { if (isset($innerValue[$key], $innerValue[$value])) { $output[$target][$innerValue[$key]] = $innerValue[$value]; } } } return $output; }
[ "public", "static", "function", "arrayDropdown", "(", "array", "$", "raw", ",", "$", "partition", ",", "$", "key", ",", "$", "value", ")", "{", "$", "output", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "arrayPartition", "(", "$", "raw...
Drops a raw result-set into partitions and creates inner array with key => value pairs @param array $raw @param string $partition The key to be considered as partition @param string $key @param string $value @return array
[ "Drops", "a", "raw", "result", "-", "set", "into", "partitions", "and", "creates", "inner", "array", "with", "key", "=", ">", "value", "pairs" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L61-L74
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayPartition
public static function arrayPartition(array $raw, $key, $keepKey = true) { $result = array(); foreach ($raw as $index => $collection) { // Make the the root partition exists if (!isset($collection[$key])) { throw new LogicException(sprintf( 'The key "%s" does not exist in provided collection', $key )); } // Extract module' name as a key and put the rest into its values $target = array($collection[$key] => $collection); foreach ($target as $module => $array) { // When doesn't exist, then need to create a one if (!isset($result[$module])) { $result[$module] = array(); } if ($keepKey == false) { unset($array[$key]); } $result[$module][] = $array; } } return $result; }
php
public static function arrayPartition(array $raw, $key, $keepKey = true) { $result = array(); foreach ($raw as $index => $collection) { // Make the the root partition exists if (!isset($collection[$key])) { throw new LogicException(sprintf( 'The key "%s" does not exist in provided collection', $key )); } // Extract module' name as a key and put the rest into its values $target = array($collection[$key] => $collection); foreach ($target as $module => $array) { // When doesn't exist, then need to create a one if (!isset($result[$module])) { $result[$module] = array(); } if ($keepKey == false) { unset($array[$key]); } $result[$module][] = $array; } } return $result; }
[ "public", "static", "function", "arrayPartition", "(", "array", "$", "raw", ",", "$", "key", ",", "$", "keepKey", "=", "true", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "raw", "as", "$", "index", "=>", "$", "collect...
Drops an array into partitions @param array $raw Raw array @param string $key The key to be considered as partition @param boolean $keepKey Whether to keep key in output @throws \LogicException if unknown partition key supplied @return array Dropped array
[ "Drops", "an", "array", "into", "partitions" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L85-L116
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayRecovery
public static function arrayRecovery(array $array, array $keys, $value) { foreach ($keys as $key) { if (!isset($array[$key])) { $array[$key] = $value; } } return $array; }
php
public static function arrayRecovery(array $array, array $keys, $value) { foreach ($keys as $key) { if (!isset($array[$key])) { $array[$key] = $value; } } return $array; }
[ "public", "static", "function", "arrayRecovery", "(", "array", "$", "array", ",", "array", "$", "keys", ",", "$", "value", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "array", "[", "$", "k...
Recoveries missing array keys @param array $array Target array @param array $keys Missing array keys to be recovered @param mixed $value Value to be recovered @return array
[ "Recoveries", "missing", "array", "keys" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L126-L135
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.valuefy
public static function valuefy(array $data, $valueModue = true) { if ($valueModue === true) { $values = array_values($data); } else { $values = array_keys($data); } return array_combine($values, $values); }
php
public static function valuefy(array $data, $valueModue = true) { if ($valueModue === true) { $values = array_values($data); } else { $values = array_keys($data); } return array_combine($values, $values); }
[ "public", "static", "function", "valuefy", "(", "array", "$", "data", ",", "$", "valueModue", "=", "true", ")", "{", "if", "(", "$", "valueModue", "===", "true", ")", "{", "$", "values", "=", "array_values", "(", "$", "data", ")", ";", "}", "else", ...
Duplicate array values into keys @param array $data @param boolean $valueModue Whether to duplicate values, not keys @return array
[ "Duplicate", "array", "values", "into", "keys" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L144-L153
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.sumColumnsWithAverages
public static function sumColumnsWithAverages(array $entities, array $averages = array(), $precision = 2) { // Count the sum of all columns $sum = self::sumColumns($entities); if (!empty($averages)) { $count = count($entities); // Make sure that the division by zero won't occur if ($count === 0) { $count = 1; } foreach ($averages as $average) { if (isset($sum[$average])) { if ($precision !== false) { } else { $sum[$average] = $sum[$average] / $count; } } } } return $sum; }
php
public static function sumColumnsWithAverages(array $entities, array $averages = array(), $precision = 2) { // Count the sum of all columns $sum = self::sumColumns($entities); if (!empty($averages)) { $count = count($entities); // Make sure that the division by zero won't occur if ($count === 0) { $count = 1; } foreach ($averages as $average) { if (isset($sum[$average])) { if ($precision !== false) { } else { $sum[$average] = $sum[$average] / $count; } } } } return $sum; }
[ "public", "static", "function", "sumColumnsWithAverages", "(", "array", "$", "entities", ",", "array", "$", "averages", "=", "array", "(", ")", ",", "$", "precision", "=", "2", ")", "{", "// Count the sum of all columns", "$", "sum", "=", "self", "::", "sumC...
Sum columns with averages @param array $entities A collection of data @param array $averages Columns that need to be counted as average ones @param integer $precision The number of decimal digits to round to @return array
[ "Sum", "columns", "with", "averages" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L163-L188
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.roundValues
public static function roundValues(array $data, $precision = 2) { return self::filterValuesRecursively($data, function($value) use ($precision) { $value = is_numeric($value) ? round($value, $precision) : $value; $value = empty($value) ? 0 : $value; return $value; }); }
php
public static function roundValues(array $data, $precision = 2) { return self::filterValuesRecursively($data, function($value) use ($precision) { $value = is_numeric($value) ? round($value, $precision) : $value; $value = empty($value) ? 0 : $value; return $value; }); }
[ "public", "static", "function", "roundValues", "(", "array", "$", "data", ",", "$", "precision", "=", "2", ")", "{", "return", "self", "::", "filterValuesRecursively", "(", "$", "data", ",", "function", "(", "$", "value", ")", "use", "(", "$", "precision...
Round array values recursively @param array $data Target array @param integer $precision The number of decimal digits to round to @return array
[ "Round", "array", "values", "recursively" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L197-L205
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayColumns
public static function arrayColumns(array $data) { // Count the amount of values from the source input $count = count($data); if ($count === 0) { return false; } if ($count === 1) { return array_keys($data[0]); } if (isset($data[0])) { return array_keys($data[0]); } else { return false; } }
php
public static function arrayColumns(array $data) { // Count the amount of values from the source input $count = count($data); if ($count === 0) { return false; } if ($count === 1) { return array_keys($data[0]); } if (isset($data[0])) { return array_keys($data[0]); } else { return false; } }
[ "public", "static", "function", "arrayColumns", "(", "array", "$", "data", ")", "{", "// Count the amount of values from the source input", "$", "count", "=", "count", "(", "$", "data", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "return", "fals...
Returns all column names from two dimensional array validating by count @param array $data @return array|boolean
[ "Returns", "all", "column", "names", "from", "two", "dimensional", "array", "validating", "by", "count" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L213-L231
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.sumColumns
public static function sumColumns(array $data) { $columns = self::arrayColumns($data); if ($columns !== false){ return self::columnSum($data, $columns); } else { return false; } }
php
public static function sumColumns(array $data) { $columns = self::arrayColumns($data); if ($columns !== false){ return self::columnSum($data, $columns); } else { return false; } }
[ "public", "static", "function", "sumColumns", "(", "array", "$", "data", ")", "{", "$", "columns", "=", "self", "::", "arrayColumns", "(", "$", "data", ")", ";", "if", "(", "$", "columns", "!==", "false", ")", "{", "return", "self", "::", "columnSum", ...
Counts a total sum of each collection @param array $data @return array
[ "Counts", "a", "total", "sum", "of", "each", "collection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L239-L248
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.columnSum
public static function columnSum(array $data, array $columns) { $result = array(); foreach ($columns as $column) { foreach ($data as $collection) { if (isset($collection[$column])) { if (isset($result[$column])) { $result[$column] += $collection[$column]; } else { $result[$column] = $collection[$column]; } } } } return $result; }
php
public static function columnSum(array $data, array $columns) { $result = array(); foreach ($columns as $column) { foreach ($data as $collection) { if (isset($collection[$column])) { if (isset($result[$column])) { $result[$column] += $collection[$column]; } else { $result[$column] = $collection[$column]; } } } } return $result; }
[ "public", "static", "function", "columnSum", "(", "array", "$", "data", ",", "array", "$", "columns", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "foreach", "(", "$", "data", ...
Counts column sum @param array $data @param array $columns @return array
[ "Counts", "column", "sum" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L257-L274
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.filterValuesRecursively
public static function filterValuesRecursively(array $array, Closure $callback = null) { foreach ($array as $index => $value) { if (is_array($value)) { $array[$index] = call_user_func(__METHOD__, $value, $callback); } else { $array[$index] = call_user_func($callback, $value); } } return $array; }
php
public static function filterValuesRecursively(array $array, Closure $callback = null) { foreach ($array as $index => $value) { if (is_array($value)) { $array[$index] = call_user_func(__METHOD__, $value, $callback); } else { $array[$index] = call_user_func($callback, $value); } } return $array; }
[ "public", "static", "function", "filterValuesRecursively", "(", "array", "$", "array", ",", "Closure", "$", "callback", "=", "null", ")", "{", "foreach", "(", "$", "array", "as", "$", "index", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "...
Filter array values applying a callback function that returns a value @param mixed $array @param \Closure A callback function that returns a filtered value @return mixed
[ "Filter", "array", "values", "applying", "a", "callback", "function", "that", "returns", "a", "value" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L283-L294
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.filterArray
public static function filterArray(array $array, Closure $callback) { foreach ($array as $index => $collection) { $array[$index] = call_user_func($callback, $collection); } return $array; }
php
public static function filterArray(array $array, Closure $callback) { foreach ($array as $index => $collection) { $array[$index] = call_user_func($callback, $collection); } return $array; }
[ "public", "static", "function", "filterArray", "(", "array", "$", "array", ",", "Closure", "$", "callback", ")", "{", "foreach", "(", "$", "array", "as", "$", "index", "=>", "$", "collection", ")", "{", "$", "array", "[", "$", "index", "]", "=", "cal...
Filters an array applying a callback function @param array $array Target array @param \Closure A callback function that returns a filtered array @return array
[ "Filters", "an", "array", "applying", "a", "callback", "function" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L303-L310
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.mergeWithout
public static function mergeWithout(array $first, array $second, array $keys) { $result = array_merge($first, $second); return self::arrayWithout($result, $keys); }
php
public static function mergeWithout(array $first, array $second, array $keys) { $result = array_merge($first, $second); return self::arrayWithout($result, $keys); }
[ "public", "static", "function", "mergeWithout", "(", "array", "$", "first", ",", "array", "$", "second", ",", "array", "$", "keys", ")", "{", "$", "result", "=", "array_merge", "(", "$", "first", ",", "$", "second", ")", ";", "return", "self", "::", ...
Merges two arrays removing keys @param array $first @param array $second @param array $keys Keys to be removed after merging @return array
[ "Merges", "two", "arrays", "removing", "keys" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L320-L324
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.keysExist
public static function keysExist(array $collection, array $keys) { $collection = array_flip($collection); foreach ($keys as $key) { if (!in_array($key, $collection)) { return false; } } return true; }
php
public static function keysExist(array $collection, array $keys) { $collection = array_flip($collection); foreach ($keys as $key) { if (!in_array($key, $collection)) { return false; } } return true; }
[ "public", "static", "function", "keysExist", "(", "array", "$", "collection", ",", "array", "$", "keys", ")", "{", "$", "collection", "=", "array_flip", "(", "$", "collection", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", ...
Determines whether all keys exist in a collection @param array $collection @param array $keys Keys to be checked for existence @return boolean
[ "Determines", "whether", "all", "keys", "exist", "in", "a", "collection" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L333-L344
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayOnlyWith
public static function arrayOnlyWith(array $array, array $keys) { $result = array(); if (!self::isSequential($array)) { foreach ($array as $key => $value) { if (in_array($key, $keys)) { $result[$key] = $value; } } } else { foreach ($array as $value) { if (in_array($value, $keys)) { $result[] = $value; } } } return $result; }
php
public static function arrayOnlyWith(array $array, array $keys) { $result = array(); if (!self::isSequential($array)) { foreach ($array as $key => $value) { if (in_array($key, $keys)) { $result[$key] = $value; } } } else { foreach ($array as $value) { if (in_array($value, $keys)) { $result[] = $value; } } } return $result; }
[ "public", "static", "function", "arrayOnlyWith", "(", "array", "$", "array", ",", "array", "$", "keys", ")", "{", "$", "result", "=", "array", "(", ")", ";", "if", "(", "!", "self", "::", "isSequential", "(", "$", "array", ")", ")", "{", "foreach", ...
Filters an array by matching keys only @param array $array Target array @param array $keys Filtering keys @return array
[ "Filters", "an", "array", "by", "matching", "keys", "only" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L353-L372
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayCombine
public static function arrayCombine(array $first, array $second, $replacement = null, $order = true) { // Fix for different length if (count($first) !== count($second)) { $input = array($first, $second); $count = array_map('count', $input); // Find the largest and lowest array index $min = array_keys($count , max($count)); $max = array_keys($count , min($count)); // Find indexes $min = $min[0]; $max = $max[0]; $largest = $input[$min]; $smallest = $input[$max]; // Now fix the length foreach ($largest as $key => $value) { if (!isset($smallest[$key])) { $smallest[$key] = $replacement; } } $first = $smallest; $second = $largest; } if ($order === true) { return array_combine($second, $first); } else { return array_combine($first, $second); } }
php
public static function arrayCombine(array $first, array $second, $replacement = null, $order = true) { // Fix for different length if (count($first) !== count($second)) { $input = array($first, $second); $count = array_map('count', $input); // Find the largest and lowest array index $min = array_keys($count , max($count)); $max = array_keys($count , min($count)); // Find indexes $min = $min[0]; $max = $max[0]; $largest = $input[$min]; $smallest = $input[$max]; // Now fix the length foreach ($largest as $key => $value) { if (!isset($smallest[$key])) { $smallest[$key] = $replacement; } } $first = $smallest; $second = $largest; } if ($order === true) { return array_combine($second, $first); } else { return array_combine($first, $second); } }
[ "public", "static", "function", "arrayCombine", "(", "array", "$", "first", ",", "array", "$", "second", ",", "$", "replacement", "=", "null", ",", "$", "order", "=", "true", ")", "{", "// Fix for different length", "if", "(", "count", "(", "$", "first", ...
Combines two arrays even with different length @param array $first @param array $second @param string $replacement Replacement for @param boolean $order Whether to merge first with second or vice versa @return array
[ "Combines", "two", "arrays", "even", "with", "different", "length" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L383-L417
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayList
public static function arrayList(array $array, $key, $value) { $result = array(); foreach ($array as $row) { if (array_key_exists($key, $row) && array_key_exists($value, $row)) { // References $name =& $row[$key]; $text =& $row[$value]; $result[$name] = $text; } else { trigger_error(sprintf('Nested arrays must contain both %s and %s', $key, $value)); } } return $result; }
php
public static function arrayList(array $array, $key, $value) { $result = array(); foreach ($array as $row) { if (array_key_exists($key, $row) && array_key_exists($value, $row)) { // References $name =& $row[$key]; $text =& $row[$value]; $result[$name] = $text; } else { trigger_error(sprintf('Nested arrays must contain both %s and %s', $key, $value)); } } return $result; }
[ "public", "static", "function", "arrayList", "(", "array", "$", "array", ",", "$", "key", ",", "$", "value", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "row", ")", "{", "if", "(", "array_key_exist...
Turns array's row into a list @param array $array Target array @param string $key Column's name to be used as a key @param string $value Column's name to be used as a value @return array
[ "Turns", "array", "s", "row", "into", "a", "list" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L442-L460
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayWithout
public static function arrayWithout(array $array, array $keys) { // Shared filter function $filter = function(array $array, array $keys) { foreach ($keys as $key) { if (array_key_exists($key, $array)) { unset($array[$key]); } } return $array; }; if (self::hasAllArrayValues($array)) { // Apply on nested arrays as well return self::filterArray($array, function($collection) use ($keys, $filter){ return $filter($collection, $keys); }); } else { return $filter($array, $keys); } }
php
public static function arrayWithout(array $array, array $keys) { // Shared filter function $filter = function(array $array, array $keys) { foreach ($keys as $key) { if (array_key_exists($key, $array)) { unset($array[$key]); } } return $array; }; if (self::hasAllArrayValues($array)) { // Apply on nested arrays as well return self::filterArray($array, function($collection) use ($keys, $filter){ return $filter($collection, $keys); }); } else { return $filter($array, $keys); } }
[ "public", "static", "function", "arrayWithout", "(", "array", "$", "array", ",", "array", "$", "keys", ")", "{", "// Shared filter function", "$", "filter", "=", "function", "(", "array", "$", "array", ",", "array", "$", "keys", ")", "{", "foreach", "(", ...
Returns a copy of an array without keys. Handles two dimensional arrays as well @param array $array Target array @param array $keys Keys to be removed @return array
[ "Returns", "a", "copy", "of", "an", "array", "without", "keys", ".", "Handles", "two", "dimensional", "arrays", "as", "well" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L469-L490
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.search
public static function search(array $haystack, $needle) { foreach ($haystack as $key => $value) { if (is_array($value)) { $target = self::search($value, $needle); } else { $target = ''; } if ($needle === $value || ($target != false && $target != null)) { if ($target == null) { return array($key); } return array_merge(array($key), $target); } } return false; }
php
public static function search(array $haystack, $needle) { foreach ($haystack as $key => $value) { if (is_array($value)) { $target = self::search($value, $needle); } else { $target = ''; } if ($needle === $value || ($target != false && $target != null)) { if ($target == null) { return array($key); } return array_merge(array($key), $target); } } return false; }
[ "public", "static", "function", "search", "(", "array", "$", "haystack", ",", "$", "needle", ")", "{", "foreach", "(", "$", "haystack", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", ...
Search data by given value inside array recursively @param array $haystack @param string $needle @return array|boolean
[ "Search", "data", "by", "given", "value", "inside", "array", "recursively" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L499-L517
train
krystal-framework/krystal.framework
src/Krystal/Stdlib/ArrayUtils.php
ArrayUtils.arrayUnique
public static function arrayUnique(array $array) { // Serialize each array's value foreach ($array as &$value) { $value = serialize($value); } // Now remove duplicate strings $array = array_unique($array); // Now restore to its previous state with removed strings foreach ($array as &$value) { $value = unserialize($value); } return $array; }
php
public static function arrayUnique(array $array) { // Serialize each array's value foreach ($array as &$value) { $value = serialize($value); } // Now remove duplicate strings $array = array_unique($array); // Now restore to its previous state with removed strings foreach ($array as &$value) { $value = unserialize($value); } return $array; }
[ "public", "static", "function", "arrayUnique", "(", "array", "$", "array", ")", "{", "// Serialize each array's value", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "$", "value", "=", "serialize", "(", "$", "value", ")", ";", "}", "//...
Array unique for multi-dimensional arrays @param array $array @return array
[ "Array", "unique", "for", "multi", "-", "dimensional", "arrays" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Stdlib/ArrayUtils.php#L525-L541
train
spiral/odm
source/Spiral/ODM/Entities/DocumentSelector.php
DocumentSelector.orderBy
public function orderBy(string $field, int $direction = self::ASCENDING): DocumentSelector { return $this->sortBy($this->sortBy + [$field => $direction]); }
php
public function orderBy(string $field, int $direction = self::ASCENDING): DocumentSelector { return $this->sortBy($this->sortBy + [$field => $direction]); }
[ "public", "function", "orderBy", "(", "string", "$", "field", ",", "int", "$", "direction", "=", "self", "::", "ASCENDING", ")", ":", "DocumentSelector", "{", "return", "$", "this", "->", "sortBy", "(", "$", "this", "->", "sortBy", "+", "[", "$", "fiel...
Alias for sortBy. @param string $field @param int $direction @return self|$this
[ "Alias", "for", "sortBy", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Entities/DocumentSelector.php#L185-L188
train
spiral/odm
source/Spiral/ODM/Entities/DocumentSelector.php
DocumentSelector.findOne
public function findOne(array $query = [], bool $normalizeDates = true) { if ($normalizeDates) { $query = $this->normalizeDates($query); } //Working with projection (required to properly sort results) $result = $this->collection->findOne( array_merge($this->query, $query), $this->createOptions() ); if (empty($result)) { return null; } return $this->odm->make($this->class, $result, false); }
php
public function findOne(array $query = [], bool $normalizeDates = true) { if ($normalizeDates) { $query = $this->normalizeDates($query); } //Working with projection (required to properly sort results) $result = $this->collection->findOne( array_merge($this->query, $query), $this->createOptions() ); if (empty($result)) { return null; } return $this->odm->make($this->class, $result, false); }
[ "public", "function", "findOne", "(", "array", "$", "query", "=", "[", "]", ",", "bool", "$", "normalizeDates", "=", "true", ")", "{", "if", "(", "$", "normalizeDates", ")", "{", "$", "query", "=", "$", "this", "->", "normalizeDates", "(", "$", "quer...
Select one document or it's fields from collection. Attention, MongoDB is strictly typed! @param array $query Fields and conditions to query by. Query will not be added to an existed query array. @param bool $normalizeDates When true (default) all DateTime objects will be converted into MongoDate. @return CompositableInterface|null
[ "Select", "one", "document", "or", "it", "s", "fields", "from", "collection", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Entities/DocumentSelector.php#L202-L219
train
spiral/odm
source/Spiral/ODM/Entities/DocumentSelector.php
DocumentSelector.count
public function count(array $query = []): int { //Create options? return $this->collection->count( array_merge($this->query, $query), ['skip' => $this->offset, 'limit' => $this->limit] ); }
php
public function count(array $query = []): int { //Create options? return $this->collection->count( array_merge($this->query, $query), ['skip' => $this->offset, 'limit' => $this->limit] ); }
[ "public", "function", "count", "(", "array", "$", "query", "=", "[", "]", ")", ":", "int", "{", "//Create options?", "return", "$", "this", "->", "collection", "->", "count", "(", "array_merge", "(", "$", "this", "->", "query", ",", "$", "query", ")", ...
Count collection. Attention, this method depends on current values set for limit and offset! Attention, MongoDB is strictly typed! @param array $query @return int
[ "Count", "collection", ".", "Attention", "this", "method", "depends", "on", "current", "values", "set", "for", "limit", "and", "offset!" ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Entities/DocumentSelector.php#L230-L237
train
spiral/odm
source/Spiral/ODM/Entities/DocumentSelector.php
DocumentSelector.normalizeDates
protected function normalizeDates(array $query): array { array_walk_recursive($query, function (&$value) { if ($value instanceof \DateTime) { //MongoDate is always UTC, which is good :) $value = new UTCDateTime($value); } }); return $query; }
php
protected function normalizeDates(array $query): array { array_walk_recursive($query, function (&$value) { if ($value instanceof \DateTime) { //MongoDate is always UTC, which is good :) $value = new UTCDateTime($value); } }); return $query; }
[ "protected", "function", "normalizeDates", "(", "array", "$", "query", ")", ":", "array", "{", "array_walk_recursive", "(", "$", "query", ",", "function", "(", "&", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{"...
Converts DateTime objects into MongoDatetime. @param array $query @return array
[ "Converts", "DateTime", "objects", "into", "MongoDatetime", "." ]
06087691a05dcfaa86c6c461660c6029db4de06e
https://github.com/spiral/odm/blob/06087691a05dcfaa86c6c461660c6029db4de06e/source/Spiral/ODM/Entities/DocumentSelector.php#L361-L371
train
Capgemini/drupal-doctrine-cache
src/DrupalCacheAdapter.php
DrupalCacheAdapter.cache_set
public function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) { return cache_set($cid, $data, $bin, $expire); }
php
public function cache_set($cid, $data, $bin = 'cache', $expire = CACHE_PERMANENT) { return cache_set($cid, $data, $bin, $expire); }
[ "public", "function", "cache_set", "(", "$", "cid", ",", "$", "data", ",", "$", "bin", "=", "'cache'", ",", "$", "expire", "=", "CACHE_PERMANENT", ")", "{", "return", "cache_set", "(", "$", "cid", ",", "$", "data", ",", "$", "bin", ",", "$", "expir...
Stores data in the persistent cache. The persistent cache is split up into several cache bins. In the default cache implementation, each cache bin corresponds to a database table by the same name. Other implementations might want to store several bins in data structures that get flushed together. While it is not a problem for most cache bins if the entries in them are flushed before their expire time, some might break functionality or are extremely expensive to recalculate. The other bins are expired automatically by core. Contributed modules can add additional bins and get them expired automatically by implementing hook_flush_caches(). The reasons for having several bins are as follows: - Smaller bins mean smaller database tables and allow for faster selects and inserts. - We try to put fast changing cache items and rather static ones into different bins. The effect is that only the fast changing bins will need a lot of writes to disk. The more static bins will also be better cacheable with MySQL's query cache. @param $cid The cache ID of the data to store. @param $data The data to store in the cache. Complex data types will be automatically serialized before insertion. Strings will be stored as plain text and are not serialized. Some storage engines only allow objects up to a maximum of 1MB in size to be stored by default. When caching large arrays or similar, take care to ensure $data does not exceed this size. @param $bin (optional) The cache bin to store the data in. Valid core values are: - cache: (default) Generic cache storage bin (used for theme registry, locale date, list of simpletest tests, etc.). - cache_block: Stores the content of various blocks. - cache_bootstrap: Stores the class registry, the system list of modules, the list of which modules implement which hooks, and the Drupal variable list. - cache_field: Stores the field data belonging to a given object. - cache_filter: Stores filtered pieces of content. - cache_form: Stores multistep forms. Flushing this bin means that some forms displayed to users lose their state and the data already submitted to them. This bin should not be flushed before its expired time. - cache_menu: Stores the structure of visible navigation menus per page. - cache_page: Stores generated pages for anonymous users. It is flushed very often, whenever a page changes, at least for every node and comment submission. This is the only bin affected by the page cache setting on the administrator panel. - cache_path: Stores the system paths that have an alias. @param $expire (optional) One of the following values: - CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID. - CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe. - A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY. @see _update_cache_set() @see cache_get()
[ "Stores", "data", "in", "the", "persistent", "cache", "." ]
4c046be34f0fd96c254d7d0db897183ce8eb2deb
https://github.com/Capgemini/drupal-doctrine-cache/blob/4c046be34f0fd96c254d7d0db897183ce8eb2deb/src/DrupalCacheAdapter.php#L105-L107
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.getService
public function getService() { if (!isset($this->service)) { $info = $this->getInfo(); $this->service = $this->service(); // Apply the overridden property values. foreach (static::PROPERTIES_OVERRIDE as $property) { if (!isset($info[$property]) || empty($info[$property])) { continue; } $method = 'set' . ucwords($property); if (is_callable([$this->service, $method])) { call_user_func_array([$this->service, $method], [$info[$property]]); } } } return $this->service; }
php
public function getService() { if (!isset($this->service)) { $info = $this->getInfo(); $this->service = $this->service(); // Apply the overridden property values. foreach (static::PROPERTIES_OVERRIDE as $property) { if (!isset($info[$property]) || empty($info[$property])) { continue; } $method = 'set' . ucwords($property); if (is_callable([$this->service, $method])) { call_user_func_array([$this->service, $method], [$info[$property]]); } } } return $this->service; }
[ "public", "function", "getService", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "service", ")", ")", "{", "$", "info", "=", "$", "this", "->", "getInfo", "(", ")", ";", "$", "this", "->", "service", "=", "$", "this", "->", "...
Get complete service object. @return \Droath\ProjectX\Engine\DockerService A fully defined service object.
[ "Get", "complete", "service", "object", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L242-L262
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.getEnvironmentValue
public function getEnvironmentValue($name) { $name = strtolower($name); $service = $this->getService(); foreach ($service->getEnvironment() as $environment) { list($key, $value) = explode('=', $environment); if (strtolower($key) !== $name) { continue; } return $value; } return null; }
php
public function getEnvironmentValue($name) { $name = strtolower($name); $service = $this->getService(); foreach ($service->getEnvironment() as $environment) { list($key, $value) = explode('=', $environment); if (strtolower($key) !== $name) { continue; } return $value; } return null; }
[ "public", "function", "getEnvironmentValue", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "service", "=", "$", "this", "->", "getService", "(", ")", ";", "foreach", "(", "$", "service", "->", "getEnvironm...
Get environment value. @param $name The name of the environment variable. @return string The environment value; otherwise null.
[ "Get", "environment", "value", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L273-L288
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.getHostPorts
public function getHostPorts() { $ports = []; $service = $this->getService(); foreach ($service->getPorts() as $port) { list($host,) = explode(':', $port); $ports[] = $host; } return $ports; }
php
public function getHostPorts() { $ports = []; $service = $this->getService(); foreach ($service->getPorts() as $port) { list($host,) = explode(':', $port); $ports[] = $host; } return $ports; }
[ "public", "function", "getHostPorts", "(", ")", "{", "$", "ports", "=", "[", "]", ";", "$", "service", "=", "$", "this", "->", "getService", "(", ")", ";", "foreach", "(", "$", "service", "->", "getPorts", "(", ")", "as", "$", "port", ")", "{", "...
Get Docker host ports. @return array An array of host ports.
[ "Get", "Docker", "host", "ports", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L296-L307
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.getPorts
protected function getPorts($host = null) { $ports = $this->ports(); array_walk($ports, function (&$port) use ($host) { $host = isset($host) ? $host : $port; $port = "{$host}:{$port}"; }); return $ports; }
php
protected function getPorts($host = null) { $ports = $this->ports(); array_walk($ports, function (&$port) use ($host) { $host = isset($host) ? $host : $port; $port = "{$host}:{$port}"; }); return $ports; }
[ "protected", "function", "getPorts", "(", "$", "host", "=", "null", ")", "{", "$", "ports", "=", "$", "this", "->", "ports", "(", ")", ";", "array_walk", "(", "$", "ports", ",", "function", "(", "&", "$", "port", ")", "use", "(", "$", "host", ")"...
Get Docker formatted service ports. @param null $host @return array An array of Docker service ports.
[ "Get", "Docker", "formatted", "service", "ports", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L317-L326
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.getServiceNames
protected function getServiceNames() { $names = []; foreach ($this->getServices() as $name => $info) { if (!isset($info['type'])) { continue; } $names[$name] = $info['type']; } return $names; }
php
protected function getServiceNames() { $names = []; foreach ($this->getServices() as $name => $info) { if (!isset($info['type'])) { continue; } $names[$name] = $info['type']; } return $names; }
[ "protected", "function", "getServiceNames", "(", ")", "{", "$", "names", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getServices", "(", ")", "as", "$", "name", "=>", "$", "info", ")", "{", "if", "(", "!", "isset", "(", "$", "info", "[...
Get all defined docker service names. @return array An array of docker service types.
[ "Get", "all", "defined", "docker", "service", "names", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L334-L346
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.alterService
protected function alterService(DockerService $service) { if ($this->internal) { $service ->setNetworks([ 'internal' ]) ->setlabels([ 'traefik.enable=false' ]); if ($this->bindPorts) { $service->setPorts( $this->getPorts('0000') ); } } else { $service->setPorts($this->getPorts()); } return $service; }
php
protected function alterService(DockerService $service) { if ($this->internal) { $service ->setNetworks([ 'internal' ]) ->setlabels([ 'traefik.enable=false' ]); if ($this->bindPorts) { $service->setPorts( $this->getPorts('0000') ); } } else { $service->setPorts($this->getPorts()); } return $service; }
[ "protected", "function", "alterService", "(", "DockerService", "$", "service", ")", "{", "if", "(", "$", "this", "->", "internal", ")", "{", "$", "service", "->", "setNetworks", "(", "[", "'internal'", "]", ")", "->", "setlabels", "(", "[", "'traefik.enabl...
Default alternations to the service object. @param DockerService $service The docker service object. @return DockerService The alter service.
[ "Default", "alternations", "to", "the", "service", "object", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L371-L392
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.formatRunCommand
protected function formatRunCommand(array $commands) { $last = end($commands); return 'RUN ' . implode("\r\n && ", array_map( function ($value) use ($last) { return $last !== $value ? "{$value} \\" : $value; }, $commands )); }
php
protected function formatRunCommand(array $commands) { $last = end($commands); return 'RUN ' . implode("\r\n && ", array_map( function ($value) use ($last) { return $last !== $value ? "{$value} \\" : $value; }, $commands )); }
[ "protected", "function", "formatRunCommand", "(", "array", "$", "commands", ")", "{", "$", "last", "=", "end", "(", "$", "commands", ")", ";", "return", "'RUN '", ".", "implode", "(", "\"\\r\\n && \"", ",", "array_map", "(", "function", "(", "$", "value",...
Format command into a docker run statement. @param array $commands @return string
[ "Format", "command", "into", "a", "docker", "run", "statement", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L400-L410
train
droath/project-x
src/Engine/DockerServices/DockerServiceBase.php
DockerServiceBase.mergeConfigVariable
protected function mergeConfigVariable($name, array $values) { if (in_array($name, static::DOCKER_VARIABLES)) { $this->configs[$name] = array_unique( array_merge($this->configs[$name], $values) ); } return $this; }
php
protected function mergeConfigVariable($name, array $values) { if (in_array($name, static::DOCKER_VARIABLES)) { $this->configs[$name] = array_unique( array_merge($this->configs[$name], $values) ); } return $this; }
[ "protected", "function", "mergeConfigVariable", "(", "$", "name", ",", "array", "$", "values", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "static", "::", "DOCKER_VARIABLES", ")", ")", "{", "$", "this", "->", "configs", "[", "$", "name", "]...
Merge configuration variables. @param $name The name of variable. @param array $values An array of values to merge into the configuration. @return $this
[ "Merge", "configuration", "variables", "." ]
85a7a4879bd041f4c5cb565356646e5f5e2435b7
https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerServices/DockerServiceBase.php#L434-L443
train
jarnix/nofussframework
Nf/Task/Manager.php
Manager.launchNextTask
protected function launchNextTask() { if (! $this->numberOfThreadsToLaunch) { return false; } $taskInfos = $this->pool[$this->numberOfTasks - $this->numberOfThreadsToLaunch]; $taskInfos['task']->fork(); $this->numberOfRunningThreads++; $this->numberOfThreadsToLaunch--; return true; }
php
protected function launchNextTask() { if (! $this->numberOfThreadsToLaunch) { return false; } $taskInfos = $this->pool[$this->numberOfTasks - $this->numberOfThreadsToLaunch]; $taskInfos['task']->fork(); $this->numberOfRunningThreads++; $this->numberOfThreadsToLaunch--; return true; }
[ "protected", "function", "launchNextTask", "(", ")", "{", "if", "(", "!", "$", "this", "->", "numberOfThreadsToLaunch", ")", "{", "return", "false", ";", "}", "$", "taskInfos", "=", "$", "this", "->", "pool", "[", "$", "this", "->", "numberOfTasks", "-",...
Fork next task @return bool True if a task was launch, false if all tasks are already launched
[ "Fork", "next", "task" ]
2177ebefd408bd9545ac64345b47cde1ff3cdccb
https://github.com/jarnix/nofussframework/blob/2177ebefd408bd9545ac64345b47cde1ff3cdccb/Nf/Task/Manager.php#L56-L69
train
krystal-framework/krystal.framework
src/Krystal/Application/Route/Router.php
Router.match
public function match($segment, array $map) { foreach ($map as $index => $uriTemplate) { $matches = array(); if (preg_match($this->createRegEx($uriTemplate), $segment, $matches) === 1) { $matchedURI = array_shift($matches); $routeMatch = new RouteMatch(); $routeMatch->setMatchedUri($matchedURI) ->setMatchedUriTemplate($uriTemplate) ->setVariables($matches); return $routeMatch; } } // By default, we have no matches return false; }
php
public function match($segment, array $map) { foreach ($map as $index => $uriTemplate) { $matches = array(); if (preg_match($this->createRegEx($uriTemplate), $segment, $matches) === 1) { $matchedURI = array_shift($matches); $routeMatch = new RouteMatch(); $routeMatch->setMatchedUri($matchedURI) ->setMatchedUriTemplate($uriTemplate) ->setVariables($matches); return $routeMatch; } } // By default, we have no matches return false; }
[ "public", "function", "match", "(", "$", "segment", ",", "array", "$", "map", ")", "{", "foreach", "(", "$", "map", "as", "$", "index", "=>", "$", "uriTemplate", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match", "(", ...
Matches a URI string against a route map @param string $segment The actual segment to match against @param array $map Target route map to compare against @return boolean|\Krystal\Application\Route\RouteMatch
[ "Matches", "a", "URI", "string", "against", "a", "route", "map" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Route/Router.php#L42-L60
train
krystal-framework/krystal.framework
src/Krystal/Application/Route/Router.php
Router.createRegEx
private function createRegEx($uriTemplate) { $pattern = str_replace($this->getPlaceholders(), $this->getPatterns(), $uriTemplate); // Match everything after question mark, if present $pattern .= '(\?(.*))?'; return '~^' . $pattern . '$~i'; }
php
private function createRegEx($uriTemplate) { $pattern = str_replace($this->getPlaceholders(), $this->getPatterns(), $uriTemplate); // Match everything after question mark, if present $pattern .= '(\?(.*))?'; return '~^' . $pattern . '$~i'; }
[ "private", "function", "createRegEx", "(", "$", "uriTemplate", ")", "{", "$", "pattern", "=", "str_replace", "(", "$", "this", "->", "getPlaceholders", "(", ")", ",", "$", "this", "->", "getPatterns", "(", ")", ",", "$", "uriTemplate", ")", ";", "// Matc...
Creates a regular expression according to URI template @param string $uriTemplate string @return string Prepared regular expression
[ "Creates", "a", "regular", "expression", "according", "to", "URI", "template" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Application/Route/Router.php#L68-L76
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/CacheMapper.php
CacheMapper.fetchAll
public function fetchAll() { $query = sprintf('SELECT * FROM `%s`', $this->table); $result = array(); foreach ($this->pdo->query($query) as $key => $value) { $result[$key] = $value; } return $this->parse($result); }
php
public function fetchAll() { $query = sprintf('SELECT * FROM `%s`', $this->table); $result = array(); foreach ($this->pdo->query($query) as $key => $value) { $result[$key] = $value; } return $this->parse($result); }
[ "public", "function", "fetchAll", "(", ")", "{", "$", "query", "=", "sprintf", "(", "'SELECT * FROM `%s`'", ",", "$", "this", "->", "table", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "pdo", "->", "query"...
Fetches cache data @return array
[ "Fetches", "cache", "data" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/CacheMapper.php#L72-L82
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/CacheMapper.php
CacheMapper.alter
private function alter($key, $operator, $step) { $query = sprintf('UPDATE `%s` SET `value` = value %s %s WHERE `key` = :key', $this->table, $operator, $step); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':key' => $key )); }
php
private function alter($key, $operator, $step) { $query = sprintf('UPDATE `%s` SET `value` = value %s %s WHERE `key` = :key', $this->table, $operator, $step); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':key' => $key )); }
[ "private", "function", "alter", "(", "$", "key", ",", "$", "operator", ",", "$", "step", ")", "{", "$", "query", "=", "sprintf", "(", "'UPDATE `%s` SET `value` = value %s %s WHERE `key` = :key'", ",", "$", "this", "->", "table", ",", "$", "operator", ",", "$...
Alters a column @param string $key @param string $operator @param integer $step @return boolean
[ "Alters", "a", "column" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/CacheMapper.php#L92-L100
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/CacheMapper.php
CacheMapper.insert
public function insert($key, $value, $ttl, $time) { if ($this->serializer->isSerializeable($value)) { $value = $this->serializer->serialize($value); } $query = sprintf('INSERT INTO `%s` (`key`, `value`, `ttl`, `created_on`) VALUES (:key, :value, :ttl, :created_on)', $this->table); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':'.ConstProviderInterface::CACHE_PARAM_KEY => $key, ':'.ConstProviderInterface::CACHE_PARAM_VALUE => $value, ':'.ConstProviderInterface::CACHE_PARAM_TTL => $ttl, ':'.ConstProviderInterface::CACHE_PARAM_CREATED_ON => time(), )); }
php
public function insert($key, $value, $ttl, $time) { if ($this->serializer->isSerializeable($value)) { $value = $this->serializer->serialize($value); } $query = sprintf('INSERT INTO `%s` (`key`, `value`, `ttl`, `created_on`) VALUES (:key, :value, :ttl, :created_on)', $this->table); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':'.ConstProviderInterface::CACHE_PARAM_KEY => $key, ':'.ConstProviderInterface::CACHE_PARAM_VALUE => $value, ':'.ConstProviderInterface::CACHE_PARAM_TTL => $ttl, ':'.ConstProviderInterface::CACHE_PARAM_CREATED_ON => time(), )); }
[ "public", "function", "insert", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", ",", "$", "time", ")", "{", "if", "(", "$", "this", "->", "serializer", "->", "isSerializeable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this"...
Inserts new cache's record @param string $key @param mixed @param integer $ttl Time to live in seconds @param integer $time Current timestamp @return boolean
[ "Inserts", "new", "cache", "s", "record" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/CacheMapper.php#L135-L150
train
krystal-framework/krystal.framework
src/Krystal/Cache/Sql/CacheMapper.php
CacheMapper.parse
private function parse(array $data) { $result = array(); foreach ($data as $index => $array) { if ($this->serializer->isSerialized($array[ConstProviderInterface::CACHE_PARAM_VALUE])) { $array[ConstProviderInterface::CACHE_PARAM_VALUE] = $this->serializer->unserialize($array[ConstProviderInterface::CACHE_PARAM_VALUE]); } $result[$array[ConstProviderInterface::CACHE_PARAM_KEY]] = array( ConstProviderInterface::CACHE_PARAM_VALUE => $array[ConstProviderInterface::CACHE_PARAM_VALUE], ConstProviderInterface::CACHE_PARAM_TTL => $array[ConstProviderInterface::CACHE_PARAM_TTL], ConstProviderInterface::CACHE_PARAM_CREATED_ON => $array[ConstProviderInterface::CACHE_PARAM_CREATED_ON] ); } return $result; }
php
private function parse(array $data) { $result = array(); foreach ($data as $index => $array) { if ($this->serializer->isSerialized($array[ConstProviderInterface::CACHE_PARAM_VALUE])) { $array[ConstProviderInterface::CACHE_PARAM_VALUE] = $this->serializer->unserialize($array[ConstProviderInterface::CACHE_PARAM_VALUE]); } $result[$array[ConstProviderInterface::CACHE_PARAM_KEY]] = array( ConstProviderInterface::CACHE_PARAM_VALUE => $array[ConstProviderInterface::CACHE_PARAM_VALUE], ConstProviderInterface::CACHE_PARAM_TTL => $array[ConstProviderInterface::CACHE_PARAM_TTL], ConstProviderInterface::CACHE_PARAM_CREATED_ON => $array[ConstProviderInterface::CACHE_PARAM_CREATED_ON] ); } return $result; }
[ "private", "function", "parse", "(", "array", "$", "data", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "array", ")", "{", "if", "(", "$", "this", "->", "serializer", "->", "isS...
Parses result from a table @param array $data @return array
[ "Parses", "result", "from", "a", "table" ]
a5ff72384f3efbe74f390538793feb7d522b9c39
https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Cache/Sql/CacheMapper.php#L199-L216
train
hostnet/dead
src/task/PrimeTask.php
PrimeTask.insertNewFileFunctions
private function insertNewFileFunctions(iterable $new): void { // early return when there is nothing to be added if (0 === \count($new)) { return; } $table = $this->getTable(); $db = $this->getDb(); foreach ($new as $file_function => $data) { $query = $db->prepare( "INSERT INTO $table (function, added_at, changed_at) VALUES (:file_function, NOW(), :changed_at)" ); $changed_at = $data->getChangedAt(); $query->bindParam(":file_function", $file_function); $query->bindParam(":changed_at", $changed_at); $query->execute(); } }
php
private function insertNewFileFunctions(iterable $new): void { // early return when there is nothing to be added if (0 === \count($new)) { return; } $table = $this->getTable(); $db = $this->getDb(); foreach ($new as $file_function => $data) { $query = $db->prepare( "INSERT INTO $table (function, added_at, changed_at) VALUES (:file_function, NOW(), :changed_at)" ); $changed_at = $data->getChangedAt(); $query->bindParam(":file_function", $file_function); $query->bindParam(":changed_at", $changed_at); $query->execute(); } }
[ "private", "function", "insertNewFileFunctions", "(", "iterable", "$", "new", ")", ":", "void", "{", "// early return when there is nothing to be added", "if", "(", "0", "===", "\\", "count", "(", "$", "new", ")", ")", "{", "return", ";", "}", "$", "table", ...
Constructs the SQL query and executes it. @param iterable|string[] $new
[ "Constructs", "the", "SQL", "query", "and", "executes", "it", "." ]
29cdfeb4feb019405dbd0cbcd34bfa3105c07880
https://github.com/hostnet/dead/blob/29cdfeb4feb019405dbd0cbcd34bfa3105c07880/src/task/PrimeTask.php#L139-L157
train