repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.extraVars | public function extraVars($extraVars = ''): AnsiblePlaybookInterface
{
$extraVars = $this->checkParam($extraVars, ' ');
$this->addOption('--extra-vars', $extraVars);
return $this;
} | php | public function extraVars($extraVars = ''): AnsiblePlaybookInterface
{
$extraVars = $this->checkParam($extraVars, ' ');
$this->addOption('--extra-vars', $extraVars);
return $this;
} | [
"public",
"function",
"extraVars",
"(",
"$",
"extraVars",
"=",
"''",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"extraVars",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"extraVars",
",",
"' '",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--... | Set additional variables as array [ 'key' => 'value' ] or string.
@param string|array $extraVars
@return AnsiblePlaybookInterface | [
"Set",
"additional",
"variables",
"as",
"array",
"[",
"key",
"=",
">",
"value",
"]",
"or",
"string",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L171-L177 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.inventoryFile | public function inventoryFile(string $inventory = '/etc/ansible/hosts'): AnsiblePlaybookInterface
{
$this->addOption('--inventory-file', $inventory);
$this->hasInventory = true;
return $this;
} | php | public function inventoryFile(string $inventory = '/etc/ansible/hosts'): AnsiblePlaybookInterface
{
$this->addOption('--inventory-file', $inventory);
$this->hasInventory = true;
return $this;
} | [
"public",
"function",
"inventoryFile",
"(",
"string",
"$",
"inventory",
"=",
"'/etc/ansible/hosts'",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"this",
"->",
"addOption",
"(",
"'--inventory-file'",
",",
"$",
"inventory",
")",
";",
"$",
"this",
"->",
"hasInv... | Specify inventory host file (default=/etc/ansible/hosts).
@param string $inventory filename for hosts file
@return AnsiblePlaybookInterface | [
"Specify",
"inventory",
"host",
"file",
"(",
"default",
"=",
"/",
"etc",
"/",
"ansible",
"/",
"hosts",
")",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L222-L228 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.limit | public function limit($subset = ''): AnsiblePlaybookInterface
{
$subset = $this->checkParam($subset, ',');
$this->addOption('--limit', $subset);
return $this;
} | php | public function limit($subset = ''): AnsiblePlaybookInterface
{
$subset = $this->checkParam($subset, ',');
$this->addOption('--limit', $subset);
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"subset",
"=",
"''",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"subset",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"subset",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--limit'",
",... | Further limit selected hosts to an additional pattern.
@param array|string $subset list of hosts
@return AnsiblePlaybookInterface | [
"Further",
"limit",
"selected",
"hosts",
"to",
"an",
"additional",
"pattern",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L236-L243 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.colors | public function colors(bool $colors = true): AnsiblePlaybookInterface
{
$this->processBuilder->setEnv('ANSIBLE_FORCE_COLOR', intval($colors));
return $this;
} | php | public function colors(bool $colors = true): AnsiblePlaybookInterface
{
$this->processBuilder->setEnv('ANSIBLE_FORCE_COLOR', intval($colors));
return $this;
} | [
"public",
"function",
"colors",
"(",
"bool",
"$",
"colors",
"=",
"true",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"this",
"->",
"processBuilder",
"->",
"setEnv",
"(",
"'ANSIBLE_FORCE_COLOR'",
",",
"intval",
"(",
"$",
"colors",
")",
")",
";",
"return",... | Enable/Disable Colors
@param bool $colors
@return AnsiblePlaybookInterface | [
"Enable",
"/",
"Disable",
"Colors"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L301-L306 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.tags | public function tags($tags): AnsiblePlaybookInterface
{
$tags = $this->checkParam($tags, ',');
$this->addOption('--tags', $tags);
return $this;
} | php | public function tags($tags): AnsiblePlaybookInterface
{
$tags = $this->checkParam($tags, ',');
$this->addOption('--tags', $tags);
return $this;
} | [
"public",
"function",
"tags",
"(",
"$",
"tags",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"tags",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--tags'",
",",
"$",
"tags",
"... | Only run plays and tasks tagged with these values.
@param string|array $tags list of tags
@return AnsiblePlaybookInterface | [
"Only",
"run",
"plays",
"and",
"tasks",
"tagged",
"with",
"these",
"values",
"."
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L403-L409 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.scpExtraArgs | public function scpExtraArgs($scpExtraArgs): AnsiblePlaybookInterface
{
$scpExtraArgs = $this->checkParam($scpExtraArgs, ',');
$this->addOption('--scp-extra-args', $scpExtraArgs);
return $this;
} | php | public function scpExtraArgs($scpExtraArgs): AnsiblePlaybookInterface
{
$scpExtraArgs = $this->checkParam($scpExtraArgs, ',');
$this->addOption('--scp-extra-args', $scpExtraArgs);
return $this;
} | [
"public",
"function",
"scpExtraArgs",
"(",
"$",
"scpExtraArgs",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"scpExtraArgs",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"scpExtraArgs",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--scp... | specify extra arguments to pass to scp only (e.g. -l)
@param string|array $scpExtraArgs
@return AnsiblePlaybookInterface | [
"specify",
"extra",
"arguments",
"to",
"pass",
"to",
"scp",
"only",
"(",
"e",
".",
"g",
".",
"-",
"l",
")"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L519-L525 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.sftpExtraArgs | public function sftpExtraArgs($sftpExtraArgs): AnsiblePlaybookInterface
{
$sftpExtraArgs = $this->checkParam($sftpExtraArgs, ',');
$this->addOption('--sftp-extra-args', $sftpExtraArgs);
return $this;
} | php | public function sftpExtraArgs($sftpExtraArgs): AnsiblePlaybookInterface
{
$sftpExtraArgs = $this->checkParam($sftpExtraArgs, ',');
$this->addOption('--sftp-extra-args', $sftpExtraArgs);
return $this;
} | [
"public",
"function",
"sftpExtraArgs",
"(",
"$",
"sftpExtraArgs",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"sftpExtraArgs",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"sftpExtraArgs",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'-... | specify extra arguments to pass to sftp only (e.g. -f, -l)
@param string|array $sftpExtraArgs
@return AnsiblePlaybookInterface | [
"specify",
"extra",
"arguments",
"to",
"pass",
"to",
"sftp",
"only",
"(",
"e",
".",
"g",
".",
"-",
"f",
"-",
"l",
")"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L533-L539 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.sshCommonArgs | public function sshCommonArgs($sshArgs): AnsiblePlaybookInterface
{
$sshArgs = $this->checkParam($sshArgs, ',');
$this->addOption('--ssh-common-args', $sshArgs);
return $this;
} | php | public function sshCommonArgs($sshArgs): AnsiblePlaybookInterface
{
$sshArgs = $this->checkParam($sshArgs, ',');
$this->addOption('--ssh-common-args', $sshArgs);
return $this;
} | [
"public",
"function",
"sshCommonArgs",
"(",
"$",
"sshArgs",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"sshArgs",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"sshArgs",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--ssh-common-args'"... | specify common arguments to pass to sftp/scp/ssh (e.g. ProxyCommand)
@param string|array $sshArgs
@return AnsiblePlaybookInterface | [
"specify",
"common",
"arguments",
"to",
"pass",
"to",
"sftp",
"/",
"scp",
"/",
"ssh",
"(",
"e",
".",
"g",
".",
"ProxyCommand",
")"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L547-L553 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.sshExtraArgs | public function sshExtraArgs($extraArgs): AnsiblePlaybookInterface
{
$extraArgs = $this->checkParam($extraArgs, ',');
$this->addOption('--ssh-extra-args', $extraArgs);
return $this;
} | php | public function sshExtraArgs($extraArgs): AnsiblePlaybookInterface
{
$extraArgs = $this->checkParam($extraArgs, ',');
$this->addOption('--ssh-extra-args', $extraArgs);
return $this;
} | [
"public",
"function",
"sshExtraArgs",
"(",
"$",
"extraArgs",
")",
":",
"AnsiblePlaybookInterface",
"{",
"$",
"extraArgs",
"=",
"$",
"this",
"->",
"checkParam",
"(",
"$",
"extraArgs",
",",
"','",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"'--ssh-extra-ar... | specify extra arguments to pass to ssh only (e.g. -R)
@param string|array $extraArgs
@return AnsiblePlaybookInterface | [
"specify",
"extra",
"arguments",
"to",
"pass",
"to",
"ssh",
"only",
"(",
"e",
".",
"g",
".",
"-",
"R",
")"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L561-L567 |
maschmann/php-ansible | Ansible/Command/AnsiblePlaybook.php | AnsiblePlaybook.checkInventory | private function checkInventory(): void
{
if (!$this->hasInventory) {
$inventory = str_replace('.yml', '', $this->getBaseOptions());
$this->inventoryFile($inventory);
}
} | php | private function checkInventory(): void
{
if (!$this->hasInventory) {
$inventory = str_replace('.yml', '', $this->getBaseOptions());
$this->inventoryFile($inventory);
}
} | [
"private",
"function",
"checkInventory",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasInventory",
")",
"{",
"$",
"inventory",
"=",
"str_replace",
"(",
"'.yml'",
",",
"''",
",",
"$",
"this",
"->",
"getBaseOptions",
"(",
")",
")",
... | If no inventory file is given, assume | [
"If",
"no",
"inventory",
"file",
"is",
"given",
"assume"
] | train | https://github.com/maschmann/php-ansible/blob/a692eb7f8b463f6a9d078c7415487ba87447d1e1/Ansible/Command/AnsiblePlaybook.php#L598-L604 |
php-tmdb/laravel | src/TmdbServiceProvider.php | TmdbServiceProvider.register | public function register()
{
// Configure any bindings that are version dependent
$this->provider->register();
// Let the IoC container be able to make a Symfony event dispatcher
$this->app->bind(
'Symfony\Component\EventDispatcher\EventDispatcherInterface',
'Symfony\Component\EventDispatcher\EventDispatcher'
);
// Setup default configurations for the Tmdb Client
$this->app->singleton('Tmdb\Client', function() {
$config = $this->provider->config();
$options = $config['options'];
// Use an Event Dispatcher that uses the Laravel event dispatcher
$options['event_dispatcher'] = $this->app->make('Tmdb\Laravel\Adapters\EventDispatcherAdapter');
// Register the client using the key and options from config
$token = new ApiToken($config['api_key']);
return new Client($token, $options);
});
// bind the configuration (used by the image helper)
$this->app->bind('Tmdb\Model\Configuration', function() {
$configuration = $this->app->make('Tmdb\Repository\ConfigurationRepository');
return $configuration->load();
});
} | php | public function register()
{
// Configure any bindings that are version dependent
$this->provider->register();
// Let the IoC container be able to make a Symfony event dispatcher
$this->app->bind(
'Symfony\Component\EventDispatcher\EventDispatcherInterface',
'Symfony\Component\EventDispatcher\EventDispatcher'
);
// Setup default configurations for the Tmdb Client
$this->app->singleton('Tmdb\Client', function() {
$config = $this->provider->config();
$options = $config['options'];
// Use an Event Dispatcher that uses the Laravel event dispatcher
$options['event_dispatcher'] = $this->app->make('Tmdb\Laravel\Adapters\EventDispatcherAdapter');
// Register the client using the key and options from config
$token = new ApiToken($config['api_key']);
return new Client($token, $options);
});
// bind the configuration (used by the image helper)
$this->app->bind('Tmdb\Model\Configuration', function() {
$configuration = $this->app->make('Tmdb\Repository\ConfigurationRepository');
return $configuration->load();
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"// Configure any bindings that are version dependent",
"$",
"this",
"->",
"provider",
"->",
"register",
"(",
")",
";",
"// Let the IoC container be able to make a Symfony event dispatcher",
"$",
"this",
"->",
"app",
"->",
... | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/php-tmdb/laravel/blob/0468624e8ff245c5766c8745e6ac43e3ccbf05b1/src/TmdbServiceProvider.php#L61-L90 |
php-tmdb/laravel | src/TmdbServiceProvider.php | TmdbServiceProvider.registerProvider | private function registerProvider()
{
$app = $this->app;
// Pick the correct service provider for the current verison of Laravel
$this->provider = (version_compare($app::VERSION, '5.0', '<'))
? new TmdbServiceProviderLaravel4($app)
: new TmdbServiceProviderLaravel5($app);
} | php | private function registerProvider()
{
$app = $this->app;
// Pick the correct service provider for the current verison of Laravel
$this->provider = (version_compare($app::VERSION, '5.0', '<'))
? new TmdbServiceProviderLaravel4($app)
: new TmdbServiceProviderLaravel5($app);
} | [
"private",
"function",
"registerProvider",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"// Pick the correct service provider for the current verison of Laravel",
"$",
"this",
"->",
"provider",
"=",
"(",
"version_compare",
"(",
"$",
"app",
"::",
... | Register the ServiceProvider according to Laravel version
@return \Tmdb\Laravel\Provider\ProviderInterface | [
"Register",
"the",
"ServiceProvider",
"according",
"to",
"Laravel",
"version"
] | train | https://github.com/php-tmdb/laravel/blob/0468624e8ff245c5766c8745e6ac43e3ccbf05b1/src/TmdbServiceProvider.php#L97-L105 |
php-tmdb/laravel | src/Adapters/EventDispatcherAdapter.php | EventDispatcherAdapter.dispatch | public function dispatch($eventName, Event $event = null)
{
$this->laravelDispatcher->fire($eventName, $event);
return $this->symfonyDispatcher->dispatch($eventName, $event);
} | php | public function dispatch($eventName, Event $event = null)
{
$this->laravelDispatcher->fire($eventName, $event);
return $this->symfonyDispatcher->dispatch($eventName, $event);
} | [
"public",
"function",
"dispatch",
"(",
"$",
"eventName",
",",
"Event",
"$",
"event",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"laravelDispatcher",
"->",
"fire",
"(",
"$",
"eventName",
",",
"$",
"event",
")",
";",
"return",
"$",
"this",
"->",
"symfonyD... | Dispatches an event to all registered listeners.
@param string $eventName The name of the event to dispatch. The name of
the event is the name of the method that is
invoked on listeners.
@param Event $event The event to pass to the event handlers/listeners.
If not supplied, an empty Event instance is created.
@return Event
@api | [
"Dispatches",
"an",
"event",
"to",
"all",
"registered",
"listeners",
"."
] | train | https://github.com/php-tmdb/laravel/blob/0468624e8ff245c5766c8745e6ac43e3ccbf05b1/src/Adapters/EventDispatcherAdapter.php#L47-L51 |
php-tmdb/laravel | src/Adapters/EventDispatcherAdapter.php | EventDispatcherAdapter.addListener | public function addListener($eventName, $listener, $priority = 0)
{
$this->symfonyDispatcher->addListener($eventName, $listener, $priority);
} | php | public function addListener($eventName, $listener, $priority = 0)
{
$this->symfonyDispatcher->addListener($eventName, $listener, $priority);
} | [
"public",
"function",
"addListener",
"(",
"$",
"eventName",
",",
"$",
"listener",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"symfonyDispatcher",
"->",
"addListener",
"(",
"$",
"eventName",
",",
"$",
"listener",
",",
"$",
"priority",
")... | Adds an event listener that listens on the specified events.
@param string $eventName The event to listen on
@param callable $listener The listener
@param int $priority The higher this value, the earlier an event
listener will be triggered in the chain (defaults to 0)
@api | [
"Adds",
"an",
"event",
"listener",
"that",
"listens",
"on",
"the",
"specified",
"events",
"."
] | train | https://github.com/php-tmdb/laravel/blob/0468624e8ff245c5766c8745e6ac43e3ccbf05b1/src/Adapters/EventDispatcherAdapter.php#L63-L66 |
php-tmdb/laravel | src/Adapters/EventDispatcherAdapter.php | EventDispatcherAdapter.hasListeners | public function hasListeners($eventName = null)
{
return ($this->symfonyDispatcher->hasListeners($eventName) ||
$this->laravelDispatcher->hasListeners($eventName));
} | php | public function hasListeners($eventName = null)
{
return ($this->symfonyDispatcher->hasListeners($eventName) ||
$this->laravelDispatcher->hasListeners($eventName));
} | [
"public",
"function",
"hasListeners",
"(",
"$",
"eventName",
"=",
"null",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"symfonyDispatcher",
"->",
"hasListeners",
"(",
"$",
"eventName",
")",
"||",
"$",
"this",
"->",
"laravelDispatcher",
"->",
"hasListeners",
"... | Checks whether an event has any registered listeners.
@param string $eventName The name of the event
@return bool true if the specified event has any listeners, false otherwise | [
"Checks",
"whether",
"an",
"event",
"has",
"any",
"registered",
"listeners",
"."
] | train | https://github.com/php-tmdb/laravel/blob/0468624e8ff245c5766c8745e6ac43e3ccbf05b1/src/Adapters/EventDispatcherAdapter.php#L123-L127 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.scopeSortable | public function scopeSortable($query, $defaultParameters = null)
{
if (request()->allFilled(['sort', 'direction'])) { // allFilled() is macro
return $this->queryOrderBuilder($query, request()->only(['sort', 'direction']));
}
if (is_null($defaultParameters)) {
$defaultParameters = $this->getDefaultSortable();
}
if ( ! is_null($defaultParameters)) {
$defaultSortArray = $this->formatToParameters($defaultParameters);
if (config('columnsortable.allow_request_modification', true) && ! empty($defaultSortArray)) {
request()->merge($defaultSortArray);
}
return $this->queryOrderBuilder($query, $defaultSortArray);
}
return $query;
} | php | public function scopeSortable($query, $defaultParameters = null)
{
if (request()->allFilled(['sort', 'direction'])) { // allFilled() is macro
return $this->queryOrderBuilder($query, request()->only(['sort', 'direction']));
}
if (is_null($defaultParameters)) {
$defaultParameters = $this->getDefaultSortable();
}
if ( ! is_null($defaultParameters)) {
$defaultSortArray = $this->formatToParameters($defaultParameters);
if (config('columnsortable.allow_request_modification', true) && ! empty($defaultSortArray)) {
request()->merge($defaultSortArray);
}
return $this->queryOrderBuilder($query, $defaultSortArray);
}
return $query;
} | [
"public",
"function",
"scopeSortable",
"(",
"$",
"query",
",",
"$",
"defaultParameters",
"=",
"null",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"allFilled",
"(",
"[",
"'sort'",
",",
"'direction'",
"]",
")",
")",
"{",
"// allFilled() is macro",
"retur... | @param \Illuminate\Database\Query\Builder $query
@param array|null $defaultParameters
@return \Illuminate\Database\Query\Builder
@throws \Kyslik\ColumnSortable\Exceptions\ColumnSortableException | [
"@param",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Builder",
"$query",
"@param",
"array|null",
"$defaultParameters"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L24-L44 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.getDefaultSortable | private function getDefaultSortable()
{
if (config('columnsortable.default_first_column', false)) {
$sortBy = array_first($this->sortable);
if ( ! is_null($sortBy)) {
return [$sortBy => config('columnsortable.default_direction', 'asc')];
}
}
return null;
} | php | private function getDefaultSortable()
{
if (config('columnsortable.default_first_column', false)) {
$sortBy = array_first($this->sortable);
if ( ! is_null($sortBy)) {
return [$sortBy => config('columnsortable.default_direction', 'asc')];
}
}
return null;
} | [
"private",
"function",
"getDefaultSortable",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'columnsortable.default_first_column'",
",",
"false",
")",
")",
"{",
"$",
"sortBy",
"=",
"array_first",
"(",
"$",
"this",
"->",
"sortable",
")",
";",
"if",
"(",
"!",
"is... | Returns the first element of defined sortable columns from the Model
@return array|null | [
"Returns",
"the",
"first",
"element",
"of",
"defined",
"sortable",
"columns",
"from",
"the",
"Model"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L52-L62 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.queryOrderBuilder | private function queryOrderBuilder($query, array $sortParameters)
{
$model = $this;
list($column, $direction) = $this->parseParameters($sortParameters);
if (is_null($column)) {
return $query;
}
$explodeResult = SortableLink::explodeSortParameter($column);
if ( ! empty($explodeResult)) {
$relationName = $explodeResult[0];
$column = $explodeResult[1];
try {
$relation = $query->getRelation($relationName);
$query = $this->queryJoinBuilder($query, $relation);
} catch (BadMethodCallException $e) {
throw new ColumnSortableException($relationName, 1, $e);
} catch (\Exception $e) {
throw new ColumnSortableException($relationName, 2, $e);
}
$model = $relation->getRelated();
}
if (method_exists($model, camel_case($column).'Sortable')) {
return call_user_func_array([$model, camel_case($column).'Sortable'], [$query, $direction]);
}
if (isset($model->sortableAs) && in_array($column, $model->sortableAs)) {
$query = $query->orderBy($column, $direction);
} elseif ($this->columnExists($model, $column)) {
$column = $model->getTable().'.'.$column;
$query = $query->orderBy($column, $direction);
}
return $query;
} | php | private function queryOrderBuilder($query, array $sortParameters)
{
$model = $this;
list($column, $direction) = $this->parseParameters($sortParameters);
if (is_null($column)) {
return $query;
}
$explodeResult = SortableLink::explodeSortParameter($column);
if ( ! empty($explodeResult)) {
$relationName = $explodeResult[0];
$column = $explodeResult[1];
try {
$relation = $query->getRelation($relationName);
$query = $this->queryJoinBuilder($query, $relation);
} catch (BadMethodCallException $e) {
throw new ColumnSortableException($relationName, 1, $e);
} catch (\Exception $e) {
throw new ColumnSortableException($relationName, 2, $e);
}
$model = $relation->getRelated();
}
if (method_exists($model, camel_case($column).'Sortable')) {
return call_user_func_array([$model, camel_case($column).'Sortable'], [$query, $direction]);
}
if (isset($model->sortableAs) && in_array($column, $model->sortableAs)) {
$query = $query->orderBy($column, $direction);
} elseif ($this->columnExists($model, $column)) {
$column = $model->getTable().'.'.$column;
$query = $query->orderBy($column, $direction);
}
return $query;
} | [
"private",
"function",
"queryOrderBuilder",
"(",
"$",
"query",
",",
"array",
"$",
"sortParameters",
")",
"{",
"$",
"model",
"=",
"$",
"this",
";",
"list",
"(",
"$",
"column",
",",
"$",
"direction",
")",
"=",
"$",
"this",
"->",
"parseParameters",
"(",
"... | @param \Illuminate\Database\Query\Builder $query
@param array $sortParameters
@return \Illuminate\Database\Query\Builder
@throws ColumnSortableException | [
"@param",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Builder",
"$query",
"@param",
"array",
"$sortParameters"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L73-L112 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.parseParameters | private function parseParameters(array $parameters)
{
$column = array_get($parameters, 'sort');
if (empty($column)) {
return [null, null];
}
$direction = array_get($parameters, 'direction', []);
if ( ! in_array(strtolower($direction), ['asc', 'desc'])) {
$direction = config('columnsortable.default_direction', 'asc');
}
return [$column, $direction];
} | php | private function parseParameters(array $parameters)
{
$column = array_get($parameters, 'sort');
if (empty($column)) {
return [null, null];
}
$direction = array_get($parameters, 'direction', []);
if ( ! in_array(strtolower($direction), ['asc', 'desc'])) {
$direction = config('columnsortable.default_direction', 'asc');
}
return [$column, $direction];
} | [
"private",
"function",
"parseParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"column",
"=",
"array_get",
"(",
"$",
"parameters",
",",
"'sort'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"column",
")",
")",
"{",
"return",
"[",
"null",
",",
... | @param array $parameters
@return array | [
"@param",
"array",
"$parameters"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L120-L133 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.queryJoinBuilder | private function queryJoinBuilder($query, $relation)
{
$relatedTable = $relation->getRelated()->getTable();
$parentTable = $relation->getParent()->getTable();
if ($parentTable === $relatedTable) {
$query = $query->from($parentTable.' as parent_'.$parentTable);
$parentTable = 'parent_'.$parentTable;
$relation->getParent()->setTable($parentTable);
}
if ($relation instanceof HasOne) {
$relatedPrimaryKey = $relation->getQualifiedForeignKeyName();
$parentPrimaryKey = $relation->getQualifiedParentKeyName();
} elseif ($relation instanceof BelongsTo) {
$relatedPrimaryKey = $relation->getQualifiedOwnerKeyName();
$parentPrimaryKey = $relation->getQualifiedForeignKeyName();
} else {
throw new \Exception();
}
return $this->formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey);
} | php | private function queryJoinBuilder($query, $relation)
{
$relatedTable = $relation->getRelated()->getTable();
$parentTable = $relation->getParent()->getTable();
if ($parentTable === $relatedTable) {
$query = $query->from($parentTable.' as parent_'.$parentTable);
$parentTable = 'parent_'.$parentTable;
$relation->getParent()->setTable($parentTable);
}
if ($relation instanceof HasOne) {
$relatedPrimaryKey = $relation->getQualifiedForeignKeyName();
$parentPrimaryKey = $relation->getQualifiedParentKeyName();
} elseif ($relation instanceof BelongsTo) {
$relatedPrimaryKey = $relation->getQualifiedOwnerKeyName();
$parentPrimaryKey = $relation->getQualifiedForeignKeyName();
} else {
throw new \Exception();
}
return $this->formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey);
} | [
"private",
"function",
"queryJoinBuilder",
"(",
"$",
"query",
",",
"$",
"relation",
")",
"{",
"$",
"relatedTable",
"=",
"$",
"relation",
"->",
"getRelated",
"(",
")",
"->",
"getTable",
"(",
")",
";",
"$",
"parentTable",
"=",
"$",
"relation",
"->",
"getPa... | @param \Illuminate\Database\Query\Builder $query
@param \Illuminate\Database\Eloquent\Relations\BelongsTo|\Illuminate\Database\Eloquent\Relations\HasOne $relation
@return \Illuminate\Database\Query\Builder
@throws \Exception | [
"@param",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Builder",
"$query",
"@param",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Eloquent",
"\\",
"Relations",
"\\",
"BelongsTo|",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Eloquent",
"\\",
"Re... | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L144-L166 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.columnExists | private function columnExists($model, $column)
{
return (isset($model->sortable)) ? in_array($column, $model->sortable) :
Schema::connection($model->getConnectionName())->hasColumn($model->getTable(), $column);
} | php | private function columnExists($model, $column)
{
return (isset($model->sortable)) ? in_array($column, $model->sortable) :
Schema::connection($model->getConnectionName())->hasColumn($model->getTable(), $column);
} | [
"private",
"function",
"columnExists",
"(",
"$",
"model",
",",
"$",
"column",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"model",
"->",
"sortable",
")",
")",
"?",
"in_array",
"(",
"$",
"column",
",",
"$",
"model",
"->",
"sortable",
")",
":",
"Schema... | @param $model
@param $column
@return bool | [
"@param",
"$model",
"@param",
"$column"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L175-L179 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.formatToParameters | private function formatToParameters($array)
{
if (empty($array)) {
return [];
}
$defaultDirection = config('columnsortable.default_direction', 'asc');
if (is_string($array)) {
return ['sort' => $array, 'direction' => $defaultDirection];
}
return (key($array) === 0) ? ['sort' => $array[0], 'direction' => $defaultDirection] : [
'sort' => key($array),
'direction' => reset($array),
];
} | php | private function formatToParameters($array)
{
if (empty($array)) {
return [];
}
$defaultDirection = config('columnsortable.default_direction', 'asc');
if (is_string($array)) {
return ['sort' => $array, 'direction' => $defaultDirection];
}
return (key($array) === 0) ? ['sort' => $array[0], 'direction' => $defaultDirection] : [
'sort' => key($array),
'direction' => reset($array),
];
} | [
"private",
"function",
"formatToParameters",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"array",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"defaultDirection",
"=",
"config",
"(",
"'columnsortable.default_direction'",
",",
"'asc'",
"... | @param array|string $array
@return array | [
"@param",
"array|string",
"$array"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L187-L203 |
Kyslik/column-sortable | src/ColumnSortable/Sortable.php | Sortable.formJoin | private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey)
{
$joinType = config('columnsortable.join_type', 'leftJoin');
return $query->select($parentTable.'.*')->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey);
} | php | private function formJoin($query, $parentTable, $relatedTable, $parentPrimaryKey, $relatedPrimaryKey)
{
$joinType = config('columnsortable.join_type', 'leftJoin');
return $query->select($parentTable.'.*')->{$joinType}($relatedTable, $parentPrimaryKey, '=', $relatedPrimaryKey);
} | [
"private",
"function",
"formJoin",
"(",
"$",
"query",
",",
"$",
"parentTable",
",",
"$",
"relatedTable",
",",
"$",
"parentPrimaryKey",
",",
"$",
"relatedPrimaryKey",
")",
"{",
"$",
"joinType",
"=",
"config",
"(",
"'columnsortable.join_type'",
",",
"'leftJoin'",
... | @param $query
@param $parentTable
@param $relatedTable
@param $parentPrimaryKey
@param $relatedPrimaryKey
@return mixed | [
"@param",
"$query",
"@param",
"$parentTable",
"@param",
"$relatedTable",
"@param",
"$parentPrimaryKey",
"@param",
"$relatedPrimaryKey"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/Sortable.php#L215-L220 |
Kyslik/column-sortable | src/ColumnSortable/ColumnSortableServiceProvider.php | ColumnSortableServiceProvider.boot | public function boot()
{
$this->publishes([
__DIR__.'/../config/columnsortable.php' => config_path('columnsortable.php'),
], 'config');
Blade::directive('sortablelink', function ($expression) {
$expression = ($expression[0] === '(') ? substr($expression, 1, -1) : $expression;
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render(array ({$expression}));?>";
});
request()->macro('allFilled', function (array $keys) {
foreach ($keys as $key) {
if ( ! $this->filled($key)) {
return false;
}
}
return true;
});
} | php | public function boot()
{
$this->publishes([
__DIR__.'/../config/columnsortable.php' => config_path('columnsortable.php'),
], 'config');
Blade::directive('sortablelink', function ($expression) {
$expression = ($expression[0] === '(') ? substr($expression, 1, -1) : $expression;
return "<?php echo \Kyslik\ColumnSortable\SortableLink::render(array ({$expression}));?>";
});
request()->macro('allFilled', function (array $keys) {
foreach ($keys as $key) {
if ( ! $this->filled($key)) {
return false;
}
}
return true;
});
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/../config/columnsortable.php'",
"=>",
"config_path",
"(",
"'columnsortable.php'",
")",
",",
"]",
",",
"'config'",
")",
";",
"Blade",
"::",
"directive",
... | Bootstrap any application services.
@return void | [
"Bootstrap",
"any",
"application",
"services",
"."
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/ColumnSortableServiceProvider.php#L28-L49 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.render | public static function render(array $parameters)
{
list($sortColumn, $sortParameter, $title, $queryParameters, $anchorAttributes) = self::parseParameters($parameters);
$title = self::applyFormatting($title);
if ($mergeTitleAs = config('columnsortable.inject_title_as', null)) {
request()->merge([$mergeTitleAs => $title]);
}
list($icon, $direction) = self::determineDirection($sortColumn, $sortParameter);
$trailingTag = self::formTrailingTag($icon);
$anchorClass = self::getAnchorClass($sortParameter, $anchorAttributes);
$anchorAttributesString = self::buildAnchorAttributesString($anchorAttributes);
$queryString = self::buildQueryString($queryParameters, $sortParameter, $direction);
return '<a'.$anchorClass.' href="'.url(request()->path().'?'.$queryString).'"'.$anchorAttributesString.'>'.htmlentities($title).$trailingTag;
} | php | public static function render(array $parameters)
{
list($sortColumn, $sortParameter, $title, $queryParameters, $anchorAttributes) = self::parseParameters($parameters);
$title = self::applyFormatting($title);
if ($mergeTitleAs = config('columnsortable.inject_title_as', null)) {
request()->merge([$mergeTitleAs => $title]);
}
list($icon, $direction) = self::determineDirection($sortColumn, $sortParameter);
$trailingTag = self::formTrailingTag($icon);
$anchorClass = self::getAnchorClass($sortParameter, $anchorAttributes);
$anchorAttributesString = self::buildAnchorAttributesString($anchorAttributes);
$queryString = self::buildQueryString($queryParameters, $sortParameter, $direction);
return '<a'.$anchorClass.' href="'.url(request()->path().'?'.$queryString).'"'.$anchorAttributesString.'>'.htmlentities($title).$trailingTag;
} | [
"public",
"static",
"function",
"render",
"(",
"array",
"$",
"parameters",
")",
"{",
"list",
"(",
"$",
"sortColumn",
",",
"$",
"sortParameter",
",",
"$",
"title",
",",
"$",
"queryParameters",
",",
"$",
"anchorAttributes",
")",
"=",
"self",
"::",
"parsePara... | @param array $parameters
@return string
@throws \Kyslik\ColumnSortable\Exceptions\ColumnSortableException | [
"@param",
"array",
"$parameters"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L20-L41 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.parseParameters | public static function parseParameters(array $parameters)
{
//TODO: let 2nd parameter be both title, or default query parameters
//TODO: needs some checks before determining $title
$explodeResult = self::explodeSortParameter($parameters[0]);
$sortColumn = (empty($explodeResult)) ? $parameters[0] : $explodeResult[1];
$title = (count($parameters) === 1) ? $sortColumn : $parameters[1];
$queryParameters = (isset($parameters[2]) && is_array($parameters[2])) ? $parameters[2] : [];
$anchorAttributes = (isset($parameters[3]) && is_array($parameters[3])) ? $parameters[3] : [];
return [$sortColumn, $parameters[0], $title, $queryParameters, $anchorAttributes];
} | php | public static function parseParameters(array $parameters)
{
//TODO: let 2nd parameter be both title, or default query parameters
//TODO: needs some checks before determining $title
$explodeResult = self::explodeSortParameter($parameters[0]);
$sortColumn = (empty($explodeResult)) ? $parameters[0] : $explodeResult[1];
$title = (count($parameters) === 1) ? $sortColumn : $parameters[1];
$queryParameters = (isset($parameters[2]) && is_array($parameters[2])) ? $parameters[2] : [];
$anchorAttributes = (isset($parameters[3]) && is_array($parameters[3])) ? $parameters[3] : [];
return [$sortColumn, $parameters[0], $title, $queryParameters, $anchorAttributes];
} | [
"public",
"static",
"function",
"parseParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"//TODO: let 2nd parameter be both title, or default query parameters",
"//TODO: needs some checks before determining $title",
"$",
"explodeResult",
"=",
"self",
"::",
"explodeSortParamete... | @param array $parameters
@return array
@throws \Kyslik\ColumnSortable\Exceptions\ColumnSortableException | [
"@param",
"array",
"$parameters"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L50-L61 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.explodeSortParameter | public static function explodeSortParameter($parameter)
{
$separator = config('columnsortable.uri_relation_column_separator', '.');
if (str_contains($parameter, $separator)) {
$oneToOneSort = explode($separator, $parameter);
if (count($oneToOneSort) !== 2) {
throw new ColumnSortableException();
}
return $oneToOneSort;
}
return [];
} | php | public static function explodeSortParameter($parameter)
{
$separator = config('columnsortable.uri_relation_column_separator', '.');
if (str_contains($parameter, $separator)) {
$oneToOneSort = explode($separator, $parameter);
if (count($oneToOneSort) !== 2) {
throw new ColumnSortableException();
}
return $oneToOneSort;
}
return [];
} | [
"public",
"static",
"function",
"explodeSortParameter",
"(",
"$",
"parameter",
")",
"{",
"$",
"separator",
"=",
"config",
"(",
"'columnsortable.uri_relation_column_separator'",
",",
"'.'",
")",
";",
"if",
"(",
"str_contains",
"(",
"$",
"parameter",
",",
"$",
"se... | Explodes parameter if possible and returns array [column, relation]
Empty array is returned if explode could not run eg: separator was not found.
@param $parameter
@return array
@throws \Kyslik\ColumnSortable\Exceptions\ColumnSortableException | [
"Explodes",
"parameter",
"if",
"possible",
"and",
"returns",
"array",
"[",
"column",
"relation",
"]",
"Empty",
"array",
"is",
"returned",
"if",
"explode",
"could",
"not",
"run",
"eg",
":",
"separator",
"was",
"not",
"found",
"."
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L74-L88 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.applyFormatting | private static function applyFormatting($title)
{
$formatting_function = config('columnsortable.formatting_function', null);
if ( ! is_null($formatting_function) && function_exists($formatting_function)) {
$title = call_user_func($formatting_function, $title);
}
return $title;
} | php | private static function applyFormatting($title)
{
$formatting_function = config('columnsortable.formatting_function', null);
if ( ! is_null($formatting_function) && function_exists($formatting_function)) {
$title = call_user_func($formatting_function, $title);
}
return $title;
} | [
"private",
"static",
"function",
"applyFormatting",
"(",
"$",
"title",
")",
"{",
"$",
"formatting_function",
"=",
"config",
"(",
"'columnsortable.formatting_function'",
",",
"null",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"formatting_function",
")",
"&&",... | @param string $title
@return string | [
"@param",
"string",
"$title"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L96-L104 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.determineDirection | private static function determineDirection($sortColumn, $sortParameter)
{
$icon = self::selectIcon($sortColumn);
if (request()->get('sort') == $sortParameter && in_array(request()->get('direction'), ['asc', 'desc'])) {
$icon .= (request()->get('direction') === 'asc' ? config('columnsortable.asc_suffix', '-asc') :
config('columnsortable.desc_suffix', '-desc'));
$direction = request()->get('direction') === 'desc' ? 'asc' : 'desc';
return [$icon, $direction];
} else {
$icon = config('columnsortable.sortable_icon');
$direction = config('columnsortable.default_direction_unsorted', 'asc');
return [$icon, $direction];
}
} | php | private static function determineDirection($sortColumn, $sortParameter)
{
$icon = self::selectIcon($sortColumn);
if (request()->get('sort') == $sortParameter && in_array(request()->get('direction'), ['asc', 'desc'])) {
$icon .= (request()->get('direction') === 'asc' ? config('columnsortable.asc_suffix', '-asc') :
config('columnsortable.desc_suffix', '-desc'));
$direction = request()->get('direction') === 'desc' ? 'asc' : 'desc';
return [$icon, $direction];
} else {
$icon = config('columnsortable.sortable_icon');
$direction = config('columnsortable.default_direction_unsorted', 'asc');
return [$icon, $direction];
}
} | [
"private",
"static",
"function",
"determineDirection",
"(",
"$",
"sortColumn",
",",
"$",
"sortParameter",
")",
"{",
"$",
"icon",
"=",
"self",
"::",
"selectIcon",
"(",
"$",
"sortColumn",
")",
";",
"if",
"(",
"request",
"(",
")",
"->",
"get",
"(",
"'sort'"... | @param $sortColumn
@param $sortParameter
@return array | [
"@param",
"$sortColumn",
"@param",
"$sortParameter"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L113-L129 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.selectIcon | private static function selectIcon($sortColumn)
{
$icon = config('columnsortable.default_icon_set');
foreach (config('columnsortable.columns', []) as $value) {
if (in_array($sortColumn, $value['rows'])) {
$icon = $value['class'];
}
}
return $icon;
} | php | private static function selectIcon($sortColumn)
{
$icon = config('columnsortable.default_icon_set');
foreach (config('columnsortable.columns', []) as $value) {
if (in_array($sortColumn, $value['rows'])) {
$icon = $value['class'];
}
}
return $icon;
} | [
"private",
"static",
"function",
"selectIcon",
"(",
"$",
"sortColumn",
")",
"{",
"$",
"icon",
"=",
"config",
"(",
"'columnsortable.default_icon_set'",
")",
";",
"foreach",
"(",
"config",
"(",
"'columnsortable.columns'",
",",
"[",
"]",
")",
"as",
"$",
"value",
... | @param $sortColumn
@return string | [
"@param",
"$sortColumn"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L137-L148 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.formTrailingTag | private static function formTrailingTag($icon)
{
if ( ! config('columnsortable.enable_icons', true)) {
return '</a>';
}
$iconAndTextSeparator = config('columnsortable.icon_text_separator', '');
$clickableIcon = config('columnsortable.clickable_icon', false);
$trailingTag = $iconAndTextSeparator.'<i class="'.$icon.'"></i>'.'</a>';
if ($clickableIcon === false) {
$trailingTag = '</a>'.$iconAndTextSeparator.'<i class="'.$icon.'"></i>';
return $trailingTag;
}
return $trailingTag;
} | php | private static function formTrailingTag($icon)
{
if ( ! config('columnsortable.enable_icons', true)) {
return '</a>';
}
$iconAndTextSeparator = config('columnsortable.icon_text_separator', '');
$clickableIcon = config('columnsortable.clickable_icon', false);
$trailingTag = $iconAndTextSeparator.'<i class="'.$icon.'"></i>'.'</a>';
if ($clickableIcon === false) {
$trailingTag = '</a>'.$iconAndTextSeparator.'<i class="'.$icon.'"></i>';
return $trailingTag;
}
return $trailingTag;
} | [
"private",
"static",
"function",
"formTrailingTag",
"(",
"$",
"icon",
")",
"{",
"if",
"(",
"!",
"config",
"(",
"'columnsortable.enable_icons'",
",",
"true",
")",
")",
"{",
"return",
"'</a>'",
";",
"}",
"$",
"iconAndTextSeparator",
"=",
"config",
"(",
"'colum... | @param $icon
@return string | [
"@param",
"$icon"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L156-L174 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.getAnchorClass | private static function getAnchorClass($sortColumn, &$anchorAttributes = [])
{
$class = [];
$anchorClass = config('columnsortable.anchor_class', null);
if ($anchorClass !== null) {
$class[] = $anchorClass;
}
$activeClass = config('columnsortable.active_anchor_class', null);
if ($activeClass !== null && self::shouldShowActive($sortColumn)) {
$class[] = $activeClass;
}
$directionClassPrefix = config('columnsortable.direction_anchor_class_prefix', null);
if ($directionClassPrefix !== null && self::shouldShowActive($sortColumn)) {
$class[] = $directionClassPrefix.(request()->get('direction') === 'asc' ? config('columnsortable.asc_suffix', '-asc') :
config('columnsortable.desc_suffix', '-desc'));
}
if (isset($anchorAttributes['class'])) {
$class = array_merge($class, explode(' ', $anchorAttributes['class']));
unset($anchorAttributes['class']);
}
return (empty($class)) ? '' : ' class="'.implode(' ', $class).'"';
} | php | private static function getAnchorClass($sortColumn, &$anchorAttributes = [])
{
$class = [];
$anchorClass = config('columnsortable.anchor_class', null);
if ($anchorClass !== null) {
$class[] = $anchorClass;
}
$activeClass = config('columnsortable.active_anchor_class', null);
if ($activeClass !== null && self::shouldShowActive($sortColumn)) {
$class[] = $activeClass;
}
$directionClassPrefix = config('columnsortable.direction_anchor_class_prefix', null);
if ($directionClassPrefix !== null && self::shouldShowActive($sortColumn)) {
$class[] = $directionClassPrefix.(request()->get('direction') === 'asc' ? config('columnsortable.asc_suffix', '-asc') :
config('columnsortable.desc_suffix', '-desc'));
}
if (isset($anchorAttributes['class'])) {
$class = array_merge($class, explode(' ', $anchorAttributes['class']));
unset($anchorAttributes['class']);
}
return (empty($class)) ? '' : ' class="'.implode(' ', $class).'"';
} | [
"private",
"static",
"function",
"getAnchorClass",
"(",
"$",
"sortColumn",
",",
"&",
"$",
"anchorAttributes",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"[",
"]",
";",
"$",
"anchorClass",
"=",
"config",
"(",
"'columnsortable.anchor_class'",
",",
"null",
"... | Take care of special case, when `class` is passed to the sortablelink.
@param $sortColumn
@param array $anchorAttributes
@return string | [
"Take",
"care",
"of",
"special",
"case",
"when",
"class",
"is",
"passed",
"to",
"the",
"sortablelink",
"."
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L186-L212 |
Kyslik/column-sortable | src/ColumnSortable/SortableLink.php | SortableLink.buildQueryString | private static function buildQueryString($queryParameters, $sortParameter, $direction)
{
$checkStrlenOrArray = function ($element) {
return is_array($element) ? $element : strlen($element);
};
$persistParameters = array_filter(request()->except('sort', 'direction', 'page'), $checkStrlenOrArray);
$queryString = http_build_query(array_merge($queryParameters, $persistParameters, [
'sort' => $sortParameter,
'direction' => $direction,
]));
return $queryString;
} | php | private static function buildQueryString($queryParameters, $sortParameter, $direction)
{
$checkStrlenOrArray = function ($element) {
return is_array($element) ? $element : strlen($element);
};
$persistParameters = array_filter(request()->except('sort', 'direction', 'page'), $checkStrlenOrArray);
$queryString = http_build_query(array_merge($queryParameters, $persistParameters, [
'sort' => $sortParameter,
'direction' => $direction,
]));
return $queryString;
} | [
"private",
"static",
"function",
"buildQueryString",
"(",
"$",
"queryParameters",
",",
"$",
"sortParameter",
",",
"$",
"direction",
")",
"{",
"$",
"checkStrlenOrArray",
"=",
"function",
"(",
"$",
"element",
")",
"{",
"return",
"is_array",
"(",
"$",
"element",
... | @param $queryParameters
@param $sortParameter
@param $direction
@return string | [
"@param",
"$queryParameters",
"@param",
"$sortParameter",
"@param",
"$direction"
] | train | https://github.com/Kyslik/column-sortable/blob/0067a3da4ec06cb5253227cf2149c02119023b7c/src/ColumnSortable/SortableLink.php#L233-L246 |
smi2/phpClickHouse | src/Query/Degeneration/Bindings.php | Bindings.compile_binds | public function compile_binds($sql, $binds,$pattern)
{
return preg_replace_callback($pattern, function($m) use ($binds){
if(isset($binds[$m[1]])){ // If it exists in our array
return $binds[$m[1]]; // Then replace it from our array
}
return $m[0]; // Otherwise return the whole match (basically we won't change it)
}, $sql);
} | php | public function compile_binds($sql, $binds,$pattern)
{
return preg_replace_callback($pattern, function($m) use ($binds){
if(isset($binds[$m[1]])){ // If it exists in our array
return $binds[$m[1]]; // Then replace it from our array
}
return $m[0]; // Otherwise return the whole match (basically we won't change it)
}, $sql);
} | [
"public",
"function",
"compile_binds",
"(",
"$",
"sql",
",",
"$",
"binds",
",",
"$",
"pattern",
")",
"{",
"return",
"preg_replace_callback",
"(",
"$",
"pattern",
",",
"function",
"(",
"$",
"m",
")",
"use",
"(",
"$",
"binds",
")",
"{",
"if",
"(",
"iss... | Binds a list of values to the corresponding parameters.
This is similar to [[bindValue()]] except that it binds multiple values at a time.
@param string $sql
@param array $binds
@param string $pattern
@return string | [
"Binds",
"a",
"list",
"of",
"values",
"to",
"the",
"corresponding",
"parameters",
".",
"This",
"is",
"similar",
"to",
"[[",
"bindValue",
"()",
"]]",
"except",
"that",
"it",
"binds",
"multiple",
"values",
"at",
"a",
"time",
"."
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Query/Degeneration/Bindings.php#L49-L58 |
smi2/phpClickHouse | src/Query/Degeneration/Bindings.php | Bindings.process | public function process($sql)
{
$bindFormatted=[];
$bindRaw=[];
foreach ($this->bindings as $key => $value) {
if (is_array($value)) {
$valueSet = implode(', ', $value);
$values = array_map(
function ($value) {
return ValueFormatter::formatValue($value);
},
$value
);
$formattedParameter = implode(',', $values);
} else {
$valueSet = $value;
$formattedParameter = ValueFormatter::formatValue($value);
}
if ($formattedParameter !== null) {
$bindFormatted[$key]=$formattedParameter;
}
if ($valueSet !== null) {
$bindRaw[$key]=$valueSet;
}
}
for ($loop=0;$loop<2;$loop++)
{
// dipping in binds
// example ['A' => '{B}' , 'B'=>':C','C'=>123]
$sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#');
}
$sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#');
return $sql;
} | php | public function process($sql)
{
$bindFormatted=[];
$bindRaw=[];
foreach ($this->bindings as $key => $value) {
if (is_array($value)) {
$valueSet = implode(', ', $value);
$values = array_map(
function ($value) {
return ValueFormatter::formatValue($value);
},
$value
);
$formattedParameter = implode(',', $values);
} else {
$valueSet = $value;
$formattedParameter = ValueFormatter::formatValue($value);
}
if ($formattedParameter !== null) {
$bindFormatted[$key]=$formattedParameter;
}
if ($valueSet !== null) {
$bindRaw[$key]=$valueSet;
}
}
for ($loop=0;$loop<2;$loop++)
{
// dipping in binds
// example ['A' => '{B}' , 'B'=>':C','C'=>123]
$sql=$this->compile_binds($sql,$bindRaw,'#{([\w+]+)}#');
}
$sql=$this->compile_binds($sql,$bindFormatted,'#:([\w+]+)#');
return $sql;
} | [
"public",
"function",
"process",
"(",
"$",
"sql",
")",
"{",
"$",
"bindFormatted",
"=",
"[",
"]",
";",
"$",
"bindRaw",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"bindings",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
... | Compile Bindings
@param string $sql
@return mixed | [
"Compile",
"Bindings"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Query/Degeneration/Bindings.php#L66-L105 |
smi2/phpClickHouse | src/Quote/FormatLine.php | FormatLine.strictQuote | public static function strictQuote($format)
{
if (empty(self::$strict[$format]))
{
self::$strict[$format] = new StrictQuoteLine($format);
}
return self::$strict[$format];
} | php | public static function strictQuote($format)
{
if (empty(self::$strict[$format]))
{
self::$strict[$format] = new StrictQuoteLine($format);
}
return self::$strict[$format];
} | [
"public",
"static",
"function",
"strictQuote",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"strict",
"[",
"$",
"format",
"]",
")",
")",
"{",
"self",
"::",
"$",
"strict",
"[",
"$",
"format",
"]",
"=",
"new",
"StrictQuot... | Format
@param string $format
@return StrictQuoteLine | [
"Format"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Quote/FormatLine.php#L19-L26 |
smi2/phpClickHouse | src/Statement.php | Statement.info_upload | public function info_upload()
{
$this->check();
return [
'size_upload' => $this->response()->size_upload(),
'upload_content' => $this->response()->upload_content_length(),
'speed_upload' => $this->response()->speed_upload(),
'time_request' => $this->response()->total_time()
];
} | php | public function info_upload()
{
$this->check();
return [
'size_upload' => $this->response()->size_upload(),
'upload_content' => $this->response()->upload_content_length(),
'speed_upload' => $this->response()->speed_upload(),
'time_request' => $this->response()->total_time()
];
} | [
"public",
"function",
"info_upload",
"(",
")",
"{",
"$",
"this",
"->",
"check",
"(",
")",
";",
"return",
"[",
"'size_upload'",
"=>",
"$",
"this",
"->",
"response",
"(",
")",
"->",
"size_upload",
"(",
")",
",",
"'upload_content'",
"=>",
"$",
"this",
"->... | Return size_upload,upload_content,speed_upload,time_request
@return array
@throws Exception\TransportException | [
"Return",
"size_upload",
"upload_content",
"speed_upload",
"time_request"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Statement.php#L441-L450 |
smi2/phpClickHouse | src/Statement.php | Statement.info | public function info()
{
$this->check();
return [
'starttransfer_time' => $this->response()->starttransfer_time(),
'size_download' => $this->response()->size_download(),
'speed_download' => $this->response()->speed_download(),
'size_upload' => $this->response()->size_upload(),
'upload_content' => $this->response()->upload_content_length(),
'speed_upload' => $this->response()->speed_upload(),
'time_request' => $this->response()->total_time()
];
} | php | public function info()
{
$this->check();
return [
'starttransfer_time' => $this->response()->starttransfer_time(),
'size_download' => $this->response()->size_download(),
'speed_download' => $this->response()->speed_download(),
'size_upload' => $this->response()->size_upload(),
'upload_content' => $this->response()->upload_content_length(),
'speed_upload' => $this->response()->speed_upload(),
'time_request' => $this->response()->total_time()
];
} | [
"public",
"function",
"info",
"(",
")",
"{",
"$",
"this",
"->",
"check",
"(",
")",
";",
"return",
"[",
"'starttransfer_time'",
"=>",
"$",
"this",
"->",
"response",
"(",
")",
"->",
"starttransfer_time",
"(",
")",
",",
"'size_download'",
"=>",
"$",
"this",... | Return size_upload,upload_content,speed_upload,time_request,starttransfer_time,size_download,speed_download
@return array
@throws Exception\TransportException | [
"Return",
"size_upload",
"upload_content",
"speed_upload",
"time_request",
"starttransfer_time",
"size_download",
"speed_download"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Statement.php#L458-L470 |
smi2/phpClickHouse | src/Transport/CurlerRolling.php | CurlerRolling.setSimultaneousLimit | public function setSimultaneousLimit($count)
{
if (!is_int($count) || $count < 2) {
throw new \InvalidArgumentException("setSimultaneousLimit count must be an int >= 2");
}
$this->simultaneousLimit = $count;
return $this;
} | php | public function setSimultaneousLimit($count)
{
if (!is_int($count) || $count < 2) {
throw new \InvalidArgumentException("setSimultaneousLimit count must be an int >= 2");
}
$this->simultaneousLimit = $count;
return $this;
} | [
"public",
"function",
"setSimultaneousLimit",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
"||",
"$",
"count",
"<",
"2",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"setSimultaneousLimit count must be an... | Set the limit for how many cURL requests will be execute simultaneously.
Please be mindful that if you set this too high, requests are likely to fail
more frequently or automated software may perceive you as a DOS attack and
automatically block further requests.
@param int $count
@throws \InvalidArgumentException
@return $this | [
"Set",
"the",
"limit",
"for",
"how",
"many",
"cURL",
"requests",
"will",
"be",
"execute",
"simultaneously",
"."
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Transport/CurlerRolling.php#L234-L242 |
smi2/phpClickHouse | src/Cluster.php | Cluster.isReplicasWork | private function isReplicasWork($replicas)
{
$ok = true;
if (!is_array($replicas)) {
// @todo нет массива ошибка, т/к мы работем с репликами?
// @todo Как быть есть в кластере НЕТ реплик ?
return false;
}
foreach ($replicas as $replica) {
if ($replica['is_readonly']) {
$ok = false;
$this->error[] = 'is_readonly : ' . json_encode($replica);
}
if ($replica['is_session_expired']) {
$ok = false;
$this->error[] = 'is_session_expired : ' . json_encode($replica);
}
if ($replica['future_parts'] > 20) {
$ok = false;
$this->error[] = 'future_parts : ' . json_encode($replica);
}
if ($replica['parts_to_check'] > 10) {
$ok = false;
$this->error[] = 'parts_to_check : ' . json_encode($replica);
}
// @todo : rewrite total_replicas=1 если кластер без реплики , нужно проверять какой класте и сколько в нем реплик
// if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);}
if ($this->softCheck)
{
if (!$ok) {
break;
}
continue;
}
if ($replica['active_replicas'] < $replica['total_replicas']) {
$ok = false;
$this->error[] = 'active_replicas : ' . json_encode($replica);
}
if ($replica['queue_size'] > 20) {
$ok = false;
$this->error[] = 'queue_size : ' . json_encode($replica);
}
if (($replica['log_max_index'] - $replica['log_pointer']) > 10) {
$ok = false;
$this->error[] = 'log_max_index : ' . json_encode($replica);
}
if (!$ok) {
break;
}
}
return $ok;
} | php | private function isReplicasWork($replicas)
{
$ok = true;
if (!is_array($replicas)) {
// @todo нет массива ошибка, т/к мы работем с репликами?
// @todo Как быть есть в кластере НЕТ реплик ?
return false;
}
foreach ($replicas as $replica) {
if ($replica['is_readonly']) {
$ok = false;
$this->error[] = 'is_readonly : ' . json_encode($replica);
}
if ($replica['is_session_expired']) {
$ok = false;
$this->error[] = 'is_session_expired : ' . json_encode($replica);
}
if ($replica['future_parts'] > 20) {
$ok = false;
$this->error[] = 'future_parts : ' . json_encode($replica);
}
if ($replica['parts_to_check'] > 10) {
$ok = false;
$this->error[] = 'parts_to_check : ' . json_encode($replica);
}
// @todo : rewrite total_replicas=1 если кластер без реплики , нужно проверять какой класте и сколько в нем реплик
// if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);}
if ($this->softCheck)
{
if (!$ok) {
break;
}
continue;
}
if ($replica['active_replicas'] < $replica['total_replicas']) {
$ok = false;
$this->error[] = 'active_replicas : ' . json_encode($replica);
}
if ($replica['queue_size'] > 20) {
$ok = false;
$this->error[] = 'queue_size : ' . json_encode($replica);
}
if (($replica['log_max_index'] - $replica['log_pointer']) > 10) {
$ok = false;
$this->error[] = 'log_max_index : ' . json_encode($replica);
}
if (!$ok) {
break;
}
}
return $ok;
} | [
"private",
"function",
"isReplicasWork",
"(",
"$",
"replicas",
")",
"{",
"$",
"ok",
"=",
"true",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"replicas",
")",
")",
"{",
"// @todo нет массива ошибка, т/к мы работем с репликами?",
"// @todo Как быть есть в кластере НЕТ ре... | Check the status of the cluster, the request is taken from the documentation for CH
total_replicas <2 - not suitable for no replication clusters
@param mixed $replicas
@return bool | [
"Check",
"the",
"status",
"of",
"the",
"cluster",
"the",
"request",
"is",
"taken",
"from",
"the",
"documentation",
"for",
"CH",
"total_replicas",
"<2",
"-",
"not",
"suitable",
"for",
"no",
"replication",
"clusters"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L166-L219 |
smi2/phpClickHouse | src/Cluster.php | Cluster.getTables | public function getTables($resultDetail = false)
{
$this->connect();
$list = [];
foreach ($this->tables as $db_name=>$tables)
{
foreach ($tables as $table_name=>$nodes)
{
if ($resultDetail)
{
$list[$db_name . '.' . $table_name] = $nodes;
} else
{
$list[$db_name . '.' . $table_name] = array_keys($nodes);
}
}
}
return $list;
} | php | public function getTables($resultDetail = false)
{
$this->connect();
$list = [];
foreach ($this->tables as $db_name=>$tables)
{
foreach ($tables as $table_name=>$nodes)
{
if ($resultDetail)
{
$list[$db_name . '.' . $table_name] = $nodes;
} else
{
$list[$db_name . '.' . $table_name] = array_keys($nodes);
}
}
}
return $list;
} | [
"public",
"function",
"getTables",
"(",
"$",
"resultDetail",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"tables",
"as",
"$",
"db_name",
"=>",
"$",
"tables... | list all tables on all nodes
@return array
@throws Exception\TransportException | [
"list",
"all",
"tables",
"on",
"all",
"nodes"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L487-L506 |
smi2/phpClickHouse | src/Cluster.php | Cluster.getSizeTable | public function getSizeTable($database_table)
{
$nodes = $this->getNodesByTable($database_table);
// scan need node`s
foreach ($nodes as $node)
{
if (empty($this->_table_size_cache[$node]))
{
$this->_table_size_cache[$node] = $this->client($node)->tablesSize(true);
}
}
$sizes = [];
foreach ($this->_table_size_cache as $node=>$rows)
{
foreach ($rows as $row)
{
$sizes[$row['database'] . '.' . $row['table']][$node] = $row;
@$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes'];
}
}
if (empty($sizes[$database_table]))
{
return null;
}
return $sizes[$database_table]['total']['sizebytes'];
} | php | public function getSizeTable($database_table)
{
$nodes = $this->getNodesByTable($database_table);
// scan need node`s
foreach ($nodes as $node)
{
if (empty($this->_table_size_cache[$node]))
{
$this->_table_size_cache[$node] = $this->client($node)->tablesSize(true);
}
}
$sizes = [];
foreach ($this->_table_size_cache as $node=>$rows)
{
foreach ($rows as $row)
{
$sizes[$row['database'] . '.' . $row['table']][$node] = $row;
@$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes'];
}
}
if (empty($sizes[$database_table]))
{
return null;
}
return $sizes[$database_table]['total']['sizebytes'];
} | [
"public",
"function",
"getSizeTable",
"(",
"$",
"database_table",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getNodesByTable",
"(",
"$",
"database_table",
")",
";",
"// scan need node`s",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"if... | Table size on cluster
@param string $database_table
@return array|null
@throws Exception\TransportException | [
"Table",
"size",
"on",
"cluster"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L516-L546 |
smi2/phpClickHouse | src/Cluster.php | Cluster.truncateTable | public function truncateTable($database_table, $timeOut = 2000)
{
$out = [];
list($db, $table) = explode('.', $database_table);
$nodes = $this->getMasterNodeForTable($database_table);
// scan need node`s
foreach ($nodes as $node)
{
$def = $this->client($node)->getTimeout();
$this->client($node)->database($db)->setTimeout($timeOut);
$out[$node] = $this->client($node)->truncateTable($table);
$this->client($node)->setTimeout($def);
}
return $out;
} | php | public function truncateTable($database_table, $timeOut = 2000)
{
$out = [];
list($db, $table) = explode('.', $database_table);
$nodes = $this->getMasterNodeForTable($database_table);
// scan need node`s
foreach ($nodes as $node)
{
$def = $this->client($node)->getTimeout();
$this->client($node)->database($db)->setTimeout($timeOut);
$out[$node] = $this->client($node)->truncateTable($table);
$this->client($node)->setTimeout($def);
}
return $out;
} | [
"public",
"function",
"truncateTable",
"(",
"$",
"database_table",
",",
"$",
"timeOut",
"=",
"2000",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"list",
"(",
"$",
"db",
",",
"$",
"table",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"database_table",
"... | Truncate on all nodes
@deprecated
@param string $database_table
@return array
@throws Exception\TransportException | [
"Truncate",
"on",
"all",
"nodes"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L556-L570 |
smi2/phpClickHouse | src/Cluster.php | Cluster.getMasterNodeForTable | public function getMasterNodeForTable($database_table)
{
$list = $this->getTables(true);
if (empty($list[$database_table])) {
return [];
}
$result = [];
foreach ($list[$database_table] as $node=>$row)
{
if ($row['is_leader']) {
$result[] = $node;
}
}
return $result;
} | php | public function getMasterNodeForTable($database_table)
{
$list = $this->getTables(true);
if (empty($list[$database_table])) {
return [];
}
$result = [];
foreach ($list[$database_table] as $node=>$row)
{
if ($row['is_leader']) {
$result[] = $node;
}
}
return $result;
} | [
"public",
"function",
"getMasterNodeForTable",
"(",
"$",
"database_table",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getTables",
"(",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
"[",
"$",
"database_table",
"]",
")",
")",
"{",
"return"... | is_leader node
@param string $database_table
@return array
@throws Exception\TransportException | [
"is_leader",
"node"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L579-L596 |
smi2/phpClickHouse | src/Cluster.php | Cluster.getNodesByTable | public function getNodesByTable($database_table)
{
$list = $this->getTables();
if (empty($list[$database_table])) {
throw new QueryException('Not find :' . $database_table);
}
return $list[$database_table];
} | php | public function getNodesByTable($database_table)
{
$list = $this->getTables();
if (empty($list[$database_table])) {
throw new QueryException('Not find :' . $database_table);
}
return $list[$database_table];
} | [
"public",
"function",
"getNodesByTable",
"(",
"$",
"database_table",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"getTables",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
"[",
"$",
"database_table",
"]",
")",
")",
"{",
"throw",
"new",
"Que... | Find nodes by : db_name.table_name
@param string $database_table
@return array
@throws Exception\TransportException | [
"Find",
"nodes",
"by",
":",
"db_name",
".",
"table_name"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Cluster.php#L604-L611 |
smi2/phpClickHouse | src/Client.php | Client.setReadOnlyUser | public function setReadOnlyUser(bool $flag)
{
$this->connectUserReadonly = $flag;
$this->settings()->setReadOnlyUser($this->connectUserReadonly);
} | php | public function setReadOnlyUser(bool $flag)
{
$this->connectUserReadonly = $flag;
$this->settings()->setReadOnlyUser($this->connectUserReadonly);
} | [
"public",
"function",
"setReadOnlyUser",
"(",
"bool",
"$",
"flag",
")",
"{",
"$",
"this",
"->",
"connectUserReadonly",
"=",
"$",
"flag",
";",
"$",
"this",
"->",
"settings",
"(",
")",
"->",
"setReadOnlyUser",
"(",
"$",
"this",
"->",
"connectUserReadonly",
"... | if the user has only read in the config file | [
"if",
"the",
"user",
"has",
"only",
"read",
"in",
"the",
"config",
"file"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L117-L121 |
smi2/phpClickHouse | src/Client.php | Client.write | public function write(string $sql, array $bindings = [], bool $exception = true)
{
return $this->transport()->write($sql, $bindings, $exception);
} | php | public function write(string $sql, array $bindings = [], bool $exception = true)
{
return $this->transport()->write($sql, $bindings, $exception);
} | [
"public",
"function",
"write",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"bindings",
"=",
"[",
"]",
",",
"bool",
"$",
"exception",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"transport",
"(",
")",
"->",
"write",
"(",
"$",
"sql",
",",
... | Query CREATE/DROP
@param mixed[] $bindings
@return Statement | [
"Query",
"CREATE",
"/",
"DROP"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L294-L297 |
smi2/phpClickHouse | src/Client.php | Client.enableLogQueries | public function enableLogQueries(bool $flag = true)
{
$this->settings()->set('log_queries', (int) $flag);
return $this;
} | php | public function enableLogQueries(bool $flag = true)
{
$this->settings()->set('log_queries', (int) $flag);
return $this;
} | [
"public",
"function",
"enableLogQueries",
"(",
"bool",
"$",
"flag",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"settings",
"(",
")",
"->",
"set",
"(",
"'log_queries'",
",",
"(",
"int",
")",
"$",
"flag",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Write to system.query_log
@return static | [
"Write",
"to",
"system",
".",
"query_log"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L315-L320 |
smi2/phpClickHouse | src/Client.php | Client.enableExtremes | public function enableExtremes(bool $flag = true)
{
$this->settings()->set('extremes', (int) $flag);
return $this;
} | php | public function enableExtremes(bool $flag = true)
{
$this->settings()->set('extremes', (int) $flag);
return $this;
} | [
"public",
"function",
"enableExtremes",
"(",
"bool",
"$",
"flag",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"settings",
"(",
")",
"->",
"set",
"(",
"'extremes'",
",",
"(",
"int",
")",
"$",
"flag",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Read extremes of the result columns. They can be output in JSON-formats.
@return static | [
"Read",
"extremes",
"of",
"the",
"result",
"columns",
".",
"They",
"can",
"be",
"output",
"in",
"JSON",
"-",
"formats",
"."
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L351-L356 |
smi2/phpClickHouse | src/Client.php | Client.progressFunction | public function progressFunction(callable $callback)
{
if (! is_callable($callback)) {
throw new \InvalidArgumentException('Not is_callable progressFunction');
}
if (! $this->settings()->is('send_progress_in_http_headers')) {
$this->settings()->set('send_progress_in_http_headers', 1);
}
if (! $this->settings()->is('http_headers_progress_interval_ms')) {
$this->settings()->set('http_headers_progress_interval_ms', 100);
}
$this->transport()->setProgressFunction($callback);
} | php | public function progressFunction(callable $callback)
{
if (! is_callable($callback)) {
throw new \InvalidArgumentException('Not is_callable progressFunction');
}
if (! $this->settings()->is('send_progress_in_http_headers')) {
$this->settings()->set('send_progress_in_http_headers', 1);
}
if (! $this->settings()->is('http_headers_progress_interval_ms')) {
$this->settings()->set('http_headers_progress_interval_ms', 100);
}
$this->transport()->setProgressFunction($callback);
} | [
"public",
"function",
"progressFunction",
"(",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Not is_callable progressFunction'",
")",
";",
"}",
... | set progressFunction | [
"set",
"progressFunction"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L387-L401 |
smi2/phpClickHouse | src/Client.php | Client.selectAsync | public function selectAsync(
string $sql,
array $bindings = [],
WhereInFile $whereInFile = null,
WriteToFile $writeToFile = null
) {
return $this->transport()->selectAsync($sql, $bindings, $whereInFile, $writeToFile);
} | php | public function selectAsync(
string $sql,
array $bindings = [],
WhereInFile $whereInFile = null,
WriteToFile $writeToFile = null
) {
return $this->transport()->selectAsync($sql, $bindings, $whereInFile, $writeToFile);
} | [
"public",
"function",
"selectAsync",
"(",
"string",
"$",
"sql",
",",
"array",
"$",
"bindings",
"=",
"[",
"]",
",",
"WhereInFile",
"$",
"whereInFile",
"=",
"null",
",",
"WriteToFile",
"$",
"writeToFile",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",... | prepare select
@param mixed[] $bindings
@return Statement | [
"prepare",
"select"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L409-L416 |
smi2/phpClickHouse | src/Client.php | Client.prepareInsertAssocBulk | public function prepareInsertAssocBulk(array $values)
{
if (isset($values[0]) && is_array($values[0])) { //случай, когда много строк вставляется
$preparedFields = array_keys($values[0]);
$preparedValues = [];
foreach ($values as $idx => $row) {
$_fields = array_keys($row);
if ($_fields !== $preparedFields) {
throw new QueryException(
sprintf(
'Fields not match: %s and %s on element %s',
implode(',', $_fields),
implode(',', $preparedFields),
$idx
)
);
}
$preparedValues[] = array_values($row);
}
} else {
$preparedFields = array_keys($values);
$preparedValues = [array_values($values)];
}
return [$preparedFields, $preparedValues];
} | php | public function prepareInsertAssocBulk(array $values)
{
if (isset($values[0]) && is_array($values[0])) { //случай, когда много строк вставляется
$preparedFields = array_keys($values[0]);
$preparedValues = [];
foreach ($values as $idx => $row) {
$_fields = array_keys($row);
if ($_fields !== $preparedFields) {
throw new QueryException(
sprintf(
'Fields not match: %s and %s on element %s',
implode(',', $_fields),
implode(',', $preparedFields),
$idx
)
);
}
$preparedValues[] = array_values($row);
}
} else {
$preparedFields = array_keys($values);
$preparedValues = [array_values($values)];
}
return [$preparedFields, $preparedValues];
} | [
"public",
"function",
"prepareInsertAssocBulk",
"(",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"0",
"]",
")",
"&&",
"is_array",
"(",
"$",
"values",
"[",
"0",
"]",
")",
")",
"{",
"//случай, когда много строк вставляется"... | * Prepares the values to insert from the associative array.
* There may be one or more lines inserted, but then the keys inside the array list must match (including in the sequence)
*
* @param mixed[] $values - array column_name => value (if we insert one row) or array list column_name => value if we insert many lines
* @return mixed[][] - list of arrays - 0 => fields, 1 => list of value arrays for insertion | [
"*",
"Prepares",
"the",
"values",
"to",
"insert",
"from",
"the",
"associative",
"array",
".",
"*",
"There",
"may",
"be",
"one",
"or",
"more",
"lines",
"inserted",
"but",
"then",
"the",
"keys",
"inside",
"the",
"array",
"list",
"must",
"match",
"(",
"incl... | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L506-L531 |
smi2/phpClickHouse | src/Client.php | Client.insertAssocBulk | public function insertAssocBulk(string $tableName, array $values)
{
list($columns, $vals) = $this->prepareInsertAssocBulk($values);
return $this->insert($tableName, $vals, $columns);
} | php | public function insertAssocBulk(string $tableName, array $values)
{
list($columns, $vals) = $this->prepareInsertAssocBulk($values);
return $this->insert($tableName, $vals, $columns);
} | [
"public",
"function",
"insertAssocBulk",
"(",
"string",
"$",
"tableName",
",",
"array",
"$",
"values",
")",
"{",
"list",
"(",
"$",
"columns",
",",
"$",
"vals",
")",
"=",
"$",
"this",
"->",
"prepareInsertAssocBulk",
"(",
"$",
"values",
")",
";",
"return",... | Inserts one or more rows from an associative array.
If there is a discrepancy between the keys of the value arrays (or their order) - throws an exception.
@param mixed[] $values - array column_name => value (if we insert one row) or array list column_name => value if we insert many lines
@return Statement | [
"Inserts",
"one",
"or",
"more",
"rows",
"from",
"an",
"associative",
"array",
".",
"If",
"there",
"is",
"a",
"discrepancy",
"between",
"the",
"keys",
"of",
"the",
"value",
"arrays",
"(",
"or",
"their",
"order",
")",
"-",
"throws",
"an",
"exception",
"."
... | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L540-L545 |
smi2/phpClickHouse | src/Client.php | Client.insertBatchTSVFiles | public function insertBatchTSVFiles(string $tableName, $fileNames, array $columns = [])
{
return $this->insertBatchFiles($tableName, $fileNames, $columns, 'TabSeparated');
} | php | public function insertBatchTSVFiles(string $tableName, $fileNames, array $columns = [])
{
return $this->insertBatchFiles($tableName, $fileNames, $columns, 'TabSeparated');
} | [
"public",
"function",
"insertBatchTSVFiles",
"(",
"string",
"$",
"tableName",
",",
"$",
"fileNames",
",",
"array",
"$",
"columns",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"insertBatchFiles",
"(",
"$",
"tableName",
",",
"$",
"fileNames",
",",
... | insert TabSeparated files
@param string|string[] $fileNames
@param string[] $columns
@return mixed | [
"insert",
"TabSeparated",
"files"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L554-L557 |
smi2/phpClickHouse | src/Client.php | Client.insertBatchFiles | public function insertBatchFiles(string $tableName, $fileNames, array $columns = [], string $format = 'CSV')
{
if (is_string($fileNames)) {
$fileNames = [$fileNames];
}
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
}
if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
throw new QueryException('Format not support in insertBatchFiles');
}
$result = [];
foreach ($fileNames as $fileName) {
if (! is_file($fileName) || ! is_readable($fileName)) {
throw new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file'));
}
if (empty($columns)) {
$sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
} else {
$sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
}
$result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName);
}
// exec
$this->executeAsync();
// fetch resutl
foreach ($fileNames as $fileName) {
if (! $result[$fileName]->isError()) {
continue;
}
$result[$fileName]->error();
}
return $result;
} | php | public function insertBatchFiles(string $tableName, $fileNames, array $columns = [], string $format = 'CSV')
{
if (is_string($fileNames)) {
$fileNames = [$fileNames];
}
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
}
if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
throw new QueryException('Format not support in insertBatchFiles');
}
$result = [];
foreach ($fileNames as $fileName) {
if (! is_file($fileName) || ! is_readable($fileName)) {
throw new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file'));
}
if (empty($columns)) {
$sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
} else {
$sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
}
$result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName);
}
// exec
$this->executeAsync();
// fetch resutl
foreach ($fileNames as $fileName) {
if (! $result[$fileName]->isError()) {
continue;
}
$result[$fileName]->error();
}
return $result;
} | [
"public",
"function",
"insertBatchFiles",
"(",
"string",
"$",
"tableName",
",",
"$",
"fileNames",
",",
"array",
"$",
"columns",
"=",
"[",
"]",
",",
"string",
"$",
"format",
"=",
"'CSV'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fileNames",
")",
")"... | insert Batch Files
@param string|string[] $fileNames
@param string[] $columns
@param string $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames']
@return Statement[]
@throws Exception\TransportException | [
"insert",
"Batch",
"Files"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L568-L609 |
smi2/phpClickHouse | src/Client.php | Client.insertBatchStream | public function insertBatchStream(string $tableName, array $columns = [], string $format = 'CSV')
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
}
if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
throw new QueryException('Format not support in insertBatchFiles');
}
if (empty($columns)) {
$sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
} else {
$sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
}
return $this->transport()->writeStreamData($sql);
} | php | public function insertBatchStream(string $tableName, array $columns = [], string $format = 'CSV')
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before insertBatch, need executeAsync');
}
if (! in_array($format, self::SUPPORTED_FORMATS, true)) {
throw new QueryException('Format not support in insertBatchFiles');
}
if (empty($columns)) {
$sql = 'INSERT INTO ' . $tableName . ' FORMAT ' . $format;
} else {
$sql = 'INSERT INTO ' . $tableName . ' ( ' . implode(',', $columns) . ' ) FORMAT ' . $format;
}
return $this->transport()->writeStreamData($sql);
} | [
"public",
"function",
"insertBatchStream",
"(",
"string",
"$",
"tableName",
",",
"array",
"$",
"columns",
"=",
"[",
"]",
",",
"string",
"$",
"format",
"=",
"'CSV'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCountPendingQueue",
"(",
")",
">",
"0",
")"... | insert Batch Stream
@param string[] $columns
@param string $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames']
@return Transport\CurlerRequest | [
"insert",
"Batch",
"Stream"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L618-L635 |
smi2/phpClickHouse | src/Client.php | Client.streamWrite | public function streamWrite(Stream $stream, string $sql, array $bind = [])
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before streamWrite');
}
return $this->transport()->streamWrite($stream, $sql, $bind);
} | php | public function streamWrite(Stream $stream, string $sql, array $bind = [])
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before streamWrite');
}
return $this->transport()->streamWrite($stream, $sql, $bind);
} | [
"public",
"function",
"streamWrite",
"(",
"Stream",
"$",
"stream",
",",
"string",
"$",
"sql",
",",
"array",
"$",
"bind",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCountPendingQueue",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
"Q... | stream Write
@param string[] $bind
@return Statement
@throws Exception\TransportException | [
"stream",
"Write"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L644-L651 |
smi2/phpClickHouse | src/Client.php | Client.streamRead | public function streamRead(Stream $streamRead, string $sql, array $bind = [])
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before streamWrite');
}
return $this->transport()->streamRead($streamRead, $sql, $bind);
} | php | public function streamRead(Stream $streamRead, string $sql, array $bind = [])
{
if ($this->getCountPendingQueue() > 0) {
throw new QueryException('Queue must be empty, before streamWrite');
}
return $this->transport()->streamRead($streamRead, $sql, $bind);
} | [
"public",
"function",
"streamRead",
"(",
"Stream",
"$",
"streamRead",
",",
"string",
"$",
"sql",
",",
"array",
"$",
"bind",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getCountPendingQueue",
"(",
")",
">",
"0",
")",
"{",
"throw",
"new",
... | stream Read
@param string[] $bind
@return Statement | [
"stream",
"Read"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L659-L666 |
smi2/phpClickHouse | src/Client.php | Client.tableSize | public function tableSize(string $tableName)
{
$tables = $this->tablesSize();
if (isset($tables[$tableName])) {
return $tables[$tableName];
}
return null;
} | php | public function tableSize(string $tableName)
{
$tables = $this->tablesSize();
if (isset($tables[$tableName])) {
return $tables[$tableName];
}
return null;
} | [
"public",
"function",
"tableSize",
"(",
"string",
"$",
"tableName",
")",
"{",
"$",
"tables",
"=",
"$",
"this",
"->",
"tablesSize",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tables",
"[",
"$",
"tableName",
"]",
")",
")",
"{",
"return",
"$",
"tab... | Size of tables
@return mixed | [
"Size",
"of",
"tables"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L693-L702 |
smi2/phpClickHouse | src/Client.php | Client.tablesSize | public function tablesSize($flatList = false)
{
$result = $this->select('
SELECT name as table,database,
max(sizebytes) as sizebytes,
max(size) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.tables
ANY LEFT JOIN
(
SELECT table,database,
formatReadableSize(sum(bytes)) as size,
sum(bytes) as sizebytes,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active AND database=:database
GROUP BY table,database
) USING ( table,database )
WHERE database=:database
GROUP BY table,database
',
['database' => $this->settings()->getDatabase()]);
if ($flatList) {
return $result->rows();
}
return $result->rowsAsTree('table');
} | php | public function tablesSize($flatList = false)
{
$result = $this->select('
SELECT name as table,database,
max(sizebytes) as sizebytes,
max(size) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.tables
ANY LEFT JOIN
(
SELECT table,database,
formatReadableSize(sum(bytes)) as size,
sum(bytes) as sizebytes,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active AND database=:database
GROUP BY table,database
) USING ( table,database )
WHERE database=:database
GROUP BY table,database
',
['database' => $this->settings()->getDatabase()]);
if ($flatList) {
return $result->rows();
}
return $result->rowsAsTree('table');
} | [
"public",
"function",
"tablesSize",
"(",
"$",
"flatList",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"select",
"(",
"'\n SELECT name as table,database,\n max(sizebytes) as sizebytes,\n max(size) as size,\n min(min_date) ... | Tables sizes
@param bool $flatList
@return mixed[][] | [
"Tables",
"sizes"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L720-L750 |
smi2/phpClickHouse | src/Client.php | Client.isExists | public function isExists(string $database, string $table)
{
return $this->select(
'
SELECT *
FROM system.tables
WHERE name=\'' . $table . '\' AND database=\'' . $database . '\''
)->rowsAsTree('name');
} | php | public function isExists(string $database, string $table)
{
return $this->select(
'
SELECT *
FROM system.tables
WHERE name=\'' . $table . '\' AND database=\'' . $database . '\''
)->rowsAsTree('name');
} | [
"public",
"function",
"isExists",
"(",
"string",
"$",
"database",
",",
"string",
"$",
"table",
")",
"{",
"return",
"$",
"this",
"->",
"select",
"(",
"'\n SELECT *\n FROM system.tables \n WHERE name=\\''",
".",
"$",
"table",
".",
"'\\' ... | isExists
@return array | [
"isExists"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L757-L765 |
smi2/phpClickHouse | src/Client.php | Client.partitions | public function partitions(string $table, int $limit = null, bool $active = null)
{
$database = $this->settings()->getDatabase();
$whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active);
$limitClause = $limit !== null ? ' LIMIT ' . $limit : '';
return $this->select(<<<CLICKHOUSE
SELECT *
FROM system.parts
WHERE like(table,'%$table%') AND database='$database'$whereActiveClause
ORDER BY max_date $limitClause
CLICKHOUSE
)->rowsAsTree('name');
} | php | public function partitions(string $table, int $limit = null, bool $active = null)
{
$database = $this->settings()->getDatabase();
$whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active);
$limitClause = $limit !== null ? ' LIMIT ' . $limit : '';
return $this->select(<<<CLICKHOUSE
SELECT *
FROM system.parts
WHERE like(table,'%$table%') AND database='$database'$whereActiveClause
ORDER BY max_date $limitClause
CLICKHOUSE
)->rowsAsTree('name');
} | [
"public",
"function",
"partitions",
"(",
"string",
"$",
"table",
",",
"int",
"$",
"limit",
"=",
"null",
",",
"bool",
"$",
"active",
"=",
"null",
")",
"{",
"$",
"database",
"=",
"$",
"this",
"->",
"settings",
"(",
")",
"->",
"getDatabase",
"(",
")",
... | List of partitions
@return mixed[][] | [
"List",
"of",
"partitions"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L772-L785 |
smi2/phpClickHouse | src/Client.php | Client.dropPartition | public function dropPartition(string $dataBaseTableName, string $partition_id)
{
$partition_id = trim($partition_id, '\'');
$this->settings()->set('replication_alter_partitions_sync', 2);
$state = $this->write('ALTER TABLE {dataBaseTableName} DROP PARTITION :partion_id',
[
'dataBaseTableName' => $dataBaseTableName,
'partion_id' => $partition_id,
]);
return $state;
} | php | public function dropPartition(string $dataBaseTableName, string $partition_id)
{
$partition_id = trim($partition_id, '\'');
$this->settings()->set('replication_alter_partitions_sync', 2);
$state = $this->write('ALTER TABLE {dataBaseTableName} DROP PARTITION :partion_id',
[
'dataBaseTableName' => $dataBaseTableName,
'partion_id' => $partition_id,
]);
return $state;
} | [
"public",
"function",
"dropPartition",
"(",
"string",
"$",
"dataBaseTableName",
",",
"string",
"$",
"partition_id",
")",
"{",
"$",
"partition_id",
"=",
"trim",
"(",
"$",
"partition_id",
",",
"'\\''",
")",
";",
"$",
"this",
"->",
"settings",
"(",
")",
"->",... | dropPartition
@deprecated
@return Statement | [
"dropPartition"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L792-L804 |
smi2/phpClickHouse | src/Client.php | Client.truncateTable | public function truncateTable(string $tableName)
{
$partions = $this->partitions($tableName);
$out = [];
foreach ($partions as $part_key => $part) {
$part_id = $part['partition'];
$out[$part_id] = $this->dropPartition($tableName, $part_id);
}
return $out;
} | php | public function truncateTable(string $tableName)
{
$partions = $this->partitions($tableName);
$out = [];
foreach ($partions as $part_key => $part) {
$part_id = $part['partition'];
$out[$part_id] = $this->dropPartition($tableName, $part_id);
}
return $out;
} | [
"public",
"function",
"truncateTable",
"(",
"string",
"$",
"tableName",
")",
"{",
"$",
"partions",
"=",
"$",
"this",
"->",
"partitions",
"(",
"$",
"tableName",
")",
";",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"partions",
"as",
"$",
"par... | Truncate ( drop all partitions )
@deprecated
@return array | [
"Truncate",
"(",
"drop",
"all",
"partitions",
")"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L811-L821 |
smi2/phpClickHouse | src/Client.php | Client.getServerSystemSettings | public function getServerSystemSettings(string $like = '')
{
$l = [];
$list = $this->select('SELECT * FROM system.settings' . ($like ? ' WHERE name LIKE :like' : ''),
['like' => '%' . $like . '%'])->rows();
foreach ($list as $row) {
if (isset($row['name'])) {
$n = $row['name'];
unset($row['name']);
$l[$n] = $row;
}
}
return $l;
} | php | public function getServerSystemSettings(string $like = '')
{
$l = [];
$list = $this->select('SELECT * FROM system.settings' . ($like ? ' WHERE name LIKE :like' : ''),
['like' => '%' . $like . '%'])->rows();
foreach ($list as $row) {
if (isset($row['name'])) {
$n = $row['name'];
unset($row['name']);
$l[$n] = $row;
}
}
return $l;
} | [
"public",
"function",
"getServerSystemSettings",
"(",
"string",
"$",
"like",
"=",
"''",
")",
"{",
"$",
"l",
"=",
"[",
"]",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"select",
"(",
"'SELECT * FROM system.settings'",
".",
"(",
"$",
"like",
"?",
"' WHERE na... | Read system.settings table
@return mixed[][] | [
"Read",
"system",
".",
"settings",
"table"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L847-L861 |
smi2/phpClickHouse | src/Client.php | Client.dropOldPartitions | public function dropOldPartitions(string $table_name, int $days_ago, int $count_partitons_per_one = 100)
{
$days_ago = strtotime(date('Y-m-d 00:00:00', strtotime('-' . $days_ago . ' day')));
$drop = [];
$list_patitions = $this->partitions($table_name, $count_partitons_per_one);
foreach ($list_patitions as $partion_id => $partition) {
if (stripos($partition['engine'], 'mergetree') === false) {
continue;
}
// $min_date = strtotime($partition['min_date']);
$max_date = strtotime($partition['max_date']);
if ($max_date < $days_ago) {
$drop[] = $partition['partition'];
}
}
$result = [];
foreach ($drop as $partition_id) {
$result[$partition_id] = $this->dropPartition($table_name, $partition_id);
}
return $result;
} | php | public function dropOldPartitions(string $table_name, int $days_ago, int $count_partitons_per_one = 100)
{
$days_ago = strtotime(date('Y-m-d 00:00:00', strtotime('-' . $days_ago . ' day')));
$drop = [];
$list_patitions = $this->partitions($table_name, $count_partitons_per_one);
foreach ($list_patitions as $partion_id => $partition) {
if (stripos($partition['engine'], 'mergetree') === false) {
continue;
}
// $min_date = strtotime($partition['min_date']);
$max_date = strtotime($partition['max_date']);
if ($max_date < $days_ago) {
$drop[] = $partition['partition'];
}
}
$result = [];
foreach ($drop as $partition_id) {
$result[$partition_id] = $this->dropPartition($table_name, $partition_id);
}
return $result;
} | [
"public",
"function",
"dropOldPartitions",
"(",
"string",
"$",
"table_name",
",",
"int",
"$",
"days_ago",
",",
"int",
"$",
"count_partitons_per_one",
"=",
"100",
")",
"{",
"$",
"days_ago",
"=",
"strtotime",
"(",
"date",
"(",
"'Y-m-d 00:00:00'",
",",
"strtotime... | dropOldPartitions by day_ago
@deprecated
@return array
@throws Exception\TransportException
@throws \Exception | [
"dropOldPartitions",
"by",
"day_ago",
"@deprecated"
] | train | https://github.com/smi2/phpClickHouse/blob/4fd6c4fcd916f9429f60db2413636b1ef47c1142/src/Client.php#L871-L897 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.convertTo | public function convertTo($filename)
{
$outputExtension = pathinfo($filename, PATHINFO_EXTENSION);
$supportedExtensions = $this->getAllowedConverter($this->extension);
if (!in_array($outputExtension, $supportedExtensions)) {
throw new OfficeConverterException("Output extension({$outputExtension}) not supported for input file({$this->basename})");
}
$outdir = $this->tempPath;
$shell = $this->exec($this->makeCommand($outdir, $outputExtension));
if ($shell['return'] != 0) {
throw new OfficeConverterException("Convertion Failure! Contact Server Admin.");
}
return $this->prepOutput($outdir, $filename, $outputExtension);
} | php | public function convertTo($filename)
{
$outputExtension = pathinfo($filename, PATHINFO_EXTENSION);
$supportedExtensions = $this->getAllowedConverter($this->extension);
if (!in_array($outputExtension, $supportedExtensions)) {
throw new OfficeConverterException("Output extension({$outputExtension}) not supported for input file({$this->basename})");
}
$outdir = $this->tempPath;
$shell = $this->exec($this->makeCommand($outdir, $outputExtension));
if ($shell['return'] != 0) {
throw new OfficeConverterException("Convertion Failure! Contact Server Admin.");
}
return $this->prepOutput($outdir, $filename, $outputExtension);
} | [
"public",
"function",
"convertTo",
"(",
"$",
"filename",
")",
"{",
"$",
"outputExtension",
"=",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"supportedExtensions",
"=",
"$",
"this",
"->",
"getAllowedConverter",
"(",
"$",
"this",
... | @param $filename
@return null|string
@throws OfficeConverterException | [
"@param",
"$filename"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L40-L56 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.open | protected function open($filename)
{
if (!file_exists($filename)) {
throw new OfficeConverterException('File does not exist --'.$filename);
}
$this->file = realpath($filename);
return true;
} | php | protected function open($filename)
{
if (!file_exists($filename)) {
throw new OfficeConverterException('File does not exist --'.$filename);
}
$this->file = realpath($filename);
return true;
} | [
"protected",
"function",
"open",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"OfficeConverterException",
"(",
"'File does not exist --'",
".",
"$",
"filename",
")",
";",
"}",
"$",
"thi... | @param $filename
@return bool
@throws OfficeConverterException | [
"@param",
"$filename"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L64-L72 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.setup | protected function setup($tempPath, $bin, $prefixExecWithExportHome)
{
//basename
$this->basename = pathinfo($this->file, PATHINFO_BASENAME);
//extension
$extension = pathinfo($this->file, PATHINFO_EXTENSION);
//Check for valid input file extension
if (!array_key_exists($extension, $this->getAllowedConverter())) {
throw new OfficeConverterException('Input file extension not supported -- '.$extension);
}
$this->extension = $extension;
//setup output path
if (!is_dir($tempPath)) {
$tempPath = dirname($this->file);
}
$this->tempPath = realpath($tempPath);
//binary location
$this->bin = $bin;
//use prefix export home or not
$this->prefixExecWithExportHome = $prefixExecWithExportHome;
} | php | protected function setup($tempPath, $bin, $prefixExecWithExportHome)
{
//basename
$this->basename = pathinfo($this->file, PATHINFO_BASENAME);
//extension
$extension = pathinfo($this->file, PATHINFO_EXTENSION);
//Check for valid input file extension
if (!array_key_exists($extension, $this->getAllowedConverter())) {
throw new OfficeConverterException('Input file extension not supported -- '.$extension);
}
$this->extension = $extension;
//setup output path
if (!is_dir($tempPath)) {
$tempPath = dirname($this->file);
}
$this->tempPath = realpath($tempPath);
//binary location
$this->bin = $bin;
//use prefix export home or not
$this->prefixExecWithExportHome = $prefixExecWithExportHome;
} | [
"protected",
"function",
"setup",
"(",
"$",
"tempPath",
",",
"$",
"bin",
",",
"$",
"prefixExecWithExportHome",
")",
"{",
"//basename",
"$",
"this",
"->",
"basename",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"file",
",",
"PATHINFO_BASENAME",
")",
";",
"//ex... | @param $tempPath
@param $bin
@param $prefixExecWithExportHome
@throws OfficeConverterException | [
"@param",
"$tempPath",
"@param",
"$bin",
"@param",
"$prefixExecWithExportHome"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L81-L106 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.makeCommand | protected function makeCommand($outputDirectory, $outputExtension)
{
$oriFile = escapeshellarg($this->file);
$outputDirectory = escapeshellarg($outputDirectory);
return "{$this->bin} --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory}";
} | php | protected function makeCommand($outputDirectory, $outputExtension)
{
$oriFile = escapeshellarg($this->file);
$outputDirectory = escapeshellarg($outputDirectory);
return "{$this->bin} --headless --convert-to {$outputExtension} {$oriFile} --outdir {$outputDirectory}";
} | [
"protected",
"function",
"makeCommand",
"(",
"$",
"outputDirectory",
",",
"$",
"outputExtension",
")",
"{",
"$",
"oriFile",
"=",
"escapeshellarg",
"(",
"$",
"this",
"->",
"file",
")",
";",
"$",
"outputDirectory",
"=",
"escapeshellarg",
"(",
"$",
"outputDirecto... | @param $outputDirectory
@param $outputExtension
@return string | [
"@param",
"$outputDirectory",
"@param",
"$outputExtension"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L114-L120 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.prepOutput | protected function prepOutput($outdir, $filename, $outputExtension)
{
$DS = DIRECTORY_SEPARATOR;
$tmpName = str_replace($this->extension, '', $this->basename).$outputExtension;
if (rename($outdir.$DS.$tmpName, $outdir.$DS.$filename)) {
return $outdir.$DS.$filename;
} elseif (is_file($outdir.$DS.$tmpName)) {
return $outdir.$DS.$tmpName;
}
return null;
} | php | protected function prepOutput($outdir, $filename, $outputExtension)
{
$DS = DIRECTORY_SEPARATOR;
$tmpName = str_replace($this->extension, '', $this->basename).$outputExtension;
if (rename($outdir.$DS.$tmpName, $outdir.$DS.$filename)) {
return $outdir.$DS.$filename;
} elseif (is_file($outdir.$DS.$tmpName)) {
return $outdir.$DS.$tmpName;
}
return null;
} | [
"protected",
"function",
"prepOutput",
"(",
"$",
"outdir",
",",
"$",
"filename",
",",
"$",
"outputExtension",
")",
"{",
"$",
"DS",
"=",
"DIRECTORY_SEPARATOR",
";",
"$",
"tmpName",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"extension",
",",
"''",
",",
"... | @param $outdir
@param $filename
@param $outputExtension
@return null|string | [
"@param",
"$outdir",
"@param",
"$filename",
"@param",
"$outputExtension"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L129-L140 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.getAllowedConverter | private function getAllowedConverter($extension = null)
{
$allowedConverter = [
'' => ['pdf'],
'pptx' => ['pdf'],
'ppt' => ['pdf'],
'pdf' => ['pdf'],
'docx' => ['pdf', 'odt', 'html'],
'doc' => ['pdf', 'odt', 'html'],
'wps' => ['pdf', 'odt', 'html'],
'dotx' => ['pdf', 'odt', 'html'],
'docm' => ['pdf', 'odt', 'html'],
'dotm' => ['pdf', 'odt', 'html'],
'dot' => ['pdf', 'odt', 'html'],
'odt' => ['pdf', 'html'],
'xlsx' => ['pdf'],
'xls' => ['pdf'],
'png' => ['pdf'],
'jpg' => ['pdf'],
'jpeg' => ['pdf'],
'jfif' => ['pdf'],
'PPTX' => ['pdf'],
'PPT' => ['pdf'],
'PDF' => ['pdf'],
'DOCX' => ['pdf', 'odt', 'html'],
'DOC' => ['pdf', 'odt', 'html'],
'WPS' => ['pdf', 'odt', 'html'],
'DOTX' => ['pdf', 'odt', 'html'],
'DOCM' => ['pdf', 'odt', 'html'],
'DOTM' => ['pdf', 'odt', 'html'],
'DOT' => ['pdf', 'odt', 'html'],
'ODT' => ['pdf', 'html'],
'XLSX' => ['pdf'],
'XLS' => ['pdf'],
'PNG' => ['pdf'],
'JPG' => ['pdf'],
'JPEG' => ['pdf'],
'JFIF' => ['pdf'],
'Pptx' => ['pdf'],
'Ppt' => ['pdf'],
'Pdf' => ['pdf'],
'Docx' => ['pdf', 'odt', 'html'],
'Doc' => ['pdf', 'odt', 'html'],
'Wps' => ['pdf', 'odt', 'html'],
'Dotx' => ['pdf', 'odt', 'html'],
'Docm' => ['pdf', 'odt', 'html'],
'Dotm' => ['pdf', 'odt', 'html'],
'Dot' => ['pdf', 'odt', 'html'],
'Ddt' => ['pdf', 'html'],
'Xlsx' => ['pdf'],
'Xls' => ['pdf'],
'Png' => ['pdf'],
'Jpg' => ['pdf'],
'Jpeg' => ['pdf'],
'Jfif' => ['pdf'],
'rtf' => ['docx', 'txt']
];
if ($extension !== null) {
if (isset($allowedConverter[$extension])) {
return $allowedConverter[$extension];
}
return [];
}
return $allowedConverter;
} | php | private function getAllowedConverter($extension = null)
{
$allowedConverter = [
'' => ['pdf'],
'pptx' => ['pdf'],
'ppt' => ['pdf'],
'pdf' => ['pdf'],
'docx' => ['pdf', 'odt', 'html'],
'doc' => ['pdf', 'odt', 'html'],
'wps' => ['pdf', 'odt', 'html'],
'dotx' => ['pdf', 'odt', 'html'],
'docm' => ['pdf', 'odt', 'html'],
'dotm' => ['pdf', 'odt', 'html'],
'dot' => ['pdf', 'odt', 'html'],
'odt' => ['pdf', 'html'],
'xlsx' => ['pdf'],
'xls' => ['pdf'],
'png' => ['pdf'],
'jpg' => ['pdf'],
'jpeg' => ['pdf'],
'jfif' => ['pdf'],
'PPTX' => ['pdf'],
'PPT' => ['pdf'],
'PDF' => ['pdf'],
'DOCX' => ['pdf', 'odt', 'html'],
'DOC' => ['pdf', 'odt', 'html'],
'WPS' => ['pdf', 'odt', 'html'],
'DOTX' => ['pdf', 'odt', 'html'],
'DOCM' => ['pdf', 'odt', 'html'],
'DOTM' => ['pdf', 'odt', 'html'],
'DOT' => ['pdf', 'odt', 'html'],
'ODT' => ['pdf', 'html'],
'XLSX' => ['pdf'],
'XLS' => ['pdf'],
'PNG' => ['pdf'],
'JPG' => ['pdf'],
'JPEG' => ['pdf'],
'JFIF' => ['pdf'],
'Pptx' => ['pdf'],
'Ppt' => ['pdf'],
'Pdf' => ['pdf'],
'Docx' => ['pdf', 'odt', 'html'],
'Doc' => ['pdf', 'odt', 'html'],
'Wps' => ['pdf', 'odt', 'html'],
'Dotx' => ['pdf', 'odt', 'html'],
'Docm' => ['pdf', 'odt', 'html'],
'Dotm' => ['pdf', 'odt', 'html'],
'Dot' => ['pdf', 'odt', 'html'],
'Ddt' => ['pdf', 'html'],
'Xlsx' => ['pdf'],
'Xls' => ['pdf'],
'Png' => ['pdf'],
'Jpg' => ['pdf'],
'Jpeg' => ['pdf'],
'Jfif' => ['pdf'],
'rtf' => ['docx', 'txt']
];
if ($extension !== null) {
if (isset($allowedConverter[$extension])) {
return $allowedConverter[$extension];
}
return [];
}
return $allowedConverter;
} | [
"private",
"function",
"getAllowedConverter",
"(",
"$",
"extension",
"=",
"null",
")",
"{",
"$",
"allowedConverter",
"=",
"[",
"''",
"=>",
"[",
"'pdf'",
"]",
",",
"'pptx'",
"=>",
"[",
"'pdf'",
"]",
",",
"'ppt'",
"=>",
"[",
"'pdf'",
"]",
",",
"'pdf'",
... | @param null $extension
@return array|mixed | [
"@param",
"null",
"$extension"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L147-L214 |
ncjoes/office-converter | src/OfficeConverter/OfficeConverter.php | OfficeConverter.exec | private function exec($cmd, $input = '')
{
// Cannot use $_SERVER superglobal since that's empty during UnitUnishTestCase
// getenv('HOME') isn't set on Windows and generates a Notice.
if ($this->prefixExecWithExportHome) {
$home = getenv('HOME');
if (!is_writable($home)) {
$cmd = 'export HOME=/tmp && ' . $cmd;
}
}
$process = proc_open($cmd, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
fwrite($pipes[0], $input);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn = proc_close($process);
return [
'stdout' => $stdout,
'stderr' => $stderr,
'return' => $rtn
];
} | php | private function exec($cmd, $input = '')
{
// Cannot use $_SERVER superglobal since that's empty during UnitUnishTestCase
// getenv('HOME') isn't set on Windows and generates a Notice.
if ($this->prefixExecWithExportHome) {
$home = getenv('HOME');
if (!is_writable($home)) {
$cmd = 'export HOME=/tmp && ' . $cmd;
}
}
$process = proc_open($cmd, [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes);
fwrite($pipes[0], $input);
fclose($pipes[0]);
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$rtn = proc_close($process);
return [
'stdout' => $stdout,
'stderr' => $stderr,
'return' => $rtn
];
} | [
"private",
"function",
"exec",
"(",
"$",
"cmd",
",",
"$",
"input",
"=",
"''",
")",
"{",
"// Cannot use $_SERVER superglobal since that's empty during UnitUnishTestCase",
"// getenv('HOME') isn't set on Windows and generates a Notice.",
"if",
"(",
"$",
"this",
"->",
"prefixExe... | More intelligent interface to system calls
@link http://php.net/manual/en/function.system.php
@param $cmd
@param string $input
@return array | [
"More",
"intelligent",
"interface",
"to",
"system",
"calls"
] | train | https://github.com/ncjoes/office-converter/blob/c93df31cd2bf5f6c725ae29e3c3f05d6d4bdd4ad/src/OfficeConverter/OfficeConverter.php#L226-L250 |
basvandorst/StravaPHP | src/Strava/API/Factory.php | Factory.getOAuthClient | public function getOAuthClient($client_id, $client_secret, $redirect_uri)
{
$options = [
'clientId' => $client_id,
'clientSecret' => $client_secret,
'redirectUri' => $redirect_uri
];
$OAuthClient = new OAuth($options);
return $OAuthClient;
} | php | public function getOAuthClient($client_id, $client_secret, $redirect_uri)
{
$options = [
'clientId' => $client_id,
'clientSecret' => $client_secret,
'redirectUri' => $redirect_uri
];
$OAuthClient = new OAuth($options);
return $OAuthClient;
} | [
"public",
"function",
"getOAuthClient",
"(",
"$",
"client_id",
",",
"$",
"client_secret",
",",
"$",
"redirect_uri",
")",
"{",
"$",
"options",
"=",
"[",
"'clientId'",
"=>",
"$",
"client_id",
",",
"'clientSecret'",
"=>",
"$",
"client_secret",
",",
"'redirectUri'... | Return a new instance of the OAuth Client
@param string $client_id
@param string $client_secret
@param string $redirect_uri
@return OAuth | [
"Return",
"a",
"new",
"instance",
"of",
"the",
"OAuth",
"Client"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Factory.php#L26-L36 |
basvandorst/StravaPHP | src/Strava/API/Factory.php | Factory.getAPIClient | public function getAPIClient($token)
{
$adapter = new \GuzzleHttp\Client(['base_uri' => self::$endpoint]);
$service = new Service\REST($token, $adapter);
$APIClient = new Client($service);
return $APIClient;
} | php | public function getAPIClient($token)
{
$adapter = new \GuzzleHttp\Client(['base_uri' => self::$endpoint]);
$service = new Service\REST($token, $adapter);
$APIClient = new Client($service);
return $APIClient;
} | [
"public",
"function",
"getAPIClient",
"(",
"$",
"token",
")",
"{",
"$",
"adapter",
"=",
"new",
"\\",
"GuzzleHttp",
"\\",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"self",
"::",
"$",
"endpoint",
"]",
")",
";",
"$",
"service",
"=",
"new",
"Service",
"\\",
... | Return a new instance of the API Client
@param string $token
@return Client | [
"Return",
"a",
"new",
"instance",
"of",
"the",
"API",
"Client"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Factory.php#L44-L52 |
basvandorst/StravaPHP | src/Strava/API/Service/REST.php | REST.getResult | private function getResult($response)
{
$status = $response->getStatusCode();
if ($status == 200) {
return json_decode($response->getBody(), JSON_PRETTY_PRINT);
} else {
return [$status => $response->getReasonPhrase()];
}
} | php | private function getResult($response)
{
$status = $response->getStatusCode();
if ($status == 200) {
return json_decode($response->getBody(), JSON_PRETTY_PRINT);
} else {
return [$status => $response->getReasonPhrase()];
}
} | [
"private",
"function",
"getResult",
"(",
"$",
"response",
")",
"{",
"$",
"status",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"status",
"==",
"200",
")",
"{",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getBod... | Get a request result.
Returns an array with a response body or and error code => reason.
@param \GuzzleHttp\Psr7\Response $response
@return array|mixed | [
"Get",
"a",
"request",
"result",
".",
"Returns",
"an",
"array",
"with",
"a",
"response",
"body",
"or",
"and",
"error",
"code",
"=",
">",
"reason",
"."
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Service/REST.php#L52-L60 |
basvandorst/StravaPHP | src/Strava/API/Service/REST.php | REST.getResponse | private function getResponse($method, $path, $parameters)
{
try {
$response = $this->adapter->request($method, $path, $parameters);
return $this->getResult($response);
}
catch (\Exception $e) {
return $e->getMessage();
}
} | php | private function getResponse($method, $path, $parameters)
{
try {
$response = $this->adapter->request($method, $path, $parameters);
return $this->getResult($response);
}
catch (\Exception $e) {
return $e->getMessage();
}
} | [
"private",
"function",
"getResponse",
"(",
"$",
"method",
",",
"$",
"path",
",",
"$",
"parameters",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"adapter",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"path",
",",
"$",
"parameters... | Get an API request response and handle possible exceptions.
@param string $method
@param string $path
@param array $parameters
@return array|mixed|string | [
"Get",
"an",
"API",
"request",
"response",
"and",
"handle",
"possible",
"exceptions",
"."
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Service/REST.php#L71-L80 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getAthlete | public function getAthlete($id = null)
{
try {
return $this->service->getAthlete($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getAthlete($id = null)
{
try {
return $this->service->getAthlete($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getAthlete",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getAthlete",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
... | Retrieve current athlete
@link https://strava.github.io/api/v3/athlete/#get-details,
https://strava.github.io/api/v3/athlete/#get-another-details
@param int $id
@return array
@throws Exception | [
"Retrieve",
"current",
"athlete"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L43-L50 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getAthleteStats | public function getAthleteStats($id)
{
try {
return $this->service->getAthleteStats($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getAthleteStats($id)
{
try {
return $this->service->getAthleteStats($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getAthleteStats",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getAthleteStats",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"Client... | Retrieve athlete stats
Only available for the authenticated athlete.
@link https://strava.github.io/api/v3/athlete/#stats
@param int $id
@return array
@throws ClientException | [
"Retrieve",
"athlete",
"stats"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L62-L69 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getAthleteRoutes | public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
{
try {
return $this->service->getAthleteRoutes($id, $type, $after, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getAthleteRoutes($id, $type = null, $after = null, $page = null, $per_page = null)
{
try {
return $this->service->getAthleteRoutes($id, $type, $after, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getAthleteRoutes",
"(",
"$",
"id",
",",
"$",
"type",
"=",
"null",
",",
"$",
"after",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",... | Retrieve athlete routes
@link https://strava.github.io/api/v3/routes/#list
@param int $id
@return array
@throws ClientException | [
"Retrieve",
"athlete",
"routes"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L79-L86 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getAthleteActivities | public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
{
try {
return $this->service->getAthleteActivities($before, $after, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getAthleteActivities($before = null, $after = null, $page = null, $per_page = null)
{
try {
return $this->service->getAthleteActivities($before, $after, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getAthleteActivities",
"(",
"$",
"before",
"=",
"null",
",",
"$",
"after",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getA... | List athlete activities
@link https://strava.github.io/api/v3/activities/#get-activities
@param string $before
@param string $after
@param int $page
@param int $per_page
@return array
@throws Exception | [
"List",
"athlete",
"activities"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L115-L122 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.updateAthlete | public function updateAthlete($city, $state, $country, $sex, $weight)
{
try {
return $this->service->updateAthlete($city, $state, $country, $sex, $weight);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function updateAthlete($city, $state, $country, $sex, $weight)
{
try {
return $this->service->updateAthlete($city, $state, $country, $sex, $weight);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"updateAthlete",
"(",
"$",
"city",
",",
"$",
"state",
",",
"$",
"country",
",",
"$",
"sex",
",",
"$",
"weight",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"updateAthlete",
"(",
"$",
"city",
",",
"$",
"... | Update current athlete
@link https://strava.github.io/api/v3/athlete/#update
@param string $city
@param string $state
@param string $country
@param string $sex
@param float $weight
@return array
@throws Exception | [
"Update",
"current",
"athlete"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L249-L256 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityFollowing | public function getActivityFollowing($before = null, $page = null, $per_page = null)
{
try {
return $this->service->getActivityFollowing($before, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityFollowing($before = null, $page = null, $per_page = null)
{
try {
return $this->service->getActivityFollowing($before, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityFollowing",
"(",
"$",
"before",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityFollowing",
"(",
"$",
"before... | Retrieve activity from user followers
@link https://strava.github.io/api/v3/activities/#get-feed
@param type $before
@param type $page
@param type $per_page
@return type
@throws ClientException | [
"Retrieve",
"activity",
"from",
"user",
"followers"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L269-L276 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivity | public function getActivity($id, $include_all_efforts = null)
{
try {
return $this->service->getActivity($id, $include_all_efforts);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivity($id, $include_all_efforts = null)
{
try {
return $this->service->getActivity($id, $include_all_efforts);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivity",
"(",
"$",
"id",
",",
"$",
"include_all_efforts",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivity",
"(",
"$",
"id",
",",
"$",
"include_all_efforts",
")",
";",
"}",
"catch",... | Retrieve an activity
@link https://strava.github.io/api/v3/athlete/#get-details,
https://strava.github.io/api/v3/athlete/#get-another-details
@param int $id
@param boolean $include_all_efforts
@return array
@throws Exception | [
"Retrieve",
"an",
"activity"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L289-L296 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityComments | public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
{
try {
return $this->service->getActivityComments($id, $markdown, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityComments($id, $markdown = null, $page = null, $per_page = null)
{
try {
return $this->service->getActivityComments($id, $markdown, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityComments",
"(",
"$",
"id",
",",
"$",
"markdown",
"=",
"null",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityComments",
... | List activity comments
@link https://strava.github.io/api/v3/comments/#list
@param int $id
@param boolean $markdown
@param int $page
@param int $per_page
@return array
@throws Exception | [
"List",
"activity",
"comments"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L309-L316 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityKudos | public function getActivityKudos($id, $page = null, $per_page = null)
{
try {
return $this->service->getActivityKudos($id, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityKudos($id, $page = null, $per_page = null)
{
try {
return $this->service->getActivityKudos($id, $page, $per_page);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityKudos",
"(",
"$",
"id",
",",
"$",
"page",
"=",
"null",
",",
"$",
"per_page",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityKudos",
"(",
"$",
"id",
",",
"$",
"page",
",",... | List activity kudoers
@link https://strava.github.io/api/v3/kudos/#list
@param int $id
@param int $page
@param int $per_page
@return array
@throws Exception | [
"List",
"activity",
"kudoers"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L328-L335 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityPhotos | public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
{
try {
return $this->service->getActivityPhotos($id, $size, $photo_sources);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityPhotos($id, $size = 2048, $photo_sources = 'true')
{
try {
return $this->service->getActivityPhotos($id, $size, $photo_sources);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityPhotos",
"(",
"$",
"id",
",",
"$",
"size",
"=",
"2048",
",",
"$",
"photo_sources",
"=",
"'true'",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityPhotos",
"(",
"$",
"id",
",",
"$",
"size... | List activity photos
@link https://strava.github.io/api/v3/photos/#list
@param int $id
@param int $size In pixels.
@param string $photo_sources Must be "true".
@return array
@throws Exception | [
"List",
"activity",
"photos"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L347-L354 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityZones | public function getActivityZones($id)
{
try {
return $this->service->getActivityZones($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityZones($id)
{
try {
return $this->service->getActivityZones($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityZones",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityZones",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"Clie... | List activity zones
@link https://strava.github.io/api/v3/activities/#zones
@param int $id
@return array
@throws Exception | [
"List",
"activity",
"zones"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L364-L371 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityLaps | public function getActivityLaps($id)
{
try {
return $this->service->getActivityLaps($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityLaps($id)
{
try {
return $this->service->getActivityLaps($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityLaps",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityLaps",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"Client... | List activity laps
@link https://strava.github.io/api/v3/activities/#laps
@param int $id
@return array
@throws Exception | [
"List",
"activity",
"laps"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L381-L388 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getActivityUploadStatus | public function getActivityUploadStatus($id)
{
try {
return $this->service->getActivityUploadStatus($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getActivityUploadStatus($id)
{
try {
return $this->service->getActivityUploadStatus($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getActivityUploadStatus",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getActivityUploadStatus",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
... | Check upload status
@link https://strava.github.io/api/v3/uploads/#get-status
@param int $id
@return array
@throws Exception | [
"Check",
"upload",
"status"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L398-L405 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.createActivity | public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
{
try {
return $this->service->createActivity($name, $type, $start_date_local, $elapsed_time, $description, $distance, $private, $trainer);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function createActivity($name, $type, $start_date_local, $elapsed_time, $description = null, $distance = null, $private = null, $trainer = null)
{
try {
return $this->service->createActivity($name, $type, $start_date_local, $elapsed_time, $description, $distance, $private, $trainer);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"createActivity",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"start_date_local",
",",
"$",
"elapsed_time",
",",
"$",
"description",
"=",
"null",
",",
"$",
"distance",
"=",
"null",
",",
"$",
"private",
"=",
"null",
",",
"$",
"tr... | Create an activity
@link https://strava.github.io/api/v3/activities/#create
@param string $name
@param string $type
@param string $start_date_local
@param int $elapsed_time
@param string $description
@param float $distance
@param int $private
@param int $trainer
@return array
@throws Exception | [
"Create",
"an",
"activity"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L422-L429 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.uploadActivity | public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
{
try {
return $this->service->uploadActivity($file, $activity_type, $name, $description, $private, $trainer, $commute, $data_type, $external_id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function uploadActivity($file, $activity_type = null, $name = null, $description = null, $private = null, $trainer = null, $commute = null, $data_type = null, $external_id = null)
{
try {
return $this->service->uploadActivity($file, $activity_type, $name, $description, $private, $trainer, $commute, $data_type, $external_id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"uploadActivity",
"(",
"$",
"file",
",",
"$",
"activity_type",
"=",
"null",
",",
"$",
"name",
"=",
"null",
",",
"$",
"description",
"=",
"null",
",",
"$",
"private",
"=",
"null",
",",
"$",
"trainer",
"=",
"null",
",",
"$",
"comm... | Upload an activity
@link https://strava.github.io/api/v3/uploads/#post-file
@param mixed $file
@param string $activity_type
@param string $name
@param string $description
@param int $private
@param int $trainer
@param int $commute
@param string $data_type
@param string $external_id
@return array
@throws Exception | [
"Upload",
"an",
"activity"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L447-L454 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.updateActivity | public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
{
try {
return $this->service->updateActivity($id, $name, $type, $private, $commute, $trainer, $gear_id, $description);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function updateActivity($id, $name = null, $type = null, $private = false, $commute = false, $trainer = false, $gear_id = null, $description = null)
{
try {
return $this->service->updateActivity($id, $name, $type, $private, $commute, $trainer, $gear_id, $description);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"updateActivity",
"(",
"$",
"id",
",",
"$",
"name",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"private",
"=",
"false",
",",
"$",
"commute",
"=",
"false",
",",
"$",
"trainer",
"=",
"false",
",",
"$",
"gear_id",
"=",... | Update an activity
@link https://strava.github.io/api/v3/activities/#put-updates
@param int $id
@param string $name
@param string $type
@param boolean $private
@param boolean $commute
@param boolean $trainer
@param string $gear_id
@param string $description
@return array
@throws Exception | [
"Update",
"an",
"activity"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L471-L478 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.deleteActivity | public function deleteActivity($id)
{
try {
return $this->service->deleteActivity($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function deleteActivity($id)
{
try {
return $this->service->deleteActivity($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"deleteActivity",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"deleteActivity",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientEx... | Delete an activity
@link https://strava.github.io/api/v3/activities/#delete
@param int $id
@return array
@throws Exception | [
"Delete",
"an",
"activity"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L488-L495 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getGear | public function getGear($id)
{
try {
return $this->service->getGear($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getGear($id)
{
try {
return $this->service->getGear($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getGear",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getGear",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
"(... | Retrieve gear
@link https://strava.github.io/api/v3/gear/
@param int $id
@return array
@throws Exception | [
"Retrieve",
"gear"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L505-L512 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getClub | public function getClub($id)
{
try {
return $this->service->getClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getClub($id)
{
try {
return $this->service->getClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getClub",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getClub",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
"(... | Retrieve a club
@link https://strava.github.io/api/v3/clubs/#get-details
@param int $id
@return array
@throws Exception | [
"Retrieve",
"a",
"club"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L522-L529 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getClubAnnouncements | public function getClubAnnouncements($id)
{
try {
return $this->service->getClubAnnouncements($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getClubAnnouncements($id)
{
try {
return $this->service->getClubAnnouncements($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getClubAnnouncements",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getClubAnnouncements",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",... | List club announcements
@link https://strava.github.io/api/v3/clubs/#get-announcements
@param int $id
@return array
@throws Exception | [
"List",
"club",
"announcements"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L577-L584 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.getClubGroupEvents | public function getClubGroupEvents($id)
{
try {
return $this->service->getClubGroupEvents($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function getClubGroupEvents($id)
{
try {
return $this->service->getClubGroupEvents($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"getClubGroupEvents",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"getClubGroupEvents",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"... | List club group events
@link https://strava.github.io/api/v3/clubs/#get-group-events
@param int $id
@return array
@throws Exception | [
"List",
"club",
"group",
"events"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L594-L601 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.joinClub | public function joinClub($id)
{
try {
return $this->service->joinClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function joinClub($id)
{
try {
return $this->service->joinClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"joinClub",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"joinClub",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
... | Join a club
@link https://strava.github.io/api/v3/clubs/#join
@param int $id
@return array
@throws Exception | [
"Join",
"a",
"club"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L611-L618 |
basvandorst/StravaPHP | src/Strava/API/Client.php | Client.leaveClub | public function leaveClub($id)
{
try {
return $this->service->leaveClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | php | public function leaveClub($id)
{
try {
return $this->service->leaveClub($id);
} catch (ServiceException $e) {
throw new ClientException('[SERVICE] ' . $e->getMessage());
}
} | [
"public",
"function",
"leaveClub",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"service",
"->",
"leaveClub",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
... | Leave a club
@link https://strava.github.io/api/v3/clubs/#leave
@param int $id
@return array
@throws Exception | [
"Leave",
"a",
"club"
] | train | https://github.com/basvandorst/StravaPHP/blob/5b2b2a9246434273e5a7b8e9d0333765e0fcafbf/src/Strava/API/Client.php#L628-L635 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.