repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.drawTable | protected function drawTable(string $heading, array $headers, array $rows): void
{
if(!empty($rows))
{
$this->output->write(PHP_EOL);
$this->output->writeLn('<yellow>' . $heading . '</yellow>');
$this->output->write(PHP_EOL);
$table = new Table($this->output);
$headers = array_map(function($value) { return '<green>' . $value . '</green>'; }, $headers);
$table->draw($headers, $rows);
}
} | php | protected function drawTable(string $heading, array $headers, array $rows): void
{
if(!empty($rows))
{
$this->output->write(PHP_EOL);
$this->output->writeLn('<yellow>' . $heading . '</yellow>');
$this->output->write(PHP_EOL);
$table = new Table($this->output);
$headers = array_map(function($value) { return '<green>' . $value . '</green>'; }, $headers);
$table->draw($headers, $rows);
}
} | [
"protected",
"function",
"drawTable",
"(",
"string",
"$",
"heading",
",",
"array",
"$",
"headers",
",",
"array",
"$",
"rows",
")",
":",
"void",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"rows",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"write... | Draws information table.
@param string $heading Table heading
@param array $headers Table headers
@param array $rows Table rows | [
"Draws",
"information",
"table",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L170-L186 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.getOptions | protected function getOptions(): array
{
$options = [];
foreach($this->options as $group)
{
foreach($group as $name => $option)
{
$options[] = ['--' . $name, $option['description']];
}
}
sort($options);
return $options;
} | php | protected function getOptions(): array
{
$options = [];
foreach($this->options as $group)
{
foreach($group as $name => $option)
{
$options[] = ['--' . $name, $option['description']];
}
}
sort($options);
return $options;
} | [
"protected",
"function",
"getOptions",
"(",
")",
":",
"array",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"group",
"as",
"$",
"name",
"=>",
"$",
"option"... | Returns an array of option information.
@return array | [
"Returns",
"an",
"array",
"of",
"option",
"information",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L193-L208 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.displayReactorInfo | protected function displayReactorInfo(): void
{
// Display basic reactor information
if(!empty($this->logo))
{
$this->output->writeLn($this->logo);
$this->output->write(PHP_EOL);
}
$this->output->writeLn('<yellow>Usage:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn('php reactor [command] [arguments] [options]');
// Display reactor options if there are any
$this->listOptions();
} | php | protected function displayReactorInfo(): void
{
// Display basic reactor information
if(!empty($this->logo))
{
$this->output->writeLn($this->logo);
$this->output->write(PHP_EOL);
}
$this->output->writeLn('<yellow>Usage:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn('php reactor [command] [arguments] [options]');
// Display reactor options if there are any
$this->listOptions();
} | [
"protected",
"function",
"displayReactorInfo",
"(",
")",
":",
"void",
"{",
"// Display basic reactor information",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"logo",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeLn",
"(",
"$",
"this",
"->",... | Displays basic reactor information. | [
"Displays",
"basic",
"reactor",
"information",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L223-L243 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.getCommands | protected function getCommands(): array
{
$info = [];
foreach($this->commands as $name => $class)
{
$command = $this->instantiateCommandWithoutConstructor($class);
$info[$name] = [$name, $command->getCommandDescription()];
}
ksort($info);
return $info;
} | php | protected function getCommands(): array
{
$info = [];
foreach($this->commands as $name => $class)
{
$command = $this->instantiateCommandWithoutConstructor($class);
$info[$name] = [$name, $command->getCommandDescription()];
}
ksort($info);
return $info;
} | [
"protected",
"function",
"getCommands",
"(",
")",
":",
"array",
"{",
"$",
"info",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"commands",
"as",
"$",
"name",
"=>",
"$",
"class",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"instantia... | Returns an array of command information.
@return array | [
"Returns",
"an",
"array",
"of",
"command",
"information",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L261-L275 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.convertArgumentsAndOptionsArrayToRows | protected function convertArgumentsAndOptionsArrayToRows(array $input): array
{
$rows = [];
foreach($input as $name => $info)
{
$rows[] = [$name, $info['description'], var_export($info['optional'], true)];
}
return $rows;
} | php | protected function convertArgumentsAndOptionsArrayToRows(array $input): array
{
$rows = [];
foreach($input as $name => $info)
{
$rows[] = [$name, $info['description'], var_export($info['optional'], true)];
}
return $rows;
} | [
"protected",
"function",
"convertArgumentsAndOptionsArrayToRows",
"(",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"name",
"=>",
"$",
"info",
")",
"{",
"$",
"rows",
"[",
"]",
... | Converst the argument and options arrays to table rows.
@param array $input Argument or option array
@return array | [
"Converst",
"the",
"argument",
"and",
"options",
"arrays",
"to",
"table",
"rows",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L307-L317 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.displayCommandHelp | protected function displayCommandHelp(string $command): int
{
$commandInstance = $this->instantiateCommandWithoutConstructor($this->commands[$command]);
$this->output->writeLn('<yellow>Command:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn('php reactor ' . $command);
$this->output->write(PHP_EOL);
$this->output->writeLn('<yellow>Description:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn($commandInstance->getCommandDescription());
if(!empty($arguments = $commandInstance->getCommandArguments()))
{
$this->drawTable('Arguments:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($arguments));
}
if(!empty($options = $commandInstance->getCommandOptions()))
{
$this->drawTable('Options:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($options));
}
return CommandInterface::STATUS_SUCCESS;
} | php | protected function displayCommandHelp(string $command): int
{
$commandInstance = $this->instantiateCommandWithoutConstructor($this->commands[$command]);
$this->output->writeLn('<yellow>Command:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn('php reactor ' . $command);
$this->output->write(PHP_EOL);
$this->output->writeLn('<yellow>Description:</yellow>');
$this->output->write(PHP_EOL);
$this->output->writeLn($commandInstance->getCommandDescription());
if(!empty($arguments = $commandInstance->getCommandArguments()))
{
$this->drawTable('Arguments:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($arguments));
}
if(!empty($options = $commandInstance->getCommandOptions()))
{
$this->drawTable('Options:', ['Name', 'Description', 'Optional'], $this->convertArgumentsAndOptionsArrayToRows($options));
}
return CommandInterface::STATUS_SUCCESS;
} | [
"protected",
"function",
"displayCommandHelp",
"(",
"string",
"$",
"command",
")",
":",
"int",
"{",
"$",
"commandInstance",
"=",
"$",
"this",
"->",
"instantiateCommandWithoutConstructor",
"(",
"$",
"this",
"->",
"commands",
"[",
"$",
"command",
"]",
")",
";",
... | Displays information about the chosen command.
@param string $command Command
@return int | [
"Displays",
"information",
"about",
"the",
"chosen",
"command",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L325-L354 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.unknownCommand | protected function unknownCommand(string $command): int
{
$message = 'Unknown command [ ' . $command . ' ].';
if(($suggestion = $this->suggest($command, array_keys($this->commands))) !== null)
{
$message .= ' Did you mean [ ' . $suggestion . ' ]?';
}
$this->output->writeLn('<red>' . $message . '</red>');
$this->listCommands();
return CommandInterface::STATUS_ERROR;
} | php | protected function unknownCommand(string $command): int
{
$message = 'Unknown command [ ' . $command . ' ].';
if(($suggestion = $this->suggest($command, array_keys($this->commands))) !== null)
{
$message .= ' Did you mean [ ' . $suggestion . ' ]?';
}
$this->output->writeLn('<red>' . $message . '</red>');
$this->listCommands();
return CommandInterface::STATUS_ERROR;
} | [
"protected",
"function",
"unknownCommand",
"(",
"string",
"$",
"command",
")",
":",
"int",
"{",
"$",
"message",
"=",
"'Unknown command [ '",
".",
"$",
"command",
".",
"' ].'",
";",
"if",
"(",
"(",
"$",
"suggestion",
"=",
"$",
"this",
"->",
"suggest",
"("... | Displays error message for unknown commands.
@param string $command Command
@return int | [
"Displays",
"error",
"message",
"for",
"unknown",
"commands",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L373-L387 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.getGlobalOptionNames | protected function getGlobalOptionNames(): array
{
$names = [];
foreach($this->options as $group)
{
$names = array_merge($names, array_keys($group));
}
return $names;
} | php | protected function getGlobalOptionNames(): array
{
$names = [];
foreach($this->options as $group)
{
$names = array_merge($names, array_keys($group));
}
return $names;
} | [
"protected",
"function",
"getGlobalOptionNames",
"(",
")",
":",
"array",
"{",
"$",
"names",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"group",
")",
"{",
"$",
"names",
"=",
"array_merge",
"(",
"$",
"names",
",",
"arr... | Returns the names of the global options.
@return array | [
"Returns",
"the",
"names",
"of",
"the",
"global",
"options",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L394-L404 | train |
mako-framework/framework | src/mako/reactor/Reactor.php | Reactor.run | public function run(): int
{
$this->handleGlobalOptions();
if(($command = $this->input->getArgument(1)) === null)
{
return $this->displayReactorInfoAndCommandList();
}
if($this->commandExists($command) === false)
{
return $this->unknownCommand($command);
}
if($this->input->getArgument('help', false) !== false)
{
return $this->displayCommandHelp($command);
}
return $this->dispatch($command);
} | php | public function run(): int
{
$this->handleGlobalOptions();
if(($command = $this->input->getArgument(1)) === null)
{
return $this->displayReactorInfoAndCommandList();
}
if($this->commandExists($command) === false)
{
return $this->unknownCommand($command);
}
if($this->input->getArgument('help', false) !== false)
{
return $this->displayCommandHelp($command);
}
return $this->dispatch($command);
} | [
"public",
"function",
"run",
"(",
")",
":",
"int",
"{",
"$",
"this",
"->",
"handleGlobalOptions",
"(",
")",
";",
"if",
"(",
"(",
"$",
"command",
"=",
"$",
"this",
"->",
"input",
"->",
"getArgument",
"(",
"1",
")",
")",
"===",
"null",
")",
"{",
"r... | Run the reactor.
@return int | [
"Run",
"the",
"reactor",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/Reactor.php#L435-L455 | train |
mako-framework/framework | src/mako/commander/CommandBus.php | CommandBus.addMiddleware | public function addMiddleware(string $middleware, bool $inner = true): int
{
return $inner ? $this->onion->addInnerLayer($middleware) : $this->onion->addOuterLayer($middleware);
} | php | public function addMiddleware(string $middleware, bool $inner = true): int
{
return $inner ? $this->onion->addInnerLayer($middleware) : $this->onion->addOuterLayer($middleware);
} | [
"public",
"function",
"addMiddleware",
"(",
"string",
"$",
"middleware",
",",
"bool",
"$",
"inner",
"=",
"true",
")",
":",
"int",
"{",
"return",
"$",
"inner",
"?",
"$",
"this",
"->",
"onion",
"->",
"addInnerLayer",
"(",
"$",
"middleware",
")",
":",
"$"... | Adds middleware.
@param string $middleware Middleware class
@param bool $inner Add an inner layer?
@return int | [
"Adds",
"middleware",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/commander/CommandBus.php#L71-L74 | train |
mako-framework/framework | src/mako/commander/CommandBus.php | CommandBus.resolveCommand | protected function resolveCommand($command, array $parameters): CommandInterface
{
if($command instanceof CommandInterface)
{
return $command;
}
return $this->container->get($command, $parameters);
} | php | protected function resolveCommand($command, array $parameters): CommandInterface
{
if($command instanceof CommandInterface)
{
return $command;
}
return $this->container->get($command, $parameters);
} | [
"protected",
"function",
"resolveCommand",
"(",
"$",
"command",
",",
"array",
"$",
"parameters",
")",
":",
"CommandInterface",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"CommandInterface",
")",
"{",
"return",
"$",
"command",
";",
"}",
"return",
"$",
"thi... | Resolves the command.
@param \mako\commander\CommandInterface|string $command Command
@param array $parameters Parameters
@return \mako\commander\CommandInterface | [
"Resolves",
"the",
"command",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/commander/CommandBus.php#L83-L91 | train |
mako-framework/framework | src/mako/commander/CommandBus.php | CommandBus.resolveCommandHandler | protected function resolveCommandHandler(CommandInterface $command): CommandHandlerInterface
{
$class = get_class($command);
// Build handler class name
$commandSuffixLength = strlen(static::COMMAND_SUFFIX);
if(static::COMMAND_SUFFIX === substr($class, -$commandSuffixLength))
{
$handler = substr_replace($class, static::HANDLER_SUFFIX, strrpos($class, static::COMMAND_SUFFIX), $commandSuffixLength);
}
else
{
$handler = $class . static::HANDLER_SUFFIX;
}
// Return handler instance
return $this->container->get($handler);
} | php | protected function resolveCommandHandler(CommandInterface $command): CommandHandlerInterface
{
$class = get_class($command);
// Build handler class name
$commandSuffixLength = strlen(static::COMMAND_SUFFIX);
if(static::COMMAND_SUFFIX === substr($class, -$commandSuffixLength))
{
$handler = substr_replace($class, static::HANDLER_SUFFIX, strrpos($class, static::COMMAND_SUFFIX), $commandSuffixLength);
}
else
{
$handler = $class . static::HANDLER_SUFFIX;
}
// Return handler instance
return $this->container->get($handler);
} | [
"protected",
"function",
"resolveCommandHandler",
"(",
"CommandInterface",
"$",
"command",
")",
":",
"CommandHandlerInterface",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"command",
")",
";",
"// Build handler class name",
"$",
"commandSuffixLength",
"=",
"strlen"... | Resolves the command handler.
@param \mako\commander\CommandInterface $command Command
@return \mako\commander\CommandHandlerInterface | [
"Resolves",
"the",
"command",
"handler",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/commander/CommandBus.php#L99-L119 | train |
mako-framework/framework | src/mako/commander/CommandBus.php | CommandBus.resolveOnion | protected function resolveOnion(array $middleware): Onion
{
if(empty($middleware))
{
return $this->onion;
}
$onion = clone $this->onion;
foreach($middleware as $layer)
{
$onion->addLayer($layer);
}
return $onion;
} | php | protected function resolveOnion(array $middleware): Onion
{
if(empty($middleware))
{
return $this->onion;
}
$onion = clone $this->onion;
foreach($middleware as $layer)
{
$onion->addLayer($layer);
}
return $onion;
} | [
"protected",
"function",
"resolveOnion",
"(",
"array",
"$",
"middleware",
")",
":",
"Onion",
"{",
"if",
"(",
"empty",
"(",
"$",
"middleware",
")",
")",
"{",
"return",
"$",
"this",
"->",
"onion",
";",
"}",
"$",
"onion",
"=",
"clone",
"$",
"this",
"->"... | Resolves the onion instance.
@param array $middleware Middleware
@return \mako\onion\Onion | [
"Resolves",
"the",
"onion",
"instance",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/commander/CommandBus.php#L157-L172 | train |
mako-framework/framework | src/mako/validator/ValidationException.php | ValidationException.addMeta | public function addMeta(string $key, $value): void
{
Arr::set($this->meta, $key, $value);
} | php | public function addMeta(string $key, $value): void
{
Arr::set($this->meta, $key, $value);
} | [
"public",
"function",
"addMeta",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"void",
"{",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"meta",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Adds meta.
@param string $key Meta key
@param mixed $value Meta value | [
"Adds",
"meta",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/validator/ValidationException.php#L66-L69 | train |
mako-framework/framework | src/mako/http/request/Cookies.php | Cookies.getSigned | public function getSigned(string $name, $default = null)
{
if(empty($this->signer))
{
throw new RuntimeException('A [ Signer ] instance is required to read signed cookies.');
}
if(isset($this->cookies[$name]) && ($cookie = $this->signer->validate($this->cookies[$name])) !== false)
{
return $cookie;
}
return $default;
} | php | public function getSigned(string $name, $default = null)
{
if(empty($this->signer))
{
throw new RuntimeException('A [ Signer ] instance is required to read signed cookies.');
}
if(isset($this->cookies[$name]) && ($cookie = $this->signer->validate($this->cookies[$name])) !== false)
{
return $cookie;
}
return $default;
} | [
"public",
"function",
"getSigned",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"signer",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'A [ Signer ] instance is required to re... | Gets a signed cookie value.
@param string $name Cookie name
@param mixed $default Default value
@throws \RuntimeException
@return mixed | [
"Gets",
"a",
"signed",
"cookie",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/request/Cookies.php#L131-L144 | train |
mako-framework/framework | src/mako/common/AdapterManager.php | AdapterManager.instance | public function instance(?string $configuration = null)
{
$configuration = $configuration ?? $this->default;
if(!isset($this->instances[$configuration]))
{
$this->instances[$configuration] = $this->instantiate($configuration);
}
return $this->instances[$configuration];
} | php | public function instance(?string $configuration = null)
{
$configuration = $configuration ?? $this->default;
if(!isset($this->instances[$configuration]))
{
$this->instances[$configuration] = $this->instantiate($configuration);
}
return $this->instances[$configuration];
} | [
"public",
"function",
"instance",
"(",
"?",
"string",
"$",
"configuration",
"=",
"null",
")",
"{",
"$",
"configuration",
"=",
"$",
"configuration",
"??",
"$",
"this",
"->",
"default",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"instances",
"... | Returns an instance of the chosen adapter configuration.
@param string|null $configuration Configuration name
@return mixed | [
"Returns",
"an",
"instance",
"of",
"the",
"chosen",
"adapter",
"configuration",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/common/AdapterManager.php#L118-L128 | train |
mako-framework/framework | src/mako/config/Config.php | Config.parseKey | protected function parseKey(string $key): array
{
return (strpos($key, '.') === false) ? [$key, null] : explode('.', $key, 2);
} | php | protected function parseKey(string $key): array
{
return (strpos($key, '.') === false) ? [$key, null] : explode('.', $key, 2);
} | [
"protected",
"function",
"parseKey",
"(",
"string",
"$",
"key",
")",
":",
"array",
"{",
"return",
"(",
"strpos",
"(",
"$",
"key",
",",
"'.'",
")",
"===",
"false",
")",
"?",
"[",
"$",
"key",
",",
"null",
"]",
":",
"explode",
"(",
"'.'",
",",
"$",
... | Parses the language key.
@param string $key Language key
@return array | [
"Parses",
"the",
"language",
"key",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/config/Config.php#L93-L96 | train |
mako-framework/framework | src/mako/config/Config.php | Config.load | protected function load(string $file): void
{
$this->configuration[$file] = $this->loader->load($file, $this->environment);
} | php | protected function load(string $file): void
{
$this->configuration[$file] = $this->loader->load($file, $this->environment);
} | [
"protected",
"function",
"load",
"(",
"string",
"$",
"file",
")",
":",
"void",
"{",
"$",
"this",
"->",
"configuration",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"loader",
"->",
"load",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"environment",
... | Loads the configuration file.
@param string $file File name | [
"Loads",
"the",
"configuration",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/config/Config.php#L103-L106 | train |
mako-framework/framework | src/mako/config/Config.php | Config.get | public function get(string $key, $default = null)
{
[$file, $path] = $this->parseKey($key);
if(!isset($this->configuration[$file]))
{
$this->load($file);
}
return $path === null ? $this->configuration[$file] : Arr::get($this->configuration[$file], $path, $default);
} | php | public function get(string $key, $default = null)
{
[$file, $path] = $this->parseKey($key);
if(!isset($this->configuration[$file]))
{
$this->load($file);
}
return $path === null ? $this->configuration[$file] : Arr::get($this->configuration[$file], $path, $default);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"[",
"$",
"file",
",",
"$",
"path",
"]",
"=",
"$",
"this",
"->",
"parseKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"th... | Returns config value or entire config array from a file.
@param string $key Config key
@param mixed $default Default value to return if config value doesn't exist
@return mixed | [
"Returns",
"config",
"value",
"or",
"entire",
"config",
"array",
"from",
"a",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/config/Config.php#L115-L125 | train |
mako-framework/framework | src/mako/config/Config.php | Config.set | public function set(string $key, $value): void
{
[$file] = $this->parseKey($key);
if(!isset($this->configuration[$file]))
{
$this->load($file);
}
Arr::set($this->configuration, $key, $value);
} | php | public function set(string $key, $value): void
{
[$file] = $this->parseKey($key);
if(!isset($this->configuration[$file]))
{
$this->load($file);
}
Arr::set($this->configuration, $key, $value);
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"void",
"{",
"[",
"$",
"file",
"]",
"=",
"$",
"this",
"->",
"parseKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"configurat... | Sets a config value.
@param string $key Config key
@param mixed $value Config value | [
"Sets",
"a",
"config",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/config/Config.php#L133-L143 | train |
mako-framework/framework | src/mako/http/routing/Routes.php | Routes.getNamedRoute | public function getNamedRoute(string $name): Route
{
if(!isset($this->namedRoutes[$name]))
{
throw new RuntimeException(vsprintf('No route named [ %s ] has been defined.', [$name]));
}
return $this->namedRoutes[$name];
} | php | public function getNamedRoute(string $name): Route
{
if(!isset($this->namedRoutes[$name]))
{
throw new RuntimeException(vsprintf('No route named [ %s ] has been defined.', [$name]));
}
return $this->namedRoutes[$name];
} | [
"public",
"function",
"getNamedRoute",
"(",
"string",
"$",
"name",
")",
":",
"Route",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namedRoutes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"vsprintf",
"(",
... | Returns the named route.
@param string $name Route name
@throws \RuntimeException
@return \mako\http\routing\Route | [
"Returns",
"the",
"named",
"route",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Routes.php#L93-L101 | train |
mako-framework/framework | src/mako/http/routing/Routes.php | Routes.group | public function group(array $options, Closure $routes): void
{
$this->groups[] = $options;
$routes($this);
array_pop($this->groups);
} | php | public function group(array $options, Closure $routes): void
{
$this->groups[] = $options;
$routes($this);
array_pop($this->groups);
} | [
"public",
"function",
"group",
"(",
"array",
"$",
"options",
",",
"Closure",
"$",
"routes",
")",
":",
"void",
"{",
"$",
"this",
"->",
"groups",
"[",
"]",
"=",
"$",
"options",
";",
"$",
"routes",
"(",
"$",
"this",
")",
";",
"array_pop",
"(",
"$",
... | Adds a grouped set of routes to the colleciton.
@param array $options Group options
@param \Closure $routes Route closure | [
"Adds",
"a",
"grouped",
"set",
"of",
"routes",
"to",
"the",
"colleciton",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Routes.php#L109-L116 | train |
mako-framework/framework | src/mako/http/routing/Routes.php | Routes.get | public function get(string $route, $action, ?string $name = null): Route
{
return $this->registerRoute(['GET', 'HEAD', 'OPTIONS'], $route, $action, $name);
} | php | public function get(string $route, $action, ?string $name = null): Route
{
return $this->registerRoute(['GET', 'HEAD', 'OPTIONS'], $route, $action, $name);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"route",
",",
"$",
"action",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"registerRoute",
"(",
"[",
"'GET'",
",",
"'HEAD'",
",",
"'OPTIONS'",
"]",... | Adds a route that responds to GET requests to the collection.
@param string $route Route
@param string|\Closure $action Route action
@param string|null $name Route name
@return \mako\http\routing\Route | [
"Adds",
"a",
"route",
"that",
"responds",
"to",
"GET",
"requests",
"to",
"the",
"collection",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Routes.php#L165-L168 | train |
mako-framework/framework | src/mako/http/routing/Routes.php | Routes.register | public function register(array $methods, string $route, $action, ?string $name = null): Route
{
return $this->registerRoute($methods, $route, $action, $name);
} | php | public function register(array $methods, string $route, $action, ?string $name = null): Route
{
return $this->registerRoute($methods, $route, $action, $name);
} | [
"public",
"function",
"register",
"(",
"array",
"$",
"methods",
",",
"string",
"$",
"route",
",",
"$",
"action",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"registerRoute",
"(",
"$",
"methods",
... | Adds a route that respodns to the chosen HTTP methods to the collection.
@param array $methods Array of HTTP methods the route should respond to
@param string $route Route
@param string|\Closure $action Route action
@param string|null $name Route name
@return \mako\http\routing\Route | [
"Adds",
"a",
"route",
"that",
"respodns",
"to",
"the",
"chosen",
"HTTP",
"methods",
"to",
"the",
"collection",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/Routes.php#L244-L247 | train |
mako-framework/framework | src/mako/cli/output/helpers/Countdown.php | Countdown.draw | public function draw(int $from = 5): void
{
$dots = 0;
$fromLength = strlen($from);
$totalLength = $fromLength + 5;
do
{
do
{
$numbers = str_pad($from, $fromLength, '0', STR_PAD_LEFT);
$this->output->write("\r" . str_pad($numbers . ' ' . str_repeat('.', $dots) . ' ', $totalLength, ' '));
$this->sleep();
}
while($dots++ < 3);
$dots = 0;
}
while($from-- > 1);
$this->output->write("\r" . str_repeat(' ', $totalLength) . "\r");
} | php | public function draw(int $from = 5): void
{
$dots = 0;
$fromLength = strlen($from);
$totalLength = $fromLength + 5;
do
{
do
{
$numbers = str_pad($from, $fromLength, '0', STR_PAD_LEFT);
$this->output->write("\r" . str_pad($numbers . ' ' . str_repeat('.', $dots) . ' ', $totalLength, ' '));
$this->sleep();
}
while($dots++ < 3);
$dots = 0;
}
while($from-- > 1);
$this->output->write("\r" . str_repeat(' ', $totalLength) . "\r");
} | [
"public",
"function",
"draw",
"(",
"int",
"$",
"from",
"=",
"5",
")",
":",
"void",
"{",
"$",
"dots",
"=",
"0",
";",
"$",
"fromLength",
"=",
"strlen",
"(",
"$",
"from",
")",
";",
"$",
"totalLength",
"=",
"$",
"fromLength",
"+",
"5",
";",
"do",
"... | Counts down from n.
@param int $from Number of seconds to count down | [
"Counts",
"down",
"from",
"n",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/Countdown.php#L61-L86 | train |
mako-framework/framework | src/mako/common/traits/ConfigurableTrait.php | ConfigurableTrait.removeConfiguration | public function removeConfiguration(string $name): void
{
unset($this->configurations[$name], $this->connections[$name]);
} | php | public function removeConfiguration(string $name): void
{
unset($this->configurations[$name], $this->connections[$name]);
} | [
"public",
"function",
"removeConfiguration",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"unset",
"(",
"$",
"this",
"->",
"configurations",
"[",
"$",
"name",
"]",
",",
"$",
"this",
"->",
"connections",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Removes a configuration.
It will also remove any active connection linked to the configuration.
@param string $name Connection name | [
"Removes",
"a",
"configuration",
".",
"It",
"will",
"also",
"remove",
"any",
"active",
"connection",
"linked",
"to",
"the",
"configuration",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/common/traits/ConfigurableTrait.php#L61-L64 | train |
mako-framework/framework | src/mako/common/traits/NamespacedFileLoaderTrait.php | NamespacedFileLoaderTrait.getFilePath | protected function getFilePath(string $file, ?string $extension = null, ?string $suffix = null): string
{
if(strpos($file, '::') === false)
{
// No namespace so we'll just use the default path
$path = $this->path;
}
else
{
// The file is namespaced so we'll use the namespace path
[$namespace, $file] = explode('::', $file, 2);
if(!isset($this->namespaces[$namespace]))
{
throw new RuntimeException(vsprintf('The [ %s ] namespace does not exist.', [$namespace]));
}
$path = $this->namespaces[$namespace];
}
// Append suffix to path if needed
if($suffix !== null)
{
$path .= DIRECTORY_SEPARATOR . $suffix;
}
// Return full path to file
return $path . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $file) . ($extension ?? $this->extension);
} | php | protected function getFilePath(string $file, ?string $extension = null, ?string $suffix = null): string
{
if(strpos($file, '::') === false)
{
// No namespace so we'll just use the default path
$path = $this->path;
}
else
{
// The file is namespaced so we'll use the namespace path
[$namespace, $file] = explode('::', $file, 2);
if(!isset($this->namespaces[$namespace]))
{
throw new RuntimeException(vsprintf('The [ %s ] namespace does not exist.', [$namespace]));
}
$path = $this->namespaces[$namespace];
}
// Append suffix to path if needed
if($suffix !== null)
{
$path .= DIRECTORY_SEPARATOR . $suffix;
}
// Return full path to file
return $path . DIRECTORY_SEPARATOR . str_replace('.', DIRECTORY_SEPARATOR, $file) . ($extension ?? $this->extension);
} | [
"protected",
"function",
"getFilePath",
"(",
"string",
"$",
"file",
",",
"?",
"string",
"$",
"extension",
"=",
"null",
",",
"?",
"string",
"$",
"suffix",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"strpos",
"(",
"$",
"file",
",",
"'::'",
")",
... | Returns the path to the file.
@param string $file File name
@param string|null $extension File extension
@param string|null $suffix Path suffix
@throws \RuntimeException
@return string | [
"Returns",
"the",
"path",
"to",
"the",
"file",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/common/traits/NamespacedFileLoaderTrait.php#L86-L118 | train |
mako-framework/framework | src/mako/common/traits/NamespacedFileLoaderTrait.php | NamespacedFileLoaderTrait.getCascadingFilePaths | protected function getCascadingFilePaths(string $file, ?string $extension = null, ?string $suffix = null): array
{
$paths = [];
if(strpos($file, '::') === false)
{
// No namespace so we'll just have add a single file
$paths[] = $this->getFilePath($file, $extension, $suffix);
}
else
{
// Add the namespaced file first
$paths[] = $this->getFilePath($file, $extension, $suffix);
// Prepend the cascading file
[$package, $file] = explode('::', $file);
$suffix = 'packages' . DIRECTORY_SEPARATOR . $package . (($suffix !== null) ? DIRECTORY_SEPARATOR . $suffix : '');
array_unshift($paths, $this->getFilePath($file, $extension, $suffix));
}
return $paths;
} | php | protected function getCascadingFilePaths(string $file, ?string $extension = null, ?string $suffix = null): array
{
$paths = [];
if(strpos($file, '::') === false)
{
// No namespace so we'll just have add a single file
$paths[] = $this->getFilePath($file, $extension, $suffix);
}
else
{
// Add the namespaced file first
$paths[] = $this->getFilePath($file, $extension, $suffix);
// Prepend the cascading file
[$package, $file] = explode('::', $file);
$suffix = 'packages' . DIRECTORY_SEPARATOR . $package . (($suffix !== null) ? DIRECTORY_SEPARATOR . $suffix : '');
array_unshift($paths, $this->getFilePath($file, $extension, $suffix));
}
return $paths;
} | [
"protected",
"function",
"getCascadingFilePaths",
"(",
"string",
"$",
"file",
",",
"?",
"string",
"$",
"extension",
"=",
"null",
",",
"?",
"string",
"$",
"suffix",
"=",
"null",
")",
":",
"array",
"{",
"$",
"paths",
"=",
"[",
"]",
";",
"if",
"(",
"str... | Returns an array of cascading file paths.
@param string $file File name
@param string|null $extension File extension
@param string|null $suffix Path suffix
@return array | [
"Returns",
"an",
"array",
"of",
"cascading",
"file",
"paths",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/common/traits/NamespacedFileLoaderTrait.php#L128-L154 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.validate | public static function validate(string $uuid): bool
{
$uuid = str_replace(['urn:uuid:', '{', '}'], '', $uuid);
return (bool) preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid);
} | php | public static function validate(string $uuid): bool
{
$uuid = str_replace(['urn:uuid:', '{', '}'], '', $uuid);
return (bool) preg_match('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $uuid);
} | [
"public",
"static",
"function",
"validate",
"(",
"string",
"$",
"uuid",
")",
":",
"bool",
"{",
"$",
"uuid",
"=",
"str_replace",
"(",
"[",
"'urn:uuid:'",
",",
"'{'",
",",
"'}'",
"]",
",",
"''",
",",
"$",
"uuid",
")",
";",
"return",
"(",
"bool",
")",... | Checks if a UUID is valid.
@param string $uuid The UUID to validate
@return bool | [
"Checks",
"if",
"a",
"UUID",
"is",
"valid",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L81-L86 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.toBinary | public static function toBinary(string $uuid): string
{
if(!static::validate($uuid))
{
throw new InvalidArgumentException('The provided string is not a valid UUID.');
}
$hex = str_replace(['urn:uuid:', '{', '}', '-'], '', $uuid);
$binary = '';
for($i = 0; $i < 32; $i += 2)
{
$binary .= chr(hexdec($hex[$i] . $hex[$i + 1]));
}
return $binary;
} | php | public static function toBinary(string $uuid): string
{
if(!static::validate($uuid))
{
throw new InvalidArgumentException('The provided string is not a valid UUID.');
}
$hex = str_replace(['urn:uuid:', '{', '}', '-'], '', $uuid);
$binary = '';
for($i = 0; $i < 32; $i += 2)
{
$binary .= chr(hexdec($hex[$i] . $hex[$i + 1]));
}
return $binary;
} | [
"public",
"static",
"function",
"toBinary",
"(",
"string",
"$",
"uuid",
")",
":",
"string",
"{",
"if",
"(",
"!",
"static",
"::",
"validate",
"(",
"$",
"uuid",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The provided string is not a valid ... | Converts a UUID from its hexadecimal representation to a binary string.
@param string $uuid UUID
@throws \InvalidArgumentException
@return string | [
"Converts",
"a",
"UUID",
"from",
"its",
"hexadecimal",
"representation",
"to",
"a",
"binary",
"string",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L95-L112 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.toHexadecimal | public static function toHexadecimal(string $bytes): string
{
if(strlen($bytes) !== 16)
{
throw new InvalidArgumentException('The input must be exactly 16 bytes.');
}
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($bytes), 4));
} | php | public static function toHexadecimal(string $bytes): string
{
if(strlen($bytes) !== 16)
{
throw new InvalidArgumentException('The input must be exactly 16 bytes.');
}
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($bytes), 4));
} | [
"public",
"static",
"function",
"toHexadecimal",
"(",
"string",
"$",
"bytes",
")",
":",
"string",
"{",
"if",
"(",
"strlen",
"(",
"$",
"bytes",
")",
"!==",
"16",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The input must be exactly 16 bytes.'",
... | Converts a binary UUID to its hexadecimal representation.
@param string $bytes Binary representation of a UUID
@return string | [
"Converts",
"a",
"binary",
"UUID",
"to",
"its",
"hexadecimal",
"representation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L120-L128 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.v3 | public static function v3(string $namespace, string $name): string
{
$hash = md5(self::toBinary($namespace) . $name);
return sprintf
(
'%s-%s-%x-%x-%s',
substr($hash, 0, 8),
substr($hash, 8, 4),
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
substr($hash, 20, 12)
);
} | php | public static function v3(string $namespace, string $name): string
{
$hash = md5(self::toBinary($namespace) . $name);
return sprintf
(
'%s-%s-%x-%x-%s',
substr($hash, 0, 8),
substr($hash, 8, 4),
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
substr($hash, 20, 12)
);
} | [
"public",
"static",
"function",
"v3",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"hash",
"=",
"md5",
"(",
"self",
"::",
"toBinary",
"(",
"$",
"namespace",
")",
".",
"$",
"name",
")",
";",
"return",
"s... | Returns a V3 UUID.
@param string $namespace Namespace
@param string $name Name
@return string | [
"Returns",
"a",
"V3",
"UUID",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L137-L150 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.v4 | public static function v4(): string
{
$random = random_bytes(16);
$random[6] = chr(ord($random[6]) & 0x0f | 0x40);
$random[8] = chr(ord($random[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($random), 4));
} | php | public static function v4(): string
{
$random = random_bytes(16);
$random[6] = chr(ord($random[6]) & 0x0f | 0x40);
$random[8] = chr(ord($random[8]) & 0x3f | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($random), 4));
} | [
"public",
"static",
"function",
"v4",
"(",
")",
":",
"string",
"{",
"$",
"random",
"=",
"random_bytes",
"(",
"16",
")",
";",
"$",
"random",
"[",
"6",
"]",
"=",
"chr",
"(",
"ord",
"(",
"$",
"random",
"[",
"6",
"]",
")",
"&",
"0x0f",
"|",
"0x40",... | Returns a V4 UUID.
@return string | [
"Returns",
"a",
"V4",
"UUID",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L157-L166 | train |
mako-framework/framework | src/mako/utility/UUID.php | UUID.v5 | public static function v5(string $namespace, string $name): string
{
$hash = sha1(static::toBinary($namespace) . $name);
return sprintf
(
'%s-%s-%x-%x-%s',
substr($hash, 0, 8),
substr($hash, 8, 4),
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
substr($hash, 20, 12)
);
} | php | public static function v5(string $namespace, string $name): string
{
$hash = sha1(static::toBinary($namespace) . $name);
return sprintf
(
'%s-%s-%x-%x-%s',
substr($hash, 0, 8),
substr($hash, 8, 4),
(hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000,
(hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
substr($hash, 20, 12)
);
} | [
"public",
"static",
"function",
"v5",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"hash",
"=",
"sha1",
"(",
"static",
"::",
"toBinary",
"(",
"$",
"namespace",
")",
".",
"$",
"name",
")",
";",
"return",
... | Returns a V5 UUID.
@param string $namespace Namespace
@param string $name Name
@return string | [
"Returns",
"a",
"V5",
"UUID",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/utility/UUID.php#L175-L188 | train |
mako-framework/framework | src/mako/reactor/traits/CommandHelperTrait.php | CommandHelperTrait.nl | protected function nl(int $lines = 1, int $writer = Output::STANDARD): void
{
$this->output->write(str_repeat(PHP_EOL, $lines), $writer);
} | php | protected function nl(int $lines = 1, int $writer = Output::STANDARD): void
{
$this->output->write(str_repeat(PHP_EOL, $lines), $writer);
} | [
"protected",
"function",
"nl",
"(",
"int",
"$",
"lines",
"=",
"1",
",",
"int",
"$",
"writer",
"=",
"Output",
"::",
"STANDARD",
")",
":",
"void",
"{",
"$",
"this",
"->",
"output",
"->",
"write",
"(",
"str_repeat",
"(",
"PHP_EOL",
",",
"$",
"lines",
... | Writes n newlines to output.
@param int $lines Number of newlines to write
@param int $writer Output writer | [
"Writes",
"n",
"newlines",
"to",
"output",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/traits/CommandHelperTrait.php#L41-L44 | train |
mako-framework/framework | src/mako/reactor/traits/CommandHelperTrait.php | CommandHelperTrait.alert | protected function alert(string $message, string $template = Alert::DEFAULT, int $writer = Output::STANDARD): void
{
(new Alert($this->output))->draw($message, $template, $writer);
} | php | protected function alert(string $message, string $template = Alert::DEFAULT, int $writer = Output::STANDARD): void
{
(new Alert($this->output))->draw($message, $template, $writer);
} | [
"protected",
"function",
"alert",
"(",
"string",
"$",
"message",
",",
"string",
"$",
"template",
"=",
"Alert",
"::",
"DEFAULT",
",",
"int",
"$",
"writer",
"=",
"Output",
"::",
"STANDARD",
")",
":",
"void",
"{",
"(",
"new",
"Alert",
"(",
"$",
"this",
... | Draws an alert.
@param string $message Message
@param string $template Alert template
@param int $writer Output writer | [
"Draws",
"an",
"alert",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/traits/CommandHelperTrait.php#L82-L85 | train |
mako-framework/framework | src/mako/reactor/traits/CommandHelperTrait.php | CommandHelperTrait.ol | protected function ol(array $items, string $marker = '<yellow>%s</yellow>.', int $writer = Output::STANDARD): void
{
(new OrderedList($this->output))->draw($items, $marker, $writer);
} | php | protected function ol(array $items, string $marker = '<yellow>%s</yellow>.', int $writer = Output::STANDARD): void
{
(new OrderedList($this->output))->draw($items, $marker, $writer);
} | [
"protected",
"function",
"ol",
"(",
"array",
"$",
"items",
",",
"string",
"$",
"marker",
"=",
"'<yellow>%s</yellow>.'",
",",
"int",
"$",
"writer",
"=",
"Output",
"::",
"STANDARD",
")",
":",
"void",
"{",
"(",
"new",
"OrderedList",
"(",
"$",
"this",
"->",
... | Draws an ordered list.
@param array $items Items
@param string $marker Item marker
@param int $writer Output writer | [
"Draws",
"an",
"ordered",
"list",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/traits/CommandHelperTrait.php#L154-L157 | train |
mako-framework/framework | src/mako/reactor/traits/CommandHelperTrait.php | CommandHelperTrait.confirm | protected function confirm(string $question, string $default = 'n')
{
return (new Confirmation($this->input, $this->output))->ask($question, $default);
} | php | protected function confirm(string $question, string $default = 'n')
{
return (new Confirmation($this->input, $this->output))->ask($question, $default);
} | [
"protected",
"function",
"confirm",
"(",
"string",
"$",
"question",
",",
"string",
"$",
"default",
"=",
"'n'",
")",
"{",
"return",
"(",
"new",
"Confirmation",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"output",
")",
")",
"->",
"ask",
"... | Writes question to output and returns boolesn value corresponding to the chosen value.
@param string $question Question to ask
@param string $default Default answer
@return bool | [
"Writes",
"question",
"to",
"output",
"and",
"returns",
"boolesn",
"value",
"corresponding",
"to",
"the",
"chosen",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/reactor/traits/CommandHelperTrait.php#L178-L181 | train |
mako-framework/framework | src/mako/security/Key.php | Key.decode | public static function decode(string $key): string
{
if(strpos($key, 'hex:') === 0)
{
return hex2bin(mb_substr($key, 4, null, '8bit'));
}
return $key;
} | php | public static function decode(string $key): string
{
if(strpos($key, 'hex:') === 0)
{
return hex2bin(mb_substr($key, 4, null, '8bit'));
}
return $key;
} | [
"public",
"static",
"function",
"decode",
"(",
"string",
"$",
"key",
")",
":",
"string",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'hex:'",
")",
"===",
"0",
")",
"{",
"return",
"hex2bin",
"(",
"mb_substr",
"(",
"$",
"key",
",",
"4",
",",
"... | Converts a hexadecimal key into its binary representation.
@param string $key Encoded key
@return string | [
"Converts",
"a",
"hexadecimal",
"key",
"into",
"its",
"binary",
"representation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/security/Key.php#L40-L48 | train |
mako-framework/framework | src/mako/error/handlers/cli/DevelopmentHandler.php | DevelopmentHandler.escape | protected function escape(string $string): string
{
if(($formatter = $this->output->getFormatter()) === null)
{
return $string;
}
return $formatter->escape($string);
} | php | protected function escape(string $string): string
{
if(($formatter = $this->output->getFormatter()) === null)
{
return $string;
}
return $formatter->escape($string);
} | [
"protected",
"function",
"escape",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"if",
"(",
"(",
"$",
"formatter",
"=",
"$",
"this",
"->",
"output",
"->",
"getFormatter",
"(",
")",
")",
"===",
"null",
")",
"{",
"return",
"$",
"string",
";",
... | Escape formatting tags.
@param string $string String to escape
@return string | [
"Escape",
"formatting",
"tags",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/handlers/cli/DevelopmentHandler.php#L49-L57 | train |
mako-framework/framework | src/mako/error/handlers/cli/DevelopmentHandler.php | DevelopmentHandler.determineExceptionType | protected function determineExceptionType(Throwable $exception): string
{
if($exception instanceof ErrorException)
{
$code = $exception->getCode();
$codes =
[
E_ERROR => 'Fatal Error',
E_PARSE => 'Parse Error',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_STRICT => 'Strict Mode Error',
E_NOTICE => 'Notice',
E_WARNING => 'Warning',
E_RECOVERABLE_ERROR => 'Recoverable Error',
E_DEPRECATED => 'Deprecated',
E_USER_NOTICE => 'Notice',
E_USER_WARNING => 'Warning',
E_USER_ERROR => 'Error',
E_USER_DEPRECATED => 'Deprecated',
];
return in_array($code, array_keys($codes)) ? $codes[$code] : 'ErrorException';
}
return get_class($exception);
} | php | protected function determineExceptionType(Throwable $exception): string
{
if($exception instanceof ErrorException)
{
$code = $exception->getCode();
$codes =
[
E_ERROR => 'Fatal Error',
E_PARSE => 'Parse Error',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_STRICT => 'Strict Mode Error',
E_NOTICE => 'Notice',
E_WARNING => 'Warning',
E_RECOVERABLE_ERROR => 'Recoverable Error',
E_DEPRECATED => 'Deprecated',
E_USER_NOTICE => 'Notice',
E_USER_WARNING => 'Warning',
E_USER_ERROR => 'Error',
E_USER_DEPRECATED => 'Deprecated',
];
return in_array($code, array_keys($codes)) ? $codes[$code] : 'ErrorException';
}
return get_class($exception);
} | [
"protected",
"function",
"determineExceptionType",
"(",
"Throwable",
"$",
"exception",
")",
":",
"string",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"ErrorException",
")",
"{",
"$",
"code",
"=",
"$",
"exception",
"->",
"getCode",
"(",
")",
";",
"$",
... | Determines the exception type.
@param \Throwable $exception Throwable
@return string | [
"Determines",
"the",
"exception",
"type",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/error/handlers/cli/DevelopmentHandler.php#L65-L92 | train |
mako-framework/framework | src/mako/cli/output/formatter/Formatter.php | Formatter.getStyleCodes | protected function getStyleCodes(string $tag): array
{
if(isset($this->styles[$tag]))
{
return [$this->styles[$tag]];
}
elseif(isset($this->userStyles[$tag]))
{
$codes = [];
foreach($this->userStyles[$tag] as $tag)
{
$codes = array_merge($codes, $this->getStyleCodes($tag));
}
return $codes;
}
throw new FormatterException(vsprintf('Undefined formatting tag [ %s ] detected.', [$tag]));
} | php | protected function getStyleCodes(string $tag): array
{
if(isset($this->styles[$tag]))
{
return [$this->styles[$tag]];
}
elseif(isset($this->userStyles[$tag]))
{
$codes = [];
foreach($this->userStyles[$tag] as $tag)
{
$codes = array_merge($codes, $this->getStyleCodes($tag));
}
return $codes;
}
throw new FormatterException(vsprintf('Undefined formatting tag [ %s ] detected.', [$tag]));
} | [
"protected",
"function",
"getStyleCodes",
"(",
"string",
"$",
"tag",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"styles",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"styles",
"[",
"$",
"tag",
"... | Returns style codes associated with the tag name.
@param string $tag Tag name
@throws \mako\cli\output\formatter\FormatterException
@return array | [
"Returns",
"style",
"codes",
"associated",
"with",
"the",
"tag",
"name",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/formatter/Formatter.php#L158-L177 | train |
mako-framework/framework | src/mako/cli/output/formatter/Formatter.php | Formatter.closeStyle | protected function closeStyle(string $tag): string
{
if($this->getTagName($tag) !== end($this->openTags))
{
throw new FormatterException('Detected incorrectly nested formatting tag.');
}
// Pop the tag off the array of open tags
array_pop($this->openTags);
// Reset style
$style = $this->getSgrResetSequence();
// Append previous styles if the closed tag was nested
if(!empty($this->openTags))
{
foreach($this->openTags as $tag)
{
$style .= $this->getSgrStyleSequence($tag);
}
}
// Return style
return $style;
} | php | protected function closeStyle(string $tag): string
{
if($this->getTagName($tag) !== end($this->openTags))
{
throw new FormatterException('Detected incorrectly nested formatting tag.');
}
// Pop the tag off the array of open tags
array_pop($this->openTags);
// Reset style
$style = $this->getSgrResetSequence();
// Append previous styles if the closed tag was nested
if(!empty($this->openTags))
{
foreach($this->openTags as $tag)
{
$style .= $this->getSgrStyleSequence($tag);
}
}
// Return style
return $style;
} | [
"protected",
"function",
"closeStyle",
"(",
"string",
"$",
"tag",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"getTagName",
"(",
"$",
"tag",
")",
"!==",
"end",
"(",
"$",
"this",
"->",
"openTags",
")",
")",
"{",
"throw",
"new",
"FormatterEx... | Returns ANSI SGR escape sequence for style reset and
ANSI SGR escape sequence for parent style if the closed tag was nested.
@param string $tag Tag name
@throws \mako\cli\output\formatter\FormatterException
@return string | [
"Returns",
"ANSI",
"SGR",
"escape",
"sequence",
"for",
"style",
"reset",
"and",
"ANSI",
"SGR",
"escape",
"sequence",
"for",
"parent",
"style",
"if",
"the",
"closed",
"tag",
"was",
"nested",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/formatter/Formatter.php#L214-L242 | train |
mako-framework/framework | src/mako/http/routing/URLBuilder.php | URLBuilder.matches | public function matches(string $pattern): bool
{
return (bool) preg_match('#' . $pattern . '#', $this->request->getPath());
} | php | public function matches(string $pattern): bool
{
return (bool) preg_match('#' . $pattern . '#', $this->request->getPath());
} | [
"public",
"function",
"matches",
"(",
"string",
"$",
"pattern",
")",
":",
"bool",
"{",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"'#'",
".",
"$",
"pattern",
".",
"'#'",
",",
"$",
"this",
"->",
"request",
"->",
"getPath",
"(",
")",
")",
";",
"}... | Returns TRUE if the pattern matches the current route and FALSE if not.
@param string $pattern Pattern to match
@return bool | [
"Returns",
"TRUE",
"if",
"the",
"pattern",
"matches",
"the",
"current",
"route",
"and",
"FALSE",
"if",
"not",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/URLBuilder.php#L98-L101 | train |
mako-framework/framework | src/mako/http/routing/URLBuilder.php | URLBuilder.to | public function to(string $path, array $queryParams = [], string $separator = '&', $language = true): string
{
$url = $this->baseURL . ($this->cleanURLs ? '' : '/' . $this->scriptName) . ($language === true ? $this->languagePrefix : (!$language ? '' : '/' . $language)) . $path;
if(!empty($queryParams))
{
$url .= '?' . http_build_query($queryParams, '', $separator, PHP_QUERY_RFC3986);
}
return $url;
} | php | public function to(string $path, array $queryParams = [], string $separator = '&', $language = true): string
{
$url = $this->baseURL . ($this->cleanURLs ? '' : '/' . $this->scriptName) . ($language === true ? $this->languagePrefix : (!$language ? '' : '/' . $language)) . $path;
if(!empty($queryParams))
{
$url .= '?' . http_build_query($queryParams, '', $separator, PHP_QUERY_RFC3986);
}
return $url;
} | [
"public",
"function",
"to",
"(",
"string",
"$",
"path",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
",",
"string",
"$",
"separator",
"=",
"'&'",
",",
"$",
"language",
"=",
"true",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
... | Returns the URL of the specified path.
@param string $path Path
@param array $queryParams Associative array used to build URL-encoded query string
@param string $separator Argument separator
@param mixed $language Request language
@return string | [
"Returns",
"the",
"URL",
"of",
"the",
"specified",
"path",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/URLBuilder.php#L122-L132 | train |
mako-framework/framework | src/mako/http/routing/URLBuilder.php | URLBuilder.toLanguage | public function toLanguage(string $route, $language, array $queryParams = [], string $separator = '&'): string
{
return $this->to($route, $queryParams, $separator, $language);
} | php | public function toLanguage(string $route, $language, array $queryParams = [], string $separator = '&'): string
{
return $this->to($route, $queryParams, $separator, $language);
} | [
"public",
"function",
"toLanguage",
"(",
"string",
"$",
"route",
",",
"$",
"language",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
",",
"string",
"$",
"separator",
"=",
"'&'",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"to",
"(",
"$",... | Returns the URL of the specified route.
@param string $route URL segments
@param mixed $language Request language
@param array $queryParams Associative array used to build URL-encoded query string
@param string $separator Argument separator
@return string | [
"Returns",
"the",
"URL",
"of",
"the",
"specified",
"route",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/routing/URLBuilder.php#L190-L193 | train |
mako-framework/framework | src/mako/http/request/Parameters.php | Parameters.add | public function add(string $name, $value): void
{
Arr::set($this->parameters, $name, $value);
} | php | public function add(string $name, $value): void
{
Arr::set($this->parameters, $name, $value);
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"void",
"{",
"Arr",
"::",
"set",
"(",
"$",
"this",
"->",
"parameters",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | Adds a parameter.
@param string $name Parameter name
@param mixed $value Parameter value | [
"Adds",
"a",
"parameter",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/request/Parameters.php#L70-L73 | train |
mako-framework/framework | src/mako/pagination/Pagination.php | Pagination.buildPageUrl | protected function buildPageUrl(int $page): string
{
if($this->params === null)
{
$this->params = $this->request->getQuery()->all();
}
return $this->urlBuilder->current([$this->options['page_key'] => $page] + $this->params);
} | php | protected function buildPageUrl(int $page): string
{
if($this->params === null)
{
$this->params = $this->request->getQuery()->all();
}
return $this->urlBuilder->current([$this->options['page_key'] => $page] + $this->params);
} | [
"protected",
"function",
"buildPageUrl",
"(",
"int",
"$",
"page",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"params",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"params",
"=",
"$",
"this",
"->",
"request",
"->",
"getQuery",
"(",
")",
... | Builds a url to the desired page.
@param int $page Page
@return string | [
"Builds",
"a",
"url",
"to",
"the",
"desired",
"page",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/pagination/Pagination.php#L222-L230 | train |
mako-framework/framework | src/mako/pagination/Pagination.php | Pagination.pagination | public function pagination(): array
{
if(empty($this->pagination))
{
if(empty($this->request))
{
throw new RuntimeException('A [ Request ] instance is required to generate the pagination array.');
}
if(empty($this->urlBuilder))
{
throw new RuntimeException('A [ URLBuilder ] instance is required to generate the pagination array.');
}
$pagination = $this->toArray();
if($this->options['max_page_links'] !== 0)
{
if($this->pages > $this->options['max_page_links'])
{
$start = (int) max(($this->currentPage) - ceil($this->options['max_page_links'] / 2), 0);
$end = $start + $this->options['max_page_links'];
if($end > $this->pages)
{
$end = $this->pages;
}
if($start > ($end - $this->options['max_page_links']))
{
$start = $end - $this->options['max_page_links'];
}
}
else
{
$start = 0;
$end = $this->pages;
}
$pagination['pages'] = [];
for($i = $start + 1; $i <= $end; $i++)
{
$pagination['pages'][] =
[
'url' => $this->buildPageUrl($i),
'number' => $i,
'is_current' => $i === $this->currentPage,
];
}
}
$this->pagination = $pagination;
}
return $this->pagination;
} | php | public function pagination(): array
{
if(empty($this->pagination))
{
if(empty($this->request))
{
throw new RuntimeException('A [ Request ] instance is required to generate the pagination array.');
}
if(empty($this->urlBuilder))
{
throw new RuntimeException('A [ URLBuilder ] instance is required to generate the pagination array.');
}
$pagination = $this->toArray();
if($this->options['max_page_links'] !== 0)
{
if($this->pages > $this->options['max_page_links'])
{
$start = (int) max(($this->currentPage) - ceil($this->options['max_page_links'] / 2), 0);
$end = $start + $this->options['max_page_links'];
if($end > $this->pages)
{
$end = $this->pages;
}
if($start > ($end - $this->options['max_page_links']))
{
$start = $end - $this->options['max_page_links'];
}
}
else
{
$start = 0;
$end = $this->pages;
}
$pagination['pages'] = [];
for($i = $start + 1; $i <= $end; $i++)
{
$pagination['pages'][] =
[
'url' => $this->buildPageUrl($i),
'number' => $i,
'is_current' => $i === $this->currentPage,
];
}
}
$this->pagination = $pagination;
}
return $this->pagination;
} | [
"public",
"function",
"pagination",
"(",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"pagination",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"request",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
... | Builds and returns the pagination array.
@throws \RuntimeException
@return array | [
"Builds",
"and",
"returns",
"the",
"pagination",
"array",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/pagination/Pagination.php#L284-L342 | train |
mako-framework/framework | src/mako/pagination/Pagination.php | Pagination.render | public function render(string $view): string
{
if(empty($this->viewFactory))
{
throw new RuntimeException('A [ ViewFactory ] instance is required to render pagination views.');
}
return $this->viewFactory->create($view, $this->pagination())->render();
} | php | public function render(string $view): string
{
if(empty($this->viewFactory))
{
throw new RuntimeException('A [ ViewFactory ] instance is required to render pagination views.');
}
return $this->viewFactory->create($view, $this->pagination())->render();
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"view",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"viewFactory",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'A [ ViewFactory ] instance is required to render pagination vi... | Renders and returns the pagination partial.
@param string $view Pagination view
@throws \RuntimeException
@return string | [
"Renders",
"and",
"returns",
"the",
"pagination",
"partial",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/pagination/Pagination.php#L351-L359 | train |
mako-framework/framework | src/mako/database/midgard/relations/Relation.php | Relation.getForeignKey | protected function getForeignKey()
{
if($this->foreignKey === null)
{
$this->foreignKey = $this->parent->getForeignKey();
}
return $this->foreignKey;
} | php | protected function getForeignKey()
{
if($this->foreignKey === null)
{
$this->foreignKey = $this->parent->getForeignKey();
}
return $this->foreignKey;
} | [
"protected",
"function",
"getForeignKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"foreignKey",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"foreignKey",
"=",
"$",
"this",
"->",
"parent",
"->",
"getForeignKey",
"(",
")",
";",
"}",
"return",
"$",
... | Returns the foreign key.
@return string | [
"Returns",
"the",
"foreign",
"key",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/relations/Relation.php#L79-L87 | train |
mako-framework/framework | src/mako/database/midgard/relations/Relation.php | Relation.keys | protected function keys(array $results)
{
$keys = [];
foreach($results as $result)
{
$keys[] = $result->getPrimaryKeyValue();
}
return array_unique($keys);
} | php | protected function keys(array $results)
{
$keys = [];
foreach($results as $result)
{
$keys[] = $result->getPrimaryKeyValue();
}
return array_unique($keys);
} | [
"protected",
"function",
"keys",
"(",
"array",
"$",
"results",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"$",
"result",
"->",
"getPrimaryKeyValue",
"(",
")"... | Returns the keys used to eagerly load records.
@param array $results Result set
@return array | [
"Returns",
"the",
"keys",
"used",
"to",
"eagerly",
"load",
"records",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/relations/Relation.php#L95-L105 | train |
mako-framework/framework | src/mako/database/midgard/relations/Relation.php | Relation.lazyCriterion | protected function lazyCriterion(): void
{
$this->where($this->table . '.' . $this->getForeignKey(), '=', $this->parent->getPrimaryKeyValue());
} | php | protected function lazyCriterion(): void
{
$this->where($this->table . '.' . $this->getForeignKey(), '=', $this->parent->getPrimaryKeyValue());
} | [
"protected",
"function",
"lazyCriterion",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"where",
"(",
"$",
"this",
"->",
"table",
".",
"'.'",
".",
"$",
"this",
"->",
"getForeignKey",
"(",
")",
",",
"'='",
",",
"$",
"this",
"->",
"parent",
"->",
"g... | Sets the criterion used when lazy loading related records. | [
"Sets",
"the",
"criterion",
"used",
"when",
"lazy",
"loading",
"related",
"records",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/relations/Relation.php#L110-L113 | train |
mako-framework/framework | src/mako/database/midgard/relations/Relation.php | Relation.eagerLoadChunked | protected function eagerLoadChunked(array $keys)
{
if(count($keys) > static::EAGER_LOAD_CHUNK_SIZE)
{
$records = [];
foreach(array_chunk($keys, static::EAGER_LOAD_CHUNK_SIZE) as $chunk)
{
$query = clone $this;
$records = array_merge($records, $query->eagerCriterion($chunk)->all()->getItems());
}
return $this->createResultSet($records);
}
return $this->eagerCriterion($keys)->all();
} | php | protected function eagerLoadChunked(array $keys)
{
if(count($keys) > static::EAGER_LOAD_CHUNK_SIZE)
{
$records = [];
foreach(array_chunk($keys, static::EAGER_LOAD_CHUNK_SIZE) as $chunk)
{
$query = clone $this;
$records = array_merge($records, $query->eagerCriterion($chunk)->all()->getItems());
}
return $this->createResultSet($records);
}
return $this->eagerCriterion($keys)->all();
} | [
"protected",
"function",
"eagerLoadChunked",
"(",
"array",
"$",
"keys",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
">",
"static",
"::",
"EAGER_LOAD_CHUNK_SIZE",
")",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_chunk",
"(",
... | Eager loads records in chunks.
@param array $keys Parent keys
@return \mako\database\midgard\ResultSet | [
"Eager",
"loads",
"records",
"in",
"chunks",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/midgard/relations/Relation.php#L136-L153 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.setOperation | protected function setOperation($query, string $operation)
{
if(($query instanceof Subquery) === false)
{
$query = new Subquery($query);
}
$this->setOperations[] =
[
'query' => $query,
'operation' => $operation,
];
return $this;
} | php | protected function setOperation($query, string $operation)
{
if(($query instanceof Subquery) === false)
{
$query = new Subquery($query);
}
$this->setOperations[] =
[
'query' => $query,
'operation' => $operation,
];
return $this;
} | [
"protected",
"function",
"setOperation",
"(",
"$",
"query",
",",
"string",
"$",
"operation",
")",
"{",
"if",
"(",
"(",
"$",
"query",
"instanceof",
"Subquery",
")",
"===",
"false",
")",
"{",
"$",
"query",
"=",
"new",
"Subquery",
"(",
"$",
"query",
")",
... | Adds a set operation.
@param \Closure|\mako\database\query\Query|\mako\database\query\Subquery $query Query
@param string $operation Operation
@return $this | [
"Adds",
"a",
"set",
"operation",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L381-L395 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.table | public function table($table)
{
if($table instanceof Closure)
{
$table = new Subquery($table, 'mako0');
}
$this->table = $table;
return $this;
} | php | public function table($table)
{
if($table instanceof Closure)
{
$table = new Subquery($table, 'mako0');
}
$this->table = $table;
return $this;
} | [
"public",
"function",
"table",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"table",
"instanceof",
"Closure",
")",
"{",
"$",
"table",
"=",
"new",
"Subquery",
"(",
"$",
"table",
",",
"'mako0'",
")",
";",
"}",
"$",
"this",
"->",
"table",
"=",
"$",
... | Sets table we want to query.
@param string|\Closure|\mako\database\query\Subquery|\mako\database\query\Raw $table Database table or subquery
@return $this | [
"Sets",
"table",
"we",
"want",
"to",
"query",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L469-L479 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.whereRaw | public function whereRaw($column, $operator = null, ?string $raw = null, string $separator = 'AND')
{
if($raw === null)
{
$this->wheres[] =
[
'type' => 'whereRaw',
'raw' => new Raw($column, is_array($operator) ? $operator : []),
'separator' => $separator,
];
return $this;
}
return $this->where($column, $operator, new Raw($raw), $separator);
} | php | public function whereRaw($column, $operator = null, ?string $raw = null, string $separator = 'AND')
{
if($raw === null)
{
$this->wheres[] =
[
'type' => 'whereRaw',
'raw' => new Raw($column, is_array($operator) ? $operator : []),
'separator' => $separator,
];
return $this;
}
return $this->where($column, $operator, new Raw($raw), $separator);
} | [
"public",
"function",
"whereRaw",
"(",
"$",
"column",
",",
"$",
"operator",
"=",
"null",
",",
"?",
"string",
"$",
"raw",
"=",
"null",
",",
"string",
"$",
"separator",
"=",
"'AND'",
")",
"{",
"if",
"(",
"$",
"raw",
"===",
"null",
")",
"{",
"$",
"t... | Adds a raw WHERE clause.
@param string|array $column Column name, an array of column names or raw SQL
@param string|array|null $operator Operator or parameters
@param string|null $raw Raw SQL
@param string $separator Clause separator
@return $this | [
"Adds",
"a",
"raw",
"WHERE",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L576-L591 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.orWhereRaw | public function orWhereRaw($column, $operator = null, ?string $raw = null)
{
return $this->whereRaw($column, $operator, $raw, 'OR');
} | php | public function orWhereRaw($column, $operator = null, ?string $raw = null)
{
return $this->whereRaw($column, $operator, $raw, 'OR');
} | [
"public",
"function",
"orWhereRaw",
"(",
"$",
"column",
",",
"$",
"operator",
"=",
"null",
",",
"?",
"string",
"$",
"raw",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"whereRaw",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"raw",
",... | Adds a raw OR WHERE clause.
@param string|array $column Column name, and array of column names or raw SQL
@param string|array|null $operator Operator or parameters
@param string|null $raw Raw SQL
@return $this | [
"Adds",
"a",
"raw",
"OR",
"WHERE",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L614-L617 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.between | public function between($column, $value1, $value2, string $separator = 'AND', bool $not = false)
{
$this->wheres[] =
[
'type' => 'between',
'column' => $column,
'value1' => $value1,
'value2' => $value2,
'separator' => $separator,
'not' => $not,
];
return $this;
} | php | public function between($column, $value1, $value2, string $separator = 'AND', bool $not = false)
{
$this->wheres[] =
[
'type' => 'between',
'column' => $column,
'value1' => $value1,
'value2' => $value2,
'separator' => $separator,
'not' => $not,
];
return $this;
} | [
"public",
"function",
"between",
"(",
"$",
"column",
",",
"$",
"value1",
",",
"$",
"value2",
",",
"string",
"$",
"separator",
"=",
"'AND'",
",",
"bool",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"[",
"'type'",
... | Adds a BETWEEN clause.
@param mixed $column Column name
@param mixed $value1 First value
@param mixed $value2 Second value
@param string $separator Clause separator
@param bool $not Not between?
@return $this | [
"Adds",
"a",
"BETWEEN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L629-L642 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.notBetween | public function notBetween($column, $value1, $value2)
{
return $this->between($column, $value1, $value2, 'AND', true);
} | php | public function notBetween($column, $value1, $value2)
{
return $this->between($column, $value1, $value2, 'AND', true);
} | [
"public",
"function",
"notBetween",
"(",
"$",
"column",
",",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"return",
"$",
"this",
"->",
"between",
"(",
"$",
"column",
",",
"$",
"value1",
",",
"$",
"value2",
",",
"'AND'",
",",
"true",
")",
";",
"}"
] | Adds a NOT BETWEEN clause.
@param mixed $column Column name
@param mixed $value1 First value
@param mixed $value2 Second value
@return $this | [
"Adds",
"a",
"NOT",
"BETWEEN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L665-L668 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.orNotBetween | public function orNotBetween($column, $value1, $value2)
{
return $this->between($column, $value1, $value2, 'OR', true);
} | php | public function orNotBetween($column, $value1, $value2)
{
return $this->between($column, $value1, $value2, 'OR', true);
} | [
"public",
"function",
"orNotBetween",
"(",
"$",
"column",
",",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"return",
"$",
"this",
"->",
"between",
"(",
"$",
"column",
",",
"$",
"value1",
",",
"$",
"value2",
",",
"'OR'",
",",
"true",
")",
";",
"}"
... | Adds a OR NOT BETWEEN clause.
@param mixed $column Column name
@param mixed $value1 First value
@param mixed $value2 Second value
@return $this | [
"Adds",
"a",
"OR",
"NOT",
"BETWEEN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L678-L681 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.in | public function in($column, $values, string $separator = 'AND', bool $not = false)
{
if($values instanceof Raw || $values instanceof Subquery)
{
$values = [$values];
}
elseif($values instanceof Closure)
{
$values = [new Subquery($values)];
}
$this->wheres[] =
[
'type' => 'in',
'column' => $column,
'values' => $values,
'separator' => $separator,
'not' => $not,
];
return $this;
} | php | public function in($column, $values, string $separator = 'AND', bool $not = false)
{
if($values instanceof Raw || $values instanceof Subquery)
{
$values = [$values];
}
elseif($values instanceof Closure)
{
$values = [new Subquery($values)];
}
$this->wheres[] =
[
'type' => 'in',
'column' => $column,
'values' => $values,
'separator' => $separator,
'not' => $not,
];
return $this;
} | [
"public",
"function",
"in",
"(",
"$",
"column",
",",
"$",
"values",
",",
"string",
"$",
"separator",
"=",
"'AND'",
",",
"bool",
"$",
"not",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"values",
"instanceof",
"Raw",
"||",
"$",
"values",
"instanceof",
"Sub... | Adds a IN clause.
@param mixed $column Column name
@param array|\mako\database\query\Raw|\Closure|\mako\database\query\Subquery $values Array of values or Subquery
@param string $separator Clause separator
@param bool $not Not in?
@return $this | [
"Adds",
"a",
"IN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L692-L713 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.isNull | public function isNull($column, string $separator = 'AND', bool $not = false)
{
$this->wheres[] =
[
'type' => 'null',
'column' => $column,
'separator' => $separator,
'not' => $not,
];
return $this;
} | php | public function isNull($column, string $separator = 'AND', bool $not = false)
{
$this->wheres[] =
[
'type' => 'null',
'column' => $column,
'separator' => $separator,
'not' => $not,
];
return $this;
} | [
"public",
"function",
"isNull",
"(",
"$",
"column",
",",
"string",
"$",
"separator",
"=",
"'AND'",
",",
"bool",
"$",
"not",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'null'",
",",
"'column'",
"=>",
"$... | Adds a IS NULL clause.
@param mixed $column Column name
@param string $separator Clause separator
@param bool $not Not in?
@return $this | [
"Adds",
"a",
"IS",
"NULL",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L759-L770 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.exists | public function exists($query, string $separator = 'AND', bool $not = false)
{
if($query instanceof Closure)
{
$query = new Subquery($query);
}
$this->wheres[] =
[
'type' => 'exists',
'query' => $query,
'separator' => $separator,
'not' => $not,
];
return $this;
} | php | public function exists($query, string $separator = 'AND', bool $not = false)
{
if($query instanceof Closure)
{
$query = new Subquery($query);
}
$this->wheres[] =
[
'type' => 'exists',
'query' => $query,
'separator' => $separator,
'not' => $not,
];
return $this;
} | [
"public",
"function",
"exists",
"(",
"$",
"query",
",",
"string",
"$",
"separator",
"=",
"'AND'",
",",
"bool",
"$",
"not",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"query",
"instanceof",
"Closure",
")",
"{",
"$",
"query",
"=",
"new",
"Subquery",
"(",
... | Adds a EXISTS clause.
@param \Closure|\mako\database\query\Subquery $query Subquery
@param string $separator Clause separator
@param bool $not Not exists?
@return $this | [
"Adds",
"a",
"EXISTS",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L813-L829 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.join | public function join($table, $column1 = null, $operator = null, $column2 = null, string $type = 'INNER', bool $raw = false)
{
$join = new Join($type, $table);
if($column1 instanceof Closure)
{
$column1($join);
}
else
{
if($raw)
{
$join->onRaw($column1, $operator, $column2);
}
else
{
$join->on($column1, $operator, $column2);
}
}
$this->joins[] = $join;
return $this;
} | php | public function join($table, $column1 = null, $operator = null, $column2 = null, string $type = 'INNER', bool $raw = false)
{
$join = new Join($type, $table);
if($column1 instanceof Closure)
{
$column1($join);
}
else
{
if($raw)
{
$join->onRaw($column1, $operator, $column2);
}
else
{
$join->on($column1, $operator, $column2);
}
}
$this->joins[] = $join;
return $this;
} | [
"public",
"function",
"join",
"(",
"$",
"table",
",",
"$",
"column1",
"=",
"null",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"column2",
"=",
"null",
",",
"string",
"$",
"type",
"=",
"'INNER'",
",",
"bool",
"$",
"raw",
"=",
"false",
")",
"{",
"... | Adds a JOIN clause.
@param string $table Table name
@param string|\Closure $column1 Column name or closure
@param string $operator Operator
@param string $column2 Column name
@param string $type Join type
@param bool $raw Raw join?
@return $this | [
"Adds",
"a",
"JOIN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L875-L898 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.joinRaw | public function joinRaw($table, $column1, $operator, $raw, string $type = 'INNER')
{
return $this->join($table, $column1, $operator, $raw, $type, true);
} | php | public function joinRaw($table, $column1, $operator, $raw, string $type = 'INNER')
{
return $this->join($table, $column1, $operator, $raw, $type, true);
} | [
"public",
"function",
"joinRaw",
"(",
"$",
"table",
",",
"$",
"column1",
",",
"$",
"operator",
",",
"$",
"raw",
",",
"string",
"$",
"type",
"=",
"'INNER'",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"column1",
",",
... | Adds a raw JOIN clause.
@param string $table Table name
@param string $column1 Column name or closure
@param string $operator Operator
@param string $raw Raw SQL
@param string $type Join type
@return $this | [
"Adds",
"a",
"raw",
"JOIN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L910-L913 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.leftJoin | public function leftJoin($table, $column1 = null, $operator = null, $column2 = null)
{
return $this->join($table, $column1, $operator, $column2, 'LEFT OUTER');
} | php | public function leftJoin($table, $column1 = null, $operator = null, $column2 = null)
{
return $this->join($table, $column1, $operator, $column2, 'LEFT OUTER');
} | [
"public",
"function",
"leftJoin",
"(",
"$",
"table",
",",
"$",
"column1",
"=",
"null",
",",
"$",
"operator",
"=",
"null",
",",
"$",
"column2",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"join",
"(",
"$",
"table",
",",
"$",
"column1",
",",
... | Adds a LEFT OUTER JOIN clause.
@param string $table Table name
@param string|\Closure $column1 Column name or closure
@param string $operator Operator
@param string $column2 Column name
@return $this | [
"Adds",
"a",
"LEFT",
"OUTER",
"JOIN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L924-L927 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.leftJoinRaw | public function leftJoinRaw($table, $column1, $operator, $raw)
{
return $this->joinRaw($table, $column1, $operator, $raw, 'LEFT OUTER');
} | php | public function leftJoinRaw($table, $column1, $operator, $raw)
{
return $this->joinRaw($table, $column1, $operator, $raw, 'LEFT OUTER');
} | [
"public",
"function",
"leftJoinRaw",
"(",
"$",
"table",
",",
"$",
"column1",
",",
"$",
"operator",
",",
"$",
"raw",
")",
"{",
"return",
"$",
"this",
"->",
"joinRaw",
"(",
"$",
"table",
",",
"$",
"column1",
",",
"$",
"operator",
",",
"$",
"raw",
","... | Adds a raw LEFT OUTER JOIN clause.
@param string $table Table name
@param string $column1 Column name or closure
@param string $operator Operator
@param string $raw Raw SQL
@return $this | [
"Adds",
"a",
"raw",
"LEFT",
"OUTER",
"JOIN",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L938-L941 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.having | public function having($column, $operator, $value, string $separator = 'AND')
{
$this->havings[] =
[
'column' => $column,
'operator' => $operator,
'value' => $value,
'separator' => $separator,
];
return $this;
} | php | public function having($column, $operator, $value, string $separator = 'AND')
{
$this->havings[] =
[
'column' => $column,
'operator' => $operator,
'value' => $value,
'separator' => $separator,
];
return $this;
} | [
"public",
"function",
"having",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"string",
"$",
"separator",
"=",
"'AND'",
")",
"{",
"$",
"this",
"->",
"havings",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"$",
"column",
",",
"'operator'"... | Adds a HAVING clause.
@param string $column Column name
@param string $operator Operator
@param mixed $value Value
@param string $separator Clause separator
@return $this | [
"Adds",
"a",
"HAVING",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L965-L976 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.havingRaw | public function havingRaw($raw, $operator, $value, string $separator = 'AND')
{
return $this->having(new Raw($raw), $operator, $value, $separator);
} | php | public function havingRaw($raw, $operator, $value, string $separator = 'AND')
{
return $this->having(new Raw($raw), $operator, $value, $separator);
} | [
"public",
"function",
"havingRaw",
"(",
"$",
"raw",
",",
"$",
"operator",
",",
"$",
"value",
",",
"string",
"$",
"separator",
"=",
"'AND'",
")",
"{",
"return",
"$",
"this",
"->",
"having",
"(",
"new",
"Raw",
"(",
"$",
"raw",
")",
",",
"$",
"operato... | Adds a raw HAVING clause.
@param string $raw Raw SQL
@param string $operator Operator
@param mixed $value Value
@param string $separator Clause separator
@return $this | [
"Adds",
"a",
"raw",
"HAVING",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L987-L990 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.orderBy | public function orderBy($columns, string $order = 'ASC')
{
$this->orderings[] =
[
'column' => is_array($columns) ? $columns : [$columns],
'order' => ($order === 'ASC' || $order === 'asc') ? 'ASC' : 'DESC',
];
return $this;
} | php | public function orderBy($columns, string $order = 'ASC')
{
$this->orderings[] =
[
'column' => is_array($columns) ? $columns : [$columns],
'order' => ($order === 'ASC' || $order === 'asc') ? 'ASC' : 'DESC',
];
return $this;
} | [
"public",
"function",
"orderBy",
"(",
"$",
"columns",
",",
"string",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"$",
"this",
"->",
"orderings",
"[",
"]",
"=",
"[",
"'column'",
"=>",
"is_array",
"(",
"$",
"columns",
")",
"?",
"$",
"columns",
":",
"[",
"$... | Adds a ORDER BY clause.
@param string|array $columns Column name or array of column names
@param string $order Sorting order
@return $this | [
"Adds",
"a",
"ORDER",
"BY",
"clause",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1025-L1034 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.column | public function column($column = null)
{
if($column !== null)
{
$this->select([$column]);
}
$query = $this->limit(1)->compiler->select();
return $this->connection->column($query['sql'], $query['params']);
} | php | public function column($column = null)
{
if($column !== null)
{
$this->select([$column]);
}
$query = $this->limit(1)->compiler->select();
return $this->connection->column($query['sql'], $query['params']);
} | [
"public",
"function",
"column",
"(",
"$",
"column",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"column",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"select",
"(",
"[",
"$",
"column",
"]",
")",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"limit... | Executes a SELECT query and returns the value of the chosen column of the first row of the result set.
@param string $column The column to select
@return mixed | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"the",
"value",
"of",
"the",
"chosen",
"column",
"of",
"the",
"first",
"row",
"of",
"the",
"result",
"set",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1172-L1182 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.fetchFirst | protected function fetchFirst(...$fetchMode)
{
$query = $this->limit(1)->compiler->select();
return $this->connection->first($query['sql'], $query['params'], ...$fetchMode);
} | php | protected function fetchFirst(...$fetchMode)
{
$query = $this->limit(1)->compiler->select();
return $this->connection->first($query['sql'], $query['params'], ...$fetchMode);
} | [
"protected",
"function",
"fetchFirst",
"(",
"...",
"$",
"fetchMode",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"limit",
"(",
"1",
")",
"->",
"compiler",
"->",
"select",
"(",
")",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"first",
"(... | Executes a SELECT query and returns the first row of the result set.
@param mixed ...$fetchMode Fetch mode
@return mixed | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"the",
"first",
"row",
"of",
"the",
"result",
"set",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1224-L1229 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.fetchAll | protected function fetchAll(bool $returnResultSet, ...$fetchMode)
{
$query = $this->compiler->select();
$results = $this->connection->all($query['sql'], $query['params'], ...$fetchMode);
return $returnResultSet ? $this->createResultSet($results) : $results;
} | php | protected function fetchAll(bool $returnResultSet, ...$fetchMode)
{
$query = $this->compiler->select();
$results = $this->connection->all($query['sql'], $query['params'], ...$fetchMode);
return $returnResultSet ? $this->createResultSet($results) : $results;
} | [
"protected",
"function",
"fetchAll",
"(",
"bool",
"$",
"returnResultSet",
",",
"...",
"$",
"fetchMode",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"compiler",
"->",
"select",
"(",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"connection",
"->... | Executes a SELECT query and returns an array containing all of the result set rows.
@param bool $returnResultSet Return result set?
@param mixed ...$fetchMode Fetch mode
@return array|\mako\database\query\ResultSet | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"an",
"array",
"containing",
"all",
"of",
"the",
"result",
"set",
"rows",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1259-L1266 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.fetchYield | protected function fetchYield(...$fetchMode): Generator
{
$query = $this->compiler->select();
yield from $this->connection->yield($query['sql'], $query['params'], ...$fetchMode);
} | php | protected function fetchYield(...$fetchMode): Generator
{
$query = $this->compiler->select();
yield from $this->connection->yield($query['sql'], $query['params'], ...$fetchMode);
} | [
"protected",
"function",
"fetchYield",
"(",
"...",
"$",
"fetchMode",
")",
":",
"Generator",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"compiler",
"->",
"select",
"(",
")",
";",
"yield",
"from",
"$",
"this",
"->",
"connection",
"->",
"yield",
"(",
"$",... | Executes a SELECT query and returns a generator that lets you iterate over the results.
@param mixed ...$fetchMode Fetch mode
@return \Generator | [
"Executes",
"a",
"SELECT",
"query",
"and",
"returns",
"a",
"generator",
"that",
"lets",
"you",
"iterate",
"over",
"the",
"results",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1284-L1289 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.paginationCount | protected function paginationCount(): int
{
$clone = (clone $this)->clearOrderings();
if(empty($this->groupings) && $this->distinct === false)
{
return $clone->count();
}
return $this->newInstance()->table(new Subquery($clone, 'count'))->count();
} | php | protected function paginationCount(): int
{
$clone = (clone $this)->clearOrderings();
if(empty($this->groupings) && $this->distinct === false)
{
return $clone->count();
}
return $this->newInstance()->table(new Subquery($clone, 'count'))->count();
} | [
"protected",
"function",
"paginationCount",
"(",
")",
":",
"int",
"{",
"$",
"clone",
"=",
"(",
"clone",
"$",
"this",
")",
"->",
"clearOrderings",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"groupings",
")",
"&&",
"$",
"this",
"->",
... | Returns the number of records that the query will return.
@return int | [
"Returns",
"the",
"number",
"of",
"records",
"that",
"the",
"query",
"will",
"return",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1306-L1316 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.paginate | public function paginate(?int $itemsPerPage = null, array $options = [])
{
$count = $this->paginationCount();
$pagination = static::getPaginationFactory()->create($count, $itemsPerPage, $options);
if($count > 0)
{
$results = $this->limit($pagination->limit())->offset($pagination->offset())->all();
}
else
{
$results = $this->createResultSet([]);
}
$results->setPagination($pagination);
return $results;
} | php | public function paginate(?int $itemsPerPage = null, array $options = [])
{
$count = $this->paginationCount();
$pagination = static::getPaginationFactory()->create($count, $itemsPerPage, $options);
if($count > 0)
{
$results = $this->limit($pagination->limit())->offset($pagination->offset())->all();
}
else
{
$results = $this->createResultSet([]);
}
$results->setPagination($pagination);
return $results;
} | [
"public",
"function",
"paginate",
"(",
"?",
"int",
"$",
"itemsPerPage",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"paginationCount",
"(",
")",
";",
"$",
"pagination",
"=",
"static",
"::"... | Paginates the results using a pagination instance.
@param int|null $itemsPerPage Number of items per page
@param array $options Pagination options
@return \mako\database\query\ResultSet | [
"Paginates",
"the",
"results",
"using",
"a",
"pagination",
"instance",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1325-L1343 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.batch | public function batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, ?int $offsetEnd = null): void
{
$this->limit($batchSize);
while(true)
{
$query = clone $this;
if($offsetEnd !== null && $offsetStart >= $offsetEnd)
{
break;
}
if($offsetStart !== 0)
{
$query->offset($offsetStart);
}
$results = $query->all();
if(count($results) > 0)
{
$processor($results);
$offsetStart += $batchSize;
}
else
{
break;
}
}
} | php | public function batch(Closure $processor, int $batchSize = 1000, int $offsetStart = 0, ?int $offsetEnd = null): void
{
$this->limit($batchSize);
while(true)
{
$query = clone $this;
if($offsetEnd !== null && $offsetStart >= $offsetEnd)
{
break;
}
if($offsetStart !== 0)
{
$query->offset($offsetStart);
}
$results = $query->all();
if(count($results) > 0)
{
$processor($results);
$offsetStart += $batchSize;
}
else
{
break;
}
}
} | [
"public",
"function",
"batch",
"(",
"Closure",
"$",
"processor",
",",
"int",
"$",
"batchSize",
"=",
"1000",
",",
"int",
"$",
"offsetStart",
"=",
"0",
",",
"?",
"int",
"$",
"offsetEnd",
"=",
"null",
")",
":",
"void",
"{",
"$",
"this",
"->",
"limit",
... | Fetches data in batches and passes them to the processor closure.
@param \Closure $processor Closure that processes the results
@param int $batchSize Batch size
@param int $offsetStart Offset start
@param int|null $offsetEnd Offset end | [
"Fetches",
"data",
"in",
"batches",
"and",
"passes",
"them",
"to",
"the",
"processor",
"closure",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1353-L1384 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.aggregate | protected function aggregate(string $function, $column)
{
$this->select([new Raw(sprintf($function, $this->compiler->columns(is_array($column) ? $column : [$column])))]);
if($this->inSubqueryContext === false)
{
$query = $this->compiler->select();
return $this->connection->column($query['sql'], $query['params']);
}
} | php | protected function aggregate(string $function, $column)
{
$this->select([new Raw(sprintf($function, $this->compiler->columns(is_array($column) ? $column : [$column])))]);
if($this->inSubqueryContext === false)
{
$query = $this->compiler->select();
return $this->connection->column($query['sql'], $query['params']);
}
} | [
"protected",
"function",
"aggregate",
"(",
"string",
"$",
"function",
",",
"$",
"column",
")",
"{",
"$",
"this",
"->",
"select",
"(",
"[",
"new",
"Raw",
"(",
"sprintf",
"(",
"$",
"function",
",",
"$",
"this",
"->",
"compiler",
"->",
"columns",
"(",
"... | Sets the selected column of the query to the chosen aggreate.
Executes the query and returns the result if not in subquery context.
@param string $function Aggregate function
@param string|array $column Column name or array of column names
@return mixed | [
"Sets",
"the",
"selected",
"column",
"of",
"the",
"query",
"to",
"the",
"chosen",
"aggreate",
".",
"Executes",
"the",
"query",
"and",
"returns",
"the",
"result",
"if",
"not",
"in",
"subquery",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1394-L1404 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.insert | public function insert(array $values = []): bool
{
$query = $this->compiler->insert($values);
return $this->connection->query($query['sql'], $query['params']);
} | php | public function insert(array $values = []): bool
{
$query = $this->compiler->insert($values);
return $this->connection->query($query['sql'], $query['params']);
} | [
"public",
"function",
"insert",
"(",
"array",
"$",
"values",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"compiler",
"->",
"insert",
"(",
"$",
"values",
")",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"que... | Inserts data into the chosen table.
@param array $values Associative array of column values
@return bool | [
"Inserts",
"data",
"into",
"the",
"chosen",
"table",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1478-L1483 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.insertAndGetId | public function insertAndGetId(array $values, string $primaryKey = 'id')
{
return $this->helper->insertAndGetId($this, $values, $primaryKey);
} | php | public function insertAndGetId(array $values, string $primaryKey = 'id')
{
return $this->helper->insertAndGetId($this, $values, $primaryKey);
} | [
"public",
"function",
"insertAndGetId",
"(",
"array",
"$",
"values",
",",
"string",
"$",
"primaryKey",
"=",
"'id'",
")",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"insertAndGetId",
"(",
"$",
"this",
",",
"$",
"values",
",",
"$",
"primaryKey",
")"... | Inserts data into the chosen table and returns the auto increment id.
@param array $values Associative array of column values
@param string $primaryKey Primary key
@return int|bool | [
"Inserts",
"data",
"into",
"the",
"chosen",
"table",
"and",
"returns",
"the",
"auto",
"increment",
"id",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1492-L1495 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.update | public function update(array $values): int
{
$query = $this->compiler->update($values);
return $this->connection->queryAndCount($query['sql'], $query['params']);
} | php | public function update(array $values): int
{
$query = $this->compiler->update($values);
return $this->connection->queryAndCount($query['sql'], $query['params']);
} | [
"public",
"function",
"update",
"(",
"array",
"$",
"values",
")",
":",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"compiler",
"->",
"update",
"(",
"$",
"values",
")",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"queryAndCount",
"(",
... | Updates data from the chosen table.
@param array $values Associative array of column values
@return int | [
"Updates",
"data",
"from",
"the",
"chosen",
"table",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1503-L1508 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.increment | public function increment($column, int $increment = 1): int
{
return $this->update([$column => new Raw($this->compiler->escapeIdentifier($column) . ' + ' . (int) $increment)]);
} | php | public function increment($column, int $increment = 1): int
{
return $this->update([$column => new Raw($this->compiler->escapeIdentifier($column) . ' + ' . (int) $increment)]);
} | [
"public",
"function",
"increment",
"(",
"$",
"column",
",",
"int",
"$",
"increment",
"=",
"1",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
"[",
"$",
"column",
"=>",
"new",
"Raw",
"(",
"$",
"this",
"->",
"compiler",
"->",
"esca... | Increments column value.
@param string $column Column name
@param int $increment Increment value
@return int | [
"Increments",
"column",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1517-L1520 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.decrement | public function decrement($column, int $decrement = 1): int
{
return $this->update([$column => new Raw($this->compiler->escapeIdentifier($column) . ' - ' . (int) $decrement)]);
} | php | public function decrement($column, int $decrement = 1): int
{
return $this->update([$column => new Raw($this->compiler->escapeIdentifier($column) . ' - ' . (int) $decrement)]);
} | [
"public",
"function",
"decrement",
"(",
"$",
"column",
",",
"int",
"$",
"decrement",
"=",
"1",
")",
":",
"int",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
"[",
"$",
"column",
"=>",
"new",
"Raw",
"(",
"$",
"this",
"->",
"compiler",
"->",
"esca... | Decrements column value.
@param string $column Column name
@param int $decrement Decrement value
@return int | [
"Decrements",
"column",
"value",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1529-L1532 | train |
mako-framework/framework | src/mako/database/query/Query.php | Query.delete | public function delete(): int
{
$query = $this->compiler->delete();
return $this->connection->queryAndCount($query['sql'], $query['params']);
} | php | public function delete(): int
{
$query = $this->compiler->delete();
return $this->connection->queryAndCount($query['sql'], $query['params']);
} | [
"public",
"function",
"delete",
"(",
")",
":",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"compiler",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"queryAndCount",
"(",
"$",
"query",
"[",
"'sql'",
"]",
",",
... | Deletes data from the chosen table.
@return int | [
"Deletes",
"data",
"from",
"the",
"chosen",
"table",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/database/query/Query.php#L1539-L1544 | train |
mako-framework/framework | src/mako/application/Package.php | Package.getFileNamespace | public function getFileNamespace(): string
{
if($this->fileNamespace === null)
{
$this->fileNamespace = str_replace('/', '-', strtolower($this->packageName));
}
return $this->fileNamespace;
} | php | public function getFileNamespace(): string
{
if($this->fileNamespace === null)
{
$this->fileNamespace = str_replace('/', '-', strtolower($this->packageName));
}
return $this->fileNamespace;
} | [
"public",
"function",
"getFileNamespace",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"fileNamespace",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"fileNamespace",
"=",
"str_replace",
"(",
"'/'",
",",
"'-'",
",",
"strtolower",
"(",
"$",
... | Returns the package namespace.
@return string | [
"Returns",
"the",
"package",
"namespace",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Package.php#L100-L108 | train |
mako-framework/framework | src/mako/application/Package.php | Package.getClassNamespace | public function getClassNamespace(bool $prefix = false): string
{
if($this->classNamespace === null)
{
$this->classNamespace = substr(static::class, 0, strrpos(static::class, '\\'));
}
return $prefix ? '\\' . $this->classNamespace : $this->classNamespace;
} | php | public function getClassNamespace(bool $prefix = false): string
{
if($this->classNamespace === null)
{
$this->classNamespace = substr(static::class, 0, strrpos(static::class, '\\'));
}
return $prefix ? '\\' . $this->classNamespace : $this->classNamespace;
} | [
"public",
"function",
"getClassNamespace",
"(",
"bool",
"$",
"prefix",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"classNamespace",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"classNamespace",
"=",
"substr",
"(",
"static",
"::"... | Returns the class namespace.
@param bool $prefix Prefix the namespace with a slash?
@return string | [
"Returns",
"the",
"class",
"namespace",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Package.php#L116-L124 | train |
mako-framework/framework | src/mako/application/Package.php | Package.getPath | public function getPath(): string
{
if($this->path === null)
{
$this->path = dirname((new ReflectionClass($this))->getFileName(), 2);
}
return $this->path;
} | php | public function getPath(): string
{
if($this->path === null)
{
$this->path = dirname((new ReflectionClass($this))->getFileName(), 2);
}
return $this->path;
} | [
"public",
"function",
"getPath",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"path",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"path",
"=",
"dirname",
"(",
"(",
"new",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getFileN... | Returns package path.
@return string | [
"Returns",
"package",
"path",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Package.php#L131-L139 | train |
mako-framework/framework | src/mako/application/Package.php | Package.boot | public function boot(): void
{
$fileSystem = $this->container->get(FileSystem::class);
// Register configuration namespace
if($fileSystem->isDirectory($path = $this->getConfigPath()))
{
$configLoader = $this->container->get(Config::class)->getLoader();
if(in_array(NamespacedFileLoaderTrait::class, class_uses($configLoader)))
{
$configLoader->registerNamespace($this->getFileNamespace(), $path);
}
}
// Register i18n namespace
if($fileSystem->isDirectory($path = $this->getI18nPath()) && $this->container->has(I18n::class))
{
$i18nLoader = $this->container->get(I18n::class)->getLoader();
if(in_array(NamespacedFileLoaderTrait::class, class_uses($i18nLoader)))
{
$i18nLoader->registerNamespace($this->getFileNamespace(), $path);
}
}
// Register view namespace
if($fileSystem->isDirectory($path = $this->getViewPath()) && $this->container->has(ViewFactory::class))
{
$this->container->get(ViewFactory::class)->registerNamespace($this->getFileNamespace(), $path);
}
// Bootstrap package
$this->bootstrap();
} | php | public function boot(): void
{
$fileSystem = $this->container->get(FileSystem::class);
// Register configuration namespace
if($fileSystem->isDirectory($path = $this->getConfigPath()))
{
$configLoader = $this->container->get(Config::class)->getLoader();
if(in_array(NamespacedFileLoaderTrait::class, class_uses($configLoader)))
{
$configLoader->registerNamespace($this->getFileNamespace(), $path);
}
}
// Register i18n namespace
if($fileSystem->isDirectory($path = $this->getI18nPath()) && $this->container->has(I18n::class))
{
$i18nLoader = $this->container->get(I18n::class)->getLoader();
if(in_array(NamespacedFileLoaderTrait::class, class_uses($i18nLoader)))
{
$i18nLoader->registerNamespace($this->getFileNamespace(), $path);
}
}
// Register view namespace
if($fileSystem->isDirectory($path = $this->getViewPath()) && $this->container->has(ViewFactory::class))
{
$this->container->get(ViewFactory::class)->registerNamespace($this->getFileNamespace(), $path);
}
// Bootstrap package
$this->bootstrap();
} | [
"public",
"function",
"boot",
"(",
")",
":",
"void",
"{",
"$",
"fileSystem",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"FileSystem",
"::",
"class",
")",
";",
"// Register configuration namespace",
"if",
"(",
"$",
"fileSystem",
"->",
"isDirectory... | Boots the package. | [
"Boots",
"the",
"package",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/Package.php#L192-L230 | train |
mako-framework/framework | src/mako/cli/output/helpers/OrderedList.php | OrderedList.calculateWidth | protected function calculateWidth(array $items, string $marker): array
{
$count = 0;
foreach($items as $item)
{
if(!is_array($item))
{
$count++;
}
}
$number = strlen($count);
$marker = strlen(sprintf($this->formatter === null ? $marker : $this->formatter->stripTags($marker), '')) + $number;
return ['number' => $number, 'marker' => $marker];
} | php | protected function calculateWidth(array $items, string $marker): array
{
$count = 0;
foreach($items as $item)
{
if(!is_array($item))
{
$count++;
}
}
$number = strlen($count);
$marker = strlen(sprintf($this->formatter === null ? $marker : $this->formatter->stripTags($marker), '')) + $number;
return ['number' => $number, 'marker' => $marker];
} | [
"protected",
"function",
"calculateWidth",
"(",
"array",
"$",
"items",
",",
"string",
"$",
"marker",
")",
":",
"array",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$... | Calculates the maximum width of a marker in a list.
@param array $items Items
@param string $marker Item marker
@return array | [
"Calculates",
"the",
"maximum",
"width",
"of",
"a",
"marker",
"in",
"a",
"list",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/OrderedList.php#L64-L81 | train |
mako-framework/framework | src/mako/cli/output/helpers/OrderedList.php | OrderedList.buildList | protected function buildList(array $items, string $marker, int $nestingLevel = 0, int $parentWidth = 0): string
{
$width = $this->calculateWidth($items, $marker);
$number = 0;
$list = '';
foreach($items as $item)
{
if(is_array($item))
{
$list .= $this->buildList($item, $marker, ($nestingLevel + 1), ($width['marker'] - 1 + $parentWidth));
}
else
{
$list .= $this->buildListItem($item, $marker, $width['number'], ++$number, $nestingLevel, $parentWidth);
}
}
return $list;
} | php | protected function buildList(array $items, string $marker, int $nestingLevel = 0, int $parentWidth = 0): string
{
$width = $this->calculateWidth($items, $marker);
$number = 0;
$list = '';
foreach($items as $item)
{
if(is_array($item))
{
$list .= $this->buildList($item, $marker, ($nestingLevel + 1), ($width['marker'] - 1 + $parentWidth));
}
else
{
$list .= $this->buildListItem($item, $marker, $width['number'], ++$number, $nestingLevel, $parentWidth);
}
}
return $list;
} | [
"protected",
"function",
"buildList",
"(",
"array",
"$",
"items",
",",
"string",
"$",
"marker",
",",
"int",
"$",
"nestingLevel",
"=",
"0",
",",
"int",
"$",
"parentWidth",
"=",
"0",
")",
":",
"string",
"{",
"$",
"width",
"=",
"$",
"this",
"->",
"calcu... | Builds an ordered list.
@param array $items Items
@param string $marker Item marker
@param int $nestingLevel Nesting level
@param int $parentWidth Parent marker width
@return string | [
"Builds",
"an",
"ordered",
"list",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/helpers/OrderedList.php#L110-L129 | train |
mako-framework/framework | src/mako/cli/output/Output.php | Output.getWriter | public function getWriter(int $writer = Output::STANDARD): WriterInterface
{
return ($writer === static::STANDARD) ? $this->standard : $this->error;
} | php | public function getWriter(int $writer = Output::STANDARD): WriterInterface
{
return ($writer === static::STANDARD) ? $this->standard : $this->error;
} | [
"public",
"function",
"getWriter",
"(",
"int",
"$",
"writer",
"=",
"Output",
"::",
"STANDARD",
")",
":",
"WriterInterface",
"{",
"return",
"(",
"$",
"writer",
"===",
"static",
"::",
"STANDARD",
")",
"?",
"$",
"this",
"->",
"standard",
":",
"$",
"this",
... | Returns the chosen writer.
@param int $writer Writer
@return \mako\cli\output\writer\WriterInterface | [
"Returns",
"the",
"chosen",
"writer",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/Output.php#L97-L100 | train |
mako-framework/framework | src/mako/cli/output/Output.php | Output.dump | public function dump($value, int $writer = Output::STANDARD): void
{
$this->getWriter($writer)->write(var_export($value, true) . PHP_EOL);
} | php | public function dump($value, int $writer = Output::STANDARD): void
{
$this->getWriter($writer)->write(var_export($value, true) . PHP_EOL);
} | [
"public",
"function",
"dump",
"(",
"$",
"value",
",",
"int",
"$",
"writer",
"=",
"Output",
"::",
"STANDARD",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getWriter",
"(",
"$",
"writer",
")",
"->",
"write",
"(",
"var_export",
"(",
"$",
"value",
",",
"... | Dumps a value to the output.
@param mixed $value Value
@param int $writer Output type
@return void | [
"Dumps",
"a",
"value",
"to",
"the",
"output",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/Output.php#L224-L227 | train |
mako-framework/framework | src/mako/cli/output/Output.php | Output.clearLines | public function clearLines(int $lines): void
{
if($this->environment->hasAnsiSupport())
{
for($i = 0; $i < $lines; $i++)
{
if($i > 0)
{
$this->write("\033[F");
}
$this->clearLine();
}
}
} | php | public function clearLines(int $lines): void
{
if($this->environment->hasAnsiSupport())
{
for($i = 0; $i < $lines; $i++)
{
if($i > 0)
{
$this->write("\033[F");
}
$this->clearLine();
}
}
} | [
"public",
"function",
"clearLines",
"(",
"int",
"$",
"lines",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"environment",
"->",
"hasAnsiSupport",
"(",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"lines",
";",
... | Clears n lines.
@param int $lines Number of lines to clear | [
"Clears",
"n",
"lines",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/cli/output/Output.php#L256-L270 | train |
mako-framework/framework | src/mako/http/request/Server.php | Server.getHeaders | public function getHeaders(): array
{
$headers = [];
foreach($this->parameters as $key => $value)
{
if(strpos($key, 'HTTP_') === 0)
{
$headers[substr($key, 5)] = $value;
}
elseif(in_array($key, ['CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE']))
{
$headers[$key] = $value;
}
}
return $headers;
} | php | public function getHeaders(): array
{
$headers = [];
foreach($this->parameters as $key => $value)
{
if(strpos($key, 'HTTP_') === 0)
{
$headers[substr($key, 5)] = $value;
}
elseif(in_array($key, ['CONTENT_LENGTH', 'CONTENT_MD5', 'CONTENT_TYPE']))
{
$headers[$key] = $value;
}
}
return $headers;
} | [
"public",
"function",
"getHeaders",
"(",
")",
":",
"array",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'HTT... | Returns all the request headers.
@return array | [
"Returns",
"all",
"the",
"request",
"headers",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/http/request/Server.php#L26-L43 | train |
mako-framework/framework | src/mako/view/View.php | View.assign | public function assign(string $name, $value): View
{
$this->variables[$name] = $value;
return $this;
} | php | public function assign(string $name, $value): View
{
$this->variables[$name] = $value;
return $this;
} | [
"public",
"function",
"assign",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"View",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Assign a local view variable.
@param string $name Variable name
@param mixed $value View variable
@return \mako\view\View | [
"Assign",
"a",
"local",
"view",
"variable",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/view/View.php#L83-L88 | train |
mako-framework/framework | src/mako/redis/ConnectionManager.php | ConnectionManager.connect | protected function connect(string $connection): Redis
{
if(!isset($this->configurations[$connection]))
{
throw new RuntimeException(vsprintf('[ %s ] has not been defined in the redis configuration.', [$connection]));
}
$config = $this->configurations[$connection];
return new Redis(new Connection($config['host'], $config['port'], $config['persistent'] ?? false, $config['timeout'] ?? 60, $connection), $config);
} | php | protected function connect(string $connection): Redis
{
if(!isset($this->configurations[$connection]))
{
throw new RuntimeException(vsprintf('[ %s ] has not been defined in the redis configuration.', [$connection]));
}
$config = $this->configurations[$connection];
return new Redis(new Connection($config['host'], $config['port'], $config['persistent'] ?? false, $config['timeout'] ?? 60, $connection), $config);
} | [
"protected",
"function",
"connect",
"(",
"string",
"$",
"connection",
")",
":",
"Redis",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"configurations",
"[",
"$",
"connection",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"vsprint... | Connects to the chosen redis configuration and returns the connection.
@param string $connection Connection name
@throws \RuntimeException
@return \mako\redis\Redis | [
"Connects",
"to",
"the",
"chosen",
"redis",
"configuration",
"and",
"returns",
"the",
"connection",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/redis/ConnectionManager.php#L31-L41 | train |
mako-framework/framework | src/mako/security/crypto/encrypters/Encrypter.php | Encrypter.deriveKey | protected function deriveKey(string $key, string $salt, int $keySize): string
{
return hash_pbkdf2(static::DERIVATION_HASH, $key, $salt, static::DERIVATION_ITERATIONS, $keySize, true);
} | php | protected function deriveKey(string $key, string $salt, int $keySize): string
{
return hash_pbkdf2(static::DERIVATION_HASH, $key, $salt, static::DERIVATION_ITERATIONS, $keySize, true);
} | [
"protected",
"function",
"deriveKey",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"salt",
",",
"int",
"$",
"keySize",
")",
":",
"string",
"{",
"return",
"hash_pbkdf2",
"(",
"static",
"::",
"DERIVATION_HASH",
",",
"$",
"key",
",",
"$",
"salt",
",",
"... | Generate a PBKDF2 key derivation of a supplied key.
@param string $key The key to derive
@param string $salt The salt
@param int $keySize The desired key size
@return string | [
"Generate",
"a",
"PBKDF2",
"key",
"derivation",
"of",
"a",
"supplied",
"key",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/security/crypto/encrypters/Encrypter.php#L41-L44 | train |
mako-framework/framework | src/mako/application/services/LoggerService.php | LoggerService.getContext | protected function getContext(): array
{
if($this->app->isCommandLine() === false && $this->container->has(Gatekeeper::class))
{
$user = $this->container->get(Gatekeeper::class)->getUser();
return ['user_id' => $user !== null ? $user->getId() : null];
}
return [];
} | php | protected function getContext(): array
{
if($this->app->isCommandLine() === false && $this->container->has(Gatekeeper::class))
{
$user = $this->container->get(Gatekeeper::class)->getUser();
return ['user_id' => $user !== null ? $user->getId() : null];
}
return [];
} | [
"protected",
"function",
"getContext",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"isCommandLine",
"(",
")",
"===",
"false",
"&&",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"Gatekeeper",
"::",
"class",
")",
")",
"... | Get global logger context.
@return array | [
"Get",
"global",
"logger",
"context",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/services/LoggerService.php#L31-L41 | train |
mako-framework/framework | src/mako/application/services/LoggerService.php | LoggerService.getHandler | protected function getHandler(): HandlerInterface
{
$handler = new StreamHandler($this->app->getPath() . '/storage/logs/' . date('Y-m-d') . '.mako');
$formatter = new LineFormatter(null, null, true, true);
$formatter->includeStacktraces();
$handler->setFormatter($formatter);
return $handler;
} | php | protected function getHandler(): HandlerInterface
{
$handler = new StreamHandler($this->app->getPath() . '/storage/logs/' . date('Y-m-d') . '.mako');
$formatter = new LineFormatter(null, null, true, true);
$formatter->includeStacktraces();
$handler->setFormatter($formatter);
return $handler;
} | [
"protected",
"function",
"getHandler",
"(",
")",
":",
"HandlerInterface",
"{",
"$",
"handler",
"=",
"new",
"StreamHandler",
"(",
"$",
"this",
"->",
"app",
"->",
"getPath",
"(",
")",
".",
"'/storage/logs/'",
".",
"date",
"(",
"'Y-m-d'",
")",
".",
"'.mako'",... | Returns the default handler.
@return \Monolog\Handler\HandlerInterface | [
"Returns",
"the",
"default",
"handler",
"."
] | 35600160f83cdff5b0459823f54c8d4c5cb602a4 | https://github.com/mako-framework/framework/blob/35600160f83cdff5b0459823f54c8d4c5cb602a4/src/mako/application/services/LoggerService.php#L48-L59 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.