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
deInternetJongens/Lighthouse-Utils
src/Generators/Mutations/CreateMutationGenerator.php
CreateMutationGenerator.generate
public static function generate(string $typeName, array $typeFields): string { $mutationName = 'create' . $typeName; $arguments = RelationArgumentGenerator::generate($typeFields); $arguments = array_merge($arguments, InputFieldsArgumentGenerator::generate($typeFields)); if (count($arguments) < 1) { return ''; } $mutation = sprintf(' %s(%s)', $mutationName, implode(', ', $arguments)); $mutation .= sprintf(': %1$s @create(model: "%1$s")', $typeName); if (config('lighthouse-utils.authorization')) { $permission = sprintf('create%1$s', $typeName); $mutation .= sprintf(' @can(if: "%1$s", model: "User")', $permission); } GraphQLSchema::register($mutationName, $typeName, 'mutation', $permission ?? null); return $mutation; }
php
public static function generate(string $typeName, array $typeFields): string { $mutationName = 'create' . $typeName; $arguments = RelationArgumentGenerator::generate($typeFields); $arguments = array_merge($arguments, InputFieldsArgumentGenerator::generate($typeFields)); if (count($arguments) < 1) { return ''; } $mutation = sprintf(' %s(%s)', $mutationName, implode(', ', $arguments)); $mutation .= sprintf(': %1$s @create(model: "%1$s")', $typeName); if (config('lighthouse-utils.authorization')) { $permission = sprintf('create%1$s', $typeName); $mutation .= sprintf(' @can(if: "%1$s", model: "User")', $permission); } GraphQLSchema::register($mutationName, $typeName, 'mutation', $permission ?? null); return $mutation; }
[ "public", "static", "function", "generate", "(", "string", "$", "typeName", ",", "array", "$", "typeFields", ")", ":", "string", "{", "$", "mutationName", "=", "'create'", ".", "$", "typeName", ";", "$", "arguments", "=", "RelationArgumentGenerator", "::", "...
Generates a GraphQL Mutation to create a record @param string $typeName @param Type[] $typeFields @return string
[ "Generates", "a", "GraphQL", "Mutation", "to", "create", "a", "record" ]
31cd7ffe225f4639f3ecf2fd40c4e6835a145dda
https://github.com/deInternetJongens/Lighthouse-Utils/blob/31cd7ffe225f4639f3ecf2fd40c4e6835a145dda/src/Generators/Mutations/CreateMutationGenerator.php#L18-L40
train
deInternetJongens/Lighthouse-Utils
src/Generators/Mutations/UpdateMutationWithInputTypeGenerator.php
UpdateMutationWithInputTypeGenerator.generate
public static function generate(string $typeName, array $typeFields): MutationWithInput { $mutationName = 'update' . $typeName; $inputTypeName = sprintf('update%sInput', ucfirst($typeName)); $inputType = InputTypeArgumentGenerator::generate($inputTypeName, $typeFields, true); if (empty($inputType)) { return new MutationWithInput('', ''); } $mutation = sprintf(' %s(input: %s!)', $mutationName, $inputTypeName); $mutation .= sprintf(': %1$s @update(model: "%1$s", flatten: true)', $typeName); if (config('lighthouse-utils.authorization')) { $permission = sprintf('update%1$s', $typeName); $mutation .= sprintf(' @can(if: "%1$s", model: "User")', $permission); } GraphQLSchema::register($mutationName, $typeName, 'mutation', $permission ?? null); return new MutationWithInput($mutation, $inputType); }
php
public static function generate(string $typeName, array $typeFields): MutationWithInput { $mutationName = 'update' . $typeName; $inputTypeName = sprintf('update%sInput', ucfirst($typeName)); $inputType = InputTypeArgumentGenerator::generate($inputTypeName, $typeFields, true); if (empty($inputType)) { return new MutationWithInput('', ''); } $mutation = sprintf(' %s(input: %s!)', $mutationName, $inputTypeName); $mutation .= sprintf(': %1$s @update(model: "%1$s", flatten: true)', $typeName); if (config('lighthouse-utils.authorization')) { $permission = sprintf('update%1$s', $typeName); $mutation .= sprintf(' @can(if: "%1$s", model: "User")', $permission); } GraphQLSchema::register($mutationName, $typeName, 'mutation', $permission ?? null); return new MutationWithInput($mutation, $inputType); }
[ "public", "static", "function", "generate", "(", "string", "$", "typeName", ",", "array", "$", "typeFields", ")", ":", "MutationWithInput", "{", "$", "mutationName", "=", "'update'", ".", "$", "typeName", ";", "$", "inputTypeName", "=", "sprintf", "(", "'upd...
Generates a GraphQL Mutation to update a record @param string $typeName @param Type[] $typeFields @return MutationWithInput
[ "Generates", "a", "GraphQL", "Mutation", "to", "update", "a", "record" ]
31cd7ffe225f4639f3ecf2fd40c4e6835a145dda
https://github.com/deInternetJongens/Lighthouse-Utils/blob/31cd7ffe225f4639f3ecf2fd40c4e6835a145dda/src/Generators/Mutations/UpdateMutationWithInputTypeGenerator.php#L18-L39
train
RWOverdijk/AssetManager
src/AssetManager/Service/MimeResolver.php
MimeResolver.getMimeType
public function getMimeType($filename) { $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (isset($this->mimeTypes[$extension])) { return $this->mimeTypes[$extension]; } return 'text/plain'; }
php
public function getMimeType($filename) { $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (isset($this->mimeTypes[$extension])) { return $this->mimeTypes[$extension]; } return 'text/plain'; }
[ "public", "function", "getMimeType", "(", "$", "filename", ")", "{", "$", "extension", "=", "strtolower", "(", "pathinfo", "(", "$", "filename", ",", "PATHINFO_EXTENSION", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "mimeTypes", "[", "$", ...
Get the mime type from a file extension. @param string $filename @return string The mime type found. Falls back to text/plain.
[ "Get", "the", "mime", "type", "from", "a", "file", "extension", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/MimeResolver.php#L564-L573
train
RWOverdijk/AssetManager
src/AssetManager/Service/MimeResolver.php
MimeResolver.getExtension
public function getExtension($mimetype) { if (!($extension = array_search($mimetype, $this->mainMimeTypes))) { $extension = array_search($mimetype, $this->mimeTypes); } return !$extension ? null : $extension; }
php
public function getExtension($mimetype) { if (!($extension = array_search($mimetype, $this->mainMimeTypes))) { $extension = array_search($mimetype, $this->mimeTypes); } return !$extension ? null : $extension; }
[ "public", "function", "getExtension", "(", "$", "mimetype", ")", "{", "if", "(", "!", "(", "$", "extension", "=", "array_search", "(", "$", "mimetype", ",", "$", "this", "->", "mainMimeTypes", ")", ")", ")", "{", "$", "extension", "=", "array_search", ...
Get the extension that matches given mimetype. @param string $mimetype @return mixed null when not found, extension (string) when found.
[ "Get", "the", "extension", "that", "matches", "given", "mimetype", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/MimeResolver.php#L581-L588
train
loveorigami/yii2-notification-wrapper
src/Wrapper.php
Wrapper.init
public function init() { parent::init(); $this->url = Yii::$app->getUrlManager()->createUrl(['noty/default/index']); if (!$this->layerClass) { $this->layerClass = self::DEFAULT_LAYER; } }
php
public function init() { parent::init(); $this->url = Yii::$app->getUrlManager()->createUrl(['noty/default/index']); if (!$this->layerClass) { $this->layerClass = self::DEFAULT_LAYER; } }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "this", "->", "url", "=", "Yii", "::", "$", "app", "->", "getUrlManager", "(", ")", "->", "createUrl", "(", "[", "'noty/default/index'", "]", ")", ";", "if", "...
init layer class
[ "init", "layer", "class" ]
544c5a34b33799e0f0f0882e1163273bd12728e0
https://github.com/loveorigami/yii2-notification-wrapper/blob/544c5a34b33799e0f0f0882e1163273bd12728e0/src/Wrapper.php#L70-L79
train
loveorigami/yii2-notification-wrapper
src/Wrapper.php
Wrapper.registerJs
protected function registerJs() { $config['options'] = $this->options; $config['layerOptions'] = $this->layerOptions; $config['layerOptions']['layerId'] = $this->layer->getLayerId(); $config = Json::encode($config); $layerClass = Json::encode($this->layerClass); $this->view->registerJs(" $.ajaxSetup({ showNoty: true // default for all ajax calls }); $(document).ajaxComplete(function (event, xhr, settings) { if (settings.showNoty && (settings.type=='POST' || settings.container)) { $.ajax({ url: '$this->url', method: 'POST', cache: false, showNoty: false, global: false, data: { layerClass: '$layerClass', config: '$config' }, success: function(data) { $('#" . $this->layer->getLayerId() . "').html(data); } }); } }); ", View::POS_END); }
php
protected function registerJs() { $config['options'] = $this->options; $config['layerOptions'] = $this->layerOptions; $config['layerOptions']['layerId'] = $this->layer->getLayerId(); $config = Json::encode($config); $layerClass = Json::encode($this->layerClass); $this->view->registerJs(" $.ajaxSetup({ showNoty: true // default for all ajax calls }); $(document).ajaxComplete(function (event, xhr, settings) { if (settings.showNoty && (settings.type=='POST' || settings.container)) { $.ajax({ url: '$this->url', method: 'POST', cache: false, showNoty: false, global: false, data: { layerClass: '$layerClass', config: '$config' }, success: function(data) { $('#" . $this->layer->getLayerId() . "').html(data); } }); } }); ", View::POS_END); }
[ "protected", "function", "registerJs", "(", ")", "{", "$", "config", "[", "'options'", "]", "=", "$", "this", "->", "options", ";", "$", "config", "[", "'layerOptions'", "]", "=", "$", "this", "->", "layerOptions", ";", "$", "config", "[", "'layerOptions...
Register js for ajax notifications
[ "Register", "js", "for", "ajax", "notifications" ]
544c5a34b33799e0f0f0882e1163273bd12728e0
https://github.com/loveorigami/yii2-notification-wrapper/blob/544c5a34b33799e0f0f0882e1163273bd12728e0/src/Wrapper.php#L157-L189
train
RWOverdijk/AssetManager
src/AssetManager/Service/AssetFilterManager.php
AssetFilterManager.ensureByService
protected function ensureByService(AssetInterface $asset, $service) { if (is_string($service)) { $this->ensureByFilter($asset, $this->getServiceLocator()->get($service)); } else { throw new Exception\RuntimeException( 'Unexpected service provided. Expected string or callback.' ); } }
php
protected function ensureByService(AssetInterface $asset, $service) { if (is_string($service)) { $this->ensureByFilter($asset, $this->getServiceLocator()->get($service)); } else { throw new Exception\RuntimeException( 'Unexpected service provided. Expected string or callback.' ); } }
[ "protected", "function", "ensureByService", "(", "AssetInterface", "$", "asset", ",", "$", "service", ")", "{", "if", "(", "is_string", "(", "$", "service", ")", ")", "{", "$", "this", "->", "ensureByFilter", "(", "$", "asset", ",", "$", "this", "->", ...
Ensure that the filters as service are set. @param AssetInterface $asset @param string $service A valid service name. @throws Exception\RuntimeException
[ "Ensure", "that", "the", "filters", "as", "service", "are", "set", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/AssetFilterManager.php#L112-L121
train
RWOverdijk/AssetManager
src/AssetManager/Service/AssetFilterManager.php
AssetFilterManager.ensureByFilter
protected function ensureByFilter(AssetInterface $asset, $filter) { if ($filter instanceof FilterInterface) { $filterInstance = $filter; $asset->ensureFilter($filterInstance); return; } $filterClass = $filter; if (!is_subclass_of($filterClass, 'Assetic\Filter\FilterInterface', true)) { $filterClass .= (substr($filterClass, -6) === 'Filter') ? '' : 'Filter'; $filterClass = 'Assetic\Filter\\' . $filterClass; } if (!class_exists($filterClass)) { throw new Exception\RuntimeException( 'No filter found for ' . $filter ); } if (!isset($this->filterInstances[$filterClass])) { $this->filterInstances[$filterClass] = new $filterClass(); } $filterInstance = $this->filterInstances[$filterClass]; $asset->ensureFilter($filterInstance); }
php
protected function ensureByFilter(AssetInterface $asset, $filter) { if ($filter instanceof FilterInterface) { $filterInstance = $filter; $asset->ensureFilter($filterInstance); return; } $filterClass = $filter; if (!is_subclass_of($filterClass, 'Assetic\Filter\FilterInterface', true)) { $filterClass .= (substr($filterClass, -6) === 'Filter') ? '' : 'Filter'; $filterClass = 'Assetic\Filter\\' . $filterClass; } if (!class_exists($filterClass)) { throw new Exception\RuntimeException( 'No filter found for ' . $filter ); } if (!isset($this->filterInstances[$filterClass])) { $this->filterInstances[$filterClass] = new $filterClass(); } $filterInstance = $this->filterInstances[$filterClass]; $asset->ensureFilter($filterInstance); }
[ "protected", "function", "ensureByFilter", "(", "AssetInterface", "$", "asset", ",", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "FilterInterface", ")", "{", "$", "filterInstance", "=", "$", "filter", ";", "$", "asset", "->", "ensureFilt...
Ensure that the filters as filter are set. @param AssetInterface $asset @param mixed $filter Either an instance of FilterInterface or a classname. @throws Exception\RuntimeException
[ "Ensure", "that", "the", "filters", "as", "filter", "are", "set", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/AssetFilterManager.php#L130-L159
train
loveorigami/yii2-notification-wrapper
src/layers/Layer.php
Layer.setTitle
public function setTitle() { switch ($this->type) { case self::TYPE_ERROR: $t = Yii::t('noty', 'Error'); break; case self::TYPE_INFO: $t = Yii::t('noty', 'Info'); break; case self::TYPE_WARNING: $t = Yii::t('noty', 'Warning'); break; case self::TYPE_SUCCESS: $t = Yii::t('noty', 'Success'); break; default: $t = ''; } $this->title = $this->showTitle ? $t : ''; }
php
public function setTitle() { switch ($this->type) { case self::TYPE_ERROR: $t = Yii::t('noty', 'Error'); break; case self::TYPE_INFO: $t = Yii::t('noty', 'Info'); break; case self::TYPE_WARNING: $t = Yii::t('noty', 'Warning'); break; case self::TYPE_SUCCESS: $t = Yii::t('noty', 'Success'); break; default: $t = ''; } $this->title = $this->showTitle ? $t : ''; }
[ "public", "function", "setTitle", "(", ")", "{", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "self", "::", "TYPE_ERROR", ":", "$", "t", "=", "Yii", "::", "t", "(", "'noty'", ",", "'Error'", ")", ";", "break", ";", "case", "self", ...
set title by type
[ "set", "title", "by", "type" ]
544c5a34b33799e0f0f0882e1163273bd12728e0
https://github.com/loveorigami/yii2-notification-wrapper/blob/544c5a34b33799e0f0f0882e1163273bd12728e0/src/layers/Layer.php#L113-L133
train
RWOverdijk/AssetManager
src/AssetManager/Cache/FilePathCache.php
FilePathCache.cachedFile
protected function cachedFile() { if (null === $this->cachedFile) { $this->cachedFile = rtrim($this->dir, '/') . '/' . ltrim($this->filename, '/'); } return $this->cachedFile; }
php
protected function cachedFile() { if (null === $this->cachedFile) { $this->cachedFile = rtrim($this->dir, '/') . '/' . ltrim($this->filename, '/'); } return $this->cachedFile; }
[ "protected", "function", "cachedFile", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "cachedFile", ")", "{", "$", "this", "->", "cachedFile", "=", "rtrim", "(", "$", "this", "->", "dir", ",", "'/'", ")", ".", "'/'", ".", "ltrim", "(",...
Get the path-to-file. @return string Cache path
[ "Get", "the", "path", "-", "to", "-", "file", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Cache/FilePathCache.php#L122-L129
train
RWOverdijk/AssetManager
src/AssetManager/Service/AssetCacheManager.php
AssetCacheManager.getProvider
private function getProvider($path) { $cacheProvider = $this->getCacheProviderConfig($path); if (!$cacheProvider) { return null; } if (is_string($cacheProvider['cache']) && $this->serviceLocator->has($cacheProvider['cache']) ) { return $this->serviceLocator->get($cacheProvider['cache']); } // Left here for BC. Please consider defining a ZF2 service instead. if (is_callable($cacheProvider['cache'])) { return call_user_func($cacheProvider['cache'], $path); } $dir = ''; $class = $cacheProvider['cache']; if (!empty($cacheProvider['options']['dir'])) { $dir = $cacheProvider['options']['dir']; } $class = $this->classMapper($class); return new $class($dir, $path); }
php
private function getProvider($path) { $cacheProvider = $this->getCacheProviderConfig($path); if (!$cacheProvider) { return null; } if (is_string($cacheProvider['cache']) && $this->serviceLocator->has($cacheProvider['cache']) ) { return $this->serviceLocator->get($cacheProvider['cache']); } // Left here for BC. Please consider defining a ZF2 service instead. if (is_callable($cacheProvider['cache'])) { return call_user_func($cacheProvider['cache'], $path); } $dir = ''; $class = $cacheProvider['cache']; if (!empty($cacheProvider['options']['dir'])) { $dir = $cacheProvider['options']['dir']; } $class = $this->classMapper($class); return new $class($dir, $path); }
[ "private", "function", "getProvider", "(", "$", "path", ")", "{", "$", "cacheProvider", "=", "$", "this", "->", "getCacheProviderConfig", "(", "$", "path", ")", ";", "if", "(", "!", "$", "cacheProvider", ")", "{", "return", "null", ";", "}", "if", "(",...
Get the cache provider. First checks to see if the provider is callable, then will attempt to get it from the service locator, finally will fallback to a class mapper. @param $path @return array
[ "Get", "the", "cache", "provider", ".", "First", "checks", "to", "see", "if", "the", "provider", "is", "callable", "then", "will", "attempt", "to", "get", "it", "from", "the", "service", "locator", "finally", "will", "fallback", "to", "a", "class", "mapper...
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/AssetCacheManager.php#L72-L100
train
RWOverdijk/AssetManager
src/AssetManager/Service/AssetCacheManager.php
AssetCacheManager.getCacheProviderConfig
private function getCacheProviderConfig($path) { $cacheProvider = null; if (!empty($this->config[$path]) && !empty($this->config[$path]['cache'])) { $cacheProvider = $this->config[$path]; } if (!$cacheProvider && !empty($this->config['default']) && !empty($this->config['default']['cache']) ) { $cacheProvider = $this->config['default']; } return $cacheProvider; }
php
private function getCacheProviderConfig($path) { $cacheProvider = null; if (!empty($this->config[$path]) && !empty($this->config[$path]['cache'])) { $cacheProvider = $this->config[$path]; } if (!$cacheProvider && !empty($this->config['default']) && !empty($this->config['default']['cache']) ) { $cacheProvider = $this->config['default']; } return $cacheProvider; }
[ "private", "function", "getCacheProviderConfig", "(", "$", "path", ")", "{", "$", "cacheProvider", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "config", "[", "$", "path", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", ...
Get the cache provider config. Use default values if defined. @param $path @return null|array Cache config definition. Returns null if not found in config.
[ "Get", "the", "cache", "provider", "config", ".", "Use", "default", "values", "if", "defined", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Service/AssetCacheManager.php#L110-L126
train
RWOverdijk/AssetManager
src/AssetManager/Module.php
Module.onDispatch
public function onDispatch(MvcEvent $event) { /* @var $response \Zend\Http\Response */ $response = $event->getResponse(); if (!method_exists($response, 'getStatusCode') || $response->getStatusCode() !== 404) { return; } $request = $event->getRequest(); $serviceManager = $event->getApplication()->getServiceManager(); $assetManager = $serviceManager->get(__NAMESPACE__ . '\Service\AssetManager'); if (!$assetManager->resolvesToAsset($request)) { return; } $response->setStatusCode(200); return $assetManager->setAssetOnResponse($response); }
php
public function onDispatch(MvcEvent $event) { /* @var $response \Zend\Http\Response */ $response = $event->getResponse(); if (!method_exists($response, 'getStatusCode') || $response->getStatusCode() !== 404) { return; } $request = $event->getRequest(); $serviceManager = $event->getApplication()->getServiceManager(); $assetManager = $serviceManager->get(__NAMESPACE__ . '\Service\AssetManager'); if (!$assetManager->resolvesToAsset($request)) { return; } $response->setStatusCode(200); return $assetManager->setAssetOnResponse($response); }
[ "public", "function", "onDispatch", "(", "MvcEvent", "$", "event", ")", "{", "/* @var $response \\Zend\\Http\\Response */", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "response", ",", "'ge...
Callback method for dispatch and dispatch.error events. @param MvcEvent $event
[ "Callback", "method", "for", "dispatch", "and", "dispatch", ".", "error", "events", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Module.php#L52-L70
train
loveorigami/yii2-notification-wrapper
src/layers/Notie.php
Notie.overrideConfirm
public function overrideConfirm() { if ($this->overrideSystemConfirm) { $ok = Yii::t('noty', 'Ok'); $cancel = Yii::t('noty', 'Cancel'); $this->view->registerJs(" yii.confirm = function(message, ok, cancel) { notie.confirm(message, '$ok', '$cancel', function() { !ok || ok(); }); } "); } }
php
public function overrideConfirm() { if ($this->overrideSystemConfirm) { $ok = Yii::t('noty', 'Ok'); $cancel = Yii::t('noty', 'Cancel'); $this->view->registerJs(" yii.confirm = function(message, ok, cancel) { notie.confirm(message, '$ok', '$cancel', function() { !ok || ok(); }); } "); } }
[ "public", "function", "overrideConfirm", "(", ")", "{", "if", "(", "$", "this", "->", "overrideSystemConfirm", ")", "{", "$", "ok", "=", "Yii", "::", "t", "(", "'noty'", ",", "'Ok'", ")", ";", "$", "cancel", "=", "Yii", "::", "t", "(", "'noty'", ",...
Override System Confirm
[ "Override", "System", "Confirm" ]
544c5a34b33799e0f0f0882e1163273bd12728e0
https://github.com/loveorigami/yii2-notification-wrapper/blob/544c5a34b33799e0f0f0882e1163273bd12728e0/src/layers/Notie.php#L100-L117
train
RWOverdijk/AssetManager
src/AssetManager/View/Helper/Asset.php
Asset.appendTimestamp
private function appendTimestamp($filename, $queryString, $timestamp = null) { // current timestamp as default $timestamp = $timestamp === null ? time() : $timestamp; return $filename . '?' . urlencode($queryString) . '=' . $timestamp; }
php
private function appendTimestamp($filename, $queryString, $timestamp = null) { // current timestamp as default $timestamp = $timestamp === null ? time() : $timestamp; return $filename . '?' . urlencode($queryString) . '=' . $timestamp; }
[ "private", "function", "appendTimestamp", "(", "$", "filename", ",", "$", "queryString", ",", "$", "timestamp", "=", "null", ")", "{", "// current timestamp as default", "$", "timestamp", "=", "$", "timestamp", "===", "null", "?", "time", "(", ")", ":", "$",...
Append timestamp as query param to the filename @param string $filename @param string $queryString @param int|null $timestamp @return string
[ "Append", "timestamp", "as", "query", "param", "to", "the", "filename" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/View/Helper/Asset.php#L41-L47
train
RWOverdijk/AssetManager
src/AssetManager/View/Helper/Asset.php
Asset.elaborateFilePath
private function elaborateFilePath($filename, $queryString) { $asset = $this->assetManagerResolver->resolve($filename); if ($asset !== null) { // append last modified date to the filepath and use a custom query string return $this->appendTimestamp($filename, $queryString, $asset->getLastModified()); } return $filename; }
php
private function elaborateFilePath($filename, $queryString) { $asset = $this->assetManagerResolver->resolve($filename); if ($asset !== null) { // append last modified date to the filepath and use a custom query string return $this->appendTimestamp($filename, $queryString, $asset->getLastModified()); } return $filename; }
[ "private", "function", "elaborateFilePath", "(", "$", "filename", ",", "$", "queryString", ")", "{", "$", "asset", "=", "$", "this", "->", "assetManagerResolver", "->", "resolve", "(", "$", "filename", ")", ";", "if", "(", "$", "asset", "!==", "null", ")...
find the file and if it exists, append its unix modification time to the filename @param string $filename @param string $queryString @return string
[ "find", "the", "file", "and", "if", "it", "exists", "append", "its", "unix", "modification", "time", "to", "the", "filename" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/View/Helper/Asset.php#L56-L66
train
RWOverdijk/AssetManager
src/AssetManager/View/Helper/Asset.php
Asset.getFilePathFromCache
private function getFilePathFromCache($filename, $queryString) { // return if cache not found if ($this->cache == null) { return null; } // cache key based on the filename $cacheKey = md5($filename); $itemIsFoundInCache = false; $filePath = $this->cache->getItem($cacheKey, $itemIsFoundInCache); // if there is no element in the cache, elaborate and cache it if ($itemIsFoundInCache === false || $filePath === null) { $filePath = $this->elaborateFilePath($filename, $queryString); $this->cache->setItem($cacheKey, $filePath); } return $filePath; }
php
private function getFilePathFromCache($filename, $queryString) { // return if cache not found if ($this->cache == null) { return null; } // cache key based on the filename $cacheKey = md5($filename); $itemIsFoundInCache = false; $filePath = $this->cache->getItem($cacheKey, $itemIsFoundInCache); // if there is no element in the cache, elaborate and cache it if ($itemIsFoundInCache === false || $filePath === null) { $filePath = $this->elaborateFilePath($filename, $queryString); $this->cache->setItem($cacheKey, $filePath); } return $filePath; }
[ "private", "function", "getFilePathFromCache", "(", "$", "filename", ",", "$", "queryString", ")", "{", "// return if cache not found", "if", "(", "$", "this", "->", "cache", "==", "null", ")", "{", "return", "null", ";", "}", "// cache key based on the filename",...
Use the cache to get the filePath @param string $filename @param string $queryString @return mixed|string
[ "Use", "the", "cache", "to", "get", "the", "filePath" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/View/Helper/Asset.php#L76-L95
train
RWOverdijk/AssetManager
src/AssetManager/Resolver/AliasPathStackResolver.php
AliasPathStackResolver.addAlias
private function addAlias($alias, $path) { if (!is_string($path)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } if (!is_string($alias)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid alias provided; must be a string, received %s', gettype($alias) )); } $this->aliases[$alias] = $this->normalizePath($path); }
php
private function addAlias($alias, $path) { if (!is_string($path)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } if (!is_string($alias)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid alias provided; must be a string, received %s', gettype($alias) )); } $this->aliases[$alias] = $this->normalizePath($path); }
[ "private", "function", "addAlias", "(", "$", "alias", ",", "$", "path", ")", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid path provided; must ...
Add a single alias to the stack @param string $alias @param string $path @throws Exception\InvalidArgumentException
[ "Add", "a", "single", "alias", "to", "the", "stack" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Resolver/AliasPathStackResolver.php#L59-L76
train
RWOverdijk/AssetManager
src/AssetManager/Controller/ConsoleController.php
ConsoleController.warmupAction
public function warmupAction() { $request = $this->getRequest(); $purge = $request->getParam('purge', false); $verbose = $request->getParam('verbose', false) || $request->getParam('v', false); // purge cache for every configuration if ($purge) { $this->purgeCache($verbose); } $this->output('Collecting all assets...', $verbose); $collection = $this->assetManager->getResolver()->collect(); $this->output(sprintf('Collected %d assets, warming up...', count($collection)), $verbose); foreach ($collection as $path) { $asset = $this->assetManager->getResolver()->resolve($path); $this->assetManager->getAssetFilterManager()->setFilters($path, $asset); $this->assetManager->getAssetCacheManager()->setCache($path, $asset)->dump(); } $this->output(sprintf('Warming up finished...', $verbose)); }
php
public function warmupAction() { $request = $this->getRequest(); $purge = $request->getParam('purge', false); $verbose = $request->getParam('verbose', false) || $request->getParam('v', false); // purge cache for every configuration if ($purge) { $this->purgeCache($verbose); } $this->output('Collecting all assets...', $verbose); $collection = $this->assetManager->getResolver()->collect(); $this->output(sprintf('Collected %d assets, warming up...', count($collection)), $verbose); foreach ($collection as $path) { $asset = $this->assetManager->getResolver()->resolve($path); $this->assetManager->getAssetFilterManager()->setFilters($path, $asset); $this->assetManager->getAssetCacheManager()->setCache($path, $asset)->dump(); } $this->output(sprintf('Warming up finished...', $verbose)); }
[ "public", "function", "warmupAction", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "purge", "=", "$", "request", "->", "getParam", "(", "'purge'", ",", "false", ")", ";", "$", "verbose", "=", "$", "request"...
Dumps all assets to cache directories.
[ "Dumps", "all", "assets", "to", "cache", "directories", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Controller/ConsoleController.php#L66-L89
train
RWOverdijk/AssetManager
src/AssetManager/Controller/ConsoleController.php
ConsoleController.purgeCache
protected function purgeCache($verbose = false) { if (empty($this->appConfig['asset_manager']['caching'])) { return false; } foreach ($this->appConfig['asset_manager']['caching'] as $configName => $config) { if (empty($config['options']['dir'])) { continue; } $this->output(sprintf('Purging %s on "%s"...', $config['options']['dir'], $configName), $verbose); $node = $config['options']['dir']; if ($configName !== 'default') { $node .= '/'.$configName; } $this->recursiveRemove($node, $verbose); } return true; }
php
protected function purgeCache($verbose = false) { if (empty($this->appConfig['asset_manager']['caching'])) { return false; } foreach ($this->appConfig['asset_manager']['caching'] as $configName => $config) { if (empty($config['options']['dir'])) { continue; } $this->output(sprintf('Purging %s on "%s"...', $config['options']['dir'], $configName), $verbose); $node = $config['options']['dir']; if ($configName !== 'default') { $node .= '/'.$configName; } $this->recursiveRemove($node, $verbose); } return true; }
[ "protected", "function", "purgeCache", "(", "$", "verbose", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "appConfig", "[", "'asset_manager'", "]", "[", "'caching'", "]", ")", ")", "{", "return", "false", ";", "}", "foreach", "(",...
Purges all directories defined as AssetManager cache dir. @param bool $verbose verbose flag, default false @return bool false if caching is not set, otherwise true
[ "Purges", "all", "directories", "defined", "as", "AssetManager", "cache", "dir", "." ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Controller/ConsoleController.php#L96-L120
train
RWOverdijk/AssetManager
src/AssetManager/Resolver/PathStackResolver.php
PathStackResolver.addPath
public function addPath($path) { if (!is_string($path)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } $this->paths[] = $this->normalizePath($path); }
php
public function addPath($path) { if (!is_string($path)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid path provided; must be a string, received %s', gettype($path) )); } $this->paths[] = $this->normalizePath($path); }
[ "public", "function", "addPath", "(", "$", "path", ")", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid path provided; must be a string, received %s'",...
Add a single path to the stack @param string $path @throws Exception\InvalidArgumentException
[ "Add", "a", "single", "path", "to", "the", "stack" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Resolver/PathStackResolver.php#L116-L126
train
RWOverdijk/AssetManager
src/AssetManager/Asset/AggregateAsset.php
AggregateAsset.processContent
private function processContent($content) { $this->mimetype = null; foreach ($content as $asset) { if (null === $this->mimetype) { $this->mimetype = $asset->mimetype; } if ($asset->mimetype !== $this->mimetype) { throw new Exception\RuntimeException( sprintf( 'Asset "%s" doesn\'t have the expected mime-type "%s".', $asset->getTargetPath(), $this->mimetype ) ); } $this->setLastModified( max( $asset->getLastModified(), $this->getLastModified() ) ); $this->setContent( $this->getContent() . $asset->dump() ); } }
php
private function processContent($content) { $this->mimetype = null; foreach ($content as $asset) { if (null === $this->mimetype) { $this->mimetype = $asset->mimetype; } if ($asset->mimetype !== $this->mimetype) { throw new Exception\RuntimeException( sprintf( 'Asset "%s" doesn\'t have the expected mime-type "%s".', $asset->getTargetPath(), $this->mimetype ) ); } $this->setLastModified( max( $asset->getLastModified(), $this->getLastModified() ) ); $this->setContent( $this->getContent() . $asset->dump() ); } }
[ "private", "function", "processContent", "(", "$", "content", ")", "{", "$", "this", "->", "mimetype", "=", "null", ";", "foreach", "(", "$", "content", "as", "$", "asset", ")", "{", "if", "(", "null", "===", "$", "this", "->", "mimetype", ")", "{", ...
Loop through assets and merge content @param string $content @throws Exception\RuntimeException
[ "Loop", "through", "assets", "and", "merge", "content" ]
982e3b1802d76ec69b74f90c24154b37f460656f
https://github.com/RWOverdijk/AssetManager/blob/982e3b1802d76ec69b74f90c24154b37f460656f/src/AssetManager/Asset/AggregateAsset.php#L74-L102
train
ElForastero/Transliterate
src/Transliterator.php
Transliterator.make
public function make(string $text): string { $map = $this->getMap(); $transliterated = str_replace(array_keys($map), array_values($map), $text); if (true === config('transliterate.remove_accents', false)) { $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII'); $transliterated = $transliterator->transliterate($transliterated); } return self::applyTransformers($transliterated); }
php
public function make(string $text): string { $map = $this->getMap(); $transliterated = str_replace(array_keys($map), array_values($map), $text); if (true === config('transliterate.remove_accents', false)) { $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII'); $transliterated = $transliterator->transliterate($transliterated); } return self::applyTransformers($transliterated); }
[ "public", "function", "make", "(", "string", "$", "text", ")", ":", "string", "{", "$", "map", "=", "$", "this", "->", "getMap", "(", ")", ";", "$", "transliterated", "=", "str_replace", "(", "array_keys", "(", "$", "map", ")", ",", "array_values", "...
Transliterate the given string. @param string $text @return string
[ "Transliterate", "the", "given", "string", "." ]
6f7d1d88440f7be3cc0f91f2a06b2374fece0832
https://github.com/ElForastero/Transliterate/blob/6f7d1d88440f7be3cc0f91f2a06b2374fece0832/src/Transliterator.php#L69-L80
train
ElForastero/Transliterate
src/Transliterator.php
Transliterator.slugify
public function slugify(string $text): string { $map = $this->getMap(); $text = str_replace(array_keys($map), array_values($map), trim($text)); $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()'); $text = $transliterator->transliterate($text); $text = str_replace('&', 'and', $text); return preg_replace( ['/[^\w\s]/', '/\s+/'], ['', '-'], $text ); }
php
public function slugify(string $text): string { $map = $this->getMap(); $text = str_replace(array_keys($map), array_values($map), trim($text)); $transliterator = IntlTransliterator::create('Any-Latin; Latin-ASCII; Lower()'); $text = $transliterator->transliterate($text); $text = str_replace('&', 'and', $text); return preg_replace( ['/[^\w\s]/', '/\s+/'], ['', '-'], $text ); }
[ "public", "function", "slugify", "(", "string", "$", "text", ")", ":", "string", "{", "$", "map", "=", "$", "this", "->", "getMap", "(", ")", ";", "$", "text", "=", "str_replace", "(", "array_keys", "(", "$", "map", ")", ",", "array_values", "(", "...
Create a slug by converting and removing all non-ascii characters. @param string $text @return string
[ "Create", "a", "slug", "by", "converting", "and", "removing", "all", "non", "-", "ascii", "characters", "." ]
6f7d1d88440f7be3cc0f91f2a06b2374fece0832
https://github.com/ElForastero/Transliterate/blob/6f7d1d88440f7be3cc0f91f2a06b2374fece0832/src/Transliterator.php#L89-L104
train
ElForastero/Transliterate
src/Transliterator.php
Transliterator.getMap
private function getMap(): array { $map = $this->map ?? config('transliterate.default_map'); $lang = $this->lang ?? config('transliterate.default_lang'); $customMaps = config('transliterate.custom_maps'); $vendorMapsPath = __DIR__.DIRECTORY_SEPARATOR.'maps'.DIRECTORY_SEPARATOR; $path = $customMaps[$lang][$map] ?? $vendorMapsPath.$lang.DIRECTORY_SEPARATOR.$map.'.php'; if (!file_exists($path)) { throw new \InvalidArgumentException("The transliteration map '${path}' doesn't exist"); } /* @noinspection PhpIncludeInspection */ return require $path; }
php
private function getMap(): array { $map = $this->map ?? config('transliterate.default_map'); $lang = $this->lang ?? config('transliterate.default_lang'); $customMaps = config('transliterate.custom_maps'); $vendorMapsPath = __DIR__.DIRECTORY_SEPARATOR.'maps'.DIRECTORY_SEPARATOR; $path = $customMaps[$lang][$map] ?? $vendorMapsPath.$lang.DIRECTORY_SEPARATOR.$map.'.php'; if (!file_exists($path)) { throw new \InvalidArgumentException("The transliteration map '${path}' doesn't exist"); } /* @noinspection PhpIncludeInspection */ return require $path; }
[ "private", "function", "getMap", "(", ")", ":", "array", "{", "$", "map", "=", "$", "this", "->", "map", "??", "config", "(", "'transliterate.default_map'", ")", ";", "$", "lang", "=", "$", "this", "->", "lang", "??", "config", "(", "'transliterate.defau...
Get map array according to config file. @return array
[ "Get", "map", "array", "according", "to", "config", "file", "." ]
6f7d1d88440f7be3cc0f91f2a06b2374fece0832
https://github.com/ElForastero/Transliterate/blob/6f7d1d88440f7be3cc0f91f2a06b2374fece0832/src/Transliterator.php#L111-L126
train
ElForastero/Transliterate
src/Transliterator.php
Transliterator.applyTransformers
private function applyTransformers(string $string): string { foreach (Transformer::getAll() as $transformer) { $string = $transformer($string); } return $string; }
php
private function applyTransformers(string $string): string { foreach (Transformer::getAll() as $transformer) { $string = $transformer($string); } return $string; }
[ "private", "function", "applyTransformers", "(", "string", "$", "string", ")", ":", "string", "{", "foreach", "(", "Transformer", "::", "getAll", "(", ")", "as", "$", "transformer", ")", "{", "$", "string", "=", "$", "transformer", "(", "$", "string", ")...
Apply a series of transformations defined as closures in the configuration file. @param string $string @return string
[ "Apply", "a", "series", "of", "transformations", "defined", "as", "closures", "in", "the", "configuration", "file", "." ]
6f7d1d88440f7be3cc0f91f2a06b2374fece0832
https://github.com/ElForastero/Transliterate/blob/6f7d1d88440f7be3cc0f91f2a06b2374fece0832/src/Transliterator.php#L135-L142
train
fabulator/endomondo-api
lib/Fabulator/Endomondo/EndomondoApi.php
EndomondoApi.generateCSRFToken
protected function generateCSRFToken() { try { parent::generateCSRFToken(); } catch (ClientException $e) { // too many request, sleep for a while if ($e->getCode() === 429) { throw new EndomondoApiException('Too many requests', $e->getCode(), $e); } throw new EndomondoApiException($e->getMessage(), $e->getCode(), $e); } }
php
protected function generateCSRFToken() { try { parent::generateCSRFToken(); } catch (ClientException $e) { // too many request, sleep for a while if ($e->getCode() === 429) { throw new EndomondoApiException('Too many requests', $e->getCode(), $e); } throw new EndomondoApiException($e->getMessage(), $e->getCode(), $e); } }
[ "protected", "function", "generateCSRFToken", "(", ")", "{", "try", "{", "parent", "::", "generateCSRFToken", "(", ")", ";", "}", "catch", "(", "ClientException", "$", "e", ")", "{", "// too many request, sleep for a while", "if", "(", "$", "e", "->", "getCode...
Generate csfr token. @return void @throws EndomondoApiException When generating fail
[ "Generate", "csfr", "token", "." ]
844b603a01b6237815fd186cfc11ee72594ae52b
https://github.com/fabulator/endomondo-api/blob/844b603a01b6237815fd186cfc11ee72594ae52b/lib/Fabulator/Endomondo/EndomondoApi.php#L31-L43
train
fabulator/endomondo-api
lib/Fabulator/Endomondo/EndomondoApi.php
EndomondoApi.getWorkoutBetween
public function getWorkoutBetween(\DateTime $from, \DateTime $to) { $workouts = $this->getWorkoutsUntil($to, 1); /* @var $workout Workout */ $workout = $workouts['workouts'][0]; if (!$workout) { return null; } if ($workout->getStart() > $from) { return $workout; } return null; }
php
public function getWorkoutBetween(\DateTime $from, \DateTime $to) { $workouts = $this->getWorkoutsUntil($to, 1); /* @var $workout Workout */ $workout = $workouts['workouts'][0]; if (!$workout) { return null; } if ($workout->getStart() > $from) { return $workout; } return null; }
[ "public", "function", "getWorkoutBetween", "(", "\\", "DateTime", "$", "from", ",", "\\", "DateTime", "$", "to", ")", "{", "$", "workouts", "=", "$", "this", "->", "getWorkoutsUntil", "(", "$", "to", ",", "1", ")", ";", "/* @var $workout Workout */", "$", ...
Try to find a single workout between two dates. @param \DateTime $from @param \DateTime $to @return Workout|null
[ "Try", "to", "find", "a", "single", "workout", "between", "two", "dates", "." ]
844b603a01b6237815fd186cfc11ee72594ae52b
https://github.com/fabulator/endomondo-api/blob/844b603a01b6237815fd186cfc11ee72594ae52b/lib/Fabulator/Endomondo/EndomondoApi.php#L208-L224
train
fabulator/endomondo-api
lib/Fabulator/Endomondo/EndomondoApi.php
EndomondoApi.getWorkoutsFromTo
public function getWorkoutsFromTo(\DateTime $from, \DateTime $to) { return $this->getWorkouts([ 'after' => $from->format('c'), 'before' => $to->format('c'), ]); }
php
public function getWorkoutsFromTo(\DateTime $from, \DateTime $to) { return $this->getWorkouts([ 'after' => $from->format('c'), 'before' => $to->format('c'), ]); }
[ "public", "function", "getWorkoutsFromTo", "(", "\\", "DateTime", "$", "from", ",", "\\", "DateTime", "$", "to", ")", "{", "return", "$", "this", "->", "getWorkouts", "(", "[", "'after'", "=>", "$", "from", "->", "format", "(", "'c'", ")", ",", "'befor...
Get all workouts between two dates. @param \DateTime $from @param \DateTime $to @return array $options { @var int $total Total found workout @var string $next Url for next workouts @var Workout[] $workout List of workouts }
[ "Get", "all", "workouts", "between", "two", "dates", "." ]
844b603a01b6237815fd186cfc11ee72594ae52b
https://github.com/fabulator/endomondo-api/blob/844b603a01b6237815fd186cfc11ee72594ae52b/lib/Fabulator/Endomondo/EndomondoApi.php#L237-L243
train
ahmedkhan847/mysqlwithelasticsearch
src/SearchElastic/Search.php
Search.search
public function search($query) { $this->validate($query); $client = $this->client->getClient(); $result = array(); // Change the match column name with the column name you want to search in it. $params = [ 'index' => $this->client->getIndex(), 'type' => $this->client->getType(), 'body' => [ 'query' => [ 'match' => [ $this->searchColumn => $query], ], ], ]; $query = $client->search($params); return $this->extractResult($query); }
php
public function search($query) { $this->validate($query); $client = $this->client->getClient(); $result = array(); // Change the match column name with the column name you want to search in it. $params = [ 'index' => $this->client->getIndex(), 'type' => $this->client->getType(), 'body' => [ 'query' => [ 'match' => [ $this->searchColumn => $query], ], ], ]; $query = $client->search($params); return $this->extractResult($query); }
[ "public", "function", "search", "(", "$", "query", ")", "{", "$", "this", "->", "validate", "(", "$", "query", ")", ";", "$", "client", "=", "$", "this", "->", "client", "->", "getClient", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";"...
Search in Elasticsearch. @param string $query @return Result from elasticsearch
[ "Search", "in", "Elasticsearch", "." ]
d30e169a0ae3ee04aac824d0037c53506b427be5
https://github.com/ahmedkhan847/mysqlwithelasticsearch/blob/d30e169a0ae3ee04aac824d0037c53506b427be5/src/SearchElastic/Search.php#L17-L35
train
ahmedkhan847/mysqlwithelasticsearch
src/ElasticSearchClient/Mapping.php
Mapping.createMapping
public function createMapping(array $map) { try { $elasticclient = $this->client->getClient(); $response = $elasticclient->indices()->create($map); return $response['acknowledged']; } catch (\Exception $ex) { return $ex->getMessage(); } }
php
public function createMapping(array $map) { try { $elasticclient = $this->client->getClient(); $response = $elasticclient->indices()->create($map); return $response['acknowledged']; } catch (\Exception $ex) { return $ex->getMessage(); } }
[ "public", "function", "createMapping", "(", "array", "$", "map", ")", "{", "try", "{", "$", "elasticclient", "=", "$", "this", "->", "client", "->", "getClient", "(", ")", ";", "$", "response", "=", "$", "elasticclient", "->", "indices", "(", ")", "->"...
Create mapping for Elasticsearch. @param array $map An array of elasticsearch mapping @return \ElasticSearchClient\ElasticSearchClient
[ "Create", "mapping", "for", "Elasticsearch", "." ]
d30e169a0ae3ee04aac824d0037c53506b427be5
https://github.com/ahmedkhan847/mysqlwithelasticsearch/blob/d30e169a0ae3ee04aac824d0037c53506b427be5/src/ElasticSearchClient/Mapping.php#L29-L38
train
ahmedkhan847/mysqlwithelasticsearch
src/ElasticSearchClient/Mapping.php
Mapping.deleteMapping
public function deleteMapping($index) { try { $elasticclient = $this->client->getClient(); $map = ['index' => $index]; $response = $elasticclient->indices()->delete($map); return $response['acknowledged']; } catch (\Exception $ex) { return $ex->getMessage(); } }
php
public function deleteMapping($index) { try { $elasticclient = $this->client->getClient(); $map = ['index' => $index]; $response = $elasticclient->indices()->delete($map); return $response['acknowledged']; } catch (\Exception $ex) { return $ex->getMessage(); } }
[ "public", "function", "deleteMapping", "(", "$", "index", ")", "{", "try", "{", "$", "elasticclient", "=", "$", "this", "->", "client", "->", "getClient", "(", ")", ";", "$", "map", "=", "[", "'index'", "=>", "$", "index", "]", ";", "$", "response", ...
Delete the previous mapping by passing its name @param $index Name of an exisiting index to delete @return \ElasticSearchClient\ElasticSearchClient
[ "Delete", "the", "previous", "mapping", "by", "passing", "its", "name" ]
d30e169a0ae3ee04aac824d0037c53506b427be5
https://github.com/ahmedkhan847/mysqlwithelasticsearch/blob/d30e169a0ae3ee04aac824d0037c53506b427be5/src/ElasticSearchClient/Mapping.php#L46-L56
train
ahmedkhan847/mysqlwithelasticsearch
src/SearchElastic/SearchAbstract/SearchAbstract.php
SearchAbstract.extractResult
protected function extractResult($query) { $result = null; $i = 0; $hits = sizeof($query['hits']['hits']); $hit = $query['hits']['hits']; $result['searchfound'] = $hits; while ($i < $hits) { $result['result'][$i] = $query['hits']['hits'][$i]['_source']; $i++; } return $result; }
php
protected function extractResult($query) { $result = null; $i = 0; $hits = sizeof($query['hits']['hits']); $hit = $query['hits']['hits']; $result['searchfound'] = $hits; while ($i < $hits) { $result['result'][$i] = $query['hits']['hits'][$i]['_source']; $i++; } return $result; }
[ "protected", "function", "extractResult", "(", "$", "query", ")", "{", "$", "result", "=", "null", ";", "$", "i", "=", "0", ";", "$", "hits", "=", "sizeof", "(", "$", "query", "[", "'hits'", "]", "[", "'hits'", "]", ")", ";", "$", "hit", "=", "...
Function to extract Search Result From ElasticSearch @param $query @return void
[ "Function", "to", "extract", "Search", "Result", "From", "ElasticSearch" ]
d30e169a0ae3ee04aac824d0037c53506b427be5
https://github.com/ahmedkhan847/mysqlwithelasticsearch/blob/d30e169a0ae3ee04aac824d0037c53506b427be5/src/SearchElastic/SearchAbstract/SearchAbstract.php#L62-L75
train
ahmedkhan847/mysqlwithelasticsearch
src/SearchElastic/SearchAbstract/SearchAbstract.php
SearchAbstract.validate
protected function validate($query) { if ($this->client->getIndex() == null) { throw new SearchException("Index cannot be null"); } if ($this->client->getType() == null) { throw new SearchException("Type cannot be null"); } if ($query == null) { throw new SearchException("Query can't be null"); } }
php
protected function validate($query) { if ($this->client->getIndex() == null) { throw new SearchException("Index cannot be null"); } if ($this->client->getType() == null) { throw new SearchException("Type cannot be null"); } if ($query == null) { throw new SearchException("Query can't be null"); } }
[ "protected", "function", "validate", "(", "$", "query", ")", "{", "if", "(", "$", "this", "->", "client", "->", "getIndex", "(", ")", "==", "null", ")", "{", "throw", "new", "SearchException", "(", "\"Index cannot be null\"", ")", ";", "}", "if", "(", ...
Function to validate Search @param string $query @return void
[ "Function", "to", "validate", "Search" ]
d30e169a0ae3ee04aac824d0037c53506b427be5
https://github.com/ahmedkhan847/mysqlwithelasticsearch/blob/d30e169a0ae3ee04aac824d0037c53506b427be5/src/SearchElastic/SearchAbstract/SearchAbstract.php#L94-L105
train
apollopy/flysystem-aliyun-oss
src/AliyunOssAdapter.php
AliyunOssAdapter.putFile
public function putFile($path, $localFilePath, Config $config) { $object = $this->applyPathPrefix($path); $options = $this->getOptionsFromConfig($config); $options[OssClient::OSS_CHECK_MD5] = true; if (! isset($options[OssClient::OSS_CONTENT_TYPE])) { $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, ''); } try { $this->client->uploadFile($this->bucket, $object, $localFilePath, $options); } catch (OssException $e) { return false; } $type = 'file'; $result = compact('type', 'path'); $result['mimetype'] = $options[OssClient::OSS_CONTENT_TYPE]; return $result; }
php
public function putFile($path, $localFilePath, Config $config) { $object = $this->applyPathPrefix($path); $options = $this->getOptionsFromConfig($config); $options[OssClient::OSS_CHECK_MD5] = true; if (! isset($options[OssClient::OSS_CONTENT_TYPE])) { $options[OssClient::OSS_CONTENT_TYPE] = Util::guessMimeType($path, ''); } try { $this->client->uploadFile($this->bucket, $object, $localFilePath, $options); } catch (OssException $e) { return false; } $type = 'file'; $result = compact('type', 'path'); $result['mimetype'] = $options[OssClient::OSS_CONTENT_TYPE]; return $result; }
[ "public", "function", "putFile", "(", "$", "path", ",", "$", "localFilePath", ",", "Config", "$", "config", ")", "{", "$", "object", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "path", ")", ";", "$", "options", "=", "$", "this", "->", "getOp...
Write using a local file path. @param string $path @param string $localFilePath @param Config $config Config object @return array|false false on failure file meta data on success
[ "Write", "using", "a", "local", "file", "path", "." ]
08081796cef20984858e4a7cd0f708e0ca1b0bc9
https://github.com/apollopy/flysystem-aliyun-oss/blob/08081796cef20984858e4a7cd0f708e0ca1b0bc9/src/AliyunOssAdapter.php#L95-L117
train
apollopy/flysystem-aliyun-oss
src/AliyunOssAdapter.php
AliyunOssAdapter.getSignedDownloadUrl
public function getSignedDownloadUrl($path, $expires = 3600, $host_name = '', $use_ssl = false) { $object = $this->applyPathPrefix($path); $url = $this->client->signUrl($this->bucket, $object, $expires); if (! empty($host_name) || $use_ssl) { $parse_url = parse_url($url); if (! empty($host_name)) { $parse_url['host'] = $this->bucket.'.'.$host_name; } if ($use_ssl) { $parse_url['scheme'] = 'https'; } $url = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '') .( isset($parse_url['user']) ? $parse_url['user'].(isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').'@' : '' ) .(isset($parse_url['host']) ? $parse_url['host'] : '') .(isset($parse_url['port']) ? ':'.$parse_url['port'] : '') .(isset($parse_url['path']) ? $parse_url['path'] : '') .(isset($parse_url['query']) ? '?'.$parse_url['query'] : ''); } return $url; }
php
public function getSignedDownloadUrl($path, $expires = 3600, $host_name = '', $use_ssl = false) { $object = $this->applyPathPrefix($path); $url = $this->client->signUrl($this->bucket, $object, $expires); if (! empty($host_name) || $use_ssl) { $parse_url = parse_url($url); if (! empty($host_name)) { $parse_url['host'] = $this->bucket.'.'.$host_name; } if ($use_ssl) { $parse_url['scheme'] = 'https'; } $url = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '') .( isset($parse_url['user']) ? $parse_url['user'].(isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').'@' : '' ) .(isset($parse_url['host']) ? $parse_url['host'] : '') .(isset($parse_url['port']) ? ':'.$parse_url['port'] : '') .(isset($parse_url['path']) ? $parse_url['path'] : '') .(isset($parse_url['query']) ? '?'.$parse_url['query'] : ''); } return $url; }
[ "public", "function", "getSignedDownloadUrl", "(", "$", "path", ",", "$", "expires", "=", "3600", ",", "$", "host_name", "=", "''", ",", "$", "use_ssl", "=", "false", ")", "{", "$", "object", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "path",...
Get the signed download url of a file. @param string $path @param int $expires @param string $host_name @param bool $use_ssl @return string
[ "Get", "the", "signed", "download", "url", "of", "a", "file", "." ]
08081796cef20984858e4a7cd0f708e0ca1b0bc9
https://github.com/apollopy/flysystem-aliyun-oss/blob/08081796cef20984858e4a7cd0f708e0ca1b0bc9/src/AliyunOssAdapter.php#L442-L469
train
nilportugues/php-backslasher
src/BackslashFixer/Fixer/FileEditor.php
FileEditor.removeUseFunctionsFromBackslashing
private function removeUseFunctionsFromBackslashing(FileGenerator $generator, array $functions) { foreach ($generator->getUses() as $namespacedFunction) { list($functionOrClass) = $namespacedFunction; if (\function_exists($functionOrClass)) { $function = \explode("\\", $functionOrClass); $function = \array_pop($function); if (!empty($functions[$function])) { unset($functions[$function]); } } } return $functions; }
php
private function removeUseFunctionsFromBackslashing(FileGenerator $generator, array $functions) { foreach ($generator->getUses() as $namespacedFunction) { list($functionOrClass) = $namespacedFunction; if (\function_exists($functionOrClass)) { $function = \explode("\\", $functionOrClass); $function = \array_pop($function); if (!empty($functions[$function])) { unset($functions[$function]); } } } return $functions; }
[ "private", "function", "removeUseFunctionsFromBackslashing", "(", "FileGenerator", "$", "generator", ",", "array", "$", "functions", ")", "{", "foreach", "(", "$", "generator", "->", "getUses", "(", ")", "as", "$", "namespacedFunction", ")", "{", "list", "(", ...
If a method exists under a namespace and has been aliased, or has been imported, don't replace. @param FileGenerator $generator @param array $functions @return array
[ "If", "a", "method", "exists", "under", "a", "namespace", "and", "has", "been", "aliased", "or", "has", "been", "imported", "don", "t", "replace", "." ]
e55984ef50b60c165b5f204a6ffb2756ee1592b2
https://github.com/nilportugues/php-backslasher/blob/e55984ef50b60c165b5f204a6ffb2756ee1592b2/src/BackslashFixer/Fixer/FileEditor.php#L103-L119
train
dunglas/php-torcontrol
src/TorControl.php
TorControl.detectAuthMethod
private function detectAuthMethod() { $data = $this->executeCommand('PROTOCOLINFO'); foreach ($data as $info) { if ('AUTH METHODS=NULL' === $info['message']) { $this->options['authmethod'] = static::AUTH_METHOD_NULL; return; } if ('AUTH METHODS=HASHEDPASSWORD' === $info['message']) { $this->options['authmethod'] = static::AUTH_METHOD_HASHEDPASSWORD; return; } if (preg_match('/^AUTH METHODS=(.*) COOKIEFILE="(.*)"/', $info['message'], $matches) === 1) { $this->options['authmethod'] = static::AUTH_METHOD_COOKIE; $this->options['cookiefile'] = $matches[2]; return; } } throw new Exception\ProtocolError('Auth method not supported'); }
php
private function detectAuthMethod() { $data = $this->executeCommand('PROTOCOLINFO'); foreach ($data as $info) { if ('AUTH METHODS=NULL' === $info['message']) { $this->options['authmethod'] = static::AUTH_METHOD_NULL; return; } if ('AUTH METHODS=HASHEDPASSWORD' === $info['message']) { $this->options['authmethod'] = static::AUTH_METHOD_HASHEDPASSWORD; return; } if (preg_match('/^AUTH METHODS=(.*) COOKIEFILE="(.*)"/', $info['message'], $matches) === 1) { $this->options['authmethod'] = static::AUTH_METHOD_COOKIE; $this->options['cookiefile'] = $matches[2]; return; } } throw new Exception\ProtocolError('Auth method not supported'); }
[ "private", "function", "detectAuthMethod", "(", ")", "{", "$", "data", "=", "$", "this", "->", "executeCommand", "(", "'PROTOCOLINFO'", ")", ";", "foreach", "(", "$", "data", "as", "$", "info", ")", "{", "if", "(", "'AUTH METHODS=NULL'", "===", "$", "inf...
Detects auth method using the PROTOCOLINFO command. @throws Exception\ProtocolError
[ "Detects", "auth", "method", "using", "the", "PROTOCOLINFO", "command", "." ]
ef908baf586acbc36dac4a2eed3a560894ffafee
https://github.com/dunglas/php-torcontrol/blob/ef908baf586acbc36dac4a2eed3a560894ffafee/src/TorControl.php#L79-L105
train
dunglas/php-torcontrol
src/TorControl.php
TorControl.connect
public function connect() { if ($this->connected) { return; } $this->socket = @fsockopen($this->options['hostname'], $this->options['port'], $errno, $errstr, $this->options['timeout']); if (!$this->socket) { throw new Exception\IOError($errno.' - '.$errstr); } $this->connected = true; return $this; }
php
public function connect() { if ($this->connected) { return; } $this->socket = @fsockopen($this->options['hostname'], $this->options['port'], $errno, $errstr, $this->options['timeout']); if (!$this->socket) { throw new Exception\IOError($errno.' - '.$errstr); } $this->connected = true; return $this; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "$", "this", "->", "connected", ")", "{", "return", ";", "}", "$", "this", "->", "socket", "=", "@", "fsockopen", "(", "$", "this", "->", "options", "[", "'hostname'", "]", ",", "$", "this"...
Connects to the Tor server. @throws Exception\IOError @return \TorControl\TorControl
[ "Connects", "to", "the", "Tor", "server", "." ]
ef908baf586acbc36dac4a2eed3a560894ffafee
https://github.com/dunglas/php-torcontrol/blob/ef908baf586acbc36dac4a2eed3a560894ffafee/src/TorControl.php#L168-L182
train
dunglas/php-torcontrol
src/TorControl.php
TorControl.authenticate
public function authenticate() { if (static::AUTH_METHOD_NOT_SET === $this->options['authmethod']) { $this->detectAuthMethod(); } switch ($this->options['authmethod']) { case static::AUTH_METHOD_NULL: $this->executeCommand('AUTHENTICATE'); break; case static::AUTH_METHOD_HASHEDPASSWORD: $password = $this->getOption('password'); if (false === $password) { throw new \Exception('You must set a password option'); } $this->executeCommand('AUTHENTICATE '.static::quote($password)); break; case static::AUTH_METHOD_COOKIE: $cookieFile = $this->getOption('cookiefile'); if (false === $cookieFile) { throw new \Exception('You must set a cookiefile option'); } $cookie = file_get_contents($cookieFile); $this->executeCommand('AUTHENTICATE '.bin2hex($cookie)); break; } return $this; }
php
public function authenticate() { if (static::AUTH_METHOD_NOT_SET === $this->options['authmethod']) { $this->detectAuthMethod(); } switch ($this->options['authmethod']) { case static::AUTH_METHOD_NULL: $this->executeCommand('AUTHENTICATE'); break; case static::AUTH_METHOD_HASHEDPASSWORD: $password = $this->getOption('password'); if (false === $password) { throw new \Exception('You must set a password option'); } $this->executeCommand('AUTHENTICATE '.static::quote($password)); break; case static::AUTH_METHOD_COOKIE: $cookieFile = $this->getOption('cookiefile'); if (false === $cookieFile) { throw new \Exception('You must set a cookiefile option'); } $cookie = file_get_contents($cookieFile); $this->executeCommand('AUTHENTICATE '.bin2hex($cookie)); break; } return $this; }
[ "public", "function", "authenticate", "(", ")", "{", "if", "(", "static", "::", "AUTH_METHOD_NOT_SET", "===", "$", "this", "->", "options", "[", "'authmethod'", "]", ")", "{", "$", "this", "->", "detectAuthMethod", "(", ")", ";", "}", "switch", "(", "$",...
Authenticates to the Tor server. Autodetect authentication method if not set in options @throws \Exception @return \TorControl\TorControl
[ "Authenticates", "to", "the", "Tor", "server", "." ]
ef908baf586acbc36dac4a2eed3a560894ffafee
https://github.com/dunglas/php-torcontrol/blob/ef908baf586acbc36dac4a2eed3a560894ffafee/src/TorControl.php#L193-L225
train
dunglas/php-torcontrol
src/TorControl.php
TorControl.executeCommand
public function executeCommand($cmd) { $this->checkConnected(); $write = @fwrite($this->socket, "$cmd\r\n"); if (false === $write) { throw new Exception\IOError('Error while writing to the Tor server'); } $data = []; while (true) { $response = fread($this->socket, 1024); $multiline = false; $last_code = null; $last_separator = null; foreach (explode("\r\n", $response) as $line) { $code = substr($line, 0, 3); $separator = substr($line, 3, 1); $message = substr($line, 4); if ('+' === $separator) { $multiline = true; $last_code = $code; $last_separator = $separator; } if ($multiline) { $data[] = [ 'code' => $last_code, 'separator' => $last_separator, 'message' => $line, ]; } else { if (false === $code || false === $separator) { $e = new Exception\ProtocolError('Bad response format'); $e->setResponse($response); throw $e; } if (!in_array($separator, [' ', '+', '-'])) { $e = new Exception\ProtocolError('Unknown separator'); $e->setResponse($response); throw $e; } if (!in_array(substr($code, 0, 1), ['2', '6'])) { $e = new Exception\TorError($message, $code); $e->setResponse($response); return $e; } $data[] = [ 'code' => $code, 'separator' => $separator, 'message' => $message, ]; } if (' ' === $separator) { break 2; } } } return $data; }
php
public function executeCommand($cmd) { $this->checkConnected(); $write = @fwrite($this->socket, "$cmd\r\n"); if (false === $write) { throw new Exception\IOError('Error while writing to the Tor server'); } $data = []; while (true) { $response = fread($this->socket, 1024); $multiline = false; $last_code = null; $last_separator = null; foreach (explode("\r\n", $response) as $line) { $code = substr($line, 0, 3); $separator = substr($line, 3, 1); $message = substr($line, 4); if ('+' === $separator) { $multiline = true; $last_code = $code; $last_separator = $separator; } if ($multiline) { $data[] = [ 'code' => $last_code, 'separator' => $last_separator, 'message' => $line, ]; } else { if (false === $code || false === $separator) { $e = new Exception\ProtocolError('Bad response format'); $e->setResponse($response); throw $e; } if (!in_array($separator, [' ', '+', '-'])) { $e = new Exception\ProtocolError('Unknown separator'); $e->setResponse($response); throw $e; } if (!in_array(substr($code, 0, 1), ['2', '6'])) { $e = new Exception\TorError($message, $code); $e->setResponse($response); return $e; } $data[] = [ 'code' => $code, 'separator' => $separator, 'message' => $message, ]; } if (' ' === $separator) { break 2; } } } return $data; }
[ "public", "function", "executeCommand", "(", "$", "cmd", ")", "{", "$", "this", "->", "checkConnected", "(", ")", ";", "$", "write", "=", "@", "fwrite", "(", "$", "this", "->", "socket", ",", "\"$cmd\\r\\n\"", ")", ";", "if", "(", "false", "===", "$"...
Executes a command on the Tor server. @param string $cmd @throws Exception\IOError @throws Exception\ProtocolError @return array
[ "Executes", "a", "command", "on", "the", "Tor", "server", "." ]
ef908baf586acbc36dac4a2eed3a560894ffafee
https://github.com/dunglas/php-torcontrol/blob/ef908baf586acbc36dac4a2eed3a560894ffafee/src/TorControl.php#L237-L306
train
dunglas/php-torcontrol
src/TorControl.php
TorControl.quit
public function quit() { if ($this->connected && $this->socket) { $this->executeCommand('QUIT'); $close = @fclose($this->socket); if (!$close) { throw new Exception\IOError('Error while closing the connection to the Tor server'); } } $this->connected = false; }
php
public function quit() { if ($this->connected && $this->socket) { $this->executeCommand('QUIT'); $close = @fclose($this->socket); if (!$close) { throw new Exception\IOError('Error while closing the connection to the Tor server'); } } $this->connected = false; }
[ "public", "function", "quit", "(", ")", "{", "if", "(", "$", "this", "->", "connected", "&&", "$", "this", "->", "socket", ")", "{", "$", "this", "->", "executeCommand", "(", "'QUIT'", ")", ";", "$", "close", "=", "@", "fclose", "(", "$", "this", ...
Closes the connection to the Tor server.
[ "Closes", "the", "connection", "to", "the", "Tor", "server", "." ]
ef908baf586acbc36dac4a2eed3a560894ffafee
https://github.com/dunglas/php-torcontrol/blob/ef908baf586acbc36dac4a2eed3a560894ffafee/src/TorControl.php#L311-L322
train
KnpLabs/rad-resource-resolver
src/Knp/Rad/ResourceResolver/RoutingNormalizer.php
RoutingNormalizer.normalizeDeclaration
public function normalizeDeclaration($declaration) { if (is_string($declaration)) { return $this->normalizeString($declaration); } // Normalize numerically indexed array if (array_keys($declaration) === array_keys(array_values($declaration))) { return $this->normalizeArray($declaration); } if (isset($declaration['arguments']) && !is_array($declaration['arguments'])) { throw new \InvalidArgumentException('The "arguments" parameter should be an array of arguments.'); } // Adds default value to associative array return array_merge(['method' => null, 'required' => true, 'arguments' => []], $declaration); }
php
public function normalizeDeclaration($declaration) { if (is_string($declaration)) { return $this->normalizeString($declaration); } // Normalize numerically indexed array if (array_keys($declaration) === array_keys(array_values($declaration))) { return $this->normalizeArray($declaration); } if (isset($declaration['arguments']) && !is_array($declaration['arguments'])) { throw new \InvalidArgumentException('The "arguments" parameter should be an array of arguments.'); } // Adds default value to associative array return array_merge(['method' => null, 'required' => true, 'arguments' => []], $declaration); }
[ "public", "function", "normalizeDeclaration", "(", "$", "declaration", ")", "{", "if", "(", "is_string", "(", "$", "declaration", ")", ")", "{", "return", "$", "this", "->", "normalizeString", "(", "$", "declaration", ")", ";", "}", "// Normalize numerically i...
Normalizes string and array declarations into associative array. @param string|array $declaration @return array
[ "Normalizes", "string", "and", "array", "declarations", "into", "associative", "array", "." ]
e4ece8d1fa8cbc984c98a27f6025002d3b449f56
https://github.com/KnpLabs/rad-resource-resolver/blob/e4ece8d1fa8cbc984c98a27f6025002d3b449f56/src/Knp/Rad/ResourceResolver/RoutingNormalizer.php#L14-L31
train
ouqiang/etcd-php
src/Client.php
Client.put
public function put($key, $value, array $options = []) { $params = [ 'key' => $key, 'value' => $value, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_PUT, $params, $options); $body = $this->decodeBodyForFields( $body, 'prev_kv', ['key', 'value',] ); if (isset($body['prev_kv']) && $this->pretty) { return $this->convertFields($body['prev_kv']); } return $body; }
php
public function put($key, $value, array $options = []) { $params = [ 'key' => $key, 'value' => $value, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_PUT, $params, $options); $body = $this->decodeBodyForFields( $body, 'prev_kv', ['key', 'value',] ); if (isset($body['prev_kv']) && $this->pretty) { return $this->convertFields($body['prev_kv']); } return $body; }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "[", "'key'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ",", "]", ";", "$", "params", "=", ...
Put puts the given key into the key-value store. A put request increments the revision of the key-value store\nand generates one event in the event history. @param string $key @param string $value @param array $options 可选参数 int64 lease bool prev_kv bool ignore_value bool ignore_lease @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "Put", "puts", "the", "given", "key", "into", "the", "key", "-", "value", "store", ".", "A", "put", "request", "increments", "the", "revision", "of", "the", "key", "-", "value", "store", "\\", "nand", "generates", "one", "event", "in", "the", "event", ...
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L127-L148
train
ouqiang/etcd-php
src/Client.php
Client.get
public function get($key, array $options = []) { $params = [ 'key' => $key, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_RANGE, $params, $options); $body = $this->decodeBodyForFields( $body, 'kvs', ['key', 'value',] ); if (isset($body['kvs']) && $this->pretty) { return $this->convertFields($body['kvs']); } return $body; }
php
public function get($key, array $options = []) { $params = [ 'key' => $key, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_RANGE, $params, $options); $body = $this->decodeBodyForFields( $body, 'kvs', ['key', 'value',] ); if (isset($body['kvs']) && $this->pretty) { return $this->convertFields($body['kvs']); } return $body; }
[ "public", "function", "get", "(", "$", "key", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "[", "'key'", "=>", "$", "key", ",", "]", ";", "$", "params", "=", "$", "this", "->", "encode", "(", "$", "params", ")", ...
Gets the key or a range of keys @param string $key @param array $options string range_end int limit int revision int sort_order int sort_target bool serializable bool keys_only bool count_only int64 min_mod_revision int64 max_mod_revision int64 min_create_revision int64 max_create_revision @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "Gets", "the", "key", "or", "a", "range", "of", "keys" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L170-L189
train
ouqiang/etcd-php
src/Client.php
Client.getKeysWithPrefix
public function getKeysWithPrefix($prefix) { $prefix = trim($prefix); if (!$prefix) { return []; } $lastIndex = strlen($prefix) - 1; $lastChar = $prefix[$lastIndex]; $nextAsciiCode = ord($lastChar) + 1; $rangeEnd = $prefix; $rangeEnd[$lastIndex] = chr($nextAsciiCode); return $this->get($prefix, ['range_end' => $rangeEnd]); }
php
public function getKeysWithPrefix($prefix) { $prefix = trim($prefix); if (!$prefix) { return []; } $lastIndex = strlen($prefix) - 1; $lastChar = $prefix[$lastIndex]; $nextAsciiCode = ord($lastChar) + 1; $rangeEnd = $prefix; $rangeEnd[$lastIndex] = chr($nextAsciiCode); return $this->get($prefix, ['range_end' => $rangeEnd]); }
[ "public", "function", "getKeysWithPrefix", "(", "$", "prefix", ")", "{", "$", "prefix", "=", "trim", "(", "$", "prefix", ")", ";", "if", "(", "!", "$", "prefix", ")", "{", "return", "[", "]", ";", "}", "$", "lastIndex", "=", "strlen", "(", "$", "...
get all keys with prefix @param string $prefix @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "get", "all", "keys", "with", "prefix" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L209-L222
train
ouqiang/etcd-php
src/Client.php
Client.del
public function del($key, array $options = []) { $params = [ 'key' => $key, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_DELETE_RANGE, $params, $options); $body = $this->decodeBodyForFields( $body, 'prev_kvs', ['key', 'value',] ); if (isset($body['prev_kvs']) && $this->pretty) { return $this->convertFields($body['prev_kvs']); } return $body; }
php
public function del($key, array $options = []) { $params = [ 'key' => $key, ]; $params = $this->encode($params); $options = $this->encode($options); $body = $this->request(self::URI_DELETE_RANGE, $params, $options); $body = $this->decodeBodyForFields( $body, 'prev_kvs', ['key', 'value',] ); if (isset($body['prev_kvs']) && $this->pretty) { return $this->convertFields($body['prev_kvs']); } return $body; }
[ "public", "function", "del", "(", "$", "key", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "params", "=", "[", "'key'", "=>", "$", "key", ",", "]", ";", "$", "params", "=", "$", "this", "->", "encode", "(", "$", "params", ")", ...
Removes the specified key or range of keys @param string $key @param array $options string range_end bool prev_kv @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "Removes", "the", "specified", "key", "or", "range", "of", "keys" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L234-L253
train
ouqiang/etcd-php
src/Client.php
Client.compaction
public function compaction($revision, $physical = false) { $params = [ 'revision' => $revision, 'physical' => $physical, ]; $body = $this->request(self::URI_COMPACTION, $params); return $body; }
php
public function compaction($revision, $physical = false) { $params = [ 'revision' => $revision, 'physical' => $physical, ]; $body = $this->request(self::URI_COMPACTION, $params); return $body; }
[ "public", "function", "compaction", "(", "$", "revision", ",", "$", "physical", "=", "false", ")", "{", "$", "params", "=", "[", "'revision'", "=>", "$", "revision", ",", "'physical'", "=>", "$", "physical", ",", "]", ";", "$", "body", "=", "$", "thi...
Compact compacts the event history in the etcd key-value store. The key-value\nstore should be periodically compacted or the event history will continue to grow\nindefinitely. @param int $revision @param bool|false $physical @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "Compact", "compacts", "the", "event", "history", "in", "the", "etcd", "key", "-", "value", "store", ".", "The", "key", "-", "value", "\\", "nstore", "should", "be", "periodically", "compacted", "or", "the", "event", "history", "will", "continue", "to", "g...
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L267-L277
train
ouqiang/etcd-php
src/Client.php
Client.grant
public function grant($ttl, $id = 0) { $params = [ 'TTL' => $ttl, 'ID' => $id, ]; $body = $this->request(self::URI_GRANT, $params); return $body; }
php
public function grant($ttl, $id = 0) { $params = [ 'TTL' => $ttl, 'ID' => $id, ]; $body = $this->request(self::URI_GRANT, $params); return $body; }
[ "public", "function", "grant", "(", "$", "ttl", ",", "$", "id", "=", "0", ")", "{", "$", "params", "=", "[", "'TTL'", "=>", "$", "ttl", ",", "'ID'", "=>", "$", "id", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", ...
LeaseGrant creates a lease which expires if the server does not receive a keepAlive\nwithin a given time to live period. All keys attached to the lease will be expired and\ndeleted if the lease expires. Each expired key generates a delete event in the event history.", @param int $ttl TTL is the advisory time-to-live in seconds. @param int $id ID is the requested ID for the lease. If ID is set to 0, the lessor chooses an ID. @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "LeaseGrant", "creates", "a", "lease", "which", "expires", "if", "the", "server", "does", "not", "receive", "a", "keepAlive", "\\", "nwithin", "a", "given", "time", "to", "live", "period", ".", "All", "keys", "attached", "to", "the", "lease", "will", "be",...
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L295-L306
train
ouqiang/etcd-php
src/Client.php
Client.revoke
public function revoke($id) { $params = [ 'ID' => $id, ]; $body = $this->request(self::URI_REVOKE, $params); return $body; }
php
public function revoke($id) { $params = [ 'ID' => $id, ]; $body = $this->request(self::URI_REVOKE, $params); return $body; }
[ "public", "function", "revoke", "(", "$", "id", ")", "{", "$", "params", "=", "[", "'ID'", "=>", "$", "id", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_REVOKE", ",", "$", "params", ")", ";", "return", ...
revokes a lease. All keys attached to the lease will expire and be deleted. @param int $id ID is the lease ID to revoke. When the ID is revoked, all associated keys will be deleted. @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "revokes", "a", "lease", ".", "All", "keys", "attached", "to", "the", "lease", "will", "expire", "and", "be", "deleted", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L316-L325
train
ouqiang/etcd-php
src/Client.php
Client.keepAlive
public function keepAlive($id) { $params = [ 'ID' => $id, ]; $body = $this->request(self::URI_KEEPALIVE, $params); if (!isset($body['result'])) { return $body; } // response "result" field, etcd bug? return [ 'ID' => $body['result']['ID'], 'TTL' => $body['result']['TTL'], ]; }
php
public function keepAlive($id) { $params = [ 'ID' => $id, ]; $body = $this->request(self::URI_KEEPALIVE, $params); if (!isset($body['result'])) { return $body; } // response "result" field, etcd bug? return [ 'ID' => $body['result']['ID'], 'TTL' => $body['result']['TTL'], ]; }
[ "public", "function", "keepAlive", "(", "$", "id", ")", "{", "$", "params", "=", "[", "'ID'", "=>", "$", "id", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_KEEPALIVE", ",", "$", "params", ")", ";", "if", ...
keeps the lease alive by streaming keep alive requests from the client\nto the server and streaming keep alive responses from the server to the client. @param int $id ID is the lease ID for the lease to keep alive. @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "keeps", "the", "lease", "alive", "by", "streaming", "keep", "alive", "requests", "from", "the", "client", "\\", "nto", "the", "server", "and", "streaming", "keep", "alive", "responses", "from", "the", "server", "to", "the", "client", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L336-L352
train
ouqiang/etcd-php
src/Client.php
Client.timeToLive
public function timeToLive($id, $keys = false) { $params = [ 'ID' => $id, 'keys' => $keys, ]; $body = $this->request(self::URI_TIMETOLIVE, $params); if (isset($body['keys'])) { $body['keys'] = array_map(function($value) { return base64_decode($value); }, $body['keys']); } return $body; }
php
public function timeToLive($id, $keys = false) { $params = [ 'ID' => $id, 'keys' => $keys, ]; $body = $this->request(self::URI_TIMETOLIVE, $params); if (isset($body['keys'])) { $body['keys'] = array_map(function($value) { return base64_decode($value); }, $body['keys']); } return $body; }
[ "public", "function", "timeToLive", "(", "$", "id", ",", "$", "keys", "=", "false", ")", "{", "$", "params", "=", "[", "'ID'", "=>", "$", "id", ",", "'keys'", "=>", "$", "keys", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "("...
retrieves lease information. @param int $id ID is the lease ID for the lease. @param bool|false $keys @return array @throws BadResponseException
[ "retrieves", "lease", "information", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L362-L378
train
ouqiang/etcd-php
src/Client.php
Client.addRole
public function addRole($name) { $params = [ 'name' => $name, ]; $body = $this->request(self::URI_AUTH_ROLE_ADD, $params); return $body; }
php
public function addRole($name) { $params = [ 'name' => $name, ]; $body = $this->request(self::URI_AUTH_ROLE_ADD, $params); return $body; }
[ "public", "function", "addRole", "(", "$", "name", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "name", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_ROLE_ADD", ",", "$", "params", ")", ";", ...
add a new role. @param string $name @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "add", "a", "new", "role", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L440-L449
train
ouqiang/etcd-php
src/Client.php
Client.getRole
public function getRole($role) { $params = [ 'role' => $role, ]; $body = $this->request(self::URI_AUTH_ROLE_GET, $params); $body = $this->decodeBodyForFields( $body, 'perm', ['key', 'range_end',] ); if ($this->pretty && isset($body['perm'])) { return $body['perm']; } return $body; }
php
public function getRole($role) { $params = [ 'role' => $role, ]; $body = $this->request(self::URI_AUTH_ROLE_GET, $params); $body = $this->decodeBodyForFields( $body, 'perm', ['key', 'range_end',] ); if ($this->pretty && isset($body['perm'])) { return $body['perm']; } return $body; }
[ "public", "function", "getRole", "(", "$", "role", ")", "{", "$", "params", "=", "[", "'role'", "=>", "$", "role", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_ROLE_GET", ",", "$", "params", ")", ";", ...
get detailed role information. @param string $role @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "get", "detailed", "role", "information", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L458-L475
train
ouqiang/etcd-php
src/Client.php
Client.deleteRole
public function deleteRole($role) { $params = [ 'role' => $role, ]; $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params); return $body; }
php
public function deleteRole($role) { $params = [ 'role' => $role, ]; $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params); return $body; }
[ "public", "function", "deleteRole", "(", "$", "role", ")", "{", "$", "params", "=", "[", "'role'", "=>", "$", "role", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_ROLE_DELETE", ",", "$", "params", ")", ...
delete a specified role. @param string $role @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "delete", "a", "specified", "role", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L484-L493
train
ouqiang/etcd-php
src/Client.php
Client.roleList
public function roleList() { $body = $this->request(self::URI_AUTH_ROLE_LIST); if ($this->pretty && isset($body['roles'])) { return $body['roles']; } return $body; }
php
public function roleList() { $body = $this->request(self::URI_AUTH_ROLE_LIST); if ($this->pretty && isset($body['roles'])) { return $body['roles']; } return $body; }
[ "public", "function", "roleList", "(", ")", "{", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_ROLE_LIST", ")", ";", "if", "(", "$", "this", "->", "pretty", "&&", "isset", "(", "$", "body", "[", "'roles'", "]", ")", "...
get lists of all roles @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "get", "lists", "of", "all", "roles" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L501-L510
train
ouqiang/etcd-php
src/Client.php
Client.addUser
public function addUser($user, $password) { $params = [ 'name' => $user, 'password' => $password, ]; $body = $this->request(self::URI_AUTH_USER_ADD, $params); return $body; }
php
public function addUser($user, $password) { $params = [ 'name' => $user, 'password' => $password, ]; $body = $this->request(self::URI_AUTH_USER_ADD, $params); return $body; }
[ "public", "function", "addUser", "(", "$", "user", ",", "$", "password", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "user", ",", "'password'", "=>", "$", "password", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", ...
add a new user @param string $user @param string $password @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "add", "a", "new", "user" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L520-L530
train
ouqiang/etcd-php
src/Client.php
Client.getUser
public function getUser($user) { $params = [ 'name' => $user, ]; $body = $this->request(self::URI_AUTH_USER_GET, $params); if ($this->pretty && isset($body['roles'])) { return $body['roles']; } return $body; }
php
public function getUser($user) { $params = [ 'name' => $user, ]; $body = $this->request(self::URI_AUTH_USER_GET, $params); if ($this->pretty && isset($body['roles'])) { return $body['roles']; } return $body; }
[ "public", "function", "getUser", "(", "$", "user", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "user", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_USER_GET", ",", "$", "params", ")", ";", ...
get detailed user information @param string $user @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "get", "detailed", "user", "information" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L539-L551
train
ouqiang/etcd-php
src/Client.php
Client.deleteUser
public function deleteUser($user) { $params = [ 'name' => $user, ]; $body = $this->request(self::URI_AUTH_USER_DELETE, $params); return $body; }
php
public function deleteUser($user) { $params = [ 'name' => $user, ]; $body = $this->request(self::URI_AUTH_USER_DELETE, $params); return $body; }
[ "public", "function", "deleteUser", "(", "$", "user", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "user", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_USER_DELETE", ",", "$", "params", ")", ...
delete a specified user @param string $user @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "delete", "a", "specified", "user" ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L560-L569
train
ouqiang/etcd-php
src/Client.php
Client.userList
public function userList() { $body = $this->request(self::URI_AUTH_USER_LIST); if ($this->pretty && isset($body['users'])) { return $body['users']; } return $body; }
php
public function userList() { $body = $this->request(self::URI_AUTH_USER_LIST); if ($this->pretty && isset($body['users'])) { return $body['users']; } return $body; }
[ "public", "function", "userList", "(", ")", "{", "$", "body", "=", "$", "this", "->", "request", "(", "self", "::", "URI_AUTH_USER_LIST", ")", ";", "if", "(", "$", "this", "->", "pretty", "&&", "isset", "(", "$", "body", "[", "'users'", "]", ")", "...
get a list of all users. @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "get", "a", "list", "of", "all", "users", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L577-L585
train
ouqiang/etcd-php
src/Client.php
Client.changeUserPassword
public function changeUserPassword($user, $password) { $params = [ 'name' => $user, 'password' => $password, ]; $body = $this->request(self::URI_AUTH_USER_CHANGE_PASSWORD, $params); return $body; }
php
public function changeUserPassword($user, $password) { $params = [ 'name' => $user, 'password' => $password, ]; $body = $this->request(self::URI_AUTH_USER_CHANGE_PASSWORD, $params); return $body; }
[ "public", "function", "changeUserPassword", "(", "$", "user", ",", "$", "password", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "user", ",", "'password'", "=>", "$", "password", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request...
change the password of a specified user. @param string $user @param string $password @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "change", "the", "password", "of", "a", "specified", "user", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L595-L605
train
ouqiang/etcd-php
src/Client.php
Client.grantRolePermission
public function grantRolePermission($role, $permType, $key, $rangeEnd = null) { $params = [ 'name' => $role, 'perm' => [ 'permType' => $permType, 'key' => base64_encode($key), ], ]; if ($rangeEnd !== null) { $params['perm']['range_end'] = base64_encode($rangeEnd); } $body = $this->request(self::URI_AUTH_ROLE_GRANT, $params); return $body; }
php
public function grantRolePermission($role, $permType, $key, $rangeEnd = null) { $params = [ 'name' => $role, 'perm' => [ 'permType' => $permType, 'key' => base64_encode($key), ], ]; if ($rangeEnd !== null) { $params['perm']['range_end'] = base64_encode($rangeEnd); } $body = $this->request(self::URI_AUTH_ROLE_GRANT, $params); return $body; }
[ "public", "function", "grantRolePermission", "(", "$", "role", ",", "$", "permType", ",", "$", "key", ",", "$", "rangeEnd", "=", "null", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "role", ",", "'perm'", "=>", "[", "'permType'", "=>", "$"...
grant a permission of a specified key or range to a specified role. @param string $role @param int $permType @param string $key @param string|null $rangeEnd @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "grant", "a", "permission", "of", "a", "specified", "key", "or", "range", "to", "a", "specified", "role", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L617-L633
train
ouqiang/etcd-php
src/Client.php
Client.revokeRolePermission
public function revokeRolePermission($role, $key, $rangeEnd = null) { $params = [ 'role' => $role, 'key' => $key, ]; if ($rangeEnd !== null) { $params['range_end'] = $rangeEnd; } $body = $this->request(self::URI_AUTH_ROLE_REVOKE, $params); return $body; }
php
public function revokeRolePermission($role, $key, $rangeEnd = null) { $params = [ 'role' => $role, 'key' => $key, ]; if ($rangeEnd !== null) { $params['range_end'] = $rangeEnd; } $body = $this->request(self::URI_AUTH_ROLE_REVOKE, $params); return $body; }
[ "public", "function", "revokeRolePermission", "(", "$", "role", ",", "$", "key", ",", "$", "rangeEnd", "=", "null", ")", "{", "$", "params", "=", "[", "'role'", "=>", "$", "role", ",", "'key'", "=>", "$", "key", ",", "]", ";", "if", "(", "$", "ra...
revoke a key or range permission of a specified role. @param string $role @param string $key @param string|null $rangeEnd @return array @throws BadResponseException
[ "revoke", "a", "key", "or", "range", "permission", "of", "a", "specified", "role", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L644-L657
train
ouqiang/etcd-php
src/Client.php
Client.grantUserRole
public function grantUserRole($user, $role) { $params = [ 'user' => $user, 'role' => $role, ]; $body = $this->request(self::URI_AUTH_USER_GRANT, $params); return $body; }
php
public function grantUserRole($user, $role) { $params = [ 'user' => $user, 'role' => $role, ]; $body = $this->request(self::URI_AUTH_USER_GRANT, $params); return $body; }
[ "public", "function", "grantUserRole", "(", "$", "user", ",", "$", "role", ")", "{", "$", "params", "=", "[", "'user'", "=>", "$", "user", ",", "'role'", "=>", "$", "role", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "self...
grant a role to a specified user. @param string $user @param string $role @return array @throws BadResponseException
[ "grant", "a", "role", "to", "a", "specified", "user", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L667-L677
train
ouqiang/etcd-php
src/Client.php
Client.revokeUserRole
public function revokeUserRole($user, $role) { $params = [ 'name' => $user, 'role' => $role, ]; $body = $this->request(self::URI_AUTH_USER_REVOKE, $params); return $body; }
php
public function revokeUserRole($user, $role) { $params = [ 'name' => $user, 'role' => $role, ]; $body = $this->request(self::URI_AUTH_USER_REVOKE, $params); return $body; }
[ "public", "function", "revokeUserRole", "(", "$", "user", ",", "$", "role", ")", "{", "$", "params", "=", "[", "'name'", "=>", "$", "user", ",", "'role'", "=>", "$", "role", ",", "]", ";", "$", "body", "=", "$", "this", "->", "request", "(", "sel...
revoke a role of specified user. @param string $user @param string $role @return array @throws \GuzzleHttp\Exception\BadResponseException
[ "revoke", "a", "role", "of", "specified", "user", "." ]
8d16ee71fadb50e055b83509da78e21ff959fe2c
https://github.com/ouqiang/etcd-php/blob/8d16ee71fadb50e055b83509da78e21ff959fe2c/src/Client.php#L687-L697
train
XavRsl/Cas
src/Xavrsl/Cas/CasManager.php
CasManager.connection
public function connection() { if ( empty($this->connection)) { $this->connection = $this->createConnection(); } return $this->connection; }
php
public function connection() { if ( empty($this->connection)) { $this->connection = $this->createConnection(); } return $this->connection; }
[ "public", "function", "connection", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "connection", ")", ")", "{", "$", "this", "->", "connection", "=", "$", "this", "->", "createConnection", "(", ")", ";", "}", "return", "$", "this", "->", ...
Get a Cas connection instance. @return Xavrsl\Cas\Directory
[ "Get", "a", "Cas", "connection", "instance", "." ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/CasManager.php#L31-L39
train
XavRsl/Cas
src/Xavrsl/Cas/Sso.php
Sso.initializeCas
private function initializeCas() { $this->configureDebug(); // initialize CAS client $this->configureCasClient(); $this->configureSslValidation(); phpCAS::handleLogoutRequests(); $this->configureProxyChain(); }
php
private function initializeCas() { $this->configureDebug(); // initialize CAS client $this->configureCasClient(); $this->configureSslValidation(); phpCAS::handleLogoutRequests(); $this->configureProxyChain(); }
[ "private", "function", "initializeCas", "(", ")", "{", "$", "this", "->", "configureDebug", "(", ")", ";", "// initialize CAS client", "$", "this", "->", "configureCasClient", "(", ")", ";", "$", "this", "->", "configureSslValidation", "(", ")", ";", "phpCAS",...
Make PHPCAS Initialization Initialize phpCAS before authentication @return none
[ "Make", "PHPCAS", "Initialization" ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/Sso.php#L38-L48
train
XavRsl/Cas
src/Xavrsl/Cas/Sso.php
Sso.configureDebug
private function configureDebug() { if($debug = $this->config['cas_debug']) { $path = (gettype($debug) == 'string') ? $debug : ''; phpCAS::setDebug($path); // https://github.com/Jasig/phpCAS/commit/bb382f5038f6241c7c577fb55430ad505f1f6e23 phpCAS::setVerbose(true); } }
php
private function configureDebug() { if($debug = $this->config['cas_debug']) { $path = (gettype($debug) == 'string') ? $debug : ''; phpCAS::setDebug($path); // https://github.com/Jasig/phpCAS/commit/bb382f5038f6241c7c577fb55430ad505f1f6e23 phpCAS::setVerbose(true); } }
[ "private", "function", "configureDebug", "(", ")", "{", "if", "(", "$", "debug", "=", "$", "this", "->", "config", "[", "'cas_debug'", "]", ")", "{", "$", "path", "=", "(", "gettype", "(", "$", "debug", ")", "==", "'string'", ")", "?", "$", "debug"...
Configure CAS debug
[ "Configure", "CAS", "debug" ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/Sso.php#L53-L62
train
XavRsl/Cas
src/Xavrsl/Cas/Sso.php
Sso.configureCasClient
private function configureCasClient() { $method = !$this->config['cas_proxy'] ? 'client' : 'proxy'; // Last argument of method (proxy or client) is $changeSessionID. It is true by default. It means it will // override the framework's session_id. This allows for Single Sign Out. And it means that there is no point // in using the framework's session and authentication objects. If CAS destroys the session, it will destroy it // for everyone and you only need to deal with one session. phpCAS::$method( !$this->config['cas_saml'] ? CAS_VERSION_2_0 : SAML_VERSION_1_1, $this->config['cas_hostname'], (integer) $this->config['cas_port'], $this->config['cas_uri'] ); }
php
private function configureCasClient() { $method = !$this->config['cas_proxy'] ? 'client' : 'proxy'; // Last argument of method (proxy or client) is $changeSessionID. It is true by default. It means it will // override the framework's session_id. This allows for Single Sign Out. And it means that there is no point // in using the framework's session and authentication objects. If CAS destroys the session, it will destroy it // for everyone and you only need to deal with one session. phpCAS::$method( !$this->config['cas_saml'] ? CAS_VERSION_2_0 : SAML_VERSION_1_1, $this->config['cas_hostname'], (integer) $this->config['cas_port'], $this->config['cas_uri'] ); }
[ "private", "function", "configureCasClient", "(", ")", "{", "$", "method", "=", "!", "$", "this", "->", "config", "[", "'cas_proxy'", "]", "?", "'client'", ":", "'proxy'", ";", "// Last argument of method (proxy or client) is $changeSessionID. It is true by default. It me...
Configure CAS Client
[ "Configure", "CAS", "Client" ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/Sso.php#L68-L81
train
XavRsl/Cas
src/Xavrsl/Cas/Sso.php
Sso.configureSslValidation
private function configureSslValidation() { // set SSL validation for the CAS server if ($this->config['cas_validation'] == 'ca' || $this->config['cas_validation'] == 'self') { phpCAS::setCasServerCACert($this->config['cas_cert']); } else { phpCAS::setNoCasServerValidation(); } }
php
private function configureSslValidation() { // set SSL validation for the CAS server if ($this->config['cas_validation'] == 'ca' || $this->config['cas_validation'] == 'self') { phpCAS::setCasServerCACert($this->config['cas_cert']); } else { phpCAS::setNoCasServerValidation(); } }
[ "private", "function", "configureSslValidation", "(", ")", "{", "// set SSL validation for the CAS server", "if", "(", "$", "this", "->", "config", "[", "'cas_validation'", "]", "==", "'ca'", "||", "$", "this", "->", "config", "[", "'cas_validation'", "]", "==", ...
Configure SSL Validation Having some kind of server cert validation in production is highly recommended.
[ "Configure", "SSL", "Validation" ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/Sso.php#L89-L100
train
XavRsl/Cas
src/Xavrsl/Cas/Sso.php
Sso.configureProxyChain
private function configureProxyChain() { if (is_array($this->config['cas_proxied_services']) && !empty($this->config['cas_proxied_services'])) { phpCAS::allowProxyChain(new \CAS_ProxyChain($this->config['cas_proxied_services'])); } }
php
private function configureProxyChain() { if (is_array($this->config['cas_proxied_services']) && !empty($this->config['cas_proxied_services'])) { phpCAS::allowProxyChain(new \CAS_ProxyChain($this->config['cas_proxied_services'])); } }
[ "private", "function", "configureProxyChain", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "config", "[", "'cas_proxied_services'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "config", "[", "'cas_proxied_services'", "]", ")", ")...
Configure Cas Proxy Chain Cas can proxy services. Here you can specify which ones are allowed.
[ "Configure", "Cas", "Proxy", "Chain" ]
2f9dc56844e5e6b463bcb751d651a62c9e76111b
https://github.com/XavRsl/Cas/blob/2f9dc56844e5e6b463bcb751d651a62c9e76111b/src/Xavrsl/Cas/Sso.php#L107-L114
train
bpolaszek/bentools-etl
src/Exception/UnexpectedTypeException.php
UnexpectedTypeException.throwIfNot
public static function throwIfNot($actualObject, string $expectedType, bool $allowNull = false): void { if (!is_a($expectedType, $expectedType, true)) { if (\gettype($actualObject) !== $expectedType) { if (null === $actualObject && $allowNull) { return; } throw new self($expectedType, $actualObject); } return; } if (!$actualObject instanceof $expectedType) { if (null === $actualObject && $allowNull) { return; } throw new self($expectedType, $actualObject); } }
php
public static function throwIfNot($actualObject, string $expectedType, bool $allowNull = false): void { if (!is_a($expectedType, $expectedType, true)) { if (\gettype($actualObject) !== $expectedType) { if (null === $actualObject && $allowNull) { return; } throw new self($expectedType, $actualObject); } return; } if (!$actualObject instanceof $expectedType) { if (null === $actualObject && $allowNull) { return; } throw new self($expectedType, $actualObject); } }
[ "public", "static", "function", "throwIfNot", "(", "$", "actualObject", ",", "string", "$", "expectedType", ",", "bool", "$", "allowNull", "=", "false", ")", ":", "void", "{", "if", "(", "!", "is_a", "(", "$", "expectedType", ",", "$", "expectedType", ",...
Throw an UnexpectedTypeException if actual object doesn't match expected type. @param $actualObject @param string $expectedType @param bool $allowNull @throws UnexpectedTypeException
[ "Throw", "an", "UnexpectedTypeException", "if", "actual", "object", "doesn", "t", "match", "expected", "type", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Exception/UnexpectedTypeException.php#L30-L48
train
bpolaszek/bentools-etl
src/Etl.php
Etl.process
public function process($data, ...$initLoaderArgs): void { $flushCounter = $totalCounter = 0; $this->start(); foreach ($this->extract($data) as $key => $item) { if ($this->shouldSkip) { $this->skip($item, $key); continue; } if ($this->shouldStop) { $this->stop($item, $key); break; } $transformed = $this->transform($item, $key); if ($this->shouldSkip) { $this->skip($item, $key); continue; } if ($this->shouldStop) { $this->stop($item, $key); break; } $flushCounter++; $totalCounter++; if (1 === $totalCounter) { $this->initLoader($item, $key, ...$initLoaderArgs); } $flush = (null === $this->flushEvery ? false : (0 === ($totalCounter % $this->flushEvery))); $this->load($transformed(), $item, $key, $flush, $flushCounter, $totalCounter); } $this->end($flushCounter, $totalCounter); }
php
public function process($data, ...$initLoaderArgs): void { $flushCounter = $totalCounter = 0; $this->start(); foreach ($this->extract($data) as $key => $item) { if ($this->shouldSkip) { $this->skip($item, $key); continue; } if ($this->shouldStop) { $this->stop($item, $key); break; } $transformed = $this->transform($item, $key); if ($this->shouldSkip) { $this->skip($item, $key); continue; } if ($this->shouldStop) { $this->stop($item, $key); break; } $flushCounter++; $totalCounter++; if (1 === $totalCounter) { $this->initLoader($item, $key, ...$initLoaderArgs); } $flush = (null === $this->flushEvery ? false : (0 === ($totalCounter % $this->flushEvery))); $this->load($transformed(), $item, $key, $flush, $flushCounter, $totalCounter); } $this->end($flushCounter, $totalCounter); }
[ "public", "function", "process", "(", "$", "data", ",", "...", "$", "initLoaderArgs", ")", ":", "void", "{", "$", "flushCounter", "=", "$", "totalCounter", "=", "0", ";", "$", "this", "->", "start", "(", ")", ";", "foreach", "(", "$", "this", "->", ...
Run the ETL on the given input. @param $data @param ...$initLoaderArgs - Optional arguments for loader init @throws EtlException
[ "Run", "the", "ETL", "on", "the", "given", "input", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L104-L144
train
bpolaszek/bentools-etl
src/Etl.php
Etl.skip
private function skip($item, $key): void { $this->shouldSkip = false; $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::SKIP, $item, $key, $this)); }
php
private function skip($item, $key): void { $this->shouldSkip = false; $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::SKIP, $item, $key, $this)); }
[ "private", "function", "skip", "(", "$", "item", ",", "$", "key", ")", ":", "void", "{", "$", "this", "->", "shouldSkip", "=", "false", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "ItemEvent", "(", "EtlEvents", "::", "SKIP"...
Process item skip. @param $item @param $key
[ "Process", "item", "skip", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L166-L170
train
bpolaszek/bentools-etl
src/Etl.php
Etl.stopProcessing
public function stopProcessing(bool $rollback = false): void { $this->shouldStop = true; $this->shouldRollback = $rollback; }
php
public function stopProcessing(bool $rollback = false): void { $this->shouldStop = true; $this->shouldRollback = $rollback; }
[ "public", "function", "stopProcessing", "(", "bool", "$", "rollback", "=", "false", ")", ":", "void", "{", "$", "this", "->", "shouldStop", "=", "true", ";", "$", "this", "->", "shouldRollback", "=", "$", "rollback", ";", "}" ]
Ask the ETl to stop. @param bool $rollback - if the loader should rollback instead of flushing.
[ "Ask", "the", "ETl", "to", "stop", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L177-L181
train
bpolaszek/bentools-etl
src/Etl.php
Etl.reset
private function reset(): void { $this->shouldSkip = false; $this->shouldStop = false; $this->shouldRollback = false; }
php
private function reset(): void { $this->shouldSkip = false; $this->shouldStop = false; $this->shouldRollback = false; }
[ "private", "function", "reset", "(", ")", ":", "void", "{", "$", "this", "->", "shouldSkip", "=", "false", ";", "$", "this", "->", "shouldStop", "=", "false", ";", "$", "this", "->", "shouldRollback", "=", "false", ";", "}" ]
Reset the ETL.
[ "Reset", "the", "ETL", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L195-L200
train
bpolaszek/bentools-etl
src/Etl.php
Etl.extract
private function extract($data): iterable { $items = null === $this->extract ? $data : ($this->extract)($data, $this); if (null === $items) { $items = new \EmptyIterator(); } if (!\is_iterable($items)) { throw new EtlException('Could not extract data.'); } try { foreach ($items as $key => $item) { try { $this->shouldSkip = false; $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::EXTRACT, $item, $key, $this)); yield $key => $item; } catch (\Exception $e) { continue; } } } catch (\Throwable $e) { /** @var ItemExceptionEvent $event */ $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::EXTRACT_EXCEPTION, $item ?? null, $key ?? null, $this, $e)); if ($event->shouldThrowException()) { throw $e; } } }
php
private function extract($data): iterable { $items = null === $this->extract ? $data : ($this->extract)($data, $this); if (null === $items) { $items = new \EmptyIterator(); } if (!\is_iterable($items)) { throw new EtlException('Could not extract data.'); } try { foreach ($items as $key => $item) { try { $this->shouldSkip = false; $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::EXTRACT, $item, $key, $this)); yield $key => $item; } catch (\Exception $e) { continue; } } } catch (\Throwable $e) { /** @var ItemExceptionEvent $event */ $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::EXTRACT_EXCEPTION, $item ?? null, $key ?? null, $this, $e)); if ($event->shouldThrowException()) { throw $e; } } }
[ "private", "function", "extract", "(", "$", "data", ")", ":", "iterable", "{", "$", "items", "=", "null", "===", "$", "this", "->", "extract", "?", "$", "data", ":", "(", "$", "this", "->", "extract", ")", "(", "$", "data", ",", "$", "this", ")",...
Extract data. @param $data @return iterable @throws EtlException
[ "Extract", "data", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L209-L238
train
bpolaszek/bentools-etl
src/Etl.php
Etl.transform
private function transform($item, $key) { $transformed = ($this->transform)($item, $key, $this); if (!$transformed instanceof \Generator) { throw new EtlException('The transformer must return a generator.'); } // Traverse generator to trigger events try { $transformed = \iterator_to_array($transformed); $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::TRANSFORM, $item, $key, $this)); } catch (\Exception $e) { /** @var ItemExceptionEvent $event */ $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::TRANSFORM_EXCEPTION, $item, $key, $this, $e)); if ($event->shouldThrowException()) { throw $e; } } return function () use ($transformed) { yield from $transformed; }; }
php
private function transform($item, $key) { $transformed = ($this->transform)($item, $key, $this); if (!$transformed instanceof \Generator) { throw new EtlException('The transformer must return a generator.'); } // Traverse generator to trigger events try { $transformed = \iterator_to_array($transformed); $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::TRANSFORM, $item, $key, $this)); } catch (\Exception $e) { /** @var ItemExceptionEvent $event */ $event = $this->eventDispatcher->dispatch(new ItemExceptionEvent(EtlEvents::TRANSFORM_EXCEPTION, $item, $key, $this, $e)); if ($event->shouldThrowException()) { throw $e; } } return function () use ($transformed) { yield from $transformed; }; }
[ "private", "function", "transform", "(", "$", "item", ",", "$", "key", ")", "{", "$", "transformed", "=", "(", "$", "this", "->", "transform", ")", "(", "$", "item", ",", "$", "key", ",", "$", "this", ")", ";", "if", "(", "!", "$", "transformed",...
Transform data. @param $item @param $key @return callable @throws EtlException
[ "Transform", "data", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L248-L271
train
bpolaszek/bentools-etl
src/Etl.php
Etl.initLoader
private function initLoader($item, $key, ...$initLoaderArgs): void { $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::LOADER_INIT, $item, $key, $this)); if (null === $this->init) { return; } ($this->init)(...$initLoaderArgs); }
php
private function initLoader($item, $key, ...$initLoaderArgs): void { $this->eventDispatcher->dispatch(new ItemEvent(EtlEvents::LOADER_INIT, $item, $key, $this)); if (null === $this->init) { return; } ($this->init)(...$initLoaderArgs); }
[ "private", "function", "initLoader", "(", "$", "item", ",", "$", "key", ",", "...", "$", "initLoaderArgs", ")", ":", "void", "{", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "ItemEvent", "(", "EtlEvents", "::", "LOADER_INIT", ",", ...
Init the loader on the 1st item.
[ "Init", "the", "loader", "on", "the", "1st", "item", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L276-L285
train
bpolaszek/bentools-etl
src/Etl.php
Etl.flush
private function flush(int &$flushCounter, bool $partial): void { if (null === $this->flush) { return; } ($this->flush)($partial); $this->eventDispatcher->dispatch(new FlushEvent($this, $flushCounter, $partial)); $flushCounter = 0; }
php
private function flush(int &$flushCounter, bool $partial): void { if (null === $this->flush) { return; } ($this->flush)($partial); $this->eventDispatcher->dispatch(new FlushEvent($this, $flushCounter, $partial)); $flushCounter = 0; }
[ "private", "function", "flush", "(", "int", "&", "$", "flushCounter", ",", "bool", "$", "partial", ")", ":", "void", "{", "if", "(", "null", "===", "$", "this", "->", "flush", ")", "{", "return", ";", "}", "(", "$", "this", "->", "flush", ")", "(...
Flush elements.
[ "Flush", "elements", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L315-L324
train
bpolaszek/bentools-etl
src/Etl.php
Etl.rollback
private function rollback(int &$flushCounter): void { if (null === $this->rollback) { return; } ($this->rollback)(); $this->eventDispatcher->dispatch(new RollbackEvent($this, $flushCounter)); $flushCounter = 0; }
php
private function rollback(int &$flushCounter): void { if (null === $this->rollback) { return; } ($this->rollback)(); $this->eventDispatcher->dispatch(new RollbackEvent($this, $flushCounter)); $flushCounter = 0; }
[ "private", "function", "rollback", "(", "int", "&", "$", "flushCounter", ")", ":", "void", "{", "if", "(", "null", "===", "$", "this", "->", "rollback", ")", "{", "return", ";", "}", "(", "$", "this", "->", "rollback", ")", "(", ")", ";", "$", "t...
Restore loader's initial state.
[ "Restore", "loader", "s", "initial", "state", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L329-L338
train
bpolaszek/bentools-etl
src/Etl.php
Etl.end
private function end(int $flushCounter, int $totalCounter): void { if ($this->shouldRollback) { $this->rollback($flushCounter); $totalCounter = max(0, $totalCounter - $flushCounter); } else { $this->flush($flushCounter, false); } $this->eventDispatcher->dispatch(new EndProcessEvent($this, $totalCounter)); $this->reset(); }
php
private function end(int $flushCounter, int $totalCounter): void { if ($this->shouldRollback) { $this->rollback($flushCounter); $totalCounter = max(0, $totalCounter - $flushCounter); } else { $this->flush($flushCounter, false); } $this->eventDispatcher->dispatch(new EndProcessEvent($this, $totalCounter)); $this->reset(); }
[ "private", "function", "end", "(", "int", "$", "flushCounter", ",", "int", "$", "totalCounter", ")", ":", "void", "{", "if", "(", "$", "this", "->", "shouldRollback", ")", "{", "$", "this", "->", "rollback", "(", "$", "flushCounter", ")", ";", "$", "...
Process the end of the ETL. @param int $flushCounter @param int $totalCounter
[ "Process", "the", "end", "of", "the", "ETL", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Etl.php#L346-L356
train
bpolaszek/bentools-etl
src/Iterator/TextLinesIterator.php
TextLinesIterator.traverseWithStrTok
private function traverseWithStrTok() { $tok = \strtok($this->content, "\r\n"); while (false !== $tok) { $line = $tok; $tok = \strtok("\n\r"); yield $line; } }
php
private function traverseWithStrTok() { $tok = \strtok($this->content, "\r\n"); while (false !== $tok) { $line = $tok; $tok = \strtok("\n\r"); yield $line; } }
[ "private", "function", "traverseWithStrTok", "(", ")", "{", "$", "tok", "=", "\\", "strtok", "(", "$", "this", "->", "content", ",", "\"\\r\\n\"", ")", ";", "while", "(", "false", "!==", "$", "tok", ")", "{", "$", "line", "=", "$", "tok", ";", "$",...
Uses strtok to split lines. Provides better performance, but skips empty lines. @return \Generator|string[]
[ "Uses", "strtok", "to", "split", "lines", ".", "Provides", "better", "performance", "but", "skips", "empty", "lines", "." ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Iterator/TextLinesIterator.php#L59-L67
train
bpolaszek/bentools-etl
src/Iterator/KeysAwareCsvIterator.php
KeysAwareCsvIterator.combine
private static function combine(array $keys, array $values): array { $nbKeys = \count($keys); $nbValues = \count($values); if ($nbKeys < $nbValues) { return \array_combine($keys, \array_slice(\array_values($values), 0, $nbKeys)); } if ($nbKeys > $nbValues) { return \array_combine($keys, \array_merge($values, \array_fill(0, $nbKeys - $nbValues, null))); } return \array_combine($keys, $values); }
php
private static function combine(array $keys, array $values): array { $nbKeys = \count($keys); $nbValues = \count($values); if ($nbKeys < $nbValues) { return \array_combine($keys, \array_slice(\array_values($values), 0, $nbKeys)); } if ($nbKeys > $nbValues) { return \array_combine($keys, \array_merge($values, \array_fill(0, $nbKeys - $nbValues, null))); } return \array_combine($keys, $values); }
[ "private", "static", "function", "combine", "(", "array", "$", "keys", ",", "array", "$", "values", ")", ":", "array", "{", "$", "nbKeys", "=", "\\", "count", "(", "$", "keys", ")", ";", "$", "nbValues", "=", "\\", "count", "(", "$", "values", ")",...
Combine keys & values @param array $keys @param array $values @return array
[ "Combine", "keys", "&", "values" ]
d76dea73c5949866a9773ace19a4006f111e4b71
https://github.com/bpolaszek/bentools-etl/blob/d76dea73c5949866a9773ace19a4006f111e4b71/src/Iterator/KeysAwareCsvIterator.php#L68-L82
train
jumilla/laravel-extension
sources/Commands/TailCommand.php
TailCommand.tailLocalLogs
protected function tailLocalLogs($path) { $output = $this->output; $lines = $this->option('lines'); (new Process('tail -f -n '.$lines.' '.escapeshellarg($path)))->setTimeout(null)->run(function ($type, $line) use ($output) { $output->write($line); }); }
php
protected function tailLocalLogs($path) { $output = $this->output; $lines = $this->option('lines'); (new Process('tail -f -n '.$lines.' '.escapeshellarg($path)))->setTimeout(null)->run(function ($type, $line) use ($output) { $output->write($line); }); }
[ "protected", "function", "tailLocalLogs", "(", "$", "path", ")", "{", "$", "output", "=", "$", "this", "->", "output", ";", "$", "lines", "=", "$", "this", "->", "option", "(", "'lines'", ")", ";", "(", "new", "Process", "(", "'tail -f -n '", ".", "$...
Tail a local log file for the application. @param string $path @return string
[ "Tail", "a", "local", "log", "file", "for", "the", "application", "." ]
a0ed9065fb1416eca947164dbf355ba3dc669cb3
https://github.com/jumilla/laravel-extension/blob/a0ed9065fb1416eca947164dbf355ba3dc669cb3/sources/Commands/TailCommand.php#L93-L102
train
jumilla/laravel-extension
sources/Generators/GeneratorCommandTrait.php
GeneratorCommandTrait.getAddon
protected function getAddon() { if ($addon = $this->option('addon')) { $env = app(AddonEnvironment::class); if (!$env->exists($addon)) { throw new UnexpectedValueException("Addon '$addon' is not found."); } return $env->addon($addon); } else { return; } }
php
protected function getAddon() { if ($addon = $this->option('addon')) { $env = app(AddonEnvironment::class); if (!$env->exists($addon)) { throw new UnexpectedValueException("Addon '$addon' is not found."); } return $env->addon($addon); } else { return; } }
[ "protected", "function", "getAddon", "(", ")", "{", "if", "(", "$", "addon", "=", "$", "this", "->", "option", "(", "'addon'", ")", ")", "{", "$", "env", "=", "app", "(", "AddonEnvironment", "::", "class", ")", ";", "if", "(", "!", "$", "env", "-...
Get addon. @return string
[ "Get", "addon", "." ]
a0ed9065fb1416eca947164dbf355ba3dc669cb3
https://github.com/jumilla/laravel-extension/blob/a0ed9065fb1416eca947164dbf355ba3dc669cb3/sources/Generators/GeneratorCommandTrait.php#L59-L72
train
jumilla/laravel-extension
sources/Generators/GeneratorCommandTrait.php
GeneratorCommandTrait.getRootDirectory
protected function getRootDirectory() { if ($this->addon) { $directories = $this->addon->config('addon.directories'); if (! $directories) { $directories = ['classes']; } return $this->addon->path($directories[0]); } else { return parent::getRootDirectory(); } }
php
protected function getRootDirectory() { if ($this->addon) { $directories = $this->addon->config('addon.directories'); if (! $directories) { $directories = ['classes']; } return $this->addon->path($directories[0]); } else { return parent::getRootDirectory(); } }
[ "protected", "function", "getRootDirectory", "(", ")", "{", "if", "(", "$", "this", "->", "addon", ")", "{", "$", "directories", "=", "$", "this", "->", "addon", "->", "config", "(", "'addon.directories'", ")", ";", "if", "(", "!", "$", "directories", ...
Get the directory path for root namespace. @return string
[ "Get", "the", "directory", "path", "for", "root", "namespace", "." ]
a0ed9065fb1416eca947164dbf355ba3dc669cb3
https://github.com/jumilla/laravel-extension/blob/a0ed9065fb1416eca947164dbf355ba3dc669cb3/sources/Generators/GeneratorCommandTrait.php#L109-L123
train
oat-sa/extension-tao-outcomekeyvalue
models/classes/class.KeyValueResultStorage.php
taoAltResultStorage_models_classes_KeyValueResultStorage.extractResultVariableProperty
public function extractResultVariableProperty($variableId) { $variableIds = explode('http://',$variableId); $parts = explode(static::PROPERTY_SEPARATOR, $variableIds[2]); $itemUri = $variableIds[0] . 'http://' . $parts[0]; $propertyName = empty($parts[1]) ? 'RESPONSE' : $parts[1]; return [ $itemUri, $propertyName ]; }
php
public function extractResultVariableProperty($variableId) { $variableIds = explode('http://',$variableId); $parts = explode(static::PROPERTY_SEPARATOR, $variableIds[2]); $itemUri = $variableIds[0] . 'http://' . $parts[0]; $propertyName = empty($parts[1]) ? 'RESPONSE' : $parts[1]; return [ $itemUri, $propertyName ]; }
[ "public", "function", "extractResultVariableProperty", "(", "$", "variableId", ")", "{", "$", "variableIds", "=", "explode", "(", "'http://'", ",", "$", "variableId", ")", ";", "$", "parts", "=", "explode", "(", "static", "::", "PROPERTY_SEPARATOR", ",", "$", ...
Returns the variable property key from the absolute variable key. @param string $variableId @return array
[ "Returns", "the", "variable", "property", "key", "from", "the", "absolute", "variable", "key", "." ]
c5b4c1b20d5a9c7db643243c779fe7a3e51d5a0c
https://github.com/oat-sa/extension-tao-outcomekeyvalue/blob/c5b4c1b20d5a9c7db643243c779fe7a3e51d5a0c/models/classes/class.KeyValueResultStorage.php#L398-L410
train
oat-sa/lib-generis-search
src/factory/QueryCriterionFactory.php
QueryCriterionFactory.get
public function get($className,array $options = array()) { $Param = $this->getServiceLocator()->get($className); if($this->isValidClass($Param)) { $Param->setName($options[0]) ->setOperator($options[1]) ->setValue($options[2]) ->setServiceLocator($this->getServiceLocator()); return $Param; } }
php
public function get($className,array $options = array()) { $Param = $this->getServiceLocator()->get($className); if($this->isValidClass($Param)) { $Param->setName($options[0]) ->setOperator($options[1]) ->setValue($options[2]) ->setServiceLocator($this->getServiceLocator()); return $Param; } }
[ "public", "function", "get", "(", "$", "className", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "Param", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "$", "className", ")", ";", "if", "(", "$", ...
return a new Query param @param string $className @param array $options @return \oat\search\factory\QueryCriterionInterface @throws \InvalidArgumentException
[ "return", "a", "new", "Query", "param" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/factory/QueryCriterionFactory.php#L42-L54
train
oat-sa/lib-generis-search
src/Query.php
Query.addOr
public function addOr($value , $operator = null) { /*@var $criterion QueryCriterionInterface */ $criterion = end($this->storedQueryCriteria); $criterion->addOr($value, $operator); return $this; }
php
public function addOr($value , $operator = null) { /*@var $criterion QueryCriterionInterface */ $criterion = end($this->storedQueryCriteria); $criterion->addOr($value, $operator); return $this; }
[ "public", "function", "addOr", "(", "$", "value", ",", "$", "operator", "=", "null", ")", "{", "/*@var $criterion QueryCriterionInterface */", "$", "criterion", "=", "end", "(", "$", "this", "->", "storedQueryCriteria", ")", ";", "$", "criterion", "->", "addOr...
add a new condition on same property with OR separator @param mixed $value @param string|null $operator @return $this
[ "add", "a", "new", "condition", "on", "same", "property", "with", "OR", "separator" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/Query.php#L205-L211
train
oat-sa/lib-generis-search
src/DbSql/TaoRdf/Command/AbstractRdfOperator.php
AbstractRdfOperator.setPropertyName
protected function setPropertyName($name) { if(!empty($name)) { $name = $this->getDriverEscaper()->escape($name); $name = $this->getDriverEscaper()->quote($name); return $this->getDriverEscaper()->reserved('predicate') . ' = ' . $name . ' ' . $this->getDriverEscaper()->dbCommand('AND') . ' ( '; } return ''; }
php
protected function setPropertyName($name) { if(!empty($name)) { $name = $this->getDriverEscaper()->escape($name); $name = $this->getDriverEscaper()->quote($name); return $this->getDriverEscaper()->reserved('predicate') . ' = ' . $name . ' ' . $this->getDriverEscaper()->dbCommand('AND') . ' ( '; } return ''; }
[ "protected", "function", "setPropertyName", "(", "$", "name", ")", "{", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getDriverEscaper", "(", ")", "->", "escape", "(", "$", "name", ")", ";", "$", ...
set up predicate name condition @param string $name @return string
[ "set", "up", "predicate", "name", "condition" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/DbSql/TaoRdf/Command/AbstractRdfOperator.php#L46-L54
train
oat-sa/lib-generis-search
src/DbSql/AbstractSqlQuerySerialyser.php
AbstractSqlQuerySerialyser.prefixQuery
public function prefixQuery() { $options = $this->getOptions(); if ($this->validateOptions($options)) { $this->queryPrefix = $this->getDriverEscaper()->dbCommand('SELECT') . ' '; $fields = $this->setFieldList($options); $this->queryPrefix .= $fields . ' ' . $this->getDriverEscaper()->dbCommand('FROM') . ' ' . $this->getDriverEscaper()->reserved($options['table']) . ' ' . $this->getDriverEscaper()->dbCommand('WHERE') . ' '; } return $this; }
php
public function prefixQuery() { $options = $this->getOptions(); if ($this->validateOptions($options)) { $this->queryPrefix = $this->getDriverEscaper()->dbCommand('SELECT') . ' '; $fields = $this->setFieldList($options); $this->queryPrefix .= $fields . ' ' . $this->getDriverEscaper()->dbCommand('FROM') . ' ' . $this->getDriverEscaper()->reserved($options['table']) . ' ' . $this->getDriverEscaper()->dbCommand('WHERE') . ' '; } return $this; }
[ "public", "function", "prefixQuery", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "$", "this", "->", "validateOptions", "(", "$", "options", ")", ")", "{", "$", "this", "->", "queryPrefix", "=", "$", ...
create base query for SQL single table query @return $this
[ "create", "base", "query", "for", "SQL", "single", "table", "query" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/DbSql/AbstractSqlQuerySerialyser.php#L40-L51
train
oat-sa/lib-generis-search
src/DbSql/AbstractSqlQuerySerialyser.php
AbstractSqlQuerySerialyser.setFieldList
protected function setFieldList(array $options) { $fields = $this->getDriverEscaper()->getAllFields(); if (array_key_exists('fields', $options)) { $fieldsList = []; foreach ($options['fields'] as $field) { $fieldsList[] = $this->getDriverEscaper()->reserved($field); } $fields = implode(' ' . $this->getDriverEscaper()->getFieldsSeparator() . ' ', $fieldsList); } return $fields; }
php
protected function setFieldList(array $options) { $fields = $this->getDriverEscaper()->getAllFields(); if (array_key_exists('fields', $options)) { $fieldsList = []; foreach ($options['fields'] as $field) { $fieldsList[] = $this->getDriverEscaper()->reserved($field); } $fields = implode(' ' . $this->getDriverEscaper()->getFieldsSeparator() . ' ', $fieldsList); } return $fields; }
[ "protected", "function", "setFieldList", "(", "array", "$", "options", ")", "{", "$", "fields", "=", "$", "this", "->", "getDriverEscaper", "(", ")", "->", "getAllFields", "(", ")", ";", "if", "(", "array_key_exists", "(", "'fields'", ",", "$", "options", ...
set up selected field list @param array $options @return string
[ "set", "up", "selected", "field", "list" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/DbSql/AbstractSqlQuerySerialyser.php#L57-L67
train
oat-sa/lib-generis-search
src/DbSql/AbstractSqlQuerySerialyser.php
AbstractSqlQuerySerialyser.addLimit
protected function addLimit($limit, $offset = null) { $limitQuery = ''; if (intval($limit) > 0) { $limitQuery .= $this->getDriverEscaper()->dbCommand('LIMIT') . ' ' . $limit; if (!is_null($offset)) { $limitQuery .= ' ' . $this->getDriverEscaper()->dbCommand('OFFSET') . ' ' . $offset; } } return $limitQuery; }
php
protected function addLimit($limit, $offset = null) { $limitQuery = ''; if (intval($limit) > 0) { $limitQuery .= $this->getDriverEscaper()->dbCommand('LIMIT') . ' ' . $limit; if (!is_null($offset)) { $limitQuery .= ' ' . $this->getDriverEscaper()->dbCommand('OFFSET') . ' ' . $offset; } } return $limitQuery; }
[ "protected", "function", "addLimit", "(", "$", "limit", ",", "$", "offset", "=", "null", ")", "{", "$", "limitQuery", "=", "''", ";", "if", "(", "intval", "(", "$", "limit", ")", ">", "0", ")", "{", "$", "limitQuery", ".=", "$", "this", "->", "ge...
create limit part for query @param integer $limit @param integer $offset @return string
[ "create", "limit", "part", "for", "query" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/DbSql/AbstractSqlQuerySerialyser.php#L123-L135
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.pretty
public function pretty($pretty) { if($pretty) { $this->operationSeparator = $this->prettyChar ; } else { $this->operationSeparator = $this->unPrettyChar ; } return $this; }
php
public function pretty($pretty) { if($pretty) { $this->operationSeparator = $this->prettyChar ; } else { $this->operationSeparator = $this->unPrettyChar ; } return $this; }
[ "public", "function", "pretty", "(", "$", "pretty", ")", "{", "if", "(", "$", "pretty", ")", "{", "$", "this", "->", "operationSeparator", "=", "$", "this", "->", "prettyChar", ";", "}", "else", "{", "$", "this", "->", "operationSeparator", "=", "$", ...
change operation separator to pretty print or unpretty print @param boolean $pretty @return $this
[ "change", "operation", "separator", "to", "pretty", "print", "or", "unpretty", "print" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L95-L102
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.serialyse
public function serialyse() { $this->query = $this->queryPrefix; foreach ($this->criteriaList->getStoredQueries() as $query) { $this->setNextSeparator(false); $this->parseQuery($query); } $this->finishQuery(); return $this->query; }
php
public function serialyse() { $this->query = $this->queryPrefix; foreach ($this->criteriaList->getStoredQueries() as $query) { $this->setNextSeparator(false); $this->parseQuery($query); } $this->finishQuery(); return $this->query; }
[ "public", "function", "serialyse", "(", ")", "{", "$", "this", "->", "query", "=", "$", "this", "->", "queryPrefix", ";", "foreach", "(", "$", "this", "->", "criteriaList", "->", "getStoredQueries", "(", ")", "as", "$", "query", ")", "{", "$", "this", ...
generate query exploitable by driver @return string
[ "generate", "query", "exploitable", "by", "driver" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L117-L129
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.parseQuery
protected function parseQuery(QueryInterface $query) { $operationList = $query->getStoredQueryCriteria(); $pos = 0; foreach ($operationList as $operation) { if($pos > 0) { $this->addSeparator(true); } $this->parseOperation($operation); $pos++; } return $this; }
php
protected function parseQuery(QueryInterface $query) { $operationList = $query->getStoredQueryCriteria(); $pos = 0; foreach ($operationList as $operation) { if($pos > 0) { $this->addSeparator(true); } $this->parseOperation($operation); $pos++; } return $this; }
[ "protected", "function", "parseQuery", "(", "QueryInterface", "$", "query", ")", "{", "$", "operationList", "=", "$", "query", "->", "getStoredQueryCriteria", "(", ")", ";", "$", "pos", "=", "0", ";", "foreach", "(", "$", "operationList", "as", "$", "opera...
parse QueryInterface criteria @param QueryInterface $query @return $this
[ "parse", "QueryInterface", "criteria" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L136-L148
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.parseOperation
protected function parseOperation(QueryCriterionInterface $operation) { $operation->setValue($this->getOperationValue($operation->getValue())); $command = $this->prepareOperator()->getOperator($operation->getOperator())->convert($operation); $this->setConditions($command , $operation->getAnd(), 'and'); $this->setConditions($command , $operation->getOr(), 'or'); $this->addOperator($command); return $this; }
php
protected function parseOperation(QueryCriterionInterface $operation) { $operation->setValue($this->getOperationValue($operation->getValue())); $command = $this->prepareOperator()->getOperator($operation->getOperator())->convert($operation); $this->setConditions($command , $operation->getAnd(), 'and'); $this->setConditions($command , $operation->getOr(), 'or'); $this->addOperator($command); return $this; }
[ "protected", "function", "parseOperation", "(", "QueryCriterionInterface", "$", "operation", ")", "{", "$", "operation", "->", "setValue", "(", "$", "this", "->", "getOperationValue", "(", "$", "operation", "->", "getValue", "(", ")", ")", ")", ";", "$", "co...
parse QueryCriterionInterface criteria @param QueryCriterionInterface $operation @return $this
[ "parse", "QueryCriterionInterface", "criteria" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L155-L167
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.getOperationValue
protected function getOperationValue($value) { if(is_a($value, '\\oat\\search\\base\\QueryBuilderInterface')) { $serialyser = new self(); $serialyser->setDriverEscaper($this->getDriverEscaper())->setServiceLocator($this->getServiceLocator())->setOptions($this->getOptions()); $value = $serialyser->setCriteriaList($value)->prefixQuery()->serialyse(); } return $value; }
php
protected function getOperationValue($value) { if(is_a($value, '\\oat\\search\\base\\QueryBuilderInterface')) { $serialyser = new self(); $serialyser->setDriverEscaper($this->getDriverEscaper())->setServiceLocator($this->getServiceLocator())->setOptions($this->getOptions()); $value = $serialyser->setCriteriaList($value)->prefixQuery()->serialyse(); } return $value; }
[ "protected", "function", "getOperationValue", "(", "$", "value", ")", "{", "if", "(", "is_a", "(", "$", "value", ",", "'\\\\oat\\\\search\\\\base\\\\QueryBuilderInterface'", ")", ")", "{", "$", "serialyser", "=", "new", "self", "(", ")", ";", "$", "serialyser"...
convert value to string if it's an object @param mixed $value @return string
[ "convert", "value", "to", "string", "if", "it", "s", "an", "object" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L174-L182
train
oat-sa/lib-generis-search
src/AbstractQuerySerialyser.php
AbstractQuerySerialyser.setConditions
protected function setConditions(&$command , array $conditionList , $separator = 'and') { foreach($conditionList as $condition) { $addCondition = $this->getOperator($condition->getOperator())->convert($condition); $this->mergeCondition($command , $addCondition , $separator); } return $command; }
php
protected function setConditions(&$command , array $conditionList , $separator = 'and') { foreach($conditionList as $condition) { $addCondition = $this->getOperator($condition->getOperator())->convert($condition); $this->mergeCondition($command , $addCondition , $separator); } return $command; }
[ "protected", "function", "setConditions", "(", "&", "$", "command", ",", "array", "$", "conditionList", ",", "$", "separator", "=", "'and'", ")", "{", "foreach", "(", "$", "conditionList", "as", "$", "condition", ")", "{", "$", "addCondition", "=", "$", ...
generate and add to query a condition exploitable by database driver @param type $command @param array $conditionList @param type $separator @return string
[ "generate", "and", "add", "to", "query", "a", "condition", "exploitable", "by", "database", "driver" ]
bf19991d7fb807341f7889f7e786f09668013a13
https://github.com/oat-sa/lib-generis-search/blob/bf19991d7fb807341f7889f7e786f09668013a13/src/AbstractQuerySerialyser.php#L193-L201
train