repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
networking/init-cms-bundle
src/Admin/BaseAdmin.php
BaseAdmin.setUpTranslatableLocale
public function setUpTranslatableLocale() { /** @var \Gedmo\Translatable\TranslatableListener $translatable */ $translatableListener = $this->getContainer()->get('stof_doctrine_extensions.listener.translatable', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($translatableListener) { $translatableListener->setTranslatableLocale($this->getDefaultLocale()); } }
php
public function setUpTranslatableLocale() { /** @var \Gedmo\Translatable\TranslatableListener $translatable */ $translatableListener = $this->getContainer()->get('stof_doctrine_extensions.listener.translatable', ContainerInterface::NULL_ON_INVALID_REFERENCE); if ($translatableListener) { $translatableListener->setTranslatableLocale($this->getDefaultLocale()); } }
[ "public", "function", "setUpTranslatableLocale", "(", ")", "{", "/** @var \\Gedmo\\Translatable\\TranslatableListener $translatable */", "$", "translatableListener", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'stof_doctrine_extensions.listener.translat...
Set up listner to make sure the correct locale is used.
[ "Set", "up", "listner", "to", "make", "sure", "the", "correct", "locale", "is", "used", "." ]
9c6e0f09de216e19795caac5840c197f46fde03d
https://github.com/networking/init-cms-bundle/blob/9c6e0f09de216e19795caac5840c197f46fde03d/src/Admin/BaseAdmin.php#L53-L60
train
wutongwan/laravel-lego
src/Lego/Foundation/Event.php
Event.register
public function register($event, $listener, \Closure $callback) { if (!isset($this->events[$event])) { $this->events[$event] = []; } if ($listener) { $this->events[$event][$listener] = $callback; } else { $this->events[$event][] = $callback; $keys = array_keys($this->events[$event]); $listener = array_pop($keys); } return $listener; }
php
public function register($event, $listener, \Closure $callback) { if (!isset($this->events[$event])) { $this->events[$event] = []; } if ($listener) { $this->events[$event][$listener] = $callback; } else { $this->events[$event][] = $callback; $keys = array_keys($this->events[$event]); $listener = array_pop($keys); } return $listener; }
[ "public", "function", "register", "(", "$", "event", ",", "$", "listener", ",", "\\", "Closure", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "events", "[", "$", "event", "]", ")", ")", "{", "$", "this", "->", "even...
Register event. @param string $event event name @param string $listener listener name @param \Closure $callback call when fire @return string|int
[ "Register", "event", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Event.php#L25-L40
train
wutongwan/laravel-lego
src/Lego/Foundation/Event.php
Event.once
public function once($event, $listener, \Closure $callback) { $realListener = $this->register($event, $listener, $callback); if (!isset($this->once[$event])) { $this->once[$event] = []; } $this->once[$event][$realListener] = true; return $realListener; }
php
public function once($event, $listener, \Closure $callback) { $realListener = $this->register($event, $listener, $callback); if (!isset($this->once[$event])) { $this->once[$event] = []; } $this->once[$event][$realListener] = true; return $realListener; }
[ "public", "function", "once", "(", "$", "event", ",", "$", "listener", ",", "\\", "Closure", "$", "callback", ")", "{", "$", "realListener", "=", "$", "this", "->", "register", "(", "$", "event", ",", "$", "listener", ",", "$", "callback", ")", ";", ...
fire only once.
[ "fire", "only", "once", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Event.php#L45-L55
train
wutongwan/laravel-lego
src/Lego/Foundation/Button.php
Button.attribute
public function attribute($name, $value, $merge = true) { if (!$merge) { $this->attributes[$name] = $value; return $this; } $current = array_get($this->attributes, $name); if (is_array($current) && is_array($value)) { $current = array_unique(array_merge($current, $value)); } elseif (is_string($current) && is_string($value)) { $current = trim($current) . ' ' . trim($value); } else { $current = $value; } $this->attributes[$name] = $current; return $this; }
php
public function attribute($name, $value, $merge = true) { if (!$merge) { $this->attributes[$name] = $value; return $this; } $current = array_get($this->attributes, $name); if (is_array($current) && is_array($value)) { $current = array_unique(array_merge($current, $value)); } elseif (is_string($current) && is_string($value)) { $current = trim($current) . ' ' . trim($value); } else { $current = $value; } $this->attributes[$name] = $current; return $this; }
[ "public", "function", "attribute", "(", "$", "name", ",", "$", "value", ",", "$", "merge", "=", "true", ")", "{", "if", "(", "!", "$", "merge", ")", "{", "$", "this", "->", "attributes", "[", "$", "name", "]", "=", "$", "value", ";", "return", ...
set html attribute. @param $name @param $value @param bool $merge if true, new `value` will be merge to current `value` @return $this
[ "set", "html", "attribute", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Foundation/Button.php#L93-L112
train
wutongwan/laravel-lego
src/Lego/Field/Concerns/HasValidation.php
HasValidation.unique
public function unique($id = null, $idColumn = null, $extra = null) { if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) { throw new LegoException( 'Validation: `unique` rule only worked for Eloquent, ' . 'you can use `validator($closure)` implement unique validation.' ); } /** * @var \Illuminate\Database\Eloquent\Model * @var Field $this */ $model = $this->data; $id = $id ?: $this->store->getKey() ?: 'NULL'; $idColumn = $idColumn ?: $this->store->getKeyName(); $parts = [ "unique:{$model->getConnectionName()}.{$model->getTable()}", $this->column(), $id, $idColumn, ]; if ($extra) { $parts[] = trim($extra, ','); } $this->rule(join(',', $parts)); return $this; }
php
public function unique($id = null, $idColumn = null, $extra = null) { if (!$this->store instanceof \Lego\Operator\Eloquent\EloquentStore) { throw new LegoException( 'Validation: `unique` rule only worked for Eloquent, ' . 'you can use `validator($closure)` implement unique validation.' ); } /** * @var \Illuminate\Database\Eloquent\Model * @var Field $this */ $model = $this->data; $id = $id ?: $this->store->getKey() ?: 'NULL'; $idColumn = $idColumn ?: $this->store->getKeyName(); $parts = [ "unique:{$model->getConnectionName()}.{$model->getTable()}", $this->column(), $id, $idColumn, ]; if ($extra) { $parts[] = trim($extra, ','); } $this->rule(join(',', $parts)); return $this; }
[ "public", "function", "unique", "(", "$", "id", "=", "null", ",", "$", "idColumn", "=", "null", ",", "$", "extra", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "store", "instanceof", "\\", "Lego", "\\", "Operator", "\\", "Eloquent", "\...
Laravel Validation unique. Auto except current model https://laravel.com/docs/master/validation#rule-unique
[ "Laravel", "Validation", "unique", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Field/Concerns/HasValidation.php#L163-L195
train
wutongwan/laravel-lego
src/Lego/Field/FieldNameSlicer.php
FieldNameSlicer.split
public static function split(string $name): array { $parts = explode(self::JSON_DELIMITER, $name, 2); $jsonPath = count($parts) === 2 ? explode(self::JSON_DELIMITER, end($parts)) : []; $relationParts = explode(self::RELATION_DELIMITER, $parts[0]); return [ array_slice($relationParts, 0, -1), end($relationParts), $jsonPath, ]; }
php
public static function split(string $name): array { $parts = explode(self::JSON_DELIMITER, $name, 2); $jsonPath = count($parts) === 2 ? explode(self::JSON_DELIMITER, end($parts)) : []; $relationParts = explode(self::RELATION_DELIMITER, $parts[0]); return [ array_slice($relationParts, 0, -1), end($relationParts), $jsonPath, ]; }
[ "public", "static", "function", "split", "(", "string", "$", "name", ")", ":", "array", "{", "$", "parts", "=", "explode", "(", "self", "::", "JSON_DELIMITER", ",", "$", "name", ",", "2", ")", ";", "$", "jsonPath", "=", "count", "(", "$", "parts", ...
split name to relation, column and json path. @param string $name field name, eg: school.city.column:json_key:sub_json_key @return array eg: [ ['school', 'city'], 'column', ['json_key', 'sub_json_key'] ]
[ "split", "name", "to", "relation", "column", "and", "json", "path", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Field/FieldNameSlicer.php#L23-L35
train
wutongwan/laravel-lego
src/Lego/Operator/Query.php
Query.paginate
public function paginate( $perPage = null, $columns = null, $pageName = null, $page = null, bool $lengthAware = true ) { $perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage; $pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName; $columns = is_null($columns) ? ['*'] : $columns; $page = $page ?: Request::query($pageName, 1); if ($lengthAware) { $this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page); } else { $this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page); } $this->paginator->setCollection( $this->paginator->getCollection()->map(function ($row) { return Finder::createStore($row); }) ); return $this->paginator; }
php
public function paginate( $perPage = null, $columns = null, $pageName = null, $page = null, bool $lengthAware = true ) { $perPage = is_null($perPage) ? config('lego.paginator.per-page') : $perPage; $pageName = is_null($pageName) ? config('lego.paginator.page-name') : $pageName; $columns = is_null($columns) ? ['*'] : $columns; $page = $page ?: Request::query($pageName, 1); if ($lengthAware) { $this->paginator = $this->createLengthAwarePaginator($perPage, $columns, $pageName, $page); } else { $this->paginator = $this->createLengthNotAwarePaginator($perPage, $columns, $pageName, $page); } $this->paginator->setCollection( $this->paginator->getCollection()->map(function ($row) { return Finder::createStore($row); }) ); return $this->paginator; }
[ "public", "function", "paginate", "(", "$", "perPage", "=", "null", ",", "$", "columns", "=", "null", ",", "$", "pageName", "=", "null", ",", "$", "page", "=", "null", ",", "bool", "$", "lengthAware", "=", "true", ")", "{", "$", "perPage", "=", "is...
Paginator API. @param int $perPage 每页条数 @param array $columns 需要的字段列表 @param string $pageName 分页的 GET 参数名称 @param int $page 当前页码 @param bool $lengthAware 是否需要查询总页数 @return AbstractPaginator|Store[]
[ "Paginator", "API", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Operator/Query.php#L214-L239
train
wutongwan/laravel-lego
src/Lego/Widget/Grid/Concerns/HasCells.php
HasCells.remove
public function remove($names) { $names = is_array($names) ? $names : func_get_args(); foreach ($names as $name) { unset($this->cells[$name]); } return $this; }
php
public function remove($names) { $names = is_array($names) ? $names : func_get_args(); foreach ($names as $name) { unset($this->cells[$name]); } return $this; }
[ "public", "function", "remove", "(", "$", "names", ")", "{", "$", "names", "=", "is_array", "(", "$", "names", ")", "?", "$", "names", ":", "func_get_args", "(", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "unset", "(", "...
remove cell from grid.
[ "remove", "cell", "from", "grid", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Grid/Concerns/HasCells.php#L54-L62
train
wutongwan/laravel-lego
src/Lego/Widget/Concerns/HasBottomButtons.php
HasBottomButtons.submitText
public function submitText(string $submitText) { /** @var Button $btn */ $btn = $this->getButton($this->bottomLocation, $this->submitButtonKey); $btn->text($submitText); return $this; }
php
public function submitText(string $submitText) { /** @var Button $btn */ $btn = $this->getButton($this->bottomLocation, $this->submitButtonKey); $btn->text($submitText); return $this; }
[ "public", "function", "submitText", "(", "string", "$", "submitText", ")", "{", "/** @var Button $btn */", "$", "btn", "=", "$", "this", "->", "getButton", "(", "$", "this", "->", "bottomLocation", ",", "$", "this", "->", "submitButtonKey", ")", ";", "$", ...
Set submit button text. @param string $submitText @return $this
[ "Set", "submit", "button", "text", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasBottomButtons.php#L63-L70
train
wutongwan/laravel-lego
src/Lego/Widget/Concerns/HasBottomButtons.php
HasBottomButtons.resetText
public function resetText(string $resetText) { /** @var Button $btn */ $btn = $this->getButton($this->bottomLocation, $this->resetButtonKey); $btn->text($resetText); return $this; }
php
public function resetText(string $resetText) { /** @var Button $btn */ $btn = $this->getButton($this->bottomLocation, $this->resetButtonKey); $btn->text($resetText); return $this; }
[ "public", "function", "resetText", "(", "string", "$", "resetText", ")", "{", "/** @var Button $btn */", "$", "btn", "=", "$", "this", "->", "getButton", "(", "$", "this", "->", "bottomLocation", ",", "$", "this", "->", "resetButtonKey", ")", ";", "$", "bt...
Set reset button text. @param string $resetText @return $this
[ "Set", "reset", "button", "text", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasBottomButtons.php#L79-L86
train
wutongwan/laravel-lego
src/Lego/Operator/Plastic/PlasticQuery.php
PlasticQuery.with
public function with(array $relations) { $this->with = array_unique(array_merge($this->with, $relations)); return $this; }
php
public function with(array $relations) { $this->with = array_unique(array_merge($this->with, $relations)); return $this; }
[ "public", "function", "with", "(", "array", "$", "relations", ")", "{", "$", "this", "->", "with", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "with", ",", "$", "relations", ")", ")", ";", "return", "$", "this", ";", "}" ]
Query with eager loading. @param array $relations @return static
[ "Query", "with", "eager", "loading", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Operator/Plastic/PlasticQuery.php#L44-L49
train
wutongwan/laravel-lego
src/Lego/Widget/Grid/Cell.php
Cell.value
public function value() { $value = lego_default($this->getOriginalValue(), $this->default); foreach ($this->pipes as $pipe) { $value = $pipe->handle($value, $this->data, $this); } return new HtmlString((string) $value); }
php
public function value() { $value = lego_default($this->getOriginalValue(), $this->default); foreach ($this->pipes as $pipe) { $value = $pipe->handle($value, $this->data, $this); } return new HtmlString((string) $value); }
[ "public", "function", "value", "(", ")", "{", "$", "value", "=", "lego_default", "(", "$", "this", "->", "getOriginalValue", "(", ")", ",", "$", "this", "->", "default", ")", ";", "foreach", "(", "$", "this", "->", "pipes", "as", "$", "pipe", ")", ...
cell value after pipes processed. @return HtmlString
[ "cell", "value", "after", "pipes", "processed", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Grid/Cell.php#L123-L131
train
wutongwan/laravel-lego
src/Lego/Widget/Concerns/HasFields.php
HasFields.editableFields
public function editableFields() { $ignored = []; foreach ($this->groups() as $group) { if ($group->getCondition() && $group->getCondition()->fail()) { $ignored = array_merge($ignored, $group->fieldNames()); } } return $this->fields()->filter(function (Field $field) use ($ignored) { return $field->isEditable() && !in_array($field->name(), $ignored); }); }
php
public function editableFields() { $ignored = []; foreach ($this->groups() as $group) { if ($group->getCondition() && $group->getCondition()->fail()) { $ignored = array_merge($ignored, $group->fieldNames()); } } return $this->fields()->filter(function (Field $field) use ($ignored) { return $field->isEditable() && !in_array($field->name(), $ignored); }); }
[ "public", "function", "editableFields", "(", ")", "{", "$", "ignored", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "groups", "(", ")", "as", "$", "group", ")", "{", "if", "(", "$", "group", "->", "getCondition", "(", ")", "&&", "$", "g...
only editable fields. @return Collection|Field[]
[ "only", "editable", "fields", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasFields.php#L86-L98
train
wutongwan/laravel-lego
src/Lego/Widget/Concerns/HasFields.php
HasFields.required
public function required($fields = []) { $fields = $fields ?: $this->fields(); foreach ($fields as $field) { if (is_string($field)) { $this->field($field)->required(); continue; } /* @var Field $field */ $field->required(); } return $this; }
php
public function required($fields = []) { $fields = $fields ?: $this->fields(); foreach ($fields as $field) { if (is_string($field)) { $this->field($field)->required(); continue; } /* @var Field $field */ $field->required(); } return $this; }
[ "public", "function", "required", "(", "$", "fields", "=", "[", "]", ")", "{", "$", "fields", "=", "$", "fields", "?", ":", "$", "this", "->", "fields", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "is_...
Mark Fields as Required. @param array[]|Field[] $fields @return $this
[ "Mark", "Fields", "as", "Required", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Concerns/HasFields.php#L135-L150
train
wutongwan/laravel-lego
src/Lego/Widget/Form.php
Form.saveFieldsValueToStore
protected function saveFieldsValueToStore() { $this->editableFields()->each(function (Field $field) { if ($field->isDoesntStore()) { return; } $field->syncValueToStore(); }); $this->events->fire('saving', [$this->data, $this]); if ($this->getStore()->save()) { $this->syncFieldsValueFromStore(); $this->events->fire('saved', [$this->data, $this]); return true; } return false; }
php
protected function saveFieldsValueToStore() { $this->editableFields()->each(function (Field $field) { if ($field->isDoesntStore()) { return; } $field->syncValueToStore(); }); $this->events->fire('saving', [$this->data, $this]); if ($this->getStore()->save()) { $this->syncFieldsValueFromStore(); $this->events->fire('saved', [$this->data, $this]); return true; } return false; }
[ "protected", "function", "saveFieldsValueToStore", "(", ")", "{", "$", "this", "->", "editableFields", "(", ")", "->", "each", "(", "function", "(", "Field", "$", "field", ")", "{", "if", "(", "$", "field", "->", "isDoesntStore", "(", ")", ")", "{", "r...
sync field's value to source.
[ "sync", "field", "s", "value", "to", "source", "." ]
c9bf8443f5bafb97986315f45025d0ce742a1091
https://github.com/wutongwan/laravel-lego/blob/c9bf8443f5bafb97986315f45025d0ce742a1091/src/Lego/Widget/Form.php#L168-L187
train
yzalis/Supervisor
src/Supervisor/Process.php
Process.startProcess
public function startProcess($wait = true) { return $this->rpcClient->call('supervisor.startProcess', array($this->processGroup.':'.$this->processName, $wait)); }
php
public function startProcess($wait = true) { return $this->rpcClient->call('supervisor.startProcess', array($this->processGroup.':'.$this->processName, $wait)); }
[ "public", "function", "startProcess", "(", "$", "wait", "=", "true", ")", "{", "return", "$", "this", "->", "rpcClient", "->", "call", "(", "'supervisor.startProcess'", ",", "array", "(", "$", "this", "->", "processGroup", ".", "':'", ".", "$", "this", "...
Start a process @param boolean $wait Wait for process to be fully started @return boolean Always true unless error
[ "Start", "a", "process" ]
d73f228fadde179bf6590928450f71ea69509ce4
https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Process.php#L78-L81
train
yzalis/Supervisor
src/Supervisor/Process.php
Process.stopProcess
public function stopProcess($wait = true) { return $this->rpcClient->call('supervisor.stopProcess', array($this->processGroup.':'.$this->processName, $wait)); }
php
public function stopProcess($wait = true) { return $this->rpcClient->call('supervisor.stopProcess', array($this->processGroup.':'.$this->processName, $wait)); }
[ "public", "function", "stopProcess", "(", "$", "wait", "=", "true", ")", "{", "return", "$", "this", "->", "rpcClient", "->", "call", "(", "'supervisor.stopProcess'", ",", "array", "(", "$", "this", "->", "processGroup", ".", "':'", ".", "$", "this", "->...
Stop a process @param boolean $wait Wait for process to be fully started @return boolean Always true unless error
[ "Stop", "a", "process" ]
d73f228fadde179bf6590928450f71ea69509ce4
https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Process.php#L90-L93
train
yzalis/Supervisor
src/Supervisor/Supervisor.php
Supervisor.createKey
private function createKey($ipAdress, $port, $username = null, $password = null) { $this->key = hash('md5', serialize(array( $ipAdress, $port, $username, $password, ))); }
php
private function createKey($ipAdress, $port, $username = null, $password = null) { $this->key = hash('md5', serialize(array( $ipAdress, $port, $username, $password, ))); }
[ "private", "function", "createKey", "(", "$", "ipAdress", ",", "$", "port", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ")", "{", "$", "this", "->", "key", "=", "hash", "(", "'md5'", ",", "serialize", "(", "array", "(", "$...
Create a unique key. It ll be used to retrieve a supervisor object. @param string $ipAdress @param string $username @param string $password
[ "Create", "a", "unique", "key", ".", "It", "ll", "be", "used", "to", "retrieve", "a", "supervisor", "object", "." ]
d73f228fadde179bf6590928450f71ea69509ce4
https://github.com/yzalis/Supervisor/blob/d73f228fadde179bf6590928450f71ea69509ce4/src/Supervisor/Supervisor.php#L77-L85
train
wikimedia/IPSet
src/IPSet.php
IPSet.addCidr
private function addCidr( $cidr ) { // v4 or v6 check if ( strpos( $cidr, ':' ) === false ) { $node =& $this->root4; $defMask = '32'; } else { $node =& $this->root6; $defMask = '128'; } // Default to all-1's mask if no netmask in the input if ( strpos( $cidr, '/' ) === false ) { $net = $cidr; $mask = $defMask; } else { list( $net, $mask ) = explode( '/', $cidr, 2 ); if ( !ctype_digit( $mask ) || intval( $mask ) > $defMask ) { trigger_error( "IPSet: Bad mask '$mask' from '$cidr', ignored", E_USER_WARNING ); return false; } } $mask = intval( $mask ); // explicit integer convert, checked above // convert $net to an array of integer bytes, length 4 or 16: $raw = AtEase::quietCall( 'inet_pton', $net ); if ( $raw === false ) { return false; } $rawOrd = array_map( 'ord', str_split( $raw ) ); // iterate the bits of the address while walking the tree structure for inserts // at the end, $snode will point to the highest node that could only lead to a // successful match (and thus can be set to true) $snode =& $node; $curBit = 0; while ( 1 ) { if ( $node === true ) { // already added a larger supernet, no need to go deeper return; } elseif ( $curBit == $mask ) { // this may wipe out deeper subnets from earlier $snode = true; return; } elseif ( $node === false ) { // create new subarray to go deeper if ( !( $curBit & 7 ) && $curBit <= $mask - 8 ) { $node = [ 'comp' => $rawOrd[$curBit >> 3], 'next' => false ]; } else { $node = [ false, false ]; } } if ( isset( $node['comp'] ) ) { $comp = $node['comp']; if ( $rawOrd[$curBit >> 3] == $comp && $curBit <= $mask - 8 ) { // whole byte matches, skip over the compressed node $node =& $node['next']; $snode =& $node; $curBit += 8; continue; } else { // have to decompress the node and check individual bits $unode = $node['next']; for ( $i = 0; $i < 8; ++$i ) { $unode = ( $comp & ( 1 << $i ) ) ? [ false, $unode ] : [ $unode, false ]; } $node = $unode; } } $maskShift = 7 - ( $curBit & 7 ); $index = ( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift; if ( $node[$index ^ 1] !== true ) { // no adjacent subnet, can't form a supernet at this level $snode =& $node[$index]; } $node =& $node[$index]; ++$curBit; } // Unreachable outside 'while' }
php
private function addCidr( $cidr ) { // v4 or v6 check if ( strpos( $cidr, ':' ) === false ) { $node =& $this->root4; $defMask = '32'; } else { $node =& $this->root6; $defMask = '128'; } // Default to all-1's mask if no netmask in the input if ( strpos( $cidr, '/' ) === false ) { $net = $cidr; $mask = $defMask; } else { list( $net, $mask ) = explode( '/', $cidr, 2 ); if ( !ctype_digit( $mask ) || intval( $mask ) > $defMask ) { trigger_error( "IPSet: Bad mask '$mask' from '$cidr', ignored", E_USER_WARNING ); return false; } } $mask = intval( $mask ); // explicit integer convert, checked above // convert $net to an array of integer bytes, length 4 or 16: $raw = AtEase::quietCall( 'inet_pton', $net ); if ( $raw === false ) { return false; } $rawOrd = array_map( 'ord', str_split( $raw ) ); // iterate the bits of the address while walking the tree structure for inserts // at the end, $snode will point to the highest node that could only lead to a // successful match (and thus can be set to true) $snode =& $node; $curBit = 0; while ( 1 ) { if ( $node === true ) { // already added a larger supernet, no need to go deeper return; } elseif ( $curBit == $mask ) { // this may wipe out deeper subnets from earlier $snode = true; return; } elseif ( $node === false ) { // create new subarray to go deeper if ( !( $curBit & 7 ) && $curBit <= $mask - 8 ) { $node = [ 'comp' => $rawOrd[$curBit >> 3], 'next' => false ]; } else { $node = [ false, false ]; } } if ( isset( $node['comp'] ) ) { $comp = $node['comp']; if ( $rawOrd[$curBit >> 3] == $comp && $curBit <= $mask - 8 ) { // whole byte matches, skip over the compressed node $node =& $node['next']; $snode =& $node; $curBit += 8; continue; } else { // have to decompress the node and check individual bits $unode = $node['next']; for ( $i = 0; $i < 8; ++$i ) { $unode = ( $comp & ( 1 << $i ) ) ? [ false, $unode ] : [ $unode, false ]; } $node = $unode; } } $maskShift = 7 - ( $curBit & 7 ); $index = ( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift; if ( $node[$index ^ 1] !== true ) { // no adjacent subnet, can't form a supernet at this level $snode =& $node[$index]; } $node =& $node[$index]; ++$curBit; } // Unreachable outside 'while' }
[ "private", "function", "addCidr", "(", "$", "cidr", ")", "{", "// v4 or v6 check", "if", "(", "strpos", "(", "$", "cidr", ",", "':'", ")", "===", "false", ")", "{", "$", "node", "=", "&", "$", "this", "->", "root4", ";", "$", "defMask", "=", "'32'"...
Add a single CIDR spec to the internal matching trees @param string $cidr String CIDR spec, IPv[46], optional /mask (def all-1's) @return false|null Returns null on success, false on failure
[ "Add", "a", "single", "CIDR", "spec", "to", "the", "internal", "matching", "trees" ]
1913cc022f43a3cd03c17b386299aa488faf1e21
https://github.com/wikimedia/IPSet/blob/1913cc022f43a3cd03c17b386299aa488faf1e21/src/IPSet.php#L112-L193
train
wikimedia/IPSet
src/IPSet.php
IPSet.match
public function match( $ip ) { $raw = AtEase::quietCall( 'inet_pton', $ip ); if ( $raw === false ) { return false; } $rawOrd = array_map( 'ord', str_split( $raw ) ); if ( count( $rawOrd ) == 4 ) { $node =& $this->root4; } else { $node =& $this->root6; } $curBit = 0; while ( $node !== true && $node !== false ) { if ( isset( $node['comp'] ) ) { // compressed node, matches 1 whole byte on a byte boundary if ( $rawOrd[$curBit >> 3] != $node['comp'] ) { return false; } $curBit += 8; $node =& $node['next']; } else { // uncompressed node, walk in the correct direction for the current bit-value $maskShift = 7 - ( $curBit & 7 ); $node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift]; ++$curBit; } } return $node; }
php
public function match( $ip ) { $raw = AtEase::quietCall( 'inet_pton', $ip ); if ( $raw === false ) { return false; } $rawOrd = array_map( 'ord', str_split( $raw ) ); if ( count( $rawOrd ) == 4 ) { $node =& $this->root4; } else { $node =& $this->root6; } $curBit = 0; while ( $node !== true && $node !== false ) { if ( isset( $node['comp'] ) ) { // compressed node, matches 1 whole byte on a byte boundary if ( $rawOrd[$curBit >> 3] != $node['comp'] ) { return false; } $curBit += 8; $node =& $node['next']; } else { // uncompressed node, walk in the correct direction for the current bit-value $maskShift = 7 - ( $curBit & 7 ); $node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift]; ++$curBit; } } return $node; }
[ "public", "function", "match", "(", "$", "ip", ")", "{", "$", "raw", "=", "AtEase", "::", "quietCall", "(", "'inet_pton'", ",", "$", "ip", ")", ";", "if", "(", "$", "raw", "===", "false", ")", "{", "return", "false", ";", "}", "$", "rawOrd", "=",...
Match an IP address against the set If $ip is unparseable, inet_pton may issue an E_WARNING to that effect @param string $ip string IPv[46] address @return bool True is match success, false is match failure
[ "Match", "an", "IP", "address", "against", "the", "set" ]
1913cc022f43a3cd03c17b386299aa488faf1e21
https://github.com/wikimedia/IPSet/blob/1913cc022f43a3cd03c17b386299aa488faf1e21/src/IPSet.php#L203-L234
train
hiqdev/hiam
src/base/Message.php
Message.renderHtmlBody
public function renderHtmlBody($view, array $params = []) { if (!array_key_exists('message', $params)) { $params['message'] = $this; } return $this->setHtmlBody($this->render($view, $params, $this->mailer->htmlLayout)); }
php
public function renderHtmlBody($view, array $params = []) { if (!array_key_exists('message', $params)) { $params['message'] = $this; } return $this->setHtmlBody($this->render($view, $params, $this->mailer->htmlLayout)); }
[ "public", "function", "renderHtmlBody", "(", "$", "view", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "array_key_exists", "(", "'message'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'message'", "]", "=", "$", ...
Renders and sets message HTML content. @param string|array|null $view the view to be used for rendering the message body @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file @return $this self reference
[ "Renders", "and", "sets", "message", "HTML", "content", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/Message.php#L23-L30
train
hiqdev/hiam
src/base/Message.php
Message.renderTextBody
public function renderTextBody($view, array $params = []) { if (!array_key_exists('message', $params)) { $params['message'] = $this; } return $this->setTextBody($this->render($view, $params, $this->mailer->textLayout)); }
php
public function renderTextBody($view, array $params = []) { if (!array_key_exists('message', $params)) { $params['message'] = $this; } return $this->setTextBody($this->render($view, $params, $this->mailer->textLayout)); }
[ "public", "function", "renderTextBody", "(", "$", "view", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "array_key_exists", "(", "'message'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'message'", "]", "=", "$", ...
Renders and sets message plain text content. @param string|array|null $view the view to be used for rendering the message body @param array $params the parameters (name-value pairs) that will be extracted and made available in the view file @return $this self reference
[ "Renders", "and", "sets", "message", "plain", "text", "content", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/Message.php#L38-L45
train
hiqdev/hiam
src/base/User.php
User.findIdentityByAuthClient
public function findIdentityByAuthClient(ClientInterface $client) { $remote = $this->getRemoteUser($client); if (!$remote->provider) { return null; } if ($remote->client_id) { return $this->findIdentity($remote->client_id); } $email = $client->getUserAttributes()['email']; $user = $this->findIdentityByEmail($email); if (!$user) { return null; } if ($remote->isTrustedEmail($email)) { return $this->setRemoteUser($client, $user); } return null; }
php
public function findIdentityByAuthClient(ClientInterface $client) { $remote = $this->getRemoteUser($client); if (!$remote->provider) { return null; } if ($remote->client_id) { return $this->findIdentity($remote->client_id); } $email = $client->getUserAttributes()['email']; $user = $this->findIdentityByEmail($email); if (!$user) { return null; } if ($remote->isTrustedEmail($email)) { return $this->setRemoteUser($client, $user); } return null; }
[ "public", "function", "findIdentityByAuthClient", "(", "ClientInterface", "$", "client", ")", "{", "$", "remote", "=", "$", "this", "->", "getRemoteUser", "(", "$", "client", ")", ";", "if", "(", "!", "$", "remote", "->", "provider", ")", "{", "return", ...
Finds user through RemoteUser. @return IdentityInterface
[ "Finds", "user", "through", "RemoteUser", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/User.php#L94-L113
train
hiqdev/hiam
src/base/User.php
User.setRemoteUser
public function setRemoteUser(ClientInterface $client, IdentityInterface $user) { $model = $this->getRemoteUser($client); $model->client_id = $user->getId(); $model->save(); return $user; }
php
public function setRemoteUser(ClientInterface $client, IdentityInterface $user) { $model = $this->getRemoteUser($client); $model->client_id = $user->getId(); $model->save(); return $user; }
[ "public", "function", "setRemoteUser", "(", "ClientInterface", "$", "client", ",", "IdentityInterface", "$", "user", ")", "{", "$", "model", "=", "$", "this", "->", "getRemoteUser", "(", "$", "client", ")", ";", "$", "model", "->", "client_id", "=", "$", ...
Inserts or updates RemoteUser. @return IdentityInterface user
[ "Inserts", "or", "updates", "RemoteUser", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/base/User.php#L119-L126
train
hiqdev/hiam
src/controllers/OauthController.php
OauthController.getRequestValue
public function getRequestValue($name, $default = null) { $request = $this->getModule()->getRequest(); return isset($request->request[$name]) ? $request->request[$name] : $request->query($name, $default); }
php
public function getRequestValue($name, $default = null) { $request = $this->getModule()->getRequest(); return isset($request->request[$name]) ? $request->request[$name] : $request->query($name, $default); }
[ "public", "function", "getRequestValue", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "request", "=", "$", "this", "->", "getModule", "(", ")", "->", "getRequest", "(", ")", ";", "return", "isset", "(", "$", "request", "->", "re...
Get request parameter from POST then GET. @param string $name @param string $default @return string
[ "Get", "request", "parameter", "from", "POST", "then", "GET", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/controllers/OauthController.php#L84-L89
train
hiqdev/hiam
src/controllers/SiteController.php
SiteController.login
private function login(Identity $identity, $sessionDuration = 0): bool { $returnUrl = $this->user->getReturnUrl(); $result = $this->user->login($identity, $sessionDuration ? null : 0); if ($result && $returnUrl !== null) { $this->user->setReturnUrl($returnUrl); } return $result; }
php
private function login(Identity $identity, $sessionDuration = 0): bool { $returnUrl = $this->user->getReturnUrl(); $result = $this->user->login($identity, $sessionDuration ? null : 0); if ($result && $returnUrl !== null) { $this->user->setReturnUrl($returnUrl); } return $result; }
[ "private", "function", "login", "(", "Identity", "$", "identity", ",", "$", "sessionDuration", "=", "0", ")", ":", "bool", "{", "$", "returnUrl", "=", "$", "this", "->", "user", "->", "getReturnUrl", "(", ")", ";", "$", "result", "=", "$", "this", "-...
Logs user in and preserves return URL.
[ "Logs", "user", "in", "and", "preserves", "return", "URL", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/controllers/SiteController.php#L163-L173
train
hiqdev/hiam
src/models/RemoteUser.php
RemoteUser.isTrustedEmail
public function isTrustedEmail($email) { static $trustedEmails = [ '@gmail.com' => 'Google', '@yandex.ru' => 'Yandex', ]; foreach ($trustedEmails as $domain => $trusted) { if ($this->provider === static::toProvider($trusted) && substr($email, -strlen($domain)) === $domain) { return true; } } return false; }
php
public function isTrustedEmail($email) { static $trustedEmails = [ '@gmail.com' => 'Google', '@yandex.ru' => 'Yandex', ]; foreach ($trustedEmails as $domain => $trusted) { if ($this->provider === static::toProvider($trusted) && substr($email, -strlen($domain)) === $domain) { return true; } } return false; }
[ "public", "function", "isTrustedEmail", "(", "$", "email", ")", "{", "static", "$", "trustedEmails", "=", "[", "'@gmail.com'", "=>", "'Google'", ",", "'@yandex.ru'", "=>", "'Yandex'", ",", "]", ";", "foreach", "(", "$", "trustedEmails", "as", "$", "domain", ...
Returns if given email is provided with appropriate service so it can be trusted. @param string email address @return bool is trusted
[ "Returns", "if", "given", "email", "is", "provided", "with", "appropriate", "service", "so", "it", "can", "be", "trusted", "." ]
1cc20ae30599adc4044cffb34dc97c57075cbfe3
https://github.com/hiqdev/hiam/blob/1cc20ae30599adc4044cffb34dc97c57075cbfe3/src/models/RemoteUser.php#L49-L62
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.read
protected function read() { // Ignore first byte fread($this->socket, 1); // There is also masking bit, as MSB, bit it's 0 $payloadLength = ord(fread($this->socket, 1)); switch ($payloadLength) { case 126: $payloadLength = unpack('n', fread($this->socket, 2)); $payloadLength = $payloadLength[1]; break; case 127: //$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!"); break; } return fread($this->socket, $payloadLength); }
php
protected function read() { // Ignore first byte fread($this->socket, 1); // There is also masking bit, as MSB, bit it's 0 $payloadLength = ord(fread($this->socket, 1)); switch ($payloadLength) { case 126: $payloadLength = unpack('n', fread($this->socket, 2)); $payloadLength = $payloadLength[1]; break; case 127: //$this->stdout('error', "Next 8 bytes are 64bit uint payload length, not yet implemented, since PHP can't handle 64bit longs!"); break; } return fread($this->socket, $payloadLength); }
[ "protected", "function", "read", "(", ")", "{", "// Ignore first byte", "fread", "(", "$", "this", "->", "socket", ",", "1", ")", ";", "// There is also masking bit, as MSB, bit it's 0", "$", "payloadLength", "=", "ord", "(", "fread", "(", "$", "this", "->", "...
Read the buffer and return the oldest event in stack. @see https://tools.ietf.org/html/rfc6455#section-5.2 @return string
[ "Read", "the", "buffer", "and", "return", "the", "oldest", "event", "in", "stack", "." ]
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L194-L213
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.send
protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true) { $rawMessage = json_encode($data); $payload = new WebsocketPayload(); $payload ->setOpcode($opcode) ->setMask($masked) ->setPayload($rawMessage); $encoded = $payload->encodePayload(); if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect. $this->connected = false; $this->connect($this->target); fwrite($this->socket, $encoded); } return $this; }
php
protected function send($data, $opcode = WebsocketPayload::OPCODE_TEXT, $masked = true) { $rawMessage = json_encode($data); $payload = new WebsocketPayload(); $payload ->setOpcode($opcode) ->setMask($masked) ->setPayload($rawMessage); $encoded = $payload->encodePayload(); if (0 === @fwrite($this->socket, $encoded)) { //connection reseted by peers, just reconnect. $this->connected = false; $this->connect($this->target); fwrite($this->socket, $encoded); } return $this; }
[ "protected", "function", "send", "(", "$", "data", ",", "$", "opcode", "=", "WebsocketPayload", "::", "OPCODE_TEXT", ",", "$", "masked", "=", "true", ")", "{", "$", "rawMessage", "=", "json_encode", "(", "$", "data", ")", ";", "$", "payload", "=", "new...
Send message to the websocket. @param array $data @return $this|Client
[ "Send", "message", "to", "the", "websocket", "." ]
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L261-L280
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.prefix
public function prefix($prefix, $uri) { $type = Protocol::MSG_PREFIX; $data = [$type, $prefix, $uri]; $this->send($data); }
php
public function prefix($prefix, $uri) { $type = Protocol::MSG_PREFIX; $data = [$type, $prefix, $uri]; $this->send($data); }
[ "public", "function", "prefix", "(", "$", "prefix", ",", "$", "uri", ")", "{", "$", "type", "=", "Protocol", "::", "MSG_PREFIX", ";", "$", "data", "=", "[", "$", "type", ",", "$", "prefix", ",", "$", "uri", "]", ";", "$", "this", "->", "send", ...
Establish a prefix on server. @see http://wamp.ws/spec#prefix_message @param string $prefix @param string $uri
[ "Establish", "a", "prefix", "on", "server", "." ]
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L290-L295
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.call
public function call($procUri, $arguments = []) { $args = func_get_args(); array_shift($args); $type = Protocol::MSG_CALL; $callId = uniqid('', $moreEntropy = true); $data = array_merge(array($type, $callId, $procUri), $args); $this->send($data); }
php
public function call($procUri, $arguments = []) { $args = func_get_args(); array_shift($args); $type = Protocol::MSG_CALL; $callId = uniqid('', $moreEntropy = true); $data = array_merge(array($type, $callId, $procUri), $args); $this->send($data); }
[ "public", "function", "call", "(", "$", "procUri", ",", "$", "arguments", "=", "[", "]", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "$", "type", "=", "Protocol", "::", "MSG_CALL", ";", "$"...
Call a procedure on server. @see http://wamp.ws/spec#call_message @param string $procURI @param mixed $arguments
[ "Call", "a", "procedure", "on", "server", "." ]
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L305-L314
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.publish
public function publish($topicUri, $payload, $exclude = [], $eligible = []) { if (null !== $this->logger) { $this->logger->info(sprintf( 'Publish in %s', $topicUri )); } $data = array(Protocol::MSG_PUBLISH, $topicUri, $payload, $exclude, $eligible); $this->send($data); }
php
public function publish($topicUri, $payload, $exclude = [], $eligible = []) { if (null !== $this->logger) { $this->logger->info(sprintf( 'Publish in %s', $topicUri )); } $data = array(Protocol::MSG_PUBLISH, $topicUri, $payload, $exclude, $eligible); $this->send($data); }
[ "public", "function", "publish", "(", "$", "topicUri", ",", "$", "payload", ",", "$", "exclude", "=", "[", "]", ",", "$", "eligible", "=", "[", "]", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "...
The client will send an event to all clients connected to the server who have subscribed to the topicURI. @see http://wamp.ws/spec#publish_message @param string $topicUri @param string $payload @param string $exclude @param string $eligible
[ "The", "client", "will", "send", "an", "event", "to", "all", "clients", "connected", "to", "the", "server", "who", "have", "subscribed", "to", "the", "topicURI", "." ]
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L326-L337
train
GeniusesOfSymfony/WebSocketPhpClient
Wamp/Client.php
Client.event
public function event($topicUri, $payload) { $type = Protocol::MSG_EVENT; $data = array($type, $topicUri, $payload); $this->send($data); }
php
public function event($topicUri, $payload) { $type = Protocol::MSG_EVENT; $data = array($type, $topicUri, $payload); $this->send($data); }
[ "public", "function", "event", "(", "$", "topicUri", ",", "$", "payload", ")", "{", "$", "type", "=", "Protocol", "::", "MSG_EVENT", ";", "$", "data", "=", "array", "(", "$", "type", ",", "$", "topicUri", ",", "$", "payload", ")", ";", "$", "this",...
Subscribers receive PubSub events published by subscribers via the EVENT message. The EVENT message contains the topicURI, the topic under which the event was published, and event, the PubSub event payload. @param string $topicUri @param string $payload
[ "Subscribers", "receive", "PubSub", "events", "published", "by", "subscribers", "via", "the", "EVENT", "message", ".", "The", "EVENT", "message", "contains", "the", "topicURI", "the", "topic", "under", "which", "the", "event", "was", "published", "and", "event",...
64e4351d42acb77d5b6df748221c889a2f0adee4
https://github.com/GeniusesOfSymfony/WebSocketPhpClient/blob/64e4351d42acb77d5b6df748221c889a2f0adee4/Wamp/Client.php#L345-L350
train
glensc/slack-unfurl
src/Command/UrlVerification.php
UrlVerification.execute
public function execute(array $payload): JsonResponse { $challenge = $payload['challenge'] ?? null; if ($challenge) { return new JsonResponse(['challenge' => $challenge]); } throw new RuntimeException(); }
php
public function execute(array $payload): JsonResponse { $challenge = $payload['challenge'] ?? null; if ($challenge) { return new JsonResponse(['challenge' => $challenge]); } throw new RuntimeException(); }
[ "public", "function", "execute", "(", "array", "$", "payload", ")", ":", "JsonResponse", "{", "$", "challenge", "=", "$", "payload", "[", "'challenge'", "]", "??", "null", ";", "if", "(", "$", "challenge", ")", "{", "return", "new", "JsonResponse", "(", ...
Handle Request URL Configuration & Verification @param array $payload @return JsonResponse @see https://api.slack.com/events-api#request_url_configuration__amp__verification
[ "Handle", "Request", "URL", "Configuration", "&", "Verification" ]
5dabe632a728b40f1391479f6c32f93f7b4db860
https://github.com/glensc/slack-unfurl/blob/5dabe632a728b40f1391479f6c32f93f7b4db860/src/Command/UrlVerification.php#L17-L25
train
EFTEC/ValidationOne
lib/ValidationOne.php
ValidationOne.input
private function input() { if ($this->input===null) { $this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list } return $this->input; }
php
private function input() { if ($this->input===null) { $this->input=new ValidationInputOne($this->prefix,$this->messageList); // we used the same message list } return $this->input; }
[ "private", "function", "input", "(", ")", "{", "if", "(", "$", "this", "->", "input", "===", "null", ")", "{", "$", "this", "->", "input", "=", "new", "ValidationInputOne", "(", "$", "this", "->", "prefix", ",", "$", "this", "->", "messageList", ")",...
it's the injector of validationinputone. @return ValidationInputOne
[ "it", "s", "the", "injector", "of", "validationinputone", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L112-L117
train
EFTEC/ValidationOne
lib/ValidationOne.php
ValidationOne.getTypeFamily
private function getTypeFamily($type) { if (is_array($type)) { $r=[]; foreach($type as $key=>$t) { $r[$key]=$this->getTypeFamily($t); } } else { switch (1 == 1) { case (strpos($this->STRARR, $type) !== false): $r = 1; // string break; case (strpos($this->DATARR, $type) !== false): $r = 2; // date break; case ($type == 'boolean'): $r = 3; // boolean break; case ($type == 'file'): $r = 4; // file break; default: $r = 0; // number } } return $r; }
php
private function getTypeFamily($type) { if (is_array($type)) { $r=[]; foreach($type as $key=>$t) { $r[$key]=$this->getTypeFamily($t); } } else { switch (1 == 1) { case (strpos($this->STRARR, $type) !== false): $r = 1; // string break; case (strpos($this->DATARR, $type) !== false): $r = 2; // date break; case ($type == 'boolean'): $r = 3; // boolean break; case ($type == 'file'): $r = 4; // file break; default: $r = 0; // number } } return $r; }
[ "private", "function", "getTypeFamily", "(", "$", "type", ")", "{", "if", "(", "is_array", "(", "$", "type", ")", ")", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "type", "as", "$", "key", "=>", "$", "t", ")", "{", "$", "r", "[", ...
It returns the number of the family. @param string|array $type=['integer','unixtime','boolean','decimal','float','varchar','string','date','datetime','file'][$i] @return int|int[] 1=string,2=date,3=boolean,4=file,0=number
[ "It", "returns", "the", "number", "of", "the", "family", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L389-L414
train
EFTEC/ValidationOne
lib/ValidationOne.php
ValidationOne.getMessage
public function getMessage($withWarning=false) { if ($withWarning) return $this->messageList->firstErrorOrWarning(); return $this->messageList->firstErrorText(); }
php
public function getMessage($withWarning=false) { if ($withWarning) return $this->messageList->firstErrorOrWarning(); return $this->messageList->firstErrorText(); }
[ "public", "function", "getMessage", "(", "$", "withWarning", "=", "false", ")", "{", "if", "(", "$", "withWarning", ")", "return", "$", "this", "->", "messageList", "->", "firstErrorOrWarning", "(", ")", ";", "return", "$", "this", "->", "messageList", "->...
It gets the first error message available in the whole messagelist. @param bool $withWarning @return null|string
[ "It", "gets", "the", "first", "error", "message", "available", "in", "the", "whole", "messagelist", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L1261-L1264
train
EFTEC/ValidationOne
lib/ValidationOne.php
ValidationOne.getMessages
public function getMessages($withWarning=false) { if ($withWarning) $this->messageList->allErrorOrWarningArray(); return $this->messageList->allErrorArray(); }
php
public function getMessages($withWarning=false) { if ($withWarning) $this->messageList->allErrorOrWarningArray(); return $this->messageList->allErrorArray(); }
[ "public", "function", "getMessages", "(", "$", "withWarning", "=", "false", ")", "{", "if", "(", "$", "withWarning", ")", "$", "this", "->", "messageList", "->", "allErrorOrWarningArray", "(", ")", ";", "return", "$", "this", "->", "messageList", "->", "al...
It returns an array with all the errors of all "ids" @param bool $withWarning @return array
[ "It", "returns", "an", "array", "with", "all", "the", "errors", "of", "all", "ids" ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationOne.php#L1271-L1274
train
devgeniem/wp-sanitize-accented-uploads
wp-cli-integration.php
Sanitize_Command.all
public function all($args, $assoc_args) { $result = self::replace_content($args,$assoc_args); if ( isset($assoc_args['dry-run']) ) WP_CLI::success("Found {$result['replaced_count']} from {$result['considered_count']} attachments to replace."); else WP_CLI::success("Replaced {$result['replaced_count']} from {$result['considered_count']} attachments."); }
php
public function all($args, $assoc_args) { $result = self::replace_content($args,$assoc_args); if ( isset($assoc_args['dry-run']) ) WP_CLI::success("Found {$result['replaced_count']} from {$result['considered_count']} attachments to replace."); else WP_CLI::success("Replaced {$result['replaced_count']} from {$result['considered_count']} attachments."); }
[ "public", "function", "all", "(", "$", "args", ",", "$", "assoc_args", ")", "{", "$", "result", "=", "self", "::", "replace_content", "(", "$", "args", ",", "$", "assoc_args", ")", ";", "if", "(", "isset", "(", "$", "assoc_args", "[", "'dry-run'", "]...
Makes all currently uploaded filenames and urls sanitized. Also replaces corresponding files from wp_posts and wp_postmeta // OPTIONS [--dry-run] : Only prints the changes without replacing. [--verbose] : More output from replacing. [--without-sanitize] : This doesn't make files to lower case and doesn't strip special chars [--network] : More output from replacing. // EXAMPLES wp sanitize all wp sanitize all --dry-run @synopsis [--dry-run] [--without-sanitize] [--verbose] [--network]
[ "Makes", "all", "currently", "uploaded", "filenames", "and", "urls", "sanitized", ".", "Also", "replaces", "corresponding", "files", "from", "wp_posts", "and", "wp_postmeta" ]
58c4f7a1adb568a37f98834c3eacb6d2c73b275e
https://github.com/devgeniem/wp-sanitize-accented-uploads/blob/58c4f7a1adb568a37f98834c3eacb6d2c73b275e/wp-cli-integration.php#L48-L56
train
EFTEC/ValidationOne
lib/ValidationInputOne.php
ValidationInputOne.addMessageInternal
private function addMessageInternal($msg, $msg2, $fieldId, $value, $vcomp, $level='error') { $txt=($msg)?$msg:$msg2; if (is_array($vcomp)) { $first=@$vcomp[0]; $second=@$vcomp[1]; $vcomp=@$vcomp[0]; // is not array anymore } else { $first=$vcomp; $second=$vcomp; } if (is_array($this->originalValue)) { $txt=str_replace(['%field','%realfield','%value','%comp','%first','%second'] ,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId ,$value,$vcomp,$first,$second],$txt); } else { $txt=str_replace(['%field','%realfield','%value','%comp','%first','%second'] ,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId ,$this->originalValue,$vcomp,$first,$second],$txt); } $this->messageList->addItem($fieldId,$txt, $level); }
php
private function addMessageInternal($msg, $msg2, $fieldId, $value, $vcomp, $level='error') { $txt=($msg)?$msg:$msg2; if (is_array($vcomp)) { $first=@$vcomp[0]; $second=@$vcomp[1]; $vcomp=@$vcomp[0]; // is not array anymore } else { $first=$vcomp; $second=$vcomp; } if (is_array($this->originalValue)) { $txt=str_replace(['%field','%realfield','%value','%comp','%first','%second'] ,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId ,$value,$vcomp,$first,$second],$txt); } else { $txt=str_replace(['%field','%realfield','%value','%comp','%first','%second'] ,[($this->friendId===null)?$fieldId:$this->friendId,$fieldId ,$this->originalValue,$vcomp,$first,$second],$txt); } $this->messageList->addItem($fieldId,$txt, $level); }
[ "private", "function", "addMessageInternal", "(", "$", "msg", ",", "$", "msg2", ",", "$", "fieldId", ",", "$", "value", ",", "$", "vcomp", ",", "$", "level", "=", "'error'", ")", "{", "$", "txt", "=", "(", "$", "msg", ")", "?", "$", "msg", ":", ...
It adds an error @param string $msg first message. If it's empty or null then it uses the second message<br> Message could uses the next variables '%field','%realfield','%value','%comp','%first','%second' @param string $msg2 second message @param string $fieldId id of the field @param mixed $value value supplied @param mixed $vcomp value to compare. @param string $level (error,warning,info,success) error level
[ "It", "adds", "an", "error" ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationInputOne.php#L172-L192
train
EFTEC/ValidationOne
lib/ValidationInputOne.php
ValidationInputOne.sanitizeFileName
public static function sanitizeFileName($filename) { if (empty($filename)) return ""; if (function_exists("mb_ereg_replace")) { $filename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename); $filename = mb_ereg_replace("([\.]{2,})", '', $filename); } else { $filename = preg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename); $filename = preg_replace("([\.]{2,})", '', $filename); } return $filename; }
php
public static function sanitizeFileName($filename) { if (empty($filename)) return ""; if (function_exists("mb_ereg_replace")) { $filename = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename); $filename = mb_ereg_replace("([\.]{2,})", '', $filename); } else { $filename = preg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $filename); $filename = preg_replace("([\.]{2,})", '', $filename); } return $filename; }
[ "public", "static", "function", "sanitizeFileName", "(", "$", "filename", ")", "{", "if", "(", "empty", "(", "$", "filename", ")", ")", "return", "\"\"", ";", "if", "(", "function_exists", "(", "\"mb_ereg_replace\"", ")", ")", "{", "$", "filename", "=", ...
Sanitize a filename removing .. and other nasty characters. if mb_string is available then it also allows multibyte string characters such as accents. @param string $filename @return false|string|null
[ "Sanitize", "a", "filename", "removing", "..", "and", "other", "nasty", "characters", ".", "if", "mb_string", "is", "available", "then", "it", "also", "allows", "multibyte", "string", "characters", "such", "as", "accents", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/ValidationInputOne.php#L200-L210
train
glensc/slack-unfurl
src/Command/LinkShared.php
LinkShared.execute
public function execute(array $data): JsonResponse { $this->debug('link_shared', ['event' => $data]); /** @var UnfurlEvent $event */ $event = $this->dispatcher->dispatch(Events::SLACK_UNFURL, new UnfurlEvent($data)); $unfurls = $event->getUnfurls(); $this->debug('unfurls', ['channel' => $data['channel'], 'ts' => $data['message_ts'], 'unfurls' => $unfurls]); if ($unfurls) { $this->slackClient->unfurl($data['channel'], $data['message_ts'], $unfurls); } return new JsonResponse([]); }
php
public function execute(array $data): JsonResponse { $this->debug('link_shared', ['event' => $data]); /** @var UnfurlEvent $event */ $event = $this->dispatcher->dispatch(Events::SLACK_UNFURL, new UnfurlEvent($data)); $unfurls = $event->getUnfurls(); $this->debug('unfurls', ['channel' => $data['channel'], 'ts' => $data['message_ts'], 'unfurls' => $unfurls]); if ($unfurls) { $this->slackClient->unfurl($data['channel'], $data['message_ts'], $unfurls); } return new JsonResponse([]); }
[ "public", "function", "execute", "(", "array", "$", "data", ")", ":", "JsonResponse", "{", "$", "this", "->", "debug", "(", "'link_shared'", ",", "[", "'event'", "=>", "$", "data", "]", ")", ";", "/** @var UnfurlEvent $event */", "$", "event", "=", "$", ...
Handle Link Shared event @param array $data @return JsonResponse @see https://api.slack.com/events/link_shared
[ "Handle", "Link", "Shared", "event" ]
5dabe632a728b40f1391479f6c32f93f7b4db860
https://github.com/glensc/slack-unfurl/blob/5dabe632a728b40f1391479f6c32f93f7b4db860/src/Command/LinkShared.php#L38-L52
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.allErrorArray
public function allErrorArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); } return $r; }
php
public function allErrorArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); } return $r; }
[ "public", "function", "allErrorArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allError", "("...
It returns an array with all messages of error of all containers. @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "error", "of", "all", "containers", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L167-L173
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.allInfoArray
public function allInfoArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allInfo()); } return $r; }
php
public function allInfoArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allInfo()); } return $r; }
[ "public", "function", "allInfoArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allInfo", "(", ...
It returns an array with all messages of info of all containers. @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "info", "of", "all", "containers", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L178-L184
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.allWarningArray
public function allWarningArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allWarning()); } return $r; }
php
public function allWarningArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allWarning()); } return $r; }
[ "public", "function", "allWarningArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allWarning", ...
It returns an array with all messages of warning of all containers. @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "warning", "of", "all", "containers", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L189-L195
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.AllSuccessArray
public function AllSuccessArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allSuccess()); } return $r; }
php
public function AllSuccessArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allSuccess()); } return $r; }
[ "public", "function", "AllSuccessArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allSuccess", ...
It returns an array with all messages of success of all containers. @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "success", "of", "all", "containers", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L200-L206
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.allArray
public function allArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); $r=array_merge($r,$v->allWarning()); $r=array_merge($r,$v->allInfo()); $r=array_merge($r,$v->allSuccess()); } return $r; }
php
public function allArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); $r=array_merge($r,$v->allWarning()); $r=array_merge($r,$v->allInfo()); $r=array_merge($r,$v->allSuccess()); } return $r; }
[ "public", "function", "allArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allError", "(", "...
It returns an array with all messages of any type of all containers @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "any", "type", "of", "all", "containers" ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L211-L220
train
EFTEC/ValidationOne
lib/MessageList.php
MessageList.allErrorOrWarningArray
public function allErrorOrWarningArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); $r=array_merge($r,$v->allWarning()); } return $r; }
php
public function allErrorOrWarningArray() { $r=array(); foreach($this->items as $v) { $r=array_merge($r,$v->allError()); $r=array_merge($r,$v->allWarning()); } return $r; }
[ "public", "function", "allErrorOrWarningArray", "(", ")", "{", "$", "r", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "v", ")", "{", "$", "r", "=", "array_merge", "(", "$", "r", ",", "$", "v", "->", "allErro...
It returns an array with all messages of errors and warnings of all containers. @return string[] empty if there is none
[ "It", "returns", "an", "array", "with", "all", "messages", "of", "errors", "and", "warnings", "of", "all", "containers", "." ]
420f335cdf355d520026e5f380f7a7e4d23412a2
https://github.com/EFTEC/ValidationOne/blob/420f335cdf355d520026e5f380f7a7e4d23412a2/lib/MessageList.php#L225-L232
train
monkeysuffrage/phpuri
phpuri.php
phpUri.parse
public static function parse( $url ) { $uri = new phpUri( $url ); /** * CHANGE: * @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de> * @since 24 Mai 2015 10:25 Uhr * The base-url should always have a path */ if ( empty( $uri->path ) ) { $uri->path = '/'; } return $uri; }
php
public static function parse( $url ) { $uri = new phpUri( $url ); /** * CHANGE: * @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de> * @since 24 Mai 2015 10:25 Uhr * The base-url should always have a path */ if ( empty( $uri->path ) ) { $uri->path = '/'; } return $uri; }
[ "public", "static", "function", "parse", "(", "$", "url", ")", "{", "$", "uri", "=", "new", "phpUri", "(", "$", "url", ")", ";", "/**\r\n\t\t\t * CHANGE:\r\n\t\t\t * @author Dominik Habichtsberg <Dominik.Habichtsberg@Hbg-IT.de>\r\n\t\t\t * @since 24 Mai 2015 10:25 Uhr\r\n\t\t\...
Parse an url string @param string $url the url to parse @return phpUri
[ "Parse", "an", "url", "string" ]
39da58b0a233d6c430f257d78da48e7ed339711d
https://github.com/monkeysuffrage/phpuri/blob/39da58b0a233d6c430f257d78da48e7ed339711d/phpuri.php#L133-L149
train
monkeysuffrage/phpuri
phpuri.php
phpUri.join
public function join( $relative ) { $uri = new phpUri( $relative ); switch ( TRUE ) { case !empty( $uri->scheme ): break; case !empty( $uri->authority ): break; case empty( $uri->path ): $uri->path = $this->path; if ( empty( $uri->query ) ) { $uri->query = $this->query; } break; case strpos( $uri->path, '/' ) === 0: break; default: $base_path = $this->path; if ( strpos( $base_path, '/' ) === FALSE ) { $base_path = ''; } else { $base_path = preg_replace( '/\/[^\/]+$/', '/', $base_path ); } if ( empty( $base_path ) && empty( $this->authority ) ) { $base_path = '/'; } $uri->path = $base_path . $uri->path; } if ( empty( $uri->scheme ) ) { $uri->scheme = $this->scheme; if ( empty( $uri->authority ) ) { $uri->authority = $this->authority; } } return $uri->to_str(); }
php
public function join( $relative ) { $uri = new phpUri( $relative ); switch ( TRUE ) { case !empty( $uri->scheme ): break; case !empty( $uri->authority ): break; case empty( $uri->path ): $uri->path = $this->path; if ( empty( $uri->query ) ) { $uri->query = $this->query; } break; case strpos( $uri->path, '/' ) === 0: break; default: $base_path = $this->path; if ( strpos( $base_path, '/' ) === FALSE ) { $base_path = ''; } else { $base_path = preg_replace( '/\/[^\/]+$/', '/', $base_path ); } if ( empty( $base_path ) && empty( $this->authority ) ) { $base_path = '/'; } $uri->path = $base_path . $uri->path; } if ( empty( $uri->scheme ) ) { $uri->scheme = $this->scheme; if ( empty( $uri->authority ) ) { $uri->authority = $this->authority; } } return $uri->to_str(); }
[ "public", "function", "join", "(", "$", "relative", ")", "{", "$", "uri", "=", "new", "phpUri", "(", "$", "relative", ")", ";", "switch", "(", "TRUE", ")", "{", "case", "!", "empty", "(", "$", "uri", "->", "scheme", ")", ":", "break", ";", "case"...
Join with a relative url @param string $relative the relative url to join @return string
[ "Join", "with", "a", "relative", "url" ]
39da58b0a233d6c430f257d78da48e7ed339711d
https://github.com/monkeysuffrage/phpuri/blob/39da58b0a233d6c430f257d78da48e7ed339711d/phpuri.php#L158-L207
train
ramsey/uuid-console
src/Command/GenerateCommand.php
GenerateCommand.validateNamespace
protected function validateNamespace($namespace) { switch ($namespace) { case 'ns:DNS': return Uuid::NAMESPACE_DNS; break; case 'ns:URL': return Uuid::NAMESPACE_URL; break; case 'ns:OID': return Uuid::NAMESPACE_OID; break; case 'ns:X500': return Uuid::NAMESPACE_X500; break; } if (Uuid::isValid($namespace)) { return $namespace; } throw new Exception( 'Invalid namespace. ' . 'May be either a UUID in string representation or an identifier ' . 'for internally pre-defined namespace UUIDs (currently known ' . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").' ); }
php
protected function validateNamespace($namespace) { switch ($namespace) { case 'ns:DNS': return Uuid::NAMESPACE_DNS; break; case 'ns:URL': return Uuid::NAMESPACE_URL; break; case 'ns:OID': return Uuid::NAMESPACE_OID; break; case 'ns:X500': return Uuid::NAMESPACE_X500; break; } if (Uuid::isValid($namespace)) { return $namespace; } throw new Exception( 'Invalid namespace. ' . 'May be either a UUID in string representation or an identifier ' . 'for internally pre-defined namespace UUIDs (currently known ' . 'are "ns:DNS", "ns:URL", "ns:OID", and "ns:X500").' ); }
[ "protected", "function", "validateNamespace", "(", "$", "namespace", ")", "{", "switch", "(", "$", "namespace", ")", "{", "case", "'ns:DNS'", ":", "return", "Uuid", "::", "NAMESPACE_DNS", ";", "break", ";", "case", "'ns:URL'", ":", "return", "Uuid", "::", ...
Validates the namespace argument @param string $namespace @return string The namespace, if valid @throws Exception
[ "Validates", "the", "namespace", "argument" ]
80594b4c02b8083c28236f2c906aac69094a6e9f
https://github.com/ramsey/uuid-console/blob/80594b4c02b8083c28236f2c906aac69094a6e9f/src/Command/GenerateCommand.php#L171-L198
train
laravie/authen
src/AuthenUser.php
AuthenUser.scopeFindByIdentifiers
public function scopeFindByIdentifiers(Builder $query, $username): Builder { $identifiers = $this->getAuthIdentifiersName(); $query->where(function ($query) use ($identifiers, $username) { foreach ($identifiers as $key) { $query->orWhere($key, '=', $username); } }); return $query; }
php
public function scopeFindByIdentifiers(Builder $query, $username): Builder { $identifiers = $this->getAuthIdentifiersName(); $query->where(function ($query) use ($identifiers, $username) { foreach ($identifiers as $key) { $query->orWhere($key, '=', $username); } }); return $query; }
[ "public", "function", "scopeFindByIdentifiers", "(", "Builder", "$", "query", ",", "$", "username", ")", ":", "Builder", "{", "$", "identifiers", "=", "$", "this", "->", "getAuthIdentifiersName", "(", ")", ";", "$", "query", "->", "where", "(", "function", ...
Find by identifiers scope. @param \Illuminate\Database\Eloquent\Builder $query @param string|int $username @return \Illuminate\Database\Eloquent\Builder
[ "Find", "by", "identifiers", "scope", "." ]
96141e5ede07a478ce36c453ad555d246d032971
https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/AuthenUser.php#L17-L28
train
ramsey/uuid-console
src/Util/UuidFormatter.php
UuidFormatter.getContent
public function getContent(UuidInterface $uuid) { $formatter = self::$formatters[$uuid->getVersion()]; return $formatter->getContent($uuid); }
php
public function getContent(UuidInterface $uuid) { $formatter = self::$formatters[$uuid->getVersion()]; return $formatter->getContent($uuid); }
[ "public", "function", "getContent", "(", "UuidInterface", "$", "uuid", ")", "{", "$", "formatter", "=", "self", "::", "$", "formatters", "[", "$", "uuid", "->", "getVersion", "(", ")", "]", ";", "return", "$", "formatter", "->", "getContent", "(", "$", ...
Returns content as an array of rows, each row being an array containing column values.
[ "Returns", "content", "as", "an", "array", "of", "rows", "each", "row", "being", "an", "array", "containing", "column", "values", "." ]
80594b4c02b8083c28236f2c906aac69094a6e9f
https://github.com/ramsey/uuid-console/blob/80594b4c02b8083c28236f2c906aac69094a6e9f/src/Util/UuidFormatter.php#L92-L97
train
laravie/authen
src/Authen.php
Authen.setIdentifierName
public static function setIdentifierName(string $identifier): void { if (empty($identifier)) { throw new InvalidArgumentException("Identifier shouldn't be empty."); } elseif (\in_array($identifier, ['password'])) { throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!"); } static::$identifier = $identifier; }
php
public static function setIdentifierName(string $identifier): void { if (empty($identifier)) { throw new InvalidArgumentException("Identifier shouldn't be empty."); } elseif (\in_array($identifier, ['password'])) { throw new InvalidArgumentException("Identifier [{$identifier}] is not allowed!"); } static::$identifier = $identifier; }
[ "public", "static", "function", "setIdentifierName", "(", "string", "$", "identifier", ")", ":", "void", "{", "if", "(", "empty", "(", "$", "identifier", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Identifier shouldn't be empty.\"", ")", "...
Set identifier name. @param string $identifier @throws \InvalidArgumentException
[ "Set", "identifier", "name", "." ]
96141e5ede07a478ce36c453ad555d246d032971
https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/Authen.php#L33-L42
train
laravie/authen
src/BootAuthenProvider.php
BootAuthenProvider.bootAuthenProvider
protected function bootAuthenProvider(): void { Auth::provider('authen', function ($app, array $config) { return new AuthenUserProvider($app->make('hash'), $config['model']); }); }
php
protected function bootAuthenProvider(): void { Auth::provider('authen', function ($app, array $config) { return new AuthenUserProvider($app->make('hash'), $config['model']); }); }
[ "protected", "function", "bootAuthenProvider", "(", ")", ":", "void", "{", "Auth", "::", "provider", "(", "'authen'", ",", "function", "(", "$", "app", ",", "array", "$", "config", ")", "{", "return", "new", "AuthenUserProvider", "(", "$", "app", "->", "...
Register authen user provider. @return void
[ "Register", "authen", "user", "provider", "." ]
96141e5ede07a478ce36c453ad555d246d032971
https://github.com/laravie/authen/blob/96141e5ede07a478ce36c453ad555d246d032971/src/BootAuthenProvider.php#L14-L19
train
GeniusesOfSymfony/PubSubRouterBundle
Matcher/Dumper/PhpMatcherDumper.php
PhpMatcherDumper.generateMatchMethod
private function generateMatchMethod(): string { // Group hosts by same-suffix, re-order when possible $routes = new StaticPrefixCollection(); foreach ($this->getRoutes()->all() as $name => $route) { $routes->addRoute('/(.*)', [$name, $route]); } $routes = $this->getRoutes(); $code = rtrim($this->compileRoutes($routes), "\n"); $code = <<<EOF { $code EOF; return " public function match(string \$channel): array\n".$code."\n throw new ResourceNotFoundException();\n }"; }
php
private function generateMatchMethod(): string { // Group hosts by same-suffix, re-order when possible $routes = new StaticPrefixCollection(); foreach ($this->getRoutes()->all() as $name => $route) { $routes->addRoute('/(.*)', [$name, $route]); } $routes = $this->getRoutes(); $code = rtrim($this->compileRoutes($routes), "\n"); $code = <<<EOF { $code EOF; return " public function match(string \$channel): array\n".$code."\n throw new ResourceNotFoundException();\n }"; }
[ "private", "function", "generateMatchMethod", "(", ")", ":", "string", "{", "// Group hosts by same-suffix, re-order when possible", "$", "routes", "=", "new", "StaticPrefixCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRoutes", "(", ")", "->", ...
Generates the code for the match method implementing MatcherInterface.
[ "Generates", "the", "code", "for", "the", "match", "method", "implementing", "MatcherInterface", "." ]
aad607c7a58131c9c44aefd02fbefefdfbe2dfc6
https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Matcher/Dumper/PhpMatcherDumper.php#L59-L78
train
GeniusesOfSymfony/PubSubRouterBundle
Router/RouteCompiler.php
RouteCompiler.determineStaticPrefix
private static function determineStaticPrefix(Route $route, array $tokens): string { if (!$tokens) { return ''; } if ('text' !== $tokens[0][0]) { return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1]; } $prefix = $tokens[0][1]; if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) { $prefix .= $tokens[1][1]; } return $prefix; }
php
private static function determineStaticPrefix(Route $route, array $tokens): string { if (!$tokens) { return ''; } if ('text' !== $tokens[0][0]) { return ($route->hasDefault($tokens[0][3]) || '/' === $tokens[0][1]) ? '' : $tokens[0][1]; } $prefix = $tokens[0][1]; if (isset($tokens[1][1]) && '/' !== $tokens[1][1] && false === $route->hasDefault($tokens[1][3])) { $prefix .= $tokens[1][1]; } return $prefix; }
[ "private", "static", "function", "determineStaticPrefix", "(", "Route", "$", "route", ",", "array", "$", "tokens", ")", ":", "string", "{", "if", "(", "!", "$", "tokens", ")", "{", "return", "''", ";", "}", "if", "(", "'text'", "!==", "$", "tokens", ...
Determines the longest static prefix possible for a route.
[ "Determines", "the", "longest", "static", "prefix", "possible", "for", "a", "route", "." ]
aad607c7a58131c9c44aefd02fbefefdfbe2dfc6
https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Router/RouteCompiler.php#L228-L245
train
photogabble/php-confusable-homoglyphs
src/Categories.php
Categories.aliasesCategories
public function aliasesCategories(string $chr) : array { $l = 0; $r = count($this->categoriesData['code_points_ranges']); $c = mb_ord($chr, $this->encoding); // Binary Search while ($r >= $l){ $m = floor(($l + $r) / 2); if ($c < $this->categoriesData['code_points_ranges'][$m][0]) { $r = $m - 1; } else if ($c > $this->categoriesData['code_points_ranges'][$m][1]) { $l = $m + 1; } else { return [ $this->categoriesData['iso_15924_aliases'][$this->categoriesData['code_points_ranges'][$m][2]], $this->categoriesData['categories'][$this->categoriesData['code_points_ranges'][$m][3]], ]; } } return ['Unknown', 'Zzzz']; }
php
public function aliasesCategories(string $chr) : array { $l = 0; $r = count($this->categoriesData['code_points_ranges']); $c = mb_ord($chr, $this->encoding); // Binary Search while ($r >= $l){ $m = floor(($l + $r) / 2); if ($c < $this->categoriesData['code_points_ranges'][$m][0]) { $r = $m - 1; } else if ($c > $this->categoriesData['code_points_ranges'][$m][1]) { $l = $m + 1; } else { return [ $this->categoriesData['iso_15924_aliases'][$this->categoriesData['code_points_ranges'][$m][2]], $this->categoriesData['categories'][$this->categoriesData['code_points_ranges'][$m][3]], ]; } } return ['Unknown', 'Zzzz']; }
[ "public", "function", "aliasesCategories", "(", "string", "$", "chr", ")", ":", "array", "{", "$", "l", "=", "0", ";", "$", "r", "=", "count", "(", "$", "this", "->", "categoriesData", "[", "'code_points_ranges'", "]", ")", ";", "$", "c", "=", "mb_or...
Retrieves the script block alias and unicode category for a unicode character. e.g. aliasesCategories('A') -> ['LATIN', 'L'] aliasesCategories('τ') -> ['GREEK', 'L'] aliasesCategories('-') -> ['COMMON', 'Pd'] @param string $chr A unicode character @return array The script block alias and unicode category for a unicode character.
[ "Retrieves", "the", "script", "block", "alias", "and", "unicode", "category", "for", "a", "unicode", "character", "." ]
80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688
https://github.com/photogabble/php-confusable-homoglyphs/blob/80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688/src/Categories.php#L56-L78
train
photogabble/php-confusable-homoglyphs
src/Categories.php
Categories.uniqueAliases
public function uniqueAliases(string $string) : array { $return = []; foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) { $alias = $this->alias($char); if (! in_array($alias, $return)) { array_push($return, $alias); } } return $return; }
php
public function uniqueAliases(string $string) : array { $return = []; foreach (preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY) as $char) { $alias = $this->alias($char); if (! in_array($alias, $return)) { array_push($return, $alias); } } return $return; }
[ "public", "function", "uniqueAliases", "(", "string", "$", "string", ")", ":", "array", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "preg_split", "(", "'//u'", ",", "$", "string", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", "as", "$", ...
Retrieves all unique script block aliases used in a unicode string. e.g. uniqueAliases('ABC') -> ['LATIN'] uniqueAliases('ρAτ-') -> ['GREEK', 'LATIN', 'COMMON'] @param string $string A unicode string @return array A set of the script block aliases used in a unicode string.
[ "Retrieves", "all", "unique", "script", "block", "aliases", "used", "in", "a", "unicode", "string", "." ]
80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688
https://github.com/photogabble/php-confusable-homoglyphs/blob/80201a7e7e5fc02ebbbd6067cb9a53a2fb2e0688/src/Categories.php#L127-L137
train
GeniusesOfSymfony/PubSubRouterBundle
Matcher/Matcher.php
Matcher.mergeDefaults
protected function mergeDefaults(array $params, array $defaults): array { foreach ($params as $key => $value) { if (!\is_int($key) && null !== $value) { $defaults[$key] = $value; } } return $defaults; }
php
protected function mergeDefaults(array $params, array $defaults): array { foreach ($params as $key => $value) { if (!\is_int($key) && null !== $value) { $defaults[$key] = $value; } } return $defaults; }
[ "protected", "function", "mergeDefaults", "(", "array", "$", "params", ",", "array", "$", "defaults", ")", ":", "array", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "\\", "is_int", "(", "$", "...
Get merged default parameters. @param array $params @param array $defaults @return array
[ "Get", "merged", "default", "parameters", "." ]
aad607c7a58131c9c44aefd02fbefefdfbe2dfc6
https://github.com/GeniusesOfSymfony/PubSubRouterBundle/blob/aad607c7a58131c9c44aefd02fbefefdfbe2dfc6/Matcher/Matcher.php#L95-L104
train
tienvx/mbt-bundle
src/PathReducer/PathReducerManager.php
PathReducerManager.getPathReducer
public function getPathReducer($name): PathReducerInterface { if (isset($this->pathReducers[$name])) { return $this->pathReducers[$name]; } throw new Exception(sprintf('Path reducer %s does not exist.', $name)); }
php
public function getPathReducer($name): PathReducerInterface { if (isset($this->pathReducers[$name])) { return $this->pathReducers[$name]; } throw new Exception(sprintf('Path reducer %s does not exist.', $name)); }
[ "public", "function", "getPathReducer", "(", "$", "name", ")", ":", "PathReducerInterface", "{", "if", "(", "isset", "(", "$", "this", "->", "pathReducers", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "pathReducers", "[", "$", "n...
Returns one path reducer by name. @param $name @return PathReducerInterface @throws Exception
[ "Returns", "one", "path", "reducer", "by", "name", "." ]
45299305732a77a5e4c077b4a33c5fbb64c596ca
https://github.com/tienvx/mbt-bundle/blob/45299305732a77a5e4c077b4a33c5fbb64c596ca/src/PathReducer/PathReducerManager.php#L28-L35
train
tienvx/mbt-bundle
src/Generator/GeneratorManager.php
GeneratorManager.getGenerator
public function getGenerator($name): GeneratorInterface { if (isset($this->generators[$name])) { return $this->generators[$name]; } throw new Exception(sprintf('Generator %s does not exist.', $name)); }
php
public function getGenerator($name): GeneratorInterface { if (isset($this->generators[$name])) { return $this->generators[$name]; } throw new Exception(sprintf('Generator %s does not exist.', $name)); }
[ "public", "function", "getGenerator", "(", "$", "name", ")", ":", "GeneratorInterface", "{", "if", "(", "isset", "(", "$", "this", "->", "generators", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "generators", "[", "$", "name", ...
Returns one generator by name. @param $name @return GeneratorInterface @throws Exception
[ "Returns", "one", "generator", "by", "name", "." ]
45299305732a77a5e4c077b4a33c5fbb64c596ca
https://github.com/tienvx/mbt-bundle/blob/45299305732a77a5e4c077b4a33c5fbb64c596ca/src/Generator/GeneratorManager.php#L28-L35
train
maiorano84/shortcodes
src/Contracts/Traits/ContainerAware.php
ContainerAware.hasShortcode
public function hasShortcode(string $content): bool { if (!($this->isBound())) { throw RegisterException::missing($this->name); } return $this->manager->hasShortcode($content, $this->getContext()); }
php
public function hasShortcode(string $content): bool { if (!($this->isBound())) { throw RegisterException::missing($this->name); } return $this->manager->hasShortcode($content, $this->getContext()); }
[ "public", "function", "hasShortcode", "(", "string", "$", "content", ")", ":", "bool", "{", "if", "(", "!", "(", "$", "this", "->", "isBound", "(", ")", ")", ")", "{", "throw", "RegisterException", "::", "missing", "(", "$", "this", "->", "name", ")"...
Convenience method Utilizes manager's implementation of hasShortcode Limits search to this shortcode's context. @param string $content @throws RegisterException @return bool
[ "Convenience", "method", "Utilizes", "manager", "s", "implementation", "of", "hasShortcode", "Limits", "search", "to", "this", "shortcode", "s", "context", "." ]
806d3e21fcba9def8aa25d8b370bcd7de446cd0a
https://github.com/maiorano84/shortcodes/blob/806d3e21fcba9def8aa25d8b370bcd7de446cd0a/src/Contracts/Traits/ContainerAware.php#L50-L57
train
maiorano84/shortcodes
src/Contracts/Traits/ContainerAware.php
ContainerAware.doShortcode
public function doShortcode(string $content, bool $deep = false): string { if (!($this->isBound())) { throw RegisterException::missing($this->name); } return $this->manager->doShortcode($content, $this->getContext(), $deep); }
php
public function doShortcode(string $content, bool $deep = false): string { if (!($this->isBound())) { throw RegisterException::missing($this->name); } return $this->manager->doShortcode($content, $this->getContext(), $deep); }
[ "public", "function", "doShortcode", "(", "string", "$", "content", ",", "bool", "$", "deep", "=", "false", ")", ":", "string", "{", "if", "(", "!", "(", "$", "this", "->", "isBound", "(", ")", ")", ")", "{", "throw", "RegisterException", "::", "miss...
Convenience method Utilizes manager's implementation of doShortcode Limits search to this shortcode's context. @param string $content @param bool $deep @throws RegisterException @return string
[ "Convenience", "method", "Utilizes", "manager", "s", "implementation", "of", "doShortcode", "Limits", "search", "to", "this", "shortcode", "s", "context", "." ]
806d3e21fcba9def8aa25d8b370bcd7de446cd0a
https://github.com/maiorano84/shortcodes/blob/806d3e21fcba9def8aa25d8b370bcd7de446cd0a/src/Contracts/Traits/ContainerAware.php#L71-L78
train
maiorano84/shortcodes
src/Contracts/Traits/ContainerAware.php
ContainerAware.getContext
private function getContext(): array { $context = [$this->name]; if ($this instanceof AliasInterface) { $context = array_unique(array_merge($context, $this->getAlias())); } return $context; }
php
private function getContext(): array { $context = [$this->name]; if ($this instanceof AliasInterface) { $context = array_unique(array_merge($context, $this->getAlias())); } return $context; }
[ "private", "function", "getContext", "(", ")", ":", "array", "{", "$", "context", "=", "[", "$", "this", "->", "name", "]", ";", "if", "(", "$", "this", "instanceof", "AliasInterface", ")", "{", "$", "context", "=", "array_unique", "(", "array_merge", ...
Utility method. @return array
[ "Utility", "method", "." ]
806d3e21fcba9def8aa25d8b370bcd7de446cd0a
https://github.com/maiorano84/shortcodes/blob/806d3e21fcba9def8aa25d8b370bcd7de446cd0a/src/Contracts/Traits/ContainerAware.php#L93-L101
train
gigablah/silex-oauth
src/EventListener/UserProviderListener.php
UserProviderListener.onGetUser
public function onGetUser(GetUserForTokenEvent $event) { $userProvider = $event->getUserProvider(); if (!$userProvider instanceof OAuthUserProviderInterface) { return; } $token = $event->getToken(); if ($user = $userProvider->loadUserByOAuthCredentials($token)) { $token->setUser($user); } }
php
public function onGetUser(GetUserForTokenEvent $event) { $userProvider = $event->getUserProvider(); if (!$userProvider instanceof OAuthUserProviderInterface) { return; } $token = $event->getToken(); if ($user = $userProvider->loadUserByOAuthCredentials($token)) { $token->setUser($user); } }
[ "public", "function", "onGetUser", "(", "GetUserForTokenEvent", "$", "event", ")", "{", "$", "userProvider", "=", "$", "event", "->", "getUserProvider", "(", ")", ";", "if", "(", "!", "$", "userProvider", "instanceof", "OAuthUserProviderInterface", ")", "{", "...
Populate the security token with a user from the local database. @param GetUserForTokenEvent $event
[ "Populate", "the", "security", "token", "with", "a", "user", "from", "the", "local", "database", "." ]
29beb1ed60110cd6838b606277037d53980ba25e
https://github.com/gigablah/silex-oauth/blob/29beb1ed60110cd6838b606277037d53980ba25e/src/EventListener/UserProviderListener.php#L22-L35
train
gigablah/silex-oauth
src/OAuthServiceRegistry.php
OAuthServiceRegistry.getService
public function getService($service) { $service = $this->mapServiceName($service); if (isset($this->services[$service])) { return $this->services[$service]; } return $this->services[$service] = $this->createService($service); }
php
public function getService($service) { $service = $this->mapServiceName($service); if (isset($this->services[$service])) { return $this->services[$service]; } return $this->services[$service] = $this->createService($service); }
[ "public", "function", "getService", "(", "$", "service", ")", "{", "$", "service", "=", "$", "this", "->", "mapServiceName", "(", "$", "service", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "services", "[", "$", "service", "]", ")", ")", ...
Retrieve a service by name. @param string $service @return ServiceInterface
[ "Retrieve", "a", "service", "by", "name", "." ]
29beb1ed60110cd6838b606277037d53980ba25e
https://github.com/gigablah/silex-oauth/blob/29beb1ed60110cd6838b606277037d53980ba25e/src/OAuthServiceRegistry.php#L55-L64
train
gigablah/silex-oauth
src/OAuthServiceRegistry.php
OAuthServiceRegistry.getServiceName
public static function getServiceName(ServiceInterface $oauthService) { if ($oauthService instanceof AbstractService) { return $oauthService->service(); } return preg_replace('/^.*\\\\/', '', get_class($oauthService)); }
php
public static function getServiceName(ServiceInterface $oauthService) { if ($oauthService instanceof AbstractService) { return $oauthService->service(); } return preg_replace('/^.*\\\\/', '', get_class($oauthService)); }
[ "public", "static", "function", "getServiceName", "(", "ServiceInterface", "$", "oauthService", ")", "{", "if", "(", "$", "oauthService", "instanceof", "AbstractService", ")", "{", "return", "$", "oauthService", "->", "service", "(", ")", ";", "}", "return", "...
Retrieve the name from a service instance. @param ServiceInterface $oauthService @return string
[ "Retrieve", "the", "name", "from", "a", "service", "instance", "." ]
29beb1ed60110cd6838b606277037d53980ba25e
https://github.com/gigablah/silex-oauth/blob/29beb1ed60110cd6838b606277037d53980ba25e/src/OAuthServiceRegistry.php#L85-L92
train
gigablah/silex-oauth
src/OAuthServiceRegistry.php
OAuthServiceRegistry.createService
protected function createService($service) { if (!isset($this->config[$service])) { throw new \InvalidArgumentException(sprintf('OAuth configuration not defined for the "%s" service.', $service)); } $referenceType = true; $urlGeneratorInterface = 'Symfony\Component\Routing\Generator\UrlGeneratorInterface'; if (defined(sprintf('%s::ABSOLUTE_URL', $urlGeneratorInterface))) { $referenceType = $urlGeneratorInterface::ABSOLUTE_URL; } $credentials = new Credentials( $this->config[$service]['key'], $this->config[$service]['secret'], $this->urlGenerator->generate($this->options['callback_route'], array( 'service' => strtolower($service) ), $referenceType) ); $scope = isset($this->config[$service]['scope']) ? $this->config[$service]['scope'] : array(); $uri = isset($this->config[$service]['uri']) ? new Uri($this->config[$service]['uri']) : null; if (isset($this->config[$service]['class'])) { $this->oauthServiceFactory->registerService($service, $this->config[$service]['class']); unset($this->config[$service]['class']); } return $this->oauthServiceFactory->createService( $service, $credentials, $this->oauthStorage, $scope, $uri ); }
php
protected function createService($service) { if (!isset($this->config[$service])) { throw new \InvalidArgumentException(sprintf('OAuth configuration not defined for the "%s" service.', $service)); } $referenceType = true; $urlGeneratorInterface = 'Symfony\Component\Routing\Generator\UrlGeneratorInterface'; if (defined(sprintf('%s::ABSOLUTE_URL', $urlGeneratorInterface))) { $referenceType = $urlGeneratorInterface::ABSOLUTE_URL; } $credentials = new Credentials( $this->config[$service]['key'], $this->config[$service]['secret'], $this->urlGenerator->generate($this->options['callback_route'], array( 'service' => strtolower($service) ), $referenceType) ); $scope = isset($this->config[$service]['scope']) ? $this->config[$service]['scope'] : array(); $uri = isset($this->config[$service]['uri']) ? new Uri($this->config[$service]['uri']) : null; if (isset($this->config[$service]['class'])) { $this->oauthServiceFactory->registerService($service, $this->config[$service]['class']); unset($this->config[$service]['class']); } return $this->oauthServiceFactory->createService( $service, $credentials, $this->oauthStorage, $scope, $uri ); }
[ "protected", "function", "createService", "(", "$", "service", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "config", "[", "$", "service", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'OAuth co...
Instantiate a service by name. @param string $service @return ServiceInterface
[ "Instantiate", "a", "service", "by", "name", "." ]
29beb1ed60110cd6838b606277037d53980ba25e
https://github.com/gigablah/silex-oauth/blob/29beb1ed60110cd6838b606277037d53980ba25e/src/OAuthServiceRegistry.php#L101-L135
train
gigablah/silex-oauth
src/EventListener/UserInfoListener.php
UserInfoListener.onFilterToken
public function onFilterToken(FilterTokenEvent $event) { $token = $event->getToken(); $service = $token->getService(); $oauthService = $this->registry->getService($service); $config = $this->config[$service]; $serviceName = OAuthServiceRegistry::getServiceName($oauthService); $accessToken = $oauthService->getStorage()->retrieveAccessToken($serviceName); $token->setAccessToken($accessToken); $callback = isset($config['user_callback']) && is_callable($config['user_callback']) ? $config['user_callback'] : array($this, 'defaultUserCallback'); if (isset($config['user_endpoint'])) { $rawUserInfo = json_decode($oauthService->request($config['user_endpoint']), true); } call_user_func($callback, $token, $rawUserInfo, $oauthService); }
php
public function onFilterToken(FilterTokenEvent $event) { $token = $event->getToken(); $service = $token->getService(); $oauthService = $this->registry->getService($service); $config = $this->config[$service]; $serviceName = OAuthServiceRegistry::getServiceName($oauthService); $accessToken = $oauthService->getStorage()->retrieveAccessToken($serviceName); $token->setAccessToken($accessToken); $callback = isset($config['user_callback']) && is_callable($config['user_callback']) ? $config['user_callback'] : array($this, 'defaultUserCallback'); if (isset($config['user_endpoint'])) { $rawUserInfo = json_decode($oauthService->request($config['user_endpoint']), true); } call_user_func($callback, $token, $rawUserInfo, $oauthService); }
[ "public", "function", "onFilterToken", "(", "FilterTokenEvent", "$", "event", ")", "{", "$", "token", "=", "$", "event", "->", "getToken", "(", ")", ";", "$", "service", "=", "$", "token", "->", "getService", "(", ")", ";", "$", "oauthService", "=", "$...
When the security token is created, populate it with user information from the service API. @param FilterTokenEvent $event
[ "When", "the", "security", "token", "is", "created", "populate", "it", "with", "user", "information", "from", "the", "service", "API", "." ]
29beb1ed60110cd6838b606277037d53980ba25e
https://github.com/gigablah/silex-oauth/blob/29beb1ed60110cd6838b606277037d53980ba25e/src/EventListener/UserInfoListener.php#L37-L54
train
imbo/imboclient-php
src/ImboClient/Query.php
Query.page
public function page($page = null) { if ($page === null) { return $this->page; } $this->page = (int) $page; return $this; }
php
public function page($page = null) { if ($page === null) { return $this->page; } $this->page = (int) $page; return $this; }
[ "public", "function", "page", "(", "$", "page", "=", "null", ")", "{", "if", "(", "$", "page", "===", "null", ")", "{", "return", "$", "this", "->", "page", ";", "}", "$", "this", "->", "page", "=", "(", "int", ")", "$", "page", ";", "return", ...
Set or get the page property @param int $page Give this a value to set the page property @return int|self
[ "Set", "or", "get", "the", "page", "property" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Query.php#L40-L48
train
imbo/imboclient-php
src/ImboClient/EventSubscriber/Authenticate.php
Authenticate.signRequest
public function signRequest(Event $event) { $command = $event['command']; switch ($command->getName()) { case 'AddImage': case 'DeleteImage': case 'ReplaceMetadata': case 'EditMetadata': case 'DeleteMetadata': case 'GenerateShortUrl': case 'EditResourceGroup': case 'DeleteResourceGroup': case 'EditPublicKey': case 'DeletePublicKey': case 'AddAccessControlRules': case 'DeleteAccessControlRule': // Add the auth headers $this->addAuthenticationHeaders($command->getRequest()); break; } }
php
public function signRequest(Event $event) { $command = $event['command']; switch ($command->getName()) { case 'AddImage': case 'DeleteImage': case 'ReplaceMetadata': case 'EditMetadata': case 'DeleteMetadata': case 'GenerateShortUrl': case 'EditResourceGroup': case 'DeleteResourceGroup': case 'EditPublicKey': case 'DeletePublicKey': case 'AddAccessControlRules': case 'DeleteAccessControlRule': // Add the auth headers $this->addAuthenticationHeaders($command->getRequest()); break; } }
[ "public", "function", "signRequest", "(", "Event", "$", "event", ")", "{", "$", "command", "=", "$", "event", "[", "'command'", "]", ";", "switch", "(", "$", "command", "->", "getName", "(", ")", ")", "{", "case", "'AddImage'", ":", "case", "'DeleteIma...
Sign the request by adding some special request headers @param Event $event The current event
[ "Sign", "the", "request", "by", "adding", "some", "special", "request", "headers" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/EventSubscriber/Authenticate.php#L42-L62
train
imbo/imboclient-php
src/ImboClient/EventSubscriber/Authenticate.php
Authenticate.addAuthenticationHeaders
private function addAuthenticationHeaders(Request $request) { $client = $request->getClient(); // Get a GMT/UTC timestamp $timestamp = gmdate('Y-m-d\TH:i:s\Z'); // Build the data to base the hash on $data = $request->getMethod() . '|' . $request->getUrl() . '|' . $client->getConfig('publicKey') . '|' . $timestamp; // Generate signature $signature = hash_hmac('sha256', $data, $client->getConfig('privateKey')); // Add relevant request headers (overwriting once that might already exist) $request->setHeader('X-Imbo-Authenticate-Signature', $signature); $request->setHeader('X-Imbo-Authenticate-Timestamp', $timestamp); }
php
private function addAuthenticationHeaders(Request $request) { $client = $request->getClient(); // Get a GMT/UTC timestamp $timestamp = gmdate('Y-m-d\TH:i:s\Z'); // Build the data to base the hash on $data = $request->getMethod() . '|' . $request->getUrl() . '|' . $client->getConfig('publicKey') . '|' . $timestamp; // Generate signature $signature = hash_hmac('sha256', $data, $client->getConfig('privateKey')); // Add relevant request headers (overwriting once that might already exist) $request->setHeader('X-Imbo-Authenticate-Signature', $signature); $request->setHeader('X-Imbo-Authenticate-Timestamp', $timestamp); }
[ "private", "function", "addAuthenticationHeaders", "(", "Request", "$", "request", ")", "{", "$", "client", "=", "$", "request", "->", "getClient", "(", ")", ";", "// Get a GMT/UTC timestamp", "$", "timestamp", "=", "gmdate", "(", "'Y-m-d\\TH:i:s\\Z'", ")", ";",...
Sign the current request for write operations @param Request $request The current request
[ "Sign", "the", "current", "request", "for", "write", "operations" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/EventSubscriber/Authenticate.php#L69-L87
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.blur
public function blur(array $params) { $mode = isset($params['mode']) ? $params['mode'] : null; $required = array('radius', 'sigma'); if ($mode === 'motion') { $required[] = 'angle'; } else if ($mode === 'radial') { $required = array('angle'); } $transformation = $mode ? array('mode=' . $mode) : array(); foreach ($required as $param) { if (!isset($params[$param])) { throw new InvalidArgumentException('`' . $param . '` must be specified'); } $transformation[] = $param . '=' . $params[$param]; } return $this->addTransformation(sprintf('blur:%s', implode(',', $transformation))); }
php
public function blur(array $params) { $mode = isset($params['mode']) ? $params['mode'] : null; $required = array('radius', 'sigma'); if ($mode === 'motion') { $required[] = 'angle'; } else if ($mode === 'radial') { $required = array('angle'); } $transformation = $mode ? array('mode=' . $mode) : array(); foreach ($required as $param) { if (!isset($params[$param])) { throw new InvalidArgumentException('`' . $param . '` must be specified'); } $transformation[] = $param . '=' . $params[$param]; } return $this->addTransformation(sprintf('blur:%s', implode(',', $transformation))); }
[ "public", "function", "blur", "(", "array", "$", "params", ")", "{", "$", "mode", "=", "isset", "(", "$", "params", "[", "'mode'", "]", ")", "?", "$", "params", "[", "'mode'", "]", ":", "null", ";", "$", "required", "=", "array", "(", "'radius'", ...
Add a blur transformation Parameters: `mode` - `gaussian`, `adaptive`, `motion` or `radial`. Default: `guassian` `radius` - Radius of the gaussian, in pixels, not counting the center pixel. Required for `gaussian`, `adaptive` and `motion`-modes `sigma` - The standard deviation of the gaussian, in pixels. Required for `gaussian`, `adaptive` and `motion`-modes `angle` - Angle of the radial blur. Only used in `radial`-mode. @param array $params Array of parameters @return self
[ "Add", "a", "blur", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L112-L133
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.border
public function border($color = '000000', $width = 1, $height = 1, $mode = 'outbound') { return $this->addTransformation( sprintf('border:color=%s,width=%d,height=%d,mode=%s', $color, (int) $width, (int) $height, $mode) ); }
php
public function border($color = '000000', $width = 1, $height = 1, $mode = 'outbound') { return $this->addTransformation( sprintf('border:color=%s,width=%d,height=%d,mode=%s', $color, (int) $width, (int) $height, $mode) ); }
[ "public", "function", "border", "(", "$", "color", "=", "'000000'", ",", "$", "width", "=", "1", ",", "$", "height", "=", "1", ",", "$", "mode", "=", "'outbound'", ")", "{", "return", "$", "this", "->", "addTransformation", "(", "sprintf", "(", "'bor...
Add a border transformation @param string $color Color of the border @param int $width Width of the left and right sides of the border @param int $height Height of the top and bottom sides of the border @param string $mode The mode of the border, "inline" or "outbound" @return self
[ "Add", "a", "border", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L144-L148
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.canvas
public function canvas($width, $height, $mode = null, $x = null, $y = null, $bg = null) { if (!$width || !$height) { throw new InvalidArgumentException('width and height must be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($mode) { $params[] = 'mode=' . $mode; } if ($x) { $params[] = 'x=' . (int) $x; } if ($y) { $params[] = 'y=' . (int) $y; } if ($bg) { $params[] = 'bg=' . $bg; } return $this->addTransformation(sprintf('canvas:%s', implode(',', $params))); }
php
public function canvas($width, $height, $mode = null, $x = null, $y = null, $bg = null) { if (!$width || !$height) { throw new InvalidArgumentException('width and height must be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($mode) { $params[] = 'mode=' . $mode; } if ($x) { $params[] = 'x=' . (int) $x; } if ($y) { $params[] = 'y=' . (int) $y; } if ($bg) { $params[] = 'bg=' . $bg; } return $this->addTransformation(sprintf('canvas:%s', implode(',', $params))); }
[ "public", "function", "canvas", "(", "$", "width", ",", "$", "height", ",", "$", "mode", "=", "null", ",", "$", "x", "=", "null", ",", "$", "y", "=", "null", ",", "$", "bg", "=", "null", ")", "{", "if", "(", "!", "$", "width", "||", "!", "$...
Add a canvas transformation @param int $width Width of the canvas @param int $height Height of the canvas @param string $mode The placement mode, "free", "center", "center-x" or "center-y" @param int $x X coordinate of the placement of the upper left corner of the existing image @param int $y Y coordinate of the placement of the upper left corner of the existing image @param string $bg Background color of the canvas @return self @throws InvalidArgumentException
[ "Add", "a", "canvas", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L162-L189
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.contrast
public function contrast($alpha = null, $beta = null) { $params = array(); if ($alpha !== null) { $params[] = 'alpha=' . (float) $alpha; } if ($beta !== null) { $params[] = 'beta=' . (float) min(1, max(0, $beta)); } return $this->addTransformation( 'contrast' . ($params ? ':' . implode(',', $params) : '') ); }
php
public function contrast($alpha = null, $beta = null) { $params = array(); if ($alpha !== null) { $params[] = 'alpha=' . (float) $alpha; } if ($beta !== null) { $params[] = 'beta=' . (float) min(1, max(0, $beta)); } return $this->addTransformation( 'contrast' . ($params ? ':' . implode(',', $params) : '') ); }
[ "public", "function", "contrast", "(", "$", "alpha", "=", "null", ",", "$", "beta", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "alpha", "!==", "null", ")", "{", "$", "params", "[", "]", "=", "'alpha='", "...
Add a contrast transformation @param float $alpha Adjusts intensity differences between lighter and darker elements @param float $beta Where the midpoint of the gradient will be. Range: 0 to 1 @return self
[ "Add", "a", "contrast", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L208-L222
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.crop
public function crop($x = null, $y = null, $width = null, $height = null, $mode = null) { if ($mode === null && ($x === null || $y === null)) { throw new InvalidArgumentException('x and y needs to be specified without a crop mode'); } if ($mode === 'center-x' && $y === null) { throw new InvalidArgumentException('y needs to be specified when mode is center-x'); } if ($mode === 'center-y' && $x === null) { throw new InvalidArgumentException('x needs to be specified when mode is center-y'); } if ($width === null || $height === null) { throw new InvalidArgumentException('width and height needs to be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($x) { $params[] = 'x=' . (int) $x; } if ($y) { $params[] = 'y=' . (int) $y; } if ($mode) { $params[] = 'mode=' . $mode; } return $this->addTransformation('crop:' . implode(',', $params)); }
php
public function crop($x = null, $y = null, $width = null, $height = null, $mode = null) { if ($mode === null && ($x === null || $y === null)) { throw new InvalidArgumentException('x and y needs to be specified without a crop mode'); } if ($mode === 'center-x' && $y === null) { throw new InvalidArgumentException('y needs to be specified when mode is center-x'); } if ($mode === 'center-y' && $x === null) { throw new InvalidArgumentException('x needs to be specified when mode is center-y'); } if ($width === null || $height === null) { throw new InvalidArgumentException('width and height needs to be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($x) { $params[] = 'x=' . (int) $x; } if ($y) { $params[] = 'y=' . (int) $y; } if ($mode) { $params[] = 'mode=' . $mode; } return $this->addTransformation('crop:' . implode(',', $params)); }
[ "public", "function", "crop", "(", "$", "x", "=", "null", ",", "$", "y", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "mode", "=", "null", ")", "{", "if", "(", "$", "mode", "===", "null", "&&", "(", ...
Add a crop transformation @param int $x X coordinate of the top left corner of the crop @param int $y Y coordinate of the top left corner of the crop @param int $width Width of the crop @param int $height Height of the crop @param string $mode The crop mode. Available in Imbo >= 1.1.0. @return self @throws InvalidArgumentException
[ "Add", "a", "crop", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L265-L300
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.histogram
public function histogram($scale = null, $ratio = null, $red = null, $green = null, $blue = null) { $params = array(); if ($scale) { $params[] = 'scale=' . (int) $scale; } if ($ratio) { $params[] = 'ratio=' . (float) $ratio; } if ($red) { $params[] = 'red=' . $red; } if ($green) { $params[] = 'green=' . $green; } if ($blue) { $params[] = 'blue=' . $blue; } return $this->addTransformation('histogram' . ($params ? ':' . implode(',', $params) : '')); }
php
public function histogram($scale = null, $ratio = null, $red = null, $green = null, $blue = null) { $params = array(); if ($scale) { $params[] = 'scale=' . (int) $scale; } if ($ratio) { $params[] = 'ratio=' . (float) $ratio; } if ($red) { $params[] = 'red=' . $red; } if ($green) { $params[] = 'green=' . $green; } if ($blue) { $params[] = 'blue=' . $blue; } return $this->addTransformation('histogram' . ($params ? ':' . implode(',', $params) : '')); }
[ "public", "function", "histogram", "(", "$", "scale", "=", "null", ",", "$", "ratio", "=", "null", ",", "$", "red", "=", "null", ",", "$", "green", "=", "null", ",", "$", "blue", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";"...
Add a histogram transformation @param int $scale The amount to scale the histogram @param float $ratio The ratio to use when calculating the height of the image @param string $red The color to use when drawing the graph for the red channel @param string $green The color to use when drawing the graph for the green channel @param string $blue The color to use when drawing the graph for the blue channel @return self
[ "Add", "a", "histogram", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L368-L392
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.level
public function level($amount = 1, $channel = null) { $params = array('amount=' . $amount); if ($channel) { $params[] = 'channel=' . $channel; } return $this->addTransformation('level:' . implode(',', $params)); }
php
public function level($amount = 1, $channel = null) { $params = array('amount=' . $amount); if ($channel) { $params[] = 'channel=' . $channel; } return $this->addTransformation('level:' . implode(',', $params)); }
[ "public", "function", "level", "(", "$", "amount", "=", "1", ",", "$", "channel", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'amount='", ".", "$", "amount", ")", ";", "if", "(", "$", "channel", ")", "{", "$", "params", "[", "]", ...
Add a level transformation to the image, adjusting the levels of an image @param int $amount Amount to adjust, on a scale from -100 to 100 @param string $channel Optional channel to adjust. Possible values: r, g, b, c, m, y, k - can be combined to adjust multiple. @return self
[ "Add", "a", "level", "transformation", "to", "the", "image", "adjusting", "the", "levels", "of", "an", "image" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L402-L410
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.maxSize
public function maxSize($maxWidth = null, $maxHeight = null) { $params = array(); if ($maxWidth) { $params[] = 'width=' . (int) $maxWidth; } if ($maxHeight) { $params[] = 'height=' . (int) $maxHeight; } if (!$params) { throw new InvalidArgumentException('width and/or height must be specified'); } return $this->addTransformation(sprintf('maxSize:%s', implode(',', $params))); }
php
public function maxSize($maxWidth = null, $maxHeight = null) { $params = array(); if ($maxWidth) { $params[] = 'width=' . (int) $maxWidth; } if ($maxHeight) { $params[] = 'height=' . (int) $maxHeight; } if (!$params) { throw new InvalidArgumentException('width and/or height must be specified'); } return $this->addTransformation(sprintf('maxSize:%s', implode(',', $params))); }
[ "public", "function", "maxSize", "(", "$", "maxWidth", "=", "null", ",", "$", "maxHeight", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "maxWidth", ")", "{", "$", "params", "[", "]", "=", "'width='", ".", "("...
Add a maxSize transformation @param int $maxWidth Max width of the resized image @param int $maxHeight Max height of the resized image @return self @throws InvalidArgumentException
[ "Add", "a", "maxSize", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L420-L436
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.modulate
public function modulate($brightness = null, $saturation = null, $hue = null) { $params = array(); if ($brightness) { $params[] = 'b=' . (int) $brightness; } if ($saturation) { $params[] = 's=' . (int) $saturation; } if ($hue) { $params[] = 'h=' . (int) $hue; } if (!$params) { throw new InvalidArgumentException('brightness, saturation and/or hue must be specified'); } return $this->addTransformation(sprintf('modulate:%s', implode(',', $params))); }
php
public function modulate($brightness = null, $saturation = null, $hue = null) { $params = array(); if ($brightness) { $params[] = 'b=' . (int) $brightness; } if ($saturation) { $params[] = 's=' . (int) $saturation; } if ($hue) { $params[] = 'h=' . (int) $hue; } if (!$params) { throw new InvalidArgumentException('brightness, saturation and/or hue must be specified'); } return $this->addTransformation(sprintf('modulate:%s', implode(',', $params))); }
[ "public", "function", "modulate", "(", "$", "brightness", "=", "null", ",", "$", "saturation", "=", "null", ",", "$", "hue", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "brightness", ")", "{", "$", "params", ...
Add a modulate transformation @param int $brightness Brightness of the image in percent @param int $saturation Saturation of the image in percent @param int $hue Hue percentage @return self @throws InvalidArgumentException
[ "Add", "a", "modulate", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L447-L467
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.resize
public function resize($width = null, $height = null) { $params = array(); if ($width) { $params[] = 'width=' . (int) $width; } if ($height) { $params[] = 'height=' . (int) $height; } if (!$params) { throw new InvalidArgumentException('width and/or height must be specified'); } return $this->addTransformation(sprintf('resize:%s', implode(',', $params))); }
php
public function resize($width = null, $height = null) { $params = array(); if ($width) { $params[] = 'width=' . (int) $width; } if ($height) { $params[] = 'height=' . (int) $height; } if (!$params) { throw new InvalidArgumentException('width and/or height must be specified'); } return $this->addTransformation(sprintf('resize:%s', implode(',', $params))); }
[ "public", "function", "resize", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "width", ")", "{", "$", "params", "[", "]", "=", "'width='", ".", "(", "int",...
Add a resize transformation @param int $width Width of the resized image @param int $height Height of the resized image @return self @throws InvalidArgumentException
[ "Add", "a", "resize", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L486-L502
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.rotate
public function rotate($angle, $bg = '000000') { if (!$angle) { throw new InvalidArgumentException('angle must be specified'); } return $this->addTransformation(sprintf('rotate:angle=%d,bg=%s', (int) $angle, $bg)); }
php
public function rotate($angle, $bg = '000000') { if (!$angle) { throw new InvalidArgumentException('angle must be specified'); } return $this->addTransformation(sprintf('rotate:angle=%d,bg=%s', (int) $angle, $bg)); }
[ "public", "function", "rotate", "(", "$", "angle", ",", "$", "bg", "=", "'000000'", ")", "{", "if", "(", "!", "$", "angle", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'angle must be specified'", ")", ";", "}", "return", "$", "this", "->"...
Add a rotate transformation @param float $angle The angle to rotate @param string $bg Background color of the rotated image @return self @throws InvalidArgumentException
[ "Add", "a", "rotate", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L512-L518
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.sharpen
public function sharpen(array $params = null) { $options = array('preset', 'radius', 'sigma', 'threshold', 'gain'); $transformation = array(); foreach ($options as $param) { if (!isset($params[$param])) { continue; } $transformation[] = $param . '=' . $params[$param]; } return $this->addTransformation( 'sharpen' . ($transformation ? ':' . implode(',', $transformation) : '') ); }
php
public function sharpen(array $params = null) { $options = array('preset', 'radius', 'sigma', 'threshold', 'gain'); $transformation = array(); foreach ($options as $param) { if (!isset($params[$param])) { continue; } $transformation[] = $param . '=' . $params[$param]; } return $this->addTransformation( 'sharpen' . ($transformation ? ':' . implode(',', $transformation) : '') ); }
[ "public", "function", "sharpen", "(", "array", "$", "params", "=", "null", ")", "{", "$", "options", "=", "array", "(", "'preset'", ",", "'radius'", ",", "'sigma'", ",", "'threshold'", ",", "'gain'", ")", ";", "$", "transformation", "=", "array", "(", ...
Add a sharpen transformation Parameters: `preset` - `light`, `moderate`, `strong`, `extreme`. `radius` - Radius of the gaussian, in pixels `sigma` - Standard deviation of the gaussian, in pixels `threshold` - The threshold in pixels needed to apply the difference gain `gain` - Percentage of difference between original and the blur image that is added back into the original @param array $params Parameters for the transformation @return self
[ "Add", "a", "sharpen", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L544-L559
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.smartSize
public function smartSize($width, $height, $crop = null, $poi = null) { if (!$width || !$height) { throw new InvalidArgumentException('width and height must be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($crop) { $params[] = 'crop=' . $crop; } if ($poi) { $params[] = 'poi=' . $poi; } return $this->addTransformation(sprintf('smartSize:%s', implode(',', $params))); }
php
public function smartSize($width, $height, $crop = null, $poi = null) { if (!$width || !$height) { throw new InvalidArgumentException('width and height must be specified'); } $params = array( 'width=' . (int) $width, 'height=' . (int) $height, ); if ($crop) { $params[] = 'crop=' . $crop; } if ($poi) { $params[] = 'poi=' . $poi; } return $this->addTransformation(sprintf('smartSize:%s', implode(',', $params))); }
[ "public", "function", "smartSize", "(", "$", "width", ",", "$", "height", ",", "$", "crop", "=", "null", ",", "$", "poi", "=", "null", ")", "{", "if", "(", "!", "$", "width", "||", "!", "$", "height", ")", "{", "throw", "new", "InvalidArgumentExcep...
Add a smartSize transformation @param int $width Width of the resized image @param int $height Height of the resized image @param string $crop Closeness of crop (`close`, `medium` or `wide`). Optional. @param string $poi POI-coordinate to crop around (as `x,y`). Optional if POI-metadata exists for the image. @return self
[ "Add", "a", "smartSize", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L571-L590
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.thumbnail
public function thumbnail($width = 50, $height = 50, $fit = 'outbound') { return $this->addTransformation( sprintf('thumbnail:width=%d,height=%s,fit=%s', (int) $width, (int) $height, $fit) ); }
php
public function thumbnail($width = 50, $height = 50, $fit = 'outbound') { return $this->addTransformation( sprintf('thumbnail:width=%d,height=%s,fit=%s', (int) $width, (int) $height, $fit) ); }
[ "public", "function", "thumbnail", "(", "$", "width", "=", "50", ",", "$", "height", "=", "50", ",", "$", "fit", "=", "'outbound'", ")", "{", "return", "$", "this", "->", "addTransformation", "(", "sprintf", "(", "'thumbnail:width=%d,height=%s,fit=%s'", ",",...
Add a thumbnail transformation @param int $width Width of the thumbnail @param int $height Height of the thumbnail @param string $fit Fit type. 'outbound' or 'inset' @return self
[ "Add", "a", "thumbnail", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L609-L613
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.vignette
public function vignette($scale = null, $outerColor = null, $innerColor = null) { $params = array(); if ($scale) { $params[] = 'scale=' . $scale; } if ($outerColor) { $params[] = 'outer=' . $outerColor; } if ($innerColor) { $params[] = 'inner=' . $innerColor; } return $this->addTransformation( 'vignette' . ($params ? ':' . implode(',', $params) : '') ); }
php
public function vignette($scale = null, $outerColor = null, $innerColor = null) { $params = array(); if ($scale) { $params[] = 'scale=' . $scale; } if ($outerColor) { $params[] = 'outer=' . $outerColor; } if ($innerColor) { $params[] = 'inner=' . $innerColor; } return $this->addTransformation( 'vignette' . ($params ? ':' . implode(',', $params) : '') ); }
[ "public", "function", "vignette", "(", "$", "scale", "=", "null", ",", "$", "outerColor", "=", "null", ",", "$", "innerColor", "=", "null", ")", "{", "$", "params", "=", "array", "(", ")", ";", "if", "(", "$", "scale", ")", "{", "$", "params", "[...
Add a vignette transformation @param float $scale Scale factor of vignette. 2 means twice the size of the original image @param string $outerColor Color at the edge of the image @param string $innerColor Color at the center of the image @return self
[ "Add", "a", "vignette", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L641-L659
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.watermark
public function watermark($img = null, $width = null, $height = null, $position = 'top-left', $x = 0, $y = 0) { $params = array( 'position=' . $position, 'x=' . (int) $x, 'y=' . (int) $y, ); if ($img !== null) { $params[] = 'img=' . $img; } if ($width !== null) { $params[] = 'width=' . (int) $width; } if ($height !== null) { $params[] = 'height=' . (int) $height; } return $this->addTransformation(sprintf('watermark:%s', implode(',', $params))); }
php
public function watermark($img = null, $width = null, $height = null, $position = 'top-left', $x = 0, $y = 0) { $params = array( 'position=' . $position, 'x=' . (int) $x, 'y=' . (int) $y, ); if ($img !== null) { $params[] = 'img=' . $img; } if ($width !== null) { $params[] = 'width=' . (int) $width; } if ($height !== null) { $params[] = 'height=' . (int) $height; } return $this->addTransformation(sprintf('watermark:%s', implode(',', $params))); }
[ "public", "function", "watermark", "(", "$", "img", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "position", "=", "'top-left'", ",", "$", "x", "=", "0", ",", "$", "y", "=", "0", ")", "{", "$", "params"...
Add a watermark transformation @param string $img The identifier of the image to be used as a watermark. Can be omitted if the server is configured with a default watermark. @param int $width The width of the watermark @param int $height The height of the watermark @param string $position The position of the watermark on the original image, 'top-left', 'top-right', 'bottom-left', 'bottom-right' or 'center'. Defaults to 'top-left'. @param int $x Offset in the X-axis relative to the $position parameter. Defaults to 0 @param int $y Offset in the Y-axis relative to the $position parameter. Defaults to 0 @return self
[ "Add", "a", "watermark", "transformation" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L675-L695
train
imbo/imboclient-php
src/ImboClient/Http/ImageUrl.php
ImageUrl.reset
public function reset() { if ($this->transformations) { // Remove image transformations $this->transformations = array(); $this->query->remove('t'); } if ($this->extension) { // Remove the extension $this->path = str_replace('.' . $this->extension, '', $this->path); $this->extension = null; } return $this; }
php
public function reset() { if ($this->transformations) { // Remove image transformations $this->transformations = array(); $this->query->remove('t'); } if ($this->extension) { // Remove the extension $this->path = str_replace('.' . $this->extension, '', $this->path); $this->extension = null; } return $this; }
[ "public", "function", "reset", "(", ")", "{", "if", "(", "$", "this", "->", "transformations", ")", "{", "// Remove image transformations", "$", "this", "->", "transformations", "=", "array", "(", ")", ";", "$", "this", "->", "query", "->", "remove", "(", ...
Reset the URL Effectively removes added transformations and an optional extension. @return self
[ "Reset", "the", "URL" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Http/ImageUrl.php#L750-L764
train
imbo/imboclient-php
src/ImboClient/EventSubscriber/PublicKey.php
PublicKey.addPublicKey
public function addPublicKey(Event $event) { $command = $event['command']; $request = $command->getRequest(); $url = $request->getUrl(true); // Don't add public key if query string already contains public key if ($url->getQuery()->hasKey('publicKey')) { return; } $client = $request->getClient(); $publicKey = $client->getPublicKey(); $user = $client->getUser(); // No need for the header if the user and public key matches if ($user && $user === $publicKey) { return; } $request->setHeader('X-Imbo-PublicKey', $publicKey); }
php
public function addPublicKey(Event $event) { $command = $event['command']; $request = $command->getRequest(); $url = $request->getUrl(true); // Don't add public key if query string already contains public key if ($url->getQuery()->hasKey('publicKey')) { return; } $client = $request->getClient(); $publicKey = $client->getPublicKey(); $user = $client->getUser(); // No need for the header if the user and public key matches if ($user && $user === $publicKey) { return; } $request->setHeader('X-Imbo-PublicKey', $publicKey); }
[ "public", "function", "addPublicKey", "(", "Event", "$", "event", ")", "{", "$", "command", "=", "$", "event", "[", "'command'", "]", ";", "$", "request", "=", "$", "command", "->", "getRequest", "(", ")", ";", "$", "url", "=", "$", "request", "->", ...
Add a public key header to the request @param Event $event The current event
[ "Add", "a", "public", "key", "header", "to", "the", "request" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/EventSubscriber/PublicKey.php#L42-L62
train
imbo/imboclient-php
src/ImboClient/Helper/PublicKeyFallback.php
PublicKeyFallback.fallback
public static function fallback($info) { $user = isset($info['user']) ? $info['user'] : null; $publicKey = isset($info['publicKey']) ? $info['publicKey'] : null; if (!$user && $publicKey) { $info['user'] = $publicKey; } else if (!$publicKey && $user) { $info['publicKey'] = $user; } return $info; }
php
public static function fallback($info) { $user = isset($info['user']) ? $info['user'] : null; $publicKey = isset($info['publicKey']) ? $info['publicKey'] : null; if (!$user && $publicKey) { $info['user'] = $publicKey; } else if (!$publicKey && $user) { $info['publicKey'] = $user; } return $info; }
[ "public", "static", "function", "fallback", "(", "$", "info", ")", "{", "$", "user", "=", "isset", "(", "$", "info", "[", "'user'", "]", ")", "?", "$", "info", "[", "'user'", "]", ":", "null", ";", "$", "publicKey", "=", "isset", "(", "$", "info"...
For backwards-compatibility, we provide both `user` and `publicKey`. In future version of ImboClient, the `publicKey` will be removed. @param array $info @return array
[ "For", "backwards", "-", "compatibility", "we", "provide", "both", "user", "and", "publicKey", ".", "In", "future", "version", "of", "ImboClient", "the", "publicKey", "will", "be", "removed", "." ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/Helper/PublicKeyFallback.php#L28-L39
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.addImageFromUrl
public function addImageFromUrl($url) { if (is_string($url)) { // URL specified as a string. Create a URL instance $url = GuzzleUrl::factory($url); } if (!($url instanceof GuzzleUrl)) { // Invalid argument throw new InvalidArgumentException( 'Parameter must be a string or an instance of Guzzle\Http\Url' ); } if (!$url->getScheme()) { throw new InvalidArgumentException('URL is missing scheme: ' . (string) $url); } // Fetch the image we want to add $image = (string) $this->get($url)->send()->getBody(); return $this->addImageFromString($image); }
php
public function addImageFromUrl($url) { if (is_string($url)) { // URL specified as a string. Create a URL instance $url = GuzzleUrl::factory($url); } if (!($url instanceof GuzzleUrl)) { // Invalid argument throw new InvalidArgumentException( 'Parameter must be a string or an instance of Guzzle\Http\Url' ); } if (!$url->getScheme()) { throw new InvalidArgumentException('URL is missing scheme: ' . (string) $url); } // Fetch the image we want to add $image = (string) $this->get($url)->send()->getBody(); return $this->addImageFromString($image); }
[ "public", "function", "addImageFromUrl", "(", "$", "url", ")", "{", "if", "(", "is_string", "(", "$", "url", ")", ")", "{", "// URL specified as a string. Create a URL instance", "$", "url", "=", "GuzzleUrl", "::", "factory", "(", "$", "url", ")", ";", "}", ...
Add an image from a URL @param GuzzleUrl|string $url A URL to an image @return Model @throws InvalidArgumentException
[ "Add", "an", "image", "from", "a", "URL" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L181-L202
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.addImageFromString
public function addImageFromString($image) { if (empty($image)) { throw new InvalidArgumentException('Specified image is empty'); } return $this->getCommand('AddImage', array( 'user' => $this->getUser(), 'image' => $image, ))->execute(); }
php
public function addImageFromString($image) { if (empty($image)) { throw new InvalidArgumentException('Specified image is empty'); } return $this->getCommand('AddImage', array( 'user' => $this->getUser(), 'image' => $image, ))->execute(); }
[ "public", "function", "addImageFromString", "(", "$", "image", ")", "{", "if", "(", "empty", "(", "$", "image", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Specified image is empty'", ")", ";", "}", "return", "$", "this", "->", "getComm...
Add an image from memory @param string $image An image in memory @return Model @throws InvalidArgumentException
[ "Add", "an", "image", "from", "memory" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L211-L220
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.getUserInfo
public function getUserInfo() { $userInfo = $this->getCommand('GetUserInfo', array( 'user' => $this->getUser(), ))->execute(); return PublicKeyFallback::fallback($userInfo); }
php
public function getUserInfo() { $userInfo = $this->getCommand('GetUserInfo', array( 'user' => $this->getUser(), ))->execute(); return PublicKeyFallback::fallback($userInfo); }
[ "public", "function", "getUserInfo", "(", ")", "{", "$", "userInfo", "=", "$", "this", "->", "getCommand", "(", "'GetUserInfo'", ",", "array", "(", "'user'", "=>", "$", "this", "->", "getUser", "(", ")", ",", ")", ")", "->", "execute", "(", ")", ";",...
Fetch the user info of the current user @return Model
[ "Fetch", "the", "user", "info", "of", "the", "current", "user" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L245-L251
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.editMetadata
public function editMetadata($imageIdentifier, array $metadata) { return $this->getCommand('EditMetadata', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageIdentifier, 'metadata' => json_encode($metadata), ))->execute(); }
php
public function editMetadata($imageIdentifier, array $metadata) { return $this->getCommand('EditMetadata', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageIdentifier, 'metadata' => json_encode($metadata), ))->execute(); }
[ "public", "function", "editMetadata", "(", "$", "imageIdentifier", ",", "array", "$", "metadata", ")", "{", "return", "$", "this", "->", "getCommand", "(", "'EditMetadata'", ",", "array", "(", "'user'", "=>", "$", "this", "->", "getUser", "(", ")", ",", ...
Edit metadata of an image @param string $imageIdentifier The identifier of the image @param array $metadata The metadata to set @return Model
[ "Edit", "metadata", "of", "an", "image" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L286-L292
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.replaceMetadata
public function replaceMetadata($imageIdentifier, array $metadata) { return $this->getCommand('ReplaceMetadata', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageIdentifier, 'metadata' => json_encode($metadata), ))->execute(); }
php
public function replaceMetadata($imageIdentifier, array $metadata) { return $this->getCommand('ReplaceMetadata', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageIdentifier, 'metadata' => json_encode($metadata), ))->execute(); }
[ "public", "function", "replaceMetadata", "(", "$", "imageIdentifier", ",", "array", "$", "metadata", ")", "{", "return", "$", "this", "->", "getCommand", "(", "'ReplaceMetadata'", ",", "array", "(", "'user'", "=>", "$", "this", "->", "getUser", "(", ")", "...
Replace metadata of an image @param string $imageIdentifier The identifier of the image @param array $metadata The metadata to set @return Model
[ "Replace", "metadata", "of", "an", "image" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L301-L307
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.getImages
public function getImages(ImagesQuery $query = null) { if (!$query) { $query = new ImagesQuery(); } $params = array( 'user' => $this->getUser(), 'page' => $query->page(), 'limit' => $query->limit(), ); if ($query->metadata()) { $params['metadata'] = true; } if ($from = $query->from()) { $params['from'] = $from; } if ($to = $query->to()) { $params['to'] = $to; } if ($fields = $query->fields()) { $params['fields'] = $fields; } if ($sort = $query->sort()) { $params['sort'] = $sort; } if ($ids = $query->ids()) { $params['ids'] = $ids; } if ($checksums = $query->checksums()) { $params['checksums'] = $checksums; } if ($originalChecksums = $query->originalChecksums()) { $params['originalChecksums'] = $originalChecksums; } $response = $this->getCommand('GetImages', $params)->execute(); $response['images'] = array_map( array('ImboClient\Helper\PublicKeyFallback', 'fallback'), $response['images'] ); return $response; }
php
public function getImages(ImagesQuery $query = null) { if (!$query) { $query = new ImagesQuery(); } $params = array( 'user' => $this->getUser(), 'page' => $query->page(), 'limit' => $query->limit(), ); if ($query->metadata()) { $params['metadata'] = true; } if ($from = $query->from()) { $params['from'] = $from; } if ($to = $query->to()) { $params['to'] = $to; } if ($fields = $query->fields()) { $params['fields'] = $fields; } if ($sort = $query->sort()) { $params['sort'] = $sort; } if ($ids = $query->ids()) { $params['ids'] = $ids; } if ($checksums = $query->checksums()) { $params['checksums'] = $checksums; } if ($originalChecksums = $query->originalChecksums()) { $params['originalChecksums'] = $originalChecksums; } $response = $this->getCommand('GetImages', $params)->execute(); $response['images'] = array_map( array('ImboClient\Helper\PublicKeyFallback', 'fallback'), $response['images'] ); return $response; }
[ "public", "function", "getImages", "(", "ImagesQuery", "$", "query", "=", "null", ")", "{", "if", "(", "!", "$", "query", ")", "{", "$", "query", "=", "new", "ImagesQuery", "(", ")", ";", "}", "$", "params", "=", "array", "(", "'user'", "=>", "$", ...
Get images owned by a user @param ImagesQuery $query An optional images query object @return Model
[ "Get", "images", "owned", "by", "a", "user" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L328-L378
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.generateShortUrl
public function generateShortUrl(Http\ImageUrl $imageUrl) { $transformations = $imageUrl->getTransformations(); if ($transformations) { $transformations = '?t[]=' . implode('&t[]=', $transformations); } else { $transformations = null; } $params = array( 'user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'extension' => $imageUrl->getExtension(), 'query' => $transformations, ); return $this->getCommand('GenerateShortUrl', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'params' => json_encode($params), ))->execute(); }
php
public function generateShortUrl(Http\ImageUrl $imageUrl) { $transformations = $imageUrl->getTransformations(); if ($transformations) { $transformations = '?t[]=' . implode('&t[]=', $transformations); } else { $transformations = null; } $params = array( 'user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'extension' => $imageUrl->getExtension(), 'query' => $transformations, ); return $this->getCommand('GenerateShortUrl', array( 'user' => $this->getUser(), 'imageIdentifier' => $imageUrl->getImageIdentifier(), 'params' => json_encode($params), ))->execute(); }
[ "public", "function", "generateShortUrl", "(", "Http", "\\", "ImageUrl", "$", "imageUrl", ")", "{", "$", "transformations", "=", "$", "imageUrl", "->", "getTransformations", "(", ")", ";", "if", "(", "$", "transformations", ")", "{", "$", "transformations", ...
Generate a short URL @param Http\ImageUrl $imageUrl An instance of an imageUrl @return Model
[ "Generate", "a", "short", "URL" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L399-L420
train
imbo/imboclient-php
src/ImboClient/ImboClient.php
ImboClient.getResourceGroups
public function getResourceGroups(Query $query = null) { if (!$query) { $query = new Query(); } return $this->getCommand('GetResourceGroups', array( 'page' => $query->page(), 'limit' => $query->limit(), ))->execute(); }
php
public function getResourceGroups(Query $query = null) { if (!$query) { $query = new Query(); } return $this->getCommand('GetResourceGroups', array( 'page' => $query->page(), 'limit' => $query->limit(), ))->execute(); }
[ "public", "function", "getResourceGroups", "(", "Query", "$", "query", "=", "null", ")", "{", "if", "(", "!", "$", "query", ")", "{", "$", "query", "=", "new", "Query", "(", ")", ";", "}", "return", "$", "this", "->", "getCommand", "(", "'GetResource...
Get the available resource groups @param Query $query An optional query object @return Model
[ "Get", "the", "available", "resource", "groups" ]
41287eb61bf11054822468dd6cc2cdf0e220e115
https://github.com/imbo/imboclient-php/blob/41287eb61bf11054822468dd6cc2cdf0e220e115/src/ImboClient/ImboClient.php#L428-L437
train