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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dfeyer/Ttree.Oembed | Classes/Consumer.php | Consumer.findProviderForUrl | protected function findProviderForUrl($url)
{
foreach ($this->providers as $provider) {
if ($provider->match($url)) {
return $provider;
}
}
return null;
} | php | protected function findProviderForUrl($url)
{
foreach ($this->providers as $provider) {
if ($provider->match($url)) {
return $provider;
}
}
return null;
} | [
"protected",
"function",
"findProviderForUrl",
"(",
"$",
"url",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"providers",
"as",
"$",
"provider",
")",
"{",
"if",
"(",
"$",
"provider",
"->",
"match",
"(",
"$",
"url",
")",
")",
"{",
"return",
"$",
"prov... | Find an oEmbed provider matching the supplied URL.
@param string $url The URL to find an oEmbed provider for.
@return \Ttree\Oembed\Provider | [
"Find",
"an",
"oEmbed",
"provider",
"matching",
"the",
"supplied",
"URL",
"."
] | 1f38d18f51c1abe96c19fe4760acc9ef907194df | https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Consumer.php#L218-L227 | train |
JBZoo/Html | src/Render/Radio.php | Radio._checkSelected | protected function _checkSelected(array $options, $selectedVal)
{
if (!empty($selectedVal) && !Arr::key($selectedVal, $options)) {
$selectedVal = self::KEY_NO_EXITS_VAL;
$options = array_merge(array(self::KEY_NO_EXITS_VAL => $this->_translate('No exits')), $options);
}
return array($options, $selectedVal);
} | php | protected function _checkSelected(array $options, $selectedVal)
{
if (!empty($selectedVal) && !Arr::key($selectedVal, $options)) {
$selectedVal = self::KEY_NO_EXITS_VAL;
$options = array_merge(array(self::KEY_NO_EXITS_VAL => $this->_translate('No exits')), $options);
}
return array($options, $selectedVal);
} | [
"protected",
"function",
"_checkSelected",
"(",
"array",
"$",
"options",
",",
"$",
"selectedVal",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"selectedVal",
")",
"&&",
"!",
"Arr",
"::",
"key",
"(",
"$",
"selectedVal",
",",
"$",
"options",
")",
")",
... | Check selected option in list.
@param array $options
@param string $selectedVal
@return array | [
"Check",
"selected",
"option",
"in",
"list",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Radio.php#L70-L78 | train |
phug-php/renderer | src/Phug/Renderer/Partial/AdapterTrait.php | AdapterTrait.getNewSandBox | public function getNewSandBox(callable $action)
{
$errorHandler = $this->getOption('error_reporting');
if ($errorHandler !== null && !is_callable($errorHandler)) {
$errorReporting = $errorHandler;
$errorHandler = function ($number, $message, $file, $line) use ($errorReporting) {
if ($errorReporting & $number) {
throw new ErrorException($message, 0, $number, $file, $line);
}
return true;
};
}
return new SandBox($action, $errorHandler);
} | php | public function getNewSandBox(callable $action)
{
$errorHandler = $this->getOption('error_reporting');
if ($errorHandler !== null && !is_callable($errorHandler)) {
$errorReporting = $errorHandler;
$errorHandler = function ($number, $message, $file, $line) use ($errorReporting) {
if ($errorReporting & $number) {
throw new ErrorException($message, 0, $number, $file, $line);
}
return true;
};
}
return new SandBox($action, $errorHandler);
} | [
"public",
"function",
"getNewSandBox",
"(",
"callable",
"$",
"action",
")",
"{",
"$",
"errorHandler",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'error_reporting'",
")",
";",
"if",
"(",
"$",
"errorHandler",
"!==",
"null",
"&&",
"!",
"is_callable",
"(",
"$"... | Return a sandbox with renderer settings for a given callable action.
@param callable $action
@return SandBox | [
"Return",
"a",
"sandbox",
"with",
"renderer",
"settings",
"for",
"a",
"given",
"callable",
"action",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Partial/AdapterTrait.php#L86-L101 | train |
phug-php/renderer | src/Phug/Renderer/Partial/AdapterTrait.php | AdapterTrait.getSandboxCall | private function getSandboxCall(&$source, $method, $path, $input, callable $getSource, array $parameters)
{
return $this->getNewSandBox(function () use (&$source, $method, $path, $input, $getSource, $parameters) {
$adapter = $this->getAdapter();
$cacheEnabled = (
$adapter->hasOption('cache_dir') && $adapter->getOption('cache_dir') ||
$this->hasOption('cache_dir') && $this->getOption('cache_dir')
);
if ($cacheEnabled) {
$this->expectCacheAdapter();
$adapter = $this->getAdapter();
$display = function () use ($adapter, $path, $input, $getSource, $parameters) {
/* @var CacheInterface $adapter */
$adapter->displayCached($path, $input, $getSource, $parameters);
};
return in_array($method, ['display', 'displayFile'])
? $display()
: $adapter->captureBuffer($display);
}
$source = $getSource($path, $input);
return $adapter->$method(
$source,
$parameters
);
});
} | php | private function getSandboxCall(&$source, $method, $path, $input, callable $getSource, array $parameters)
{
return $this->getNewSandBox(function () use (&$source, $method, $path, $input, $getSource, $parameters) {
$adapter = $this->getAdapter();
$cacheEnabled = (
$adapter->hasOption('cache_dir') && $adapter->getOption('cache_dir') ||
$this->hasOption('cache_dir') && $this->getOption('cache_dir')
);
if ($cacheEnabled) {
$this->expectCacheAdapter();
$adapter = $this->getAdapter();
$display = function () use ($adapter, $path, $input, $getSource, $parameters) {
/* @var CacheInterface $adapter */
$adapter->displayCached($path, $input, $getSource, $parameters);
};
return in_array($method, ['display', 'displayFile'])
? $display()
: $adapter->captureBuffer($display);
}
$source = $getSource($path, $input);
return $adapter->$method(
$source,
$parameters
);
});
} | [
"private",
"function",
"getSandboxCall",
"(",
"&",
"$",
"source",
",",
"$",
"method",
",",
"$",
"path",
",",
"$",
"input",
",",
"callable",
"$",
"getSource",
",",
"array",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"getNewSandBox",
"(",
... | Call an adapter method inside a sandbox and return the SandBox result.
@param string $source
@param string $method
@param string $path
@param string $input
@param callable $getSource
@param array $parameters
@return SandBox | [
"Call",
"an",
"adapter",
"method",
"inside",
"a",
"sandbox",
"and",
"return",
"the",
"SandBox",
"result",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Partial/AdapterTrait.php#L115-L143 | train |
HeroBanana/directadmin | src/DirectAdmin/DirectAdmin.php | DirectAdmin.send | private function send(string $method, string $command, array $options = []): array
{
$result = $this->client->da_request($method, self::CMD_PREFIX . $command, $options);
return $result;
} | php | private function send(string $method, string $command, array $options = []): array
{
$result = $this->client->da_request($method, self::CMD_PREFIX . $command, $options);
return $result;
} | [
"private",
"function",
"send",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"command",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"da_request",
"(",
"$",
"method",
... | Send command.
@param string $method Method get or post.
@param string $command DirectAdmin command.
@param array $options Additional options.
@return array | [
"Send",
"command",
"."
] | 9081ce63ecc881c43bb497a114345a9b483b5a62 | https://github.com/HeroBanana/directadmin/blob/9081ce63ecc881c43bb497a114345a9b483b5a62/src/DirectAdmin/DirectAdmin.php#L65-L70 | train |
JBZoo/Html | src/Render/Select.php | Select._checkNoSelected | protected function _checkNoSelected(array $options, array $selected, $isMultiply = false)
{
if ($isMultiply === 'multiple') {
return array($options, $selected);
}
$_selected = array_pop($selected);
if (!Arr::key($_selected, $options) && !empty($selected)) {
$options = array_merge(array($_selected => $this->_translate('--No selected--')), $options);
}
return array($options, array($_selected));
} | php | protected function _checkNoSelected(array $options, array $selected, $isMultiply = false)
{
if ($isMultiply === 'multiple') {
return array($options, $selected);
}
$_selected = array_pop($selected);
if (!Arr::key($_selected, $options) && !empty($selected)) {
$options = array_merge(array($_selected => $this->_translate('--No selected--')), $options);
}
return array($options, array($_selected));
} | [
"protected",
"function",
"_checkNoSelected",
"(",
"array",
"$",
"options",
",",
"array",
"$",
"selected",
",",
"$",
"isMultiply",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"isMultiply",
"===",
"'multiple'",
")",
"{",
"return",
"array",
"(",
"$",
"options",
... | Check on no selected and add new select option.
@param array $options
@param array $selected
@param bool|false $isMultiply
@return array | [
"Check",
"on",
"no",
"selected",
"and",
"add",
"new",
"select",
"option",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Select.php#L70-L83 | train |
JBZoo/Html | src/Render/Select.php | Select._createGroup | protected function _createGroup($key, array $gOptions, array $selected, array $options)
{
$label = (is_int($key)) ? sprintf($this->_translate('Select group %s'), $key) : $key;
$output = array(
'<optgroup label="' . $this->_translate($label) . '">'
);
foreach ($gOptions as $value => $label) {
if (Arr::key($value, $options)) {
continue;
}
$classes = implode(' ', array(
$this->_jbSrt('option'),
$this->_jbSrt('option-' . Str::slug($label)),
));
$isSelected = $this->_isSelected($value, $selected);
$output[] = $this->_option($value, $isSelected, $classes, $label);
}
$output[] = '</optgroup>';
return implode(PHP_EOL, $output);
} | php | protected function _createGroup($key, array $gOptions, array $selected, array $options)
{
$label = (is_int($key)) ? sprintf($this->_translate('Select group %s'), $key) : $key;
$output = array(
'<optgroup label="' . $this->_translate($label) . '">'
);
foreach ($gOptions as $value => $label) {
if (Arr::key($value, $options)) {
continue;
}
$classes = implode(' ', array(
$this->_jbSrt('option'),
$this->_jbSrt('option-' . Str::slug($label)),
));
$isSelected = $this->_isSelected($value, $selected);
$output[] = $this->_option($value, $isSelected, $classes, $label);
}
$output[] = '</optgroup>';
return implode(PHP_EOL, $output);
} | [
"protected",
"function",
"_createGroup",
"(",
"$",
"key",
",",
"array",
"$",
"gOptions",
",",
"array",
"$",
"selected",
",",
"array",
"$",
"options",
")",
"{",
"$",
"label",
"=",
"(",
"is_int",
"(",
"$",
"key",
")",
")",
"?",
"sprintf",
"(",
"$",
"... | Create options group.
@param string $key
@param array $gOptions
@param array $selected
@param array $options
@return string | [
"Create",
"options",
"group",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Select.php#L94-L118 | train |
JBZoo/Html | src/Render/Select.php | Select._getOptions | protected function _getOptions(array $options, array $selected = array(), $isMultiple = false)
{
$output = array();
list($options, $_selected) = $this->_checkNoSelected($options, $selected, $isMultiple);
foreach ($options as $key => $data) {
$label = $data;
$value = $key;
$classes = implode(' ', array(
$this->_jbSrt('option'),
$this->_jbSrt('option-' . Str::slug($value, true)),
));
$isSelected = $this->_isSelected($value, $_selected);
if (is_array($data)) {
$output[] = $this->_createGroup($key, $data, $_selected, $options);
} else {
$output[] = $this->_option($value, $isSelected, $classes, $label);
}
}
return implode(PHP_EOL, $output);
} | php | protected function _getOptions(array $options, array $selected = array(), $isMultiple = false)
{
$output = array();
list($options, $_selected) = $this->_checkNoSelected($options, $selected, $isMultiple);
foreach ($options as $key => $data) {
$label = $data;
$value = $key;
$classes = implode(' ', array(
$this->_jbSrt('option'),
$this->_jbSrt('option-' . Str::slug($value, true)),
));
$isSelected = $this->_isSelected($value, $_selected);
if (is_array($data)) {
$output[] = $this->_createGroup($key, $data, $_selected, $options);
} else {
$output[] = $this->_option($value, $isSelected, $classes, $label);
}
}
return implode(PHP_EOL, $output);
} | [
"protected",
"function",
"_getOptions",
"(",
"array",
"$",
"options",
",",
"array",
"$",
"selected",
"=",
"array",
"(",
")",
",",
"$",
"isMultiple",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"list",
"(",
"$",
"options",
",",... | Get select options.
@param array $options
@param array $selected
@param bool|false $isMultiple
@return string | [
"Get",
"select",
"options",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Select.php#L128-L153 | train |
JBZoo/Html | src/Render/Select.php | Select._option | protected function _option($value, $selected = false, $class = '', $label = '')
{
if ($selected === true) {
$selected = ' selected="selected"';
}
$option = '<option value="' . $value . '" class="' . $class . '"' . $selected .'>' .
$this->_translate($label) .
'</option>';
return $option;
} | php | protected function _option($value, $selected = false, $class = '', $label = '')
{
if ($selected === true) {
$selected = ' selected="selected"';
}
$option = '<option value="' . $value . '" class="' . $class . '"' . $selected .'>' .
$this->_translate($label) .
'</option>';
return $option;
} | [
"protected",
"function",
"_option",
"(",
"$",
"value",
",",
"$",
"selected",
"=",
"false",
",",
"$",
"class",
"=",
"''",
",",
"$",
"label",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"selected",
"===",
"true",
")",
"{",
"$",
"selected",
"=",
"' selected=... | Create option.
@param string $value
@param bool|false $selected
@param string $class
@param string $label
@return string | [
"Create",
"option",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Select.php#L181-L192 | train |
phug-php/renderer | src/Phug/Renderer/Adapter/FileAdapter.php | FileAdapter.cache | public function cache($path, $input, callable $rendered, &$success = null)
{
$cacheFolder = $this->getCacheDirectory();
$destination = $path;
if (!$this->isCacheUpToDate($destination, $input)) {
if (!is_writable($cacheFolder)) {
throw new RuntimeException(sprintf('Cache directory must be writable. "%s" is not.', $cacheFolder), 6);
}
$compiler = $this->getRenderer()->getCompiler();
$fullPath = $compiler->locate($path) ?: $path;
$output = $rendered($fullPath, $input);
$importsPaths = $compiler->getImportPaths($fullPath);
$success = $this->cacheFileContents(
$destination,
$output,
$importsPaths
);
}
return $destination;
} | php | public function cache($path, $input, callable $rendered, &$success = null)
{
$cacheFolder = $this->getCacheDirectory();
$destination = $path;
if (!$this->isCacheUpToDate($destination, $input)) {
if (!is_writable($cacheFolder)) {
throw new RuntimeException(sprintf('Cache directory must be writable. "%s" is not.', $cacheFolder), 6);
}
$compiler = $this->getRenderer()->getCompiler();
$fullPath = $compiler->locate($path) ?: $path;
$output = $rendered($fullPath, $input);
$importsPaths = $compiler->getImportPaths($fullPath);
$success = $this->cacheFileContents(
$destination,
$output,
$importsPaths
);
}
return $destination;
} | [
"public",
"function",
"cache",
"(",
"$",
"path",
",",
"$",
"input",
",",
"callable",
"$",
"rendered",
",",
"&",
"$",
"success",
"=",
"null",
")",
"{",
"$",
"cacheFolder",
"=",
"$",
"this",
"->",
"getCacheDirectory",
"(",
")",
";",
"$",
"destination",
... | Return the cached file path after cache optional process.
@param $path
@param string $input pug input
@param callable $rendered method to compile the source into PHP
@param bool $success
@return string | [
"Return",
"the",
"cached",
"file",
"path",
"after",
"cache",
"optional",
"process",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Adapter/FileAdapter.php#L48-L71 | train |
phug-php/renderer | src/Phug/Renderer/Adapter/FileAdapter.php | FileAdapter.displayCached | public function displayCached($path, $input, callable $rendered, array $variables, &$success = null)
{
$__pug_parameters = $variables;
$__pug_path = $this->cache($path, $input, $rendered, $success);
call_user_func(function () use ($__pug_path, $__pug_parameters) {
extract($__pug_parameters);
include $__pug_path;
});
} | php | public function displayCached($path, $input, callable $rendered, array $variables, &$success = null)
{
$__pug_parameters = $variables;
$__pug_path = $this->cache($path, $input, $rendered, $success);
call_user_func(function () use ($__pug_path, $__pug_parameters) {
extract($__pug_parameters);
include $__pug_path;
});
} | [
"public",
"function",
"displayCached",
"(",
"$",
"path",
",",
"$",
"input",
",",
"callable",
"$",
"rendered",
",",
"array",
"$",
"variables",
",",
"&",
"$",
"success",
"=",
"null",
")",
"{",
"$",
"__pug_parameters",
"=",
"$",
"variables",
";",
"$",
"__... | Display rendered template after optional cache process.
@param $path
@param string $input pug input
@param callable $rendered method to compile the source into PHP
@param array $variables local variables
@param bool $success | [
"Display",
"rendered",
"template",
"after",
"optional",
"cache",
"process",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Adapter/FileAdapter.php#L82-L91 | train |
phug-php/renderer | src/Phug/Renderer/Adapter/FileAdapter.php | FileAdapter.cacheFileIfChanged | public function cacheFileIfChanged($path)
{
$outputFile = $path;
if (!$this->isCacheUpToDate($outputFile)) {
$compiler = $this->getRenderer()->getCompiler();
return $this->cacheFileContents(
$outputFile,
$compiler->compileFile($path),
$compiler->getCurrentImportPaths()
);
}
return true;
} | php | public function cacheFileIfChanged($path)
{
$outputFile = $path;
if (!$this->isCacheUpToDate($outputFile)) {
$compiler = $this->getRenderer()->getCompiler();
return $this->cacheFileContents(
$outputFile,
$compiler->compileFile($path),
$compiler->getCurrentImportPaths()
);
}
return true;
} | [
"public",
"function",
"cacheFileIfChanged",
"(",
"$",
"path",
")",
"{",
"$",
"outputFile",
"=",
"$",
"path",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isCacheUpToDate",
"(",
"$",
"outputFile",
")",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"g... | Cache a template file in the cache directory if the cache is obsolete.
Returns true if the cache is up to date and cache not change,
else returns the number of bytes written in the cache file or false if
a failure occurred.
@param string $path
@return bool|int | [
"Cache",
"a",
"template",
"file",
"in",
"the",
"cache",
"directory",
"if",
"the",
"cache",
"is",
"obsolete",
".",
"Returns",
"true",
"if",
"the",
"cache",
"is",
"up",
"to",
"date",
"and",
"cache",
"not",
"change",
"else",
"returns",
"the",
"number",
"of"... | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Adapter/FileAdapter.php#L125-L139 | train |
phug-php/renderer | src/Phug/Renderer/Adapter/FileAdapter.php | FileAdapter.cacheDirectory | public function cacheDirectory($directory)
{
$success = 0;
$errors = 0;
$errorDetails = [];
$renderer = $this->getRenderer();
$events = $renderer->getCompiler()->getEventListeners();
foreach ($renderer->scanDirectory($directory) as $inputFile) {
$renderer->initCompiler();
$compiler = $renderer->getCompiler();
$compiler->mergeEventListeners($events);
$path = $inputFile;
$this->isCacheUpToDate($path);
$sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
$this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
$success++;
});
$error = $sandBox->getThrowable();
if ($error) {
$errors++;
$errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
}
}
return [$success, $errors, $errorDetails];
} | php | public function cacheDirectory($directory)
{
$success = 0;
$errors = 0;
$errorDetails = [];
$renderer = $this->getRenderer();
$events = $renderer->getCompiler()->getEventListeners();
foreach ($renderer->scanDirectory($directory) as $inputFile) {
$renderer->initCompiler();
$compiler = $renderer->getCompiler();
$compiler->mergeEventListeners($events);
$path = $inputFile;
$this->isCacheUpToDate($path);
$sandBox = $this->getRenderer()->getNewSandBox(function () use (&$success, $compiler, $path, $inputFile) {
$this->cacheFileContents($path, $compiler->compileFile($inputFile), $compiler->getCurrentImportPaths());
$success++;
});
$error = $sandBox->getThrowable();
if ($error) {
$errors++;
$errorDetails[] = compact(['directory', 'inputFile', 'path', 'error']);
}
}
return [$success, $errors, $errorDetails];
} | [
"public",
"function",
"cacheDirectory",
"(",
"$",
"directory",
")",
"{",
"$",
"success",
"=",
"0",
";",
"$",
"errors",
"=",
"0",
";",
"$",
"errorDetails",
"=",
"[",
"]",
";",
"$",
"renderer",
"=",
"$",
"this",
"->",
"getRenderer",
"(",
")",
";",
"$... | Scan a directory recursively, compile them and save them into the cache directory.
@param string $directory the directory to search in pug
@throws \Phug\RendererException
@return array count of cached files and error count | [
"Scan",
"a",
"directory",
"recursively",
"compile",
"them",
"and",
"save",
"them",
"into",
"the",
"cache",
"directory",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Adapter/FileAdapter.php#L150-L178 | train |
phug-php/renderer | src/Phug/Renderer/Adapter/FileAdapter.php | FileAdapter.isCacheUpToDate | private function isCacheUpToDate(&$path, $input = null)
{
if (!$input) {
$compiler = $this->getRenderer()->getCompiler();
$input = $compiler->resolve($path);
$path = $this->getCachePath(
($this->getOption('keep_base_name') ? basename($path) : '').
$this->hashPrint($input)
);
// If up_to_date_check never refresh the cache
if (!$this->getOption('up_to_date_check')) {
return true;
}
// If there is no cache file, create it
if (!file_exists($path)) {
return false;
}
// Else check the main input path and all imported paths in the template
return !$this->hasExpiredImport($input, $path);
}
$path = $this->getCachePath($this->hashPrint($input));
// Do not re-parse file if the same hash exists
return file_exists($path);
} | php | private function isCacheUpToDate(&$path, $input = null)
{
if (!$input) {
$compiler = $this->getRenderer()->getCompiler();
$input = $compiler->resolve($path);
$path = $this->getCachePath(
($this->getOption('keep_base_name') ? basename($path) : '').
$this->hashPrint($input)
);
// If up_to_date_check never refresh the cache
if (!$this->getOption('up_to_date_check')) {
return true;
}
// If there is no cache file, create it
if (!file_exists($path)) {
return false;
}
// Else check the main input path and all imported paths in the template
return !$this->hasExpiredImport($input, $path);
}
$path = $this->getCachePath($this->hashPrint($input));
// Do not re-parse file if the same hash exists
return file_exists($path);
} | [
"private",
"function",
"isCacheUpToDate",
"(",
"&",
"$",
"path",
",",
"$",
"input",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"input",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"getRenderer",
"(",
")",
"->",
"getCompiler",
"(",
")",
";",... | Return true if the file or content is up to date in the cache folder,
false else.
@param &string $path to be filled
@param string $input file or pug code
@return bool | [
"Return",
"true",
"if",
"the",
"file",
"or",
"content",
"is",
"up",
"to",
"date",
"in",
"the",
"cache",
"folder",
"false",
"else",
"."
] | ada6f713b6d614d215d62b36e64d2162e7f2569c | https://github.com/phug-php/renderer/blob/ada6f713b6d614d215d62b36e64d2162e7f2569c/src/Phug/Renderer/Adapter/FileAdapter.php#L294-L322 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukePoll.php | XmlnukePoll.getPollConfig | protected function getPollConfig()
{
$pollfile = new AnydatasetFilenameProcessor("_poll");
$anyconfig = new AnyDataset($pollfile->FullQualifiedNameAndPath());
$it = $anyconfig->getIterator();
if ($it->hasNext())
{
$sr = $it->moveNext();
$this->_isdb = $sr->getField("dbname") != "-anydata-";
$this->_connection = $sr->getField("dbname");
$this->_tblanswer = $sr->getField("tbl_answer");
$this->_tblpoll = $sr->getField("tbl_poll");
$this->_tbllastip = $sr->getField("tbl_lastip");
}
else
{
$this->_error = true;
}
} | php | protected function getPollConfig()
{
$pollfile = new AnydatasetFilenameProcessor("_poll");
$anyconfig = new AnyDataset($pollfile->FullQualifiedNameAndPath());
$it = $anyconfig->getIterator();
if ($it->hasNext())
{
$sr = $it->moveNext();
$this->_isdb = $sr->getField("dbname") != "-anydata-";
$this->_connection = $sr->getField("dbname");
$this->_tblanswer = $sr->getField("tbl_answer");
$this->_tblpoll = $sr->getField("tbl_poll");
$this->_tbllastip = $sr->getField("tbl_lastip");
}
else
{
$this->_error = true;
}
} | [
"protected",
"function",
"getPollConfig",
"(",
")",
"{",
"$",
"pollfile",
"=",
"new",
"AnydatasetFilenameProcessor",
"(",
"\"_poll\"",
")",
";",
"$",
"anyconfig",
"=",
"new",
"AnyDataset",
"(",
"$",
"pollfile",
"->",
"FullQualifiedNameAndPath",
"(",
")",
")",
... | Get informations about WHERE I need to store poll data | [
"Get",
"informations",
"about",
"WHERE",
"I",
"need",
"to",
"store",
"poll",
"data"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukePoll.php#L126-L145 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukePoll.php | XmlnukePoll.getAnyData | protected function getAnyData()
{
$filepoll = new AnydatasetFilenameProcessor("poll_list");
$this->_anyPoll = new AnyDataset($filepoll->FullQualifiedNameAndPath());
$fileanswer = new AnydatasetFilenameProcessor("poll_" . $this->_poll . "_" . $this->_lang);
$this->_anyAnswer = new AnyDataset($fileanswer->FullQualifiedNameAndPath());
} | php | protected function getAnyData()
{
$filepoll = new AnydatasetFilenameProcessor("poll_list");
$this->_anyPoll = new AnyDataset($filepoll->FullQualifiedNameAndPath());
$fileanswer = new AnydatasetFilenameProcessor("poll_" . $this->_poll . "_" . $this->_lang);
$this->_anyAnswer = new AnyDataset($fileanswer->FullQualifiedNameAndPath());
} | [
"protected",
"function",
"getAnyData",
"(",
")",
"{",
"$",
"filepoll",
"=",
"new",
"AnydatasetFilenameProcessor",
"(",
"\"poll_list\"",
")",
";",
"$",
"this",
"->",
"_anyPoll",
"=",
"new",
"AnyDataset",
"(",
"$",
"filepoll",
"->",
"FullQualifiedNameAndPath",
"("... | Get AnydataSet Poll information | [
"Get",
"AnydataSet",
"Poll",
"information"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukePoll.php#L151-L157 | train |
anklimsk/cakephp-theme | Controller/ToursController.php | ToursController.steps | public function steps() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = $this->ConfigTheme->getStepsConfigTourApp();
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | public function steps() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = $this->ConfigTheme->getStepsConfigTourApp();
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | [
"public",
"function",
"steps",
"(",
")",
"{",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
"||",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
... | Action `steps`. Is used to get data of tour steps
@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void | [
"Action",
"steps",
".",
"Is",
"used",
"to",
"get",
"data",
"of",
"tour",
"steps"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/ToursController.php#L45-L55 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php | FirePHPHandler.write | protected function write(array $record)
{
if (!self::$sendHeaders) {
return;
}
// WildFire-specific headers must be sent prior to any messages
if (!self::$initialized) {
self::$initialized = true;
self::$sendHeaders = $this->headersAccepted();
if (!self::$sendHeaders) {
return;
}
foreach ($this->getInitHeaders() as $header => $content) {
$this->sendHeader($header, $content);
}
}
$header = $this->createRecordHeader($record);
if (trim(current($header)) !== '') {
$this->sendHeader(key($header), current($header));
}
} | php | protected function write(array $record)
{
if (!self::$sendHeaders) {
return;
}
// WildFire-specific headers must be sent prior to any messages
if (!self::$initialized) {
self::$initialized = true;
self::$sendHeaders = $this->headersAccepted();
if (!self::$sendHeaders) {
return;
}
foreach ($this->getInitHeaders() as $header => $content) {
$this->sendHeader($header, $content);
}
}
$header = $this->createRecordHeader($record);
if (trim(current($header)) !== '') {
$this->sendHeader(key($header), current($header));
}
} | [
"protected",
"function",
"write",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"sendHeaders",
")",
"{",
"return",
";",
"}",
"// WildFire-specific headers must be sent prior to any messages",
"if",
"(",
"!",
"self",
"::",
"$",
"init... | Creates & sends header for a record, ensuring init headers have been sent prior
@see sendHeader()
@see sendInitHeaders()
@param array $record | [
"Creates",
"&",
"sends",
"header",
"for",
"a",
"record",
"ensuring",
"init",
"headers",
"have",
"been",
"sent",
"prior"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php#L132-L156 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/GuiHandler.php | GuiHandler.displayManialinks | protected function displayManialinks()
{
$size = 0;
foreach ($this->getManialinksToDisplay() as $mlData) {
$currentSize = $size;
$size += strlen($mlData['ml']);
if ($currentSize != 0 && $size > $this->charLimit) {
$this->executeMultiCall();
$size = strlen($mlData['ml']);
}
$logins = array_filter($mlData['logins'], function ($value) {
return $value != '';
});
if (!empty($logins)) {
$this->factory->getConnection()->sendDisplayManialinkPage(
$mlData['logins'],
$mlData['ml'],
$mlData['timeout'],
false,
true
);
}
}
if ($size > 0) {
$this->executeMultiCall();
}
// Reset the queues.
$this->displayQueu = [];
$this->individualQueu = [];
$this->hideQueu = [];
$this->hideIndividualQueu = [];
$this->disconnectedLogins = [];
} | php | protected function displayManialinks()
{
$size = 0;
foreach ($this->getManialinksToDisplay() as $mlData) {
$currentSize = $size;
$size += strlen($mlData['ml']);
if ($currentSize != 0 && $size > $this->charLimit) {
$this->executeMultiCall();
$size = strlen($mlData['ml']);
}
$logins = array_filter($mlData['logins'], function ($value) {
return $value != '';
});
if (!empty($logins)) {
$this->factory->getConnection()->sendDisplayManialinkPage(
$mlData['logins'],
$mlData['ml'],
$mlData['timeout'],
false,
true
);
}
}
if ($size > 0) {
$this->executeMultiCall();
}
// Reset the queues.
$this->displayQueu = [];
$this->individualQueu = [];
$this->hideQueu = [];
$this->hideIndividualQueu = [];
$this->disconnectedLogins = [];
} | [
"protected",
"function",
"displayManialinks",
"(",
")",
"{",
"$",
"size",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getManialinksToDisplay",
"(",
")",
"as",
"$",
"mlData",
")",
"{",
"$",
"currentSize",
"=",
"$",
"size",
";",
"$",
"size",
"+=",... | Display & hide all manialinks.
@throws \Maniaplanet\DedicatedServer\InvalidArgumentException | [
"Display",
"&",
"hide",
"all",
"manialinks",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/GuiHandler.php#L177-L214 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/GuiHandler.php | GuiHandler.executeMultiCall | protected function executeMultiCall()
{
try {
$this->factory->getConnection()->executeMulticall();
} catch (\Exception $e) {
$this->logger->error("Couldn't deliver all manialinks : ".$e->getMessage(), ['exception' => $e]);
$this->console->writeln('$F00ERROR - Couldn\'t deliver all manialinks : '.$e->getMessage());
}
} | php | protected function executeMultiCall()
{
try {
$this->factory->getConnection()->executeMulticall();
} catch (\Exception $e) {
$this->logger->error("Couldn't deliver all manialinks : ".$e->getMessage(), ['exception' => $e]);
$this->console->writeln('$F00ERROR - Couldn\'t deliver all manialinks : '.$e->getMessage());
}
} | [
"protected",
"function",
"executeMultiCall",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"factory",
"->",
"getConnection",
"(",
")",
"->",
"executeMulticall",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",... | Execute multi call & handle error. | [
"Execute",
"multi",
"call",
"&",
"handle",
"error",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/GuiHandler.php#L219-L227 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/GuiHandler.php | GuiHandler.getManialinksToDisplay | protected function getManialinksToDisplay()
{
foreach ($this->displayQueu as $groupName => $manialinks) {
foreach ($manialinks as $factoryId => $manialink) {
$logins = $manialink->getUserGroup()->getLogins();
$this->displayeds[$groupName][$factoryId] = $manialink;
if (!empty($logins)) {
yield ['logins' => $logins, 'ml' => $manialink->getXml(), "timeout" => $manialink->getTimeout()];
}
}
}
foreach ($this->individualQueu as $manialinks) {
// Fetch all logins
$logins = [];
$lastManialink = null;
foreach ($manialinks as $login => $manialink) {
$logins[] = $login;
$lastManialink = $manialink;
}
if ($lastManialink) {
$xml = $manialink->getXml();
yield ['logins' => $logins, 'ml' => $xml, "timeout" => $manialink->getTimeout()];
}
}
foreach ($this->hideQueu as $manialinks) {
foreach ($manialinks as $manialink) {
$id = $manialink->getId();
$manialink->destroy();
$logins = $manialink->getUserGroup()->getLogins();
$logins = array_diff($logins, $this->disconnectedLogins);
if (!empty($logins)) {
yield ['logins' => $logins, 'ml' => '<manialink id="'.$id.'" />', "timeout" => 0];
}
}
}
foreach ($this->hideIndividualQueu as $id => $manialinks) {
// Fetch all logins.
$logins = [];
$lastManialink = null;
foreach ($manialinks as $login => $manialink) {
if (!in_array($login, $this->disconnectedLogins)) {
$logins[] = $login;
$lastManialink = $manialink;
}
}
if ($lastManialink) {
// Manialink is not destroyed just not shown at a particular user that left the group.
yield ['logins' => $logins, 'ml' => '<manialink id="'.$lastManialink->getId().'" />', "timeout" => 0];
}
}
} | php | protected function getManialinksToDisplay()
{
foreach ($this->displayQueu as $groupName => $manialinks) {
foreach ($manialinks as $factoryId => $manialink) {
$logins = $manialink->getUserGroup()->getLogins();
$this->displayeds[$groupName][$factoryId] = $manialink;
if (!empty($logins)) {
yield ['logins' => $logins, 'ml' => $manialink->getXml(), "timeout" => $manialink->getTimeout()];
}
}
}
foreach ($this->individualQueu as $manialinks) {
// Fetch all logins
$logins = [];
$lastManialink = null;
foreach ($manialinks as $login => $manialink) {
$logins[] = $login;
$lastManialink = $manialink;
}
if ($lastManialink) {
$xml = $manialink->getXml();
yield ['logins' => $logins, 'ml' => $xml, "timeout" => $manialink->getTimeout()];
}
}
foreach ($this->hideQueu as $manialinks) {
foreach ($manialinks as $manialink) {
$id = $manialink->getId();
$manialink->destroy();
$logins = $manialink->getUserGroup()->getLogins();
$logins = array_diff($logins, $this->disconnectedLogins);
if (!empty($logins)) {
yield ['logins' => $logins, 'ml' => '<manialink id="'.$id.'" />', "timeout" => 0];
}
}
}
foreach ($this->hideIndividualQueu as $id => $manialinks) {
// Fetch all logins.
$logins = [];
$lastManialink = null;
foreach ($manialinks as $login => $manialink) {
if (!in_array($login, $this->disconnectedLogins)) {
$logins[] = $login;
$lastManialink = $manialink;
}
}
if ($lastManialink) {
// Manialink is not destroyed just not shown at a particular user that left the group.
yield ['logins' => $logins, 'ml' => '<manialink id="'.$lastManialink->getId().'" />', "timeout" => 0];
}
}
} | [
"protected",
"function",
"getManialinksToDisplay",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"displayQueu",
"as",
"$",
"groupName",
"=>",
"$",
"manialinks",
")",
"{",
"foreach",
"(",
"$",
"manialinks",
"as",
"$",
"factoryId",
"=>",
"$",
"manialink",
... | Get list of all manialinks that needs to be displayed
@return \Generator | [
"Get",
"list",
"of",
"all",
"manialinks",
"that",
"needs",
"to",
"be",
"displayed"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/GuiHandler.php#L234-L292 | train |
JBZoo/Html | src/Render/Button.php | Button.render | public function render($name = '', $content = '', array $attrs = array(), $type = 'submit')
{
$attrs = array_merge(array('text' => null, 'name' => $name), $attrs);
$attrs = $this->_getBtnClasses($attrs);
$attrs['type'] = $type;
if (Arr::key('icon', $attrs)) {
$content = '<i class="' . $this->_icon . '-' . $attrs['icon'] . '"></i> ' . $this->_translate($content);
unset($attrs['icon']);
}
return '<button ' . $this->buildAttrs($attrs) . '>' . $content . '</button>';
} | php | public function render($name = '', $content = '', array $attrs = array(), $type = 'submit')
{
$attrs = array_merge(array('text' => null, 'name' => $name), $attrs);
$attrs = $this->_getBtnClasses($attrs);
$attrs['type'] = $type;
if (Arr::key('icon', $attrs)) {
$content = '<i class="' . $this->_icon . '-' . $attrs['icon'] . '"></i> ' . $this->_translate($content);
unset($attrs['icon']);
}
return '<button ' . $this->buildAttrs($attrs) . '>' . $content . '</button>';
} | [
"public",
"function",
"render",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"content",
"=",
"''",
",",
"array",
"$",
"attrs",
"=",
"array",
"(",
")",
",",
"$",
"type",
"=",
"'submit'",
")",
"{",
"$",
"attrs",
"=",
"array_merge",
"(",
"array",
"(",
"'t... | Crete button.
@param string $name
@param string $content
@param array $attrs
@param string $type
@return string | [
"Crete",
"button",
"."
] | bd61d49a78199f425a2ed3270621e47dff4a014e | https://github.com/JBZoo/Html/blob/bd61d49a78199f425a2ed3270621e47dff4a014e/src/Render/Button.php#L38-L51 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/Search.php | Search.CreatePage | public function CreatePage()
{
$myWords = $this->WordCollection();
$this->_titlePage = $myWords->Value("TITLE", $this->_context->get("SERVER_NAME") );
$this->_abstractPage = $myWords->Value("ABSTRACT", $this->_context->get("SERVER_NAME") );
$this->_document = new XmlnukeDocument($this->_titlePage, $this->_abstractPage);
$this->txtSearch = $this->_context->get("txtSearch");
if ($this->txtSearch != "")
{
$this->Form();
$doc = $this->Find();
}
else
{
$this->Form();
}
return $this->_document->generatePage();
} | php | public function CreatePage()
{
$myWords = $this->WordCollection();
$this->_titlePage = $myWords->Value("TITLE", $this->_context->get("SERVER_NAME") );
$this->_abstractPage = $myWords->Value("ABSTRACT", $this->_context->get("SERVER_NAME") );
$this->_document = new XmlnukeDocument($this->_titlePage, $this->_abstractPage);
$this->txtSearch = $this->_context->get("txtSearch");
if ($this->txtSearch != "")
{
$this->Form();
$doc = $this->Find();
}
else
{
$this->Form();
}
return $this->_document->generatePage();
} | [
"public",
"function",
"CreatePage",
"(",
")",
"{",
"$",
"myWords",
"=",
"$",
"this",
"->",
"WordCollection",
"(",
")",
";",
"$",
"this",
"->",
"_titlePage",
"=",
"$",
"myWords",
"->",
"Value",
"(",
"\"TITLE\"",
",",
"$",
"this",
"->",
"_context",
"->",... | Logic of your module
@return PageXml | [
"Logic",
"of",
"your",
"module"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/Search.php#L160-L181 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/MapListDataProvider.php | MapListDataProvider.updateMapList | protected function updateMapList()
{
$start = 0;
do {
try {
$maps = $this->factory->getConnection()->getMapList(self::BATCH_SIZE, $start);
} catch (IndexOutOfBoundException $e) {
// This is normal error when we we are trying to find all maps and we are out of bounds.
return;
} catch (NextMapException $ex) {
// this is if no maps defined
return;
}
if (!empty($maps)) {
foreach ($maps as $map) {
$this->mapStorage->addMap($map);
}
}
$start += self::BATCH_SIZE;
} while (count($maps) == self::BATCH_SIZE);
} | php | protected function updateMapList()
{
$start = 0;
do {
try {
$maps = $this->factory->getConnection()->getMapList(self::BATCH_SIZE, $start);
} catch (IndexOutOfBoundException $e) {
// This is normal error when we we are trying to find all maps and we are out of bounds.
return;
} catch (NextMapException $ex) {
// this is if no maps defined
return;
}
if (!empty($maps)) {
foreach ($maps as $map) {
$this->mapStorage->addMap($map);
}
}
$start += self::BATCH_SIZE;
} while (count($maps) == self::BATCH_SIZE);
} | [
"protected",
"function",
"updateMapList",
"(",
")",
"{",
"$",
"start",
"=",
"0",
";",
"do",
"{",
"try",
"{",
"$",
"maps",
"=",
"$",
"this",
"->",
"factory",
"->",
"getConnection",
"(",
")",
"->",
"getMapList",
"(",
"self",
"::",
"BATCH_SIZE",
",",
"$... | Update the list of maps in the storage. | [
"Update",
"the",
"list",
"of",
"maps",
"in",
"the",
"storage",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/MapListDataProvider.php#L69-L93 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/GameManiaplanet/DataProviders/MapListDataProvider.php | MapListDataProvider.onMapListModified | public function onMapListModified($curMapIndex, $nextMapIndex, $isListModified)
{
if ($isListModified) {
$oldMaps = $this->mapStorage->getMaps();
$this->mapStorage->resetMapData();
$this->updateMapList();
// We will dispatch even only when list is modified. If not we dispatch specific events.
$this->dispatch(__FUNCTION__, [$oldMaps, $curMapIndex, $nextMapIndex, $isListModified]);
}
try {
$currentMap = $this->factory->getConnection()->getCurrentMapInfo(); // sync better
} catch (\Exception $e) {
// fallback to use map storage
$currentMap = $this->mapStorage->getMapByIndex($curMapIndex);
} // current map can be false if map by index is not found..
if ($currentMap) {
if ($this->mapStorage->getCurrentMap()->uId != $currentMap->uId) {
$previousMap = $this->mapStorage->getCurrentMap();
$this->mapStorage->setCurrentMap($currentMap);
$this->dispatch('onExpansionMapChange', [$currentMap, $previousMap]);
}
}
try {
$nextMap = $this->factory->getConnection()->getNextMapInfo(); // sync better
} catch (\Exception $e) {
// fallback to use map storage
$nextMap = $this->mapStorage->getMapByIndex($nextMapIndex);
}
// next map can be false if map by index is not found..
if ($nextMap) {
if ($this->mapStorage->getNextMap()->uId != $nextMap->uId) {
$previousNextMap = $this->mapStorage->getNextMap();
$this->mapStorage->setNextMap($nextMap);
$this->dispatch('onExpansionNextMapChange', [$nextMap, $previousNextMap]);
}
}
} | php | public function onMapListModified($curMapIndex, $nextMapIndex, $isListModified)
{
if ($isListModified) {
$oldMaps = $this->mapStorage->getMaps();
$this->mapStorage->resetMapData();
$this->updateMapList();
// We will dispatch even only when list is modified. If not we dispatch specific events.
$this->dispatch(__FUNCTION__, [$oldMaps, $curMapIndex, $nextMapIndex, $isListModified]);
}
try {
$currentMap = $this->factory->getConnection()->getCurrentMapInfo(); // sync better
} catch (\Exception $e) {
// fallback to use map storage
$currentMap = $this->mapStorage->getMapByIndex($curMapIndex);
} // current map can be false if map by index is not found..
if ($currentMap) {
if ($this->mapStorage->getCurrentMap()->uId != $currentMap->uId) {
$previousMap = $this->mapStorage->getCurrentMap();
$this->mapStorage->setCurrentMap($currentMap);
$this->dispatch('onExpansionMapChange', [$currentMap, $previousMap]);
}
}
try {
$nextMap = $this->factory->getConnection()->getNextMapInfo(); // sync better
} catch (\Exception $e) {
// fallback to use map storage
$nextMap = $this->mapStorage->getMapByIndex($nextMapIndex);
}
// next map can be false if map by index is not found..
if ($nextMap) {
if ($this->mapStorage->getNextMap()->uId != $nextMap->uId) {
$previousNextMap = $this->mapStorage->getNextMap();
$this->mapStorage->setNextMap($nextMap);
$this->dispatch('onExpansionNextMapChange', [$nextMap, $previousNextMap]);
}
}
} | [
"public",
"function",
"onMapListModified",
"(",
"$",
"curMapIndex",
",",
"$",
"nextMapIndex",
",",
"$",
"isListModified",
")",
"{",
"if",
"(",
"$",
"isListModified",
")",
"{",
"$",
"oldMaps",
"=",
"$",
"this",
"->",
"mapStorage",
"->",
"getMaps",
"(",
")",... | Called when map list is modified.
@param $curMapIndex
@param $nextMapIndex
@param $isListModified | [
"Called",
"when",
"map",
"list",
"is",
"modified",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/GameManiaplanet/DataProviders/MapListDataProvider.php#L103-L145 | train |
spekulatius/silverstripe-timezones | code/tasks/PopulateTimeZonesTask.php | PopulateTimeZonesTask.rebuildTitles | protected function rebuildTitles()
{
// Update the Title field in the dataobjects. This saves the time to build the title dynamically each time.
foreach (TimeZoneData::get() as $tz) {
$newTitle = $tz->prepareTitle();
if ($newTitle != $tz->Title) {
$tz->Title = $newTitle;
$tz->write();
}
}
} | php | protected function rebuildTitles()
{
// Update the Title field in the dataobjects. This saves the time to build the title dynamically each time.
foreach (TimeZoneData::get() as $tz) {
$newTitle = $tz->prepareTitle();
if ($newTitle != $tz->Title) {
$tz->Title = $newTitle;
$tz->write();
}
}
} | [
"protected",
"function",
"rebuildTitles",
"(",
")",
"{",
"// Update the Title field in the dataobjects. This saves the time to build the title dynamically each time.",
"foreach",
"(",
"TimeZoneData",
"::",
"get",
"(",
")",
"as",
"$",
"tz",
")",
"{",
"$",
"newTitle",
"=",
... | Rebuilds the title in the dataobjects | [
"Rebuilds",
"the",
"title",
"in",
"the",
"dataobjects"
] | 61702bafd2288589f8b87c0c55cdb972c17e05e9 | https://github.com/spekulatius/silverstripe-timezones/blob/61702bafd2288589f8b87c0c55cdb972c17e05e9/code/tasks/PopulateTimeZonesTask.php#L114-L124 | train |
spekulatius/silverstripe-timezones | code/tasks/PopulateTimeZonesTask.php | PopulateTimeZonesTask.message | protected function message($text)
{
if (Controller::curr() instanceof DatabaseAdmin) {
DB::alteration_message($text, 'obsolete');
} else {
Debug::message($text);
}
} | php | protected function message($text)
{
if (Controller::curr() instanceof DatabaseAdmin) {
DB::alteration_message($text, 'obsolete');
} else {
Debug::message($text);
}
} | [
"protected",
"function",
"message",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"Controller",
"::",
"curr",
"(",
")",
"instanceof",
"DatabaseAdmin",
")",
"{",
"DB",
"::",
"alteration_message",
"(",
"$",
"text",
",",
"'obsolete'",
")",
";",
"}",
"else",
"{",
... | prints a message during the run of the task
@param string $text | [
"prints",
"a",
"message",
"during",
"the",
"run",
"of",
"the",
"task"
] | 61702bafd2288589f8b87c0c55cdb972c17e05e9 | https://github.com/spekulatius/silverstripe-timezones/blob/61702bafd2288589f8b87c0c55cdb972c17e05e9/code/tasks/PopulateTimeZonesTask.php#L131-L138 | train |
anklimsk/cakephp-theme | Controller/EventsController.php | EventsController.ssecfg | public function ssecfg() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = $this->ConfigTheme->getSseConfig();
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | public function ssecfg() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = $this->ConfigTheme->getSseConfig();
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | [
"public",
"function",
"ssecfg",
"(",
")",
"{",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
"||",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",... | Action `ssecfg`. Is used to get configuration for SSE object
@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void | [
"Action",
"ssecfg",
".",
"Is",
"used",
"to",
"get",
"configuration",
"for",
"SSE",
"object"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/EventsController.php#L77-L87 | train |
anklimsk/cakephp-theme | Controller/EventsController.php | EventsController.tasks | public function tasks() {
$this->response->disableCache();
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = [
'result' => false,
'tasks' => []
];
$delete = (bool)$this->request->data('delete');
if ($delete) {
$tasks = $this->request->data('tasks');
$data['result'] = $this->SseTask->deleteQueuedTask($tasks);
} else {
$tasks = $this->SseTask->getListQueuedTask();
$data['tasks'] = $tasks;
$data['result'] = !empty($tasks);
}
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | public function tasks() {
$this->response->disableCache();
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = [
'result' => false,
'tasks' => []
];
$delete = (bool)$this->request->data('delete');
if ($delete) {
$tasks = $this->request->data('tasks');
$data['result'] = $this->SseTask->deleteQueuedTask($tasks);
} else {
$tasks = $this->SseTask->getListQueuedTask();
$data['tasks'] = $tasks;
$data['result'] = !empty($tasks);
}
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | [
"public",
"function",
"tasks",
"(",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"disableCache",
"(",
")",
";",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'... | Action `tasks`. Is used to get list of queued tasks
POST Data array:
- `tasks` The name task to obtain list of tasks.
- `delete` If True, delete task from session.
@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void | [
"Action",
"tasks",
".",
"Is",
"used",
"to",
"get",
"list",
"of",
"queued",
"tasks"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/EventsController.php#L100-L123 | train |
anklimsk/cakephp-theme | Controller/EventsController.php | EventsController.queue | public function queue($type = null, $retry = 3000) {
$this->response->disableCache();
Configure::write('debug', 0);
if (!$this->request->is('sse')) {
throw new BadRequestException();
}
$type = (string)$type;
$result = [
'type' => '',
'progress' => 0,
'msg' => '',
'result' => null
];
$event = 'progressBar';
$retry = (int)$retry;
if (empty($type)) {
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
return;
}
$timestamp = null;
$workermaxruntime = (int)Configure::read('Queue.workermaxruntime');
if ($workermaxruntime > 0) {
$timestamp = time() - $workermaxruntime;
}
$jobInfo = $this->ExtendQueuedTask->getPendingJob($type, true, $timestamp);
if (empty($jobInfo)) {
$result['type'] = $type;
$result['result'] = false;
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
return;
}
switch ($jobInfo['ExtendQueuedTask']['status']) {
case 'COMPLETED':
$resultFlag = true;
break;
case 'NOT_READY':
case 'NOT_STARTED':
case 'FAILED':
case 'UNKNOWN':
$resultFlag = false;
break;
case 'IN_PROGRESS':
default:
$resultFlag = null;
}
$result['type'] = $type;
$result['progress'] = (float)$jobInfo['ExtendQueuedTask']['progress'];
$result['msg'] = (string)$jobInfo['ExtendQueuedTask']['failure_message'];
$result['result'] = $resultFlag;
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
} | php | public function queue($type = null, $retry = 3000) {
$this->response->disableCache();
Configure::write('debug', 0);
if (!$this->request->is('sse')) {
throw new BadRequestException();
}
$type = (string)$type;
$result = [
'type' => '',
'progress' => 0,
'msg' => '',
'result' => null
];
$event = 'progressBar';
$retry = (int)$retry;
if (empty($type)) {
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
return;
}
$timestamp = null;
$workermaxruntime = (int)Configure::read('Queue.workermaxruntime');
if ($workermaxruntime > 0) {
$timestamp = time() - $workermaxruntime;
}
$jobInfo = $this->ExtendQueuedTask->getPendingJob($type, true, $timestamp);
if (empty($jobInfo)) {
$result['type'] = $type;
$result['result'] = false;
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
return;
}
switch ($jobInfo['ExtendQueuedTask']['status']) {
case 'COMPLETED':
$resultFlag = true;
break;
case 'NOT_READY':
case 'NOT_STARTED':
case 'FAILED':
case 'UNKNOWN':
$resultFlag = false;
break;
case 'IN_PROGRESS':
default:
$resultFlag = null;
}
$result['type'] = $type;
$result['progress'] = (float)$jobInfo['ExtendQueuedTask']['progress'];
$result['msg'] = (string)$jobInfo['ExtendQueuedTask']['failure_message'];
$result['result'] = $resultFlag;
$data = json_encode($result);
$this->set(compact('retry', 'data', 'event'));
} | [
"public",
"function",
"queue",
"(",
"$",
"type",
"=",
"null",
",",
"$",
"retry",
"=",
"3000",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"disableCache",
"(",
")",
";",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"if",
"(",
... | Action `queue`. Is used to Server-Sent Events.
@param string $type Type of task
@param int $retry Repeat time of events
@throws BadRequestException if request is not `SSE`
@return void | [
"Action",
"queue",
".",
"Is",
"used",
"to",
"Server",
"-",
"Sent",
"Events",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/EventsController.php#L133-L191 | train |
TheBnl/event-tickets | code/forms/CheckInValidator.php | CheckInValidator.validate | public function validate($ticketCode = null)
{
if (filter_var($ticketCode, FILTER_VALIDATE_URL)) {
$asURL = explode('/', parse_url($ticketCode, PHP_URL_PATH));
$ticketCode = end($asURL);
}
// Check if a code is given to the validator
if (!isset($ticketCode)) {
return $result = array(
'Code' => self::MESSAGE_NO_CODE,
'Message' => self::message(self::MESSAGE_NO_CODE, $ticketCode),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => null
);
}
// Check if a ticket exists with the given ticket code
if (!$this->attendee = Attendee::get()->find('TicketCode', $ticketCode)) {
return $result = array(
'Code' => self::MESSAGE_CODE_NOT_FOUND,
'Message' => self::message(self::MESSAGE_CODE_NOT_FOUND, $ticketCode),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => null
);
} else {
$name = $this->attendee->getName();
}
// Check if the reservation is not canceled
if (!(bool)$this->attendee->Event()->getGuestList()->find('ID', $this->attendee->ID)) {
return $result = array(
'Code' => self::MESSAGE_TICKET_CANCELLED,
'Message' => self::message(self::MESSAGE_TICKET_CANCELLED, $name),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Check if the ticket is already checked in and not allowed to check out
elseif ((bool)$this->attendee->CheckedIn && !(bool)self::config()->get('allow_checkout')) {
return $result = array(
'Code' => self::MESSAGE_ALREADY_CHECKED_IN,
'Message' => self::message(self::MESSAGE_ALREADY_CHECKED_IN, $name),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Successfully checked out
elseif ((bool)$this->attendee->CheckedIn && (bool)self::config()->get('allow_checkout')) {
return $result = array(
'Code' => self::MESSAGE_CHECK_OUT_SUCCESS,
'Message' => self::message(self::MESSAGE_CHECK_OUT_SUCCESS, $name),
'Type' => self::MESSAGE_TYPE_WARNING,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Successfully checked in
else {
return $result = array(
'Code' => self::MESSAGE_CHECK_IN_SUCCESS,
'Message' => self::message(self::MESSAGE_CHECK_IN_SUCCESS, $name),
'Type' => self::MESSAGE_TYPE_GOOD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
} | php | public function validate($ticketCode = null)
{
if (filter_var($ticketCode, FILTER_VALIDATE_URL)) {
$asURL = explode('/', parse_url($ticketCode, PHP_URL_PATH));
$ticketCode = end($asURL);
}
// Check if a code is given to the validator
if (!isset($ticketCode)) {
return $result = array(
'Code' => self::MESSAGE_NO_CODE,
'Message' => self::message(self::MESSAGE_NO_CODE, $ticketCode),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => null
);
}
// Check if a ticket exists with the given ticket code
if (!$this->attendee = Attendee::get()->find('TicketCode', $ticketCode)) {
return $result = array(
'Code' => self::MESSAGE_CODE_NOT_FOUND,
'Message' => self::message(self::MESSAGE_CODE_NOT_FOUND, $ticketCode),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => null
);
} else {
$name = $this->attendee->getName();
}
// Check if the reservation is not canceled
if (!(bool)$this->attendee->Event()->getGuestList()->find('ID', $this->attendee->ID)) {
return $result = array(
'Code' => self::MESSAGE_TICKET_CANCELLED,
'Message' => self::message(self::MESSAGE_TICKET_CANCELLED, $name),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Check if the ticket is already checked in and not allowed to check out
elseif ((bool)$this->attendee->CheckedIn && !(bool)self::config()->get('allow_checkout')) {
return $result = array(
'Code' => self::MESSAGE_ALREADY_CHECKED_IN,
'Message' => self::message(self::MESSAGE_ALREADY_CHECKED_IN, $name),
'Type' => self::MESSAGE_TYPE_BAD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Successfully checked out
elseif ((bool)$this->attendee->CheckedIn && (bool)self::config()->get('allow_checkout')) {
return $result = array(
'Code' => self::MESSAGE_CHECK_OUT_SUCCESS,
'Message' => self::message(self::MESSAGE_CHECK_OUT_SUCCESS, $name),
'Type' => self::MESSAGE_TYPE_WARNING,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
// Successfully checked in
else {
return $result = array(
'Code' => self::MESSAGE_CHECK_IN_SUCCESS,
'Message' => self::message(self::MESSAGE_CHECK_IN_SUCCESS, $name),
'Type' => self::MESSAGE_TYPE_GOOD,
'Ticket' => $ticketCode,
'Attendee' => $this->attendee
);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"ticketCode",
"=",
"null",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"ticketCode",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"$",
"asURL",
"=",
"explode",
"(",
"'/'",
",",
"parse_url",
"(",
"$",
"ticketCode... | Validate the given ticket code
@param null|string $ticketCode
@return array | [
"Validate",
"the",
"given",
"ticket",
"code"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/forms/CheckInValidator.php#L47-L121 | train |
linna/typed-array | src/TypedArray.php | TypedArray.offsetSet | public function offsetSet($index, $newval)
{
if ($newval instanceof $this->type) {
parent::offsetSet($index, $newval);
return;
}
if ($this->allowedTypes[$this->type]($newval)) {
parent::offsetSet($index, $newval);
return;
}
throw new InvalidArgumentException(__CLASS__.': Elements passed to '.__CLASS__.' must be of the type '.$this->type.'.');
} | php | public function offsetSet($index, $newval)
{
if ($newval instanceof $this->type) {
parent::offsetSet($index, $newval);
return;
}
if ($this->allowedTypes[$this->type]($newval)) {
parent::offsetSet($index, $newval);
return;
}
throw new InvalidArgumentException(__CLASS__.': Elements passed to '.__CLASS__.' must be of the type '.$this->type.'.');
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"newval",
")",
"{",
"if",
"(",
"$",
"newval",
"instanceof",
"$",
"this",
"->",
"type",
")",
"{",
"parent",
"::",
"offsetSet",
"(",
"$",
"index",
",",
"$",
"newval",
")",
";",
"return",
... | Array style value assignment.
@ignore
@param mixed $index
@param mixed $newval
@throws InvalidArgumentException If value passed with $newval are not of the configured type
@return void | [
"Array",
"style",
"value",
"assignment",
"."
] | 0d76185485b6dcfa6ea9e109a5d756782ee56b2c | https://github.com/linna/typed-array/blob/0d76185485b6dcfa6ea9e109a5d756782ee56b2c/src/TypedArray.php#L122-L137 | train |
rokka-io/rokka-client-php-cli | src/Command/ImageListCommand.php | ImageListCommand.buildSearchParameter | protected function buildSearchParameter(array $searchFilters)
{
$search = [];
foreach ($searchFilters as $filter) {
$parts = explode(' ', trim($filter), 2);
if (empty($parts) || 2 !== \count($parts)) {
continue;
}
$search[$parts[0]] = $parts[1];
}
return $search;
} | php | protected function buildSearchParameter(array $searchFilters)
{
$search = [];
foreach ($searchFilters as $filter) {
$parts = explode(' ', trim($filter), 2);
if (empty($parts) || 2 !== \count($parts)) {
continue;
}
$search[$parts[0]] = $parts[1];
}
return $search;
} | [
"protected",
"function",
"buildSearchParameter",
"(",
"array",
"$",
"searchFilters",
")",
"{",
"$",
"search",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"searchFilters",
"as",
"$",
"filter",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"trim",
... | Builds the "search" parameter as required bu the Rokka client.
@param array $searchFilters
@return array | [
"Builds",
"the",
"search",
"parameter",
"as",
"required",
"bu",
"the",
"Rokka",
"client",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/Command/ImageListCommand.php#L67-L80 | train |
rokka-io/rokka-client-php-cli | src/Command/ImageListCommand.php | ImageListCommand.buildSortParameter | protected function buildSortParameter(array $sorts)
{
$sorting = [];
foreach ($sorts as $sort) {
$parts = explode(' ', trim($sort), 2);
if (empty($parts)) {
continue;
}
if (1 === \count($parts)) {
$sorting[$parts[0]] = true;
} else {
$sorting[$parts[0]] = $parts[1];
}
}
return $sorting;
} | php | protected function buildSortParameter(array $sorts)
{
$sorting = [];
foreach ($sorts as $sort) {
$parts = explode(' ', trim($sort), 2);
if (empty($parts)) {
continue;
}
if (1 === \count($parts)) {
$sorting[$parts[0]] = true;
} else {
$sorting[$parts[0]] = $parts[1];
}
}
return $sorting;
} | [
"protected",
"function",
"buildSortParameter",
"(",
"array",
"$",
"sorts",
")",
"{",
"$",
"sorting",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"sorts",
"as",
"$",
"sort",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"so... | Builds the "sort" parameter as required bu the Rokka client.
@param array $sorts
@return array | [
"Builds",
"the",
"sort",
"parameter",
"as",
"required",
"bu",
"the",
"Rokka",
"client",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/Command/ImageListCommand.php#L89-L107 | train |
k-gun/oppa | src/Agent/AgentCrud.php | AgentCrud.getAll | public final function getAll(string $query, array $queryParams = null, string $fetchClass = null): array
{
return $this->query($query, $queryParams, null, $fetchClass)->getData();
} | php | public final function getAll(string $query, array $queryParams = null, string $fetchClass = null): array
{
return $this->query($query, $queryParams, null, $fetchClass)->getData();
} | [
"public",
"final",
"function",
"getAll",
"(",
"string",
"$",
"query",
",",
"array",
"$",
"queryParams",
"=",
"null",
",",
"string",
"$",
"fetchClass",
"=",
"null",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
",",
... | Get all.
@param string $query
@param array $queryParams
@param string $fetchClass
@return array
@throws Oppa\Exception\{InvalidQueryException, InvalidResourceException, QueryException} | [
"Get",
"all",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/AgentCrud.php#L189-L192 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php | Registry.hasLogger | public static function hasLogger($logger)
{
if ($logger instanceof Logger) {
$index = array_search($logger, self::$loggers, true);
return false !== $index;
} else {
return isset(self::$loggers[$logger]);
}
} | php | public static function hasLogger($logger)
{
if ($logger instanceof Logger) {
$index = array_search($logger, self::$loggers, true);
return false !== $index;
} else {
return isset(self::$loggers[$logger]);
}
} | [
"public",
"static",
"function",
"hasLogger",
"(",
"$",
"logger",
")",
"{",
"if",
"(",
"$",
"logger",
"instanceof",
"Logger",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"logger",
",",
"self",
"::",
"$",
"loggers",
",",
"true",
")",
";",
"r... | Checks if such logging channel exists by name or instance
@param string|Logger $logger Name or logger instance | [
"Checks",
"if",
"such",
"logging",
"channel",
"exists",
"by",
"name",
"or",
"instance"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php#L71-L80 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php | Registry.removeLogger | public static function removeLogger($logger)
{
if ($logger instanceof Logger) {
if (false !== ($idx = array_search($logger, self::$loggers, true))) {
unset(self::$loggers[$idx]);
}
} else {
unset(self::$loggers[$logger]);
}
} | php | public static function removeLogger($logger)
{
if ($logger instanceof Logger) {
if (false !== ($idx = array_search($logger, self::$loggers, true))) {
unset(self::$loggers[$idx]);
}
} else {
unset(self::$loggers[$logger]);
}
} | [
"public",
"static",
"function",
"removeLogger",
"(",
"$",
"logger",
")",
"{",
"if",
"(",
"$",
"logger",
"instanceof",
"Logger",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"idx",
"=",
"array_search",
"(",
"$",
"logger",
",",
"self",
"::",
"$",
"lo... | Removes instance from registry by name or instance
@param string|Logger $logger Name or logger instance | [
"Removes",
"instance",
"from",
"registry",
"by",
"name",
"or",
"instance"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php#L87-L96 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php | Registry.getInstance | public static function getInstance($name)
{
if (!isset(self::$loggers[$name])) {
throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name));
}
return self::$loggers[$name];
} | php | public static function getInstance($name)
{
if (!isset(self::$loggers[$name])) {
throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name));
}
return self::$loggers[$name];
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"loggers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Requested \"%s... | Gets Logger instance from the registry
@param string $name Name of the requested Logger instance
@throws \InvalidArgumentException If named Logger instance is not in the registry
@return Logger Requested instance of Logger | [
"Gets",
"Logger",
"instance",
"from",
"the",
"registry"
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Registry.php#L113-L120 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/symfony/process/Pipes/AbstractPipes.php | AbstractPipes.unblock | protected function unblock()
{
if (!$this->blocked) {
return;
}
foreach ($this->pipes as $pipe) {
stream_set_blocking($pipe, 0);
}
if (is_resource($this->input)) {
stream_set_blocking($this->input, 0);
}
$this->blocked = false;
} | php | protected function unblock()
{
if (!$this->blocked) {
return;
}
foreach ($this->pipes as $pipe) {
stream_set_blocking($pipe, 0);
}
if (is_resource($this->input)) {
stream_set_blocking($this->input, 0);
}
$this->blocked = false;
} | [
"protected",
"function",
"unblock",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"blocked",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"pipes",
"as",
"$",
"pipe",
")",
"{",
"stream_set_blocking",
"(",
"$",
"pipe",
",",
"0... | Unblocks streams. | [
"Unblocks",
"streams",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/symfony/process/Pipes/AbstractPipes.php#L71-L85 | train |
dfeyer/Ttree.Oembed | Classes/Discoverer.php | Discoverer.getEndpointForUrl | public function getEndpointForUrl($url)
{
$cacheKey = sha1($url . $this->preferredFormat . json_encode($this->supportedFormats));
if (!isset($this->cachedEndpoints[$url])) {
$this->cachedEndpoints[$url] = $this->fetchEndpointForUrl($url);
if (trim($this->cachedEndpoints[$url]) === '') {
throw new Exception('Empty url endpoints', 1360175845);
}
$this->endPointCache->set($cacheKey, $this->cachedEndpoints[$url]);
} elseif ($this->endPointCache->has($cacheKey) === true) {
$this->cachedEndpoints[$url] = $this->endPointCache->get($cacheKey);
}
return $this->cachedEndpoints[$url];
} | php | public function getEndpointForUrl($url)
{
$cacheKey = sha1($url . $this->preferredFormat . json_encode($this->supportedFormats));
if (!isset($this->cachedEndpoints[$url])) {
$this->cachedEndpoints[$url] = $this->fetchEndpointForUrl($url);
if (trim($this->cachedEndpoints[$url]) === '') {
throw new Exception('Empty url endpoints', 1360175845);
}
$this->endPointCache->set($cacheKey, $this->cachedEndpoints[$url]);
} elseif ($this->endPointCache->has($cacheKey) === true) {
$this->cachedEndpoints[$url] = $this->endPointCache->get($cacheKey);
}
return $this->cachedEndpoints[$url];
} | [
"public",
"function",
"getEndpointForUrl",
"(",
"$",
"url",
")",
"{",
"$",
"cacheKey",
"=",
"sha1",
"(",
"$",
"url",
".",
"$",
"this",
"->",
"preferredFormat",
".",
"json_encode",
"(",
"$",
"this",
"->",
"supportedFormats",
")",
")",
";",
"if",
"(",
"!... | Get the provider's endpoint URL for the supplied resource.
@param string $url The URL to get the endpoint's URL for.
@return string
@throws Exception | [
"Get",
"the",
"provider",
"s",
"endpoint",
"URL",
"for",
"the",
"supplied",
"resource",
"."
] | 1f38d18f51c1abe96c19fe4760acc9ef907194df | https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Discoverer.php#L72-L87 | train |
dfeyer/Ttree.Oembed | Classes/Discoverer.php | Discoverer.fetchEndpointForUrl | protected function fetchEndpointForUrl($url)
{
$endPoint = null;
try {
$content = $this->browser->getContent($url);
} catch (Exception $exception) {
throw new Exception(
'Unable to fetch the page body for "' . $url . '": ' . $exception->getMessage(),
Exception::PAGE_BODY_FETCH_FAILED
);
}
preg_match_all("/<link rel=\"alternate\"[^>]+>/i",
$content,
$out);
if ($out[0]) {
foreach ($out[0] as $link) {
if (strpos($link, trim($this->preferredFormat . '+oembed')) !== false) {
$endPoint = $this->extractEndpointFromAttributes($link);
break;
}
}
} else {
throw new Exception(
'No valid oEmbed links found on the document at "' . $url . '".',
Exception::NO_OEMBED_LINKS_FOUND
);
}
return $endPoint;
} | php | protected function fetchEndpointForUrl($url)
{
$endPoint = null;
try {
$content = $this->browser->getContent($url);
} catch (Exception $exception) {
throw new Exception(
'Unable to fetch the page body for "' . $url . '": ' . $exception->getMessage(),
Exception::PAGE_BODY_FETCH_FAILED
);
}
preg_match_all("/<link rel=\"alternate\"[^>]+>/i",
$content,
$out);
if ($out[0]) {
foreach ($out[0] as $link) {
if (strpos($link, trim($this->preferredFormat . '+oembed')) !== false) {
$endPoint = $this->extractEndpointFromAttributes($link);
break;
}
}
} else {
throw new Exception(
'No valid oEmbed links found on the document at "' . $url . '".',
Exception::NO_OEMBED_LINKS_FOUND
);
}
return $endPoint;
} | [
"protected",
"function",
"fetchEndpointForUrl",
"(",
"$",
"url",
")",
"{",
"$",
"endPoint",
"=",
"null",
";",
"try",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"browser",
"->",
"getContent",
"(",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"Exception",
... | Fetch the provider's endpoint URL for the supplied resource.
@param string $url The provider's endpoint URL for the supplied resource.
@return string
@throws \Ttree\Oembed\Exception
@todo is not endpoint is found try other format (supportedFormat) | [
"Fetch",
"the",
"provider",
"s",
"endpoint",
"URL",
"for",
"the",
"supplied",
"resource",
"."
] | 1f38d18f51c1abe96c19fe4760acc9ef907194df | https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Discoverer.php#L97-L128 | train |
ansas/php-component | src/Slim/Handler/FlashHandler.php | FlashHandler.all | public function all()
{
return array_merge($this->messages[self::DURABLE], $this->messages[self::NOW]);
} | php | public function all()
{
return array_merge($this->messages[self::DURABLE], $this->messages[self::NOW]);
} | [
"public",
"function",
"all",
"(",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"messages",
"[",
"self",
"::",
"DURABLE",
"]",
",",
"$",
"this",
"->",
"messages",
"[",
"self",
"::",
"NOW",
"]",
")",
";",
"}"
] | Get all messages.
@return string[] | [
"Get",
"all",
"messages",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/FlashHandler.php#L157-L160 | train |
ansas/php-component | src/Slim/Handler/FlashHandler.php | FlashHandler.load | protected function load()
{
$this->reset();
$messages = $this->cookie->get($this->cookieKey);
if ($messages) {
$messages = json_decode($messages, true);
if (!empty($messages[self::DURABLE])) {
$this->messages[self::DURABLE] = $messages[self::DURABLE];
}
if (!empty($messages[self::NEXT])) {
$this->messages[self::NOW] = $messages[self::NEXT];
}
$this->save();
}
return $this;
} | php | protected function load()
{
$this->reset();
$messages = $this->cookie->get($this->cookieKey);
if ($messages) {
$messages = json_decode($messages, true);
if (!empty($messages[self::DURABLE])) {
$this->messages[self::DURABLE] = $messages[self::DURABLE];
}
if (!empty($messages[self::NEXT])) {
$this->messages[self::NOW] = $messages[self::NEXT];
}
$this->save();
}
return $this;
} | [
"protected",
"function",
"load",
"(",
")",
"{",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"$",
"messages",
"=",
"$",
"this",
"->",
"cookie",
"->",
"get",
"(",
"$",
"this",
"->",
"cookieKey",
")",
";",
"if",
"(",
"$",
"messages",
")",
"{",
"$",
... | Load messages from cookie.
@return $this | [
"Load",
"messages",
"from",
"cookie",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/FlashHandler.php#L233-L253 | train |
ansas/php-component | src/Slim/Handler/FlashHandler.php | FlashHandler.reset | public function reset()
{
$this->messages = [];
foreach (self::$when as $when) {
$this->messages[$when] = [];
}
return $this;
} | php | public function reset()
{
$this->messages = [];
foreach (self::$when as $when) {
$this->messages[$when] = [];
}
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"messages",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"when",
"as",
"$",
"when",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"$",
"when",
"]",
"=",
"[",
"]",
";",
... | Reset messages and build array structure.
@return $this | [
"Reset",
"messages",
"and",
"build",
"array",
"structure",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/FlashHandler.php#L333-L342 | train |
ansas/php-component | src/Slim/Handler/FlashHandler.php | FlashHandler.save | protected function save()
{
$messages = [];
foreach ([self::DURABLE, self::NEXT] as $when) {
if (!empty($this->messages[$when])) {
$messages[$when] = $this->messages[$when];
}
}
if ($messages) {
$messages = json_encode($messages);
$this->cookie->set($this->cookieKey, $messages);
} else {
$this->cookie->remove($this->cookieKey);
}
return $this;
} | php | protected function save()
{
$messages = [];
foreach ([self::DURABLE, self::NEXT] as $when) {
if (!empty($this->messages[$when])) {
$messages[$when] = $this->messages[$when];
}
}
if ($messages) {
$messages = json_encode($messages);
$this->cookie->set($this->cookieKey, $messages);
} else {
$this->cookie->remove($this->cookieKey);
}
return $this;
} | [
"protected",
"function",
"save",
"(",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"foreach",
"(",
"[",
"self",
"::",
"DURABLE",
",",
"self",
"::",
"NEXT",
"]",
"as",
"$",
"when",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"me... | Save messages to cookie.
@return $this | [
"Save",
"messages",
"to",
"cookie",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Slim/Handler/FlashHandler.php#L349-L366 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/symfony/process/ProcessBuilder.php | ProcessBuilder.setTimeout | public function setTimeout($timeout)
{
if (null === $timeout) {
$this->timeout = null;
return $this;
}
$timeout = (float) $timeout;
if ($timeout < 0) {
throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
}
$this->timeout = $timeout;
return $this;
} | php | public function setTimeout($timeout)
{
if (null === $timeout) {
$this->timeout = null;
return $this;
}
$timeout = (float) $timeout;
if ($timeout < 0) {
throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
}
$this->timeout = $timeout;
return $this;
} | [
"public",
"function",
"setTimeout",
"(",
"$",
"timeout",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"timeout",
")",
"{",
"$",
"this",
"->",
"timeout",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"$",
"timeout",
"=",
"(",
"float",
")",
"$",
"... | Sets the process timeout.
To disable the timeout, set this value to null.
@param float|null $timeout
@return ProcessBuilder
@throws InvalidArgumentException | [
"Sets",
"the",
"process",
"timeout",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/symfony/process/ProcessBuilder.php#L194-L211 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.setupLogging | public function setupLogging(LoggerInterface $logger, array $incrementalAttributesToLog = ['dn'])
{
if (empty($incrementalAttributesToLog)) {
throw new InvalidArgumentException('List of entry attributes to be logged during incremental sync cannot be empty');
}
$this->logger = $logger;
$this->incrementalAttributesToLog = $incrementalAttributesToLog;
} | php | public function setupLogging(LoggerInterface $logger, array $incrementalAttributesToLog = ['dn'])
{
if (empty($incrementalAttributesToLog)) {
throw new InvalidArgumentException('List of entry attributes to be logged during incremental sync cannot be empty');
}
$this->logger = $logger;
$this->incrementalAttributesToLog = $incrementalAttributesToLog;
} | [
"public",
"function",
"setupLogging",
"(",
"LoggerInterface",
"$",
"logger",
",",
"array",
"$",
"incrementalAttributesToLog",
"=",
"[",
"'dn'",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"incrementalAttributesToLog",
")",
")",
"{",
"throw",
"new",
"InvalidAr... | Enables and adjusts logging
@param LoggerInterface $logger
@param array $incrementalAttributesToLog
@throws InvalidArgumentException in case of empty $incrementalAttributesToLog | [
"Enables",
"and",
"adjusts",
"logging"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L123-L130 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.poll | public function poll($forceFullSync = false)
{
/** @var PollTaskRepository $pollTaskRepository */
$pollTaskRepository = $this->entityManager->getRepository(PollTask::class);
$lastSuccessfulPollTask = $pollTaskRepository->findLastSuccessfulForPoller($this->getName());
$rootDseDnsHostName = $this->fetcher->getRootDseDnsHostName();
$invocationId = $this->fetcher->getInvocationId();
$isFullSyncRequired = $this->isFullSyncRequired($forceFullSync, $lastSuccessfulPollTask, $rootDseDnsHostName, $invocationId);
$highestCommitedUSN = $this->fetcher->getHighestCommittedUSN();
$currentTask = $this->createCurrentPollTask(
$invocationId,
$highestCommitedUSN,
$rootDseDnsHostName,
$lastSuccessfulPollTask,
$isFullSyncRequired
);
$this->entityManager->persist($currentTask);
$this->entityManager->flush();
try {
if ($isFullSyncRequired) {
$fetchedEntriesCount = $this->fullSync($currentTask, $highestCommitedUSN);
} else {
$usnChangedStartFrom = $lastSuccessfulPollTask->getMaxUSNChangedValue() + 1;
$fetchedEntriesCount = $this->incrementalSync($currentTask, $usnChangedStartFrom, $highestCommitedUSN);
}
$currentTask->succeed($fetchedEntriesCount);
return $fetchedEntriesCount;
} catch (Exception $e) {
$currentTask->fail($e->getMessage());
throw $e;
} finally {
$this->entityManager->flush();
}
} | php | public function poll($forceFullSync = false)
{
/** @var PollTaskRepository $pollTaskRepository */
$pollTaskRepository = $this->entityManager->getRepository(PollTask::class);
$lastSuccessfulPollTask = $pollTaskRepository->findLastSuccessfulForPoller($this->getName());
$rootDseDnsHostName = $this->fetcher->getRootDseDnsHostName();
$invocationId = $this->fetcher->getInvocationId();
$isFullSyncRequired = $this->isFullSyncRequired($forceFullSync, $lastSuccessfulPollTask, $rootDseDnsHostName, $invocationId);
$highestCommitedUSN = $this->fetcher->getHighestCommittedUSN();
$currentTask = $this->createCurrentPollTask(
$invocationId,
$highestCommitedUSN,
$rootDseDnsHostName,
$lastSuccessfulPollTask,
$isFullSyncRequired
);
$this->entityManager->persist($currentTask);
$this->entityManager->flush();
try {
if ($isFullSyncRequired) {
$fetchedEntriesCount = $this->fullSync($currentTask, $highestCommitedUSN);
} else {
$usnChangedStartFrom = $lastSuccessfulPollTask->getMaxUSNChangedValue() + 1;
$fetchedEntriesCount = $this->incrementalSync($currentTask, $usnChangedStartFrom, $highestCommitedUSN);
}
$currentTask->succeed($fetchedEntriesCount);
return $fetchedEntriesCount;
} catch (Exception $e) {
$currentTask->fail($e->getMessage());
throw $e;
} finally {
$this->entityManager->flush();
}
} | [
"public",
"function",
"poll",
"(",
"$",
"forceFullSync",
"=",
"false",
")",
"{",
"/** @var PollTaskRepository $pollTaskRepository */",
"$",
"pollTaskRepository",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getRepository",
"(",
"PollTask",
"::",
"class",
")",
";"... | Make a poll request to Active Directory and return amount of processed entries
@param bool $forceFullSync force full synchronization instead of incremental one
@return integer
@throws Exception | [
"Make",
"a",
"poll",
"request",
"to",
"Active",
"Directory",
"and",
"return",
"amount",
"of",
"processed",
"entries"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L141-L179 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.createCurrentPollTask | protected function createCurrentPollTask($invocationId, $highestCommitedUSN, $rootDseDnsHostName, $lastSuccessfulPollTask, $isFullSync)
{
$currentTask = new PollTask(
$this->name,
$invocationId,
$highestCommitedUSN,
$rootDseDnsHostName,
$lastSuccessfulPollTask,
$isFullSync
);
return $currentTask;
} | php | protected function createCurrentPollTask($invocationId, $highestCommitedUSN, $rootDseDnsHostName, $lastSuccessfulPollTask, $isFullSync)
{
$currentTask = new PollTask(
$this->name,
$invocationId,
$highestCommitedUSN,
$rootDseDnsHostName,
$lastSuccessfulPollTask,
$isFullSync
);
return $currentTask;
} | [
"protected",
"function",
"createCurrentPollTask",
"(",
"$",
"invocationId",
",",
"$",
"highestCommitedUSN",
",",
"$",
"rootDseDnsHostName",
",",
"$",
"lastSuccessfulPollTask",
",",
"$",
"isFullSync",
")",
"{",
"$",
"currentTask",
"=",
"new",
"PollTask",
"(",
"$",
... | Creates poll task entity for current sync
@param string $invocationId
@param integer $highestCommitedUSN
@param string $rootDseDnsHostName
@param PollTask $lastSuccessfulPollTask
@param bool $isFullSync
@return PollTask | [
"Creates",
"poll",
"task",
"entity",
"for",
"current",
"sync"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L192-L204 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.isFullSyncRequired | private function isFullSyncRequired($forceFullSync, PollTask $lastSuccessfulSyncTask = null, $currentRootDseDnsHostName, $currentInvocationId)
{
if ($forceFullSync) {
return true;
}
if (!$lastSuccessfulSyncTask) {
return true;
}
if ($lastSuccessfulSyncTask->getRootDseDnsHostName() != $currentRootDseDnsHostName) {
return true;
}
if ($lastSuccessfulSyncTask->getInvocationId() != $currentInvocationId) {
return true;
}
return false;
} | php | private function isFullSyncRequired($forceFullSync, PollTask $lastSuccessfulSyncTask = null, $currentRootDseDnsHostName, $currentInvocationId)
{
if ($forceFullSync) {
return true;
}
if (!$lastSuccessfulSyncTask) {
return true;
}
if ($lastSuccessfulSyncTask->getRootDseDnsHostName() != $currentRootDseDnsHostName) {
return true;
}
if ($lastSuccessfulSyncTask->getInvocationId() != $currentInvocationId) {
return true;
}
return false;
} | [
"private",
"function",
"isFullSyncRequired",
"(",
"$",
"forceFullSync",
",",
"PollTask",
"$",
"lastSuccessfulSyncTask",
"=",
"null",
",",
"$",
"currentRootDseDnsHostName",
",",
"$",
"currentInvocationId",
")",
"{",
"if",
"(",
"$",
"forceFullSync",
")",
"{",
"retur... | Returns true is full AD sync required and false otherwise
@param bool $forceFullSync
@param PollTask|null $lastSuccessfulSyncTask
@param string $currentRootDseDnsHostName
@param string $currentInvocationId
@return bool | [
"Returns",
"true",
"is",
"full",
"AD",
"sync",
"required",
"and",
"false",
"otherwise"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L216-L235 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.fullSync | private function fullSync(PollTask $currentTask, $highestCommitedUSN)
{
$entries = $this->fetcher->fullFetch($highestCommitedUSN);
$this->synchronizer->fullSync($this->name, $currentTask->getId(), $entries);
$this->logFullSync($entries);
return count($entries);
} | php | private function fullSync(PollTask $currentTask, $highestCommitedUSN)
{
$entries = $this->fetcher->fullFetch($highestCommitedUSN);
$this->synchronizer->fullSync($this->name, $currentTask->getId(), $entries);
$this->logFullSync($entries);
return count($entries);
} | [
"private",
"function",
"fullSync",
"(",
"PollTask",
"$",
"currentTask",
",",
"$",
"highestCommitedUSN",
")",
"{",
"$",
"entries",
"=",
"$",
"this",
"->",
"fetcher",
"->",
"fullFetch",
"(",
"$",
"highestCommitedUSN",
")",
";",
"$",
"this",
"->",
"synchronizer... | Performs full sync
@param PollTask $currentTask
@param integer $highestCommitedUSN max usnChanged value to restrict objects search
@return int count of synced entries | [
"Performs",
"full",
"sync"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L245-L252 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.incrementalSync | private function incrementalSync(PollTask $currentTask, $usnChangedStartFrom, $highestCommitedUSN)
{
list($changed, $deleted) = $this->fetcher->incrementalFetch($usnChangedStartFrom, $highestCommitedUSN, $this->detectDeleted);
$this->synchronizer->incrementalSync($this->name, $currentTask->getId(), $changed, $deleted);
$this->logIncrementalSync($changed, $deleted);
return count($changed) + count($deleted);
} | php | private function incrementalSync(PollTask $currentTask, $usnChangedStartFrom, $highestCommitedUSN)
{
list($changed, $deleted) = $this->fetcher->incrementalFetch($usnChangedStartFrom, $highestCommitedUSN, $this->detectDeleted);
$this->synchronizer->incrementalSync($this->name, $currentTask->getId(), $changed, $deleted);
$this->logIncrementalSync($changed, $deleted);
return count($changed) + count($deleted);
} | [
"private",
"function",
"incrementalSync",
"(",
"PollTask",
"$",
"currentTask",
",",
"$",
"usnChangedStartFrom",
",",
"$",
"highestCommitedUSN",
")",
"{",
"list",
"(",
"$",
"changed",
",",
"$",
"deleted",
")",
"=",
"$",
"this",
"->",
"fetcher",
"->",
"increme... | Performs incremental sync
@param PollTask $currentTask
@param integer $usnChangedStartFrom min usnChanged value to restrict objects search
@param integer $highestCommitedUSN max usnChanged value to restrict objects search
@return int | [
"Performs",
"incremental",
"sync"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L263-L270 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.logFullSync | private function logFullSync($entries)
{
if ($this->logger) {
$this->logger->info(sprintf("Full sync processed. Entries count: %d.", count($entries)));
}
} | php | private function logFullSync($entries)
{
if ($this->logger) {
$this->logger->info(sprintf("Full sync processed. Entries count: %d.", count($entries)));
}
} | [
"private",
"function",
"logFullSync",
"(",
"$",
"entries",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"sprintf",
"(",
"\"Full sync processed. Entries count: %d.\"",
",",
"count",
"(",
"$",
"e... | Logs full sync if needed
@param array $entries | [
"Logs",
"full",
"sync",
"if",
"needed"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L277-L282 | train |
GlobalTradingTechnologies/ad-poller | src/Poller.php | Poller.logIncrementalSync | private function logIncrementalSync($changed, $deleted)
{
if ($this->logger) {
$entriesLogReducer = function ($entry) {
return array_intersect_key($entry, array_flip($this->incrementalAttributesToLog));
};
$changedToLog = array_map($entriesLogReducer, $changed);
$deletedToLog = array_map($entriesLogReducer, $deleted);
$this->logger->info(
sprintf("Incremental changeset processed. Changed: %d, Deleted: %d.", count($changed), count($deleted)),
['changed' => $changedToLog, 'deleted' => $deletedToLog]
);
}
} | php | private function logIncrementalSync($changed, $deleted)
{
if ($this->logger) {
$entriesLogReducer = function ($entry) {
return array_intersect_key($entry, array_flip($this->incrementalAttributesToLog));
};
$changedToLog = array_map($entriesLogReducer, $changed);
$deletedToLog = array_map($entriesLogReducer, $deleted);
$this->logger->info(
sprintf("Incremental changeset processed. Changed: %d, Deleted: %d.", count($changed), count($deleted)),
['changed' => $changedToLog, 'deleted' => $deletedToLog]
);
}
} | [
"private",
"function",
"logIncrementalSync",
"(",
"$",
"changed",
",",
"$",
"deleted",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"entriesLogReducer",
"=",
"function",
"(",
"$",
"entry",
")",
"{",
"return",
"array_intersect_key",
"(",... | Logs incremental sync if needed
@param $changed
@param $deleted | [
"Logs",
"incremental",
"sync",
"if",
"needed"
] | c90073b13a6963970e70af67c6439dfe8c48739e | https://github.com/GlobalTradingTechnologies/ad-poller/blob/c90073b13a6963970e70af67c6439dfe8c48739e/src/Poller.php#L290-L303 | train |
seboettg/Collection | src/Seboettg/Collection/ArrayList/ArrayListTrait.php | ArrayListTrait.filter | public function filter(\Closure $closure)
{
$newInstance = new self();
$newInstance->setArray(array_filter($this->array, $closure));
return $newInstance;
} | php | public function filter(\Closure $closure)
{
$newInstance = new self();
$newInstance->setArray(array_filter($this->array, $closure));
return $newInstance;
} | [
"public",
"function",
"filter",
"(",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"$",
"newInstance",
"=",
"new",
"self",
"(",
")",
";",
"$",
"newInstance",
"->",
"setArray",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"array",
",",
"$",
"closure",
")",... | returns a clone of this ArrayList, filtered by the given closure function
@param \Closure $closure
@return ArrayListInterface|ArrayListTrait | [
"returns",
"a",
"clone",
"of",
"this",
"ArrayList",
"filtered",
"by",
"the",
"given",
"closure",
"function"
] | d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262 | https://github.com/seboettg/Collection/blob/d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262/src/Seboettg/Collection/ArrayList/ArrayListTrait.php#L193-L198 | train |
seboettg/Collection | src/Seboettg/Collection/ArrayList/ArrayListTrait.php | ArrayListTrait.filterByKeys | public function filterByKeys(array $keys)
{
/** @noinspection PhpMethodParametersCountMismatchInspection */
$newInstance = new self();
$newInstance->setArray(array_filter($this->array, function ($key) use ($keys) {
return array_search($key, $keys) !== false;
}, ARRAY_FILTER_USE_KEY));
return $newInstance;
} | php | public function filterByKeys(array $keys)
{
/** @noinspection PhpMethodParametersCountMismatchInspection */
$newInstance = new self();
$newInstance->setArray(array_filter($this->array, function ($key) use ($keys) {
return array_search($key, $keys) !== false;
}, ARRAY_FILTER_USE_KEY));
return $newInstance;
} | [
"public",
"function",
"filterByKeys",
"(",
"array",
"$",
"keys",
")",
"{",
"/** @noinspection PhpMethodParametersCountMismatchInspection */",
"$",
"newInstance",
"=",
"new",
"self",
"(",
")",
";",
"$",
"newInstance",
"->",
"setArray",
"(",
"array_filter",
"(",
"$",
... | returns a clone of this ArrayList, filtered by the given array keys
@param array $keys
@return ArrayListInterface|ArrayListTrait | [
"returns",
"a",
"clone",
"of",
"this",
"ArrayList",
"filtered",
"by",
"the",
"given",
"array",
"keys"
] | d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262 | https://github.com/seboettg/Collection/blob/d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262/src/Seboettg/Collection/ArrayList/ArrayListTrait.php#L205-L213 | train |
seboettg/Collection | src/Seboettg/Collection/ArrayList/ArrayListTrait.php | ArrayListTrait.map | public function map(\closure $mapFunction)
{
$newInstance = new self();
$newInstance->setArray(array_map($mapFunction, $this->array));
return $newInstance;
} | php | public function map(\closure $mapFunction)
{
$newInstance = new self();
$newInstance->setArray(array_map($mapFunction, $this->array));
return $newInstance;
} | [
"public",
"function",
"map",
"(",
"\\",
"closure",
"$",
"mapFunction",
")",
"{",
"$",
"newInstance",
"=",
"new",
"self",
"(",
")",
";",
"$",
"newInstance",
"->",
"setArray",
"(",
"array_map",
"(",
"$",
"mapFunction",
",",
"$",
"this",
"->",
"array",
")... | returns a new ArrayList containing all the elements of this ArrayList after applying the callback function to each one.
@param \closure $mapFunction
@return ArrayListInterface|ArrayListTrait | [
"returns",
"a",
"new",
"ArrayList",
"containing",
"all",
"the",
"elements",
"of",
"this",
"ArrayList",
"after",
"applying",
"the",
"callback",
"function",
"to",
"each",
"one",
"."
] | d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262 | https://github.com/seboettg/Collection/blob/d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262/src/Seboettg/Collection/ArrayList/ArrayListTrait.php#L220-L225 | train |
seboettg/Collection | src/Seboettg/Collection/ArrayList/ArrayListTrait.php | ArrayListTrait.flatten | public function flatten()
{
$flattenedArray = [];
array_walk_recursive($this->array, function ($item) use (&$flattenedArray) {
$flattenedArray[] = $item;
});
$newInstance = new self();
$newInstance->setArray($flattenedArray);
return $newInstance;
} | php | public function flatten()
{
$flattenedArray = [];
array_walk_recursive($this->array, function ($item) use (&$flattenedArray) {
$flattenedArray[] = $item;
});
$newInstance = new self();
$newInstance->setArray($flattenedArray);
return $newInstance;
} | [
"public",
"function",
"flatten",
"(",
")",
"{",
"$",
"flattenedArray",
"=",
"[",
"]",
";",
"array_walk_recursive",
"(",
"$",
"this",
"->",
"array",
",",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"&",
"$",
"flattenedArray",
")",
"{",
"$",
"flattene... | Returns a new ArrayList containing an one-dimensional array of all elements of this ArrayList. Keys are going lost.
@return ArrayListInterface|ArrayListTrait | [
"Returns",
"a",
"new",
"ArrayList",
"containing",
"an",
"one",
"-",
"dimensional",
"array",
"of",
"all",
"elements",
"of",
"this",
"ArrayList",
".",
"Keys",
"are",
"going",
"lost",
"."
] | d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262 | https://github.com/seboettg/Collection/blob/d9ca9bf9a52a4d150d162e4a8825e5b9e9e02262/src/Seboettg/Collection/ArrayList/ArrayListTrait.php#L231-L240 | train |
TheBnl/event-tickets | code/extensions/TicketControllerExtension.php | TicketControllerExtension.TicketForm | public function TicketForm()
{
if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) {
$ticketForm = new TicketForm($this->owner, 'TicketForm', $this->owner->Tickets(), $this->owner->dataRecord);
$ticketForm->setNextStep(CheckoutSteps::start());
return $ticketForm;
} else {
return null;
}
} | php | public function TicketForm()
{
if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) {
$ticketForm = new TicketForm($this->owner, 'TicketForm', $this->owner->Tickets(), $this->owner->dataRecord);
$ticketForm->setNextStep(CheckoutSteps::start());
return $ticketForm;
} else {
return null;
}
} | [
"public",
"function",
"TicketForm",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"Tickets",
"(",
")",
"->",
"count",
"(",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"getTicketsAvailable",
"(",
")",
")",
"{",
"$",
"ticketForm",
"=",
... | Get the ticket form with available tickets
@return TicketForm | [
"Get",
"the",
"ticket",
"form",
"with",
"available",
"tickets"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/extensions/TicketControllerExtension.php#L34-L43 | train |
TheBnl/event-tickets | code/extensions/TicketControllerExtension.php | TicketControllerExtension.WaitingListRegistrationForm | public function WaitingListRegistrationForm()
{
if (
$this->owner->Tickets()->count()
&& $this->owner->getTicketsSoldOut()
&& !$this->owner->getEventExpired()
) {
return new WaitingListRegistrationForm($this->owner, 'WaitingListRegistrationForm');
} else {
return null;
}
} | php | public function WaitingListRegistrationForm()
{
if (
$this->owner->Tickets()->count()
&& $this->owner->getTicketsSoldOut()
&& !$this->owner->getEventExpired()
) {
return new WaitingListRegistrationForm($this->owner, 'WaitingListRegistrationForm');
} else {
return null;
}
} | [
"public",
"function",
"WaitingListRegistrationForm",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"owner",
"->",
"Tickets",
"(",
")",
"->",
"count",
"(",
")",
"&&",
"$",
"this",
"->",
"owner",
"->",
"getTicketsSoldOut",
"(",
")",
"&&",
"!",
"$",
"this"... | show the waiting list form when the event is sold out
@return WaitingListRegistrationForm | [
"show",
"the",
"waiting",
"list",
"form",
"when",
"the",
"event",
"is",
"sold",
"out"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/extensions/TicketControllerExtension.php#L50-L61 | train |
anklimsk/cakephp-theme | Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Handler/HipChatHandler.php | HipChatHandler.getAlertColor | protected function getAlertColor($level)
{
switch (true) {
case $level >= Logger::ERROR:
return 'red';
case $level >= Logger::WARNING:
return 'yellow';
case $level >= Logger::INFO:
return 'green';
case $level == Logger::DEBUG:
return 'gray';
default:
return 'yellow';
}
} | php | protected function getAlertColor($level)
{
switch (true) {
case $level >= Logger::ERROR:
return 'red';
case $level >= Logger::WARNING:
return 'yellow';
case $level >= Logger::INFO:
return 'green';
case $level == Logger::DEBUG:
return 'gray';
default:
return 'yellow';
}
} | [
"protected",
"function",
"getAlertColor",
"(",
"$",
"level",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"level",
">=",
"Logger",
"::",
"ERROR",
":",
"return",
"'red'",
";",
"case",
"$",
"level",
">=",
"Logger",
"::",
"WARNING",
":",
"retur... | Assigns a color to each level of log records.
@param int $level
@return string | [
"Assigns",
"a",
"color",
"to",
"each",
"level",
"of",
"log",
"records",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Vendor/PhpUnoconv/monolog/monolog/src/Monolog/Handler/HipChatHandler.php#L198-L212 | train |
stanislav-web/PhalconSonar | src/Sonar/System/Tasks/SonarTask.php | SonarTask.setConfig | private function setConfig(\Phalcon\Config $config) {
if(defined(CURRENT_TASK) === true) {
$this->taskName = CURRENT_TASK;
}
$this->config = $config->cli->{$this->taskName};
return $this;
} | php | private function setConfig(\Phalcon\Config $config) {
if(defined(CURRENT_TASK) === true) {
$this->taskName = CURRENT_TASK;
}
$this->config = $config->cli->{$this->taskName};
return $this;
} | [
"private",
"function",
"setConfig",
"(",
"\\",
"Phalcon",
"\\",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"defined",
"(",
"CURRENT_TASK",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"taskName",
"=",
"CURRENT_TASK",
";",
"}",
"$",
"this",
"->",... | Setup current task configurations
@param \Phalcon\Config $config
@return SonarTask | [
"Setup",
"current",
"task",
"configurations"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/System/Tasks/SonarTask.php#L57-L66 | train |
stanislav-web/PhalconSonar | src/Sonar/System/Tasks/SonarTask.php | SonarTask.setLogger | private function setLogger() {
$config = $this->getConfig();
if($config->offsetExists('errors') === true && $config->errors === true) {
$this->logger = new FileAdapter($this->getConfig()->errorLog);
}
return $this;
} | php | private function setLogger() {
$config = $this->getConfig();
if($config->offsetExists('errors') === true && $config->errors === true) {
$this->logger = new FileAdapter($this->getConfig()->errorLog);
}
return $this;
} | [
"private",
"function",
"setLogger",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"if",
"(",
"$",
"config",
"->",
"offsetExists",
"(",
"'errors'",
")",
"===",
"true",
"&&",
"$",
"config",
"->",
"errors",
"===",
"tr... | Setup file logger
@return SonarTask | [
"Setup",
"file",
"logger"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/System/Tasks/SonarTask.php#L82-L91 | train |
stanislav-web/PhalconSonar | src/Sonar/System/Tasks/SonarTask.php | SonarTask.setSilentErrorHandler | public function setSilentErrorHandler() {
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
if (0 === error_reporting()) {
return false;
}
if($this->logger != null) {
// logging all warnings & notices
$this->getLogger()->log($errstr, Logger::CRITICAL);
}
});
} | php | public function setSilentErrorHandler() {
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
if (0 === error_reporting()) {
return false;
}
if($this->logger != null) {
// logging all warnings & notices
$this->getLogger()->log($errstr, Logger::CRITICAL);
}
});
} | [
"public",
"function",
"setSilentErrorHandler",
"(",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
",",
"array",
"$",
"errcontext",
")",
"{",
"if",
"(",
"0",
"===",
"error_... | Silent error handler
catching WARNINGS & NOTICIES | [
"Silent",
"error",
"handler",
"catching",
"WARNINGS",
"&",
"NOTICIES"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/System/Tasks/SonarTask.php#L136-L148 | train |
k-gun/oppa | src/Cache.php | Cache.checkFile | private function checkFile(string &$file): bool
{
$file = "{$this->directory}/{$file}";
return file_exists($file) || (touch($file) && chmod($file, 0600));
} | php | private function checkFile(string &$file): bool
{
$file = "{$this->directory}/{$file}";
return file_exists($file) || (touch($file) && chmod($file, 0600));
} | [
"private",
"function",
"checkFile",
"(",
"string",
"&",
"$",
"file",
")",
":",
"bool",
"{",
"$",
"file",
"=",
"\"{$this->directory}/{$file}\"",
";",
"return",
"file_exists",
"(",
"$",
"file",
")",
"||",
"(",
"touch",
"(",
"$",
"file",
")",
"&&",
"chmod",... | Check file.
@param string &$file
@return bool | [
"Check",
"file",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Cache.php#L129-L134 | train |
honeybee/trellis | src/Runtime/Entity/EntityMap.php | EntityMap.getKey | public function getKey($item, $return_all = false)
{
if ($return_all === true) {
return $this->getKeys();
}
if ($this->hasKey($item->getIdentifier())) {
return $item->getIdentifier();
}
return false;
} | php | public function getKey($item, $return_all = false)
{
if ($return_all === true) {
return $this->getKeys();
}
if ($this->hasKey($item->getIdentifier())) {
return $item->getIdentifier();
}
return false;
} | [
"public",
"function",
"getKey",
"(",
"$",
"item",
",",
"$",
"return_all",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"return_all",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"getKeys",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"ha... | Return the key for the given item.
If you wish to receive all keys, set the '$return_all' parameter to true.
@param mixed $item
@param boolean $return_all
@return mixed Returns the key of the item, an array of all keys or false, if the item is not present. | [
"Return",
"the",
"key",
"for",
"the",
"given",
"item",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Entity/EntityMap.php#L65-L76 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.getPlayerPosition | public function getPlayerPosition($login)
{
return isset($this->positionPerPlayer[$login]) ? $this->positionPerPlayer[$login] : null;
} | php | public function getPlayerPosition($login)
{
return isset($this->positionPerPlayer[$login]) ? $this->positionPerPlayer[$login] : null;
} | [
"public",
"function",
"getPlayerPosition",
"(",
"$",
"login",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"positionPerPlayer",
"[",
"$",
"login",
"]",
")",
"?",
"$",
"this",
"->",
"positionPerPlayer",
"[",
"$",
"login",
"]",
":",
"null",
";",
... | Get the position of a player
@param string $login
@return integer|null | [
"Get",
"the",
"position",
"of",
"a",
"player"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L116-L119 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.getPlayerRecord | public function getPlayerRecord($login)
{
return isset($this->recordsPerPlayer[$login]) ? $this->recordsPerPlayer[$login] : null;
} | php | public function getPlayerRecord($login)
{
return isset($this->recordsPerPlayer[$login]) ? $this->recordsPerPlayer[$login] : null;
} | [
"public",
"function",
"getPlayerRecord",
"(",
"$",
"login",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"recordsPerPlayer",
"[",
"$",
"login",
"]",
")",
"?",
"$",
"this",
"->",
"recordsPerPlayer",
"[",
"$",
"login",
"]",
":",
"null",
";",
"}"
... | Get a players record information.
@param $login
@return Record|null | [
"Get",
"a",
"players",
"record",
"information",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L128-L131 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.loadForMap | public function loadForMap($mapUid, $nbLaps)
{
// Free old records from memory first.
foreach ($this->records as $record) {
$record->clearAllReferences(false);
unset($record);
}
foreach ($this->recordsPerPlayer as $record) {
$record->clearAllReferences(false);
unset($record);
}
RecordTableMap::clearInstancePool();
// Load them amm new.
$this->recordsPerPlayer = [];
$this->positionPerPlayer = [];
$this->currentMapUid = $mapUid;
$this->currentNbLaps = $nbLaps;
$this->records = $this->recordQueryBuilder
->getMapRecords($mapUid, $nbLaps, $this->getScoreOrdering(), $this->nbRecords->get());
$position = 1;
foreach ($this->records as $record) {
$this->recordsPerPlayer[$record->getPlayer()->getLogin()] = $record;
$this->positionPerPlayer[$record->getPlayer()->getLogin()] = $position++;
}
} | php | public function loadForMap($mapUid, $nbLaps)
{
// Free old records from memory first.
foreach ($this->records as $record) {
$record->clearAllReferences(false);
unset($record);
}
foreach ($this->recordsPerPlayer as $record) {
$record->clearAllReferences(false);
unset($record);
}
RecordTableMap::clearInstancePool();
// Load them amm new.
$this->recordsPerPlayer = [];
$this->positionPerPlayer = [];
$this->currentMapUid = $mapUid;
$this->currentNbLaps = $nbLaps;
$this->records = $this->recordQueryBuilder
->getMapRecords($mapUid, $nbLaps, $this->getScoreOrdering(), $this->nbRecords->get());
$position = 1;
foreach ($this->records as $record) {
$this->recordsPerPlayer[$record->getPlayer()->getLogin()] = $record;
$this->positionPerPlayer[$record->getPlayer()->getLogin()] = $position++;
}
} | [
"public",
"function",
"loadForMap",
"(",
"$",
"mapUid",
",",
"$",
"nbLaps",
")",
"{",
"// Free old records from memory first.",
"foreach",
"(",
"$",
"this",
"->",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"record",
"->",
"clearAllReferences",
"(",
"false"... | Load records for a certain map.
@param string $mapUid
@param integer $nbLaps
@throws \Propel\Runtime\Exception\PropelException | [
"Load",
"records",
"for",
"a",
"certain",
"map",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L140-L168 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.loadForPlayers | public function loadForPlayers($mapUid, $nbLaps, $logins)
{
$logins = array_diff($logins, array_keys($this->recordsPerPlayer));
if (!empty($logins)) {
$records = $this->recordQueryBuilder->getPlayerMapRecords($mapUid, $nbLaps, $logins);
foreach ($records as $record) {
$this->recordsPerPlayer[$record->getPlayer()->getLogin()] = $record;
}
}
} | php | public function loadForPlayers($mapUid, $nbLaps, $logins)
{
$logins = array_diff($logins, array_keys($this->recordsPerPlayer));
if (!empty($logins)) {
$records = $this->recordQueryBuilder->getPlayerMapRecords($mapUid, $nbLaps, $logins);
foreach ($records as $record) {
$this->recordsPerPlayer[$record->getPlayer()->getLogin()] = $record;
}
}
} | [
"public",
"function",
"loadForPlayers",
"(",
"$",
"mapUid",
",",
"$",
"nbLaps",
",",
"$",
"logins",
")",
"{",
"$",
"logins",
"=",
"array_diff",
"(",
"$",
"logins",
",",
"array_keys",
"(",
"$",
"this",
"->",
"recordsPerPlayer",
")",
")",
";",
"if",
"(",... | Load records for certain players only.
@param $mapUid
@param $nbLaps
@param $logins
@throws \Propel\Runtime\Exception\PropelException | [
"Load",
"records",
"for",
"certain",
"players",
"only",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L178-L189 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.save | public function save()
{
$con = Propel::getWriteConnection(RecordTableMap::DATABASE_NAME);
$con->beginTransaction();
foreach ($this->recordsPerPlayer as $record) {
$record->save();
}
$con->commit();
RecordTableMap::clearInstancePool();
} | php | public function save()
{
$con = Propel::getWriteConnection(RecordTableMap::DATABASE_NAME);
$con->beginTransaction();
foreach ($this->recordsPerPlayer as $record) {
$record->save();
}
$con->commit();
RecordTableMap::clearInstancePool();
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getWriteConnection",
"(",
"RecordTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"con",
"->",
"beginTransaction",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"recordsPerP... | Save all new records.
@throws \Propel\Runtime\Exception\PropelException | [
"Save",
"all",
"new",
"records",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L196-L209 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.getNewRecord | protected function getNewRecord($login)
{
$record = new Record();
$record->setPlayer($this->playerDb->get($login));
$record->setNbLaps($this->currentNbLaps);
$record->setNbFinish(0);
$record->setMapUid($this->currentMapUid);
return $record;
} | php | protected function getNewRecord($login)
{
$record = new Record();
$record->setPlayer($this->playerDb->get($login));
$record->setNbLaps($this->currentNbLaps);
$record->setNbFinish(0);
$record->setMapUid($this->currentMapUid);
return $record;
} | [
"protected",
"function",
"getNewRecord",
"(",
"$",
"login",
")",
"{",
"$",
"record",
"=",
"new",
"Record",
"(",
")",
";",
"$",
"record",
"->",
"setPlayer",
"(",
"$",
"this",
"->",
"playerDb",
"->",
"get",
"(",
"$",
"login",
")",
")",
";",
"$",
"rec... | Get a new record instance.
@param string $login
@return Record | [
"Get",
"a",
"new",
"record",
"instance",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L318-L327 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php | RecordHandler.updateRecordStats | protected function updateRecordStats(Record $record, $score)
{
$record->setAvgScore(
(($record->getAvgScore() * $record->getNbFinish()) + $score) / ($record->getNbFinish() + 1)
);
$record->setNbFinish($record->getNbFinish() + 1);
} | php | protected function updateRecordStats(Record $record, $score)
{
$record->setAvgScore(
(($record->getAvgScore() * $record->getNbFinish()) + $score) / ($record->getNbFinish() + 1)
);
$record->setNbFinish($record->getNbFinish() + 1);
} | [
"protected",
"function",
"updateRecordStats",
"(",
"Record",
"$",
"record",
",",
"$",
"score",
")",
"{",
"$",
"record",
"->",
"setAvgScore",
"(",
"(",
"(",
"$",
"record",
"->",
"getAvgScore",
"(",
")",
"*",
"$",
"record",
"->",
"getNbFinish",
"(",
")",
... | Update Records statistics.
@param Record $record
@param integer $score | [
"Update",
"Records",
"statistics",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Services/RecordHandler.php#L335-L341 | train |
stanislav-web/PhalconSonar | src/Sonar/Services/GeoService.php | GeoService.location | public function location($param) {
try {
$result = $this->geocoder->geocode($param);
// parse data from geo locator
return (new Geo($result))->toArray();
} catch (\Exception $e) {
throw new GeoServiceException($e->getMessage());
}
} | php | public function location($param) {
try {
$result = $this->geocoder->geocode($param);
// parse data from geo locator
return (new Geo($result))->toArray();
} catch (\Exception $e) {
throw new GeoServiceException($e->getMessage());
}
} | [
"public",
"function",
"location",
"(",
"$",
"param",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"geocoder",
"->",
"geocode",
"(",
"$",
"param",
")",
";",
"// parse data from geo locator",
"return",
"(",
"new",
"Geo",
"(",
"$",
"result"... | Get address from requested param
@param string $param
@throws \Sonar\Exceptions\GeoServiceException
@return array | [
"Get",
"address",
"from",
"requested",
"param"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/Services/GeoService.php#L57-L69 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.getExtraFunctionCalls | public function getExtraFunctionCalls($dataArrayJs, $optionsJs)
{
$extraFunctionCalls = array();
if ($this->zooming) {
$extraFunctionCalls[] = sprintf( self::ZOOMING_FUNCTION, $dataArrayJs, $optionsJs, $dataArrayJs, $optionsJs );
}
if ($this->useLabels) {
$seriesLabels = json_encode($this->pointLabels);
$top = '';
$left = '';
$pixelCount = '15';
for ( $i = 0; $i < strlen($this->labelSettings['location']); $i++ ) {
switch ( $this->labelSettings['location'][$i] ) {
case 'n':
$top = '-'.$pixelCount;
break;
case 'e':
$left = '+'.$pixelCount;
break;
case 's':
$top = '+'.$pixelCount;
break;
case 'w':
$left = '-'.$pixelCount;
}
}
$paddingx = '-'.(isset($this->labelSettings['xpadding']) ? $this->labelSettings['xpadding'] : '0');
$paddingy = '-'.(isset($this->labelSettings['ypadding']) ? $this->labelSettings['ypadding'] : '0');
$extraFunctionCalls[] = sprintf( self::LABELS_FUNCTION, $seriesLabels, $left, $paddingx, $top, $paddingy );
}
if ($this->highlighting) {
$formatPoints = "x + ',' + y";
foreach ($this->dateAxes as $axis=>$flag) {
if ($flag) {
$formatPoints = str_replace($axis, "(new Date(parseInt({$axis}))).toLocaleDateString()",$formatPoints);
}
}
$extraFunctionCalls[] = sprintf( self::HIGHLIGHTING_FUNCTION, $formatPoints );
}
return $extraFunctionCalls;
} | php | public function getExtraFunctionCalls($dataArrayJs, $optionsJs)
{
$extraFunctionCalls = array();
if ($this->zooming) {
$extraFunctionCalls[] = sprintf( self::ZOOMING_FUNCTION, $dataArrayJs, $optionsJs, $dataArrayJs, $optionsJs );
}
if ($this->useLabels) {
$seriesLabels = json_encode($this->pointLabels);
$top = '';
$left = '';
$pixelCount = '15';
for ( $i = 0; $i < strlen($this->labelSettings['location']); $i++ ) {
switch ( $this->labelSettings['location'][$i] ) {
case 'n':
$top = '-'.$pixelCount;
break;
case 'e':
$left = '+'.$pixelCount;
break;
case 's':
$top = '+'.$pixelCount;
break;
case 'w':
$left = '-'.$pixelCount;
}
}
$paddingx = '-'.(isset($this->labelSettings['xpadding']) ? $this->labelSettings['xpadding'] : '0');
$paddingy = '-'.(isset($this->labelSettings['ypadding']) ? $this->labelSettings['ypadding'] : '0');
$extraFunctionCalls[] = sprintf( self::LABELS_FUNCTION, $seriesLabels, $left, $paddingx, $top, $paddingy );
}
if ($this->highlighting) {
$formatPoints = "x + ',' + y";
foreach ($this->dateAxes as $axis=>$flag) {
if ($flag) {
$formatPoints = str_replace($axis, "(new Date(parseInt({$axis}))).toLocaleDateString()",$formatPoints);
}
}
$extraFunctionCalls[] = sprintf( self::HIGHLIGHTING_FUNCTION, $formatPoints );
}
return $extraFunctionCalls;
} | [
"public",
"function",
"getExtraFunctionCalls",
"(",
"$",
"dataArrayJs",
",",
"$",
"optionsJs",
")",
"{",
"$",
"extraFunctionCalls",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"zooming",
")",
"{",
"$",
"extraFunctionCalls",
"[",
"]",
"=",
... | Populates script output with hacks required to give Flot featural parity with jqPlot
@param unknown_type $dataArrayJs
@param unknown_type $optionsJs
@return multitype:string | [
"Populates",
"script",
"output",
"with",
"hacks",
"required",
"to",
"give",
"Flot",
"featural",
"parity",
"with",
"jqPlot"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L146-L200 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setAxisOptions | public function setAxisOptions($axis, $name, $value)
{
if( strtolower($axis) === 'x' || strtolower($axis) === 'y' ) {
$axis = strtolower($axis) . 'axis';
if ( array_key_exists( $name, $this->nativeOpts[$axis] ) ) {
$this->setNestedOptVal( $this->options, $axis, $name, $value );
} else {
$key = 'axes.'.$axis.'.'.$name;
if ( isset( $this->optsMapper[$key] ) ) {
$this->setOpt($this->options, $this->optsMapper[$key], $value);
}
if ( $name == 'formatString' ) {
$this->options[$axis]['tickFormatter'] = $this->getCallbackPlaceholder('function(val, axis){return "'.$value.'".replace(/%d/, val);}');
}
}
}
return $this;
} | php | public function setAxisOptions($axis, $name, $value)
{
if( strtolower($axis) === 'x' || strtolower($axis) === 'y' ) {
$axis = strtolower($axis) . 'axis';
if ( array_key_exists( $name, $this->nativeOpts[$axis] ) ) {
$this->setNestedOptVal( $this->options, $axis, $name, $value );
} else {
$key = 'axes.'.$axis.'.'.$name;
if ( isset( $this->optsMapper[$key] ) ) {
$this->setOpt($this->options, $this->optsMapper[$key], $value);
}
if ( $name == 'formatString' ) {
$this->options[$axis]['tickFormatter'] = $this->getCallbackPlaceholder('function(val, axis){return "'.$value.'".replace(/%d/, val);}');
}
}
}
return $this;
} | [
"public",
"function",
"setAxisOptions",
"(",
"$",
"axis",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"axis",
")",
"===",
"'x'",
"||",
"strtolower",
"(",
"$",
"axis",
")",
"===",
"'y'",
")",
"{",
"$",
"axis",
... | Sets an option for a given axis
@param string $axis
@param string $name
@param mixed $value
@return \Altamira\JsWriter\Flot | [
"Sets",
"an",
"option",
"for",
"a",
"given",
"axis"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L209-L231 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.initializeSeries | public function initializeSeries( $series )
{
parent::initializeSeries($series);
$title = $this->getSeriesTitle($series);
$this->options['seriesStorage'][$title]['label'] = $title;
return $this;
} | php | public function initializeSeries( $series )
{
parent::initializeSeries($series);
$title = $this->getSeriesTitle($series);
$this->options['seriesStorage'][$title]['label'] = $title;
return $this;
} | [
"public",
"function",
"initializeSeries",
"(",
"$",
"series",
")",
"{",
"parent",
"::",
"initializeSeries",
"(",
"$",
"series",
")",
";",
"$",
"title",
"=",
"$",
"this",
"->",
"getSeriesTitle",
"(",
"$",
"series",
")",
";",
"$",
"this",
"->",
"options",
... | Registers a series, performing some additional logic
@see \Altamira\JsWriter\JsWriterAbstract::initializeSeries()
@param \Altamira\Series|string $series
@return \Altamira\JsWriter\Flot | [
"Registers",
"a",
"series",
"performing",
"some",
"additional",
"logic"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L239-L245 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.getOptionsJS | protected function getOptionsJS()
{
foreach ($this->optsMapper as $opt => $mapped)
{
if (($currOpt = $this->getOptVal($this->options, $opt)) && ($currOpt !== null)) {
$this->setOpt($this->options, $mapped, $currOpt);
$this->unsetOpt($this->options, $opt);
}
}
$opts = $this->options;
// stupid pie plugin
if ( $this->getOptVal( $opts, 'seriesStorage', 'pie', 'show' ) === null ) {
$this->setNestedOptVal( $opts, 'seriesStorage', 'pie', 'show', false );
}
$this->unsetOpt( $opts, 'seriesStorage' );
$this->unsetOpt( $opts, 'seriesDefault' );
return $this->makeJSArray($opts);
} | php | protected function getOptionsJS()
{
foreach ($this->optsMapper as $opt => $mapped)
{
if (($currOpt = $this->getOptVal($this->options, $opt)) && ($currOpt !== null)) {
$this->setOpt($this->options, $mapped, $currOpt);
$this->unsetOpt($this->options, $opt);
}
}
$opts = $this->options;
// stupid pie plugin
if ( $this->getOptVal( $opts, 'seriesStorage', 'pie', 'show' ) === null ) {
$this->setNestedOptVal( $opts, 'seriesStorage', 'pie', 'show', false );
}
$this->unsetOpt( $opts, 'seriesStorage' );
$this->unsetOpt( $opts, 'seriesDefault' );
return $this->makeJSArray($opts);
} | [
"protected",
"function",
"getOptionsJS",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"optsMapper",
"as",
"$",
"opt",
"=>",
"$",
"mapped",
")",
"{",
"if",
"(",
"(",
"$",
"currOpt",
"=",
"$",
"this",
"->",
"getOptVal",
"(",
"$",
"this",
"->",
"... | Mutates the option array to the format required for flot
@return Ambigous <string, mixed> | [
"Mutates",
"the",
"option",
"array",
"to",
"the",
"format",
"required",
"for",
"flot"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L251-L272 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.getOptVal | protected function getOptVal(array $opts, $option)
{
$ploded = explode('.', $option);
$arr = $opts;
$val = null;
while ($curr = array_shift($ploded)) {
if (isset($arr[$curr])) {
if (is_array($arr[$curr])) {
$arr = $arr[$curr];
} else {
return $arr[$curr];
}
} else {
return null;
}
}
} | php | protected function getOptVal(array $opts, $option)
{
$ploded = explode('.', $option);
$arr = $opts;
$val = null;
while ($curr = array_shift($ploded)) {
if (isset($arr[$curr])) {
if (is_array($arr[$curr])) {
$arr = $arr[$curr];
} else {
return $arr[$curr];
}
} else {
return null;
}
}
} | [
"protected",
"function",
"getOptVal",
"(",
"array",
"$",
"opts",
",",
"$",
"option",
")",
"{",
"$",
"ploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"option",
")",
";",
"$",
"arr",
"=",
"$",
"opts",
";",
"$",
"val",
"=",
"null",
";",
"while",
"(",... | Retrieves a nested value or null
@param array $opts
@param mixed $option
@return Ambigous <>|NULL|multitype: | [
"Retrieves",
"a",
"nested",
"value",
"or",
"null"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L280-L296 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setOpt | protected function setOpt(array &$opts, $mapperString, $val)
{
$args = explode( '.', $mapperString );
array_push( $args, $val );
$this->setNestedOptVal( $opts, $args );
} | php | protected function setOpt(array &$opts, $mapperString, $val)
{
$args = explode( '.', $mapperString );
array_push( $args, $val );
$this->setNestedOptVal( $opts, $args );
} | [
"protected",
"function",
"setOpt",
"(",
"array",
"&",
"$",
"opts",
",",
"$",
"mapperString",
",",
"$",
"val",
")",
"{",
"$",
"args",
"=",
"explode",
"(",
"'.'",
",",
"$",
"mapperString",
")",
";",
"array_push",
"(",
"$",
"args",
",",
"$",
"val",
")... | Sets a value in a nested array based on a dot-concatenated string
Used primarily for mapping
@param array $opts
@param string $mapperString
@param mixed $val | [
"Sets",
"a",
"value",
"in",
"a",
"nested",
"array",
"based",
"on",
"a",
"dot",
"-",
"concatenated",
"string",
"Used",
"primarily",
"for",
"mapping"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L305-L310 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.unsetOpt | protected function unsetOpt(array &$opts, $mapperString)
{
$ploded = explode('.', $mapperString);
$arr = &$opts;
while ($curr = array_shift($ploded)) {
if (isset($arr[$curr])) {
if (is_array($arr[$curr])) {
$arr = &$arr[$curr];
} else {
unset($arr[$curr]);
}
}
}
} | php | protected function unsetOpt(array &$opts, $mapperString)
{
$ploded = explode('.', $mapperString);
$arr = &$opts;
while ($curr = array_shift($ploded)) {
if (isset($arr[$curr])) {
if (is_array($arr[$curr])) {
$arr = &$arr[$curr];
} else {
unset($arr[$curr]);
}
}
}
} | [
"protected",
"function",
"unsetOpt",
"(",
"array",
"&",
"$",
"opts",
",",
"$",
"mapperString",
")",
"{",
"$",
"ploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"mapperString",
")",
";",
"$",
"arr",
"=",
"&",
"$",
"opts",
";",
"while",
"(",
"$",
"curr... | Handles nested mappings
@param array $opts
@param string $mapperString | [
"Handles",
"nested",
"mappings"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L317-L330 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setSeriesLineWidth | public function setSeriesLineWidth( $series, $value )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'linewidth', $value );
} | php | public function setSeriesLineWidth( $series, $value )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'linewidth', $value );
} | [
"public",
"function",
"setSeriesLineWidth",
"(",
"$",
"series",
",",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"setNestedOptVal",
"(",
"$",
"this",
"->",
"options",
",",
"'seriesStorage'",
",",
"$",
"this",
"->",
"getSeriesTitle",
"(",
"$",
"ser... | Determines the width of the line we will show, if we're showing it
@see \Altamira\JsWriter\Ability\Lineable::setSeriesLineWidth()
@param string $series
@param mixed $value
@return \Altamira\JsWriter\Flot | [
"Determines",
"the",
"width",
"of",
"the",
"line",
"we",
"will",
"show",
"if",
"we",
"re",
"showing",
"it"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L530-L533 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setSeriesShowLine | public function setSeriesShowLine( $series, $bool )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'show', $bool );
} | php | public function setSeriesShowLine( $series, $bool )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'show', $bool );
} | [
"public",
"function",
"setSeriesShowLine",
"(",
"$",
"series",
",",
"$",
"bool",
")",
"{",
"return",
"$",
"this",
"->",
"setNestedOptVal",
"(",
"$",
"this",
"->",
"options",
",",
"'seriesStorage'",
",",
"$",
"this",
"->",
"getSeriesTitle",
"(",
"$",
"serie... | Determines whether we show the line for a series
@see \Altamira\JsWriter\Ability\Lineable::setSeriesShowLine()
@param string|\Altamira\Series $series
@param bool $bool
@return \Altamira\JsWriter\Flot | [
"Determines",
"whether",
"we",
"show",
"the",
"line",
"for",
"a",
"series"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L542-L545 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setSeriesShowMarker | public function setSeriesShowMarker( $series, $bool )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'points', 'show', $bool );
} | php | public function setSeriesShowMarker( $series, $bool )
{
return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'points', 'show', $bool );
} | [
"public",
"function",
"setSeriesShowMarker",
"(",
"$",
"series",
",",
"$",
"bool",
")",
"{",
"return",
"$",
"this",
"->",
"setNestedOptVal",
"(",
"$",
"this",
"->",
"options",
",",
"'seriesStorage'",
",",
"$",
"this",
"->",
"getSeriesTitle",
"(",
"$",
"ser... | Determines whether we show the marker for a series
@see \Altamira\JsWriter\Ability\Lineable::setSeriesShowMarker()
@param string|\Altamira\Series $series
@param bool $bool
@return \Altamira\JsWriter\Flot | [
"Determines",
"whether",
"we",
"show",
"the",
"marker",
"for",
"a",
"series"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L554-L557 | train |
Malwarebytes/Altamira | src/Altamira/JsWriter/Flot.php | Flot.setAxisTicks | public function setAxisTicks($axis, array $ticks = array() )
{
if ( in_array($axis, array('x', 'y') ) ) {
$isString = false;
$alternateTicks = array();
$cnt = 1;
foreach ($ticks as $tick) {
if (!(ctype_digit($tick) || is_int($tick))) {
$isString = true;
// this is O(2N) so deal with it
foreach ( $ticks as $tick ) {
$alternateTicks[] = array($cnt++, $tick);
}
break;
}
}
$this->setNestedOptVal( $this->options, $axis.'axis', 'ticks', $isString ? $alternateTicks : $ticks );
}
return $this;
} | php | public function setAxisTicks($axis, array $ticks = array() )
{
if ( in_array($axis, array('x', 'y') ) ) {
$isString = false;
$alternateTicks = array();
$cnt = 1;
foreach ($ticks as $tick) {
if (!(ctype_digit($tick) || is_int($tick))) {
$isString = true;
// this is O(2N) so deal with it
foreach ( $ticks as $tick ) {
$alternateTicks[] = array($cnt++, $tick);
}
break;
}
}
$this->setNestedOptVal( $this->options, $axis.'axis', 'ticks', $isString ? $alternateTicks : $ticks );
}
return $this;
} | [
"public",
"function",
"setAxisTicks",
"(",
"$",
"axis",
",",
"array",
"$",
"ticks",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"axis",
",",
"array",
"(",
"'x'",
",",
"'y'",
")",
")",
")",
"{",
"$",
"isString",
"=",
"false"... | Responsible for setting the tick labels on a given axis
@param string $axis
@param array $ticks
@return \Altamira\JsWriter\Flot | [
"Responsible",
"for",
"setting",
"the",
"tick",
"labels",
"on",
"a",
"given",
"axis"
] | 38e320f68070d7a0b6902c6c3f904995d4a8cdfc | https://github.com/Malwarebytes/Altamira/blob/38e320f68070d7a0b6902c6c3f904995d4a8cdfc/src/Altamira/JsWriter/Flot.php#L597-L621 | train |
honeybee/trellis | src/Runtime/Attribute/EmbeddedEntityList/EmbeddedEntityListRule.php | EmbeddedEntityListRule.execute | protected function execute($value, EntityInterface $parent_entity = null)
{
$success = true;
$list = null;
if ($value instanceof EntityList) {
$list = $value;
} elseif (null === $value) {
$list = new EntityList();
} elseif ($value instanceof EntityInterface) {
$list = new EntityList();
$list->push($value);
} elseif (is_array($value)) {
$list = new EntityList();
$success = $this->createEntityList($value, $list, $parent_entity);
} else {
$this->throwError('invalid_value_type');
return false;
}
$count = count($list);
if ($this->hasOption(self::OPTION_MIN_COUNT)) {
$min_count = $this->getOption(self::OPTION_MIN_COUNT, 0);
if ($count < (int)$min_count) {
$this->throwError('min_count', [ 'count' => $count, 'min_count' => $min_count ]);
$success = false;
}
}
if ($this->hasOption(self::OPTION_MAX_COUNT)) {
$max_count = $this->getOption(self::OPTION_MAX_COUNT, 0);
if ($count > (int)$max_count) {
$this->throwError('max_count', [ 'count' => $count, 'max_count' => $max_count ]);
$success = false;
}
}
if ($success) {
$this->setSanitizedValue($list);
return true;
}
return false;
} | php | protected function execute($value, EntityInterface $parent_entity = null)
{
$success = true;
$list = null;
if ($value instanceof EntityList) {
$list = $value;
} elseif (null === $value) {
$list = new EntityList();
} elseif ($value instanceof EntityInterface) {
$list = new EntityList();
$list->push($value);
} elseif (is_array($value)) {
$list = new EntityList();
$success = $this->createEntityList($value, $list, $parent_entity);
} else {
$this->throwError('invalid_value_type');
return false;
}
$count = count($list);
if ($this->hasOption(self::OPTION_MIN_COUNT)) {
$min_count = $this->getOption(self::OPTION_MIN_COUNT, 0);
if ($count < (int)$min_count) {
$this->throwError('min_count', [ 'count' => $count, 'min_count' => $min_count ]);
$success = false;
}
}
if ($this->hasOption(self::OPTION_MAX_COUNT)) {
$max_count = $this->getOption(self::OPTION_MAX_COUNT, 0);
if ($count > (int)$max_count) {
$this->throwError('max_count', [ 'count' => $count, 'max_count' => $max_count ]);
$success = false;
}
}
if ($success) {
$this->setSanitizedValue($list);
return true;
}
return false;
} | [
"protected",
"function",
"execute",
"(",
"$",
"value",
",",
"EntityInterface",
"$",
"parent_entity",
"=",
"null",
")",
"{",
"$",
"success",
"=",
"true",
";",
"$",
"list",
"=",
"null",
";",
"if",
"(",
"$",
"value",
"instanceof",
"EntityList",
")",
"{",
... | Validates and sanitizes a given value respective to the valueholder's expectations.
@param mixed $value The types 'array' and 'EntityList' are accepted.
@return boolean | [
"Validates",
"and",
"sanitizes",
"a",
"given",
"value",
"respective",
"to",
"the",
"valueholder",
"s",
"expectations",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/EmbeddedEntityList/EmbeddedEntityListRule.php#L32-L75 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/Maps/Plugins/Jukebox.php | Jukebox.onPodiumStart | public function onPodiumStart($time)
{
$jbMap = $this->jukeboxService->getFirst();
if ($jbMap) {
$length = count($this->jukeboxService->getMapQueue());
$this->chatNotification->sendMessage('expansion_jukebox.chat.nextjbmap', null, [
"%mapname%" => $jbMap->getMap()->name,
"%mapauthor%" => $jbMap->getMap()->author,
"%nickname%" => $jbMap->getPlayer()->getNickName(),
"%length%" => $length,
]);
} else {
$map = $this->mapStorage->getNextMap();
$this->chatNotification->sendMessage('expansion_jukebox.chat.nextmap', null, [
"%name%" => $map->name,
"%author%" => $map->author,
]);
}
} | php | public function onPodiumStart($time)
{
$jbMap = $this->jukeboxService->getFirst();
if ($jbMap) {
$length = count($this->jukeboxService->getMapQueue());
$this->chatNotification->sendMessage('expansion_jukebox.chat.nextjbmap', null, [
"%mapname%" => $jbMap->getMap()->name,
"%mapauthor%" => $jbMap->getMap()->author,
"%nickname%" => $jbMap->getPlayer()->getNickName(),
"%length%" => $length,
]);
} else {
$map = $this->mapStorage->getNextMap();
$this->chatNotification->sendMessage('expansion_jukebox.chat.nextmap', null, [
"%name%" => $map->name,
"%author%" => $map->author,
]);
}
} | [
"public",
"function",
"onPodiumStart",
"(",
"$",
"time",
")",
"{",
"$",
"jbMap",
"=",
"$",
"this",
"->",
"jukeboxService",
"->",
"getFirst",
"(",
")",
";",
"if",
"(",
"$",
"jbMap",
")",
"{",
"$",
"length",
"=",
"count",
"(",
"$",
"this",
"->",
"juk... | Callback sent when the "onPodiumStart" section start.
@param int $time Server time when the callback was sent
@return mixed | [
"Callback",
"sent",
"when",
"the",
"onPodiumStart",
"section",
"start",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Maps/Plugins/Jukebox.php#L228-L246 | train |
Corviz/framework | src/Mvc/View/DefaultTemplateEngine.php | DefaultTemplateEngine.draw | public function draw(string $file, array $data) : string
{
$this->file = $file;
$this->data = $data;
return $this->getOutputs();
} | php | public function draw(string $file, array $data) : string
{
$this->file = $file;
$this->data = $data;
return $this->getOutputs();
} | [
"public",
"function",
"draw",
"(",
"string",
"$",
"file",
",",
"array",
"$",
"data",
")",
":",
"string",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"return",
"$",
"this",
"->",
"getOut... | Proccess and render a template.
@param string $file
@param array $data
@return string | [
"Proccess",
"and",
"render",
"a",
"template",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/View/DefaultTemplateEngine.php#L25-L31 | train |
Corviz/framework | src/Mvc/View/DefaultTemplateEngine.php | DefaultTemplateEngine.getOutputs | private function getOutputs() : string
{
ob_start();
extract($this->data);
require $this->file;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
} | php | private function getOutputs() : string
{
ob_start();
extract($this->data);
require $this->file;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
} | [
"private",
"function",
"getOutputs",
"(",
")",
":",
"string",
"{",
"ob_start",
"(",
")",
";",
"extract",
"(",
"$",
"this",
"->",
"data",
")",
";",
"require",
"$",
"this",
"->",
"file",
";",
"$",
"contents",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_... | Handle template file.
@return string | [
"Handle",
"template",
"file",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/View/DefaultTemplateEngine.php#L38-L47 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Repositories/Setting/EloquentSetting.php | EloquentSetting.update | public function update(array $data, $Setting = null)
{
if(empty($Setting))
{
$Setting = $this->byId($data['id']);
}
foreach ($data as $key => $value)
{
$Setting->$key = $value;
}
$Setting->save();
return $Setting;
} | php | public function update(array $data, $Setting = null)
{
if(empty($Setting))
{
$Setting = $this->byId($data['id']);
}
foreach ($data as $key => $value)
{
$Setting->$key = $value;
}
$Setting->save();
return $Setting;
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"data",
",",
"$",
"Setting",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"Setting",
")",
")",
"{",
"$",
"Setting",
"=",
"$",
"this",
"->",
"byId",
"(",
"$",
"data",
"[",
"'id'",
"]",
"... | Update an existing set of settings
@param array $data
An array as follows: array('initial_year'=>$initialYear, 'create_opening_period'=>$createOpeningPeriod, 'create_closing_period'=>$createClosingPeriod, 'is_configured'=>$isConfigured,
'currency_id'=>$currencyId, 'account_chart_type_id'=>$accountChartTypeId, 'organization_id'=>$organizationId
);
@param Mgallegos\DecimaAccounting\Setting $Setting
@return Mgallegos\DecimaAccounting\Setting | [
"Update",
"an",
"existing",
"set",
"of",
"settings"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Repositories/Setting/EloquentSetting.php#L115-L130 | train |
ansas/php-component | src/Util/Text.php | Text.maxCharWidth | public static function maxCharWidth($string)
{
$chars = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
if (!$chars) {
return 0;
}
$sizes = array_map('strlen', $chars);
return max($sizes);
} | php | public static function maxCharWidth($string)
{
$chars = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
if (!$chars) {
return 0;
}
$sizes = array_map('strlen', $chars);
return max($sizes);
} | [
"public",
"static",
"function",
"maxCharWidth",
"(",
"$",
"string",
")",
"{",
"$",
"chars",
"=",
"preg_split",
"(",
"'//u'",
",",
"$",
"string",
",",
"null",
",",
"PREG_SPLIT_NO_EMPTY",
")",
";",
"if",
"(",
"!",
"$",
"chars",
")",
"{",
"return",
"0",
... | Get max bytes needed per char.
@param string $string
@return int | [
"Get",
"max",
"bytes",
"needed",
"per",
"char",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L79-L90 | train |
ansas/php-component | src/Util/Text.php | Text.stripLinks | public static function stripLinks($text, $replaceWith = '')
{
$text = preg_replace('/(?:(?:[^\s\:>]+:)?\/\/|www\.)[^\s\.]+\.\w+[^\s<]+/u', $replaceWith, $text);
$text = preg_replace('/[^\s\.>]+\.[a-z]{2,}\/[^\s<]+/u', $replaceWith, $text);
return $text;
} | php | public static function stripLinks($text, $replaceWith = '')
{
$text = preg_replace('/(?:(?:[^\s\:>]+:)?\/\/|www\.)[^\s\.]+\.\w+[^\s<]+/u', $replaceWith, $text);
$text = preg_replace('/[^\s\.>]+\.[a-z]{2,}\/[^\s<]+/u', $replaceWith, $text);
return $text;
} | [
"public",
"static",
"function",
"stripLinks",
"(",
"$",
"text",
",",
"$",
"replaceWith",
"=",
"''",
")",
"{",
"$",
"text",
"=",
"preg_replace",
"(",
"'/(?:(?:[^\\s\\:>]+:)?\\/\\/|www\\.)[^\\s\\.]+\\.\\w+[^\\s<]+/u'",
",",
"$",
"replaceWith",
",",
"$",
"text",
")",... | Remove links in text.
This method can remove these types:
- <code>http://test.de</code> (with every protocol)
- <code>//test.de</code> (without protocol)
- <code>www.test.de</code> (with www subdomain)
- <code>www.test.de/test/test.htm?test=1&test2=2</code> (with path, file and param suffix)
- <code>test.de/sub</code> (with path)
@param string $text
@param string $replaceWith [optional]
@return string | [
"Remove",
"links",
"in",
"text",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L143-L149 | train |
ansas/php-component | src/Util/Text.php | Text.stripSocials | public static function stripSocials($text, $replaceWith = '')
{
$text = preg_replace('/(?<=\s|^|>)@[^\s<]+/u', $replaceWith, $text);
$text = preg_replace('/(?:[^\s>]+\.)?facebook.com\/[^\s<]+/u', $replaceWith, $text);
return $text;
} | php | public static function stripSocials($text, $replaceWith = '')
{
$text = preg_replace('/(?<=\s|^|>)@[^\s<]+/u', $replaceWith, $text);
$text = preg_replace('/(?:[^\s>]+\.)?facebook.com\/[^\s<]+/u', $replaceWith, $text);
return $text;
} | [
"public",
"static",
"function",
"stripSocials",
"(",
"$",
"text",
",",
"$",
"replaceWith",
"=",
"''",
")",
"{",
"$",
"text",
"=",
"preg_replace",
"(",
"'/(?<=\\s|^|>)@[^\\s<]+/u'",
",",
"$",
"replaceWith",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"p... | Remove social hints in text.
This method can remove these types:
- <code>@test</code> (twitter)
- <code>facebook.com/test</code> (facebook)
@param string $text
@param string $replaceWith [optional]
@return string | [
"Remove",
"social",
"hints",
"in",
"text",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L186-L192 | train |
ansas/php-component | src/Util/Text.php | Text.toBool | public static function toBool($string)
{
if (is_null($string)) {
return false;
}
if (!is_scalar($string)) {
throw new InvalidArgumentException("Value must be scalar");
}
if (!is_string($string)) {
return (bool) $string;
}
return !in_array(strtolower($string), ['false', 'off', '-', 'no', 'n', '0', '']);
} | php | public static function toBool($string)
{
if (is_null($string)) {
return false;
}
if (!is_scalar($string)) {
throw new InvalidArgumentException("Value must be scalar");
}
if (!is_string($string)) {
return (bool) $string;
}
return !in_array(strtolower($string), ['false', 'off', '-', 'no', 'n', '0', '']);
} | [
"public",
"static",
"function",
"toBool",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"string",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"string",
")",
")",
"{",
"throw",
"new",
"InvalidAr... | Convert string into bool value.
@param mixed $string
@return bool
@throws InvalidArgumentException | [
"Convert",
"string",
"into",
"bool",
"value",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L202-L217 | train |
ansas/php-component | src/Util/Text.php | Text.toCase | public static function toCase($string, $case)
{
switch ($case) {
case self::UPPER:
$string = mb_strtoupper($string);
break;
case self::LOWER:
$string = mb_strtolower($string);
break;
case self::UPPER_FIRST:
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
break;
case self::UPPER_WORDS:
$string = mb_convert_case($string, MB_CASE_TITLE);
break;
case self::NONE:
break;
default:
throw new InvalidArgumentException("Cannot set case {$case}");
}
return $string;
} | php | public static function toCase($string, $case)
{
switch ($case) {
case self::UPPER:
$string = mb_strtoupper($string);
break;
case self::LOWER:
$string = mb_strtolower($string);
break;
case self::UPPER_FIRST:
$string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
break;
case self::UPPER_WORDS:
$string = mb_convert_case($string, MB_CASE_TITLE);
break;
case self::NONE:
break;
default:
throw new InvalidArgumentException("Cannot set case {$case}");
}
return $string;
} | [
"public",
"static",
"function",
"toCase",
"(",
"$",
"string",
",",
"$",
"case",
")",
"{",
"switch",
"(",
"$",
"case",
")",
"{",
"case",
"self",
"::",
"UPPER",
":",
"$",
"string",
"=",
"mb_strtoupper",
"(",
"$",
"string",
")",
";",
"break",
";",
"ca... | Convert case of a string.
@param string $string
@param string $case
@return string
@throws InvalidArgumentException | [
"Convert",
"case",
"of",
"a",
"string",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L228-L250 | train |
ansas/php-component | src/Util/Text.php | Text.toSingleWhitespace | public static function toSingleWhitespace($string, $trim = true)
{
$string = preg_replace("/\r|\n|\t/", " ", $string);
$string = preg_replace("/ {2,}/", " ", $string);
if ($trim) {
$string = self::trim($string);
}
return $string;
} | php | public static function toSingleWhitespace($string, $trim = true)
{
$string = preg_replace("/\r|\n|\t/", " ", $string);
$string = preg_replace("/ {2,}/", " ", $string);
if ($trim) {
$string = self::trim($string);
}
return $string;
} | [
"public",
"static",
"function",
"toSingleWhitespace",
"(",
"$",
"string",
",",
"$",
"trim",
"=",
"true",
")",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"\"/\\r|\\n|\\t/\"",
",",
"\" \"",
",",
"$",
"string",
")",
";",
"$",
"string",
"=",
"preg_replace",... | Convert to single line string without multiple whitespaces.
@param string $string
@param bool $trim [optional]
@return string | [
"Convert",
"to",
"single",
"line",
"string",
"without",
"multiple",
"whitespaces",
"."
] | 24574a1e32d5f1355a6e2b6f20f49b1eda7250ba | https://github.com/ansas/php-component/blob/24574a1e32d5f1355a6e2b6f20f49b1eda7250ba/src/Util/Text.php#L291-L301 | train |
video-games-records/CoreBundle | Repository/PlayerRepository.php | PlayerRepository.majRankPointGame | public function majRankPointGame()
{
$players = $this->findBy(array(), array('pointGame' => 'DESC'));
Ranking::addObjectRank($players, 'rankPointGame', array('pointGame'));
$this->getEntityManager()->flush();
} | php | public function majRankPointGame()
{
$players = $this->findBy(array(), array('pointGame' => 'DESC'));
Ranking::addObjectRank($players, 'rankPointGame', array('pointGame'));
$this->getEntityManager()->flush();
} | [
"public",
"function",
"majRankPointGame",
"(",
")",
"{",
"$",
"players",
"=",
"$",
"this",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'pointGame'",
"=>",
"'DESC'",
")",
")",
";",
"Ranking",
"::",
"addObjectRank",
"(",
"$",
"players",
"... | Update column rankPointGame | [
"Update",
"column",
"rankPointGame"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Repository/PlayerRepository.php#L212-L218 | train |
video-games-records/CoreBundle | Repository/PlayerRepository.php | PlayerRepository.majRankMedal | public function majRankMedal()
{
$players = $this->findBy(array(), array('chartRank0' => 'DESC', 'chartRank1' => 'DESC', 'chartRank2' => 'DESC', 'chartRank3' => 'DESC'));
Ranking::addObjectRank($players, 'rankMedal', array('chartRank0', 'chartRank1', 'chartRank2', 'chartRank3'));
$this->getEntityManager()->flush();
} | php | public function majRankMedal()
{
$players = $this->findBy(array(), array('chartRank0' => 'DESC', 'chartRank1' => 'DESC', 'chartRank2' => 'DESC', 'chartRank3' => 'DESC'));
Ranking::addObjectRank($players, 'rankMedal', array('chartRank0', 'chartRank1', 'chartRank2', 'chartRank3'));
$this->getEntityManager()->flush();
} | [
"public",
"function",
"majRankMedal",
"(",
")",
"{",
"$",
"players",
"=",
"$",
"this",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'chartRank0'",
"=>",
"'DESC'",
",",
"'chartRank1'",
"=>",
"'DESC'",
",",
"'chartRank2'",
"=>",
"'DESC'",
",... | Update column rankMedal | [
"Update",
"column",
"rankMedal"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Repository/PlayerRepository.php#L223-L229 | train |
video-games-records/CoreBundle | Repository/PlayerRepository.php | PlayerRepository.majRankProof | public function majRankProof()
{
$players = $this->findBy(array(), array('nbChartProven' => 'DESC'));
Ranking::addObjectRank($players, 'rankProof', array('nbChartProven'));
$this->getEntityManager()->flush();
} | php | public function majRankProof()
{
$players = $this->findBy(array(), array('nbChartProven' => 'DESC'));
Ranking::addObjectRank($players, 'rankProof', array('nbChartProven'));
$this->getEntityManager()->flush();
} | [
"public",
"function",
"majRankProof",
"(",
")",
"{",
"$",
"players",
"=",
"$",
"this",
"->",
"findBy",
"(",
"array",
"(",
")",
",",
"array",
"(",
"'nbChartProven'",
"=>",
"'DESC'",
")",
")",
";",
"Ranking",
"::",
"addObjectRank",
"(",
"$",
"players",
"... | Update column rankProof | [
"Update",
"column",
"rankProof"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Repository/PlayerRepository.php#L248-L254 | train |
mridang/pearify | src/Pearify/Utils/ComposerUtils.php | ComposerUtils.getDirectories | public static function getDirectories() {
Logger::info("Resolving dependencies for project");
$packages = array();
$root = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))));
$composer = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json');
$composer = json_decode($composer, true);
if (array_key_exists('require', $composer) && !empty($composer['require'])) {
foreach ($composer['require'] as $requirement => $version) {
$packages = array_merge(self::readFile($requirement), $packages);
}
} else {
Logger::trace("Project has no dependencies");
}
foreach ($packages as $package) {
Logger::debug("Project references package %s", $package);
}
Logger::info("%d dependencies found", count($packages));
return $packages;
} | php | public static function getDirectories() {
Logger::info("Resolving dependencies for project");
$packages = array();
$root = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))));
$composer = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json');
$composer = json_decode($composer, true);
if (array_key_exists('require', $composer) && !empty($composer['require'])) {
foreach ($composer['require'] as $requirement => $version) {
$packages = array_merge(self::readFile($requirement), $packages);
}
} else {
Logger::trace("Project has no dependencies");
}
foreach ($packages as $package) {
Logger::debug("Project references package %s", $package);
}
Logger::info("%d dependencies found", count($packages));
return $packages;
} | [
"public",
"static",
"function",
"getDirectories",
"(",
")",
"{",
"Logger",
"::",
"info",
"(",
"\"Resolving dependencies for project\"",
")",
";",
"$",
"packages",
"=",
"array",
"(",
")",
";",
"$",
"root",
"=",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
... | Returns the list of packages and all the other referenced packages from the composer file.
@return array the array of referenced packages | [
"Returns",
"the",
"list",
"of",
"packages",
"and",
"all",
"the",
"other",
"referenced",
"packages",
"from",
"the",
"composer",
"file",
"."
] | 7bc0710beb4165164e07f88b456de47cad8b3002 | https://github.com/mridang/pearify/blob/7bc0710beb4165164e07f88b456de47cad8b3002/src/Pearify/Utils/ComposerUtils.php#L28-L46 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.