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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
RhubarbPHP/Rhubarb | src/DependencyInjection/Container.php | Container.getSingleton | public function getSingleton($requestedClass, callable $singletonCreationCallback = null)
{
if (!isset($this->singletons[$requestedClass])){
if ($singletonCreationCallback){
$singleton = $singletonCreationCallback;
} else {
$singleton = $this->instance($requestedClass);
}
$this->singletons[$requestedClass] = $singleton;
$this->concreteClassMappings["_".$requestedClass] = $requestedClass;
}
if (is_callable($this->singletons[$requestedClass])){
$callback = $this->singletons[$requestedClass];
$this->singletons[$requestedClass] = $callback();
}
return $this->singletons[$requestedClass];
} | php | public function getSingleton($requestedClass, callable $singletonCreationCallback = null)
{
if (!isset($this->singletons[$requestedClass])){
if ($singletonCreationCallback){
$singleton = $singletonCreationCallback;
} else {
$singleton = $this->instance($requestedClass);
}
$this->singletons[$requestedClass] = $singleton;
$this->concreteClassMappings["_".$requestedClass] = $requestedClass;
}
if (is_callable($this->singletons[$requestedClass])){
$callback = $this->singletons[$requestedClass];
$this->singletons[$requestedClass] = $callback();
}
return $this->singletons[$requestedClass];
} | [
"public",
"function",
"getSingleton",
"(",
"$",
"requestedClass",
",",
"callable",
"$",
"singletonCreationCallback",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"singletons",
"[",
"$",
"requestedClass",
"]",
")",
")",
"{",
"if",... | Creates a singleton object instance of the requested class from the current DI container
@see getInstance()
@param $requestedClass
@param ...$arguments
@return mixed | [
"Creates",
"a",
"singleton",
"object",
"instance",
"of",
"the",
"requested",
"class",
"from",
"the",
"current",
"DI",
"container"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/DependencyInjection/Container.php#L151-L170 | train |
glorpen/GlorpenPropelBundle | src/Services/OMClassOverrider.php | OMClassOverrider.getExtendedClass | public function getExtendedClass($class)
{
$ret = null;
if (array_key_exists($class, $this->dynamicClasses)) {
$ret = $this->dynamicClasses[$class];
}
if (!$ret) {
$ret = array_search($class, $this->classes);
}
return $ret?$ret:null;
} | php | public function getExtendedClass($class)
{
$ret = null;
if (array_key_exists($class, $this->dynamicClasses)) {
$ret = $this->dynamicClasses[$class];
}
if (!$ret) {
$ret = array_search($class, $this->classes);
}
return $ret?$ret:null;
} | [
"public",
"function",
"getExtendedClass",
"(",
"$",
"class",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"dynamicClasses",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"dynam... | Returns base class
@param string $class
@return string | [
"Returns",
"base",
"class"
] | b679c83377c81ab582de179f84bc23eaeb1e86aa | https://github.com/glorpen/GlorpenPropelBundle/blob/b679c83377c81ab582de179f84bc23eaeb1e86aa/src/Services/OMClassOverrider.php#L59-L69 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.reset | protected function reset()
{
$this->element = null;
$this->arguments = [];
$this->methods = [];
$this->cloneElement = false;
$this->translatableIndicator = false;
return $this;
} | php | protected function reset()
{
$this->element = null;
$this->arguments = [];
$this->methods = [];
$this->cloneElement = false;
$this->translatableIndicator = false;
return $this;
} | [
"protected",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"element",
"=",
"null",
";",
"$",
"this",
"->",
"arguments",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"methods",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"cloneElement",
"=",
"false",
... | Resets the properties.
@return $this | [
"Resets",
"the",
"properties",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L171-L180 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.locales | public function locales(array $locales = null)
{
return is_null($locales)
? $this->locales
: ($this->locales = $locales);
} | php | public function locales(array $locales = null)
{
return is_null($locales)
? $this->locales
: ($this->locales = $locales);
} | [
"public",
"function",
"locales",
"(",
"array",
"$",
"locales",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"locales",
")",
"?",
"$",
"this",
"->",
"locales",
":",
"(",
"$",
"this",
"->",
"locales",
"=",
"$",
"locales",
")",
";",
"}"
] | Get or set the available locales.
@param array|null $locales
@return array | [
"Get",
"or",
"set",
"the",
"available",
"locales",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L189-L194 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.element | protected function element($element = null)
{
return is_null($element)
? $this->element
: ($this->element = $element);
} | php | protected function element($element = null)
{
return is_null($element)
? $this->element
: ($this->element = $element);
} | [
"protected",
"function",
"element",
"(",
"$",
"element",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"element",
")",
"?",
"$",
"this",
"->",
"element",
":",
"(",
"$",
"this",
"->",
"element",
"=",
"$",
"element",
")",
";",
"}"
] | Get or set the current element.
@param string|null $element
@return string | [
"Get",
"or",
"set",
"the",
"current",
"element",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L203-L208 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.arguments | protected function arguments(array $arguments = null)
{
return is_null($arguments)
? $this->arguments
: ($this->arguments = $arguments);
} | php | protected function arguments(array $arguments = null)
{
return is_null($arguments)
? $this->arguments
: ($this->arguments = $arguments);
} | [
"protected",
"function",
"arguments",
"(",
"array",
"$",
"arguments",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"arguments",
")",
"?",
"$",
"this",
"->",
"arguments",
":",
"(",
"$",
"this",
"->",
"arguments",
"=",
"$",
"arguments",
")",
";"... | Get or set the arguments.
@param array|null $arguments
@return array | [
"Get",
"or",
"set",
"the",
"arguments",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L217-L222 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.methods | protected function methods(array $methods = null)
{
return is_null($methods)
? $this->methods
: ($this->methods = $methods);
} | php | protected function methods(array $methods = null)
{
return is_null($methods)
? $this->methods
: ($this->methods = $methods);
} | [
"protected",
"function",
"methods",
"(",
"array",
"$",
"methods",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"methods",
")",
"?",
"$",
"this",
"->",
"methods",
":",
"(",
"$",
"this",
"->",
"methods",
"=",
"$",
"methods",
")",
";",
"}"
] | Get or set the methods.
@param array|null $methods
@return array | [
"Get",
"or",
"set",
"the",
"methods",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L231-L236 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.translatableIndicator | protected function translatableIndicator($add = null)
{
return is_null($add)
? $this->translatableIndicator
: ($this->translatableIndicator = (bool) $add);
} | php | protected function translatableIndicator($add = null)
{
return is_null($add)
? $this->translatableIndicator
: ($this->translatableIndicator = (bool) $add);
} | [
"protected",
"function",
"translatableIndicator",
"(",
"$",
"add",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"add",
")",
"?",
"$",
"this",
"->",
"translatableIndicator",
":",
"(",
"$",
"this",
"->",
"translatableIndicator",
"=",
"(",
"bool",
")... | Get or set the translatable indicator boolean.
@param bool|null $add
@return bool | [
"Get",
"or",
"set",
"the",
"translatable",
"indicator",
"boolean",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L259-L264 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.overwriteArgument | protected function overwriteArgument($argument, $value)
{
$arguments = $this->arguments();
$arguments[$argument] = $value;
$this->arguments($arguments);
} | php | protected function overwriteArgument($argument, $value)
{
$arguments = $this->arguments();
$arguments[$argument] = $value;
$this->arguments($arguments);
} | [
"protected",
"function",
"overwriteArgument",
"(",
"$",
"argument",
",",
"$",
"value",
")",
"{",
"$",
"arguments",
"=",
"$",
"this",
"->",
"arguments",
"(",
")",
";",
"$",
"arguments",
"[",
"$",
"argument",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"... | Overwrites an argument.
@param string $argument
@param string|array $value | [
"Overwrites",
"an",
"argument",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L272-L279 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.addMethod | protected function addMethod($name, $parameters)
{
$methods = $this->methods();
$parameters = is_array($parameters) ? $parameters : [$parameters];
$methods[] = compact('name', 'parameters');
$this->methods($methods);
} | php | protected function addMethod($name, $parameters)
{
$methods = $this->methods();
$parameters = is_array($parameters) ? $parameters : [$parameters];
$methods[] = compact('name', 'parameters');
$this->methods($methods);
} | [
"protected",
"function",
"addMethod",
"(",
"$",
"name",
",",
"$",
"parameters",
")",
"{",
"$",
"methods",
"=",
"$",
"this",
"->",
"methods",
"(",
")",
";",
"$",
"parameters",
"=",
"is_array",
"(",
"$",
"parameters",
")",
"?",
"$",
"parameters",
":",
... | Adds a method.
@param string $name
@param string|array $parameters | [
"Adds",
"a",
"method",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L287-L296 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.createInput | protected function createInput($currentLocale = null)
{
// Create element using arguments.
$element = call_user_func_array([$this->form, $this->element()], array_values($this->arguments()));
// Elements such as 'bind' do not return renderable stuff and do not accept methods.
if ($element) {
// Apply requested methods.
foreach ($this->methods() as $method) {
$methodName = $method['name'];
$methodParameters = $method['parameters'];
// Check if method is locale-specific.
if (ends_with($methodName, 'ForLocale')) {
$methodName = strstr($methodName, 'ForLocale', true);
$locales = array_shift($methodParameters);
$locales = is_array($locales) ? $locales : [$locales];
if (!is_null($currentLocale) && !in_array($currentLocale, $locales)) {
// Method should not be applied for this locale.
continue;
}
}
// Call method.
if (!empty($methodParameters)) {
call_user_func_array([$element, $methodName], $this->replacePlaceholdersRecursively($methodParameters, $currentLocale));
} else {
$element->{$methodName}();
}
}
}
return $element;
} | php | protected function createInput($currentLocale = null)
{
// Create element using arguments.
$element = call_user_func_array([$this->form, $this->element()], array_values($this->arguments()));
// Elements such as 'bind' do not return renderable stuff and do not accept methods.
if ($element) {
// Apply requested methods.
foreach ($this->methods() as $method) {
$methodName = $method['name'];
$methodParameters = $method['parameters'];
// Check if method is locale-specific.
if (ends_with($methodName, 'ForLocale')) {
$methodName = strstr($methodName, 'ForLocale', true);
$locales = array_shift($methodParameters);
$locales = is_array($locales) ? $locales : [$locales];
if (!is_null($currentLocale) && !in_array($currentLocale, $locales)) {
// Method should not be applied for this locale.
continue;
}
}
// Call method.
if (!empty($methodParameters)) {
call_user_func_array([$element, $methodName], $this->replacePlaceholdersRecursively($methodParameters, $currentLocale));
} else {
$element->{$methodName}();
}
}
}
return $element;
} | [
"protected",
"function",
"createInput",
"(",
"$",
"currentLocale",
"=",
"null",
")",
"{",
"// Create element using arguments.",
"$",
"element",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"form",
",",
"$",
"this",
"->",
"element",
"(",
")",
"]",
... | Creates an input element using the supplied arguments and methods.
@param string|null $currentLocale
@return mixed | [
"Creates",
"an",
"input",
"element",
"using",
"the",
"supplied",
"arguments",
"and",
"methods",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L361-L394 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.applyElementBehavior | protected function applyElementBehavior()
{
$behaviors = isset($this->elementBehaviors[$this->element()]) ? $this->elementBehaviors[$this->element()] : [];
foreach ($behaviors as $behavior) {
$this->{$behavior}(true);
}
} | php | protected function applyElementBehavior()
{
$behaviors = isset($this->elementBehaviors[$this->element()]) ? $this->elementBehaviors[$this->element()] : [];
foreach ($behaviors as $behavior) {
$this->{$behavior}(true);
}
} | [
"protected",
"function",
"applyElementBehavior",
"(",
")",
"{",
"$",
"behaviors",
"=",
"isset",
"(",
"$",
"this",
"->",
"elementBehaviors",
"[",
"$",
"this",
"->",
"element",
"(",
")",
"]",
")",
"?",
"$",
"this",
"->",
"elementBehaviors",
"[",
"$",
"this... | Add specific element behavior to the current translatable form element. | [
"Add",
"specific",
"element",
"behavior",
"to",
"the",
"current",
"translatable",
"form",
"element",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L418-L425 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.mapArguments | protected function mapArguments(array $arguments)
{
$keys = isset($this->mappableArguments[$this->element()]) ? $this->mappableArguments[$this->element()] : [];
return array_combine(array_slice($keys, 0, count($arguments)), $arguments);
} | php | protected function mapArguments(array $arguments)
{
$keys = isset($this->mappableArguments[$this->element()]) ? $this->mappableArguments[$this->element()] : [];
return array_combine(array_slice($keys, 0, count($arguments)), $arguments);
} | [
"protected",
"function",
"mapArguments",
"(",
"array",
"$",
"arguments",
")",
"{",
"$",
"keys",
"=",
"isset",
"(",
"$",
"this",
"->",
"mappableArguments",
"[",
"$",
"this",
"->",
"element",
"(",
")",
"]",
")",
"?",
"$",
"this",
"->",
"mappableArguments",... | Maps the form element arguments to their name.
@param array $arguments
@return array | [
"Maps",
"the",
"form",
"element",
"arguments",
"to",
"their",
"name",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L434-L439 | train |
TypiCMS/Laravel-Translatable-Bootforms | src/TranslatableBootForm.php | TranslatableBootForm.setTranslatableLabelIndicator | protected function setTranslatableLabelIndicator($locale)
{
$localizedLabel = str_replace('%label', $this->arguments()['label'], $this->config['label-locale-indicator']);
$this->overwriteArgument('label', str_replace('%locale', $locale, $localizedLabel));
} | php | protected function setTranslatableLabelIndicator($locale)
{
$localizedLabel = str_replace('%label', $this->arguments()['label'], $this->config['label-locale-indicator']);
$this->overwriteArgument('label', str_replace('%locale', $locale, $localizedLabel));
} | [
"protected",
"function",
"setTranslatableLabelIndicator",
"(",
"$",
"locale",
")",
"{",
"$",
"localizedLabel",
"=",
"str_replace",
"(",
"'%label'",
",",
"$",
"this",
"->",
"arguments",
"(",
")",
"[",
"'label'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"... | Add a locale indicator to the label.
@param string $locale | [
"Add",
"a",
"locale",
"indicator",
"to",
"the",
"label",
"."
] | c1c877cff1aed4b8a827fc6b064bfb7832a423ec | https://github.com/TypiCMS/Laravel-Translatable-Bootforms/blob/c1c877cff1aed4b8a827fc6b064bfb7832a423ec/src/TranslatableBootForm.php#L446-L450 | train |
RhubarbPHP/Rhubarb | src/Deployment/ResourceDeploymentPackage.php | ResourceDeploymentPackage.getDeployedUrls | public function getDeployedUrls()
{
$deploymentHandler = ResourceDeploymentProvider::getProvider();
$urls = [];
foreach ($this->resourcesToDeploy as $path) {
$urls[] = $deploymentHandler->getDeployedResourceUrl($path);
}
return $urls;
} | php | public function getDeployedUrls()
{
$deploymentHandler = ResourceDeploymentProvider::getProvider();
$urls = [];
foreach ($this->resourcesToDeploy as $path) {
$urls[] = $deploymentHandler->getDeployedResourceUrl($path);
}
return $urls;
} | [
"public",
"function",
"getDeployedUrls",
"(",
")",
"{",
"$",
"deploymentHandler",
"=",
"ResourceDeploymentProvider",
"::",
"getProvider",
"(",
")",
";",
"$",
"urls",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"resourcesToDeploy",
"as",
"$",
"path... | Returns the urls with which the resources can be accessed after deployment. | [
"Returns",
"the",
"urls",
"with",
"which",
"the",
"resources",
"can",
"be",
"accessed",
"after",
"deployment",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Deployment/ResourceDeploymentPackage.php#L33-L44 | train |
RhubarbPHP/Rhubarb | src/Application.php | Application.registerModule | public final function registerModule(Module $module)
{
$dependencies = $module->getModules();
foreach($dependencies as $dependency){
$this->registerModule($dependency);
}
$this->modules[$module->getModuleName()] = $module;
} | php | public final function registerModule(Module $module)
{
$dependencies = $module->getModules();
foreach($dependencies as $dependency){
$this->registerModule($dependency);
}
$this->modules[$module->getModuleName()] = $module;
} | [
"public",
"final",
"function",
"registerModule",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"dependencies",
"=",
"$",
"module",
"->",
"getModules",
"(",
")",
";",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"$",
"this",
"->"... | Register a module with the application.
Also registers the dependencies of the application also
@param Module $module | [
"Register",
"a",
"module",
"with",
"the",
"application",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Application.php#L214-L223 | train |
RhubarbPHP/Rhubarb | src/Application.php | Application.filterUrlHandlers | public final function filterUrlHandlers($handlerSet)
{
$filteredHandlers = [];
foreach ($handlerSet as $handlers) {
$filteredHandlers = array_merge($filteredHandlers, $handlers);
}
uasort($filteredHandlers, function (UrlHandler $a, UrlHandler $b) {
$aPriority = $a->getPriority();
$bPriority = $b->getPriority();
if ($aPriority == $bPriority) {
return ($a->getCreationOrder() > $b->getCreationOrder());
}
return ($aPriority <= $bPriority);
});
return $filteredHandlers;
} | php | public final function filterUrlHandlers($handlerSet)
{
$filteredHandlers = [];
foreach ($handlerSet as $handlers) {
$filteredHandlers = array_merge($filteredHandlers, $handlers);
}
uasort($filteredHandlers, function (UrlHandler $a, UrlHandler $b) {
$aPriority = $a->getPriority();
$bPriority = $b->getPriority();
if ($aPriority == $bPriority) {
return ($a->getCreationOrder() > $b->getCreationOrder());
}
return ($aPriority <= $bPriority);
});
return $filteredHandlers;
} | [
"public",
"final",
"function",
"filterUrlHandlers",
"(",
"$",
"handlerSet",
")",
"{",
"$",
"filteredHandlers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"handlerSet",
"as",
"$",
"handlers",
")",
"{",
"$",
"filteredHandlers",
"=",
"array_merge",
"(",
"$",
"f... | Get's an array of url handlers from all registered modules.
@param UrlHandler[] $handlerSet
@return UrlHandler[] | [
"Get",
"s",
"an",
"array",
"of",
"url",
"handlers",
"from",
"all",
"registered",
"modules",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Application.php#L239-L259 | train |
RhubarbPHP/Rhubarb | src/Application.php | Application.initialiseModules | public final function initialiseModules()
{
foreach ($this->modules as $module) {
$module->initialiseModule();
}
// Initialise the application 'module' itself.
$this->initialiseModule();
$handlers = [];
foreach ($this->modules as $module) {
$handlers[] = $module->getUrlHandlers();
}
$this->rootHandlers = $this->filterUrlHandlers($handlers);
} | php | public final function initialiseModules()
{
foreach ($this->modules as $module) {
$module->initialiseModule();
}
// Initialise the application 'module' itself.
$this->initialiseModule();
$handlers = [];
foreach ($this->modules as $module) {
$handlers[] = $module->getUrlHandlers();
}
$this->rootHandlers = $this->filterUrlHandlers($handlers);
} | [
"public",
"final",
"function",
"initialiseModules",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"module",
"->",
"initialiseModule",
"(",
")",
";",
"}",
"// Initialise the application 'module' itself.",
"$",
... | Asks all modules to initialise.
Called automatically when processing requests. | [
"Asks",
"all",
"modules",
"to",
"initialise",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Application.php#L266-L281 | train |
RhubarbPHP/Rhubarb | src/Application.php | Application.getAllResponseFilters | private function getAllResponseFilters($preResponse = false)
{
$filters = [];
foreach ($this->modules as $module) {
$moduleFilters = $module->getResponseFilters();
foreach($moduleFilters as $filter){
if ($preResponse && $filter->isPreResponse()){
$filters[] = $filter;
} elseif (!$preResponse && !$filter->isPreResponse()){
$filters[] = $filter;
}
}
}
return $filters;
} | php | private function getAllResponseFilters($preResponse = false)
{
$filters = [];
foreach ($this->modules as $module) {
$moduleFilters = $module->getResponseFilters();
foreach($moduleFilters as $filter){
if ($preResponse && $filter->isPreResponse()){
$filters[] = $filter;
} elseif (!$preResponse && !$filter->isPreResponse()){
$filters[] = $filter;
}
}
}
return $filters;
} | [
"private",
"function",
"getAllResponseFilters",
"(",
"$",
"preResponse",
"=",
"false",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"moduleFilters",
"=",
"$",
"module",
... | Get's an array of response filters from all registered modules.
@return \Rhubarb\Crown\ResponseFilters\ResponseFilter[] | [
"Get",
"s",
"an",
"array",
"of",
"response",
"filters",
"from",
"all",
"registered",
"modules",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Application.php#L288-L306 | train |
zibios/wrike-php-guzzle | src/Client/GuzzleClient.php | GuzzleClient.executeRequestForParams | public function executeRequestForParams(
string $requestMethod,
string $path,
array $params,
string $accessToken
): ResponseInterface {
RequestMethodEnum::assertIsValidValue($requestMethod);
$options = $this->calculateOptionsForParams($requestMethod, $params, $accessToken);
if (RequestMethodEnum::UPLOAD === $requestMethod) {
$requestMethod = RequestMethodEnum::POST;
}
return $this->request($requestMethod, $path, $options);
} | php | public function executeRequestForParams(
string $requestMethod,
string $path,
array $params,
string $accessToken
): ResponseInterface {
RequestMethodEnum::assertIsValidValue($requestMethod);
$options = $this->calculateOptionsForParams($requestMethod, $params, $accessToken);
if (RequestMethodEnum::UPLOAD === $requestMethod) {
$requestMethod = RequestMethodEnum::POST;
}
return $this->request($requestMethod, $path, $options);
} | [
"public",
"function",
"executeRequestForParams",
"(",
"string",
"$",
"requestMethod",
",",
"string",
"$",
"path",
",",
"array",
"$",
"params",
",",
"string",
"$",
"accessToken",
")",
":",
"ResponseInterface",
"{",
"RequestMethodEnum",
"::",
"assertIsValidValue",
"... | Request method.
Generic format for HTTP client request method.
@param string $requestMethod GET/POST/PUT/DELETE
@param string $path full path to REST resource without domain, ex. 'contacts'
@param array $params optional params for GET/POST request
@param string $accessToken Access Token for Wrike access
@see \Zibios\WrikePhpLibrary\Enum\Api\RequestMethodEnum
@see \Zibios\WrikePhpLibrary\Enum\Api\RequestPathFormatEnum
@throws \Throwable
@throws ApiException
@return ResponseInterface | [
"Request",
"method",
"."
] | 957319ba26020b207e756699708e865d61b7da2f | https://github.com/zibios/wrike-php-guzzle/blob/957319ba26020b207e756699708e865d61b7da2f/src/Client/GuzzleClient.php#L47-L60 | train |
zibios/wrike-php-guzzle | src/Client/GuzzleClient.php | GuzzleClient.calculateOptionsForParams | protected function calculateOptionsForParams(string $requestMethod, array $params, string $accessToken): array
{
$options = $this->prepareBaseOptions($accessToken);
if (0 === \count($params)) {
return $options;
}
switch ($requestMethod) {
case RequestMethodEnum::GET:
case RequestMethodEnum::DELETE:
$options['query'] = $params;
break;
case RequestMethodEnum::PUT:
case RequestMethodEnum::POST:
$options['form_params'] = $params;
break;
case RequestMethodEnum::UPLOAD:
if (array_key_exists('resource', $params) && array_key_exists('name', $params)) {
$options['headers']['X-File-Name'] = $params['name'];
$options['multipart'] = [
[
'contents' => $params['resource'],
'name' => $params['name'],
],
];
}
break;
default:
throw new \InvalidArgumentException(sprintf('Request method "%s" not allowed!', $requestMethod));
}
return $options;
} | php | protected function calculateOptionsForParams(string $requestMethod, array $params, string $accessToken): array
{
$options = $this->prepareBaseOptions($accessToken);
if (0 === \count($params)) {
return $options;
}
switch ($requestMethod) {
case RequestMethodEnum::GET:
case RequestMethodEnum::DELETE:
$options['query'] = $params;
break;
case RequestMethodEnum::PUT:
case RequestMethodEnum::POST:
$options['form_params'] = $params;
break;
case RequestMethodEnum::UPLOAD:
if (array_key_exists('resource', $params) && array_key_exists('name', $params)) {
$options['headers']['X-File-Name'] = $params['name'];
$options['multipart'] = [
[
'contents' => $params['resource'],
'name' => $params['name'],
],
];
}
break;
default:
throw new \InvalidArgumentException(sprintf('Request method "%s" not allowed!', $requestMethod));
}
return $options;
} | [
"protected",
"function",
"calculateOptionsForParams",
"(",
"string",
"$",
"requestMethod",
",",
"array",
"$",
"params",
",",
"string",
"$",
"accessToken",
")",
":",
"array",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"prepareBaseOptions",
"(",
"$",
"accessTo... | Main method for calculating request params.
@param string $requestMethod
@param array $params
@param string $accessToken
@throws \InvalidArgumentException
@return array | [
"Main",
"method",
"for",
"calculating",
"request",
"params",
"."
] | 957319ba26020b207e756699708e865d61b7da2f | https://github.com/zibios/wrike-php-guzzle/blob/957319ba26020b207e756699708e865d61b7da2f/src/Client/GuzzleClient.php#L73-L105 | train |
mediact/testing-suite | src/Installer/PackagesInstaller.php | PackagesInstaller.isPackageRequired | private function isPackageRequired(string $packageName): bool
{
foreach ($this->composer->getPackage()->getRequires() as $require) {
if ($require->getTarget() === $packageName) {
return true;
}
}
return false;
} | php | private function isPackageRequired(string $packageName): bool
{
foreach ($this->composer->getPackage()->getRequires() as $require) {
if ($require->getTarget() === $packageName) {
return true;
}
}
return false;
} | [
"private",
"function",
"isPackageRequired",
"(",
"string",
"$",
"packageName",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
"->",
"getRequires",
"(",
")",
"as",
"$",
"require",
")",
"{",
"if",
"(",
... | Whether a package has been required.
@param string $packageName
@return bool | [
"Whether",
"a",
"package",
"has",
"been",
"required",
"."
] | 98614fe3b5c174e9bda2ff88d36d30349094dbc2 | https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/Installer/PackagesInstaller.php#L101-L110 | train |
byjg/cache-engine-php | src/Psr6/CachePool.php | CachePool.addElementToBuffer | protected function addElementToBuffer(CacheItem $cacheItem)
{
if ($this->bufferSize < 1) {
return;
}
$key = $cacheItem->getKey();
$this->buffer[$key] = $cacheItem;
if (in_array($key, $this->bufferKeys)) {
return;
}
array_push($this->bufferKeys, $key);
if (count($this->bufferKeys) > $this->bufferSize) {
$element = array_shift($this->bufferKeys);
unset($this->buffer[$element]);
}
} | php | protected function addElementToBuffer(CacheItem $cacheItem)
{
if ($this->bufferSize < 1) {
return;
}
$key = $cacheItem->getKey();
$this->buffer[$key] = $cacheItem;
if (in_array($key, $this->bufferKeys)) {
return;
}
array_push($this->bufferKeys, $key);
if (count($this->bufferKeys) > $this->bufferSize) {
$element = array_shift($this->bufferKeys);
unset($this->buffer[$element]);
}
} | [
"protected",
"function",
"addElementToBuffer",
"(",
"CacheItem",
"$",
"cacheItem",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"bufferSize",
"<",
"1",
")",
"{",
"return",
";",
"}",
"$",
"key",
"=",
"$",
"cacheItem",
"->",
"getKey",
"(",
")",
";",
"$",
"t... | Add an element to buffer. If the buffer is full, the first element added will be removed
@param CacheItem $cacheItem | [
"Add",
"an",
"element",
"to",
"buffer",
".",
"If",
"the",
"buffer",
"is",
"full",
"the",
"first",
"element",
"added",
"will",
"be",
"removed"
] | 001281edc3be6d908e7865b836cb6b43bd61a5cc | https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr6/CachePool.php#L71-L90 | train |
byjg/cache-engine-php | src/Psr6/CachePool.php | CachePool.removeElementFromBuffer | protected function removeElementFromBuffer($key)
{
$result = array_search($key, $this->bufferKeys);
if ($result === false) {
return;
}
unset($this->buffer[$key]);
unset($this->bufferKeys[$result]);
} | php | protected function removeElementFromBuffer($key)
{
$result = array_search($key, $this->bufferKeys);
if ($result === false) {
return;
}
unset($this->buffer[$key]);
unset($this->bufferKeys[$result]);
} | [
"protected",
"function",
"removeElementFromBuffer",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"bufferKeys",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"return",
";",
"}",
... | Remove a specific key from buffer
@param $key | [
"Remove",
"a",
"specific",
"key",
"from",
"buffer"
] | 001281edc3be6d908e7865b836cb6b43bd61a5cc | https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr6/CachePool.php#L97-L106 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/NamespaceMappedUrlHandler.php | NamespaceMappedUrlHandler.onNoTargetFound | protected function onNoTargetFound($request, $currentUrlFragment = "")
{
if (self::$onTargetNotFoundExecuting) {
return false;
}
self::$onTargetNotFoundExecuting = true;
// Try generating a response for the url with /index on the end.
// Note that we don't try /index/. This is very deliberate as we want the default behaviour
// of the handler to kick in and redirect us to /index/ rather than just outputting it's
// contents.
if ($currentUrlFragment[strlen($currentUrlFragment) - 1] != "/") {
$currentUrlFragment .= "/";
}
$currentUrlFragment .= "index";
$response = $this->generateResponseForRequest($request, $currentUrlFragment);
self::$onTargetNotFoundExecuting = false;
return $response;
} | php | protected function onNoTargetFound($request, $currentUrlFragment = "")
{
if (self::$onTargetNotFoundExecuting) {
return false;
}
self::$onTargetNotFoundExecuting = true;
// Try generating a response for the url with /index on the end.
// Note that we don't try /index/. This is very deliberate as we want the default behaviour
// of the handler to kick in and redirect us to /index/ rather than just outputting it's
// contents.
if ($currentUrlFragment[strlen($currentUrlFragment) - 1] != "/") {
$currentUrlFragment .= "/";
}
$currentUrlFragment .= "index";
$response = $this->generateResponseForRequest($request, $currentUrlFragment);
self::$onTargetNotFoundExecuting = false;
return $response;
} | [
"protected",
"function",
"onNoTargetFound",
"(",
"$",
"request",
",",
"$",
"currentUrlFragment",
"=",
"\"\"",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"onTargetNotFoundExecuting",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"$",
"onTargetNotFoundExecut... | Override this to provide a default response in the event that no action could be found.
@param \Rhubarb\Crown\Request\Request $request The original request we tried to find a target for.
@param $currentUrlFragment
@return bool|string | [
"Override",
"this",
"to",
"provide",
"a",
"default",
"response",
"in",
"the",
"event",
"that",
"no",
"action",
"could",
"be",
"found",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/NamespaceMappedUrlHandler.php#L143-L166 | train |
RhubarbPHP/Rhubarb | src/Events/Event.php | Event.attachHandler | public function attachHandler(callable $handler, $key = null)
{
if ($key !== null) {
$this->eventHandlers[$key] = $handler;
} else {
$this->eventHandlers[] = $handler;
}
} | php | public function attachHandler(callable $handler, $key = null)
{
if ($key !== null) {
$this->eventHandlers[$key] = $handler;
} else {
$this->eventHandlers[] = $handler;
}
} | [
"public",
"function",
"attachHandler",
"(",
"callable",
"$",
"handler",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"eventHandlers",
"[",
"$",
"key",
"]",
"=",
"$",
"handler",
";",
"}",... | Attach an event handler
@param callable $handler
@param string $key An optional unique identifier for the handler in case you wish to specifically remove it later | [
"Attach",
"an",
"event",
"handler"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Events/Event.php#L31-L38 | train |
RhubarbPHP/Rhubarb | src/Events/Event.php | Event.raise | public function raise(...$arguments)
{
$firstResponse = null;
/** @var callable $callBack */
$callBack = false;
$count = count($arguments);
if ($count > 0 && is_object($arguments[$count - 1]) && is_callable($arguments[$count - 1])) {
$callBack = $arguments[$count - 1];
$arguments = array_slice($arguments, 0, -1);
}
foreach ($this->eventHandlers as $handler) {
$response = $handler(...$arguments);
if ($response !== null) {
if ($callBack) {
$callBack($response);
}
if ($firstResponse === null) {
$firstResponse = $response;
}
}
}
return $firstResponse;
} | php | public function raise(...$arguments)
{
$firstResponse = null;
/** @var callable $callBack */
$callBack = false;
$count = count($arguments);
if ($count > 0 && is_object($arguments[$count - 1]) && is_callable($arguments[$count - 1])) {
$callBack = $arguments[$count - 1];
$arguments = array_slice($arguments, 0, -1);
}
foreach ($this->eventHandlers as $handler) {
$response = $handler(...$arguments);
if ($response !== null) {
if ($callBack) {
$callBack($response);
}
if ($firstResponse === null) {
$firstResponse = $response;
}
}
}
return $firstResponse;
} | [
"public",
"function",
"raise",
"(",
"...",
"$",
"arguments",
")",
"{",
"$",
"firstResponse",
"=",
"null",
";",
"/** @var callable $callBack */",
"$",
"callBack",
"=",
"false",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"if",
"(",
"... | Call all handlers for the event with the passed arguments.
If there are multiple event handlers, this will return the earliest non-null response from the handlers.
If you need to receive response data from multiple handlers, you can pass a callback function as the last argument.
The callback function will only be called for any handler which returns a value.
@param array ...$arguments
@return mixed | [
"Call",
"all",
"handlers",
"for",
"the",
"event",
"with",
"the",
"passed",
"arguments",
".",
"If",
"there",
"are",
"multiple",
"event",
"handlers",
"this",
"will",
"return",
"the",
"earliest",
"non",
"-",
"null",
"response",
"from",
"the",
"handlers",
".",
... | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Events/Event.php#L49-L77 | train |
RhubarbPHP/Rhubarb | src/Events/Event.php | Event.removeHandler | public function removeHandler(callable $handler)
{
$key = array_search($handler, $this->eventHandlers, true);
if ($key !== false) {
unset($this->eventHandlers[$key]);
}
} | php | public function removeHandler(callable $handler)
{
$key = array_search($handler, $this->eventHandlers, true);
if ($key !== false) {
unset($this->eventHandlers[$key]);
}
} | [
"public",
"function",
"removeHandler",
"(",
"callable",
"$",
"handler",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"handler",
",",
"$",
"this",
"->",
"eventHandlers",
",",
"true",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"false",
")",
"{",
"... | Removes a specific handler. You must pass a reference to the same handler you originally attached.
@param callable $handler | [
"Removes",
"a",
"specific",
"handler",
".",
"You",
"must",
"pass",
"a",
"reference",
"to",
"the",
"same",
"handler",
"you",
"originally",
"attached",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Events/Event.php#L102-L109 | train |
mediact/testing-suite | src/MappingResolver.php | MappingResolver.resolve | public function resolve(): FileMappingReaderInterface
{
$files = [
__DIR__ . '/../templates/mapping/files',
sprintf(
__DIR__ . '/../templates/mapping/project/%s',
$this->typeResolver->resolve()
)
];
return new UnixFileMappingReader(
__DIR__ . '/../templates/files',
getcwd(),
...$files
);
} | php | public function resolve(): FileMappingReaderInterface
{
$files = [
__DIR__ . '/../templates/mapping/files',
sprintf(
__DIR__ . '/../templates/mapping/project/%s',
$this->typeResolver->resolve()
)
];
return new UnixFileMappingReader(
__DIR__ . '/../templates/files',
getcwd(),
...$files
);
} | [
"public",
"function",
"resolve",
"(",
")",
":",
"FileMappingReaderInterface",
"{",
"$",
"files",
"=",
"[",
"__DIR__",
".",
"'/../templates/mapping/files'",
",",
"sprintf",
"(",
"__DIR__",
".",
"'/../templates/mapping/project/%s'",
",",
"$",
"this",
"->",
"typeResolv... | Resolve mapping files.
@return FileMappingReaderInterface | [
"Resolve",
"mapping",
"files",
"."
] | 98614fe3b5c174e9bda2ff88d36d30349094dbc2 | https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/MappingResolver.php#L32-L47 | train |
RhubarbPHP/Rhubarb | src/Xml/NodeStrategyCollation.php | NodeStrategyCollation.processNode | protected function processNode( Node $node, \XMLReader $xmlReader )
{
$node = parent::processNode( $node, $xmlReader );
$children = [ ];
if( !$xmlReader->isEmptyElement )
{
$scanner = new NodeStrategyTraversal();
$scanner->addNodeHandler( '*', new self( function ( $node ) use ( &$children )
{
$children[] = $node;
} ) );
$scanner->parse( $xmlReader, $this->startDepth );
}
$node->children = $children;
return $node;
} | php | protected function processNode( Node $node, \XMLReader $xmlReader )
{
$node = parent::processNode( $node, $xmlReader );
$children = [ ];
if( !$xmlReader->isEmptyElement )
{
$scanner = new NodeStrategyTraversal();
$scanner->addNodeHandler( '*', new self( function ( $node ) use ( &$children )
{
$children[] = $node;
} ) );
$scanner->parse( $xmlReader, $this->startDepth );
}
$node->children = $children;
return $node;
} | [
"protected",
"function",
"processNode",
"(",
"Node",
"$",
"node",
",",
"\\",
"XMLReader",
"$",
"xmlReader",
")",
"{",
"$",
"node",
"=",
"parent",
"::",
"processNode",
"(",
"$",
"node",
",",
"$",
"xmlReader",
")",
";",
"$",
"children",
"=",
"[",
"]",
... | The collation strategy should to collate all child nodes before callback
@param Node $node
@param \XMLReader $xmlReader
@return Node The node with children collated will be passed to the callback | [
"The",
"collation",
"strategy",
"should",
"to",
"collate",
"all",
"child",
"nodes",
"before",
"callback"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Xml/NodeStrategyCollation.php#L50-L68 | train |
RhubarbPHP/Rhubarb | src/Sessions/Session.php | Session.getSessionProvider | final protected function getSessionProvider()
{
if ($this->sessionProvider == null) {
$this->sessionProvider = $this->getNewSessionProvider();
}
return $this->sessionProvider;
} | php | final protected function getSessionProvider()
{
if ($this->sessionProvider == null) {
$this->sessionProvider = $this->getNewSessionProvider();
}
return $this->sessionProvider;
} | [
"final",
"protected",
"function",
"getSessionProvider",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sessionProvider",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"sessionProvider",
"=",
"$",
"this",
"->",
"getNewSessionProvider",
"(",
")",
";",
"}",
"retu... | Get's the SessionProvider for this session.
To change the session provider for a session simply implement the GetNewSessionProvider() method.
@return SessionProviders\SessionProvider | [
"Get",
"s",
"the",
"SessionProvider",
"for",
"this",
"session",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Sessions/Session.php#L52-L59 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.calculateRawProgresses | private function calculateRawProgresses(array $dist): array
{
$m = \count($dist) - 1;
$n = \count($dist[0]) - 1;
$progresses = $trace = [];
for (
$x = $m, $y = $n;
$x !== 0 && $y !== 0;
[$x, $y] = $trace
) {
switch ($dist[$x][$y]) {
case $dist[$x - 1][$y] + $this->costMap[self::OP_DEL]:
$trace = [$x - 1, $y, self::OP_DEL];
break;
case $dist[$x][$y - 1] + $this->costMap[self::OP_INS]:
$trace = [$x, $y - 1, self::OP_INS];
break;
case $dist[$x - 1][$y - 1] + $this->costMap[self::OP_REP]:
$trace = [$x - 1, $y - 1, self::OP_REP];
break;
default:
$trace = [$x - 1, $y - 1, self::OP_CPY];
break;
}
$progresses[] = [$x, $y, $trace[2]];
}
for (; $x > 0; --$x) {
$progresses[] = [$x, 0, self::OP_DEL];
}
for (; $y > 0; --$y) {
$progresses[] = [0, $y, self::OP_INS];
}
return $progresses;
} | php | private function calculateRawProgresses(array $dist): array
{
$m = \count($dist) - 1;
$n = \count($dist[0]) - 1;
$progresses = $trace = [];
for (
$x = $m, $y = $n;
$x !== 0 && $y !== 0;
[$x, $y] = $trace
) {
switch ($dist[$x][$y]) {
case $dist[$x - 1][$y] + $this->costMap[self::OP_DEL]:
$trace = [$x - 1, $y, self::OP_DEL];
break;
case $dist[$x][$y - 1] + $this->costMap[self::OP_INS]:
$trace = [$x, $y - 1, self::OP_INS];
break;
case $dist[$x - 1][$y - 1] + $this->costMap[self::OP_REP]:
$trace = [$x - 1, $y - 1, self::OP_REP];
break;
default:
$trace = [$x - 1, $y - 1, self::OP_CPY];
break;
}
$progresses[] = [$x, $y, $trace[2]];
}
for (; $x > 0; --$x) {
$progresses[] = [$x, 0, self::OP_DEL];
}
for (; $y > 0; --$y) {
$progresses[] = [0, $y, self::OP_INS];
}
return $progresses;
} | [
"private",
"function",
"calculateRawProgresses",
"(",
"array",
"$",
"dist",
")",
":",
"array",
"{",
"$",
"m",
"=",
"\\",
"count",
"(",
"$",
"dist",
")",
"-",
"1",
";",
"$",
"n",
"=",
"\\",
"count",
"(",
"$",
"dist",
"[",
"0",
"]",
")",
"-",
"1"... | Calculate the raw progresses.
@param array $dist the distance array
@return array the raw progresses | [
"Calculate",
"the",
"raw",
"progresses",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L352-L391 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.resolveRawProgresses | private function resolveRawProgresses(array $rawProgresses): array
{
static $callbacks;
$callbacks = $callbacks ?? [
self::OP_CPY => function (int $x, int $y): array {
return [self::OP_CPY, $x - 1, $y - 1, 1];
},
self::OP_DEL => function (int $x, int $y): array {
return [self::OP_DEL, $x - 1, $y, 1];
},
self::OP_INS => function (int $x, int $y): array {
return [self::OP_INS, $x, $y - 1, 1];
},
self::OP_REP => function (int $x, int $y): array {
return [self::OP_REP, $x - 1, $y - 1, 1];
},
];
foreach ($rawProgresses as &$rawProgress) {
$rawProgress = $callbacks[$rawProgress[2]](
$rawProgress[0],
$rawProgress[1]
);
}
unset($rawProgress);
return $rawProgresses;
} | php | private function resolveRawProgresses(array $rawProgresses): array
{
static $callbacks;
$callbacks = $callbacks ?? [
self::OP_CPY => function (int $x, int $y): array {
return [self::OP_CPY, $x - 1, $y - 1, 1];
},
self::OP_DEL => function (int $x, int $y): array {
return [self::OP_DEL, $x - 1, $y, 1];
},
self::OP_INS => function (int $x, int $y): array {
return [self::OP_INS, $x, $y - 1, 1];
},
self::OP_REP => function (int $x, int $y): array {
return [self::OP_REP, $x - 1, $y - 1, 1];
},
];
foreach ($rawProgresses as &$rawProgress) {
$rawProgress = $callbacks[$rawProgress[2]](
$rawProgress[0],
$rawProgress[1]
);
}
unset($rawProgress);
return $rawProgresses;
} | [
"private",
"function",
"resolveRawProgresses",
"(",
"array",
"$",
"rawProgresses",
")",
":",
"array",
"{",
"static",
"$",
"callbacks",
";",
"$",
"callbacks",
"=",
"$",
"callbacks",
"??",
"[",
"self",
"::",
"OP_CPY",
"=>",
"function",
"(",
"int",
"$",
"x",
... | Resolve the raw progresses.
@param array $rawProgresses the raw progresses
@return array [operation, old position, new position, length] | [
"Resolve",
"the",
"raw",
"progresses",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L400-L428 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.mergeNeighborProgresses | private function mergeNeighborProgresses(array $progresses): array
{
$progressesCount = \count($progresses);
if ($progressesCount === 0) {
return [];
}
$merged = [];
$last = $progresses[0];
for ($step = 1; $step < $progressesCount; ++$step) {
$progress = $progresses[$step];
if ($last[0] === $progress[0]) {
$progress[3] += $last[3];
} else {
$merged[] = $last;
}
$last = $progress;
}
$merged[] = $last;
return $merged;
} | php | private function mergeNeighborProgresses(array $progresses): array
{
$progressesCount = \count($progresses);
if ($progressesCount === 0) {
return [];
}
$merged = [];
$last = $progresses[0];
for ($step = 1; $step < $progressesCount; ++$step) {
$progress = $progresses[$step];
if ($last[0] === $progress[0]) {
$progress[3] += $last[3];
} else {
$merged[] = $last;
}
$last = $progress;
}
$merged[] = $last;
return $merged;
} | [
"private",
"function",
"mergeNeighborProgresses",
"(",
"array",
"$",
"progresses",
")",
":",
"array",
"{",
"$",
"progressesCount",
"=",
"\\",
"count",
"(",
"$",
"progresses",
")",
";",
"if",
"(",
"$",
"progressesCount",
"===",
"0",
")",
"{",
"return",
"[",... | Merge neighbor progresses and return the merged result.
@param array $progresses the progresses
@return array | [
"Merge",
"neighbor",
"progresses",
"and",
"return",
"the",
"merged",
"result",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L437-L463 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.makeProgressesPatch | private function makeProgressesPatch(array $olds, array $news, array $progresses): array
{
foreach ($progresses as $step => [$operation, $oldPos, $newPos, $length]) {
if ($operation & (self::OP_CPY | self::OP_DEL)) {
$chars = \array_slice($olds, $oldPos, $length);
} elseif ($operation & (self::OP_INS | self::OP_REP)) {
$chars = \array_slice($news, $newPos, $length);
} else {
$chars = [];
}
$progresses[$step][2] = \implode('', $chars);
}
return $progresses;
} | php | private function makeProgressesPatch(array $olds, array $news, array $progresses): array
{
foreach ($progresses as $step => [$operation, $oldPos, $newPos, $length]) {
if ($operation & (self::OP_CPY | self::OP_DEL)) {
$chars = \array_slice($olds, $oldPos, $length);
} elseif ($operation & (self::OP_INS | self::OP_REP)) {
$chars = \array_slice($news, $newPos, $length);
} else {
$chars = [];
}
$progresses[$step][2] = \implode('', $chars);
}
return $progresses;
} | [
"private",
"function",
"makeProgressesPatch",
"(",
"array",
"$",
"olds",
",",
"array",
"$",
"news",
",",
"array",
"$",
"progresses",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"progresses",
"as",
"$",
"step",
"=>",
"[",
"$",
"operation",
",",
"$",
"o... | Make progresses just like patch.
@param array $olds the old characters
@param array $news the new characters
@param array $progresses the progresses
@return array | [
"Make",
"progresses",
"just",
"like",
"patch",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L474-L489 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.removeCopyProgresses | private function removeCopyProgresses(array $progresses): array
{
foreach ($progresses as $step => $progress) {
if ($progress[0] === self::OP_CPY) {
unset($progresses[$step]);
}
}
// resort keys
return \array_values($progresses);
} | php | private function removeCopyProgresses(array $progresses): array
{
foreach ($progresses as $step => $progress) {
if ($progress[0] === self::OP_CPY) {
unset($progresses[$step]);
}
}
// resort keys
return \array_values($progresses);
} | [
"private",
"function",
"removeCopyProgresses",
"(",
"array",
"$",
"progresses",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"progresses",
"as",
"$",
"step",
"=>",
"$",
"progress",
")",
"{",
"if",
"(",
"$",
"progress",
"[",
"0",
"]",
"===",
"self",
"::... | Remove "COPY" progresses.
@param array $progresses the progresses
@return array | [
"Remove",
"COPY",
"progresses",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L498-L508 | train |
jfcherng/php-levenshtein-distance | src/LevenshteinDistance.php | LevenshteinDistance.stringifyOperations | private function stringifyOperations(array $progresses): array
{
foreach ($progresses as &$progress) {
$progress[0] = static::OP_INT2STR_MAP[$progress[0]];
}
unset($progress);
return $progresses;
} | php | private function stringifyOperations(array $progresses): array
{
foreach ($progresses as &$progress) {
$progress[0] = static::OP_INT2STR_MAP[$progress[0]];
}
unset($progress);
return $progresses;
} | [
"private",
"function",
"stringifyOperations",
"(",
"array",
"$",
"progresses",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"progresses",
"as",
"&",
"$",
"progress",
")",
"{",
"$",
"progress",
"[",
"0",
"]",
"=",
"static",
"::",
"OP_INT2STR_MAP",
"[",
"$... | Convert the operation in progresses from int to string.
@param array $progresses the progresses
@return array | [
"Convert",
"the",
"operation",
"in",
"progresses",
"from",
"int",
"to",
"string",
"."
] | 7184e6220547a80752c08386a2907655f0b20b56 | https://github.com/jfcherng/php-levenshtein-distance/blob/7184e6220547a80752c08386a2907655f0b20b56/src/LevenshteinDistance.php#L517-L525 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/UrlHandler.php | UrlHandler.addChildUrlHandlers | private function addChildUrlHandlers($childHandlers)
{
foreach ($childHandlers as $childUrl => $childHandler) {
$childHandler->setUrl($childUrl);
$childHandler->setParentHandler($this);
$this->childUrlHandlers[] = $childHandler;
}
return $this;
} | php | private function addChildUrlHandlers($childHandlers)
{
foreach ($childHandlers as $childUrl => $childHandler) {
$childHandler->setUrl($childUrl);
$childHandler->setParentHandler($this);
$this->childUrlHandlers[] = $childHandler;
}
return $this;
} | [
"private",
"function",
"addChildUrlHandlers",
"(",
"$",
"childHandlers",
")",
"{",
"foreach",
"(",
"$",
"childHandlers",
"as",
"$",
"childUrl",
"=>",
"$",
"childHandler",
")",
"{",
"$",
"childHandler",
"->",
"setUrl",
"(",
"$",
"childUrl",
")",
";",
"$",
"... | Adds child url handlers to this the parent.
@param UrlHandler[] $childHandlers
@return $this | [
"Adds",
"child",
"url",
"handlers",
"to",
"this",
"the",
"parent",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/UrlHandler.php#L204-L214 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/UrlHandler.php | UrlHandler.buildCompleteChildUrl | protected function buildCompleteChildUrl($childUrlFragment)
{
if ($this->parentHandler !== null) {
return $this->parentHandler->matchingUrl . $childUrlFragment;
} else {
return $childUrlFragment;
}
} | php | protected function buildCompleteChildUrl($childUrlFragment)
{
if ($this->parentHandler !== null) {
return $this->parentHandler->matchingUrl . $childUrlFragment;
} else {
return $childUrlFragment;
}
} | [
"protected",
"function",
"buildCompleteChildUrl",
"(",
"$",
"childUrlFragment",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parentHandler",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"parentHandler",
"->",
"matchingUrl",
".",
"$",
"childUrlFragment",
"... | Takes a URL fragment understood by a child handler and adds back the parents URL fragment to form a complete URL.
@param $childUrlFragment
@return string | [
"Takes",
"a",
"URL",
"fragment",
"understood",
"by",
"a",
"child",
"handler",
"and",
"adds",
"back",
"the",
"parents",
"URL",
"fragment",
"to",
"form",
"a",
"complete",
"URL",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/UrlHandler.php#L253-L260 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/UrlHandler.php | UrlHandler.generateResponse | public function generateResponse($request = null, $currentUrlFragment = false)
{
if ($currentUrlFragment === false) {
$currentUrlFragment = $request->urlPath;
}
if (!$this->matchesRequest($request, $currentUrlFragment)) {
return false;
}
UrlHandler::setExecutingUrlHandler($this);
Log::debug(function () {
return "Handler " . get_class($this) . " selected to generate response";
}, "ROUTER");
Log::indent();
$context = new PhpContext();
$context->UrlHandler = $this;
$this->matchingUrl = $this->getMatchingUrlFragment($request, $currentUrlFragment);
if ($this->parentHandler) {
$this->handledUrl = $this->parentHandler->handledUrl . $this->matchingUrl;
} else {
$this->handledUrl = $this->matchingUrl;
}
$childUrlFragment = substr($currentUrlFragment, strlen($this->matchingUrl));
foreach ($this->childUrlHandlers as $childHandler) {
$response = $childHandler->generateResponse($request, $childUrlFragment);
if ($response !== false) {
return $response;
}
}
$response = $this->generateResponseForRequest($request, $currentUrlFragment);
Log::debug(function () use ($response) {
if ($response !== false) {
return "Response generated by handler";
}
return "Handler deferred generation";
}, "ROUTER");
Log::outdent();
return $response;
} | php | public function generateResponse($request = null, $currentUrlFragment = false)
{
if ($currentUrlFragment === false) {
$currentUrlFragment = $request->urlPath;
}
if (!$this->matchesRequest($request, $currentUrlFragment)) {
return false;
}
UrlHandler::setExecutingUrlHandler($this);
Log::debug(function () {
return "Handler " . get_class($this) . " selected to generate response";
}, "ROUTER");
Log::indent();
$context = new PhpContext();
$context->UrlHandler = $this;
$this->matchingUrl = $this->getMatchingUrlFragment($request, $currentUrlFragment);
if ($this->parentHandler) {
$this->handledUrl = $this->parentHandler->handledUrl . $this->matchingUrl;
} else {
$this->handledUrl = $this->matchingUrl;
}
$childUrlFragment = substr($currentUrlFragment, strlen($this->matchingUrl));
foreach ($this->childUrlHandlers as $childHandler) {
$response = $childHandler->generateResponse($request, $childUrlFragment);
if ($response !== false) {
return $response;
}
}
$response = $this->generateResponseForRequest($request, $currentUrlFragment);
Log::debug(function () use ($response) {
if ($response !== false) {
return "Response generated by handler";
}
return "Handler deferred generation";
}, "ROUTER");
Log::outdent();
return $response;
} | [
"public",
"function",
"generateResponse",
"(",
"$",
"request",
"=",
"null",
",",
"$",
"currentUrlFragment",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"currentUrlFragment",
"===",
"false",
")",
"{",
"$",
"currentUrlFragment",
"=",
"$",
"request",
"->",
"urlPath... | Return the response when appropriate or false if no response could be generated.
If child handlers are present they are given priority.
@param mixed $request
@param bool|string $currentUrlFragment
@return bool|Response | [
"Return",
"the",
"response",
"when",
"appropriate",
"or",
"false",
"if",
"no",
"response",
"could",
"be",
"generated",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/UrlHandler.php#L278-L330 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/UrlHandler.php | UrlHandler.getMatchingUrlFragment | protected function getMatchingUrlFragment(Request $request, $currentUrlFragment = "")
{
if ($currentUrlFragment[strlen($currentUrlFragment) - 1] != "/") {
$currentUrlFragment .= "/";
}
if (stripos($currentUrlFragment, $this->url) === 0) {
return $this->url;
}
return false;
} | php | protected function getMatchingUrlFragment(Request $request, $currentUrlFragment = "")
{
if ($currentUrlFragment[strlen($currentUrlFragment) - 1] != "/") {
$currentUrlFragment .= "/";
}
if (stripos($currentUrlFragment, $this->url) === 0) {
return $this->url;
}
return false;
} | [
"protected",
"function",
"getMatchingUrlFragment",
"(",
"Request",
"$",
"request",
",",
"$",
"currentUrlFragment",
"=",
"\"\"",
")",
"{",
"if",
"(",
"$",
"currentUrlFragment",
"[",
"strlen",
"(",
"$",
"currentUrlFragment",
")",
"-",
"1",
"]",
"!=",
"\"/\"",
... | Returns the portion of the URL that this handler would be able to return a response for.
@param \Rhubarb\Crown\Request\Request $request
@param string $currentUrlFragment
@return bool | [
"Returns",
"the",
"portion",
"of",
"the",
"URL",
"that",
"this",
"handler",
"would",
"be",
"able",
"to",
"return",
"a",
"response",
"for",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/UrlHandler.php#L355-L366 | train |
RhubarbPHP/Rhubarb | src/UrlHandlers/UrlHandler.php | UrlHandler.matchesRequest | private function matchesRequest(Request $request, $currentUrlFragment = "")
{
// Some URL Handlers don't have a url at all in which case we assume they apply
// before even considering the url.
if ($this->url == "") {
return true;
}
return (stripos($currentUrlFragment, $this->url) === 0);
} | php | private function matchesRequest(Request $request, $currentUrlFragment = "")
{
// Some URL Handlers don't have a url at all in which case we assume they apply
// before even considering the url.
if ($this->url == "") {
return true;
}
return (stripos($currentUrlFragment, $this->url) === 0);
} | [
"private",
"function",
"matchesRequest",
"(",
"Request",
"$",
"request",
",",
"$",
"currentUrlFragment",
"=",
"\"\"",
")",
"{",
"// Some URL Handlers don't have a url at all in which case we assume they apply",
"// before even considering the url.",
"if",
"(",
"$",
"this",
"-... | Returns true of this handler's URL allows it to consider a response for the request.
In general terms this means that the current URL begins with the URL this handler is registered to handle.
However more advanced handlers might use other aspects of the request instead of the URL to determine this.
@param Request $request
@param string $currentUrlFragment
@return bool | [
"Returns",
"true",
"of",
"this",
"handler",
"s",
"URL",
"allows",
"it",
"to",
"consider",
"a",
"response",
"for",
"the",
"request",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/UrlHandlers/UrlHandler.php#L378-L387 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.makeFromDate | public static function makeFromDate($year = null, $month = null, $day = null, $timezone = null)
{
return static::makeFromDateTime($year, $month, $day, null, null, null, $timezone);
} | php | public static function makeFromDate($year = null, $month = null, $day = null, $timezone = null)
{
return static::makeFromDateTime($year, $month, $day, null, null, null, $timezone);
} | [
"public",
"static",
"function",
"makeFromDate",
"(",
"$",
"year",
"=",
"null",
",",
"$",
"month",
"=",
"null",
",",
"$",
"day",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"makeFromDateTime",
"(",
"$",
"year",
... | Make and return a new ExpressiveDate instance with defined year, month, and day.
@param int $year
@param int $month
@param int $day
@param string|DateTimeZone $timezone
@return ExpressiveDate | [
"Make",
"and",
"return",
"a",
"new",
"ExpressiveDate",
"instance",
"with",
"defined",
"year",
"month",
"and",
"day",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L80-L83 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.makeFromTime | public static function makeFromTime($hour = null, $minute = null, $second = null, $timezone = null)
{
return static::makeFromDateTime(null, null, null, $hour, $minute, $second, $timezone);
} | php | public static function makeFromTime($hour = null, $minute = null, $second = null, $timezone = null)
{
return static::makeFromDateTime(null, null, null, $hour, $minute, $second, $timezone);
} | [
"public",
"static",
"function",
"makeFromTime",
"(",
"$",
"hour",
"=",
"null",
",",
"$",
"minute",
"=",
"null",
",",
"$",
"second",
"=",
"null",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"makeFromDateTime",
"(",
"null",
","... | Make and return a new ExpressiveDate instance with defined hour, minute, and second.
@param int $hour
@param int $minute
@param int $second
@param string|DateTimeZone $timezone
@return ExpressiveDate | [
"Make",
"and",
"return",
"a",
"new",
"ExpressiveDate",
"instance",
"with",
"defined",
"hour",
"minute",
"and",
"second",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L94-L97 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.makeFromDateTime | public static function makeFromDateTime($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null)
{
$date = new static(null, $timezone);
$date->setDate($year ?: $date->getYear(), $month ?: $date->getMonth(), $day ?: $date->getDay());
// If no hour was given then we'll default the minute and second to the current
// minute and second. If a date was given and minute or second are null then
// we'll set them to 0, mimicking PHPs behaviour.
if (is_null($hour))
{
$minute = $minute ?: $date->getMinute();
$second = $second ?: $date->getSecond();
}
else
{
$minute = $minute ?: 0;
$second = $second ?: 0;
}
$date->setTime($hour ?: $date->getHour(), $minute, $second);
return $date;
} | php | public static function makeFromDateTime($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $timezone = null)
{
$date = new static(null, $timezone);
$date->setDate($year ?: $date->getYear(), $month ?: $date->getMonth(), $day ?: $date->getDay());
// If no hour was given then we'll default the minute and second to the current
// minute and second. If a date was given and minute or second are null then
// we'll set them to 0, mimicking PHPs behaviour.
if (is_null($hour))
{
$minute = $minute ?: $date->getMinute();
$second = $second ?: $date->getSecond();
}
else
{
$minute = $minute ?: 0;
$second = $second ?: 0;
}
$date->setTime($hour ?: $date->getHour(), $minute, $second);
return $date;
} | [
"public",
"static",
"function",
"makeFromDateTime",
"(",
"$",
"year",
"=",
"null",
",",
"$",
"month",
"=",
"null",
",",
"$",
"day",
"=",
"null",
",",
"$",
"hour",
"=",
"null",
",",
"$",
"minute",
"=",
"null",
",",
"$",
"second",
"=",
"null",
",",
... | Make and return a new ExpressiveDate instance with defined year, month, day, hour, minute, and second.
@param int $year
@param int $month
@param int $day
@param int $hour
@param int $minute
@param int $second
@param string|DateTimeZone $timezone
@return ExpressiveDate | [
"Make",
"and",
"return",
"a",
"new",
"ExpressiveDate",
"instance",
"with",
"defined",
"year",
"month",
"day",
"hour",
"minute",
"and",
"second",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L111-L135 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.modifySeconds | protected function modifySeconds($amount, $invert = false)
{
$interval = new DateInterval("PT{$amount}S");
$this->modifyFromInterval($interval, $invert);
return $this;
} | php | protected function modifySeconds($amount, $invert = false)
{
$interval = new DateInterval("PT{$amount}S");
$this->modifyFromInterval($interval, $invert);
return $this;
} | [
"protected",
"function",
"modifySeconds",
"(",
"$",
"amount",
",",
"$",
"invert",
"=",
"false",
")",
"{",
"$",
"interval",
"=",
"new",
"DateInterval",
"(",
"\"PT{$amount}S\"",
")",
";",
"$",
"this",
"->",
"modifyFromInterval",
"(",
"$",
"interval",
",",
"$... | Modify by an amount of seconds.
@param int $amount
@param bool $invert
@return ExpressiveDate | [
"Modify",
"by",
"an",
"amount",
"of",
"seconds",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L652-L659 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.modifyFromInterval | protected function modifyFromInterval($interval, $invert = false)
{
if ($invert)
{
$this->sub($interval);
}
else
{
$this->add($interval);
}
return $this;
} | php | protected function modifyFromInterval($interval, $invert = false)
{
if ($invert)
{
$this->sub($interval);
}
else
{
$this->add($interval);
}
return $this;
} | [
"protected",
"function",
"modifyFromInterval",
"(",
"$",
"interval",
",",
"$",
"invert",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"invert",
")",
"{",
"$",
"this",
"->",
"sub",
"(",
"$",
"interval",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"add... | Modify from a DateInterval object.
@param DateInterval $interval
@param bool $invert
@return ExpressiveDate | [
"Modify",
"from",
"a",
"DateInterval",
"object",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L732-L744 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.setTimezone | public function setTimezone($timezone)
{
$timezone = $this->parseSuppliedTimezone($timezone);
parent::setTimezone($timezone);
return $this;
} | php | public function setTimezone($timezone)
{
$timezone = $this->parseSuppliedTimezone($timezone);
parent::setTimezone($timezone);
return $this;
} | [
"public",
"function",
"setTimezone",
"(",
"$",
"timezone",
")",
"{",
"$",
"timezone",
"=",
"$",
"this",
"->",
"parseSuppliedTimezone",
"(",
"$",
"timezone",
")",
";",
"parent",
"::",
"setTimezone",
"(",
"$",
"timezone",
")",
";",
"return",
"$",
"this",
"... | Set the timezone.
@param string|DateTimeZone $timezone
@return ExpressiveDate | [
"Set",
"the",
"timezone",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L752-L759 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.setWeekStartDay | public function setWeekStartDay($weekStartDay)
{
if (is_numeric($weekStartDay))
{
$this->weekStartDay = $weekStartDay;
}
else
{
$this->weekStartDay = array_search(strtolower($weekStartDay), array('sunday', 'monday'));
}
return $this;
} | php | public function setWeekStartDay($weekStartDay)
{
if (is_numeric($weekStartDay))
{
$this->weekStartDay = $weekStartDay;
}
else
{
$this->weekStartDay = array_search(strtolower($weekStartDay), array('sunday', 'monday'));
}
return $this;
} | [
"public",
"function",
"setWeekStartDay",
"(",
"$",
"weekStartDay",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"weekStartDay",
")",
")",
"{",
"$",
"this",
"->",
"weekStartDay",
"=",
"$",
"weekStartDay",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"weekSta... | Set the starting day of the week, where 0 is Sunday and 1 is Monday.
@param int|string $weekStartDay
@return void | [
"Set",
"the",
"starting",
"day",
"of",
"the",
"week",
"where",
"0",
"is",
"Sunday",
"and",
"1",
"is",
"Monday",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L1027-L1039 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.isDateAttribute | protected function isDateAttribute($attribute)
{
switch ($attribute)
{
case 'LeapYear':
return (bool) $this->format('L');
break;
case 'AmOrPm':
return $this->format('A');
break;
case 'DaylightSavings':
return (bool) $this->format('I');
break;
}
throw new InvalidArgumentException('The date attribute ['.$attribute.'] could not be found.');
} | php | protected function isDateAttribute($attribute)
{
switch ($attribute)
{
case 'LeapYear':
return (bool) $this->format('L');
break;
case 'AmOrPm':
return $this->format('A');
break;
case 'DaylightSavings':
return (bool) $this->format('I');
break;
}
throw new InvalidArgumentException('The date attribute ['.$attribute.'] could not be found.');
} | [
"protected",
"function",
"isDateAttribute",
"(",
"$",
"attribute",
")",
"{",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"'LeapYear'",
":",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"format",
"(",
"'L'",
")",
";",
"break",
";",
"case",
"'Am... | Syntactical sugar for determining if date object "is" a condition.
@param string $attribute
@return mixed | [
"Syntactical",
"sugar",
"for",
"determining",
"if",
"date",
"object",
"is",
"a",
"condition",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L1114-L1130 | train |
jasonlewis/expressive-date | src/ExpressiveDate.php | ExpressiveDate.setDateAttribute | protected function setDateAttribute($attribute, $value)
{
switch ($attribute)
{
case 'Day':
return $this->setDate($this->getYear(), $this->getMonth(), $value);
break;
case 'Month':
return $this->setDate($this->getYear(), $value, $this->getDay());
break;
case 'Year':
return $this->setDate($value, $this->getMonth(), $this->getDay());
break;
case 'Hour':
return $this->setTime($value, $this->getMinute(), $this->getSecond());
break;
case 'Minute':
return $this->setTime($this->getHour(), $value, $this->getSecond());
break;
case 'Second':
return $this->setTime($this->getHour(), $this->getMinute(), $value);
break;
}
throw new InvalidArgumentException('The date attribute ['.$attribute.'] could not be set.');
} | php | protected function setDateAttribute($attribute, $value)
{
switch ($attribute)
{
case 'Day':
return $this->setDate($this->getYear(), $this->getMonth(), $value);
break;
case 'Month':
return $this->setDate($this->getYear(), $value, $this->getDay());
break;
case 'Year':
return $this->setDate($value, $this->getMonth(), $this->getDay());
break;
case 'Hour':
return $this->setTime($value, $this->getMinute(), $this->getSecond());
break;
case 'Minute':
return $this->setTime($this->getHour(), $value, $this->getSecond());
break;
case 'Second':
return $this->setTime($this->getHour(), $this->getMinute(), $value);
break;
}
throw new InvalidArgumentException('The date attribute ['.$attribute.'] could not be set.');
} | [
"protected",
"function",
"setDateAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"'Day'",
":",
"return",
"$",
"this",
"->",
"setDate",
"(",
"$",
"this",
"->",
"getYear",
"(",
")",
",",
... | Set a date attribute.
@param string $attribute
@return mixed | [
"Set",
"a",
"date",
"attribute",
"."
] | 1215d093fd3fe222e26629e0bc3885968ba88a01 | https://github.com/jasonlewis/expressive-date/blob/1215d093fd3fe222e26629e0bc3885968ba88a01/src/ExpressiveDate.php#L1138-L1163 | train |
mediact/testing-suite | src/Installer/PipelinesInstaller.php | PipelinesInstaller.isBitbucket | private function isBitbucket(): bool
{
$process = $this->processFactory->create('git remote -v');
$process->run();
return strpos($process->getOutput(), $this->pattern) !== false;
} | php | private function isBitbucket(): bool
{
$process = $this->processFactory->create('git remote -v');
$process->run();
return strpos($process->getOutput(), $this->pattern) !== false;
} | [
"private",
"function",
"isBitbucket",
"(",
")",
":",
"bool",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"processFactory",
"->",
"create",
"(",
"'git remote -v'",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"return",
"strpos",
"(",
"$",
"pro... | Check whether the project is on Bitbucket.
@return bool | [
"Check",
"whether",
"the",
"project",
"is",
"on",
"Bitbucket",
"."
] | 98614fe3b5c174e9bda2ff88d36d30349094dbc2 | https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/Installer/PipelinesInstaller.php#L112-L118 | train |
RhubarbPHP/Rhubarb | src/Http/CurlHttpClient.php | CurlHttpClient.getResponse | public function getResponse(HttpRequest $request)
{
$uri = $request->getUrl();
$headers = $request->getHeaders();
$flatHeaders = [];
foreach ($headers as $key => $value) {
$flatHeaders[] = $key . ": " . $value;
}
$flatHeaders[] = 'Connection: Keep-Alive';
$flatHeaders[] = 'Expect:';
$flatHeaders[] = 'Accept-Language: en-GB';
$flatHeaders[] = 'Cache-Control: no-cache';
$flatHeaders[] = 'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)';
$curl = curl_init($uri);
curl_setopt($curl, CURLOPT_HEADER, false);
$payload = $request->getPayload();
switch ($request->getMethod()) {
case "head":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "HEAD");
break;
case "delete":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
case "post":
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
break;
case "put":
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
break;
}
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $flatHeaders);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$httpResponse = new HttpResponse();
$httpResponse->setResponseBody($response);
$httpResponse->setResponseCode($responseCode);
return $httpResponse;
} | php | public function getResponse(HttpRequest $request)
{
$uri = $request->getUrl();
$headers = $request->getHeaders();
$flatHeaders = [];
foreach ($headers as $key => $value) {
$flatHeaders[] = $key . ": " . $value;
}
$flatHeaders[] = 'Connection: Keep-Alive';
$flatHeaders[] = 'Expect:';
$flatHeaders[] = 'Accept-Language: en-GB';
$flatHeaders[] = 'Cache-Control: no-cache';
$flatHeaders[] = 'User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)';
$curl = curl_init($uri);
curl_setopt($curl, CURLOPT_HEADER, false);
$payload = $request->getPayload();
switch ($request->getMethod()) {
case "head":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "HEAD");
break;
case "delete":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
case "post":
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
break;
case "put":
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
break;
}
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $flatHeaders);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
$responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$httpResponse = new HttpResponse();
$httpResponse->setResponseBody($response);
$httpResponse->setResponseCode($responseCode);
return $httpResponse;
} | [
"public",
"function",
"getResponse",
"(",
"HttpRequest",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUrl",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"request",
"->",
"getHeaders",
"(",
")",
";",
"$",
"flatHeaders",
"=",
"[",
"... | Executes an HTTP transaction and returns the response.
@param HttpRequest $request
@return HttpResponse | [
"Executes",
"an",
"HTTP",
"transaction",
"and",
"returns",
"the",
"response",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Http/CurlHttpClient.php#L31-L88 | train |
RhubarbPHP/Rhubarb | src/DateTime/RhubarbDateTime.php | RhubarbDateTime.previousMonday | public static function previousMonday($referenceDate = null)
{
if ($referenceDate == null) {
$referenceDate = new RhubarbDateTime("today");
}
$dayOfWeek = $referenceDate->format("N") - 1;
$referenceDate->modify(-$dayOfWeek . " days");
return $referenceDate;
} | php | public static function previousMonday($referenceDate = null)
{
if ($referenceDate == null) {
$referenceDate = new RhubarbDateTime("today");
}
$dayOfWeek = $referenceDate->format("N") - 1;
$referenceDate->modify(-$dayOfWeek . " days");
return $referenceDate;
} | [
"public",
"static",
"function",
"previousMonday",
"(",
"$",
"referenceDate",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"referenceDate",
"==",
"null",
")",
"{",
"$",
"referenceDate",
"=",
"new",
"RhubarbDateTime",
"(",
"\"today\"",
")",
";",
"}",
"$",
"dayOfWe... | Returns the date of the Monday of this week.
This is often used as a handle on the week commencing date
@param RhubarbDateTime $referenceDate The date to find the previous Monday of. Today if null.
@return RhubarbDateTime | [
"Returns",
"the",
"date",
"of",
"the",
"Monday",
"of",
"this",
"week",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/DateTime/RhubarbDateTime.php#L112-L123 | train |
RhubarbPHP/Rhubarb | src/DateTime/RhubarbDateTime.php | RhubarbDateTime.createFromFormat | public static function createFromFormat($format, $time, $timezone = null)
{
if ($timezone == null) {
$dateTime = DateTime::createFromFormat($format, $time);
} else {
$dateTime = DateTime::createFromFormat($format, $time, $timezone);
}
return new self($dateTime, $timezone);
} | php | public static function createFromFormat($format, $time, $timezone = null)
{
if ($timezone == null) {
$dateTime = DateTime::createFromFormat($format, $time);
} else {
$dateTime = DateTime::createFromFormat($format, $time, $timezone);
}
return new self($dateTime, $timezone);
} | [
"public",
"static",
"function",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"time",
",",
"$",
"timezone",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"timezone",
"==",
"null",
")",
"{",
"$",
"dateTime",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
... | Parse a string into a new RhubarbDateTime object according to the specified format
@param string $format Format accepted by date().
@param string $time String representing the time.
@param $timezone A DateTimeZone object representing the desired time zone.
@return RhubarbDateTime | [
"Parse",
"a",
"string",
"into",
"a",
"new",
"RhubarbDateTime",
"object",
"according",
"to",
"the",
"specified",
"format"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/DateTime/RhubarbDateTime.php#L134-L142 | train |
RhubarbPHP/Rhubarb | src/Events/EventEmitter.php | EventEmitter.replaceEventHandler | public function replaceEventHandler($event, callable $delegate)
{
if (isset($this->eventHandlers[$event])) {
$this->eventHandlers[$event] = [];
}
$this->attachEventHandler($event, $delegate);
} | php | public function replaceEventHandler($event, callable $delegate)
{
if (isset($this->eventHandlers[$event])) {
$this->eventHandlers[$event] = [];
}
$this->attachEventHandler($event, $delegate);
} | [
"public",
"function",
"replaceEventHandler",
"(",
"$",
"event",
",",
"callable",
"$",
"delegate",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"eventHandlers",
"[",
"$",
"event",
"]",
")",
")",
"{",
"$",
"this",
"->",
"eventHandlers",
"[",
"$"... | Attach an event handler as the sole handler for this event.
Removes all previously attached handlers.
@param $event
@param callable $delegate | [
"Attach",
"an",
"event",
"handler",
"as",
"the",
"sole",
"handler",
"for",
"this",
"event",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Events/EventEmitter.php#L54-L61 | train |
RhubarbPHP/Rhubarb | src/Events/EventEmitter.php | EventEmitter.raiseEvent | protected function raiseEvent($event)
{
if (!isset($this->eventHandlers[$event])) {
return null;
}
$args = func_get_args();
$args = array_slice($args, 1);
// Check if the last argument is a callback.
$count = count($args);
$callBack = false;
if (($count > 0) && is_object($args[$count - 1]) && is_callable($args[$count - 1])) {
$callBack = $args[$count - 1];
$args = array_slice($args, 0, -1);
}
$result = null;
foreach ($this->eventHandlers[$event] as $delegate) {
$answer = call_user_func_array($delegate, $args);
if ($callBack !== false && $answer !== null) {
call_user_func($callBack, $answer);
}
// If we don't have a result yet - make this the result. This way the first event handler to
// return a non null result will be the overall result of the event.
if ($result === null) {
$result = $answer;
}
}
return $result;
} | php | protected function raiseEvent($event)
{
if (!isset($this->eventHandlers[$event])) {
return null;
}
$args = func_get_args();
$args = array_slice($args, 1);
// Check if the last argument is a callback.
$count = count($args);
$callBack = false;
if (($count > 0) && is_object($args[$count - 1]) && is_callable($args[$count - 1])) {
$callBack = $args[$count - 1];
$args = array_slice($args, 0, -1);
}
$result = null;
foreach ($this->eventHandlers[$event] as $delegate) {
$answer = call_user_func_array($delegate, $args);
if ($callBack !== false && $answer !== null) {
call_user_func($callBack, $answer);
}
// If we don't have a result yet - make this the result. This way the first event handler to
// return a non null result will be the overall result of the event.
if ($result === null) {
$result = $answer;
}
}
return $result;
} | [
"protected",
"function",
"raiseEvent",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"eventHandlers",
"[",
"$",
"event",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";... | Call this function to raise an event.
In addition to $event you can pass any number of other events which are passed through
to the event handling delegate.
@param string $event The name of the event
@return mixed|null | [
"Call",
"this",
"function",
"to",
"raise",
"an",
"event",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Events/EventEmitter.php#L105-L140 | train |
RhubarbPHP/Rhubarb | src/Response/Response.php | Response.addHeaders | public function addHeaders($headers)
{
foreach ($headers as $name => $value) {
$this->setHeader($name, $value);
}
} | php | public function addHeaders($headers)
{
foreach ($headers as $name => $value) {
$this->setHeader($name, $value);
}
} | [
"public",
"function",
"addHeaders",
"(",
"$",
"headers",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Sets headers from array. Keys should be the header names.
@param string[] $headers | [
"Sets",
"headers",
"from",
"array",
".",
"Keys",
"should",
"be",
"the",
"header",
"names",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Response/Response.php#L230-L235 | train |
RhubarbPHP/Rhubarb | src/Request/Request.php | Request.fromPhpContext | public final static function fromPhpContext(PhpContext $phpContext)
{
if ($phpContext->isCliInvocation()) {
$request = new CliRequest();
} else {
$contentType = (isset($_SERVER["CONTENT_TYPE"])) ? strtolower($_SERVER["CONTENT_TYPE"]) : "";
// Special check for multipart, because the header could be multipart/form-data
// followed by boundary
$multipartType = "multipart/form-data";
if (strpos($contentType, $multipartType) === 0) {
$contentType = $multipartType;
}
// Firefox puts a charset on the end of the content type line
$parts = explode(";", $contentType);
$contentType = $parts[0];
switch ($contentType) {
case "application/octet-stream":
case "image/jpeg":
case "image/jpg":
case "image/gif":
case "image/png":
$request = new BinaryRequest();
break;
case "application/json":
$request = new JsonRequest();
break;
case "text/xml":
case "application/xml":
$request = new XmlRequest();
break;
case "multipart/form-data":
$request = new MultiPartFormDataRequest();
break;
default:
$request = new WebRequest();
break;
}
}
$request->phpContext = $phpContext;
return $request;
} | php | public final static function fromPhpContext(PhpContext $phpContext)
{
if ($phpContext->isCliInvocation()) {
$request = new CliRequest();
} else {
$contentType = (isset($_SERVER["CONTENT_TYPE"])) ? strtolower($_SERVER["CONTENT_TYPE"]) : "";
// Special check for multipart, because the header could be multipart/form-data
// followed by boundary
$multipartType = "multipart/form-data";
if (strpos($contentType, $multipartType) === 0) {
$contentType = $multipartType;
}
// Firefox puts a charset on the end of the content type line
$parts = explode(";", $contentType);
$contentType = $parts[0];
switch ($contentType) {
case "application/octet-stream":
case "image/jpeg":
case "image/jpg":
case "image/gif":
case "image/png":
$request = new BinaryRequest();
break;
case "application/json":
$request = new JsonRequest();
break;
case "text/xml":
case "application/xml":
$request = new XmlRequest();
break;
case "multipart/form-data":
$request = new MultiPartFormDataRequest();
break;
default:
$request = new WebRequest();
break;
}
}
$request->phpContext = $phpContext;
return $request;
} | [
"public",
"final",
"static",
"function",
"fromPhpContext",
"(",
"PhpContext",
"$",
"phpContext",
")",
"{",
"if",
"(",
"$",
"phpContext",
"->",
"isCliInvocation",
"(",
")",
")",
"{",
"$",
"request",
"=",
"new",
"CliRequest",
"(",
")",
";",
"}",
"else",
"{... | Creates a request object from the PHP context
@return Request | [
"Creates",
"a",
"request",
"object",
"from",
"the",
"PHP",
"context"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Request/Request.php#L98-L143 | train |
RhubarbPHP/Rhubarb | src/Request/Request.php | Request.getSuperglobalValue | protected function getSuperglobalValue($superglobal, $index, $defaultValue = null)
{
$propertyName = $superglobal . 'Data';
if (isset($this->$propertyName)){
$data = $this->$propertyName;
if (isset($data[$index])){
return $data[$index];
}
}
return $defaultValue;
} | php | protected function getSuperglobalValue($superglobal, $index, $defaultValue = null)
{
$propertyName = $superglobal . 'Data';
if (isset($this->$propertyName)){
$data = $this->$propertyName;
if (isset($data[$index])){
return $data[$index];
}
}
return $defaultValue;
} | [
"protected",
"function",
"getSuperglobalValue",
"(",
"$",
"superglobal",
",",
"$",
"index",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"$",
"propertyName",
"=",
"$",
"superglobal",
".",
"'Data'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$"... | Get the value stored against one of the request superglobals.
@param string $superglobal
@param mixed $index
@return mixed | [
"Get",
"the",
"value",
"stored",
"against",
"one",
"of",
"the",
"request",
"superglobals",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Request/Request.php#L178-L191 | train |
RhubarbPHP/Rhubarb | src/Assets/Asset.php | Asset.writeToFile | public function writeToFile($filePath)
{
$out = @fopen($filePath,"w");
if (!$out){
throw new AssetException($this->token,
"The asset '".$this->token."' could not be written to path '$filePath'. Check the path is valid and the directory exists.");
}
$stream = $this->getStream();
if (!$stream){
throw new AssetException($this->token,
"The asset '".$this->token."' could not provide a valid stream.'");
}
while(!feof($stream)){
$bytes = fread($stream, 8192);
fwrite($out, $bytes);
}
fclose($stream);
fclose($out);
} | php | public function writeToFile($filePath)
{
$out = @fopen($filePath,"w");
if (!$out){
throw new AssetException($this->token,
"The asset '".$this->token."' could not be written to path '$filePath'. Check the path is valid and the directory exists.");
}
$stream = $this->getStream();
if (!$stream){
throw new AssetException($this->token,
"The asset '".$this->token."' could not provide a valid stream.'");
}
while(!feof($stream)){
$bytes = fread($stream, 8192);
fwrite($out, $bytes);
}
fclose($stream);
fclose($out);
} | [
"public",
"function",
"writeToFile",
"(",
"$",
"filePath",
")",
"{",
"$",
"out",
"=",
"@",
"fopen",
"(",
"$",
"filePath",
",",
"\"w\"",
")",
";",
"if",
"(",
"!",
"$",
"out",
")",
"{",
"throw",
"new",
"AssetException",
"(",
"$",
"this",
"->",
"token... | Write the asset out to the corresponding file path.
@param $filePath
@throws AssetException | [
"Write",
"the",
"asset",
"out",
"to",
"the",
"corresponding",
"file",
"path",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Assets/Asset.php#L105-L128 | train |
glorpen/GlorpenPropelBundle | src/Dispatcher/EventDispatcherProxy.php | EventDispatcherProxy.trigger | public static function trigger($name, Event $data)
{
if (self::$dispatcher) {
if (!is_array($name)) {
$name=array($name);
}
foreach ($name as $n) {
call_user_func_array(self::$dispatcher, self::$dispatcher_args)->dispatch($n, $data);
}
}
} | php | public static function trigger($name, Event $data)
{
if (self::$dispatcher) {
if (!is_array($name)) {
$name=array($name);
}
foreach ($name as $n) {
call_user_func_array(self::$dispatcher, self::$dispatcher_args)->dispatch($n, $data);
}
}
} | [
"public",
"static",
"function",
"trigger",
"(",
"$",
"name",
",",
"Event",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"array",
"(",
... | Triggers event.
@param string $name
@param Event $data one of Glorpen\Propel\PropelBundle\Events | [
"Triggers",
"event",
"."
] | b679c83377c81ab582de179f84bc23eaeb1e86aa | https://github.com/glorpen/GlorpenPropelBundle/blob/b679c83377c81ab582de179f84bc23eaeb1e86aa/src/Dispatcher/EventDispatcherProxy.php#L33-L43 | train |
mediact/testing-suite | src/ProjectTypeResolver.php | ProjectTypeResolver.resolve | public function resolve(): string
{
$packageType = $this->composer->getPackage()->getType();
return array_key_exists($packageType, $this->mapping)
? $this->mapping[$packageType]
: 'default';
} | php | public function resolve(): string
{
$packageType = $this->composer->getPackage()->getType();
return array_key_exists($packageType, $this->mapping)
? $this->mapping[$packageType]
: 'default';
} | [
"public",
"function",
"resolve",
"(",
")",
":",
"string",
"{",
"$",
"packageType",
"=",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
"->",
"getType",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"packageType",
",",
"$",
"this",
... | Get the type.
@return string | [
"Get",
"the",
"type",
"."
] | 98614fe3b5c174e9bda2ff88d36d30349094dbc2 | https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/ProjectTypeResolver.php#L42-L48 | train |
mediact/testing-suite | src/ConfigResolver.php | ConfigResolver.resolve | public function resolve(): array
{
$file = sprintf($this->template, $this->typeResolver->resolve());
if (!file_exists($file)) {
$file = sprintf($this->template, 'default');
}
return json_decode(file_get_contents($file), true);
} | php | public function resolve(): array
{
$file = sprintf($this->template, $this->typeResolver->resolve());
if (!file_exists($file)) {
$file = sprintf($this->template, 'default');
}
return json_decode(file_get_contents($file), true);
} | [
"public",
"function",
"resolve",
"(",
")",
":",
"array",
"{",
"$",
"file",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"$",
"this",
"->",
"typeResolver",
"->",
"resolve",
"(",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fi... | Resolve config.
@return array | [
"Resolve",
"config",
"."
] | 98614fe3b5c174e9bda2ff88d36d30349094dbc2 | https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/ConfigResolver.php#L36-L45 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.implodeIgnoringBlanks | public static function implodeIgnoringBlanks($glue, $array, $itemCallback = null, $keysToInclude = null)
{
$array = array_filter($array);
if (!empty($itemCallback)) {
foreach ($array as $key => $value) {
$array[$key] = $itemCallback($value);
}
}
$keys = [$keysToInclude];
for ($i = 4; $i < func_num_args(); $i++) {
$keys[] = func_get_arg($i);
}
$keys = array_filter($keys);
$string = "";
if (count($keys)) {
foreach ($keys as $key) {
if (!empty($array[$key])) {
$string .= $array[$key] . $glue;
}
}
if (strlen($string) >= strlen($glue)) {
$string = substr($string, 0, strlen($string) - strlen($glue));
}
} else {
$string = implode($glue, $array);
}
return $string;
} | php | public static function implodeIgnoringBlanks($glue, $array, $itemCallback = null, $keysToInclude = null)
{
$array = array_filter($array);
if (!empty($itemCallback)) {
foreach ($array as $key => $value) {
$array[$key] = $itemCallback($value);
}
}
$keys = [$keysToInclude];
for ($i = 4; $i < func_num_args(); $i++) {
$keys[] = func_get_arg($i);
}
$keys = array_filter($keys);
$string = "";
if (count($keys)) {
foreach ($keys as $key) {
if (!empty($array[$key])) {
$string .= $array[$key] . $glue;
}
}
if (strlen($string) >= strlen($glue)) {
$string = substr($string, 0, strlen($string) - strlen($glue));
}
} else {
$string = implode($glue, $array);
}
return $string;
} | [
"public",
"static",
"function",
"implodeIgnoringBlanks",
"(",
"$",
"glue",
",",
"$",
"array",
",",
"$",
"itemCallback",
"=",
"null",
",",
"$",
"keysToInclude",
"=",
"null",
")",
"{",
"$",
"array",
"=",
"array_filter",
"(",
"$",
"array",
")",
";",
"if",
... | Removes all blanks in an array and merges them into a string
@param string $glue String to include between each element
@param array $array Array containing elements to be imploded
@param string $itemCallback A transformation closure to call on each element of the array
@param string $keysToInclude,... Keys of the array elements to include - if not supplied, all elements will be used
@return string String of concatenated elements | [
"Removes",
"all",
"blanks",
"in",
"an",
"array",
"and",
"merges",
"them",
"into",
"a",
"string"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L35-L69 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.makeSingular | public static function makeSingular($plural)
{
$plurals = ["ies" => "y", "es" => "", "s" => ""];
foreach ($plurals as $pluralEnding => $singularEnding) {
$plural = preg_replace("/" . $pluralEnding . "$/i", $singularEnding, $plural);
}
return $plural;
} | php | public static function makeSingular($plural)
{
$plurals = ["ies" => "y", "es" => "", "s" => ""];
foreach ($plurals as $pluralEnding => $singularEnding) {
$plural = preg_replace("/" . $pluralEnding . "$/i", $singularEnding, $plural);
}
return $plural;
} | [
"public",
"static",
"function",
"makeSingular",
"(",
"$",
"plural",
")",
"{",
"$",
"plurals",
"=",
"[",
"\"ies\"",
"=>",
"\"y\"",
",",
"\"es\"",
"=>",
"\"\"",
",",
"\"s\"",
"=>",
"\"\"",
"]",
";",
"foreach",
"(",
"$",
"plurals",
"as",
"$",
"pluralEndin... | Returns the English singular form of a plural word.
@param $plural
@return string | [
"Returns",
"the",
"English",
"singular",
"form",
"of",
"a",
"plural",
"word",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L89-L98 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.makePlural | public static function makePlural($singular)
{
$singulars = [
'ey' => 'eys',
'day' => 'days',
"ch" => "ches",
"s" => "ses",
"x" => "xes",
"y" => "ies",
];
foreach ($singulars as $singularEnding => $pluralEnding) {
if (preg_match("/" . $singularEnding . "$/i", $singular)) {
return preg_replace("/" . $singularEnding . "$/i", $pluralEnding, $singular);
}
}
return $singular . "s";
} | php | public static function makePlural($singular)
{
$singulars = [
'ey' => 'eys',
'day' => 'days',
"ch" => "ches",
"s" => "ses",
"x" => "xes",
"y" => "ies",
];
foreach ($singulars as $singularEnding => $pluralEnding) {
if (preg_match("/" . $singularEnding . "$/i", $singular)) {
return preg_replace("/" . $singularEnding . "$/i", $pluralEnding, $singular);
}
}
return $singular . "s";
} | [
"public",
"static",
"function",
"makePlural",
"(",
"$",
"singular",
")",
"{",
"$",
"singulars",
"=",
"[",
"'ey'",
"=>",
"'eys'",
",",
"'day'",
"=>",
"'days'",
",",
"\"ch\"",
"=>",
"\"ches\"",
",",
"\"s\"",
"=>",
"\"ses\"",
",",
"\"x\"",
"=>",
"\"xes\"",
... | Returns the English plural form of a singular word.
@param $singular
@return mixed|string | [
"Returns",
"the",
"English",
"plural",
"form",
"of",
"a",
"singular",
"word",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L107-L125 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.replaceFirst | public static function replaceFirst($search, $replace, $subject, $caseSensitive = true)
{
if ($caseSensitive) {
$pos = strpos($subject, $search);
} else {
$pos = stripos($subject, $search);
}
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
} | php | public static function replaceFirst($search, $replace, $subject, $caseSensitive = true)
{
if ($caseSensitive) {
$pos = strpos($subject, $search);
} else {
$pos = stripos($subject, $search);
}
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
} | [
"public",
"static",
"function",
"replaceFirst",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseSensitive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"caseSensitive",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"subject",
... | Replaces only the first matched instance of a string
@param string $search
@param string $replace
@param string $subject
@param bool $caseSensitive
@return mixed | [
"Replaces",
"only",
"the",
"first",
"matched",
"instance",
"of",
"a",
"string"
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L391-L402 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.camelCaseToSeparated | public static function camelCaseToSeparated($string, $separator = '-', $toLowerCase = true)
{
$separated = preg_replace(['/([a-z\d])([A-Z])/', '/([^' . preg_quote($separator) . '])([A-Z][a-z])/'], '$1' . $separator . '$2', $string);
return $toLowerCase ? strtolower($separated) : $separated;
} | php | public static function camelCaseToSeparated($string, $separator = '-', $toLowerCase = true)
{
$separated = preg_replace(['/([a-z\d])([A-Z])/', '/([^' . preg_quote($separator) . '])([A-Z][a-z])/'], '$1' . $separator . '$2', $string);
return $toLowerCase ? strtolower($separated) : $separated;
} | [
"public",
"static",
"function",
"camelCaseToSeparated",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"'-'",
",",
"$",
"toLowerCase",
"=",
"true",
")",
"{",
"$",
"separated",
"=",
"preg_replace",
"(",
"[",
"'/([a-z\\d])([A-Z])/'",
",",
"'/([^'",
".",
"preg... | Converts a string from CamelCasing to separated-words, with specifiable separator and lowercase conversion.
@param $string
@param string $separator The character to separate the words with
@param bool $toLowerCase
@return string | [
"Converts",
"a",
"string",
"from",
"CamelCasing",
"to",
"separated",
"-",
"words",
"with",
"specifiable",
"separator",
"and",
"lowercase",
"conversion",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L412-L416 | train |
RhubarbPHP/Rhubarb | src/String/StringTools.php | StringTools.detectHashTags | public static function detectHashTags($text, callable $formatHashTag = null, $url = '', $openLinksInNewWindow = true)
{
if ($formatHashTag == null) {
$formatHashTag = function ($hashTag) use ($url, $openLinksInNewWindow) {
return '<a href="' . $url . urlencode($hashTag) . ($openLinksInNewWindow ? ' target="_blank"' : '') . '">' . $hashTag . '</a>';
};
}
$hashTagRegex = '/(^|\s)(#\w+)($|[^<])/';
while (preg_match($hashTagRegex, $text, $match, PREG_OFFSET_CAPTURE)) {
list($hashTag, $index) = $match[2];
$text = substr($text, 0, $index) . $formatHashTag($hashTag) . strpos($text, $index + strlen($hashTag));
}
return $text;
} | php | public static function detectHashTags($text, callable $formatHashTag = null, $url = '', $openLinksInNewWindow = true)
{
if ($formatHashTag == null) {
$formatHashTag = function ($hashTag) use ($url, $openLinksInNewWindow) {
return '<a href="' . $url . urlencode($hashTag) . ($openLinksInNewWindow ? ' target="_blank"' : '') . '">' . $hashTag . '</a>';
};
}
$hashTagRegex = '/(^|\s)(#\w+)($|[^<])/';
while (preg_match($hashTagRegex, $text, $match, PREG_OFFSET_CAPTURE)) {
list($hashTag, $index) = $match[2];
$text = substr($text, 0, $index) . $formatHashTag($hashTag) . strpos($text, $index + strlen($hashTag));
}
return $text;
} | [
"public",
"static",
"function",
"detectHashTags",
"(",
"$",
"text",
",",
"callable",
"$",
"formatHashTag",
"=",
"null",
",",
"$",
"url",
"=",
"''",
",",
"$",
"openLinksInNewWindow",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"formatHashTag",
"==",
"null",
")... | Detects HashTags in a string and calls a callback function for each. Default behaviour is to insert HTML links for each HashTag.
@param string $text String to find HashTags in
@param callable|null $formatHashTag Will be called for each HashTag detected. If null, default behaviour will happen (inserting a link for each HashTag)
@param string $url If $formatHashTag is not set, this will prefix any linked HashTag
@param bool $openLinksInNewWindow If $formatHashTag is not set, created links will open in new browser window
@return string | [
"Detects",
"HashTags",
"in",
"a",
"string",
"and",
"calls",
"a",
"callback",
"function",
"for",
"each",
".",
"Default",
"behaviour",
"is",
"to",
"insert",
"HTML",
"links",
"for",
"each",
"HashTag",
"."
] | 327ff1f05d6a7e651d41c8e771f3551acfac18ae | https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L458-L473 | train |
byjg/cache-engine-php | src/Psr16/FileSystemCacheEngine.php | FileSystemCacheEngine.lock | public function lock($key)
{
$this->logger->info("[Filesystem cache] Lock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
try {
file_put_contents($lockFile, date('c'));
} catch (Exception $ex) {
// Ignoring... Set will cause an error
}
} | php | public function lock($key)
{
$this->logger->info("[Filesystem cache] Lock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
try {
file_put_contents($lockFile, date('c'));
} catch (Exception $ex) {
// Ignoring... Set will cause an error
}
} | [
"public",
"function",
"lock",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"[Filesystem cache] Lock '$key'\"",
")",
";",
"$",
"lockFile",
"=",
"$",
"this",
"->",
"fixKey",
"(",
"$",
"key",
")",
".",
"\".lock\"",
";",
"tr... | Lock resource before set it.
@param string $key | [
"Lock",
"resource",
"before",
"set",
"it",
"."
] | 001281edc3be6d908e7865b836cb6b43bd61a5cc | https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr16/FileSystemCacheEngine.php#L130-L141 | train |
byjg/cache-engine-php | src/Psr16/FileSystemCacheEngine.php | FileSystemCacheEngine.unlock | public function unlock($key)
{
$this->logger->info("[Filesystem cache] Unlock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
if (file_exists($lockFile)) {
unlink($lockFile);
}
} | php | public function unlock($key)
{
$this->logger->info("[Filesystem cache] Unlock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
if (file_exists($lockFile)) {
unlink($lockFile);
}
} | [
"public",
"function",
"unlock",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"[Filesystem cache] Unlock '$key'\"",
")",
";",
"$",
"lockFile",
"=",
"$",
"this",
"->",
"fixKey",
"(",
"$",
"key",
")",
".",
"\".lock\"",
";",
... | UnLock resource after set it.
@param string $key | [
"UnLock",
"resource",
"after",
"set",
"it",
"."
] | 001281edc3be6d908e7865b836cb6b43bd61a5cc | https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr16/FileSystemCacheEngine.php#L147-L157 | train |
FoxyCart/foxyclient-php | src/Foxy/FoxyClient/FoxyClient.php | FoxyClient.saveLinks | public function saveLinks($data)
{
if (isset($data['_links'])) {
foreach ($data['_links'] as $rel => $link) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel != 'curies'
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
} else if (isset($data['links'])) {
foreach ($data['links'] as $link) {
foreach ($link['rel'] as $rel) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
}
}
} | php | public function saveLinks($data)
{
if (isset($data['_links'])) {
foreach ($data['_links'] as $rel => $link) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel != 'curies'
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
} else if (isset($data['links'])) {
foreach ($data['links'] as $link) {
foreach ($link['rel'] as $rel) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
}
}
} | [
"public",
"function",
"saveLinks",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'_links'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'_links'",
"]",
"as",
"$",
"rel",
"=>",
"$",
"link",
")",
"{",
"if",
"(... | Save Links to the Object For Easy Retrieval Later | [
"Save",
"Links",
"to",
"the",
"Object",
"For",
"Easy",
"Retrieval",
"Later"
] | 592fb81ec14afb04d6463682454c4d2263db4a04 | https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L294-L314 | train |
FoxyCart/foxyclient-php | src/Foxy/FoxyClient/FoxyClient.php | FoxyClient.getErrors | public function getErrors($data)
{
$errors = array();
if ($this->getLastStatusCode() >= 400) {
if (isset($data['error_description'])) {
$errors[] = $data['error_description'];
} elseif (isset($data['_embedded']['fx:errors'])) {
foreach ($data['_embedded']['fx:errors'] as $error) {
$errors[] = $error['message'];
}
} else {
$errors[] = 'No data returned.';
}
}
return $errors;
} | php | public function getErrors($data)
{
$errors = array();
if ($this->getLastStatusCode() >= 400) {
if (isset($data['error_description'])) {
$errors[] = $data['error_description'];
} elseif (isset($data['_embedded']['fx:errors'])) {
foreach ($data['_embedded']['fx:errors'] as $error) {
$errors[] = $error['message'];
}
} else {
$errors[] = 'No data returned.';
}
}
return $errors;
} | [
"public",
"function",
"getErrors",
"(",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getLastStatusCode",
"(",
")",
">=",
"400",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'error_descri... | Return any errors that exist in the response data. | [
"Return",
"any",
"errors",
"that",
"exist",
"in",
"the",
"response",
"data",
"."
] | 592fb81ec14afb04d6463682454c4d2263db4a04 | https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L356-L371 | train |
FoxyCart/foxyclient-php | src/Foxy/FoxyClient/FoxyClient.php | FoxyClient.getHeaders | public function getHeaders()
{
$headers = array(
'FOXY-API-VERSION' => 1
);
if ($this->access_token && $this->include_auth_header) {
$headers['Authorization'] = "Bearer " . $this->access_token;
}
$headers['Accept'] = $this->getAcceptContentType();
return $headers;
} | php | public function getHeaders()
{
$headers = array(
'FOXY-API-VERSION' => 1
);
if ($this->access_token && $this->include_auth_header) {
$headers['Authorization'] = "Bearer " . $this->access_token;
}
$headers['Accept'] = $this->getAcceptContentType();
return $headers;
} | [
"public",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
"'FOXY-API-VERSION'",
"=>",
"1",
")",
";",
"if",
"(",
"$",
"this",
"->",
"access_token",
"&&",
"$",
"this",
"->",
"include_auth_header",
")",
"{",
"$",
"headers",
"[",
... | Get headers for this call | [
"Get",
"headers",
"for",
"this",
"call"
] | 592fb81ec14afb04d6463682454c4d2263db4a04 | https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L398-L409 | train |
ldaptools/ldaptools | src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php | AuthenticationOperationHandler.getAuthenticationResponse | protected function getAuthenticationResponse(AuthenticationOperation $operation)
{
$authenticated = false;
$errorMessage = null;
$errorCode = null;
// Only catch a bind failure. Let the others through, as it's probably a sign of other issues.
try {
$authenticated = (bool) $this->connection->close()->connect(...$operation->getArguments());
} catch (LdapBindException $e) {
$errorMessage = $this->connection->getLastError();
$errorCode = $this->connection->getExtendedErrorNumber();
}
return new AuthenticationResponse($authenticated, $errorMessage, $errorCode);
} | php | protected function getAuthenticationResponse(AuthenticationOperation $operation)
{
$authenticated = false;
$errorMessage = null;
$errorCode = null;
// Only catch a bind failure. Let the others through, as it's probably a sign of other issues.
try {
$authenticated = (bool) $this->connection->close()->connect(...$operation->getArguments());
} catch (LdapBindException $e) {
$errorMessage = $this->connection->getLastError();
$errorCode = $this->connection->getExtendedErrorNumber();
}
return new AuthenticationResponse($authenticated, $errorMessage, $errorCode);
} | [
"protected",
"function",
"getAuthenticationResponse",
"(",
"AuthenticationOperation",
"$",
"operation",
")",
"{",
"$",
"authenticated",
"=",
"false",
";",
"$",
"errorMessage",
"=",
"null",
";",
"$",
"errorCode",
"=",
"null",
";",
"// Only catch a bind failure. Let the... | Attempts to connect with the given credentials and returns the response.
@param AuthenticationOperation $operation
@return AuthenticationResponse | [
"Attempts",
"to",
"connect",
"with",
"the",
"given",
"credentials",
"and",
"returns",
"the",
"response",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php#L66-L81 | train |
ldaptools/ldaptools | src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php | AuthenticationOperationHandler.switchCredentials | protected function switchCredentials(AuthenticationOperation $operation)
{
$this->connection->getConfig()->setUsername($operation->getUsername());
$this->connection->getConfig()->setPassword($operation->getPassword());
} | php | protected function switchCredentials(AuthenticationOperation $operation)
{
$this->connection->getConfig()->setUsername($operation->getUsername());
$this->connection->getConfig()->setPassword($operation->getPassword());
} | [
"protected",
"function",
"switchCredentials",
"(",
"AuthenticationOperation",
"$",
"operation",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"setUsername",
"(",
"$",
"operation",
"->",
"getUsername",
"(",
")",
")",
";",
"$",
... | If the operation requested that the credentials be switched, then update the credential information in the
connections config. Otherwise it will switch again on other auth-attempts or re-connects.
@param AuthenticationOperation $operation | [
"If",
"the",
"operation",
"requested",
"that",
"the",
"credentials",
"be",
"switched",
"then",
"update",
"the",
"credential",
"information",
"in",
"the",
"connections",
"config",
".",
"Otherwise",
"it",
"will",
"switch",
"again",
"on",
"other",
"auth",
"-",
"a... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php#L89-L93 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ADTimeSpan.php | ADTimeSpan.getLdapValue | public function getLdapValue()
{
if ($this->never) {
$value = self::NEVER;
} else {
$total = 0;
foreach (self::UNIT as $unit => $conversion) {
$total += $this->$unit * $conversion;
}
$value = number_format($total, 0, '.', '');
}
return $value;
} | php | public function getLdapValue()
{
if ($this->never) {
$value = self::NEVER;
} else {
$total = 0;
foreach (self::UNIT as $unit => $conversion) {
$total += $this->$unit * $conversion;
}
$value = number_format($total, 0, '.', '');
}
return $value;
} | [
"public",
"function",
"getLdapValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"never",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"NEVER",
";",
"}",
"else",
"{",
"$",
"total",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"UNIT",
"as",
"$",
... | Get the value of all the time units in the format that LDAP expects it in.
@return string | [
"Get",
"the",
"value",
"of",
"all",
"the",
"time",
"units",
"in",
"the",
"format",
"that",
"LDAP",
"expects",
"it",
"in",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L214-L227 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ADTimeSpan.php | ADTimeSpan.getInstance | public static function getInstance($value, $unit)
{
if (!array_key_exists($unit, self::UNIT)) {
throw new InvalidArgumentException('Time unit "%s" is not recognized.', $unit);
}
$setter = 'set'.ucfirst($unit);
return (new self)->$setter($value);
} | php | public static function getInstance($value, $unit)
{
if (!array_key_exists($unit, self::UNIT)) {
throw new InvalidArgumentException('Time unit "%s" is not recognized.', $unit);
}
$setter = 'set'.ucfirst($unit);
return (new self)->$setter($value);
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"value",
",",
"$",
"unit",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"unit",
",",
"self",
"::",
"UNIT",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Time unit \"%s\... | Get an instance of the class based on a specific time unit as the second parameter.
@param int $value The time value.
@param string $unit The time unit. One of the constants of this class: DAYS, HOURS, MINUTES, SECONDS.
@return $this | [
"Get",
"an",
"instance",
"of",
"the",
"class",
"based",
"on",
"a",
"specific",
"time",
"unit",
"as",
"the",
"second",
"parameter",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L236-L244 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ADTimeSpan.php | ADTimeSpan.setAndVerify | protected function setAndVerify($value, $interval)
{
if (!filter_var($value, FILTER_VALIDATE_INT) && $value != '0') {
throw new InvalidArgumentException(sprintf("The %s should be an integer.", $interval));
}
$this->$interval = $value;
} | php | protected function setAndVerify($value, $interval)
{
if (!filter_var($value, FILTER_VALIDATE_INT) && $value != '0') {
throw new InvalidArgumentException(sprintf("The %s should be an integer.", $interval));
}
$this->$interval = $value;
} | [
"protected",
"function",
"setAndVerify",
"(",
"$",
"value",
",",
"$",
"interval",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_INT",
")",
"&&",
"$",
"value",
"!=",
"'0'",
")",
"{",
"throw",
"new",
"InvalidArgumentExcepti... | Verify the value is an integer and set the correct interval value.
@param int $value
@param string $interval | [
"Verify",
"the",
"value",
"is",
"an",
"integer",
"and",
"set",
"the",
"correct",
"interval",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L270-L276 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/ADTimeSpan.php | ADTimeSpan.setValuesFromLdap | protected function setValuesFromLdap($time)
{
if ($time == self::NEVER) {
$this->setNever(true);
} else {
$seconds = $time / self::UNIT[self::SECONDS];
$dtBase = new \DateTime('@0');
$dtSeconds = new \DateTime('@' . $seconds);
$this->setDays($dtBase->diff($dtSeconds)->format('%a'));
$this->setHours($dtBase->diff($dtSeconds)->format('%h'));
$this->setMinutes($dtBase->diff($dtSeconds)->format('%i'));
$this->setSeconds($dtBase->diff($dtSeconds)->format('%s'));
}
} | php | protected function setValuesFromLdap($time)
{
if ($time == self::NEVER) {
$this->setNever(true);
} else {
$seconds = $time / self::UNIT[self::SECONDS];
$dtBase = new \DateTime('@0');
$dtSeconds = new \DateTime('@' . $seconds);
$this->setDays($dtBase->diff($dtSeconds)->format('%a'));
$this->setHours($dtBase->diff($dtSeconds)->format('%h'));
$this->setMinutes($dtBase->diff($dtSeconds)->format('%i'));
$this->setSeconds($dtBase->diff($dtSeconds)->format('%s'));
}
} | [
"protected",
"function",
"setValuesFromLdap",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"$",
"time",
"==",
"self",
"::",
"NEVER",
")",
"{",
"$",
"this",
"->",
"setNever",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"seconds",
"=",
"$",
"time",
"/",
... | Given a time format from LDAP break it down into its individual time units and set them.
@param int $time | [
"Given",
"a",
"time",
"format",
"from",
"LDAP",
"break",
"it",
"down",
"into",
"its",
"individual",
"time",
"units",
"and",
"set",
"them",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L283-L298 | train |
ldaptools/ldaptools | src/LdapTools/Log/LoggerChain.php | LoggerChain.start | public function start(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->start($operation);
}
} | php | public function start(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->start($operation);
}
} | [
"public",
"function",
"start",
"(",
"LogOperation",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"start",
"(",
"$",
"operation",
")",
";",
"}",
"}"
] | The start of a logging operation. Initiated on each logger in the chain.
@param LogOperation $operation | [
"The",
"start",
"of",
"a",
"logging",
"operation",
".",
"Initiated",
"on",
"each",
"logger",
"in",
"the",
"chain",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Log/LoggerChain.php#L40-L45 | train |
ldaptools/ldaptools | src/LdapTools/Log/LoggerChain.php | LoggerChain.end | public function end(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->end($operation);
}
} | php | public function end(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->end($operation);
}
} | [
"public",
"function",
"end",
"(",
"LogOperation",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"end",
"(",
"$",
"operation",
")",
";",
"}",
"}"
] | The end of a logging operation. Initiated on each logger in the chain.
@param LogOperation $operation | [
"The",
"end",
"of",
"a",
"logging",
"operation",
".",
"Initiated",
"on",
"each",
"logger",
"in",
"the",
"chain",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Log/LoggerChain.php#L52-L57 | train |
ldaptools/ldaptools | src/LdapTools/Operation/AuthenticationOperation.php | AuthenticationOperation.validateArguments | protected function validateArguments()
{
if ($this->getIsAnonymousBind()) {
return;
}
if (empty($this->properties['username']) || empty($this->properties['password'])) {
throw new LdapBindException("You must specify a username and password.");
}
} | php | protected function validateArguments()
{
if ($this->getIsAnonymousBind()) {
return;
}
if (empty($this->properties['username']) || empty($this->properties['password'])) {
throw new LdapBindException("You must specify a username and password.");
}
} | [
"protected",
"function",
"validateArguments",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsAnonymousBind",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"properties",
"[",
"'username'",
"]",
")",
"||",
"empty... | Validates that the arguments given don't have any issues.
@throws LdapBindException | [
"Validates",
"that",
"the",
"arguments",
"given",
"don",
"t",
"have",
"any",
"issues",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/AuthenticationOperation.php#L190-L198 | train |
ldaptools/ldaptools | src/LdapTools/Query/Operator/bNot.php | bNot.isOperatorAllowed | protected function isOperatorAllowed(BaseOperator $operator)
{
if (!empty($this->children)) {
throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
}
if ($operator instanceof ContainsOperatorsInterface) {
throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
}
} | php | protected function isOperatorAllowed(BaseOperator $operator)
{
if (!empty($this->children)) {
throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
}
if ($operator instanceof ContainsOperatorsInterface) {
throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
}
} | [
"protected",
"function",
"isOperatorAllowed",
"(",
"BaseOperator",
"$",
"operator",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"children",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The \"Not\" operator can only have 1 child op... | The 'Not' operator has a few specific requirements. Check these here.
@param BaseOperator $operator
@throws LdapQueryException | [
"The",
"Not",
"operator",
"has",
"a",
"few",
"specific",
"requirements",
".",
"Check",
"these",
"here",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/bNot.php#L53-L61 | train |
ldaptools/ldaptools | src/LdapTools/Ldif/Entry/LdifEntryModify.php | LdifEntryModify.add | public function add($attribute, $value)
{
$this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value));
return $this;
} | php | public function add($attribute, $value)
{
$this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value));
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"batches",
"->",
"add",
"(",
"new",
"Batch",
"(",
"Batch",
"::",
"TYPE",
"[",
"'ADD'",
"]",
",",
"$",
"attribute",
",",
"$",
"value",
")",
")",
";... | Add a value to the attribute for the LDAP object.
@param $attribute
@param $value
@return $this | [
"Add",
"a",
"value",
"to",
"the",
"attribute",
"for",
"the",
"LDAP",
"object",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryModify.php#L87-L92 | train |
ldaptools/ldaptools | src/LdapTools/Security/Acl/Acl.php | Acl.setRevision | public function setRevision($revision)
{
if (!in_array((int) $revision, self::REVISION)) {
throw new InvalidArgumentException(sprintf(
'The value "%s" is not a recognized revision number. Allowed revisions are: %s',
$revision,
implode(', ', self::REVISION)
));
}
$this->revision = (int) $revision;
return $this;
} | php | public function setRevision($revision)
{
if (!in_array((int) $revision, self::REVISION)) {
throw new InvalidArgumentException(sprintf(
'The value "%s" is not a recognized revision number. Allowed revisions are: %s',
$revision,
implode(', ', self::REVISION)
));
}
$this->revision = (int) $revision;
return $this;
} | [
"public",
"function",
"setRevision",
"(",
"$",
"revision",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"(",
"int",
")",
"$",
"revision",
",",
"self",
"::",
"REVISION",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The v... | Set the revision of the ACL.
@param int $revision
@return $this | [
"Set",
"the",
"revision",
"of",
"the",
"ACL",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L89-L101 | train |
ldaptools/ldaptools | src/LdapTools/Security/Acl/Acl.php | Acl.addAce | public function addAce(Ace ...$aces)
{
foreach ($aces as $ace) {
$this->validateAce($ace);
if (!$this->hasAce($ace)) {
$this->aces[] = $ace;
}
}
return $this;
} | php | public function addAce(Ace ...$aces)
{
foreach ($aces as $ace) {
$this->validateAce($ace);
if (!$this->hasAce($ace)) {
$this->aces[] = $ace;
}
}
return $this;
} | [
"public",
"function",
"addAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"this",
"->",
"validateAce",
"(",
"$",
"ace",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAce",
"(",
"$... | Add one or more ACEs to the ACL.
@param Ace[] ...$aces
@return $this | [
"Add",
"one",
"or",
"more",
"ACEs",
"to",
"the",
"ACL",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L168-L178 | train |
ldaptools/ldaptools | src/LdapTools/Security/Acl/Acl.php | Acl.removeAce | public function removeAce(Ace ...$aces)
{
foreach ($aces as $ace) {
if ($this->hasAce($ace)) {
unset($this->aces[array_search($ace, $this->aces)]);
}
}
return $this;
} | php | public function removeAce(Ace ...$aces)
{
foreach ($aces as $ace) {
if ($this->hasAce($ace)) {
unset($this->aces[array_search($ace, $this->aces)]);
}
}
return $this;
} | [
"public",
"function",
"removeAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAce",
"(",
"$",
"ace",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"aces... | Remove one or more ACEs from the ACL.
@param Ace[] ...$aces
@return $this | [
"Remove",
"one",
"or",
"more",
"ACEs",
"from",
"the",
"ACL",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L186-L195 | train |
ldaptools/ldaptools | src/LdapTools/Security/Acl/Acl.php | Acl.hasAce | public function hasAce(Ace ...$aces)
{
$inArray = false;
foreach ($aces as $ace) {
$inArray = in_array($ace, $this->aces, true);
}
return $inArray;
} | php | public function hasAce(Ace ...$aces)
{
$inArray = false;
foreach ($aces as $ace) {
$inArray = in_array($ace, $this->aces, true);
}
return $inArray;
} | [
"public",
"function",
"hasAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"$",
"inArray",
"=",
"false",
";",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"inArray",
"=",
"in_array",
"(",
"$",
"ace",
",",
"$",
"this",
"->",
"aces"... | Check if an ACE, or multiple ACEs, exist within this ACL.
@param Ace[] ...$aces
@return bool | [
"Check",
"if",
"an",
"ACE",
"or",
"multiple",
"ACEs",
"exist",
"within",
"this",
"ACL",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L203-L212 | train |
ldaptools/ldaptools | src/LdapTools/Security/Acl/Acl.php | Acl.toBinary | public function toBinary()
{
$aces = '';
foreach ($this->aces as $ace) {
$aces .= $ace->toBinary();
}
return pack(
'C1C1v1v1v1',
$this->revision,
$this->sbz1,
((16 + (strlen(bin2hex($aces)))) / 2),
count($this->aces),
$this->sbz2
).$aces;
} | php | public function toBinary()
{
$aces = '';
foreach ($this->aces as $ace) {
$aces .= $ace->toBinary();
}
return pack(
'C1C1v1v1v1',
$this->revision,
$this->sbz1,
((16 + (strlen(bin2hex($aces)))) / 2),
count($this->aces),
$this->sbz2
).$aces;
} | [
"public",
"function",
"toBinary",
"(",
")",
"{",
"$",
"aces",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"aces",
".=",
"$",
"ace",
"->",
"toBinary",
"(",
")",
";",
"}",
"return",
"pack",
"(",
"'C... | Get the binary string representation of the ACL.
@return string | [
"Get",
"the",
"binary",
"string",
"representation",
"of",
"the",
"ACL",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L229-L244 | train |
ldaptools/ldaptools | src/LdapTools/Connection/RootDse.php | RootDse.get | public function get()
{
$anonymous = !$this->connection->isBound();
try {
$rootDse = self::doLdapQuery($anonymous);
} catch (\Exception $e) {
throw new LdapConnectionException(sprintf(
'Unable to query the RootDSE. %s',
$e->getMessage()
), $e->getCode());
} finally {
// Make sure to set things back to how they were...
if ($anonymous && $this->connection->isBound()) {
$this->connection->close();
}
}
return $rootDse;
} | php | public function get()
{
$anonymous = !$this->connection->isBound();
try {
$rootDse = self::doLdapQuery($anonymous);
} catch (\Exception $e) {
throw new LdapConnectionException(sprintf(
'Unable to query the RootDSE. %s',
$e->getMessage()
), $e->getCode());
} finally {
// Make sure to set things back to how they were...
if ($anonymous && $this->connection->isBound()) {
$this->connection->close();
}
}
return $rootDse;
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"anonymous",
"=",
"!",
"$",
"this",
"->",
"connection",
"->",
"isBound",
"(",
")",
";",
"try",
"{",
"$",
"rootDse",
"=",
"self",
"::",
"doLdapQuery",
"(",
"$",
"anonymous",
")",
";",
"}",
"catch",
"(... | Get the RootDSE LdapObject while accounting for the state of the connection.
@return \LdapTools\Object\LdapObject
@throws LdapConnectionException | [
"Get",
"the",
"RootDSE",
"LdapObject",
"while",
"accounting",
"for",
"the",
"state",
"of",
"the",
"connection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/RootDse.php#L73-L92 | train |
ldaptools/ldaptools | src/LdapTools/Connection/RootDse.php | RootDse.doLdapQuery | protected function doLdapQuery($anonymous)
{
if ($anonymous) {
$this->connection->connect('', '', true);
}
$schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
} | php | protected function doLdapQuery($anonymous)
{
if ($anonymous) {
$this->connection->connect('', '', true);
}
$schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
} | [
"protected",
"function",
"doLdapQuery",
"(",
"$",
"anonymous",
")",
"{",
"if",
"(",
"$",
"anonymous",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"connect",
"(",
"''",
",",
"''",
",",
"true",
")",
";",
"}",
"$",
"schema",
"=",
"$",
"this",
"->... | Do the LDAP query to get the LDAP object.
@param bool $anonymous
@return \LdapTools\Object\LdapObject | [
"Do",
"the",
"LDAP",
"query",
"to",
"get",
"the",
"LDAP",
"object",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/RootDse.php#L100-L108 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/TSPropertyArray.php | TSPropertyArray.toBinary | public function toBinary()
{
$binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT));
$binary .= hex2bin(str_pad(dechex(count($this->tsProperty)), 2, 0, STR_PAD_LEFT));
foreach ($this->tsProperty as $tsProperty) {
$binary .= $tsProperty->toBinary();
}
return $binary;
} | php | public function toBinary()
{
$binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT));
$binary .= hex2bin(str_pad(dechex(count($this->tsProperty)), 2, 0, STR_PAD_LEFT));
foreach ($this->tsProperty as $tsProperty) {
$binary .= $tsProperty->toBinary();
}
return $binary;
} | [
"public",
"function",
"toBinary",
"(",
")",
"{",
"$",
"binary",
"=",
"hex2bin",
"(",
"str_pad",
"(",
"dechex",
"(",
"ord",
"(",
"$",
"this",
"->",
"signature",
")",
")",
",",
"2",
",",
"0",
",",
"STR_PAD_LEFT",
")",
")",
";",
"$",
"binary",
".=",
... | Get the full binary representation of the userParameters containing the TSPropertyArray data.
@return string | [
"Get",
"the",
"full",
"binary",
"representation",
"of",
"the",
"userParameters",
"containing",
"the",
"TSPropertyArray",
"data",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSPropertyArray.php#L163-L172 | train |
ldaptools/ldaptools | src/LdapTools/Utilities/TSPropertyArray.php | TSPropertyArray.decode | protected function decode($tsPropArray)
{
$tsPropArray = bin2hex($tsPropArray);
// The signature is a 2-byte unicode character at the front
$this->signature = chr(hexdec(substr($tsPropArray, 0, 2)));
// The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray
// It starts at position 2. The actual variable data begins at position 4.
$length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2)));
// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
if (strlen($tsPropArray) > (4 + $length)) {
$this->postBinary = hex2bin(substr($tsPropArray, (4 + $length)));
}
} | php | protected function decode($tsPropArray)
{
$tsPropArray = bin2hex($tsPropArray);
// The signature is a 2-byte unicode character at the front
$this->signature = chr(hexdec(substr($tsPropArray, 0, 2)));
// The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray
// It starts at position 2. The actual variable data begins at position 4.
$length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2)));
// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
if (strlen($tsPropArray) > (4 + $length)) {
$this->postBinary = hex2bin(substr($tsPropArray, (4 + $length)));
}
} | [
"protected",
"function",
"decode",
"(",
"$",
"tsPropArray",
")",
"{",
"$",
"tsPropArray",
"=",
"bin2hex",
"(",
"$",
"tsPropArray",
")",
";",
"// The signature is a 2-byte unicode character at the front",
"$",
"this",
"->",
"signature",
"=",
"chr",
"(",
"hexdec",
"... | Given the TSPropertyArray binary data, extract out all of the TSProperty values.
@param string $tsPropArray
@return array | [
"Given",
"the",
"TSPropertyArray",
"binary",
"data",
"extract",
"out",
"all",
"of",
"the",
"TSProperty",
"values",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSPropertyArray.php#L255-L268 | train |
ldaptools/ldaptools | src/LdapTools/Query/OperatorCollection.php | OperatorCollection.add | public function add(BaseOperator ...$operators)
{
foreach ($operators as $operator) {
if ($operator instanceof bAnd) {
$this->operators['and'][] = $operator;
} elseif ($operator instanceof bOr) {
$this->operators['or'][] = $operator;
} elseif ($operator instanceof bNot) {
$this->operators['not'][] = $operator;
} elseif ($operator instanceof Wildcard) {
$this->operators['wildcard'][] = $operator;
} elseif ($operator instanceof MatchingRule) {
$this->operators['matchingrule'][] = $operator;
} elseif ($operator instanceof Comparison) {
$this->operators['comparison'][] = $operator;
} else {
throw new InvalidArgumentException('Unknown operator type.');
}
}
return $this;
} | php | public function add(BaseOperator ...$operators)
{
foreach ($operators as $operator) {
if ($operator instanceof bAnd) {
$this->operators['and'][] = $operator;
} elseif ($operator instanceof bOr) {
$this->operators['or'][] = $operator;
} elseif ($operator instanceof bNot) {
$this->operators['not'][] = $operator;
} elseif ($operator instanceof Wildcard) {
$this->operators['wildcard'][] = $operator;
} elseif ($operator instanceof MatchingRule) {
$this->operators['matchingrule'][] = $operator;
} elseif ($operator instanceof Comparison) {
$this->operators['comparison'][] = $operator;
} else {
throw new InvalidArgumentException('Unknown operator type.');
}
}
return $this;
} | [
"public",
"function",
"add",
"(",
"BaseOperator",
"...",
"$",
"operators",
")",
"{",
"foreach",
"(",
"$",
"operators",
"as",
"$",
"operator",
")",
"{",
"if",
"(",
"$",
"operator",
"instanceof",
"bAnd",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'a... | Add an Operator to the collection.
@param BaseOperator[] ...$operators
@return $this
@throws LdapQueryException | [
"Add",
"an",
"Operator",
"to",
"the",
"collection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L65-L86 | train |
ldaptools/ldaptools | src/LdapTools/Query/OperatorCollection.php | OperatorCollection.addLdapObjectSchema | public function addLdapObjectSchema(LdapObjectSchema $schema, $alias = null)
{
if (!is_null($alias) && !is_string($alias)) {
throw new InvalidArgumentException(sprintf(
'The alias for type "%s" must be a string, but "%s" was given.',
$schema->getObjectType(),
is_string($alias) ? $alias : gettype($alias)
));
}
$alias = $alias ?: $schema->getObjectType();
if (!preg_match(self::ALIAS_REGEX, $alias)) {
throw new InvalidArgumentException(sprintf(
'The alias "%s" for type "%s" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _',
$alias,
$schema->getObjectType()
));
}
$this->aliases[$alias] = $schema;
} | php | public function addLdapObjectSchema(LdapObjectSchema $schema, $alias = null)
{
if (!is_null($alias) && !is_string($alias)) {
throw new InvalidArgumentException(sprintf(
'The alias for type "%s" must be a string, but "%s" was given.',
$schema->getObjectType(),
is_string($alias) ? $alias : gettype($alias)
));
}
$alias = $alias ?: $schema->getObjectType();
if (!preg_match(self::ALIAS_REGEX, $alias)) {
throw new InvalidArgumentException(sprintf(
'The alias "%s" for type "%s" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _',
$alias,
$schema->getObjectType()
));
}
$this->aliases[$alias] = $schema;
} | [
"public",
"function",
"addLdapObjectSchema",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"alias",
")",
"&&",
"!",
"is_string",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
... | Add a LdapObjectSchema for a object type that will be selected for. Optionally specify a specific alias that is
used to reference it. If no alias is specified, then it uses the object type name for the schema.
@param LdapObjectSchema $schema
@param null|string $alias | [
"Add",
"a",
"LdapObjectSchema",
"for",
"a",
"object",
"type",
"that",
"will",
"be",
"selected",
"for",
".",
"Optionally",
"specify",
"a",
"specific",
"alias",
"that",
"is",
"used",
"to",
"reference",
"it",
".",
"If",
"no",
"alias",
"is",
"specified",
"then... | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L95-L114 | train |
ldaptools/ldaptools | src/LdapTools/Query/OperatorCollection.php | OperatorCollection.toLdapFilter | public function toLdapFilter($alias = null)
{
if (is_null($alias) && !empty($this->aliases)) {
$filter = $this->getLdapFilterForAliases();
} else {
$filter = $this->getLdapFilter($alias);
}
return $filter;
} | php | public function toLdapFilter($alias = null)
{
if (is_null($alias) && !empty($this->aliases)) {
$filter = $this->getLdapFilterForAliases();
} else {
$filter = $this->getLdapFilter($alias);
}
return $filter;
} | [
"public",
"function",
"toLdapFilter",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"alias",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"aliases",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"getLdapFilte... | Get the LDAP filter string representation of all the operators in the collection.
@param string|null $alias The alias to narrow the filter to.
@return string | [
"Get",
"the",
"LDAP",
"filter",
"string",
"representation",
"of",
"all",
"the",
"operators",
"in",
"the",
"collection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L212-L221 | train |
ldaptools/ldaptools | src/LdapTools/Query/OperatorCollection.php | OperatorCollection.sortOperatorsToArray | protected function sortOperatorsToArray()
{
return array_merge(
$this->operators['and'],
$this->operators['or'],
$this->operators['not'],
$this->operators['comparison'],
$this->operators['wildcard'],
$this->operators['matchingrule']
);
} | php | protected function sortOperatorsToArray()
{
return array_merge(
$this->operators['and'],
$this->operators['or'],
$this->operators['not'],
$this->operators['comparison'],
$this->operators['wildcard'],
$this->operators['matchingrule']
);
} | [
"protected",
"function",
"sortOperatorsToArray",
"(",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"operators",
"[",
"'and'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'or'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'not'",
"]"... | Merges all the Operators into one large array in a specific order. Before doing so, it will apply any schemas
that exist.
@return BaseOperator[]
@throws LdapQueryException | [
"Merges",
"all",
"the",
"Operators",
"into",
"one",
"large",
"array",
"in",
"a",
"specific",
"order",
".",
"Before",
"doing",
"so",
"it",
"will",
"apply",
"any",
"schemas",
"that",
"exist",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L242-L252 | train |
ldaptools/ldaptools | src/LdapTools/Query/OperatorCollection.php | OperatorCollection.getLdapFilterForAliases | protected function getLdapFilterForAliases()
{
$filters = [];
foreach (array_keys($this->aliases) as $alias) {
$filters[] = $this->getLdapFilter($alias);
}
if (count($filters) == 1) {
return $filters[0];
} else {
return bOr::SEPARATOR_START.bOr::SYMBOL.implode('', $filters).bOr::SEPARATOR_END;
}
} | php | protected function getLdapFilterForAliases()
{
$filters = [];
foreach (array_keys($this->aliases) as $alias) {
$filters[] = $this->getLdapFilter($alias);
}
if (count($filters) == 1) {
return $filters[0];
} else {
return bOr::SEPARATOR_START.bOr::SYMBOL.implode('', $filters).bOr::SEPARATOR_END;
}
} | [
"protected",
"function",
"getLdapFilterForAliases",
"(",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"aliases",
")",
"as",
"$",
"alias",
")",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"this",
"->... | Constructs a filter for multiple aliases that would return the requested LDAP objects in a single query.
@return string | [
"Constructs",
"a",
"filter",
"for",
"multiple",
"aliases",
"that",
"would",
"return",
"the",
"requested",
"LDAP",
"objects",
"in",
"a",
"single",
"query",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L286-L299 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.