id
int32 0
241k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
23,200
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.exec
|
public function exec($cmd)
{
if (trim($cmd)) {
$this->setOutputPrefix('');
if ($this->resolve('DEBUG')) {
$this->output->writeln('<comment># ' . join('::', Debug::$scope) . "</comment>");
}
if ($this->resolve('EXPLAIN')) {
if ($this->resolve('INTERACTIVE')) {
$this->notice('interactive shell:');
$line = '( /bin/bash -c \'' . trim($cmd) . '\' )';
} else {
$line = 'echo ' . escapeshellarg(trim($cmd)) . ' | ' . $this->resolve(array('SHELL'));
}
$this->output->writeln($line);
} else {
$this->executor->execute($cmd);
}
}
}
|
php
|
public function exec($cmd)
{
if (trim($cmd)) {
$this->setOutputPrefix('');
if ($this->resolve('DEBUG')) {
$this->output->writeln('<comment># ' . join('::', Debug::$scope) . "</comment>");
}
if ($this->resolve('EXPLAIN')) {
if ($this->resolve('INTERACTIVE')) {
$this->notice('interactive shell:');
$line = '( /bin/bash -c \'' . trim($cmd) . '\' )';
} else {
$line = 'echo ' . escapeshellarg(trim($cmd)) . ' | ' . $this->resolve(array('SHELL'));
}
$this->output->writeln($line);
} else {
$this->executor->execute($cmd);
}
}
}
|
[
"public",
"function",
"exec",
"(",
"$",
"cmd",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"cmd",
")",
")",
"{",
"$",
"this",
"->",
"setOutputPrefix",
"(",
"''",
")",
";",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'DEBUG'",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'<comment># '",
".",
"join",
"(",
"'::'",
",",
"Debug",
"::",
"$",
"scope",
")",
".",
"\"</comment>\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'EXPLAIN'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"resolve",
"(",
"'INTERACTIVE'",
")",
")",
"{",
"$",
"this",
"->",
"notice",
"(",
"'interactive shell:'",
")",
";",
"$",
"line",
"=",
"'( /bin/bash -c \\''",
".",
"trim",
"(",
"$",
"cmd",
")",
".",
"'\\' )'",
";",
"}",
"else",
"{",
"$",
"line",
"=",
"'echo '",
".",
"escapeshellarg",
"(",
"trim",
"(",
"$",
"cmd",
")",
")",
".",
"' | '",
".",
"$",
"this",
"->",
"resolve",
"(",
"array",
"(",
"'SHELL'",
")",
")",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"line",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"cmd",
")",
";",
"}",
"}",
"}"
] |
Executes a script snippet using the 'executor' service.
@param string $cmd
@return void
|
[
"Executes",
"a",
"script",
"snippet",
"using",
"the",
"executor",
"service",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L496-L517
|
23,201
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.str
|
public function str($value)
{
if (is_array($value)) {
$allScalar = function ($a, $b) {
return $a && is_scalar($b);
};
if (!array_reduce($value, $allScalar, true)) {
throw new UnexpectedValueException("Unexpected complex type " . Util::toPhp($value));
}
return join(' ', $value);
}
return (string)$value;
}
|
php
|
public function str($value)
{
if (is_array($value)) {
$allScalar = function ($a, $b) {
return $a && is_scalar($b);
};
if (!array_reduce($value, $allScalar, true)) {
throw new UnexpectedValueException("Unexpected complex type " . Util::toPhp($value));
}
return join(' ', $value);
}
return (string)$value;
}
|
[
"public",
"function",
"str",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"allScalar",
"=",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"a",
"&&",
"is_scalar",
"(",
"$",
"b",
")",
";",
"}",
";",
"if",
"(",
"!",
"array_reduce",
"(",
"$",
"value",
",",
"$",
"allScalar",
",",
"true",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"\"Unexpected complex type \"",
".",
"Util",
"::",
"toPhp",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"join",
"(",
"' '",
",",
"$",
"value",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}"
] |
Convert the value to a string.
@param mixed $value
@return string
@throws \UnexpectedValueException
|
[
"Convert",
"the",
"value",
"to",
"a",
"string",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L561-L573
|
23,202
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.push
|
public function push($varName, $tail)
{
if (false === $this->has($varName)) {
$this->set($varName, null);
}
if (!isset($this->varStack[json_encode($varName)])) {
$this->varStack[json_encode($varName)] = array();
}
array_push($this->varStack[json_encode($varName)], $this->get($varName));
$this->set($varName, $tail);
}
|
php
|
public function push($varName, $tail)
{
if (false === $this->has($varName)) {
$this->set($varName, null);
}
if (!isset($this->varStack[json_encode($varName)])) {
$this->varStack[json_encode($varName)] = array();
}
array_push($this->varStack[json_encode($varName)], $this->get($varName));
$this->set($varName, $tail);
}
|
[
"public",
"function",
"push",
"(",
"$",
"varName",
",",
"$",
"tail",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"has",
"(",
"$",
"varName",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"null",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
"=",
"array",
"(",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
",",
"$",
"this",
"->",
"get",
"(",
"$",
"varName",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"$",
"tail",
")",
";",
"}"
] |
Push a var on a local stack by it's name.
@param string $varName
@param string $tail
@return void
|
[
"Push",
"a",
"var",
"on",
"a",
"local",
"stack",
"by",
"it",
"s",
"name",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L650-L660
|
23,203
|
zicht/z
|
src/Zicht/Tool/Container/Container.php
|
Container.pop
|
public function pop($varName)
{
$this->set($varName, array_pop($this->varStack[json_encode($varName)]));
}
|
php
|
public function pop($varName)
{
$this->set($varName, array_pop($this->varStack[json_encode($varName)]));
}
|
[
"public",
"function",
"pop",
"(",
"$",
"varName",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"varName",
",",
"array_pop",
"(",
"$",
"this",
"->",
"varStack",
"[",
"json_encode",
"(",
"$",
"varName",
")",
"]",
")",
")",
";",
"}"
] |
Pop a var from a local var stack.
@param string $varName
@return void
|
[
"Pop",
"a",
"var",
"from",
"a",
"local",
"var",
"stack",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Container.php#L669-L672
|
23,204
|
eloquent/phony-kahlan
|
src/ArgumentFactory.php
|
ArgumentFactory.argumentsForCallback
|
public function argumentsForCallback(callable $callback): array
{
$definition = new ReflectionFunction($callback);
$arguments = [];
foreach ($definition->getParameters() as $parameter) {
if ($type = $parameter->getType()) {
$arguments[] = Phony::emptyValue($type);
} else {
$arguments[] = null;
}
}
return $arguments;
}
|
php
|
public function argumentsForCallback(callable $callback): array
{
$definition = new ReflectionFunction($callback);
$arguments = [];
foreach ($definition->getParameters() as $parameter) {
if ($type = $parameter->getType()) {
$arguments[] = Phony::emptyValue($type);
} else {
$arguments[] = null;
}
}
return $arguments;
}
|
[
"public",
"function",
"argumentsForCallback",
"(",
"callable",
"$",
"callback",
")",
":",
"array",
"{",
"$",
"definition",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"arguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"definition",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"type",
"=",
"$",
"parameter",
"->",
"getType",
"(",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"Phony",
"::",
"emptyValue",
"(",
"$",
"type",
")",
";",
"}",
"else",
"{",
"$",
"arguments",
"[",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"arguments",
";",
"}"
] |
Returns an argument list of test doubles for the supplied callback.
@param callable $callback The callback.
@return array The arguments.
|
[
"Returns",
"an",
"argument",
"list",
"of",
"test",
"doubles",
"for",
"the",
"supplied",
"callback",
"."
] |
a4654a7edf58268b492acc751ecbeddded9b176f
|
https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/ArgumentFactory.php#L21-L35
|
23,205
|
zhouyl/mellivora
|
Mellivora/Console/GeneratorCommand.php
|
GeneratorCommand.qualifyClass
|
protected function qualifyClass($name)
{
$rootNamespace = $this->rootNamespace();
if (Str::startsWith($name, $rootNamespace . '\\')) {
return $name;
}
$name = str_replace('/', '\\', $name);
return $this->qualifyClass(
$this->getDefaultNamespace(trim($rootNamespace, '\\')) . '\\' . $name
);
}
|
php
|
protected function qualifyClass($name)
{
$rootNamespace = $this->rootNamespace();
if (Str::startsWith($name, $rootNamespace . '\\')) {
return $name;
}
$name = str_replace('/', '\\', $name);
return $this->qualifyClass(
$this->getDefaultNamespace(trim($rootNamespace, '\\')) . '\\' . $name
);
}
|
[
"protected",
"function",
"qualifyClass",
"(",
"$",
"name",
")",
"{",
"$",
"rootNamespace",
"=",
"$",
"this",
"->",
"rootNamespace",
"(",
")",
";",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"name",
",",
"$",
"rootNamespace",
".",
"'\\\\'",
")",
")",
"{",
"return",
"$",
"name",
";",
"}",
"$",
"name",
"=",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getDefaultNamespace",
"(",
"trim",
"(",
"$",
"rootNamespace",
",",
"'\\\\'",
")",
")",
".",
"'\\\\'",
".",
"$",
"name",
")",
";",
"}"
] |
Parse the class name and format according to the root namespace.
@param string $name
@return string
|
[
"Parse",
"the",
"class",
"name",
"and",
"format",
"according",
"to",
"the",
"root",
"namespace",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/GeneratorCommand.php#L61-L74
|
23,206
|
amenophis/WHMCS-Connector
|
src/Amenophis/WHMCS/Adapter/Manager.php
|
Manager.get
|
public function get($name = null)
{
if(count($this->connectors) > 0)
{
if(!is_null($name))
{
if(!isset($this->connectors[$name]))
throw new \Exception("unknown Connector: $name");
return $this->connectors[$name];
}
return current($this->connectors);
}
throw new \Exception('No Connectors found');
}
|
php
|
public function get($name = null)
{
if(count($this->connectors) > 0)
{
if(!is_null($name))
{
if(!isset($this->connectors[$name]))
throw new \Exception("unknown Connector: $name");
return $this->connectors[$name];
}
return current($this->connectors);
}
throw new \Exception('No Connectors found');
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"connectors",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"\"unknown Connector: $name\"",
")",
";",
"return",
"$",
"this",
"->",
"connectors",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"current",
"(",
"$",
"this",
"->",
"connectors",
")",
";",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"'No Connectors found'",
")",
";",
"}"
] |
get an Connector by its name or it will return the default Connector
@param string $name Index of the chosen Connector
@return FP\WHMCS\Connector
|
[
"get",
"an",
"Connector",
"by",
"its",
"name",
"or",
"it",
"will",
"return",
"the",
"default",
"Connector"
] |
eb608e6652aca8a46dd80dd04159142a7e2d2f9b
|
https://github.com/amenophis/WHMCS-Connector/blob/eb608e6652aca8a46dd80dd04159142a7e2d2f9b/src/Amenophis/WHMCS/Adapter/Manager.php#L50-L65
|
23,207
|
tttptd/laravel-responder
|
src/ResponderServiceProvider.php
|
ResponderServiceProvider.registerFractal
|
protected function registerFractal()
{
$this->app->bind(SerializerAbstract::class, function ($app) {
$serializer = $app->config->get('responder.serializer');
return new $serializer;
});
$this->app->bind(Manager::class, function ($app) {
return (new Manager())->setSerializer($app[SerializerAbstract::class]);
});
$this->app->bind(ResourceFactory::class, function () {
return new ResourceFactory();
});
}
|
php
|
protected function registerFractal()
{
$this->app->bind(SerializerAbstract::class, function ($app) {
$serializer = $app->config->get('responder.serializer');
return new $serializer;
});
$this->app->bind(Manager::class, function ($app) {
return (new Manager())->setSerializer($app[SerializerAbstract::class]);
});
$this->app->bind(ResourceFactory::class, function () {
return new ResourceFactory();
});
}
|
[
"protected",
"function",
"registerFractal",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"SerializerAbstract",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"serializer",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.serializer'",
")",
";",
"return",
"new",
"$",
"serializer",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"Manager",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"(",
"new",
"Manager",
"(",
")",
")",
"->",
"setSerializer",
"(",
"$",
"app",
"[",
"SerializerAbstract",
"::",
"class",
"]",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"ResourceFactory",
"::",
"class",
",",
"function",
"(",
")",
"{",
"return",
"new",
"ResourceFactory",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Register Fractal serializer, manager and a factory to generate Fractal
resource instances.
@return void
|
[
"Register",
"Fractal",
"serializer",
"manager",
"and",
"a",
"factory",
"to",
"generate",
"Fractal",
"resource",
"instances",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L95-L110
|
23,208
|
tttptd/laravel-responder
|
src/ResponderServiceProvider.php
|
ResponderServiceProvider.registerResponseBuilders
|
protected function registerResponseBuilders()
{
$this->app->bind(SuccessResponseBuilder::class, function ($app) {
$builder = new SuccessResponseBuilder(response(), $app[ResourceFactory::class], $app[Manager::class]);
if ($parameter = $app->config->get('responder.load_relations_from_parameter')) {
$builder->include($this->app[Request::class]->input($parameter, []));
}
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
$this->app->bind(ErrorResponseBuilder::class, function ($app) {
$builder = new ErrorResponseBuilder(response(), $app['translator']);
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
}
|
php
|
protected function registerResponseBuilders()
{
$this->app->bind(SuccessResponseBuilder::class, function ($app) {
$builder = new SuccessResponseBuilder(response(), $app[ResourceFactory::class], $app[Manager::class]);
if ($parameter = $app->config->get('responder.load_relations_from_parameter')) {
$builder->include($this->app[Request::class]->input($parameter, []));
}
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
$this->app->bind(ErrorResponseBuilder::class, function ($app) {
$builder = new ErrorResponseBuilder(response(), $app['translator']);
$builder->setIncludeSuccessFlag($app->config->get('responder.include_success_flag'));
return $builder->setIncludeStatusCode($app->config->get('responder.include_status_code'));
});
}
|
[
"protected",
"function",
"registerResponseBuilders",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"SuccessResponseBuilder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"builder",
"=",
"new",
"SuccessResponseBuilder",
"(",
"response",
"(",
")",
",",
"$",
"app",
"[",
"ResourceFactory",
"::",
"class",
"]",
",",
"$",
"app",
"[",
"Manager",
"::",
"class",
"]",
")",
";",
"if",
"(",
"$",
"parameter",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.load_relations_from_parameter'",
")",
")",
"{",
"$",
"builder",
"->",
"include",
"(",
"$",
"this",
"->",
"app",
"[",
"Request",
"::",
"class",
"]",
"->",
"input",
"(",
"$",
"parameter",
",",
"[",
"]",
")",
")",
";",
"}",
"$",
"builder",
"->",
"setIncludeSuccessFlag",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_success_flag'",
")",
")",
";",
"return",
"$",
"builder",
"->",
"setIncludeStatusCode",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_status_code'",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"ErrorResponseBuilder",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"builder",
"=",
"new",
"ErrorResponseBuilder",
"(",
"response",
"(",
")",
",",
"$",
"app",
"[",
"'translator'",
"]",
")",
";",
"$",
"builder",
"->",
"setIncludeSuccessFlag",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_success_flag'",
")",
")",
";",
"return",
"$",
"builder",
"->",
"setIncludeStatusCode",
"(",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'responder.include_status_code'",
")",
")",
";",
"}",
")",
";",
"}"
] |
Register success and error response builders.
@return void
|
[
"Register",
"success",
"and",
"error",
"response",
"builders",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L117-L136
|
23,209
|
tttptd/laravel-responder
|
src/ResponderServiceProvider.php
|
ResponderServiceProvider.registerAliases
|
protected function registerAliases()
{
$this->app->alias(Responder::class, 'responder');
$this->app->alias(SuccessResponseBuilder::class, 'responder.success');
$this->app->alias(ErrorResponseBuilder::class, 'responder.error');
$this->app->alias(Manager::class, 'responder.manager');
$this->app->alias(Manager::class, 'responder.serializer');
}
|
php
|
protected function registerAliases()
{
$this->app->alias(Responder::class, 'responder');
$this->app->alias(SuccessResponseBuilder::class, 'responder.success');
$this->app->alias(ErrorResponseBuilder::class, 'responder.error');
$this->app->alias(Manager::class, 'responder.manager');
$this->app->alias(Manager::class, 'responder.serializer');
}
|
[
"protected",
"function",
"registerAliases",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Responder",
"::",
"class",
",",
"'responder'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"SuccessResponseBuilder",
"::",
"class",
",",
"'responder.success'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"ErrorResponseBuilder",
"::",
"class",
",",
"'responder.error'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Manager",
"::",
"class",
",",
"'responder.manager'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Manager",
"::",
"class",
",",
"'responder.serializer'",
")",
";",
"}"
] |
Set aliases for the provided services.
@return void
|
[
"Set",
"aliases",
"for",
"the",
"provided",
"services",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResponderServiceProvider.php#L143-L150
|
23,210
|
antaresproject/notifications
|
src/Event/EventDispatcher.php
|
EventDispatcher.run
|
public function run(array $notification, array $variables = null, array $recipients = null)
{
$typeName = Arr::get($notification, 'type.name');
switch ($typeName) {
case 'email':
$instance = app(EmailNotification::class);
break;
case 'sms':
$instance = app(SmsNotification::class);
break;
default:
$instance = app(CustomNotification::class);
break;
}
$instance->setPredefinedVariables($variables);
$instance->setModel($notification);
if ($instance instanceof SendableNotification) {
$instance->setRecipients($recipients);
if (!$this->validate($instance)) {
return false;
}
$type = $instance->getType();
$job = $instance->onConnection('database')->onQueue($type);
$this->dispatch($job);
} else {
return $instance->handle();
}
}
|
php
|
public function run(array $notification, array $variables = null, array $recipients = null)
{
$typeName = Arr::get($notification, 'type.name');
switch ($typeName) {
case 'email':
$instance = app(EmailNotification::class);
break;
case 'sms':
$instance = app(SmsNotification::class);
break;
default:
$instance = app(CustomNotification::class);
break;
}
$instance->setPredefinedVariables($variables);
$instance->setModel($notification);
if ($instance instanceof SendableNotification) {
$instance->setRecipients($recipients);
if (!$this->validate($instance)) {
return false;
}
$type = $instance->getType();
$job = $instance->onConnection('database')->onQueue($type);
$this->dispatch($job);
} else {
return $instance->handle();
}
}
|
[
"public",
"function",
"run",
"(",
"array",
"$",
"notification",
",",
"array",
"$",
"variables",
"=",
"null",
",",
"array",
"$",
"recipients",
"=",
"null",
")",
"{",
"$",
"typeName",
"=",
"Arr",
"::",
"get",
"(",
"$",
"notification",
",",
"'type.name'",
")",
";",
"switch",
"(",
"$",
"typeName",
")",
"{",
"case",
"'email'",
":",
"$",
"instance",
"=",
"app",
"(",
"EmailNotification",
"::",
"class",
")",
";",
"break",
";",
"case",
"'sms'",
":",
"$",
"instance",
"=",
"app",
"(",
"SmsNotification",
"::",
"class",
")",
";",
"break",
";",
"default",
":",
"$",
"instance",
"=",
"app",
"(",
"CustomNotification",
"::",
"class",
")",
";",
"break",
";",
"}",
"$",
"instance",
"->",
"setPredefinedVariables",
"(",
"$",
"variables",
")",
";",
"$",
"instance",
"->",
"setModel",
"(",
"$",
"notification",
")",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"SendableNotification",
")",
"{",
"$",
"instance",
"->",
"setRecipients",
"(",
"$",
"recipients",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"type",
"=",
"$",
"instance",
"->",
"getType",
"(",
")",
";",
"$",
"job",
"=",
"$",
"instance",
"->",
"onConnection",
"(",
"'database'",
")",
"->",
"onQueue",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"job",
")",
";",
"}",
"else",
"{",
"return",
"$",
"instance",
"->",
"handle",
"(",
")",
";",
"}",
"}"
] |
Sends notification.
@param array $notification
@param array|null $variables
@param array|null $recipients
@return bool|\Symfony\Component\HttpFoundation\Response
|
[
"Sends",
"notification",
"."
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Event/EventDispatcher.php#L45-L75
|
23,211
|
mothership-ec/composer
|
src/Composer/Downloader/DownloadManager.php
|
DownloadManager.getDownloaderForInstalledPackage
|
public function getDownloaderForInstalledPackage(PackageInterface $package)
{
$installationSource = $package->getInstallationSource();
if ('metapackage' === $package->getType()) {
return;
}
if ('dist' === $installationSource) {
$downloader = $this->getDownloader($package->getDistType());
} elseif ('source' === $installationSource) {
$downloader = $this->getDownloader($package->getSourceType());
} else {
throw new \InvalidArgumentException(
'Package '.$package.' seems not been installed properly'
);
}
if ($installationSource !== $downloader->getInstallationSource()) {
throw new \LogicException(sprintf(
'Downloader "%s" is a %s type downloader and can not be used to download %s',
get_class($downloader), $downloader->getInstallationSource(), $installationSource
));
}
return $downloader;
}
|
php
|
public function getDownloaderForInstalledPackage(PackageInterface $package)
{
$installationSource = $package->getInstallationSource();
if ('metapackage' === $package->getType()) {
return;
}
if ('dist' === $installationSource) {
$downloader = $this->getDownloader($package->getDistType());
} elseif ('source' === $installationSource) {
$downloader = $this->getDownloader($package->getSourceType());
} else {
throw new \InvalidArgumentException(
'Package '.$package.' seems not been installed properly'
);
}
if ($installationSource !== $downloader->getInstallationSource()) {
throw new \LogicException(sprintf(
'Downloader "%s" is a %s type downloader and can not be used to download %s',
get_class($downloader), $downloader->getInstallationSource(), $installationSource
));
}
return $downloader;
}
|
[
"public",
"function",
"getDownloaderForInstalledPackage",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"installationSource",
"=",
"$",
"package",
"->",
"getInstallationSource",
"(",
")",
";",
"if",
"(",
"'metapackage'",
"===",
"$",
"package",
"->",
"getType",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloader",
"(",
"$",
"package",
"->",
"getDistType",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"'source'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloader",
"(",
"$",
"package",
"->",
"getSourceType",
"(",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Package '",
".",
"$",
"package",
".",
"' seems not been installed properly'",
")",
";",
"}",
"if",
"(",
"$",
"installationSource",
"!==",
"$",
"downloader",
"->",
"getInstallationSource",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Downloader \"%s\" is a %s type downloader and can not be used to download %s'",
",",
"get_class",
"(",
"$",
"downloader",
")",
",",
"$",
"downloader",
"->",
"getInstallationSource",
"(",
")",
",",
"$",
"installationSource",
")",
")",
";",
"}",
"return",
"$",
"downloader",
";",
"}"
] |
Returns downloader for already installed package.
@param PackageInterface $package package instance
@return DownloaderInterface|null
@throws \InvalidArgumentException if package has no installation source specified
@throws \LogicException if specific downloader used to load package with
wrong type
|
[
"Returns",
"downloader",
"for",
"already",
"installed",
"package",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/DownloadManager.php#L131-L157
|
23,212
|
mothership-ec/composer
|
src/Composer/Downloader/DownloadManager.php
|
DownloadManager.update
|
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{
$downloader = $this->getDownloaderForInstalledPackage($initial);
if (!$downloader) {
return;
}
$installationSource = $initial->getInstallationSource();
if ('dist' === $installationSource) {
$initialType = $initial->getDistType();
$targetType = $target->getDistType();
} else {
$initialType = $initial->getSourceType();
$targetType = $target->getSourceType();
}
// upgrading from a dist stable package to a dev package, force source reinstall
if ($target->isDev() && 'dist' === $installationSource) {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir);
return;
}
if ($initialType === $targetType) {
$target->setInstallationSource($installationSource);
$downloader->update($initial, $target, $targetDir);
} else {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir, 'source' === $installationSource);
}
}
|
php
|
public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
{
$downloader = $this->getDownloaderForInstalledPackage($initial);
if (!$downloader) {
return;
}
$installationSource = $initial->getInstallationSource();
if ('dist' === $installationSource) {
$initialType = $initial->getDistType();
$targetType = $target->getDistType();
} else {
$initialType = $initial->getSourceType();
$targetType = $target->getSourceType();
}
// upgrading from a dist stable package to a dev package, force source reinstall
if ($target->isDev() && 'dist' === $installationSource) {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir);
return;
}
if ($initialType === $targetType) {
$target->setInstallationSource($installationSource);
$downloader->update($initial, $target, $targetDir);
} else {
$downloader->remove($initial, $targetDir);
$this->download($target, $targetDir, 'source' === $installationSource);
}
}
|
[
"public",
"function",
"update",
"(",
"PackageInterface",
"$",
"initial",
",",
"PackageInterface",
"$",
"target",
",",
"$",
"targetDir",
")",
"{",
"$",
"downloader",
"=",
"$",
"this",
"->",
"getDownloaderForInstalledPackage",
"(",
"$",
"initial",
")",
";",
"if",
"(",
"!",
"$",
"downloader",
")",
"{",
"return",
";",
"}",
"$",
"installationSource",
"=",
"$",
"initial",
"->",
"getInstallationSource",
"(",
")",
";",
"if",
"(",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"initialType",
"=",
"$",
"initial",
"->",
"getDistType",
"(",
")",
";",
"$",
"targetType",
"=",
"$",
"target",
"->",
"getDistType",
"(",
")",
";",
"}",
"else",
"{",
"$",
"initialType",
"=",
"$",
"initial",
"->",
"getSourceType",
"(",
")",
";",
"$",
"targetType",
"=",
"$",
"target",
"->",
"getSourceType",
"(",
")",
";",
"}",
"// upgrading from a dist stable package to a dev package, force source reinstall",
"if",
"(",
"$",
"target",
"->",
"isDev",
"(",
")",
"&&",
"'dist'",
"===",
"$",
"installationSource",
")",
"{",
"$",
"downloader",
"->",
"remove",
"(",
"$",
"initial",
",",
"$",
"targetDir",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"target",
",",
"$",
"targetDir",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"initialType",
"===",
"$",
"targetType",
")",
"{",
"$",
"target",
"->",
"setInstallationSource",
"(",
"$",
"installationSource",
")",
";",
"$",
"downloader",
"->",
"update",
"(",
"$",
"initial",
",",
"$",
"target",
",",
"$",
"targetDir",
")",
";",
"}",
"else",
"{",
"$",
"downloader",
"->",
"remove",
"(",
"$",
"initial",
",",
"$",
"targetDir",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"target",
",",
"$",
"targetDir",
",",
"'source'",
"===",
"$",
"installationSource",
")",
";",
"}",
"}"
] |
Updates package from initial to target version.
@param PackageInterface $initial initial package version
@param PackageInterface $target target package version
@param string $targetDir target dir
@throws \InvalidArgumentException if initial package is not installed
|
[
"Updates",
"package",
"from",
"initial",
"to",
"target",
"version",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/DownloadManager.php#L228-L260
|
23,213
|
Smile-SA/CronBundle
|
Repository/SmileCronRepository.php
|
SmileCronRepository.isQueued
|
public function isQueued($alias)
{
$query = $this->createQueryBuilder('c')
->where('c.alias = :alias')
->andWhere('c.ended is NULL')
->setParameter('alias', $alias)
->getQuery();
$result = $query->setMaxResults(1)->getOneOrNullResult();
if ($result)
return true;
return false;
}
|
php
|
public function isQueued($alias)
{
$query = $this->createQueryBuilder('c')
->where('c.alias = :alias')
->andWhere('c.ended is NULL')
->setParameter('alias', $alias)
->getQuery();
$result = $query->setMaxResults(1)->getOneOrNullResult();
if ($result)
return true;
return false;
}
|
[
"public",
"function",
"isQueued",
"(",
"$",
"alias",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"where",
"(",
"'c.alias = :alias'",
")",
"->",
"andWhere",
"(",
"'c.ended is NULL'",
")",
"->",
"setParameter",
"(",
"'alias'",
",",
"$",
"alias",
")",
"->",
"getQuery",
"(",
")",
";",
"$",
"result",
"=",
"$",
"query",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] |
Identify of cron command is queued
@param string $alias cron alias
@return bool true if cron is already queued
|
[
"Identify",
"of",
"cron",
"command",
"is",
"queued"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Repository/SmileCronRepository.php#L20-L34
|
23,214
|
Smile-SA/CronBundle
|
Repository/SmileCronRepository.php
|
SmileCronRepository.addQueued
|
public function addQueued($alias)
{
$query = $this->createQueryBuilder('c')
->where('c.alias = :alias')
->setParameter('alias', $alias)
->getQuery();
/** @var SmileCron $smileCron */
$smileCron = $query->setMaxResults(1)->getOneOrNullResult();
if (!$smileCron) {
$smileCron = new SmileCron();
$smileCron->setAlias($alias);
}
$now = new \DateTime('now');
$smileCron->setQueued($now);
$smileCron->setStarted(null);
$smileCron->setEnded(null);
$smileCron->setStatus(0);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
php
|
public function addQueued($alias)
{
$query = $this->createQueryBuilder('c')
->where('c.alias = :alias')
->setParameter('alias', $alias)
->getQuery();
/** @var SmileCron $smileCron */
$smileCron = $query->setMaxResults(1)->getOneOrNullResult();
if (!$smileCron) {
$smileCron = new SmileCron();
$smileCron->setAlias($alias);
}
$now = new \DateTime('now');
$smileCron->setQueued($now);
$smileCron->setStarted(null);
$smileCron->setEnded(null);
$smileCron->setStatus(0);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
[
"public",
"function",
"addQueued",
"(",
"$",
"alias",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'c'",
")",
"->",
"where",
"(",
"'c.alias = :alias'",
")",
"->",
"setParameter",
"(",
"'alias'",
",",
"$",
"alias",
")",
"->",
"getQuery",
"(",
")",
";",
"/** @var SmileCron $smileCron */",
"$",
"smileCron",
"=",
"$",
"query",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"if",
"(",
"!",
"$",
"smileCron",
")",
"{",
"$",
"smileCron",
"=",
"new",
"SmileCron",
"(",
")",
";",
"$",
"smileCron",
"->",
"setAlias",
"(",
"$",
"alias",
")",
";",
"}",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"$",
"smileCron",
"->",
"setQueued",
"(",
"$",
"now",
")",
";",
"$",
"smileCron",
"->",
"setStarted",
"(",
"null",
")",
";",
"$",
"smileCron",
"->",
"setEnded",
"(",
"null",
")",
";",
"$",
"smileCron",
"->",
"setStatus",
"(",
"0",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"smileCron",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] |
Add cron to queued
@param string $alias cron alias
|
[
"Add",
"cron",
"to",
"queued"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Repository/SmileCronRepository.php#L41-L64
|
23,215
|
Smile-SA/CronBundle
|
Repository/SmileCronRepository.php
|
SmileCronRepository.run
|
public function run(SmileCron $smileCron)
{
$now = new \DateTime('now');
$smileCron->setStarted($now);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
php
|
public function run(SmileCron $smileCron)
{
$now = new \DateTime('now');
$smileCron->setStarted($now);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
[
"public",
"function",
"run",
"(",
"SmileCron",
"$",
"smileCron",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"$",
"smileCron",
"->",
"setStarted",
"(",
"$",
"now",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"smileCron",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] |
Run cron command
@param SmileCron $smileCron cron command
|
[
"Run",
"cron",
"command"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Repository/SmileCronRepository.php#L86-L92
|
23,216
|
Smile-SA/CronBundle
|
Repository/SmileCronRepository.php
|
SmileCronRepository.end
|
public function end(SmileCron $smileCron, $status = 0)
{
$now = new \DateTime('now');
$smileCron->setEnded($now);
$smileCron->setStatus($status);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
php
|
public function end(SmileCron $smileCron, $status = 0)
{
$now = new \DateTime('now');
$smileCron->setEnded($now);
$smileCron->setStatus($status);
$this->getEntityManager()->persist($smileCron);
$this->getEntityManager()->flush();
}
|
[
"public",
"function",
"end",
"(",
"SmileCron",
"$",
"smileCron",
",",
"$",
"status",
"=",
"0",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"'now'",
")",
";",
"$",
"smileCron",
"->",
"setEnded",
"(",
"$",
"now",
")",
";",
"$",
"smileCron",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"persist",
"(",
"$",
"smileCron",
")",
";",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}"
] |
End cron command
@param SmileCron $smileCron cron command
@param int $status cron command status
|
[
"End",
"cron",
"command"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Repository/SmileCronRepository.php#L100-L107
|
23,217
|
Innmind/neo4j-dbal
|
src/Transport/Http.php
|
Http.isSuccessful
|
private function isSuccessful(Response $response): bool
{
if ($response->statusCode()->value() !== 200) {
return false;
}
$json = Json::decode((string) $response->body());
return count($json['errors']) === 0;
}
|
php
|
private function isSuccessful(Response $response): bool
{
if ($response->statusCode()->value() !== 200) {
return false;
}
$json = Json::decode((string) $response->body());
return count($json['errors']) === 0;
}
|
[
"private",
"function",
"isSuccessful",
"(",
"Response",
"$",
"response",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"response",
"->",
"statusCode",
"(",
")",
"->",
"value",
"(",
")",
"!==",
"200",
")",
"{",
"return",
"false",
";",
"}",
"$",
"json",
"=",
"Json",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"body",
"(",
")",
")",
";",
"return",
"count",
"(",
"$",
"json",
"[",
"'errors'",
"]",
")",
"===",
"0",
";",
"}"
] |
Check if the response is successful
@param Response $response
@return bool
|
[
"Check",
"if",
"the",
"response",
"is",
"successful"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Transport/Http.php#L94-L103
|
23,218
|
FriendsOfApi/phraseapp
|
src/Api/Locale.php
|
Locale.download
|
public function download(string $projectKey, string $localeId, string $ext, array $params = [])
{
$params['file_format'] = $ext;
$response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/download', $projectKey, $localeId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200) {
$this->handleErrors($response);
}
return (string) $response->getBody();
}
|
php
|
public function download(string $projectKey, string $localeId, string $ext, array $params = [])
{
$params['file_format'] = $ext;
$response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/download', $projectKey, $localeId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200) {
$this->handleErrors($response);
}
return (string) $response->getBody();
}
|
[
"public",
"function",
"download",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"localeId",
",",
"string",
"$",
"ext",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'file_format'",
"]",
"=",
"$",
"ext",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpGet",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/locales/%s/download'",
",",
"$",
"projectKey",
",",
"$",
"localeId",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
] |
Download a locale.
@param string $projectKey
@param string $localeId
@param string $ext
@param array $params
@throws Exception
@return string|ResponseInterface
|
[
"Download",
"a",
"locale",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Locale.php#L32-L47
|
23,219
|
ekuiter/feature-php
|
FeaturePhp/Generator/CopyGenerator.php
|
CopyGenerator.processFileSpecification
|
protected function processFileSpecification($artifact, $fileSpecification) {
$this->files[] = fphp\File\StoredFile::fromSpecification($fileSpecification);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"file", $artifact, $fileSpecification->getSourcePlace(), $fileSpecification->getTargetPlace());
$this->logFile->log($artifact, "added file \"{$fileSpecification->getTarget()}\"");
}
|
php
|
protected function processFileSpecification($artifact, $fileSpecification) {
$this->files[] = fphp\File\StoredFile::fromSpecification($fileSpecification);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"file", $artifact, $fileSpecification->getSourcePlace(), $fileSpecification->getTargetPlace());
$this->logFile->log($artifact, "added file \"{$fileSpecification->getTarget()}\"");
}
|
[
"protected",
"function",
"processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
"{",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"fphp",
"\\",
"File",
"\\",
"StoredFile",
"::",
"fromSpecification",
"(",
"$",
"fileSpecification",
")",
";",
"$",
"this",
"->",
"tracingLinks",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"\"file\"",
",",
"$",
"artifact",
",",
"$",
"fileSpecification",
"->",
"getSourcePlace",
"(",
")",
",",
"$",
"fileSpecification",
"->",
"getTargetPlace",
"(",
")",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"$",
"artifact",
",",
"\"added file \\\"{$fileSpecification->getTarget()}\\\"\"",
")",
";",
"}"
] |
Adds a stored file from a specification.
Considers globally excluded files. Only exact file names are supported.
@param \FeaturePhp\Artifact\Artifact $artifact
@param \FeaturePhp\Specification\FileSpecification $fileSpecification
|
[
"Adds",
"a",
"stored",
"file",
"from",
"a",
"specification",
".",
"Considers",
"globally",
"excluded",
"files",
".",
"Only",
"exact",
"file",
"names",
"are",
"supported",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/CopyGenerator.php#L34-L39
|
23,220
|
oroinc/OroLayoutComponent
|
LayoutRegistry.php
|
LayoutRegistry.addExtension
|
public function addExtension(ExtensionInterface $extension, $priority = 0)
{
$this->extensions[$priority][] = $extension;
$this->sorted = null;
$this->typeExtensions = [];
}
|
php
|
public function addExtension(ExtensionInterface $extension, $priority = 0)
{
$this->extensions[$priority][] = $extension;
$this->sorted = null;
$this->typeExtensions = [];
}
|
[
"public",
"function",
"addExtension",
"(",
"ExtensionInterface",
"$",
"extension",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"extensions",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"extension",
";",
"$",
"this",
"->",
"sorted",
"=",
"null",
";",
"$",
"this",
"->",
"typeExtensions",
"=",
"[",
"]",
";",
"}"
] |
Registers an layout extension.
@param ExtensionInterface $extension
@param int $priority
|
[
"Registers",
"an",
"layout",
"extension",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/LayoutRegistry.php#L204-L209
|
23,221
|
oroinc/OroLayoutComponent
|
LayoutRegistry.php
|
LayoutRegistry.getExtensions
|
protected function getExtensions()
{
if (null === $this->sorted) {
ksort($this->extensions);
$this->sorted = !empty($this->extensions)
? call_user_func_array('array_merge', $this->extensions)
: [];
}
return $this->sorted;
}
|
php
|
protected function getExtensions()
{
if (null === $this->sorted) {
ksort($this->extensions);
$this->sorted = !empty($this->extensions)
? call_user_func_array('array_merge', $this->extensions)
: [];
}
return $this->sorted;
}
|
[
"protected",
"function",
"getExtensions",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"sorted",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"extensions",
")",
";",
"$",
"this",
"->",
"sorted",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"extensions",
")",
"?",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"this",
"->",
"extensions",
")",
":",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"sorted",
";",
"}"
] |
Returns all registered extensions sorted by priority.
@return ExtensionInterface[]
|
[
"Returns",
"all",
"registered",
"extensions",
"sorted",
"by",
"priority",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/LayoutRegistry.php#L216-L226
|
23,222
|
ekuiter/feature-php
|
FeaturePhp/Helper/_String.php
|
_String.getMaxLength
|
public static function getMaxLength($array, $key) {
$maxLen = 0;
foreach ($array as $element) {
$str = call_user_func(array($element, $key));
$maxLen = strlen($str) > $maxLen ? strlen($str) : $maxLen;
}
return $maxLen;
}
|
php
|
public static function getMaxLength($array, $key) {
$maxLen = 0;
foreach ($array as $element) {
$str = call_user_func(array($element, $key));
$maxLen = strlen($str) > $maxLen ? strlen($str) : $maxLen;
}
return $maxLen;
}
|
[
"public",
"static",
"function",
"getMaxLength",
"(",
"$",
"array",
",",
"$",
"key",
")",
"{",
"$",
"maxLen",
"=",
"0",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"element",
")",
"{",
"$",
"str",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"element",
",",
"$",
"key",
")",
")",
";",
"$",
"maxLen",
"=",
"strlen",
"(",
"$",
"str",
")",
">",
"$",
"maxLen",
"?",
"strlen",
"(",
"$",
"str",
")",
":",
"$",
"maxLen",
";",
"}",
"return",
"$",
"maxLen",
";",
"}"
] |
Returns the maximum member length of an array of objects.
@param array $array
@param callable $key
@return int
|
[
"Returns",
"the",
"maximum",
"member",
"length",
"of",
"an",
"array",
"of",
"objects",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Helper/_String.php#L45-L52
|
23,223
|
qlake/framework
|
src/Qlake/Config/Config.php
|
Config.aliases
|
public function aliases(array $aliases = null)
{
if (is_null($aliases))
{
return $this->aliases;
}
else
{
$this->aliases = array_merge($this->aliases, $aliases);
}
}
|
php
|
public function aliases(array $aliases = null)
{
if (is_null($aliases))
{
return $this->aliases;
}
else
{
$this->aliases = array_merge($this->aliases, $aliases);
}
}
|
[
"public",
"function",
"aliases",
"(",
"array",
"$",
"aliases",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"aliases",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliases",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aliases",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"aliases",
",",
"$",
"aliases",
")",
";",
"}",
"}"
] |
Set or get config aliases
@param array $aliases
@return array|null
|
[
"Set",
"or",
"get",
"config",
"aliases"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Config/Config.php#L48-L58
|
23,224
|
qlake/framework
|
src/Qlake/Config/Config.php
|
Config.alias
|
public function alias($alias, $path = null)
{
if (is_null($path))
{
return $this->aliases[$alias] ?: null;
}
else
{
$this->aliases[$alias] = $path;
}
}
|
php
|
public function alias($alias, $path = null)
{
if (is_null($path))
{
return $this->aliases[$alias] ?: null;
}
else
{
$this->aliases[$alias] = $path;
}
}
|
[
"public",
"function",
"alias",
"(",
"$",
"alias",
",",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
"?",
":",
"null",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
"=",
"$",
"path",
";",
"}",
"}"
] |
Set or get a config alias
@param string $alias
@param string $path
@return string|null
|
[
"Set",
"or",
"get",
"a",
"config",
"alias"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Config/Config.php#L68-L78
|
23,225
|
qlake/framework
|
src/Qlake/Config/Config.php
|
Config.loadConfig
|
protected function loadConfig($alias, $configName)
{
if (isset($this->aliases[$alias]))
{
$aliasPath = $this->aliases[$alias];
}
else
{
throw new ClearException("Config Alias [$alias] Not Found.", 4);
}
$file = $aliasPath . $configName . '.php';
if (is_file($file))
{
return $this->configs[$alias][$configName] = require $file;
}
throw new ClearException("The Config File [$file] Not Found.", 4);
}
|
php
|
protected function loadConfig($alias, $configName)
{
if (isset($this->aliases[$alias]))
{
$aliasPath = $this->aliases[$alias];
}
else
{
throw new ClearException("Config Alias [$alias] Not Found.", 4);
}
$file = $aliasPath . $configName . '.php';
if (is_file($file))
{
return $this->configs[$alias][$configName] = require $file;
}
throw new ClearException("The Config File [$file] Not Found.", 4);
}
|
[
"protected",
"function",
"loadConfig",
"(",
"$",
"alias",
",",
"$",
"configName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"$",
"aliasPath",
"=",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"ClearException",
"(",
"\"Config Alias [$alias] Not Found.\"",
",",
"4",
")",
";",
"}",
"$",
"file",
"=",
"$",
"aliasPath",
".",
"$",
"configName",
".",
"'.php'",
";",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"return",
"$",
"this",
"->",
"configs",
"[",
"$",
"alias",
"]",
"[",
"$",
"configName",
"]",
"=",
"require",
"$",
"file",
";",
"}",
"throw",
"new",
"ClearException",
"(",
"\"The Config File [$file] Not Found.\"",
",",
"4",
")",
";",
"}"
] |
Open and load configs from a file
@param string $alias
@param string $configName
@return array
|
[
"Open",
"and",
"load",
"configs",
"from",
"a",
"file"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Config/Config.php#L111-L130
|
23,226
|
qlake/framework
|
src/Qlake/Config/Config.php
|
Config.set
|
public function set($mixedKey, $value)
{
list($alias, $configName, $key) = $this->parseKey($mixedKey);
if (is_null($key))
{
$this->configs[$alias][$configName] = $value;
}
$this->configs[$alias][$configName][$key] = $value;
}
|
php
|
public function set($mixedKey, $value)
{
list($alias, $configName, $key) = $this->parseKey($mixedKey);
if (is_null($key))
{
$this->configs[$alias][$configName] = $value;
}
$this->configs[$alias][$configName][$key] = $value;
}
|
[
"public",
"function",
"set",
"(",
"$",
"mixedKey",
",",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"alias",
",",
"$",
"configName",
",",
"$",
"key",
")",
"=",
"$",
"this",
"->",
"parseKey",
"(",
"$",
"mixedKey",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"configs",
"[",
"$",
"alias",
"]",
"[",
"$",
"configName",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"configs",
"[",
"$",
"alias",
"]",
"[",
"$",
"configName",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Set a config
@param string $mixedKey May be a key or a config file name
@param mixed $value
@return array|mixed
|
[
"Set",
"a",
"config"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Config/Config.php#L160-L170
|
23,227
|
qlake/framework
|
src/Qlake/Config/Config.php
|
Config.parseKey
|
protected function parseKey($mixedKey)
{
if (preg_match('/^((?P<alias>[\w]+)::)?(?P<name>\w+)(\.(?P<key>\w+))?$/', $mixedKey, $matches) !==1)
{
throw new ClearException("Invalid Config Variable Name. Name Must Be Like [alias::name.key] Or [name.key].", 4);
}
$alias = $matches['alias'];
$name = $matches['name'];
$key = $matches['key'] ?: null;
return [$alias ?: 'default', $name, $key];
}
|
php
|
protected function parseKey($mixedKey)
{
if (preg_match('/^((?P<alias>[\w]+)::)?(?P<name>\w+)(\.(?P<key>\w+))?$/', $mixedKey, $matches) !==1)
{
throw new ClearException("Invalid Config Variable Name. Name Must Be Like [alias::name.key] Or [name.key].", 4);
}
$alias = $matches['alias'];
$name = $matches['name'];
$key = $matches['key'] ?: null;
return [$alias ?: 'default', $name, $key];
}
|
[
"protected",
"function",
"parseKey",
"(",
"$",
"mixedKey",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^((?P<alias>[\\w]+)::)?(?P<name>\\w+)(\\.(?P<key>\\w+))?$/'",
",",
"$",
"mixedKey",
",",
"$",
"matches",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"ClearException",
"(",
"\"Invalid Config Variable Name. Name Must Be Like [alias::name.key] Or [name.key].\"",
",",
"4",
")",
";",
"}",
"$",
"alias",
"=",
"$",
"matches",
"[",
"'alias'",
"]",
";",
"$",
"name",
"=",
"$",
"matches",
"[",
"'name'",
"]",
";",
"$",
"key",
"=",
"$",
"matches",
"[",
"'key'",
"]",
"?",
":",
"null",
";",
"return",
"[",
"$",
"alias",
"?",
":",
"'default'",
",",
"$",
"name",
",",
"$",
"key",
"]",
";",
"}"
] |
Parse requested mixed-key and split alias, name and key
@param string $mixedKey
@return array An array like [alias, name, key]
|
[
"Parse",
"requested",
"mixed",
"-",
"key",
"and",
"split",
"alias",
"name",
"and",
"key"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Config/Config.php#L179-L191
|
23,228
|
42mate/towel
|
src/Towel/BaseApp.php
|
BaseApp.db
|
public function db($database = null)
{
if (empty($database)) {
$database = $this->database;
}
return $this->silex['dbs'][$database];
}
|
php
|
public function db($database = null)
{
if (empty($database)) {
$database = $this->database;
}
return $this->silex['dbs'][$database];
}
|
[
"public",
"function",
"db",
"(",
"$",
"database",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"database",
")",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"database",
";",
"}",
"return",
"$",
"this",
"->",
"silex",
"[",
"'dbs'",
"]",
"[",
"$",
"database",
"]",
";",
"}"
] |
Gets dbal engine.
@param string $database : Database to use, check config to see available sources.
default is the default source.
@return \Doctrine\DBAL\Connection
|
[
"Gets",
"dbal",
"engine",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/BaseApp.php#L55-L61
|
23,229
|
42mate/towel
|
src/Towel/BaseApp.php
|
BaseApp.getCurrentUser
|
public function getCurrentUser()
{
if (Towel::isCli()) {
return false; //Cli is not logged.
}
$userRecord = $this->session()->get('user', false);
if (!$userRecord) {
return false;
}
$userModel = $this->getInstance('user_model');
$userModel->setRecord($userRecord);
return $userModel;
}
|
php
|
public function getCurrentUser()
{
if (Towel::isCli()) {
return false; //Cli is not logged.
}
$userRecord = $this->session()->get('user', false);
if (!$userRecord) {
return false;
}
$userModel = $this->getInstance('user_model');
$userModel->setRecord($userRecord);
return $userModel;
}
|
[
"public",
"function",
"getCurrentUser",
"(",
")",
"{",
"if",
"(",
"Towel",
"::",
"isCli",
"(",
")",
")",
"{",
"return",
"false",
";",
"//Cli is not logged.",
"}",
"$",
"userRecord",
"=",
"$",
"this",
"->",
"session",
"(",
")",
"->",
"get",
"(",
"'user'",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"userRecord",
")",
"{",
"return",
"false",
";",
"}",
"$",
"userModel",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"'user_model'",
")",
";",
"$",
"userModel",
"->",
"setRecord",
"(",
"$",
"userRecord",
")",
";",
"return",
"$",
"userModel",
";",
"}"
] |
Gets the current user or false if is not authenticated.
@returns \Towel\Model\BaseModel
|
[
"Gets",
"the",
"current",
"user",
"or",
"false",
"if",
"is",
"not",
"authenticated",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/BaseApp.php#L97-L112
|
23,230
|
42mate/towel
|
src/Towel/BaseApp.php
|
BaseApp.sendMail
|
public function sendMail($to, $subject = '', $message = '', $headers = '')
{
if (empty($headers)) {
$headers = 'From: ' . APP_SYS_EMAIL;
}
mail($to, $subject, $message, $headers);
}
|
php
|
public function sendMail($to, $subject = '', $message = '', $headers = '')
{
if (empty($headers)) {
$headers = 'From: ' . APP_SYS_EMAIL;
}
mail($to, $subject, $message, $headers);
}
|
[
"public",
"function",
"sendMail",
"(",
"$",
"to",
",",
"$",
"subject",
"=",
"''",
",",
"$",
"message",
"=",
"''",
",",
"$",
"headers",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"=",
"'From: '",
".",
"APP_SYS_EMAIL",
";",
"}",
"mail",
"(",
"$",
"to",
",",
"$",
"subject",
",",
"$",
"message",
",",
"$",
"headers",
")",
";",
"}"
] |
Sends an Email.
@param $to
@param string $subject
@param string $message
@param string $headers
|
[
"Sends",
"an",
"Email",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/BaseApp.php#L154-L160
|
23,231
|
42mate/towel
|
src/Towel/BaseApp.php
|
BaseApp.url
|
public function url($route, $parameters = array())
{
return $this->silex['url_generator']->generate($route, $parameters, \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL);
}
|
php
|
public function url($route, $parameters = array())
{
return $this->silex['url_generator']->generate($route, $parameters, \Symfony\Component\Routing\Generator\UrlGeneratorInterface::ABSOLUTE_URL);
}
|
[
"public",
"function",
"url",
"(",
"$",
"route",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"silex",
"[",
"'url_generator'",
"]",
"->",
"generate",
"(",
"$",
"route",
",",
"$",
"parameters",
",",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"Routing",
"\\",
"Generator",
"\\",
"UrlGeneratorInterface",
"::",
"ABSOLUTE_URL",
")",
";",
"}"
] |
Generates an absolute URL from the given parameters.
@param string $route The name of the route
@param mixed $parameters An array of parameters
@return string The generated URL
|
[
"Generates",
"an",
"absolute",
"URL",
"from",
"the",
"given",
"parameters",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/BaseApp.php#L183-L186
|
23,232
|
42mate/towel
|
src/Towel/BaseApp.php
|
BaseApp.getCache
|
public function getCache()
{
if (null === self::$cache) {
if (!empty($this->appConfig['cache']['driver'])) {
// Options definition.
if (empty($this->appConfig['cache']['options'])) {
$options = array();
} else {
$options = $this->appConfig['cache']['options'];
}
// Driver definition.
if ('memcached' !== $this->appConfig['cache']['driver']) {
$className = $this->appConfig['cache']['driver'];
} else {
$className = '\Towel\Cache\TowelMemcached';
}
// Driver instantiation
$cacheDriver = new $className();
$cacheDriver->setOptions($options);
}
self::$cache = new TowelCache($cacheDriver);
}
return self::$cache;
}
|
php
|
public function getCache()
{
if (null === self::$cache) {
if (!empty($this->appConfig['cache']['driver'])) {
// Options definition.
if (empty($this->appConfig['cache']['options'])) {
$options = array();
} else {
$options = $this->appConfig['cache']['options'];
}
// Driver definition.
if ('memcached' !== $this->appConfig['cache']['driver']) {
$className = $this->appConfig['cache']['driver'];
} else {
$className = '\Towel\Cache\TowelMemcached';
}
// Driver instantiation
$cacheDriver = new $className();
$cacheDriver->setOptions($options);
}
self::$cache = new TowelCache($cacheDriver);
}
return self::$cache;
}
|
[
"public",
"function",
"getCache",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"cache",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"appConfig",
"[",
"'cache'",
"]",
"[",
"'driver'",
"]",
")",
")",
"{",
"// Options definition.",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"appConfig",
"[",
"'cache'",
"]",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"appConfig",
"[",
"'cache'",
"]",
"[",
"'options'",
"]",
";",
"}",
"// Driver definition.",
"if",
"(",
"'memcached'",
"!==",
"$",
"this",
"->",
"appConfig",
"[",
"'cache'",
"]",
"[",
"'driver'",
"]",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"appConfig",
"[",
"'cache'",
"]",
"[",
"'driver'",
"]",
";",
"}",
"else",
"{",
"$",
"className",
"=",
"'\\Towel\\Cache\\TowelMemcached'",
";",
"}",
"// Driver instantiation",
"$",
"cacheDriver",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"cacheDriver",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"}",
"self",
"::",
"$",
"cache",
"=",
"new",
"TowelCache",
"(",
"$",
"cacheDriver",
")",
";",
"}",
"return",
"self",
"::",
"$",
"cache",
";",
"}"
] |
Instantiate Cache driver
@return \Towel\Cache\CacheInterface
|
[
"Instantiate",
"Cache",
"driver"
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/BaseApp.php#L192-L219
|
23,233
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.createErrorEntry
|
protected function createErrorEntry($error, $parse_errors)
{
$marker_obj = new \DOMElement(strtolower($error->getSeverity()));
$parse_errors->appendChild($marker_obj);
$message = ($this->getTranslator())
? vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext())
: $error->getCode();
$marker_obj->appendChild(new \DOMText($message));
$marker_obj->setAttribute('line', $error->getLine());
$marker_obj->setAttribute('code', $error->getCode());
}
|
php
|
protected function createErrorEntry($error, $parse_errors)
{
$marker_obj = new \DOMElement(strtolower($error->getSeverity()));
$parse_errors->appendChild($marker_obj);
$message = ($this->getTranslator())
? vsprintf($this->getTranslator()->translate($error->getCode()), $error->getContext())
: $error->getCode();
$marker_obj->appendChild(new \DOMText($message));
$marker_obj->setAttribute('line', $error->getLine());
$marker_obj->setAttribute('code', $error->getCode());
}
|
[
"protected",
"function",
"createErrorEntry",
"(",
"$",
"error",
",",
"$",
"parse_errors",
")",
"{",
"$",
"marker_obj",
"=",
"new",
"\\",
"DOMElement",
"(",
"strtolower",
"(",
"$",
"error",
"->",
"getSeverity",
"(",
")",
")",
")",
";",
"$",
"parse_errors",
"->",
"appendChild",
"(",
"$",
"marker_obj",
")",
";",
"$",
"message",
"=",
"(",
"$",
"this",
"->",
"getTranslator",
"(",
")",
")",
"?",
"vsprintf",
"(",
"$",
"this",
"->",
"getTranslator",
"(",
")",
"->",
"translate",
"(",
"$",
"error",
"->",
"getCode",
"(",
")",
")",
",",
"$",
"error",
"->",
"getContext",
"(",
")",
")",
":",
"$",
"error",
"->",
"getCode",
"(",
")",
";",
"$",
"marker_obj",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMText",
"(",
"$",
"message",
")",
")",
";",
"$",
"marker_obj",
"->",
"setAttribute",
"(",
"'line'",
",",
"$",
"error",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"marker_obj",
"->",
"setAttribute",
"(",
"'code'",
",",
"$",
"error",
"->",
"getCode",
"(",
")",
")",
";",
"}"
] |
Creates an entry in the ParseErrors collection of a file for a given error.
@param Error $error
@param \DOMElement $parse_errors
@return void
|
[
"Creates",
"an",
"entry",
"in",
"the",
"ParseErrors",
"collection",
"of",
"a",
"file",
"for",
"a",
"given",
"error",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L253-L265
|
23,234
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.buildFunction
|
public function buildFunction(\DOMElement $parent, FunctionDescriptor $function, \DOMElement $child = null)
{
if (!$child) {
$child = new \DOMElement('function');
$parent->appendChild($child);
}
$namespace = $function->getNamespace()
? $function->getNamespace()
: $parent->getAttribute('namespace');
$child->setAttribute('namespace', ltrim($namespace, '\\'));
$child->setAttribute('line', $function->getLine());
$child->appendChild(new \DOMElement('name', $function->getName()));
$child->appendChild(new \DOMElement('full_name', $function->getFullyQualifiedStructuralElementName()));
$this->docBlockConverter->convert($child, $function);
foreach ($function->getArguments() as $argument) {
$this->argumentConverter->convert($child, $argument);
}
}
|
php
|
public function buildFunction(\DOMElement $parent, FunctionDescriptor $function, \DOMElement $child = null)
{
if (!$child) {
$child = new \DOMElement('function');
$parent->appendChild($child);
}
$namespace = $function->getNamespace()
? $function->getNamespace()
: $parent->getAttribute('namespace');
$child->setAttribute('namespace', ltrim($namespace, '\\'));
$child->setAttribute('line', $function->getLine());
$child->appendChild(new \DOMElement('name', $function->getName()));
$child->appendChild(new \DOMElement('full_name', $function->getFullyQualifiedStructuralElementName()));
$this->docBlockConverter->convert($child, $function);
foreach ($function->getArguments() as $argument) {
$this->argumentConverter->convert($child, $argument);
}
}
|
[
"public",
"function",
"buildFunction",
"(",
"\\",
"DOMElement",
"$",
"parent",
",",
"FunctionDescriptor",
"$",
"function",
",",
"\\",
"DOMElement",
"$",
"child",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"child",
")",
"{",
"$",
"child",
"=",
"new",
"\\",
"DOMElement",
"(",
"'function'",
")",
";",
"$",
"parent",
"->",
"appendChild",
"(",
"$",
"child",
")",
";",
"}",
"$",
"namespace",
"=",
"$",
"function",
"->",
"getNamespace",
"(",
")",
"?",
"$",
"function",
"->",
"getNamespace",
"(",
")",
":",
"$",
"parent",
"->",
"getAttribute",
"(",
"'namespace'",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'namespace'",
",",
"ltrim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
")",
";",
"$",
"child",
"->",
"setAttribute",
"(",
"'line'",
",",
"$",
"function",
"->",
"getLine",
"(",
")",
")",
";",
"$",
"child",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMElement",
"(",
"'name'",
",",
"$",
"function",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"child",
"->",
"appendChild",
"(",
"new",
"\\",
"DOMElement",
"(",
"'full_name'",
",",
"$",
"function",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"docBlockConverter",
"->",
"convert",
"(",
"$",
"child",
",",
"$",
"function",
")",
";",
"foreach",
"(",
"$",
"function",
"->",
"getArguments",
"(",
")",
"as",
"$",
"argument",
")",
"{",
"$",
"this",
"->",
"argumentConverter",
"->",
"convert",
"(",
"$",
"child",
",",
"$",
"argument",
")",
";",
"}",
"}"
] |
Export this function definition to the given parent DOMElement.
@param \DOMElement $parent Element to augment.
@param FunctionDescriptor $function Element to export.
@param \DOMElement $child if supplied this element will be augmented instead of freshly added.
@return void
|
[
"Export",
"this",
"function",
"definition",
"to",
"the",
"given",
"parent",
"DOMElement",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L289-L310
|
23,235
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.buildPackageTree
|
protected function buildPackageTree(\DOMDocument $dom)
{
$xpath = new \DOMXPath($dom);
$packages = array('global' => true);
$qry = $xpath->query('//@package');
for ($i = 0; $i < $qry->length; $i++) {
if (isset($packages[$qry->item($i)->nodeValue])) {
continue;
}
$packages[$qry->item($i)->nodeValue] = true;
}
$packages = $this->generateNamespaceTree(array_keys($packages));
$this->generateNamespaceElements($packages, $dom->documentElement, 'package');
}
|
php
|
protected function buildPackageTree(\DOMDocument $dom)
{
$xpath = new \DOMXPath($dom);
$packages = array('global' => true);
$qry = $xpath->query('//@package');
for ($i = 0; $i < $qry->length; $i++) {
if (isset($packages[$qry->item($i)->nodeValue])) {
continue;
}
$packages[$qry->item($i)->nodeValue] = true;
}
$packages = $this->generateNamespaceTree(array_keys($packages));
$this->generateNamespaceElements($packages, $dom->documentElement, 'package');
}
|
[
"protected",
"function",
"buildPackageTree",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"dom",
")",
";",
"$",
"packages",
"=",
"array",
"(",
"'global'",
"=>",
"true",
")",
";",
"$",
"qry",
"=",
"$",
"xpath",
"->",
"query",
"(",
"'//@package'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"qry",
"->",
"length",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"packages",
"[",
"$",
"qry",
"->",
"item",
"(",
"$",
"i",
")",
"->",
"nodeValue",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"packages",
"[",
"$",
"qry",
"->",
"item",
"(",
"$",
"i",
")",
"->",
"nodeValue",
"]",
"=",
"true",
";",
"}",
"$",
"packages",
"=",
"$",
"this",
"->",
"generateNamespaceTree",
"(",
"array_keys",
"(",
"$",
"packages",
")",
")",
";",
"$",
"this",
"->",
"generateNamespaceElements",
"(",
"$",
"packages",
",",
"$",
"dom",
"->",
"documentElement",
",",
"'package'",
")",
";",
"}"
] |
Collects all packages and subpackages, and adds a new section in the
DOM to provide an overview.
@param \DOMDocument $dom Packages are extracted and a summary inserted
in this object.
@return void
|
[
"Collects",
"all",
"packages",
"and",
"subpackages",
"and",
"adds",
"a",
"new",
"section",
"in",
"the",
"DOM",
"to",
"provide",
"an",
"overview",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L474-L489
|
23,236
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.buildNamespaceTree
|
protected function buildNamespaceTree(\DOMDocument $dom)
{
$xpath = new \DOMXPath($dom);
$namespaces = array();
$qry = $xpath->query('//@namespace');
for ($i = 0; $i < $qry->length; $i++) {
if (isset($namespaces[$qry->item($i)->nodeValue])) {
continue;
}
$namespaces[$qry->item($i)->nodeValue] = true;
}
$namespaces = $this->generateNamespaceTree(array_keys($namespaces));
$this->generateNamespaceElements($namespaces, $dom->documentElement);
}
|
php
|
protected function buildNamespaceTree(\DOMDocument $dom)
{
$xpath = new \DOMXPath($dom);
$namespaces = array();
$qry = $xpath->query('//@namespace');
for ($i = 0; $i < $qry->length; $i++) {
if (isset($namespaces[$qry->item($i)->nodeValue])) {
continue;
}
$namespaces[$qry->item($i)->nodeValue] = true;
}
$namespaces = $this->generateNamespaceTree(array_keys($namespaces));
$this->generateNamespaceElements($namespaces, $dom->documentElement);
}
|
[
"protected",
"function",
"buildNamespaceTree",
"(",
"\\",
"DOMDocument",
"$",
"dom",
")",
"{",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"dom",
")",
";",
"$",
"namespaces",
"=",
"array",
"(",
")",
";",
"$",
"qry",
"=",
"$",
"xpath",
"->",
"query",
"(",
"'//@namespace'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"qry",
"->",
"length",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"namespaces",
"[",
"$",
"qry",
"->",
"item",
"(",
"$",
"i",
")",
"->",
"nodeValue",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"namespaces",
"[",
"$",
"qry",
"->",
"item",
"(",
"$",
"i",
")",
"->",
"nodeValue",
"]",
"=",
"true",
";",
"}",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"generateNamespaceTree",
"(",
"array_keys",
"(",
"$",
"namespaces",
")",
")",
";",
"$",
"this",
"->",
"generateNamespaceElements",
"(",
"$",
"namespaces",
",",
"$",
"dom",
"->",
"documentElement",
")",
";",
"}"
] |
Collects all namespaces and sub-namespaces, and adds a new section in
the DOM to provide an overview.
@param \DOMDocument $dom Namespaces are extracted and a summary inserted
in this object.
@return void
|
[
"Collects",
"all",
"namespaces",
"and",
"sub",
"-",
"namespaces",
"and",
"adds",
"a",
"new",
"section",
"in",
"the",
"DOM",
"to",
"provide",
"an",
"overview",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L500-L515
|
23,237
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.generateNamespaceTree
|
protected function generateNamespaceTree($namespaces)
{
sort($namespaces);
$result = array();
foreach ($namespaces as $namespace) {
if (!$namespace) {
$namespace = 'global';
}
$namespace_list = explode('\\', $namespace);
$node = &$result;
foreach ($namespace_list as $singular) {
if (!isset($node[$singular])) {
$node[$singular] = array();
}
$node = &$node[$singular];
}
}
return $result;
}
|
php
|
protected function generateNamespaceTree($namespaces)
{
sort($namespaces);
$result = array();
foreach ($namespaces as $namespace) {
if (!$namespace) {
$namespace = 'global';
}
$namespace_list = explode('\\', $namespace);
$node = &$result;
foreach ($namespace_list as $singular) {
if (!isset($node[$singular])) {
$node[$singular] = array();
}
$node = &$node[$singular];
}
}
return $result;
}
|
[
"protected",
"function",
"generateNamespaceTree",
"(",
"$",
"namespaces",
")",
"{",
"sort",
"(",
"$",
"namespaces",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"if",
"(",
"!",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"'global'",
";",
"}",
"$",
"namespace_list",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"namespace",
")",
";",
"$",
"node",
"=",
"&",
"$",
"result",
";",
"foreach",
"(",
"$",
"namespace_list",
"as",
"$",
"singular",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"node",
"[",
"$",
"singular",
"]",
")",
")",
"{",
"$",
"node",
"[",
"$",
"singular",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"node",
"=",
"&",
"$",
"node",
"[",
"$",
"singular",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Generates a hierarchical array of namespaces with their singular name
from a single level list of namespaces with their full name.
@param array $namespaces the list of namespaces as retrieved from the xml.
@return array
|
[
"Generates",
"a",
"hierarchical",
"array",
"of",
"namespaces",
"with",
"their",
"singular",
"name",
"from",
"a",
"single",
"level",
"list",
"of",
"namespaces",
"with",
"their",
"full",
"name",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L568-L591
|
23,238
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php
|
Xml.generateNamespaceElements
|
protected function generateNamespaceElements($namespaces, $parent_element, $node_name = 'namespace')
{
foreach ($namespaces as $name => $sub_namespaces) {
$node = new \DOMElement($node_name);
$parent_element->appendChild($node);
$node->setAttribute('name', $name);
$fullName = $parent_element->nodeName == $node_name
? $parent_element->getAttribute('full_name') . '\\' . $name
: $name;
$node->setAttribute('full_name', $fullName);
$this->generateNamespaceElements($sub_namespaces, $node, $node_name);
}
}
|
php
|
protected function generateNamespaceElements($namespaces, $parent_element, $node_name = 'namespace')
{
foreach ($namespaces as $name => $sub_namespaces) {
$node = new \DOMElement($node_name);
$parent_element->appendChild($node);
$node->setAttribute('name', $name);
$fullName = $parent_element->nodeName == $node_name
? $parent_element->getAttribute('full_name') . '\\' . $name
: $name;
$node->setAttribute('full_name', $fullName);
$this->generateNamespaceElements($sub_namespaces, $node, $node_name);
}
}
|
[
"protected",
"function",
"generateNamespaceElements",
"(",
"$",
"namespaces",
",",
"$",
"parent_element",
",",
"$",
"node_name",
"=",
"'namespace'",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"name",
"=>",
"$",
"sub_namespaces",
")",
"{",
"$",
"node",
"=",
"new",
"\\",
"DOMElement",
"(",
"$",
"node_name",
")",
";",
"$",
"parent_element",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"$",
"node",
"->",
"setAttribute",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"$",
"fullName",
"=",
"$",
"parent_element",
"->",
"nodeName",
"==",
"$",
"node_name",
"?",
"$",
"parent_element",
"->",
"getAttribute",
"(",
"'full_name'",
")",
".",
"'\\\\'",
".",
"$",
"name",
":",
"$",
"name",
";",
"$",
"node",
"->",
"setAttribute",
"(",
"'full_name'",
",",
"$",
"fullName",
")",
";",
"$",
"this",
"->",
"generateNamespaceElements",
"(",
"$",
"sub_namespaces",
",",
"$",
"node",
",",
"$",
"node_name",
")",
";",
"}",
"}"
] |
Recursive method to create a hierarchical set of nodes in the dom.
@param array[] $namespaces the list of namespaces to process.
@param \DOMElement $parent_element the node to receive the children of
the above list.
@param string $node_name the name of the summary element.
@return void
|
[
"Recursive",
"method",
"to",
"create",
"a",
"hierarchical",
"set",
"of",
"nodes",
"in",
"the",
"dom",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml.php#L603-L615
|
23,239
|
hametuha/wpametu
|
src/WPametu/Service/Recaptcha.php
|
Recaptcha.get_html
|
public function get_html($theme = 'light', $lang = 'en', $type = 'image'){
if( $this->enabled ){
// Option value
$option = [];
// Select theme
switch($theme){
case 'dark':
$option['theme'] = $theme;
break;
case 'red':
default:
$option['theme'] = 'light';
// Do nothing
break;
}
// Select image
switch( $type ){
case 'audio':
$option['type'] = $type;
break;
default:
$option['type'] = 'image';
break;
}
// Select language
switch($lang){
case 'ar':
case 'bg':
case 'ca':
case 'zh-CN':
case 'zh-TW':
case 'hr':
case 'cs':
case 'da':
case 'nl':
case 'en-GB':
case 'en':
case 'fil':
case 'fi':
case 'fr':
case 'fr-CA':
case 'de':
case 'de-AT':
case 'de-CH':
case 'el':
case 'iw':
case 'hi':
case 'hu':
case 'id':
case 'it':
case 'ja':
case 'ko':
case 'lv':
case 'lt':
case 'no':
case 'fa':
case 'pl':
case 'pt':
case 'pt-BR':
case 'pt-PT':
case 'ro':
case 'ru':
case 'sr':
case 'sk':
case 'sl':
case 'es':
case 'es-419':
case 'sv':
case 'th':
case 'tr':
case 'uk':
case 'vi':
$option['lang'] = $lang;
break;
default:
// Do nothing
$option['lang'] = 'en';
break;
}
/**
* wpametu_recaptcha_setting
*
* Filter option to set for reCaptcha
*
* @param array $option
* @return array
*/
$option = apply_filters('wpametu_recaptcha_setting', $option);
$script = '<script src="https://www.google.com/recaptcha/api.js?hl='.$option['lang'].'" async defer></script>';
$html = <<<HTML
<div class="g-recaptcha" data-sitekey="%s" data-theme="%s" data-type="%s"></div>
HTML;
return $script.sprintf($html, constant(self::PUBLIC_KEY), $option['theme'], $option['type']);
}else{
return false;
}
}
|
php
|
public function get_html($theme = 'light', $lang = 'en', $type = 'image'){
if( $this->enabled ){
// Option value
$option = [];
// Select theme
switch($theme){
case 'dark':
$option['theme'] = $theme;
break;
case 'red':
default:
$option['theme'] = 'light';
// Do nothing
break;
}
// Select image
switch( $type ){
case 'audio':
$option['type'] = $type;
break;
default:
$option['type'] = 'image';
break;
}
// Select language
switch($lang){
case 'ar':
case 'bg':
case 'ca':
case 'zh-CN':
case 'zh-TW':
case 'hr':
case 'cs':
case 'da':
case 'nl':
case 'en-GB':
case 'en':
case 'fil':
case 'fi':
case 'fr':
case 'fr-CA':
case 'de':
case 'de-AT':
case 'de-CH':
case 'el':
case 'iw':
case 'hi':
case 'hu':
case 'id':
case 'it':
case 'ja':
case 'ko':
case 'lv':
case 'lt':
case 'no':
case 'fa':
case 'pl':
case 'pt':
case 'pt-BR':
case 'pt-PT':
case 'ro':
case 'ru':
case 'sr':
case 'sk':
case 'sl':
case 'es':
case 'es-419':
case 'sv':
case 'th':
case 'tr':
case 'uk':
case 'vi':
$option['lang'] = $lang;
break;
default:
// Do nothing
$option['lang'] = 'en';
break;
}
/**
* wpametu_recaptcha_setting
*
* Filter option to set for reCaptcha
*
* @param array $option
* @return array
*/
$option = apply_filters('wpametu_recaptcha_setting', $option);
$script = '<script src="https://www.google.com/recaptcha/api.js?hl='.$option['lang'].'" async defer></script>';
$html = <<<HTML
<div class="g-recaptcha" data-sitekey="%s" data-theme="%s" data-type="%s"></div>
HTML;
return $script.sprintf($html, constant(self::PUBLIC_KEY), $option['theme'], $option['type']);
}else{
return false;
}
}
|
[
"public",
"function",
"get_html",
"(",
"$",
"theme",
"=",
"'light'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"type",
"=",
"'image'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"enabled",
")",
"{",
"// Option value",
"$",
"option",
"=",
"[",
"]",
";",
"// Select theme",
"switch",
"(",
"$",
"theme",
")",
"{",
"case",
"'dark'",
":",
"$",
"option",
"[",
"'theme'",
"]",
"=",
"$",
"theme",
";",
"break",
";",
"case",
"'red'",
":",
"default",
":",
"$",
"option",
"[",
"'theme'",
"]",
"=",
"'light'",
";",
"// Do nothing",
"break",
";",
"}",
"// Select image",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'audio'",
":",
"$",
"option",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"break",
";",
"default",
":",
"$",
"option",
"[",
"'type'",
"]",
"=",
"'image'",
";",
"break",
";",
"}",
"// Select language",
"switch",
"(",
"$",
"lang",
")",
"{",
"case",
"'ar'",
":",
"case",
"'bg'",
":",
"case",
"'ca'",
":",
"case",
"'zh-CN'",
":",
"case",
"'zh-TW'",
":",
"case",
"'hr'",
":",
"case",
"'cs'",
":",
"case",
"'da'",
":",
"case",
"'nl'",
":",
"case",
"'en-GB'",
":",
"case",
"'en'",
":",
"case",
"'fil'",
":",
"case",
"'fi'",
":",
"case",
"'fr'",
":",
"case",
"'fr-CA'",
":",
"case",
"'de'",
":",
"case",
"'de-AT'",
":",
"case",
"'de-CH'",
":",
"case",
"'el'",
":",
"case",
"'iw'",
":",
"case",
"'hi'",
":",
"case",
"'hu'",
":",
"case",
"'id'",
":",
"case",
"'it'",
":",
"case",
"'ja'",
":",
"case",
"'ko'",
":",
"case",
"'lv'",
":",
"case",
"'lt'",
":",
"case",
"'no'",
":",
"case",
"'fa'",
":",
"case",
"'pl'",
":",
"case",
"'pt'",
":",
"case",
"'pt-BR'",
":",
"case",
"'pt-PT'",
":",
"case",
"'ro'",
":",
"case",
"'ru'",
":",
"case",
"'sr'",
":",
"case",
"'sk'",
":",
"case",
"'sl'",
":",
"case",
"'es'",
":",
"case",
"'es-419'",
":",
"case",
"'sv'",
":",
"case",
"'th'",
":",
"case",
"'tr'",
":",
"case",
"'uk'",
":",
"case",
"'vi'",
":",
"$",
"option",
"[",
"'lang'",
"]",
"=",
"$",
"lang",
";",
"break",
";",
"default",
":",
"// Do nothing",
"$",
"option",
"[",
"'lang'",
"]",
"=",
"'en'",
";",
"break",
";",
"}",
"/**\n * wpametu_recaptcha_setting\n *\n * Filter option to set for reCaptcha\n *\n * @param array $option\n * @return array\n */",
"$",
"option",
"=",
"apply_filters",
"(",
"'wpametu_recaptcha_setting'",
",",
"$",
"option",
")",
";",
"$",
"script",
"=",
"'<script src=\"https://www.google.com/recaptcha/api.js?hl='",
".",
"$",
"option",
"[",
"'lang'",
"]",
".",
"'\" async defer></script>'",
";",
"$",
"html",
"=",
" <<<HTML\n<div class=\"g-recaptcha\" data-sitekey=\"%s\" data-theme=\"%s\" data-type=\"%s\"></div>\nHTML",
";",
"return",
"$",
"script",
".",
"sprintf",
"(",
"$",
"html",
",",
"constant",
"(",
"self",
"::",
"PUBLIC_KEY",
")",
",",
"$",
"option",
"[",
"'theme'",
"]",
",",
"$",
"option",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Return reCaptcha's HTML
@link https://developers.google.com/recaptcha/docs/language
@param string $theme light(default), dark
@param string $lang en(default), fr, nl, de, pt, ru, es, tr, ja and more.
@param string $type image(default) audio
@return string|false
|
[
"Return",
"reCaptcha",
"s",
"HTML"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Service/Recaptcha.php#L70-L167
|
23,240
|
Speicher210/monsum-api
|
src/Model/Subscription.php
|
Subscription.isRunning
|
public function isRunning()
{
$runningStatuses = [
self::SUBSCRIPTION_STATUS_ACTIVE,
self::SUBSCRIPTION_STATUS_TRIAL,
];
return in_array($this->getStatus(), $runningStatuses, true);
}
|
php
|
public function isRunning()
{
$runningStatuses = [
self::SUBSCRIPTION_STATUS_ACTIVE,
self::SUBSCRIPTION_STATUS_TRIAL,
];
return in_array($this->getStatus(), $runningStatuses, true);
}
|
[
"public",
"function",
"isRunning",
"(",
")",
"{",
"$",
"runningStatuses",
"=",
"[",
"self",
"::",
"SUBSCRIPTION_STATUS_ACTIVE",
",",
"self",
"::",
"SUBSCRIPTION_STATUS_TRIAL",
",",
"]",
";",
"return",
"in_array",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
",",
"$",
"runningStatuses",
",",
"true",
")",
";",
"}"
] |
Check if the current subscription is running.
@return boolean
|
[
"Check",
"if",
"the",
"current",
"subscription",
"is",
"running",
"."
] |
4611a048097de5d2b0efe9d4426779c783c0af4d
|
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Model/Subscription.php#L71-L79
|
23,241
|
CalderaWP/metaplate-core
|
src/helper_loader.php
|
helper_loader.add_helpers
|
private function add_helpers( $helpers ) {
foreach( $helpers as $helper ) {
$helper = $this->validate_helper_input( $helper );
if ( is_array( $helper ) ) {
$this->add_helper( $helper );
}
}
}
|
php
|
private function add_helpers( $helpers ) {
foreach( $helpers as $helper ) {
$helper = $this->validate_helper_input( $helper );
if ( is_array( $helper ) ) {
$this->add_helper( $helper );
}
}
}
|
[
"private",
"function",
"add_helpers",
"(",
"$",
"helpers",
")",
"{",
"foreach",
"(",
"$",
"helpers",
"as",
"$",
"helper",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"validate_helper_input",
"(",
"$",
"helper",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"helper",
")",
")",
"{",
"$",
"this",
"->",
"add_helper",
"(",
"$",
"helper",
")",
";",
"}",
"}",
"}"
] |
Add the helpers to the Handlebars instance, if validation passes.
@param array $helpers Array of helpers to add
|
[
"Add",
"the",
"helpers",
"to",
"the",
"Handlebars",
"instance",
"if",
"validation",
"passes",
"."
] |
15ede9c4250ab23112a32f8e45d5393f8278bbb8
|
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/helper_loader.php#L58-L67
|
23,242
|
CalderaWP/metaplate-core
|
src/helper_loader.php
|
helper_loader.validate_helper_input
|
private function validate_helper_input( $helper ) {
if ( ! is_array( $helper ) || empty( $helper ) ) {
return false;
}
if ( ! isset( $helper[ 'name' ] ) || ! isset( $helper[ 'class' ] ) ) {
return false;
}
//if not set, set callback name to "helper"
if ( ! isset( $helper[ 'callback' ] ) ) {
$helper[ 'callback' ] = 'helper';
}
return $helper;
}
|
php
|
private function validate_helper_input( $helper ) {
if ( ! is_array( $helper ) || empty( $helper ) ) {
return false;
}
if ( ! isset( $helper[ 'name' ] ) || ! isset( $helper[ 'class' ] ) ) {
return false;
}
//if not set, set callback name to "helper"
if ( ! isset( $helper[ 'callback' ] ) ) {
$helper[ 'callback' ] = 'helper';
}
return $helper;
}
|
[
"private",
"function",
"validate_helper_input",
"(",
"$",
"helper",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"helper",
")",
"||",
"empty",
"(",
"$",
"helper",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"helper",
"[",
"'name'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"helper",
"[",
"'class'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"//if not set, set callback name to \"helper\"",
"if",
"(",
"!",
"isset",
"(",
"$",
"helper",
"[",
"'callback'",
"]",
")",
")",
"{",
"$",
"helper",
"[",
"'callback'",
"]",
"=",
"'helper'",
";",
"}",
"return",
"$",
"helper",
";",
"}"
] |
Make sure each helper passed in is valid.
@todo ensure helper class/callback are callable. Preferably, without creating object of the class.
@param array $helper Array to add helper with.
@return bool|array Returns the array if valid, false if not.
|
[
"Make",
"sure",
"each",
"helper",
"passed",
"in",
"is",
"valid",
"."
] |
15ede9c4250ab23112a32f8e45d5393f8278bbb8
|
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/helper_loader.php#L93-L109
|
23,243
|
CalderaWP/metaplate-core
|
src/pods/access.php
|
access.offsetGet
|
public function offsetGet($offset) {
if ( $this->offsetExists( $offset ) ) {
return parent::offsetGet( $offset );
} else {
if( 'id' == $offset || 'ID' == $offset ) {
$_value = $this->pod->id();
}else{
$_value = $this->pod->field( $offset );
}
if( $_value ) {
parent::offsetSet( $offset, $_value );
return $_value;
}
}
}
|
php
|
public function offsetGet($offset) {
if ( $this->offsetExists( $offset ) ) {
return parent::offsetGet( $offset );
} else {
if( 'id' == $offset || 'ID' == $offset ) {
$_value = $this->pod->id();
}else{
$_value = $this->pod->field( $offset );
}
if( $_value ) {
parent::offsetSet( $offset, $_value );
return $_value;
}
}
}
|
[
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"return",
"parent",
"::",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"}",
"else",
"{",
"if",
"(",
"'id'",
"==",
"$",
"offset",
"||",
"'ID'",
"==",
"$",
"offset",
")",
"{",
"$",
"_value",
"=",
"$",
"this",
"->",
"pod",
"->",
"id",
"(",
")",
";",
"}",
"else",
"{",
"$",
"_value",
"=",
"$",
"this",
"->",
"pod",
"->",
"field",
"(",
"$",
"offset",
")",
";",
"}",
"if",
"(",
"$",
"_value",
")",
"{",
"parent",
"::",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"_value",
")",
";",
"return",
"$",
"_value",
";",
"}",
"}",
"}"
] |
Get an offset if already set or traverse Pod and then set plus reutrn.
@since 0.1.0
@param mixed $offset Offset to get
@return mixed
|
[
"Get",
"an",
"offset",
"if",
"already",
"set",
"or",
"traverse",
"Pod",
"and",
"then",
"set",
"plus",
"reutrn",
"."
] |
15ede9c4250ab23112a32f8e45d5393f8278bbb8
|
https://github.com/CalderaWP/metaplate-core/blob/15ede9c4250ab23112a32f8e45d5393f8278bbb8/src/pods/access.php#L66-L81
|
23,244
|
ekuiter/feature-php
|
FeaturePhp/Generator/CollaborationGenerator.php
|
CollaborationGenerator.processFileSpecification
|
protected function processFileSpecification($artifact, $fileSpecification) {
$collaboration = fphp\Collaboration\Collaboration::findByArtifact($this->collaborations, $artifact);
if (!$collaboration)
$this->collaborations[] = $collaboration = new fphp\Collaboration\Collaboration($artifact);
$collaboration->addRoleFromFileSpecification($fileSpecification);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"role", $artifact, $fileSpecification->getSourcePlace(), $fileSpecification->getTargetPlace());
$this->logFile->log($artifact, "using role at \"{$fileSpecification->getTarget()}\"");
}
|
php
|
protected function processFileSpecification($artifact, $fileSpecification) {
$collaboration = fphp\Collaboration\Collaboration::findByArtifact($this->collaborations, $artifact);
if (!$collaboration)
$this->collaborations[] = $collaboration = new fphp\Collaboration\Collaboration($artifact);
$collaboration->addRoleFromFileSpecification($fileSpecification);
$this->tracingLinks[] = new fphp\Artifact\TracingLink(
"role", $artifact, $fileSpecification->getSourcePlace(), $fileSpecification->getTargetPlace());
$this->logFile->log($artifact, "using role at \"{$fileSpecification->getTarget()}\"");
}
|
[
"protected",
"function",
"processFileSpecification",
"(",
"$",
"artifact",
",",
"$",
"fileSpecification",
")",
"{",
"$",
"collaboration",
"=",
"fphp",
"\\",
"Collaboration",
"\\",
"Collaboration",
"::",
"findByArtifact",
"(",
"$",
"this",
"->",
"collaborations",
",",
"$",
"artifact",
")",
";",
"if",
"(",
"!",
"$",
"collaboration",
")",
"$",
"this",
"->",
"collaborations",
"[",
"]",
"=",
"$",
"collaboration",
"=",
"new",
"fphp",
"\\",
"Collaboration",
"\\",
"Collaboration",
"(",
"$",
"artifact",
")",
";",
"$",
"collaboration",
"->",
"addRoleFromFileSpecification",
"(",
"$",
"fileSpecification",
")",
";",
"$",
"this",
"->",
"tracingLinks",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"\"role\"",
",",
"$",
"artifact",
",",
"$",
"fileSpecification",
"->",
"getSourcePlace",
"(",
")",
",",
"$",
"fileSpecification",
"->",
"getTargetPlace",
"(",
")",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"$",
"artifact",
",",
"\"using role at \\\"{$fileSpecification->getTarget()}\\\"\"",
")",
";",
"}"
] |
Adds a role from a file to a collaboration.
@param \FeaturePhp\Artifact\Artifact $artifact
@param \FeaturePhp\Specification\FileSpecification $fileSpecification
|
[
"Adds",
"a",
"role",
"from",
"a",
"file",
"to",
"a",
"collaboration",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/CollaborationGenerator.php#L62-L70
|
23,245
|
ekuiter/feature-php
|
FeaturePhp/Generator/CollaborationGenerator.php
|
CollaborationGenerator._generateFiles
|
protected function _generateFiles() {
foreach ($this->getRegisteredArtifacts() as $artifact) {
$featureName = $artifact->getFeature()->getName();
if (array_search($featureName, $this->featureOrder) === false)
throw new CollaborationGeneratorException("no feature order supplied for \"$featureName\"");
}
parent::_generateFiles();
$rolePartition = fphp\Helper\Partition::fromObjects($this->collaborations, "getRoles")->partitionBy("correspondsTo");
foreach ($rolePartition as $roleEquivalenceClass) {
// sort the roles by their feature order (because role composition is not commutative)
$roleEquivalenceClass = fphp\Helper\_Array::schwartzianTransform($roleEquivalenceClass, function($role) {
return array_search($role->getCollaboration()->getArtifact()->getFeature()->getName(), $this->featureOrder);
});
// take any representative from the equivalence class to extract the file target
$fileTarget = $roleEquivalenceClass[0]->getFileSpecification()->getTarget();
$this->files[] = new fphp\File\RefinedFile($fileTarget, $roleEquivalenceClass);
$this->logFile->log(null, "added file \"$fileTarget\"");
}
}
|
php
|
protected function _generateFiles() {
foreach ($this->getRegisteredArtifacts() as $artifact) {
$featureName = $artifact->getFeature()->getName();
if (array_search($featureName, $this->featureOrder) === false)
throw new CollaborationGeneratorException("no feature order supplied for \"$featureName\"");
}
parent::_generateFiles();
$rolePartition = fphp\Helper\Partition::fromObjects($this->collaborations, "getRoles")->partitionBy("correspondsTo");
foreach ($rolePartition as $roleEquivalenceClass) {
// sort the roles by their feature order (because role composition is not commutative)
$roleEquivalenceClass = fphp\Helper\_Array::schwartzianTransform($roleEquivalenceClass, function($role) {
return array_search($role->getCollaboration()->getArtifact()->getFeature()->getName(), $this->featureOrder);
});
// take any representative from the equivalence class to extract the file target
$fileTarget = $roleEquivalenceClass[0]->getFileSpecification()->getTarget();
$this->files[] = new fphp\File\RefinedFile($fileTarget, $roleEquivalenceClass);
$this->logFile->log(null, "added file \"$fileTarget\"");
}
}
|
[
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRegisteredArtifacts",
"(",
")",
"as",
"$",
"artifact",
")",
"{",
"$",
"featureName",
"=",
"$",
"artifact",
"->",
"getFeature",
"(",
")",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"array_search",
"(",
"$",
"featureName",
",",
"$",
"this",
"->",
"featureOrder",
")",
"===",
"false",
")",
"throw",
"new",
"CollaborationGeneratorException",
"(",
"\"no feature order supplied for \\\"$featureName\\\"\"",
")",
";",
"}",
"parent",
"::",
"_generateFiles",
"(",
")",
";",
"$",
"rolePartition",
"=",
"fphp",
"\\",
"Helper",
"\\",
"Partition",
"::",
"fromObjects",
"(",
"$",
"this",
"->",
"collaborations",
",",
"\"getRoles\"",
")",
"->",
"partitionBy",
"(",
"\"correspondsTo\"",
")",
";",
"foreach",
"(",
"$",
"rolePartition",
"as",
"$",
"roleEquivalenceClass",
")",
"{",
"// sort the roles by their feature order (because role composition is not commutative)",
"$",
"roleEquivalenceClass",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_Array",
"::",
"schwartzianTransform",
"(",
"$",
"roleEquivalenceClass",
",",
"function",
"(",
"$",
"role",
")",
"{",
"return",
"array_search",
"(",
"$",
"role",
"->",
"getCollaboration",
"(",
")",
"->",
"getArtifact",
"(",
")",
"->",
"getFeature",
"(",
")",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"featureOrder",
")",
";",
"}",
")",
";",
"// take any representative from the equivalence class to extract the file target",
"$",
"fileTarget",
"=",
"$",
"roleEquivalenceClass",
"[",
"0",
"]",
"->",
"getFileSpecification",
"(",
")",
"->",
"getTarget",
"(",
")",
";",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"File",
"\\",
"RefinedFile",
"(",
"$",
"fileTarget",
",",
"$",
"roleEquivalenceClass",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"null",
",",
"\"added file \\\"$fileTarget\\\"\"",
")",
";",
"}",
"}"
] |
Generates the refined files.
|
[
"Generates",
"the",
"refined",
"files",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/CollaborationGenerator.php#L75-L96
|
23,246
|
crysalead/storage-stream
|
src/MultiStream.php
|
MultiStream.append
|
public function append($string, $length = null)
{
$this->end();
return $this->write($string, $length);
}
|
php
|
public function append($string, $length = null)
{
$this->end();
return $this->write($string, $length);
}
|
[
"public",
"function",
"append",
"(",
"$",
"string",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"end",
"(",
")",
";",
"return",
"$",
"this",
"->",
"write",
"(",
"$",
"string",
",",
"$",
"length",
")",
";",
"}"
] |
Append data to the stream.
@param string $string The string that is to be written.
@param integer $length If the length argument is given, writing will stop after length bytes have
been written or the end of string if reached, whichever comes first.
@return integer Number of bytes written
|
[
"Append",
"data",
"to",
"the",
"stream",
"."
] |
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
|
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/MultiStream.php#L291-L295
|
23,247
|
crysalead/storage-stream
|
src/MultiStream.php
|
MultiStream.get
|
public function get($index)
{
if (!isset($this->_streams[$index])) {
throw new InvalidArgumentException("Unexisting stream index `{$index}`.");
}
return $this->_streams[$index];
}
|
php
|
public function get($index)
{
if (!isset($this->_streams[$index])) {
throw new InvalidArgumentException("Unexisting stream index `{$index}`.");
}
return $this->_streams[$index];
}
|
[
"public",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_streams",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexisting stream index `{$index}`.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_streams",
"[",
"$",
"index",
"]",
";",
"}"
] |
Return a contained stream.
@param integer $index An index.
@return object
|
[
"Return",
"a",
"contained",
"stream",
"."
] |
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
|
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/MultiStream.php#L335-L341
|
23,248
|
crysalead/storage-stream
|
src/MultiStream.php
|
MultiStream.remove
|
public function remove($index)
{
if (!isset($this->_streams[$index])) {
throw new InvalidArgumentException("Unexisting stream index `{$index}`.");
}
$stream = $this->_streams[$index];
unset($this->_streams[$index]);
$this->_streams = array_values($this->_streams);
return $stream;
}
|
php
|
public function remove($index)
{
if (!isset($this->_streams[$index])) {
throw new InvalidArgumentException("Unexisting stream index `{$index}`.");
}
$stream = $this->_streams[$index];
unset($this->_streams[$index]);
$this->_streams = array_values($this->_streams);
return $stream;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_streams",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unexisting stream index `{$index}`.\"",
")",
";",
"}",
"$",
"stream",
"=",
"$",
"this",
"->",
"_streams",
"[",
"$",
"index",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"_streams",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"_streams",
"=",
"array_values",
"(",
"$",
"this",
"->",
"_streams",
")",
";",
"return",
"$",
"stream",
";",
"}"
] |
Remove a stream.
@param integer $index An index.
@return object The removed stream.
|
[
"Remove",
"a",
"stream",
"."
] |
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
|
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/MultiStream.php#L349-L358
|
23,249
|
crysalead/storage-stream
|
src/MultiStream.php
|
MultiStream.detach
|
public function detach()
{
$this->_offset = $this->_current = 0;
$this->_seekable = true;
foreach ($this->_streams as $stream) {
$stream->detach();
}
$this->_streams = [];
}
|
php
|
public function detach()
{
$this->_offset = $this->_current = 0;
$this->_seekable = true;
foreach ($this->_streams as $stream) {
$stream->detach();
}
$this->_streams = [];
}
|
[
"public",
"function",
"detach",
"(",
")",
"{",
"$",
"this",
"->",
"_offset",
"=",
"$",
"this",
"->",
"_current",
"=",
"0",
";",
"$",
"this",
"->",
"_seekable",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"_streams",
"as",
"$",
"stream",
")",
"{",
"$",
"stream",
"->",
"detach",
"(",
")",
";",
"}",
"$",
"this",
"->",
"_streams",
"=",
"[",
"]",
";",
"}"
] |
Detaches each attached stream.
Returns null as it's not clear which underlying stream resource to return.
|
[
"Detaches",
"each",
"attached",
"stream",
"."
] |
8ec613b42a2dd5d7e951a118f61d6094fe97dd9b
|
https://github.com/crysalead/storage-stream/blob/8ec613b42a2dd5d7e951a118f61d6094fe97dd9b/src/MultiStream.php#L423-L433
|
23,250
|
Innmind/neo4j-dbal
|
src/Translator/HttpTranslator.php
|
HttpTranslator.computeEndpoint
|
private function computeEndpoint(): UrlInterface
{
if (!$this->transactions->isOpened()) {
return Url::fromString('/db/data/transaction/commit');
}
return $this->transactions->current()->endpoint();
}
|
php
|
private function computeEndpoint(): UrlInterface
{
if (!$this->transactions->isOpened()) {
return Url::fromString('/db/data/transaction/commit');
}
return $this->transactions->current()->endpoint();
}
|
[
"private",
"function",
"computeEndpoint",
"(",
")",
":",
"UrlInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"transactions",
"->",
"isOpened",
"(",
")",
")",
"{",
"return",
"Url",
"::",
"fromString",
"(",
"'/db/data/transaction/commit'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"transactions",
"->",
"current",
"(",
")",
"->",
"endpoint",
"(",
")",
";",
"}"
] |
Determine the appropriate endpoint based on the transactions
|
[
"Determine",
"the",
"appropriate",
"endpoint",
"based",
"on",
"the",
"transactions"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Translator/HttpTranslator.php#L77-L84
|
23,251
|
Innmind/neo4j-dbal
|
src/Translator/HttpTranslator.php
|
HttpTranslator.computeBody
|
private function computeBody(Query $query): StringStream
{
$statement = [
'statement' => $query->cypher(),
'resultDataContents' => ['graph', 'row'],
];
if ($query->hasParameters()) {
$parameters = [];
foreach ($query->parameters() as $parameter) {
$parameters[$parameter->key()] = $parameter->value();
}
$statement['parameters'] = $parameters;
}
return new StringStream(Json::encode([
'statements' => [$statement],
]));
}
|
php
|
private function computeBody(Query $query): StringStream
{
$statement = [
'statement' => $query->cypher(),
'resultDataContents' => ['graph', 'row'],
];
if ($query->hasParameters()) {
$parameters = [];
foreach ($query->parameters() as $parameter) {
$parameters[$parameter->key()] = $parameter->value();
}
$statement['parameters'] = $parameters;
}
return new StringStream(Json::encode([
'statements' => [$statement],
]));
}
|
[
"private",
"function",
"computeBody",
"(",
"Query",
"$",
"query",
")",
":",
"StringStream",
"{",
"$",
"statement",
"=",
"[",
"'statement'",
"=>",
"$",
"query",
"->",
"cypher",
"(",
")",
",",
"'resultDataContents'",
"=>",
"[",
"'graph'",
",",
"'row'",
"]",
",",
"]",
";",
"if",
"(",
"$",
"query",
"->",
"hasParameters",
"(",
")",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"parameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"$",
"parameters",
"[",
"$",
"parameter",
"->",
"key",
"(",
")",
"]",
"=",
"$",
"parameter",
"->",
"value",
"(",
")",
";",
"}",
"$",
"statement",
"[",
"'parameters'",
"]",
"=",
"$",
"parameters",
";",
"}",
"return",
"new",
"StringStream",
"(",
"Json",
"::",
"encode",
"(",
"[",
"'statements'",
"=>",
"[",
"$",
"statement",
"]",
",",
"]",
")",
")",
";",
"}"
] |
Build the json payload to be sent to the server
|
[
"Build",
"the",
"json",
"payload",
"to",
"be",
"sent",
"to",
"the",
"server"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Translator/HttpTranslator.php#L89-L109
|
23,252
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.isExpressionPath
|
public function isExpressionPath($path, $node)
{
if (is_scalar($node)) {
foreach ($this->expressionPaths as $callable) {
if (call_user_func($callable, $path)) {
return true;
}
}
}
return false;
}
|
php
|
public function isExpressionPath($path, $node)
{
if (is_scalar($node)) {
foreach ($this->expressionPaths as $callable) {
if (call_user_func($callable, $path)) {
return true;
}
}
}
return false;
}
|
[
"public",
"function",
"isExpressionPath",
"(",
"$",
"path",
",",
"$",
"node",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"node",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"expressionPaths",
"as",
"$",
"callable",
")",
"{",
"if",
"(",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"path",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Decides if a node should be an expression.
@param array $path
@param mixed $node
@return bool
|
[
"Decides",
"if",
"a",
"node",
"should",
"be",
"an",
"expression",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L58-L68
|
23,253
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.build
|
public function build()
{
Debug::enterScope('build');
$traverser = $this->createNodeCreatorTraverser($this->config);
$result = $traverser->traverse();
$node = new ContainerNode();
$gatherer = $this->createNodeGathererTraverser($result, $node);
$gatherer->traverse();
Debug::exitScope('build');
return $node;
}
|
php
|
public function build()
{
Debug::enterScope('build');
$traverser = $this->createNodeCreatorTraverser($this->config);
$result = $traverser->traverse();
$node = new ContainerNode();
$gatherer = $this->createNodeGathererTraverser($result, $node);
$gatherer->traverse();
Debug::exitScope('build');
return $node;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"Debug",
"::",
"enterScope",
"(",
"'build'",
")",
";",
"$",
"traverser",
"=",
"$",
"this",
"->",
"createNodeCreatorTraverser",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"result",
"=",
"$",
"traverser",
"->",
"traverse",
"(",
")",
";",
"$",
"node",
"=",
"new",
"ContainerNode",
"(",
")",
";",
"$",
"gatherer",
"=",
"$",
"this",
"->",
"createNodeGathererTraverser",
"(",
"$",
"result",
",",
"$",
"node",
")",
";",
"$",
"gatherer",
"->",
"traverse",
"(",
")",
";",
"Debug",
"::",
"exitScope",
"(",
"'build'",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Build the container node
@return ContainerNode
|
[
"Build",
"the",
"container",
"node"
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L76-L88
|
23,254
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.createArgNode
|
public function createArgNode($path, $node)
{
$v = trim($node);
if (substr($v, 0, 1) == '?') {
$conditional = true;
$v = ltrim(substr($v, 1));
} else {
$conditional = false;
}
return new ArgNode(end($path), $this->exprcompiler->parse($v), $conditional);
}
|
php
|
public function createArgNode($path, $node)
{
$v = trim($node);
if (substr($v, 0, 1) == '?') {
$conditional = true;
$v = ltrim(substr($v, 1));
} else {
$conditional = false;
}
return new ArgNode(end($path), $this->exprcompiler->parse($v), $conditional);
}
|
[
"public",
"function",
"createArgNode",
"(",
"$",
"path",
",",
"$",
"node",
")",
"{",
"$",
"v",
"=",
"trim",
"(",
"$",
"node",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"v",
",",
"0",
",",
"1",
")",
"==",
"'?'",
")",
"{",
"$",
"conditional",
"=",
"true",
";",
"$",
"v",
"=",
"ltrim",
"(",
"substr",
"(",
"$",
"v",
",",
"1",
")",
")",
";",
"}",
"else",
"{",
"$",
"conditional",
"=",
"false",
";",
"}",
"return",
"new",
"ArgNode",
"(",
"end",
"(",
"$",
"path",
")",
",",
"$",
"this",
"->",
"exprcompiler",
"->",
"parse",
"(",
"$",
"v",
")",
",",
"$",
"conditional",
")",
";",
"}"
] |
Creates a node for the 'args' definition of the task.
@param array $path
@param string $node
@return \Zicht\Tool\Script\Node\Task\ArgNode
|
[
"Creates",
"a",
"node",
"for",
"the",
"args",
"definition",
"of",
"the",
"task",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L160-L170
|
23,255
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.createOptNode
|
public function createOptNode($path, $node)
{
return new OptNode(end($path), $this->exprcompiler->parse($node));
}
|
php
|
public function createOptNode($path, $node)
{
return new OptNode(end($path), $this->exprcompiler->parse($node));
}
|
[
"public",
"function",
"createOptNode",
"(",
"$",
"path",
",",
"$",
"node",
")",
"{",
"return",
"new",
"OptNode",
"(",
"end",
"(",
"$",
"path",
")",
",",
"$",
"this",
"->",
"exprcompiler",
"->",
"parse",
"(",
"$",
"node",
")",
")",
";",
"}"
] |
Creates a node for the 'opts' definition of the task.
@param array $path
@param string $node
@return \Zicht\Tool\Script\Node\Task\OptNode
|
[
"Creates",
"a",
"node",
"for",
"the",
"opts",
"definition",
"of",
"the",
"task",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L179-L182
|
23,256
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.createSetNode
|
public function createSetNode($path, $node)
{
return new SetNode(end($path), $this->exprcompiler->parse($node));
}
|
php
|
public function createSetNode($path, $node)
{
return new SetNode(end($path), $this->exprcompiler->parse($node));
}
|
[
"public",
"function",
"createSetNode",
"(",
"$",
"path",
",",
"$",
"node",
")",
"{",
"return",
"new",
"SetNode",
"(",
"end",
"(",
"$",
"path",
")",
",",
"$",
"this",
"->",
"exprcompiler",
"->",
"parse",
"(",
"$",
"node",
")",
")",
";",
"}"
] |
Creates a node for the 'set' definition of the task.
@param array $path
@param string $node
@return SetNode
|
[
"Creates",
"a",
"node",
"for",
"the",
"set",
"definition",
"of",
"the",
"task",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L192-L195
|
23,257
|
zicht/z
|
src/Zicht/Tool/Container/ContainerBuilder.php
|
ContainerBuilder.createNodeCreatorTraverser
|
public function createNodeCreatorTraverser($config)
{
$traverser = new Traverser($config);
$traverser->addVisitor(
array($this, 'createArgNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'args');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createOptNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'opts');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createSetNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'set');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createExpressionNode'),
function ($path) {
return
count($path) === 3
&& $path[0] == 'tasks'
&& in_array($path[2], array('unless', 'assert', 'yield', 'if'))
;
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createScriptNode'),
function ($path) {
return
count($path) == 4
&& $path[0] == 'tasks'
&& in_array($path[2], array('do', 'pre', 'post'))
;
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createTaskNode'),
function ($path) {
return count($path) == 2 && $path[0] == 'tasks';
},
Traverser::AFTER
);
$traverser->addVisitor(
array($this, 'createDeclarationNode'),
array($this, 'isExpressionPath'),
Traverser::AFTER
);
$traverser->addVisitor(
array($this, 'createDefinitionNode'),
function ($path, $node) {
return $path[0] !== 'tasks' && (is_scalar($node) || (is_array($node) && count($node) === 0));
},
Traverser::AFTER
);
return $traverser;
}
|
php
|
public function createNodeCreatorTraverser($config)
{
$traverser = new Traverser($config);
$traverser->addVisitor(
array($this, 'createArgNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'args');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createOptNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'opts');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createSetNode'),
function ($path) {
return (count($path) == 4 && $path[0] == 'tasks' && $path[2] == 'set');
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createExpressionNode'),
function ($path) {
return
count($path) === 3
&& $path[0] == 'tasks'
&& in_array($path[2], array('unless', 'assert', 'yield', 'if'))
;
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createScriptNode'),
function ($path) {
return
count($path) == 4
&& $path[0] == 'tasks'
&& in_array($path[2], array('do', 'pre', 'post'))
;
},
Traverser::BEFORE
);
$traverser->addVisitor(
array($this, 'createTaskNode'),
function ($path) {
return count($path) == 2 && $path[0] == 'tasks';
},
Traverser::AFTER
);
$traverser->addVisitor(
array($this, 'createDeclarationNode'),
array($this, 'isExpressionPath'),
Traverser::AFTER
);
$traverser->addVisitor(
array($this, 'createDefinitionNode'),
function ($path, $node) {
return $path[0] !== 'tasks' && (is_scalar($node) || (is_array($node) && count($node) === 0));
},
Traverser::AFTER
);
return $traverser;
}
|
[
"public",
"function",
"createNodeCreatorTraverser",
"(",
"$",
"config",
")",
"{",
"$",
"traverser",
"=",
"new",
"Traverser",
"(",
"$",
"config",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createArgNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"count",
"(",
"$",
"path",
")",
"==",
"4",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
"&&",
"$",
"path",
"[",
"2",
"]",
"==",
"'args'",
")",
";",
"}",
",",
"Traverser",
"::",
"BEFORE",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createOptNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"count",
"(",
"$",
"path",
")",
"==",
"4",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
"&&",
"$",
"path",
"[",
"2",
"]",
"==",
"'opts'",
")",
";",
"}",
",",
"Traverser",
"::",
"BEFORE",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createSetNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"(",
"count",
"(",
"$",
"path",
")",
"==",
"4",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
"&&",
"$",
"path",
"[",
"2",
"]",
"==",
"'set'",
")",
";",
"}",
",",
"Traverser",
"::",
"BEFORE",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createExpressionNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"count",
"(",
"$",
"path",
")",
"===",
"3",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
"&&",
"in_array",
"(",
"$",
"path",
"[",
"2",
"]",
",",
"array",
"(",
"'unless'",
",",
"'assert'",
",",
"'yield'",
",",
"'if'",
")",
")",
";",
"}",
",",
"Traverser",
"::",
"BEFORE",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createScriptNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"count",
"(",
"$",
"path",
")",
"==",
"4",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
"&&",
"in_array",
"(",
"$",
"path",
"[",
"2",
"]",
",",
"array",
"(",
"'do'",
",",
"'pre'",
",",
"'post'",
")",
")",
";",
"}",
",",
"Traverser",
"::",
"BEFORE",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createTaskNode'",
")",
",",
"function",
"(",
"$",
"path",
")",
"{",
"return",
"count",
"(",
"$",
"path",
")",
"==",
"2",
"&&",
"$",
"path",
"[",
"0",
"]",
"==",
"'tasks'",
";",
"}",
",",
"Traverser",
"::",
"AFTER",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createDeclarationNode'",
")",
",",
"array",
"(",
"$",
"this",
",",
"'isExpressionPath'",
")",
",",
"Traverser",
"::",
"AFTER",
")",
";",
"$",
"traverser",
"->",
"addVisitor",
"(",
"array",
"(",
"$",
"this",
",",
"'createDefinitionNode'",
")",
",",
"function",
"(",
"$",
"path",
",",
"$",
"node",
")",
"{",
"return",
"$",
"path",
"[",
"0",
"]",
"!==",
"'tasks'",
"&&",
"(",
"is_scalar",
"(",
"$",
"node",
")",
"||",
"(",
"is_array",
"(",
"$",
"node",
")",
"&&",
"count",
"(",
"$",
"node",
")",
"===",
"0",
")",
")",
";",
"}",
",",
"Traverser",
"::",
"AFTER",
")",
";",
"return",
"$",
"traverser",
";",
"}"
] |
Creates the traverser that creates relevant nodes at all known paths.
@param array $config
@return Traverser
|
[
"Creates",
"the",
"traverser",
"that",
"creates",
"relevant",
"nodes",
"at",
"all",
"known",
"paths",
"."
] |
6a1731dad20b018555a96b726a61d4bf8ec8c886
|
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/ContainerBuilder.php#L230-L299
|
23,258
|
qlake/framework
|
src/Qlake/Routing/Route.php
|
Route.hasParam
|
public function hasParam($param)
{
$param = (string)$this->params[$param];
return strlen($param) > 0 ? true : false;
}
|
php
|
public function hasParam($param)
{
$param = (string)$this->params[$param];
return strlen($param) > 0 ? true : false;
}
|
[
"public",
"function",
"hasParam",
"(",
"$",
"param",
")",
"{",
"$",
"param",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"params",
"[",
"$",
"param",
"]",
";",
"return",
"strlen",
"(",
"$",
"param",
")",
">",
"0",
"?",
"true",
":",
"false",
";",
"}"
] |
Determine that route param exists.
@param string $param
@return bool
|
[
"Determine",
"that",
"route",
"param",
"exists",
"."
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Route.php#L160-L165
|
23,259
|
qlake/framework
|
src/Qlake/Routing/Route.php
|
Route.isMatch
|
public function isMatch($pathInfo)
{
$this->compile();
$pathInfo = trim($pathInfo, '/');
if (!preg_match($this->pattern, $pathInfo, $paramValues))
{
return false;
}
foreach ($this->paramNames as $name)
{
$this->params[$name] = isset($paramValues[$name]) ? urldecode($paramValues[$name]) : null;
}
return true;
}
|
php
|
public function isMatch($pathInfo)
{
$this->compile();
$pathInfo = trim($pathInfo, '/');
if (!preg_match($this->pattern, $pathInfo, $paramValues))
{
return false;
}
foreach ($this->paramNames as $name)
{
$this->params[$name] = isset($paramValues[$name]) ? urldecode($paramValues[$name]) : null;
}
return true;
}
|
[
"public",
"function",
"isMatch",
"(",
"$",
"pathInfo",
")",
"{",
"$",
"this",
"->",
"compile",
"(",
")",
";",
"$",
"pathInfo",
"=",
"trim",
"(",
"$",
"pathInfo",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"this",
"->",
"pattern",
",",
"$",
"pathInfo",
",",
"$",
"paramValues",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"paramNames",
"as",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
"=",
"isset",
"(",
"$",
"paramValues",
"[",
"$",
"name",
"]",
")",
"?",
"urldecode",
"(",
"$",
"paramValues",
"[",
"$",
"name",
"]",
")",
":",
"null",
";",
"}",
"return",
"true",
";",
"}"
] |
Determine matching route by given uri.
@param string $pathInfo
@return bool
|
[
"Determine",
"matching",
"route",
"by",
"given",
"uri",
"."
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Route.php#L261-L278
|
23,260
|
qlake/framework
|
src/Qlake/Routing/Route.php
|
Route.compile
|
public function compile()
{
//reset arrays
$this->params = [];
$this->paramNames = [];
$this->conditions = [];
$this->compiled = true;
$uri = $this->normalizeUri($this->getUri());
// match patterns like /{param?:regex}
// tested in https://regex101.com/r/gP6yH7
$regex = preg_replace_callback(
'#(?:(\\/)?\\{(\\w+)(\\?)?(?::((?:\\\\\\{|\\\\\\}|[^{}]|\\{\\d(?:\\,(?:\\d)?)?\\})+))?\\})#',
[$this, 'createRegex'],
$uri
);
$regex .= "/?";
$regex = '#^' . $regex . '$#';
if ($this->caseSensitive === false)
{
$regex .= 'i';
}
$this->pattern = $regex;
return $this;
}
|
php
|
public function compile()
{
//reset arrays
$this->params = [];
$this->paramNames = [];
$this->conditions = [];
$this->compiled = true;
$uri = $this->normalizeUri($this->getUri());
// match patterns like /{param?:regex}
// tested in https://regex101.com/r/gP6yH7
$regex = preg_replace_callback(
'#(?:(\\/)?\\{(\\w+)(\\?)?(?::((?:\\\\\\{|\\\\\\}|[^{}]|\\{\\d(?:\\,(?:\\d)?)?\\})+))?\\})#',
[$this, 'createRegex'],
$uri
);
$regex .= "/?";
$regex = '#^' . $regex . '$#';
if ($this->caseSensitive === false)
{
$regex .= 'i';
}
$this->pattern = $regex;
return $this;
}
|
[
"public",
"function",
"compile",
"(",
")",
"{",
"//reset arrays",
"$",
"this",
"->",
"params",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"paramNames",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"conditions",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"compiled",
"=",
"true",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"normalizeUri",
"(",
"$",
"this",
"->",
"getUri",
"(",
")",
")",
";",
"// match patterns like /{param?:regex}",
"// tested in https://regex101.com/r/gP6yH7",
"$",
"regex",
"=",
"preg_replace_callback",
"(",
"'#(?:(\\\\/)?\\\\{(\\\\w+)(\\\\?)?(?::((?:\\\\\\\\\\\\{|\\\\\\\\\\\\}|[^{}]|\\\\{\\\\d(?:\\\\,(?:\\\\d)?)?\\\\})+))?\\\\})#'",
",",
"[",
"$",
"this",
",",
"'createRegex'",
"]",
",",
"$",
"uri",
")",
";",
"$",
"regex",
".=",
"\"/?\"",
";",
"$",
"regex",
"=",
"'#^'",
".",
"$",
"regex",
".",
"'$#'",
";",
"if",
"(",
"$",
"this",
"->",
"caseSensitive",
"===",
"false",
")",
"{",
"$",
"regex",
".=",
"'i'",
";",
"}",
"$",
"this",
"->",
"pattern",
"=",
"$",
"regex",
";",
"return",
"$",
"this",
";",
"}"
] |
Compile route uri pattern regex
@return Qlake\Routing\Route
|
[
"Compile",
"route",
"uri",
"pattern",
"regex"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Route.php#L391-L422
|
23,261
|
qlake/framework
|
src/Qlake/Routing/Route.php
|
Route.createRegex
|
protected function createRegex($matched)
{
$startSlash = $matched[1] ? true : false;
$param = $matched[2];
$optional = $matched[3] ? true : false;
$pattern = $matched[4] ?: null;
$pattern = $this->conditions[$param] ?: $pattern ?: '[^/]+';
$this->paramNames[] = $param;
if ($startSlash)
{
$regex = ($optional ? "(/" : '/') .'(?P<' . $param . '>' . $pattern . ')'. ($optional ? ')?' : '');
}
else
{
$regex = '(?P<' . $param . '>' . $pattern . ')'. ($optional ? '?' : '');
}
return $regex;
}
|
php
|
protected function createRegex($matched)
{
$startSlash = $matched[1] ? true : false;
$param = $matched[2];
$optional = $matched[3] ? true : false;
$pattern = $matched[4] ?: null;
$pattern = $this->conditions[$param] ?: $pattern ?: '[^/]+';
$this->paramNames[] = $param;
if ($startSlash)
{
$regex = ($optional ? "(/" : '/') .'(?P<' . $param . '>' . $pattern . ')'. ($optional ? ')?' : '');
}
else
{
$regex = '(?P<' . $param . '>' . $pattern . ')'. ($optional ? '?' : '');
}
return $regex;
}
|
[
"protected",
"function",
"createRegex",
"(",
"$",
"matched",
")",
"{",
"$",
"startSlash",
"=",
"$",
"matched",
"[",
"1",
"]",
"?",
"true",
":",
"false",
";",
"$",
"param",
"=",
"$",
"matched",
"[",
"2",
"]",
";",
"$",
"optional",
"=",
"$",
"matched",
"[",
"3",
"]",
"?",
"true",
":",
"false",
";",
"$",
"pattern",
"=",
"$",
"matched",
"[",
"4",
"]",
"?",
":",
"null",
";",
"$",
"pattern",
"=",
"$",
"this",
"->",
"conditions",
"[",
"$",
"param",
"]",
"?",
":",
"$",
"pattern",
"?",
":",
"'[^/]+'",
";",
"$",
"this",
"->",
"paramNames",
"[",
"]",
"=",
"$",
"param",
";",
"if",
"(",
"$",
"startSlash",
")",
"{",
"$",
"regex",
"=",
"(",
"$",
"optional",
"?",
"\"(/\"",
":",
"'/'",
")",
".",
"'(?P<'",
".",
"$",
"param",
".",
"'>'",
".",
"$",
"pattern",
".",
"')'",
".",
"(",
"$",
"optional",
"?",
"')?'",
":",
"''",
")",
";",
"}",
"else",
"{",
"$",
"regex",
"=",
"'(?P<'",
".",
"$",
"param",
".",
"'>'",
".",
"$",
"pattern",
".",
"')'",
".",
"(",
"$",
"optional",
"?",
"'?'",
":",
"''",
")",
";",
"}",
"return",
"$",
"regex",
";",
"}"
] |
Callback for creating route param names regex
@param array $matched
@return string
|
[
"Callback",
"for",
"creating",
"route",
"param",
"names",
"regex"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Route.php#L432-L453
|
23,262
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/composer.php
|
ezcMailComposer.generateHtmlPart
|
private function generateHtmlPart()
{
$result = false;
if ( $this->htmlText != '' )
{
$matches = array();
if ( $this->options->automaticImageInclude === true )
{
// recognize file:// and file:///, pick out the image, add it as a part and then..:)
preg_match_all( '(
<img \\s+[^>]*
src\\s*=\\s*
(?:
(?# Match quoted attribute)
([\'"])file://(?P<quoted>[^>]+)\\1
(?# Match unquoted attribute, which may not contain spaces)
| file://(?P<unquoted>[^>\\s]+)
)
[^>]* >)ix', $this->htmlText, $matches );
// pictures/files can be added multiple times. We only need them once.
$matches = array_filter( array_unique( array_merge( $matches['quoted'], $matches['unquoted'] ) ) );
}
$result = new ezcMailText( $this->htmlText, $this->charset, $this->encoding );
$result->subType = "html";
if ( count( $matches ) > 0 )
{
$htmlPart = $result;
// wrap already existing message in an alternative part
$result = new ezcMailMultipartRelated( $result );
// create a filepart and add it to the related part
// also store the ID for each part since we need those
// when we replace the originals in the HTML message.
foreach ( $matches as $fileName )
{
if ( is_readable( $fileName ) )
{
// @todo waiting for fix of the fileinfo extension
// $contents = file_get_contents( $fileName );
$mimeType = null;
$contentType = null;
if ( ezcBaseFeatures::hasExtensionSupport( 'fileinfo' ) )
{
// if fileinfo extension is available
$filePart = new ezcMailFile( $fileName );
}
elseif ( ezcMailTools::guessContentType( $fileName, $contentType, $mimeType ) )
{
// if fileinfo extension is not available try to get content/mime type
// from the file extension
$filePart = new ezcMailFile( $fileName, $contentType, $mimeType );
}
else
{
// fallback in case fileinfo is not available and could not get content/mime
// type from file extension
$filePart = new ezcMailFile( $fileName, "application", "octet-stream" );
}
$cid = $result->addRelatedPart( $filePart );
// replace the original file reference with a reference to the cid
$this->htmlText = str_replace( 'file://' . $fileName, 'cid:' . $cid, $this->htmlText );
}
else
{
if ( file_exists( $fileName ) )
{
throw new ezcBaseFilePermissionException( $fileName, ezcBaseFileException::READ );
}
else
{
throw new ezcBaseFileNotFoundException( $fileName );
}
// throw
}
}
// update mail, with replaced URLs
$htmlPart->text = $this->htmlText;
}
}
return $result;
}
|
php
|
private function generateHtmlPart()
{
$result = false;
if ( $this->htmlText != '' )
{
$matches = array();
if ( $this->options->automaticImageInclude === true )
{
// recognize file:// and file:///, pick out the image, add it as a part and then..:)
preg_match_all( '(
<img \\s+[^>]*
src\\s*=\\s*
(?:
(?# Match quoted attribute)
([\'"])file://(?P<quoted>[^>]+)\\1
(?# Match unquoted attribute, which may not contain spaces)
| file://(?P<unquoted>[^>\\s]+)
)
[^>]* >)ix', $this->htmlText, $matches );
// pictures/files can be added multiple times. We only need them once.
$matches = array_filter( array_unique( array_merge( $matches['quoted'], $matches['unquoted'] ) ) );
}
$result = new ezcMailText( $this->htmlText, $this->charset, $this->encoding );
$result->subType = "html";
if ( count( $matches ) > 0 )
{
$htmlPart = $result;
// wrap already existing message in an alternative part
$result = new ezcMailMultipartRelated( $result );
// create a filepart and add it to the related part
// also store the ID for each part since we need those
// when we replace the originals in the HTML message.
foreach ( $matches as $fileName )
{
if ( is_readable( $fileName ) )
{
// @todo waiting for fix of the fileinfo extension
// $contents = file_get_contents( $fileName );
$mimeType = null;
$contentType = null;
if ( ezcBaseFeatures::hasExtensionSupport( 'fileinfo' ) )
{
// if fileinfo extension is available
$filePart = new ezcMailFile( $fileName );
}
elseif ( ezcMailTools::guessContentType( $fileName, $contentType, $mimeType ) )
{
// if fileinfo extension is not available try to get content/mime type
// from the file extension
$filePart = new ezcMailFile( $fileName, $contentType, $mimeType );
}
else
{
// fallback in case fileinfo is not available and could not get content/mime
// type from file extension
$filePart = new ezcMailFile( $fileName, "application", "octet-stream" );
}
$cid = $result->addRelatedPart( $filePart );
// replace the original file reference with a reference to the cid
$this->htmlText = str_replace( 'file://' . $fileName, 'cid:' . $cid, $this->htmlText );
}
else
{
if ( file_exists( $fileName ) )
{
throw new ezcBaseFilePermissionException( $fileName, ezcBaseFileException::READ );
}
else
{
throw new ezcBaseFileNotFoundException( $fileName );
}
// throw
}
}
// update mail, with replaced URLs
$htmlPart->text = $this->htmlText;
}
}
return $result;
}
|
[
"private",
"function",
"generateHtmlPart",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"htmlText",
"!=",
"''",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"->",
"automaticImageInclude",
"===",
"true",
")",
"{",
"// recognize file:// and file:///, pick out the image, add it as a part and then..:)",
"preg_match_all",
"(",
"'(\n <img \\\\s+[^>]*\n src\\\\s*=\\\\s*\n (?:\n (?# Match quoted attribute)\n ([\\'\"])file://(?P<quoted>[^>]+)\\\\1\n\n (?# Match unquoted attribute, which may not contain spaces)\n | file://(?P<unquoted>[^>\\\\s]+)\n )\n [^>]* >)ix'",
",",
"$",
"this",
"->",
"htmlText",
",",
"$",
"matches",
")",
";",
"// pictures/files can be added multiple times. We only need them once.",
"$",
"matches",
"=",
"array_filter",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"matches",
"[",
"'quoted'",
"]",
",",
"$",
"matches",
"[",
"'unquoted'",
"]",
")",
")",
")",
";",
"}",
"$",
"result",
"=",
"new",
"ezcMailText",
"(",
"$",
"this",
"->",
"htmlText",
",",
"$",
"this",
"->",
"charset",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"result",
"->",
"subType",
"=",
"\"html\"",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
">",
"0",
")",
"{",
"$",
"htmlPart",
"=",
"$",
"result",
";",
"// wrap already existing message in an alternative part",
"$",
"result",
"=",
"new",
"ezcMailMultipartRelated",
"(",
"$",
"result",
")",
";",
"// create a filepart and add it to the related part",
"// also store the ID for each part since we need those",
"// when we replace the originals in the HTML message.",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"fileName",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"fileName",
")",
")",
"{",
"// @todo waiting for fix of the fileinfo extension",
"// $contents = file_get_contents( $fileName );",
"$",
"mimeType",
"=",
"null",
";",
"$",
"contentType",
"=",
"null",
";",
"if",
"(",
"ezcBaseFeatures",
"::",
"hasExtensionSupport",
"(",
"'fileinfo'",
")",
")",
"{",
"// if fileinfo extension is available",
"$",
"filePart",
"=",
"new",
"ezcMailFile",
"(",
"$",
"fileName",
")",
";",
"}",
"elseif",
"(",
"ezcMailTools",
"::",
"guessContentType",
"(",
"$",
"fileName",
",",
"$",
"contentType",
",",
"$",
"mimeType",
")",
")",
"{",
"// if fileinfo extension is not available try to get content/mime type",
"// from the file extension",
"$",
"filePart",
"=",
"new",
"ezcMailFile",
"(",
"$",
"fileName",
",",
"$",
"contentType",
",",
"$",
"mimeType",
")",
";",
"}",
"else",
"{",
"// fallback in case fileinfo is not available and could not get content/mime",
"// type from file extension",
"$",
"filePart",
"=",
"new",
"ezcMailFile",
"(",
"$",
"fileName",
",",
"\"application\"",
",",
"\"octet-stream\"",
")",
";",
"}",
"$",
"cid",
"=",
"$",
"result",
"->",
"addRelatedPart",
"(",
"$",
"filePart",
")",
";",
"// replace the original file reference with a reference to the cid",
"$",
"this",
"->",
"htmlText",
"=",
"str_replace",
"(",
"'file://'",
".",
"$",
"fileName",
",",
"'cid:'",
".",
"$",
"cid",
",",
"$",
"this",
"->",
"htmlText",
")",
";",
"}",
"else",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"throw",
"new",
"ezcBaseFilePermissionException",
"(",
"$",
"fileName",
",",
"ezcBaseFileException",
"::",
"READ",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ezcBaseFileNotFoundException",
"(",
"$",
"fileName",
")",
";",
"}",
"// throw",
"}",
"}",
"// update mail, with replaced URLs",
"$",
"htmlPart",
"->",
"text",
"=",
"$",
"this",
"->",
"htmlText",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns an ezcMailPart based on the HTML provided.
This method adds local files/images to the mail itself using a
{@link ezcMailMultipartRelated} object.
@throws ezcBaseFileNotFoundException
if $fileName does not exists.
@throws ezcBaseFilePermissionProblem
if $fileName could not be read.
@return ezcMailPart
|
[
"Returns",
"an",
"ezcMailPart",
"based",
"on",
"the",
"HTML",
"provided",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/composer.php#L463-L545
|
23,263
|
WellCommerce/AppBundle
|
Manager/DictionaryManager.php
|
DictionaryManager.syncDictionary
|
public function syncDictionary()
{
$this->kernel = $this->get('kernel');
$this->locales = $this->getLocales();
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
$this->filesystem = new Filesystem();
foreach ($this->locales as $locale) {
$this->updateFilesystemTranslationsForLocale($locale);
}
$this->synchronizeDatabaseTranslations();
}
|
php
|
public function syncDictionary()
{
$this->kernel = $this->get('kernel');
$this->locales = $this->getLocales();
$this->propertyAccessor = PropertyAccess::createPropertyAccessor();
$this->filesystem = new Filesystem();
foreach ($this->locales as $locale) {
$this->updateFilesystemTranslationsForLocale($locale);
}
$this->synchronizeDatabaseTranslations();
}
|
[
"public",
"function",
"syncDictionary",
"(",
")",
"{",
"$",
"this",
"->",
"kernel",
"=",
"$",
"this",
"->",
"get",
"(",
"'kernel'",
")",
";",
"$",
"this",
"->",
"locales",
"=",
"$",
"this",
"->",
"getLocales",
"(",
")",
";",
"$",
"this",
"->",
"propertyAccessor",
"=",
"PropertyAccess",
"::",
"createPropertyAccessor",
"(",
")",
";",
"$",
"this",
"->",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"locales",
"as",
"$",
"locale",
")",
"{",
"$",
"this",
"->",
"updateFilesystemTranslationsForLocale",
"(",
"$",
"locale",
")",
";",
"}",
"$",
"this",
"->",
"synchronizeDatabaseTranslations",
"(",
")",
";",
"}"
] |
Synchronizes database and filesystem translations
|
[
"Synchronizes",
"database",
"and",
"filesystem",
"translations"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Manager/DictionaryManager.php#L58-L70
|
23,264
|
hametuha/wpametu
|
src/WPametu/UI/Field/GeoChecker.php
|
GeoChecker.get_field
|
protected function get_field( \WP_Post $post ){
$html = parent::get_field($post);
return $html.sprintf('<p class="inline-error"><i class="dashicons dashicons-location-alt"></i> %s</p>', $this->__('Can\'t find map point. Try another string'));
}
|
php
|
protected function get_field( \WP_Post $post ){
$html = parent::get_field($post);
return $html.sprintf('<p class="inline-error"><i class="dashicons dashicons-location-alt"></i> %s</p>', $this->__('Can\'t find map point. Try another string'));
}
|
[
"protected",
"function",
"get_field",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"$",
"html",
"=",
"parent",
"::",
"get_field",
"(",
"$",
"post",
")",
";",
"return",
"$",
"html",
".",
"sprintf",
"(",
"'<p class=\"inline-error\"><i class=\"dashicons dashicons-location-alt\"></i> %s</p>'",
",",
"$",
"this",
"->",
"__",
"(",
"'Can\\'t find map point. Try another string'",
")",
")",
";",
"}"
] |
Add error message.
@param \WP_Post $post
@return string
|
[
"Add",
"error",
"message",
"."
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/GeoChecker.php#L37-L40
|
23,265
|
surebert/surebert-framework
|
src/sb/JS.php
|
JS.setHTML
|
public static function setHTML($id, $html)
{
$js = '$("'.$id.'").html('.json_encode($html).');';
return self::execHeader($js);
}
|
php
|
public static function setHTML($id, $html)
{
$js = '$("'.$id.'").html('.json_encode($html).');';
return self::execHeader($js);
}
|
[
"public",
"static",
"function",
"setHTML",
"(",
"$",
"id",
",",
"$",
"html",
")",
"{",
"$",
"js",
"=",
"'$(\"'",
".",
"$",
"id",
".",
"'\").html('",
".",
"json_encode",
"(",
"$",
"html",
")",
".",
"');'",
";",
"return",
"self",
"::",
"execHeader",
"(",
"$",
"js",
")",
";",
"}"
] |
Uses jsexec_header to set the innerHTML of an element by id
@param integer $id the HTML element id
@param string $html The innerHTML to set
@return string
|
[
"Uses",
"jsexec_header",
"to",
"set",
"the",
"innerHTML",
"of",
"an",
"element",
"by",
"id"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/JS.php#L23-L27
|
23,266
|
surebert/surebert-framework
|
src/sb/JS.php
|
JS.execScript
|
public static function execScript($script_path, $context=null)
{
header('Content-type: text/javascript');
if(!is_null($context)){
if(is_object($context)){
$context = get_object_vars($context);
}
if(is_array($context)){
extract($context);
}
}
require($script_path);
}
|
php
|
public static function execScript($script_path, $context=null)
{
header('Content-type: text/javascript');
if(!is_null($context)){
if(is_object($context)){
$context = get_object_vars($context);
}
if(is_array($context)){
extract($context);
}
}
require($script_path);
}
|
[
"public",
"static",
"function",
"execScript",
"(",
"$",
"script_path",
",",
"$",
"context",
"=",
"null",
")",
"{",
"header",
"(",
"'Content-type: text/javascript'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"context",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"context",
")",
")",
"{",
"$",
"context",
"=",
"get_object_vars",
"(",
"$",
"context",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"context",
")",
")",
"{",
"extract",
"(",
"$",
"context",
")",
";",
"}",
"}",
"require",
"(",
"$",
"script_path",
")",
";",
"}"
] |
Executes a script at a certain path
@param string $script_path full path
|
[
"Executes",
"a",
"script",
"at",
"a",
"certain",
"path"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/JS.php#L33-L46
|
23,267
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processMetadataDrivers
|
private function processMetadataDrivers()
{
$builder = $this->getContainerBuilder();
// At the moment, only Docblock annotations are supported, XML and YAML are not.
$annotationReader = $builder->addDefinition($this->prefix('metadata.annotationReader'))
->setClass(AnnotationReader::class);
$cachedReader = $builder->addDefinition($this->prefix('metadata.cachedReader'))
->setClass(CachedReader::class)
->setFactory(CachedReader::class, [
'@' . $this->prefix('metadata.annotationReader'),
'@' . $this->prefix('cache.annotations'),
$this->debugMode
]);
$driverChain = $builder->addDefinition($this->prefix('metadata.driver'))
->setClass(MappingDriverChain::class);
foreach ($this->config['metadata'] as $namespace => $directory) {
$driver = $builder->addDefinition($this->prefix('driver.' . $this->createServiceName($namespace)))
->setClass(MappingDriver::class)
->setFactory(AnnotationDriver::class, [
'@' . $this->prefix('metadata.cachedReader'),
$directory
]);
$driverChain->addSetup('$service->addDriver(?, ?)', [
'@' . $this->prefix('driver.' . $this->createServiceName($namespace)), $namespace
]);
}
}
|
php
|
private function processMetadataDrivers()
{
$builder = $this->getContainerBuilder();
// At the moment, only Docblock annotations are supported, XML and YAML are not.
$annotationReader = $builder->addDefinition($this->prefix('metadata.annotationReader'))
->setClass(AnnotationReader::class);
$cachedReader = $builder->addDefinition($this->prefix('metadata.cachedReader'))
->setClass(CachedReader::class)
->setFactory(CachedReader::class, [
'@' . $this->prefix('metadata.annotationReader'),
'@' . $this->prefix('cache.annotations'),
$this->debugMode
]);
$driverChain = $builder->addDefinition($this->prefix('metadata.driver'))
->setClass(MappingDriverChain::class);
foreach ($this->config['metadata'] as $namespace => $directory) {
$driver = $builder->addDefinition($this->prefix('driver.' . $this->createServiceName($namespace)))
->setClass(MappingDriver::class)
->setFactory(AnnotationDriver::class, [
'@' . $this->prefix('metadata.cachedReader'),
$directory
]);
$driverChain->addSetup('$service->addDriver(?, ?)', [
'@' . $this->prefix('driver.' . $this->createServiceName($namespace)), $namespace
]);
}
}
|
[
"private",
"function",
"processMetadataDrivers",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"// At the moment, only Docblock annotations are supported, XML and YAML are not.\t\t",
"$",
"annotationReader",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.annotationReader'",
")",
")",
"->",
"setClass",
"(",
"AnnotationReader",
"::",
"class",
")",
";",
"$",
"cachedReader",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.cachedReader'",
")",
")",
"->",
"setClass",
"(",
"CachedReader",
"::",
"class",
")",
"->",
"setFactory",
"(",
"CachedReader",
"::",
"class",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.annotationReader'",
")",
",",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'cache.annotations'",
")",
",",
"$",
"this",
"->",
"debugMode",
"]",
")",
";",
"$",
"driverChain",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.driver'",
")",
")",
"->",
"setClass",
"(",
"MappingDriverChain",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'metadata'",
"]",
"as",
"$",
"namespace",
"=>",
"$",
"directory",
")",
"{",
"$",
"driver",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'driver.'",
".",
"$",
"this",
"->",
"createServiceName",
"(",
"$",
"namespace",
")",
")",
")",
"->",
"setClass",
"(",
"MappingDriver",
"::",
"class",
")",
"->",
"setFactory",
"(",
"AnnotationDriver",
"::",
"class",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.cachedReader'",
")",
",",
"$",
"directory",
"]",
")",
";",
"$",
"driverChain",
"->",
"addSetup",
"(",
"'$service->addDriver(?, ?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'driver.'",
".",
"$",
"this",
"->",
"createServiceName",
"(",
"$",
"namespace",
")",
")",
",",
"$",
"namespace",
"]",
")",
";",
"}",
"}"
] |
Registers metadata drivers.
|
[
"Registers",
"metadata",
"drivers",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L106-L136
|
23,268
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.createServiceName
|
private function createServiceName(string $namespace)
{
$parts = explode('\\', $namespace);
foreach ($parts as $k => $part) {
$parts[$k] = lcfirst($part);
}
return trim(implode('.', $parts), '.');
}
|
php
|
private function createServiceName(string $namespace)
{
$parts = explode('\\', $namespace);
foreach ($parts as $k => $part) {
$parts[$k] = lcfirst($part);
}
return trim(implode('.', $parts), '.');
}
|
[
"private",
"function",
"createServiceName",
"(",
"string",
"$",
"namespace",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"namespace",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"k",
"=>",
"$",
"part",
")",
"{",
"$",
"parts",
"[",
"$",
"k",
"]",
"=",
"lcfirst",
"(",
"$",
"part",
")",
";",
"}",
"return",
"trim",
"(",
"implode",
"(",
"'.'",
",",
"$",
"parts",
")",
",",
"'.'",
")",
";",
"}"
] |
Converts PHP namespace to service name.
|
[
"Converts",
"PHP",
"namespace",
"to",
"service",
"name",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L142-L149
|
23,269
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processConnection
|
private function processConnection()
{
$builder = $this->getContainerBuilder();
$connection = $builder->addDefinition($this->prefix('connection'))
->setClass(Connection::class)
->setFactory(DriverManager::class . '::getConnection', [$this->config['connection']]);
}
|
php
|
private function processConnection()
{
$builder = $this->getContainerBuilder();
$connection = $builder->addDefinition($this->prefix('connection'))
->setClass(Connection::class)
->setFactory(DriverManager::class . '::getConnection', [$this->config['connection']]);
}
|
[
"private",
"function",
"processConnection",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"connection",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'connection'",
")",
")",
"->",
"setClass",
"(",
"Connection",
"::",
"class",
")",
"->",
"setFactory",
"(",
"DriverManager",
"::",
"class",
".",
"'::getConnection'",
",",
"[",
"$",
"this",
"->",
"config",
"[",
"'connection'",
"]",
"]",
")",
";",
"}"
] |
Registers DBAL connection.
|
[
"Registers",
"DBAL",
"connection",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L155-L162
|
23,270
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processEvents
|
private function processEvents()
{
$builder = $this->getContainerBuilder();
$eventManager = $builder->addDefinition($this->prefix('eventManager'))
->setClass(EventManager::class);
$entityListenerResolver = $builder->addDefinition($this->prefix('entityListenerResolver'))
->setClass(ContainerEntityListenerResolver::class);
$rc = new \ReflectionClass(Events::class);
$events = $rc->getConstants();
foreach ($this->config['listeners'] as $event => $listeners) {
if (!isset($events[$event])) {
throw new InvalidStateException("Event '$event' is not valid doctrine event. See class "
. Events::class . ' for list of available events.');
}
foreach ((array) $listeners as $listener) {
$builder->getDefinition($this->prefix('eventManager'))->addSetup('$service->addEventListener(['
. Events::class . '::?], ?)', [$event, $listener]);
}
}
}
|
php
|
private function processEvents()
{
$builder = $this->getContainerBuilder();
$eventManager = $builder->addDefinition($this->prefix('eventManager'))
->setClass(EventManager::class);
$entityListenerResolver = $builder->addDefinition($this->prefix('entityListenerResolver'))
->setClass(ContainerEntityListenerResolver::class);
$rc = new \ReflectionClass(Events::class);
$events = $rc->getConstants();
foreach ($this->config['listeners'] as $event => $listeners) {
if (!isset($events[$event])) {
throw new InvalidStateException("Event '$event' is not valid doctrine event. See class "
. Events::class . ' for list of available events.');
}
foreach ((array) $listeners as $listener) {
$builder->getDefinition($this->prefix('eventManager'))->addSetup('$service->addEventListener(['
. Events::class . '::?], ?)', [$event, $listener]);
}
}
}
|
[
"private",
"function",
"processEvents",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"eventManager",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'eventManager'",
")",
")",
"->",
"setClass",
"(",
"EventManager",
"::",
"class",
")",
";",
"$",
"entityListenerResolver",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'entityListenerResolver'",
")",
")",
"->",
"setClass",
"(",
"ContainerEntityListenerResolver",
"::",
"class",
")",
";",
"$",
"rc",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"Events",
"::",
"class",
")",
";",
"$",
"events",
"=",
"$",
"rc",
"->",
"getConstants",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'listeners'",
"]",
"as",
"$",
"event",
"=>",
"$",
"listeners",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"events",
"[",
"$",
"event",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"\"Event '$event' is not valid doctrine event. See class \"",
".",
"Events",
"::",
"class",
".",
"' for list of available events.'",
")",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"builder",
"->",
"getDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'eventManager'",
")",
")",
"->",
"addSetup",
"(",
"'$service->addEventListener(['",
".",
"Events",
"::",
"class",
".",
"'::?], ?)'",
",",
"[",
"$",
"event",
",",
"$",
"listener",
"]",
")",
";",
"}",
"}",
"}"
] |
Registers Event Manager.
|
[
"Registers",
"Event",
"Manager",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L168-L191
|
23,271
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processEntityManager
|
private function processEntityManager()
{
$builder = $this->getContainerBuilder();
$configuration = $builder->addDefinition($this->prefix('configuration'))
->setClass(Configuration::class)
->addSetup('$service->setMetadataDriverImpl($this->getService(?))', [$this->prefix('metadata.driver')])
->addSetup('$service->setMetadataCacheImpl(?)', ['@' . $this->prefix('cache.metadata')])
->addSetup('$service->setQueryCacheImpl(?)', ['@' . $this->prefix('cache.query')])
->addSetup('$service->setResultCacheImpl(?)', ['@' . $this->prefix('cache.result')])
->addSetup('$service->setHydrationCacheImpl(?)', ['@' . $this->prefix('cache.hydration')])
->addSetup('$service->setProxyDir(?)', [$this->config['proxyDir']])
->addSetup('$service->setProxyNamespace(?)', [$this->config['proxyNamespace']])
->addSetup('$service->setNamingStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\UnderscoreNamingStrategy')])
->addSetup('$service->setQuoteStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\DefaultQuoteStrategy')])
->addSetup('$service->setAutoGenerateProxyClasses(?)', [1])
->addSetup('$service->setEntityListenerResolver(?)', ['@' . $this->prefix('entityListenerResolver')]);
$entityManager = $builder->addDefinition($this->prefix('entityManager'))
->setClass(EntityManager::class)
->setFactory(EntityManager::class . '::create', [
'@' . $this->prefix('connection'),
'@' . $this->prefix('configuration'),
'@' . $this->prefix('eventManager')
]);
}
|
php
|
private function processEntityManager()
{
$builder = $this->getContainerBuilder();
$configuration = $builder->addDefinition($this->prefix('configuration'))
->setClass(Configuration::class)
->addSetup('$service->setMetadataDriverImpl($this->getService(?))', [$this->prefix('metadata.driver')])
->addSetup('$service->setMetadataCacheImpl(?)', ['@' . $this->prefix('cache.metadata')])
->addSetup('$service->setQueryCacheImpl(?)', ['@' . $this->prefix('cache.query')])
->addSetup('$service->setResultCacheImpl(?)', ['@' . $this->prefix('cache.result')])
->addSetup('$service->setHydrationCacheImpl(?)', ['@' . $this->prefix('cache.hydration')])
->addSetup('$service->setProxyDir(?)', [$this->config['proxyDir']])
->addSetup('$service->setProxyNamespace(?)', [$this->config['proxyNamespace']])
->addSetup('$service->setNamingStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\UnderscoreNamingStrategy')])
->addSetup('$service->setQuoteStrategy(?)', [new \Nette\DI\Statement('Doctrine\ORM\Mapping\DefaultQuoteStrategy')])
->addSetup('$service->setAutoGenerateProxyClasses(?)', [1])
->addSetup('$service->setEntityListenerResolver(?)', ['@' . $this->prefix('entityListenerResolver')]);
$entityManager = $builder->addDefinition($this->prefix('entityManager'))
->setClass(EntityManager::class)
->setFactory(EntityManager::class . '::create', [
'@' . $this->prefix('connection'),
'@' . $this->prefix('configuration'),
'@' . $this->prefix('eventManager')
]);
}
|
[
"private",
"function",
"processEntityManager",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"configuration",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'configuration'",
")",
")",
"->",
"setClass",
"(",
"Configuration",
"::",
"class",
")",
"->",
"addSetup",
"(",
"'$service->setMetadataDriverImpl($this->getService(?))'",
",",
"[",
"$",
"this",
"->",
"prefix",
"(",
"'metadata.driver'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setMetadataCacheImpl(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'cache.metadata'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setQueryCacheImpl(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'cache.query'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setResultCacheImpl(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'cache.result'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setHydrationCacheImpl(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'cache.hydration'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setProxyDir(?)'",
",",
"[",
"$",
"this",
"->",
"config",
"[",
"'proxyDir'",
"]",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setProxyNamespace(?)'",
",",
"[",
"$",
"this",
"->",
"config",
"[",
"'proxyNamespace'",
"]",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setNamingStrategy(?)'",
",",
"[",
"new",
"\\",
"Nette",
"\\",
"DI",
"\\",
"Statement",
"(",
"'Doctrine\\ORM\\Mapping\\UnderscoreNamingStrategy'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setQuoteStrategy(?)'",
",",
"[",
"new",
"\\",
"Nette",
"\\",
"DI",
"\\",
"Statement",
"(",
"'Doctrine\\ORM\\Mapping\\DefaultQuoteStrategy'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setAutoGenerateProxyClasses(?)'",
",",
"[",
"1",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setEntityListenerResolver(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'entityListenerResolver'",
")",
"]",
")",
";",
"$",
"entityManager",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'entityManager'",
")",
")",
"->",
"setClass",
"(",
"EntityManager",
"::",
"class",
")",
"->",
"setFactory",
"(",
"EntityManager",
"::",
"class",
".",
"'::create'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'connection'",
")",
",",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'configuration'",
")",
",",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'eventManager'",
")",
"]",
")",
";",
"}"
] |
Registers Entity Manager.
|
[
"Registers",
"Entity",
"Manager",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L197-L222
|
23,272
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processCachingServices
|
private function processCachingServices()
{
$this->createCache('annotations');
$this->createCache('metadata');
$this->createCache('query');
$this->createCache('result');
$this->createCache('hydration');
}
|
php
|
private function processCachingServices()
{
$this->createCache('annotations');
$this->createCache('metadata');
$this->createCache('query');
$this->createCache('result');
$this->createCache('hydration');
}
|
[
"private",
"function",
"processCachingServices",
"(",
")",
"{",
"$",
"this",
"->",
"createCache",
"(",
"'annotations'",
")",
";",
"$",
"this",
"->",
"createCache",
"(",
"'metadata'",
")",
";",
"$",
"this",
"->",
"createCache",
"(",
"'query'",
")",
";",
"$",
"this",
"->",
"createCache",
"(",
"'result'",
")",
";",
"$",
"this",
"->",
"createCache",
"(",
"'hydration'",
")",
";",
"}"
] |
Registers caching services.
|
[
"Registers",
"caching",
"services",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L228-L235
|
23,273
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.createCache
|
private function createCache(string $name)
{
$builder = $this->getContainerBuilder();
$cache = $builder->addDefinition($this->prefix('cache.' . $name))
->setClass(Cache::class)
->setArguments(['@Nette\Caching\IStorage', $this->debugMode])
->addSetup('$service->setNamespace(?)', [$this->prefix('cache.' . $name)]);
return $cache;
}
|
php
|
private function createCache(string $name)
{
$builder = $this->getContainerBuilder();
$cache = $builder->addDefinition($this->prefix('cache.' . $name))
->setClass(Cache::class)
->setArguments(['@Nette\Caching\IStorage', $this->debugMode])
->addSetup('$service->setNamespace(?)', [$this->prefix('cache.' . $name)]);
return $cache;
}
|
[
"private",
"function",
"createCache",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"cache",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'cache.'",
".",
"$",
"name",
")",
")",
"->",
"setClass",
"(",
"Cache",
"::",
"class",
")",
"->",
"setArguments",
"(",
"[",
"'@Nette\\Caching\\IStorage'",
",",
"$",
"this",
"->",
"debugMode",
"]",
")",
"->",
"addSetup",
"(",
"'$service->setNamespace(?)'",
",",
"[",
"$",
"this",
"->",
"prefix",
"(",
"'cache.'",
".",
"$",
"name",
")",
"]",
")",
";",
"return",
"$",
"cache",
";",
"}"
] |
Creates a caching service.
|
[
"Creates",
"a",
"caching",
"service",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L241-L251
|
23,274
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processConsole
|
private function processConsole()
{
$builder = $this->getContainerBuilder();
$console = $builder->addDefinition($this->prefix('console'))
->setClass(Application::class)
->setArguments(['Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION])
->addSetup('?->setCatchExceptions(TRUE)', ['@self'])
->addSetup('$helperSet = ' . ConsoleRunner::class . '::createHelperSet(?)', ['@' . $this->prefix('entityManager')])
->addSetup('$helperSet->set(new \Andromeda\Doctrine\Console\Helpers\ContainerHelper(?), ?)', ['@Nette\DI\Container', 'container'])
->addSetup('?->setHelperSet($helperSet)', ['@self'])
->addSetup(ConsoleRunner::class . '::addCommands(?)', ['@self']);
$commands = array_merge([
Commands\SchemaCreateCommand::class,
Commands\SchemaUpdateCommand::class,
Commands\SchemaDropCommand::class
], $this->config['commands']);
foreach ($commands as $command) {
$console->addSetup('?->add(?)', ['@self', new Nette\DI\Statement($command)]);
}
}
|
php
|
private function processConsole()
{
$builder = $this->getContainerBuilder();
$console = $builder->addDefinition($this->prefix('console'))
->setClass(Application::class)
->setArguments(['Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION])
->addSetup('?->setCatchExceptions(TRUE)', ['@self'])
->addSetup('$helperSet = ' . ConsoleRunner::class . '::createHelperSet(?)', ['@' . $this->prefix('entityManager')])
->addSetup('$helperSet->set(new \Andromeda\Doctrine\Console\Helpers\ContainerHelper(?), ?)', ['@Nette\DI\Container', 'container'])
->addSetup('?->setHelperSet($helperSet)', ['@self'])
->addSetup(ConsoleRunner::class . '::addCommands(?)', ['@self']);
$commands = array_merge([
Commands\SchemaCreateCommand::class,
Commands\SchemaUpdateCommand::class,
Commands\SchemaDropCommand::class
], $this->config['commands']);
foreach ($commands as $command) {
$console->addSetup('?->add(?)', ['@self', new Nette\DI\Statement($command)]);
}
}
|
[
"private",
"function",
"processConsole",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"console",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'console'",
")",
")",
"->",
"setClass",
"(",
"Application",
"::",
"class",
")",
"->",
"setArguments",
"(",
"[",
"'Doctrine Command Line Interface'",
",",
"\\",
"Doctrine",
"\\",
"ORM",
"\\",
"Version",
"::",
"VERSION",
"]",
")",
"->",
"addSetup",
"(",
"'?->setCatchExceptions(TRUE)'",
",",
"[",
"'@self'",
"]",
")",
"->",
"addSetup",
"(",
"'$helperSet = '",
".",
"ConsoleRunner",
"::",
"class",
".",
"'::createHelperSet(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'entityManager'",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$helperSet->set(new \\Andromeda\\Doctrine\\Console\\Helpers\\ContainerHelper(?), ?)'",
",",
"[",
"'@Nette\\DI\\Container'",
",",
"'container'",
"]",
")",
"->",
"addSetup",
"(",
"'?->setHelperSet($helperSet)'",
",",
"[",
"'@self'",
"]",
")",
"->",
"addSetup",
"(",
"ConsoleRunner",
"::",
"class",
".",
"'::addCommands(?)'",
",",
"[",
"'@self'",
"]",
")",
";",
"$",
"commands",
"=",
"array_merge",
"(",
"[",
"Commands",
"\\",
"SchemaCreateCommand",
"::",
"class",
",",
"Commands",
"\\",
"SchemaUpdateCommand",
"::",
"class",
",",
"Commands",
"\\",
"SchemaDropCommand",
"::",
"class",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'commands'",
"]",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"command",
")",
"{",
"$",
"console",
"->",
"addSetup",
"(",
"'?->add(?)'",
",",
"[",
"'@self'",
",",
"new",
"Nette",
"\\",
"DI",
"\\",
"Statement",
"(",
"$",
"command",
")",
"]",
")",
";",
"}",
"}"
] |
Registers Doctrine Console.
|
[
"Registers",
"Doctrine",
"Console",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L257-L279
|
23,275
|
andromeda-framework/doctrine
|
src/Doctrine/DI/DoctrineExtension.php
|
DoctrineExtension.processTracy
|
private function processTracy()
{
$builder = $this->getContainerBuilder();
$tracyPanel = $builder->addDefinition($this->prefix('tracyPanel'))
->setClass(Panel::class);
$builder->getDefinition($this->prefix('entityManager'))
->addSetup('?->setEntityManager(?)', ['@' . $this->prefix('tracyPanel'), '@self']);
}
|
php
|
private function processTracy()
{
$builder = $this->getContainerBuilder();
$tracyPanel = $builder->addDefinition($this->prefix('tracyPanel'))
->setClass(Panel::class);
$builder->getDefinition($this->prefix('entityManager'))
->addSetup('?->setEntityManager(?)', ['@' . $this->prefix('tracyPanel'), '@self']);
}
|
[
"private",
"function",
"processTracy",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"tracyPanel",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'tracyPanel'",
")",
")",
"->",
"setClass",
"(",
"Panel",
"::",
"class",
")",
";",
"$",
"builder",
"->",
"getDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'entityManager'",
")",
")",
"->",
"addSetup",
"(",
"'?->setEntityManager(?)'",
",",
"[",
"'@'",
".",
"$",
"this",
"->",
"prefix",
"(",
"'tracyPanel'",
")",
",",
"'@self'",
"]",
")",
";",
"}"
] |
Registers debug panel.
|
[
"Registers",
"debug",
"panel",
"."
] |
46924d91c09e0b9fbe5764518cbad70e467ffad4
|
https://github.com/andromeda-framework/doctrine/blob/46924d91c09e0b9fbe5764518cbad70e467ffad4/src/Doctrine/DI/DoctrineExtension.php#L285-L294
|
23,276
|
antaresproject/notifications
|
src/Processor/LogsProcessor.php
|
LogsProcessor.preview
|
public function preview($id)
{
$item = app(StackRepository::class)->fetchOne((int) $id)->firstOrFail();
if (in_array($item->notification->type->name, ['email', 'sms'])) {
$classname = $item->notification->type->name === 'email' ? EmailNotification::class : SmsNotification::class;
$notification = app($classname);
$notification->setModel($item);
return view('antares/notifications::admin.logs.preview', ['content' => $notification->render()]);
}
$decorator = app(SidebarItemDecorator::class);
$decorated = $decorator->item($item, config('antares/notifications::templates.notification'));
return new JsonResponse(['content' => $decorated], 200);
}
|
php
|
public function preview($id)
{
$item = app(StackRepository::class)->fetchOne((int) $id)->firstOrFail();
if (in_array($item->notification->type->name, ['email', 'sms'])) {
$classname = $item->notification->type->name === 'email' ? EmailNotification::class : SmsNotification::class;
$notification = app($classname);
$notification->setModel($item);
return view('antares/notifications::admin.logs.preview', ['content' => $notification->render()]);
}
$decorator = app(SidebarItemDecorator::class);
$decorated = $decorator->item($item, config('antares/notifications::templates.notification'));
return new JsonResponse(['content' => $decorated], 200);
}
|
[
"public",
"function",
"preview",
"(",
"$",
"id",
")",
"{",
"$",
"item",
"=",
"app",
"(",
"StackRepository",
"::",
"class",
")",
"->",
"fetchOne",
"(",
"(",
"int",
")",
"$",
"id",
")",
"->",
"firstOrFail",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"item",
"->",
"notification",
"->",
"type",
"->",
"name",
",",
"[",
"'email'",
",",
"'sms'",
"]",
")",
")",
"{",
"$",
"classname",
"=",
"$",
"item",
"->",
"notification",
"->",
"type",
"->",
"name",
"===",
"'email'",
"?",
"EmailNotification",
"::",
"class",
":",
"SmsNotification",
"::",
"class",
";",
"$",
"notification",
"=",
"app",
"(",
"$",
"classname",
")",
";",
"$",
"notification",
"->",
"setModel",
"(",
"$",
"item",
")",
";",
"return",
"view",
"(",
"'antares/notifications::admin.logs.preview'",
",",
"[",
"'content'",
"=>",
"$",
"notification",
"->",
"render",
"(",
")",
"]",
")",
";",
"}",
"$",
"decorator",
"=",
"app",
"(",
"SidebarItemDecorator",
"::",
"class",
")",
";",
"$",
"decorated",
"=",
"$",
"decorator",
"->",
"item",
"(",
"$",
"item",
",",
"config",
"(",
"'antares/notifications::templates.notification'",
")",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'content'",
"=>",
"$",
"decorated",
"]",
",",
"200",
")",
";",
"}"
] |
Preview notification log
@param mixed $id
@return View
|
[
"Preview",
"notification",
"log"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/LogsProcessor.php#L92-L106
|
23,277
|
antaresproject/notifications
|
src/Processor/LogsProcessor.php
|
LogsProcessor.delete
|
public function delete(LogsListener $listener, $id = null): RedirectResponse
{
$stack = !empty($ids = input('attr')) ? $this->stack->newQuery()->whereIn('id', $ids) : $this->stack->newQuery()->findOrFail($id);
if ($stack->delete()) {
return $listener->deleteSuccess();
}
return $listener->deleteFailed();
}
|
php
|
public function delete(LogsListener $listener, $id = null): RedirectResponse
{
$stack = !empty($ids = input('attr')) ? $this->stack->newQuery()->whereIn('id', $ids) : $this->stack->newQuery()->findOrFail($id);
if ($stack->delete()) {
return $listener->deleteSuccess();
}
return $listener->deleteFailed();
}
|
[
"public",
"function",
"delete",
"(",
"LogsListener",
"$",
"listener",
",",
"$",
"id",
"=",
"null",
")",
":",
"RedirectResponse",
"{",
"$",
"stack",
"=",
"!",
"empty",
"(",
"$",
"ids",
"=",
"input",
"(",
"'attr'",
")",
")",
"?",
"$",
"this",
"->",
"stack",
"->",
"newQuery",
"(",
")",
"->",
"whereIn",
"(",
"'id'",
",",
"$",
"ids",
")",
":",
"$",
"this",
"->",
"stack",
"->",
"newQuery",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"stack",
"->",
"delete",
"(",
")",
")",
"{",
"return",
"$",
"listener",
"->",
"deleteSuccess",
"(",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"deleteFailed",
"(",
")",
";",
"}"
] |
Deletes notification log
@param LogsListener $listener
@param mixed $id
@return RedirectResponse
|
[
"Deletes",
"notification",
"log"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/LogsProcessor.php#L115-L122
|
23,278
|
surebert/surebert-framework
|
src/sb/PDO/Mysql/Backup.php
|
Backup.checkDumpDir
|
protected function checkDumpDir()
{
if (!is_dir($this->dump_dir)) {
mkdir($this->dump_dir, 0700, true);
}
foreach (\range($this->max_version, 1) as $version) {
$dir = $this->dump_dir . $version;
if (is_dir($dir)) {
if ($version == $this->max_version) {
$this->recursiveDelete($dir, 1);
$this->log('Deleting backup ' . $this->max_version);
} else {
$new_version = $version + 1;
rename($dir, $this->dump_dir . $new_version);
$this->log('Moving backup ' . $version . ' to version ' . $new_version);
}
}
}
if (!is_dir($this->dump_dir . '1')) {
mkdir($this->dump_dir . '1', 0700, true);
}
}
|
php
|
protected function checkDumpDir()
{
if (!is_dir($this->dump_dir)) {
mkdir($this->dump_dir, 0700, true);
}
foreach (\range($this->max_version, 1) as $version) {
$dir = $this->dump_dir . $version;
if (is_dir($dir)) {
if ($version == $this->max_version) {
$this->recursiveDelete($dir, 1);
$this->log('Deleting backup ' . $this->max_version);
} else {
$new_version = $version + 1;
rename($dir, $this->dump_dir . $new_version);
$this->log('Moving backup ' . $version . ' to version ' . $new_version);
}
}
}
if (!is_dir($this->dump_dir . '1')) {
mkdir($this->dump_dir . '1', 0700, true);
}
}
|
[
"protected",
"function",
"checkDumpDir",
"(",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"dump_dir",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"dump_dir",
",",
"0700",
",",
"true",
")",
";",
"}",
"foreach",
"(",
"\\",
"range",
"(",
"$",
"this",
"->",
"max_version",
",",
"1",
")",
"as",
"$",
"version",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"dump_dir",
".",
"$",
"version",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"if",
"(",
"$",
"version",
"==",
"$",
"this",
"->",
"max_version",
")",
"{",
"$",
"this",
"->",
"recursiveDelete",
"(",
"$",
"dir",
",",
"1",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Deleting backup '",
".",
"$",
"this",
"->",
"max_version",
")",
";",
"}",
"else",
"{",
"$",
"new_version",
"=",
"$",
"version",
"+",
"1",
";",
"rename",
"(",
"$",
"dir",
",",
"$",
"this",
"->",
"dump_dir",
".",
"$",
"new_version",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Moving backup '",
".",
"$",
"version",
".",
"' to version '",
".",
"$",
"new_version",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"dump_dir",
".",
"'1'",
")",
")",
"{",
"mkdir",
"(",
"$",
"this",
"->",
"dump_dir",
".",
"'1'",
",",
"0700",
",",
"true",
")",
";",
"}",
"}"
] |
check to make sure dump directory exists and if not create it
|
[
"check",
"to",
"make",
"sure",
"dump",
"directory",
"exists",
"and",
"if",
"not",
"create",
"it"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Mysql/Backup.php#L129-L155
|
23,279
|
surebert/surebert-framework
|
src/sb/PDO/Mysql/Backup.php
|
Backup.dumpDatabases
|
protected function dumpDatabases()
{
foreach ($this->db->query("SHOW DATABASES") as $list) {
$database = $list->Database;
if (!in_array($database, $this->ignore) || preg_match("~_no_backup$~", $database)) {
$start = microtime(true);
$dir = $this->dump_dir . '1/';
$filename = $dir . $database;
$this->log("Dumping Database: " . $database);
$command = "mysqldump -u " . $this->db_user . " -h "
. $this->db_host . " -p" . $this->db_pass . " "
. $database . ">" . $filename . ".sql";
exec($command);
$command = "tar -zcvf " . $filename . ".gz " . $filename . ".sql";
exec($command);
$ms = round((microtime(true) - $start) * 1000, 2);
clearstatcache();
$size = round((filesize($filename . '.gz') / 1024), 2) . 'kb';
$this->log($list->Database . " was backed up in " . $ms . ' ms and is ' . $size . ' bytes');
unlink($filename . '.sql');
}
}
}
|
php
|
protected function dumpDatabases()
{
foreach ($this->db->query("SHOW DATABASES") as $list) {
$database = $list->Database;
if (!in_array($database, $this->ignore) || preg_match("~_no_backup$~", $database)) {
$start = microtime(true);
$dir = $this->dump_dir . '1/';
$filename = $dir . $database;
$this->log("Dumping Database: " . $database);
$command = "mysqldump -u " . $this->db_user . " -h "
. $this->db_host . " -p" . $this->db_pass . " "
. $database . ">" . $filename . ".sql";
exec($command);
$command = "tar -zcvf " . $filename . ".gz " . $filename . ".sql";
exec($command);
$ms = round((microtime(true) - $start) * 1000, 2);
clearstatcache();
$size = round((filesize($filename . '.gz') / 1024), 2) . 'kb';
$this->log($list->Database . " was backed up in " . $ms . ' ms and is ' . $size . ' bytes');
unlink($filename . '.sql');
}
}
}
|
[
"protected",
"function",
"dumpDatabases",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"SHOW DATABASES\"",
")",
"as",
"$",
"list",
")",
"{",
"$",
"database",
"=",
"$",
"list",
"->",
"Database",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"database",
",",
"$",
"this",
"->",
"ignore",
")",
"||",
"preg_match",
"(",
"\"~_no_backup$~\"",
",",
"$",
"database",
")",
")",
"{",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"dir",
"=",
"$",
"this",
"->",
"dump_dir",
".",
"'1/'",
";",
"$",
"filename",
"=",
"$",
"dir",
".",
"$",
"database",
";",
"$",
"this",
"->",
"log",
"(",
"\"Dumping Database: \"",
".",
"$",
"database",
")",
";",
"$",
"command",
"=",
"\"mysqldump -u \"",
".",
"$",
"this",
"->",
"db_user",
".",
"\" -h \"",
".",
"$",
"this",
"->",
"db_host",
".",
"\" -p\"",
".",
"$",
"this",
"->",
"db_pass",
".",
"\" \"",
".",
"$",
"database",
".",
"\">\"",
".",
"$",
"filename",
".",
"\".sql\"",
";",
"exec",
"(",
"$",
"command",
")",
";",
"$",
"command",
"=",
"\"tar -zcvf \"",
".",
"$",
"filename",
".",
"\".gz \"",
".",
"$",
"filename",
".",
"\".sql\"",
";",
"exec",
"(",
"$",
"command",
")",
";",
"$",
"ms",
"=",
"round",
"(",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"start",
")",
"*",
"1000",
",",
"2",
")",
";",
"clearstatcache",
"(",
")",
";",
"$",
"size",
"=",
"round",
"(",
"(",
"filesize",
"(",
"$",
"filename",
".",
"'.gz'",
")",
"/",
"1024",
")",
",",
"2",
")",
".",
"'kb'",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"list",
"->",
"Database",
".",
"\" was backed up in \"",
".",
"$",
"ms",
".",
"' ms and is '",
".",
"$",
"size",
".",
"' bytes'",
")",
";",
"unlink",
"(",
"$",
"filename",
".",
"'.sql'",
")",
";",
"}",
"}",
"}"
] |
Dump the database files and gzip, add version number
|
[
"Dump",
"the",
"database",
"files",
"and",
"gzip",
"add",
"version",
"number"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Mysql/Backup.php#L160-L191
|
23,280
|
surebert/surebert-framework
|
src/sb/PDO/Mysql/Backup.php
|
Backup.log
|
protected function log($message)
{
if ($this->debug == true) {
file_put_contents("php://stdout", $message . "\n");
}
file_put_contents($this->dump_dir . 'dump.log', $message . "\n", \FILE_APPEND);
}
|
php
|
protected function log($message)
{
if ($this->debug == true) {
file_put_contents("php://stdout", $message . "\n");
}
file_put_contents($this->dump_dir . 'dump.log', $message . "\n", \FILE_APPEND);
}
|
[
"protected",
"function",
"log",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
"==",
"true",
")",
"{",
"file_put_contents",
"(",
"\"php://stdout\"",
",",
"$",
"message",
".",
"\"\\n\"",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"dump_dir",
".",
"'dump.log'",
",",
"$",
"message",
".",
"\"\\n\"",
",",
"\\",
"FILE_APPEND",
")",
";",
"}"
] |
Send messages to stdout
@param string $message
|
[
"Send",
"messages",
"to",
"stdout"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Mysql/Backup.php#L197-L205
|
23,281
|
surebert/surebert-framework
|
src/sb/PDO/Mysql/Backup.php
|
Backup.recursiveDelete
|
protected function recursiveDelete($dir, $del = 0)
{
if (substr($dir, 0, 1) == '/') {
throw new \Exception("You cannot delete root directories");
}
$iterator = new \RecursiveDirectoryIterator($dir);
foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
$name = $file->getFilename();
if ($file->isDir() && $name != '.' && $name != '..') {
rmdir($file->getPathname());
} elseif ($file->isFile()) {
unlink($file->getPathname());
}
}
if ($del == 1) {
rmdir($dir);
}
}
|
php
|
protected function recursiveDelete($dir, $del = 0)
{
if (substr($dir, 0, 1) == '/') {
throw new \Exception("You cannot delete root directories");
}
$iterator = new \RecursiveDirectoryIterator($dir);
foreach (new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
$name = $file->getFilename();
if ($file->isDir() && $name != '.' && $name != '..') {
rmdir($file->getPathname());
} elseif ($file->isFile()) {
unlink($file->getPathname());
}
}
if ($del == 1) {
rmdir($dir);
}
}
|
[
"protected",
"function",
"recursiveDelete",
"(",
"$",
"dir",
",",
"$",
"del",
"=",
"0",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"dir",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"You cannot delete root directories\"",
")",
";",
"}",
"$",
"iterator",
"=",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"$",
"iterator",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"CHILD_FIRST",
")",
"as",
"$",
"file",
")",
"{",
"$",
"name",
"=",
"$",
"file",
"->",
"getFilename",
"(",
")",
";",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"$",
"name",
"!=",
"'.'",
"&&",
"$",
"name",
"!=",
"'..'",
")",
"{",
"rmdir",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"unlink",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"del",
"==",
"1",
")",
"{",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}",
"}"
] |
Recursively deletes the files in a diretory
@param string $dir The directory path
@param boolean $del Should directory itself be deleted upon completion
@return boolean
|
[
"Recursively",
"deletes",
"the",
"files",
"in",
"a",
"diretory"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/PDO/Mysql/Backup.php#L214-L234
|
23,282
|
Isset/pushnotification
|
src/PushNotification/NotificationCenter.php
|
NotificationCenter.addNotifier
|
public function addNotifier(Notifier $notifier, bool $setLogger = true)
{
if ($notifier instanceof self) {
throw new LogicException('Cannot add self');
}
if ($setLogger) {
$notifier->setLogger($this->getLogger());
}
$this->notifiers[] = $notifier;
}
|
php
|
public function addNotifier(Notifier $notifier, bool $setLogger = true)
{
if ($notifier instanceof self) {
throw new LogicException('Cannot add self');
}
if ($setLogger) {
$notifier->setLogger($this->getLogger());
}
$this->notifiers[] = $notifier;
}
|
[
"public",
"function",
"addNotifier",
"(",
"Notifier",
"$",
"notifier",
",",
"bool",
"$",
"setLogger",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"notifier",
"instanceof",
"self",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Cannot add self'",
")",
";",
"}",
"if",
"(",
"$",
"setLogger",
")",
"{",
"$",
"notifier",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"notifiers",
"[",
"]",
"=",
"$",
"notifier",
";",
"}"
] |
Add a notifier to the Notification center.
@param Notifier $notifier
@param bool $setLogger if false the default logger will not be set to the notifier
@throws LogicException
|
[
"Add",
"a",
"notifier",
"to",
"the",
"Notification",
"center",
"."
] |
5e7634dc6b1cf4f7c371d1890243a25252db0d85
|
https://github.com/Isset/pushnotification/blob/5e7634dc6b1cf4f7c371d1890243a25252db0d85/src/PushNotification/NotificationCenter.php#L89-L99
|
23,283
|
eghojansu/moe
|
src/Base.php
|
Base.devoid
|
function devoid($key) {
$val=$this->ref($key,FALSE);
return empty($val) &&
(!Cache::instance()->exists($this->hash($key).'.var',$val) ||
!$val);
}
|
php
|
function devoid($key) {
$val=$this->ref($key,FALSE);
return empty($val) &&
(!Cache::instance()->exists($this->hash($key).'.var',$val) ||
!$val);
}
|
[
"function",
"devoid",
"(",
"$",
"key",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"ref",
"(",
"$",
"key",
",",
"FALSE",
")",
";",
"return",
"empty",
"(",
"$",
"val",
")",
"&&",
"(",
"!",
"Cache",
"::",
"instance",
"(",
")",
"->",
"exists",
"(",
"$",
"this",
"->",
"hash",
"(",
"$",
"key",
")",
".",
"'.var'",
",",
"$",
"val",
")",
"||",
"!",
"$",
"val",
")",
";",
"}"
] |
Return TRUE if hive key is empty and not cached
@return bool
@param $key string
|
[
"Return",
"TRUE",
"if",
"hive",
"key",
"is",
"empty",
"and",
"not",
"cached"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L284-L289
|
23,284
|
eghojansu/moe
|
src/Base.php
|
Base.get
|
function get($key,$args=NULL) {
if (is_string($val=$this->ref($key,FALSE)) && !is_null($args))
return call_user_func_array(
array($this,'format'),
array_merge(array($val),is_array($args)?$args:array($args))
);
if (is_null($val)) {
// Attempt to retrieve from cache
if (Cache::instance()->exists($this->hash($key).'.var',$data))
return $data;
}
return $val;
}
|
php
|
function get($key,$args=NULL) {
if (is_string($val=$this->ref($key,FALSE)) && !is_null($args))
return call_user_func_array(
array($this,'format'),
array_merge(array($val),is_array($args)?$args:array($args))
);
if (is_null($val)) {
// Attempt to retrieve from cache
if (Cache::instance()->exists($this->hash($key).'.var',$data))
return $data;
}
return $val;
}
|
[
"function",
"get",
"(",
"$",
"key",
",",
"$",
"args",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"val",
"=",
"$",
"this",
"->",
"ref",
"(",
"$",
"key",
",",
"FALSE",
")",
")",
"&&",
"!",
"is_null",
"(",
"$",
"args",
")",
")",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"'format'",
")",
",",
"array_merge",
"(",
"array",
"(",
"$",
"val",
")",
",",
"is_array",
"(",
"$",
"args",
")",
"?",
"$",
"args",
":",
"array",
"(",
"$",
"args",
")",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"val",
")",
")",
"{",
"// Attempt to retrieve from cache",
"if",
"(",
"Cache",
"::",
"instance",
"(",
")",
"->",
"exists",
"(",
"$",
"this",
"->",
"hash",
"(",
"$",
"key",
")",
".",
"'.var'",
",",
"$",
"data",
")",
")",
"return",
"$",
"data",
";",
"}",
"return",
"$",
"val",
";",
"}"
] |
Retrieve contents of hive key
@return mixed
@param $key string
@param $args string|array
|
[
"Retrieve",
"contents",
"of",
"hive",
"key"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L358-L370
|
23,285
|
eghojansu/moe
|
src/Base.php
|
Base.pre
|
function pre($data, $exit = false)
{
echo '<pre>';
print_r($data);
echo '</pre>';
!$exit || exit(str_repeat('<br>', 2).' '.$exit);
echo '<hr>';
}
|
php
|
function pre($data, $exit = false)
{
echo '<pre>';
print_r($data);
echo '</pre>';
!$exit || exit(str_repeat('<br>', 2).' '.$exit);
echo '<hr>';
}
|
[
"function",
"pre",
"(",
"$",
"data",
",",
"$",
"exit",
"=",
"false",
")",
"{",
"echo",
"'<pre>'",
";",
"print_r",
"(",
"$",
"data",
")",
";",
"echo",
"'</pre>'",
";",
"!",
"$",
"exit",
"||",
"exit",
"(",
"str_repeat",
"(",
"'<br>'",
",",
"2",
")",
".",
"' '",
".",
"$",
"exit",
")",
";",
"echo",
"'<hr>'",
";",
"}"
] |
Output the data
@param mixed $data
@param bool $exit wether to exit after dumping or not
|
[
"Output",
"the",
"data"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L654-L661
|
23,286
|
eghojansu/moe
|
src/Base.php
|
Base.constants
|
function constants($class,$prefix='') {
$ref=new ReflectionClass($class);
$out=array();
foreach (preg_grep('/^'.$prefix.'/',array_keys($ref->getconstants()))
as $val) {
$out[$key=substr($val,strlen($prefix))]=
constant((is_object($class)?get_class($class):$class).'::'.$prefix.$key);
}
unset($ref);
return $out;
}
|
php
|
function constants($class,$prefix='') {
$ref=new ReflectionClass($class);
$out=array();
foreach (preg_grep('/^'.$prefix.'/',array_keys($ref->getconstants()))
as $val) {
$out[$key=substr($val,strlen($prefix))]=
constant((is_object($class)?get_class($class):$class).'::'.$prefix.$key);
}
unset($ref);
return $out;
}
|
[
"function",
"constants",
"(",
"$",
"class",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"preg_grep",
"(",
"'/^'",
".",
"$",
"prefix",
".",
"'/'",
",",
"array_keys",
"(",
"$",
"ref",
"->",
"getconstants",
"(",
")",
")",
")",
"as",
"$",
"val",
")",
"{",
"$",
"out",
"[",
"$",
"key",
"=",
"substr",
"(",
"$",
"val",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
"]",
"=",
"constant",
"(",
"(",
"is_object",
"(",
"$",
"class",
")",
"?",
"get_class",
"(",
"$",
"class",
")",
":",
"$",
"class",
")",
".",
"'::'",
".",
"$",
"prefix",
".",
"$",
"key",
")",
";",
"}",
"unset",
"(",
"$",
"ref",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
Convert class constants to array
@return array
@param $class object|string
@param $prefix string
|
[
"Convert",
"class",
"constants",
"to",
"array"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L827-L837
|
23,287
|
eghojansu/moe
|
src/Base.php
|
Base.recursive
|
function recursive($arg,$func,$stack=NULL) {
if ($stack) {
foreach ($stack as $node)
if ($arg===$node)
return $arg;
}
else
$stack=array();
switch (gettype($arg)) {
case 'object':
if (method_exists('ReflectionClass','iscloneable')) {
$ref=new ReflectionClass($arg);
if ($ref->iscloneable()) {
$arg=clone($arg);
$cast=is_a($arg,'IteratorAggregate')?
iterator_to_array($arg):get_object_vars($arg);
foreach ($cast as $key=>$val)
$arg->$key=$this->recursive(
$val,$func,array_merge($stack,array($arg)));
}
}
return $arg;
case 'array':
$copy=array();
foreach ($arg as $key=>$val)
$copy[$key]=$this->recursive($val,$func,
array_merge($stack,array($arg)));
return $copy;
}
return $func($arg);
}
|
php
|
function recursive($arg,$func,$stack=NULL) {
if ($stack) {
foreach ($stack as $node)
if ($arg===$node)
return $arg;
}
else
$stack=array();
switch (gettype($arg)) {
case 'object':
if (method_exists('ReflectionClass','iscloneable')) {
$ref=new ReflectionClass($arg);
if ($ref->iscloneable()) {
$arg=clone($arg);
$cast=is_a($arg,'IteratorAggregate')?
iterator_to_array($arg):get_object_vars($arg);
foreach ($cast as $key=>$val)
$arg->$key=$this->recursive(
$val,$func,array_merge($stack,array($arg)));
}
}
return $arg;
case 'array':
$copy=array();
foreach ($arg as $key=>$val)
$copy[$key]=$this->recursive($val,$func,
array_merge($stack,array($arg)));
return $copy;
}
return $func($arg);
}
|
[
"function",
"recursive",
"(",
"$",
"arg",
",",
"$",
"func",
",",
"$",
"stack",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"stack",
")",
"{",
"foreach",
"(",
"$",
"stack",
"as",
"$",
"node",
")",
"if",
"(",
"$",
"arg",
"===",
"$",
"node",
")",
"return",
"$",
"arg",
";",
"}",
"else",
"$",
"stack",
"=",
"array",
"(",
")",
";",
"switch",
"(",
"gettype",
"(",
"$",
"arg",
")",
")",
"{",
"case",
"'object'",
":",
"if",
"(",
"method_exists",
"(",
"'ReflectionClass'",
",",
"'iscloneable'",
")",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"arg",
")",
";",
"if",
"(",
"$",
"ref",
"->",
"iscloneable",
"(",
")",
")",
"{",
"$",
"arg",
"=",
"clone",
"(",
"$",
"arg",
")",
";",
"$",
"cast",
"=",
"is_a",
"(",
"$",
"arg",
",",
"'IteratorAggregate'",
")",
"?",
"iterator_to_array",
"(",
"$",
"arg",
")",
":",
"get_object_vars",
"(",
"$",
"arg",
")",
";",
"foreach",
"(",
"$",
"cast",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"$",
"arg",
"->",
"$",
"key",
"=",
"$",
"this",
"->",
"recursive",
"(",
"$",
"val",
",",
"$",
"func",
",",
"array_merge",
"(",
"$",
"stack",
",",
"array",
"(",
"$",
"arg",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"arg",
";",
"case",
"'array'",
":",
"$",
"copy",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arg",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"$",
"copy",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"recursive",
"(",
"$",
"val",
",",
"$",
"func",
",",
"array_merge",
"(",
"$",
"stack",
",",
"array",
"(",
"$",
"arg",
")",
")",
")",
";",
"return",
"$",
"copy",
";",
"}",
"return",
"$",
"func",
"(",
"$",
"arg",
")",
";",
"}"
] |
Invoke callback recursively for all data types
@return mixed
@param $arg mixed
@param $func callback
@param $stack array
|
[
"Invoke",
"callback",
"recursively",
"for",
"all",
"data",
"types"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L885-L915
|
23,288
|
eghojansu/moe
|
src/Base.php
|
Base.map
|
function map($url,$class,$ttl=0,$kbps=0) {
if (is_array($url)) {
foreach ($url as $item)
$this->map($item,$class,$ttl,$kbps);
return;
}
foreach (explode('|',self::VERBS) as $method)
$this->route($method.' '.$url,is_string($class)?
$class.'->'.$this->hive['PREMAP'].strtolower($method):
array($class,$this->hive['PREMAP'].strtolower($method)),
$ttl,$kbps);
}
|
php
|
function map($url,$class,$ttl=0,$kbps=0) {
if (is_array($url)) {
foreach ($url as $item)
$this->map($item,$class,$ttl,$kbps);
return;
}
foreach (explode('|',self::VERBS) as $method)
$this->route($method.' '.$url,is_string($class)?
$class.'->'.$this->hive['PREMAP'].strtolower($method):
array($class,$this->hive['PREMAP'].strtolower($method)),
$ttl,$kbps);
}
|
[
"function",
"map",
"(",
"$",
"url",
",",
"$",
"class",
",",
"$",
"ttl",
"=",
"0",
",",
"$",
"kbps",
"=",
"0",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"foreach",
"(",
"$",
"url",
"as",
"$",
"item",
")",
"$",
"this",
"->",
"map",
"(",
"$",
"item",
",",
"$",
"class",
",",
"$",
"ttl",
",",
"$",
"kbps",
")",
";",
"return",
";",
"}",
"foreach",
"(",
"explode",
"(",
"'|'",
",",
"self",
"::",
"VERBS",
")",
"as",
"$",
"method",
")",
"$",
"this",
"->",
"route",
"(",
"$",
"method",
".",
"' '",
".",
"$",
"url",
",",
"is_string",
"(",
"$",
"class",
")",
"?",
"$",
"class",
".",
"'->'",
".",
"$",
"this",
"->",
"hive",
"[",
"'PREMAP'",
"]",
".",
"strtolower",
"(",
"$",
"method",
")",
":",
"array",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"hive",
"[",
"'PREMAP'",
"]",
".",
"strtolower",
"(",
"$",
"method",
")",
")",
",",
"$",
"ttl",
",",
"$",
"kbps",
")",
";",
"}"
] |
Provide ReST interface by mapping HTTP verb to class method
@return NULL
@param $url string
@param $class string|object
@param $ttl int
@param $kbps int
|
[
"Provide",
"ReST",
"interface",
"by",
"mapping",
"HTTP",
"verb",
"to",
"class",
"method"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L1452-L1463
|
23,289
|
eghojansu/moe
|
src/Base.php
|
Base.highlight
|
function highlight($text) {
$out='';
$pre=FALSE;
$text=trim($text);
if (!preg_match('/^<\?php/',$text)) {
$text='<?php '.$text;
$pre=TRUE;
}
foreach (token_get_all($text) as $token)
if ($pre)
$pre=FALSE;
else
$out.='<span'.
(is_array($token)?
(' class="'.
substr(strtolower(token_name($token[0])),2).'">'.
$this->encode($token[1]).''):
('>'.$this->encode($token))).
'</span>';
return $out?('<code>'.$out.'</code>'):$text;
}
|
php
|
function highlight($text) {
$out='';
$pre=FALSE;
$text=trim($text);
if (!preg_match('/^<\?php/',$text)) {
$text='<?php '.$text;
$pre=TRUE;
}
foreach (token_get_all($text) as $token)
if ($pre)
$pre=FALSE;
else
$out.='<span'.
(is_array($token)?
(' class="'.
substr(strtolower(token_name($token[0])),2).'">'.
$this->encode($token[1]).''):
('>'.$this->encode($token))).
'</span>';
return $out?('<code>'.$out.'</code>'):$text;
}
|
[
"function",
"highlight",
"(",
"$",
"text",
")",
"{",
"$",
"out",
"=",
"''",
";",
"$",
"pre",
"=",
"FALSE",
";",
"$",
"text",
"=",
"trim",
"(",
"$",
"text",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^<\\?php/'",
",",
"$",
"text",
")",
")",
"{",
"$",
"text",
"=",
"'<?php '",
".",
"$",
"text",
";",
"$",
"pre",
"=",
"TRUE",
";",
"}",
"foreach",
"(",
"token_get_all",
"(",
"$",
"text",
")",
"as",
"$",
"token",
")",
"if",
"(",
"$",
"pre",
")",
"$",
"pre",
"=",
"FALSE",
";",
"else",
"$",
"out",
".=",
"'<span'",
".",
"(",
"is_array",
"(",
"$",
"token",
")",
"?",
"(",
"' class=\"'",
".",
"substr",
"(",
"strtolower",
"(",
"token_name",
"(",
"$",
"token",
"[",
"0",
"]",
")",
")",
",",
"2",
")",
".",
"'\">'",
".",
"$",
"this",
"->",
"encode",
"(",
"$",
"token",
"[",
"1",
"]",
")",
".",
"''",
")",
":",
"(",
"'>'",
".",
"$",
"this",
"->",
"encode",
"(",
"$",
"token",
")",
")",
")",
".",
"'</span>'",
";",
"return",
"$",
"out",
"?",
"(",
"'<code>'",
".",
"$",
"out",
".",
"'</code>'",
")",
":",
"$",
"text",
";",
"}"
] |
Apply syntax highlighting
@return string
@param $text string
|
[
"Apply",
"syntax",
"highlighting"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Base.php#L2062-L2082
|
23,290
|
chrismou/phergie-irc-plugin-react-google
|
src/Provider/GoogleSearch.php
|
GoogleSearch.getApiRequestUrl
|
public function getApiRequestUrl(Event $event)
{
$params = $event->getCustomParams();
$query = trim(implode(" ", $params));
$querystringParams = [
'v' => '1.0',
'q' => $query
];
return sprintf("%s?%s", $this->apiUrl, http_build_query($querystringParams));
}
|
php
|
public function getApiRequestUrl(Event $event)
{
$params = $event->getCustomParams();
$query = trim(implode(" ", $params));
$querystringParams = [
'v' => '1.0',
'q' => $query
];
return sprintf("%s?%s", $this->apiUrl, http_build_query($querystringParams));
}
|
[
"public",
"function",
"getApiRequestUrl",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"$",
"event",
"->",
"getCustomParams",
"(",
")",
";",
"$",
"query",
"=",
"trim",
"(",
"implode",
"(",
"\" \"",
",",
"$",
"params",
")",
")",
";",
"$",
"querystringParams",
"=",
"[",
"'v'",
"=>",
"'1.0'",
",",
"'q'",
"=>",
"$",
"query",
"]",
";",
"return",
"sprintf",
"(",
"\"%s?%s\"",
",",
"$",
"this",
"->",
"apiUrl",
",",
"http_build_query",
"(",
"$",
"querystringParams",
")",
")",
";",
"}"
] |
Get the url for the API request
@param \Phergie\Irc\Plugin\React\Command\CommandEvent $event
@return string
|
[
"Get",
"the",
"url",
"for",
"the",
"API",
"request"
] |
4492bf1e25826a9cf7187afee0ec35deddefaf6f
|
https://github.com/chrismou/phergie-irc-plugin-react-google/blob/4492bf1e25826a9cf7187afee0ec35deddefaf6f/src/Provider/GoogleSearch.php#L45-L56
|
23,291
|
mikebarlow/html-helper
|
src/Integrations/PlatesPHP.php
|
PlatesPHP.getHtmlHelper
|
public function getHtmlHelper()
{
$this->HtmlHelper->Form->getDataService()->template = $this->template;
$this->HtmlHelper->getRouterService()->template = $this->template;
$this->HtmlHelper->getAssetsService()->template = $this->template;
return $this->HtmlHelper;
}
|
php
|
public function getHtmlHelper()
{
$this->HtmlHelper->Form->getDataService()->template = $this->template;
$this->HtmlHelper->getRouterService()->template = $this->template;
$this->HtmlHelper->getAssetsService()->template = $this->template;
return $this->HtmlHelper;
}
|
[
"public",
"function",
"getHtmlHelper",
"(",
")",
"{",
"$",
"this",
"->",
"HtmlHelper",
"->",
"Form",
"->",
"getDataService",
"(",
")",
"->",
"template",
"=",
"$",
"this",
"->",
"template",
";",
"$",
"this",
"->",
"HtmlHelper",
"->",
"getRouterService",
"(",
")",
"->",
"template",
"=",
"$",
"this",
"->",
"template",
";",
"$",
"this",
"->",
"HtmlHelper",
"->",
"getAssetsService",
"(",
")",
"->",
"template",
"=",
"$",
"this",
"->",
"template",
";",
"return",
"$",
"this",
"->",
"HtmlHelper",
";",
"}"
] |
return the instance of the html helper
@return object $htmlHelper Instance of the html helper
|
[
"return",
"the",
"instance",
"of",
"the",
"html",
"helper"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Integrations/PlatesPHP.php#L36-L42
|
23,292
|
alevilar/ristorantino-vendor
|
Risto/Controller/PagesController.php
|
PagesController.display
|
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
|
php
|
public function display() {
$path = func_get_args();
$count = count($path);
if (!$count) {
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$title_for_layout = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title_for_layout'));
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}
|
[
"public",
"function",
"display",
"(",
")",
"{",
"$",
"path",
"=",
"func_get_args",
"(",
")",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"count",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"'/'",
")",
";",
"}",
"$",
"page",
"=",
"$",
"subpage",
"=",
"$",
"title_for_layout",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
"[",
"0",
"]",
")",
")",
"{",
"$",
"page",
"=",
"$",
"path",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
"[",
"1",
"]",
")",
")",
"{",
"$",
"subpage",
"=",
"$",
"path",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
"[",
"$",
"count",
"-",
"1",
"]",
")",
")",
"{",
"$",
"title_for_layout",
"=",
"Inflector",
"::",
"humanize",
"(",
"$",
"path",
"[",
"$",
"count",
"-",
"1",
"]",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'page'",
",",
"'subpage'",
",",
"'title_for_layout'",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"render",
"(",
"implode",
"(",
"'/'",
",",
"$",
"path",
")",
")",
";",
"}",
"catch",
"(",
"MissingViewException",
"$",
"e",
")",
"{",
"if",
"(",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"throw",
"new",
"NotFoundException",
"(",
")",
";",
"}",
"}"
] |
Displays a view
@param mixed What page to display
@return void
@throws NotFoundException When the view file could not be found
or MissingViewException in debug mode.
|
[
"Displays",
"a",
"view"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Controller/PagesController.php#L49-L76
|
23,293
|
eXistenZNL/PermCheck
|
src/PermCheck.php
|
PermCheck.run
|
public function run()
{
$this->loader->parse();
$files = $this->filesystem->getFiles();
// Now we check all the files against the config
while ($files->valid()) {
/* @var SplFileInfo $file */
$file = $files->current();
// Skip symlinks as they are always 0777
if ($file->isLink()) {
$files->next();
continue;
}
$filename = $this->getRelativeFilename($file);
// Skip excluded files, of course.
if ($this->isExcluded($filename)) {
$files->next();
continue;
}
$fileShouldBeExecutable = $this->shouldBeExecutable($filename);
if (!$fileShouldBeExecutable && $file->isExecutable()) {
$this->messageBag->addMessage($file->getPathname(), 'minx');
$files->next();
continue;
}
if ($fileShouldBeExecutable && !$file->isExecutable()) {
$this->messageBag->addMessage($file->getPathname(), 'plusx');
$files->next();
continue;
}
$files->next();
}
}
|
php
|
public function run()
{
$this->loader->parse();
$files = $this->filesystem->getFiles();
// Now we check all the files against the config
while ($files->valid()) {
/* @var SplFileInfo $file */
$file = $files->current();
// Skip symlinks as they are always 0777
if ($file->isLink()) {
$files->next();
continue;
}
$filename = $this->getRelativeFilename($file);
// Skip excluded files, of course.
if ($this->isExcluded($filename)) {
$files->next();
continue;
}
$fileShouldBeExecutable = $this->shouldBeExecutable($filename);
if (!$fileShouldBeExecutable && $file->isExecutable()) {
$this->messageBag->addMessage($file->getPathname(), 'minx');
$files->next();
continue;
}
if ($fileShouldBeExecutable && !$file->isExecutable()) {
$this->messageBag->addMessage($file->getPathname(), 'plusx');
$files->next();
continue;
}
$files->next();
}
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"loader",
"->",
"parse",
"(",
")",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"filesystem",
"->",
"getFiles",
"(",
")",
";",
"// Now we check all the files against the config",
"while",
"(",
"$",
"files",
"->",
"valid",
"(",
")",
")",
"{",
"/* @var SplFileInfo $file */",
"$",
"file",
"=",
"$",
"files",
"->",
"current",
"(",
")",
";",
"// Skip symlinks as they are always 0777",
"if",
"(",
"$",
"file",
"->",
"isLink",
"(",
")",
")",
"{",
"$",
"files",
"->",
"next",
"(",
")",
";",
"continue",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"getRelativeFilename",
"(",
"$",
"file",
")",
";",
"// Skip excluded files, of course.",
"if",
"(",
"$",
"this",
"->",
"isExcluded",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"files",
"->",
"next",
"(",
")",
";",
"continue",
";",
"}",
"$",
"fileShouldBeExecutable",
"=",
"$",
"this",
"->",
"shouldBeExecutable",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"$",
"fileShouldBeExecutable",
"&&",
"$",
"file",
"->",
"isExecutable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messageBag",
"->",
"addMessage",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"'minx'",
")",
";",
"$",
"files",
"->",
"next",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"fileShouldBeExecutable",
"&&",
"!",
"$",
"file",
"->",
"isExecutable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"messageBag",
"->",
"addMessage",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
",",
"'plusx'",
")",
";",
"$",
"files",
"->",
"next",
"(",
")",
";",
"continue",
";",
"}",
"$",
"files",
"->",
"next",
"(",
")",
";",
"}",
"}"
] |
Run the permission check and return any errors
@return void
|
[
"Run",
"the",
"permission",
"check",
"and",
"return",
"any",
"errors"
] |
f22f2936350f6b440222fb6ea37dfc382fc4550e
|
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/PermCheck.php#L95-L134
|
23,294
|
eXistenZNL/PermCheck
|
src/PermCheck.php
|
PermCheck.isExcluded
|
protected function isExcluded($filename)
{
foreach ($this->config->getExcludedFiles() as $excludedFile) {
if ($filename === $excludedFile) {
return true;
}
}
foreach ($this->config->getExcludedDirs() as $excludedDir) {
if (strpos($filename, $excludedDir) === 0) {
return true;
}
}
return false;
}
|
php
|
protected function isExcluded($filename)
{
foreach ($this->config->getExcludedFiles() as $excludedFile) {
if ($filename === $excludedFile) {
return true;
}
}
foreach ($this->config->getExcludedDirs() as $excludedDir) {
if (strpos($filename, $excludedDir) === 0) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"isExcluded",
"(",
"$",
"filename",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getExcludedFiles",
"(",
")",
"as",
"$",
"excludedFile",
")",
"{",
"if",
"(",
"$",
"filename",
"===",
"$",
"excludedFile",
")",
"{",
"return",
"true",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getExcludedDirs",
"(",
")",
"as",
"$",
"excludedDir",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"$",
"excludedDir",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check whether the given file should be excluded.
@param string $filename The filename to check.
@return boolean
|
[
"Check",
"whether",
"the",
"given",
"file",
"should",
"be",
"excluded",
"."
] |
f22f2936350f6b440222fb6ea37dfc382fc4550e
|
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/PermCheck.php#L143-L156
|
23,295
|
eXistenZNL/PermCheck
|
src/PermCheck.php
|
PermCheck.shouldBeExecutable
|
protected function shouldBeExecutable($filename)
{
foreach ($this->config->getExecutableFiles() as $exFile) {
if ($filename === $exFile) {
return true;
}
}
return false;
}
|
php
|
protected function shouldBeExecutable($filename)
{
foreach ($this->config->getExecutableFiles() as $exFile) {
if ($filename === $exFile) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"shouldBeExecutable",
"(",
"$",
"filename",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getExecutableFiles",
"(",
")",
"as",
"$",
"exFile",
")",
"{",
"if",
"(",
"$",
"filename",
"===",
"$",
"exFile",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check whether the given file should be executable.
@param string $filename The filename to check.
@return boolean
|
[
"Check",
"whether",
"the",
"given",
"file",
"should",
"be",
"executable",
"."
] |
f22f2936350f6b440222fb6ea37dfc382fc4550e
|
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/PermCheck.php#L165-L173
|
23,296
|
eXistenZNL/PermCheck
|
src/PermCheck.php
|
PermCheck.getRelativeFilename
|
protected function getRelativeFilename(SplFileInfo $file)
{
$filename = $file->getPathname();
$regex = sprintf('#^(%s)/(.+)#', $this->directory);
$matches = array();
preg_match(
$regex,
$filename,
$matches
);
return $matches[2];
}
|
php
|
protected function getRelativeFilename(SplFileInfo $file)
{
$filename = $file->getPathname();
$regex = sprintf('#^(%s)/(.+)#', $this->directory);
$matches = array();
preg_match(
$regex,
$filename,
$matches
);
return $matches[2];
}
|
[
"protected",
"function",
"getRelativeFilename",
"(",
"SplFileInfo",
"$",
"file",
")",
"{",
"$",
"filename",
"=",
"$",
"file",
"->",
"getPathname",
"(",
")",
";",
"$",
"regex",
"=",
"sprintf",
"(",
"'#^(%s)/(.+)#'",
",",
"$",
"this",
"->",
"directory",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"filename",
",",
"$",
"matches",
")",
";",
"return",
"$",
"matches",
"[",
"2",
"]",
";",
"}"
] |
Get the relative name of the given file.
@param SplFileInfo $file The file to get the relative name for.
@return string
|
[
"Get",
"the",
"relative",
"name",
"of",
"the",
"given",
"file",
"."
] |
f22f2936350f6b440222fb6ea37dfc382fc4550e
|
https://github.com/eXistenZNL/PermCheck/blob/f22f2936350f6b440222fb6ea37dfc382fc4550e/src/PermCheck.php#L182-L195
|
23,297
|
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Serializer/Traverser.php
|
HTML5_Serializer_Traverser.walk
|
public function walk() {
if ($this->dom instanceof \DOMDocument) {
$this->rules->document($this->dom);
} elseif ($this->dom instanceof \DOMDocumentFragment) {
// Document fragments are a special case. Only the children need to
// be serialized.
if ($this->dom->hasChildNodes()) {
$this->children($this->dom->childNodes);
}
} // If NodeList, loop
elseif ($this->dom instanceof \DOMNodeList) {
// If this is a NodeList of DOMDocuments this will not work.
$this->children($this->dom);
} // Else assume this is a DOMNode-like datastructure.
else {
$this->node($this->dom);
}
return $this->out;
}
|
php
|
public function walk() {
if ($this->dom instanceof \DOMDocument) {
$this->rules->document($this->dom);
} elseif ($this->dom instanceof \DOMDocumentFragment) {
// Document fragments are a special case. Only the children need to
// be serialized.
if ($this->dom->hasChildNodes()) {
$this->children($this->dom->childNodes);
}
} // If NodeList, loop
elseif ($this->dom instanceof \DOMNodeList) {
// If this is a NodeList of DOMDocuments this will not work.
$this->children($this->dom);
} // Else assume this is a DOMNode-like datastructure.
else {
$this->node($this->dom);
}
return $this->out;
}
|
[
"public",
"function",
"walk",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dom",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"$",
"this",
"->",
"rules",
"->",
"document",
"(",
"$",
"this",
"->",
"dom",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"dom",
"instanceof",
"\\",
"DOMDocumentFragment",
")",
"{",
"// Document fragments are a special case. Only the children need to",
"// be serialized.",
"if",
"(",
"$",
"this",
"->",
"dom",
"->",
"hasChildNodes",
"(",
")",
")",
"{",
"$",
"this",
"->",
"children",
"(",
"$",
"this",
"->",
"dom",
"->",
"childNodes",
")",
";",
"}",
"}",
"// If NodeList, loop",
"elseif",
"(",
"$",
"this",
"->",
"dom",
"instanceof",
"\\",
"DOMNodeList",
")",
"{",
"// If this is a NodeList of DOMDocuments this will not work.",
"$",
"this",
"->",
"children",
"(",
"$",
"this",
"->",
"dom",
")",
";",
"}",
"// Else assume this is a DOMNode-like datastructure.",
"else",
"{",
"$",
"this",
"->",
"node",
"(",
"$",
"this",
"->",
"dom",
")",
";",
"}",
"return",
"$",
"this",
"->",
"out",
";",
"}"
] |
Tell the traverser to walk the DOM.
@return resource $out
Returns the output stream.
|
[
"Tell",
"the",
"traverser",
"to",
"walk",
"the",
"DOM",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/Traverser.php#L142-L161
|
23,298
|
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Serializer/Traverser.php
|
HTML5_Serializer_Traverser.node
|
public function node(\DOMNode $node) {
// A listing of types is at http://php.net/manual/en/dom.constants.php
switch ($node->nodeType) {
case XML_ELEMENT_NODE:
$this->rules->element($node);
break;
case XML_TEXT_NODE:
$this->rules->text($node);
break;
case XML_CDATA_SECTION_NODE:
$this->rules->cdata($node);
break;
// FIXME: It appears that the parser doesn't do PI's.
case XML_PI_NODE:
$this->rules->processorInstruction($node);
break;
case XML_COMMENT_NODE:
$this->rules->comment($node);
break;
// Currently we don't support embedding DTDs.
default:
print '<!-- Skipped -->';
break;
}
}
|
php
|
public function node(\DOMNode $node) {
// A listing of types is at http://php.net/manual/en/dom.constants.php
switch ($node->nodeType) {
case XML_ELEMENT_NODE:
$this->rules->element($node);
break;
case XML_TEXT_NODE:
$this->rules->text($node);
break;
case XML_CDATA_SECTION_NODE:
$this->rules->cdata($node);
break;
// FIXME: It appears that the parser doesn't do PI's.
case XML_PI_NODE:
$this->rules->processorInstruction($node);
break;
case XML_COMMENT_NODE:
$this->rules->comment($node);
break;
// Currently we don't support embedding DTDs.
default:
print '<!-- Skipped -->';
break;
}
}
|
[
"public",
"function",
"node",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"// A listing of types is at http://php.net/manual/en/dom.constants.php",
"switch",
"(",
"$",
"node",
"->",
"nodeType",
")",
"{",
"case",
"XML_ELEMENT_NODE",
":",
"$",
"this",
"->",
"rules",
"->",
"element",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"XML_TEXT_NODE",
":",
"$",
"this",
"->",
"rules",
"->",
"text",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"XML_CDATA_SECTION_NODE",
":",
"$",
"this",
"->",
"rules",
"->",
"cdata",
"(",
"$",
"node",
")",
";",
"break",
";",
"// FIXME: It appears that the parser doesn't do PI's.",
"case",
"XML_PI_NODE",
":",
"$",
"this",
"->",
"rules",
"->",
"processorInstruction",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"XML_COMMENT_NODE",
":",
"$",
"this",
"->",
"rules",
"->",
"comment",
"(",
"$",
"node",
")",
";",
"break",
";",
"// Currently we don't support embedding DTDs.",
"default",
":",
"print",
"'<!-- Skipped -->'",
";",
"break",
";",
"}",
"}"
] |
Process a node in the DOM.
@param mixed $node
A node implementing \DOMNode.
|
[
"Process",
"a",
"node",
"in",
"the",
"DOM",
"."
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/Traverser.php#L169-L193
|
23,299
|
PHPPowertools/HTML5
|
src/PowerTools/HTML5/Serializer/Traverser.php
|
HTML5_Serializer_Traverser.isLocalElement
|
public function isLocalElement($element) {
$uri = $element->namespaceURI;
if (empty($uri)) {
return false;
}
return isset(static::$local_ns[$uri]);
}
|
php
|
public function isLocalElement($element) {
$uri = $element->namespaceURI;
if (empty($uri)) {
return false;
}
return isset(static::$local_ns[$uri]);
}
|
[
"public",
"function",
"isLocalElement",
"(",
"$",
"element",
")",
"{",
"$",
"uri",
"=",
"$",
"element",
"->",
"namespaceURI",
";",
"if",
"(",
"empty",
"(",
"$",
"uri",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isset",
"(",
"static",
"::",
"$",
"local_ns",
"[",
"$",
"uri",
"]",
")",
";",
"}"
] |
Is an element local?
@param mixed $element
An element that implement \DOMNode.
@return bool True if local and false otherwise.
|
[
"Is",
"an",
"element",
"local?"
] |
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
|
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/Traverser.php#L215-L222
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.