repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
thiagodp/rtti
lib/RTTI.php
RTTI.setAttributes
static function setAttributes( array $map , &$obj , $visibilityFlags = null , $setterPrefix = 'set' , $useCamelCase = true ) { $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $setterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() && array_key_exists( $attributeName, $map ) ) { $method->invoke( $obj, $map[ $attributeName ] ); } } } else { // public try { if ( array_key_exists( $attributeName, $map ) ) { $obj->{ $attributeName } = $map[ $attributeName ]; } } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve only public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $attributeName => $v ) { if ( array_key_exists( $attributeName, $map ) ) { try { $obj->{ $attributeName } = $map[ $attributeName ]; } catch ( \Exception $e ) { // Ignore } } } } $currentClass = $currentClass->getParentClass(); } }
php
static function setAttributes( array $map , &$obj , $visibilityFlags = null , $setterPrefix = 'set' , $useCamelCase = true ) { $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $setterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() && array_key_exists( $attributeName, $map ) ) { $method->invoke( $obj, $map[ $attributeName ] ); } } } else { // public try { if ( array_key_exists( $attributeName, $map ) ) { $obj->{ $attributeName } = $map[ $attributeName ]; } } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve only public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $attributeName => $v ) { if ( array_key_exists( $attributeName, $map ) ) { try { $obj->{ $attributeName } = $map[ $attributeName ]; } catch ( \Exception $e ) { // Ignore } } } } $currentClass = $currentClass->getParentClass(); } }
[ "static", "function", "setAttributes", "(", "array", "$", "map", ",", "&", "$", "obj", ",", "$", "visibilityFlags", "=", "null", ",", "$", "setterPrefix", "=", "'set'", ",", "$", "useCamelCase", "=", "true", ")", "{", "$", "flags", "=", "null", "===", "$", "visibilityFlags", "?", "self", "::", "allFlags", "(", ")", ":", "$", "visibilityFlags", ";", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "obj", ")", ";", "$", "currentClass", "=", "new", "\\", "ReflectionClass", "(", "$", "obj", ")", ";", "while", "(", "$", "currentClass", "!==", "false", "&&", "!", "$", "currentClass", "->", "isInterface", "(", ")", ")", "{", "$", "properties", "=", "$", "currentClass", "->", "getProperties", "(", "$", "flags", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "attributeName", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "methodName", "=", "$", "setterPrefix", ".", "(", "$", "useCamelCase", "?", "self", "::", "mb_ucfirst", "(", "$", "attributeName", ")", ":", "$", "attributeName", ")", ";", "if", "(", "$", "property", "->", "isPrivate", "(", ")", "||", "$", "property", "->", "isProtected", "(", ")", ")", "{", "if", "(", "$", "reflectionObject", "->", "hasMethod", "(", "$", "methodName", ")", ")", "{", "$", "method", "=", "$", "reflectionObject", "->", "getMethod", "(", "$", "methodName", ")", ";", "if", "(", "$", "method", "->", "isPublic", "(", ")", "&&", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "$", "method", "->", "invoke", "(", "$", "obj", ",", "$", "map", "[", "$", "attributeName", "]", ")", ";", "}", "}", "}", "else", "{", "// public", "try", "{", "if", "(", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "$", "obj", "->", "{", "$", "attributeName", "}", "=", "$", "map", "[", "$", "attributeName", "]", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "// No properties? -> try to retrieve only public properties", "if", "(", "count", "(", "$", "properties", ")", "<", "1", ")", "{", "$", "properties", "=", "get_object_vars", "(", "$", "obj", ")", ";", "foreach", "(", "$", "properties", "as", "$", "attributeName", "=>", "$", "v", ")", "{", "if", "(", "array_key_exists", "(", "$", "attributeName", ",", "$", "map", ")", ")", "{", "try", "{", "$", "obj", "->", "{", "$", "attributeName", "}", "=", "$", "map", "[", "$", "attributeName", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "}", "$", "currentClass", "=", "$", "currentClass", "->", "getParentClass", "(", ")", ";", "}", "}" ]
Set the attribute values of a object. @param array $map A map with the attribute names and values to be changed. @param object $obj The object to be changed. @param int $visibilityFlags Filter visibility flags. Can be added. Example: RTTI::IS_PRIVATE | RTTI::IS_PROTECTED Optional, defaults to RTTI::allFlags. @param string $setterPrefix The prefix for setter public methods (defaults to 'set'). @param bool $useCamelCase If true, private and protected attributes will be set by camelCase public methods (default true).
[ "Set", "the", "attribute", "values", "of", "a", "object", "." ]
train
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L157-L214
thiagodp/rtti
lib/RTTI.php
RTTI.setPrivateAttributes
static function setPrivateAttributes( array $map, &$obj, $setterPrefix = 'set', $useCamelCase = true ) { self::setAttributes( $map, $obj, \RTTI::IS_PRIVATE, $setterPrefix, $useCamelCase ); }
php
static function setPrivateAttributes( array $map, &$obj, $setterPrefix = 'set', $useCamelCase = true ) { self::setAttributes( $map, $obj, \RTTI::IS_PRIVATE, $setterPrefix, $useCamelCase ); }
[ "static", "function", "setPrivateAttributes", "(", "array", "$", "map", ",", "&", "$", "obj", ",", "$", "setterPrefix", "=", "'set'", ",", "$", "useCamelCase", "=", "true", ")", "{", "self", "::", "setAttributes", "(", "$", "map", ",", "$", "obj", ",", "\\", "RTTI", "::", "IS_PRIVATE", ",", "$", "setterPrefix", ",", "$", "useCamelCase", ")", ";", "}" ]
Set the attribute values of a object. This method has been kept for backward compatibility. @param array $map A map with the attribute names and values to be changed. @param object $obj The object to be changed. @param string $setterPrefix The prefix for setter public methods (defaults to 'set'). @param bool $useCamelCase If true, private and protected attributes will be set by camelCase public methods (default true).
[ "Set", "the", "attribute", "values", "of", "a", "object", ".", "This", "method", "has", "been", "kept", "for", "backward", "compatibility", "." ]
train
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L229-L233
thiagodp/rtti
lib/RTTI.php
RTTI.mb_ucfirst
private static function mb_ucfirst( $str ) { if ( ! is_string( $str ) || '' === $str) { return ''; } $first = mb_strtoupper( mb_substr( $str, 0, 1 ) ); if ( 1 === mb_strlen( $str ) ) { return $first; } return $first . mb_substr( $str, 1 ); }
php
private static function mb_ucfirst( $str ) { if ( ! is_string( $str ) || '' === $str) { return ''; } $first = mb_strtoupper( mb_substr( $str, 0, 1 ) ); if ( 1 === mb_strlen( $str ) ) { return $first; } return $first . mb_substr( $str, 1 ); }
[ "private", "static", "function", "mb_ucfirst", "(", "$", "str", ")", "{", "if", "(", "!", "is_string", "(", "$", "str", ")", "||", "''", "===", "$", "str", ")", "{", "return", "''", ";", "}", "$", "first", "=", "mb_strtoupper", "(", "mb_substr", "(", "$", "str", ",", "0", ",", "1", ")", ")", ";", "if", "(", "1", "===", "mb_strlen", "(", "$", "str", ")", ")", "{", "return", "$", "first", ";", "}", "return", "$", "first", ".", "mb_substr", "(", "$", "str", ",", "1", ")", ";", "}" ]
Multibyte version of ucfirst()
[ "Multibyte", "version", "of", "ucfirst", "()" ]
train
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L236-L241
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php
Dwoo_Template_File.setIncludePath
public function setIncludePath($paths) { if (is_array($paths) === false) { $paths = array($paths); } $this->includePath = $paths; $this->resolvedPath = null; }
php
public function setIncludePath($paths) { if (is_array($paths) === false) { $paths = array($paths); } $this->includePath = $paths; $this->resolvedPath = null; }
[ "public", "function", "setIncludePath", "(", "$", "paths", ")", "{", "if", "(", "is_array", "(", "$", "paths", ")", "===", "false", ")", "{", "$", "paths", "=", "array", "(", "$", "paths", ")", ";", "}", "$", "this", "->", "includePath", "=", "$", "paths", ";", "$", "this", "->", "resolvedPath", "=", "null", ";", "}" ]
sets the include path(s) to where the given template filename must be looked up @param mixed $paths the path to look into, can be string for a single path or an array of paths
[ "sets", "the", "include", "path", "(", "s", ")", "to", "where", "the", "given", "template", "filename", "must", "be", "looked", "up" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php#L82-L90
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php
Dwoo_Template_File.getResourceIdentifier
public function getResourceIdentifier() { if ($this->resolvedPath !== null) { return $this->resolvedPath; } elseif ($this->includePath === null) { return $this->file; } else { foreach ($this->includePath as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR); if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; return $this->resolvedPath; } } throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)'); } }
php
public function getResourceIdentifier() { if ($this->resolvedPath !== null) { return $this->resolvedPath; } elseif ($this->includePath === null) { return $this->file; } else { foreach ($this->includePath as $path) { $path = rtrim($path, DIRECTORY_SEPARATOR); if (file_exists($path.DIRECTORY_SEPARATOR.$this->file) === true) { $this->resolvedPath = $path . DIRECTORY_SEPARATOR . $this->file; return $this->resolvedPath; } } throw new Dwoo_Exception('Template "'.$this->file.'" could not be found in any of your include path(s)'); } }
[ "public", "function", "getResourceIdentifier", "(", ")", "{", "if", "(", "$", "this", "->", "resolvedPath", "!==", "null", ")", "{", "return", "$", "this", "->", "resolvedPath", ";", "}", "elseif", "(", "$", "this", "->", "includePath", "===", "null", ")", "{", "return", "$", "this", "->", "file", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "includePath", "as", "$", "path", ")", "{", "$", "path", "=", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ";", "if", "(", "file_exists", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "file", ")", "===", "true", ")", "{", "$", "this", "->", "resolvedPath", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "this", "->", "file", ";", "return", "$", "this", "->", "resolvedPath", ";", "}", "}", "throw", "new", "Dwoo_Exception", "(", "'Template \"'", ".", "$", "this", "->", "file", ".", "'\" could not be found in any of your include path(s)'", ")", ";", "}", "}" ]
returns this template's source filename @return string
[ "returns", "this", "template", "s", "source", "filename" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php#L138-L155
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php
Dwoo_Template_File.templateFactory
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null) { if (DIRECTORY_SEPARATOR === '\\') { $resourceId = str_replace(array("\t", "\n", "\r", "\f", "\v"), array('\\t', '\\n', '\\r', '\\f', '\\v'), $resourceId); } $resourceId = strtr($resourceId, '\\', '/'); $includePath = null; if (file_exists($resourceId) === false) { if ($parentTemplate === null) { $parentTemplate = $dwoo->getTemplate(); } if ($parentTemplate instanceof Dwoo_Template_File) { if ($includePath = $parentTemplate->getIncludePath()) { if (strstr($resourceId, '../')) { throw new Dwoo_Exception('When using an include path you can not reference a template into a parent directory (using ../)'); } } else { $resourceId = dirname($parentTemplate->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId; if (file_exists($resourceId) === false) { return null; } } } else { return null; } } if ($policy = $dwoo->getSecurityPolicy()) { while (true) { if (preg_match('{^([a-z]+?)://}i', $resourceId)) { throw new Dwoo_Security_Exception('The security policy prevents you to read files from external sources : <em>'.$resourceId.'</em>.'); } if ($includePath) { break; } $resourceId = realpath($resourceId); $dirs = $policy->getAllowedDirectories(); foreach ($dirs as $dir=>$dummy) { if (strpos($resourceId, $dir) === 0) { break 2; } } throw new Dwoo_Security_Exception('The security policy prevents you to read <em>'.$resourceId.'</em>'); } } $class = 'Dwoo_Template_File'; if ($parentTemplate) { $class = get_class($parentTemplate); } return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath); }
php
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null) { if (DIRECTORY_SEPARATOR === '\\') { $resourceId = str_replace(array("\t", "\n", "\r", "\f", "\v"), array('\\t', '\\n', '\\r', '\\f', '\\v'), $resourceId); } $resourceId = strtr($resourceId, '\\', '/'); $includePath = null; if (file_exists($resourceId) === false) { if ($parentTemplate === null) { $parentTemplate = $dwoo->getTemplate(); } if ($parentTemplate instanceof Dwoo_Template_File) { if ($includePath = $parentTemplate->getIncludePath()) { if (strstr($resourceId, '../')) { throw new Dwoo_Exception('When using an include path you can not reference a template into a parent directory (using ../)'); } } else { $resourceId = dirname($parentTemplate->getResourceIdentifier()).DIRECTORY_SEPARATOR.$resourceId; if (file_exists($resourceId) === false) { return null; } } } else { return null; } } if ($policy = $dwoo->getSecurityPolicy()) { while (true) { if (preg_match('{^([a-z]+?)://}i', $resourceId)) { throw new Dwoo_Security_Exception('The security policy prevents you to read files from external sources : <em>'.$resourceId.'</em>.'); } if ($includePath) { break; } $resourceId = realpath($resourceId); $dirs = $policy->getAllowedDirectories(); foreach ($dirs as $dir=>$dummy) { if (strpos($resourceId, $dir) === 0) { break 2; } } throw new Dwoo_Security_Exception('The security policy prevents you to read <em>'.$resourceId.'</em>'); } } $class = 'Dwoo_Template_File'; if ($parentTemplate) { $class = get_class($parentTemplate); } return new $class($resourceId, $cacheTime, $cacheId, $compileId, $includePath); }
[ "public", "static", "function", "templateFactory", "(", "Dwoo", "$", "dwoo", ",", "$", "resourceId", ",", "$", "cacheTime", "=", "null", ",", "$", "cacheId", "=", "null", ",", "$", "compileId", "=", "null", ",", "Dwoo_ITemplate", "$", "parentTemplate", "=", "null", ")", "{", "if", "(", "DIRECTORY_SEPARATOR", "===", "'\\\\'", ")", "{", "$", "resourceId", "=", "str_replace", "(", "array", "(", "\"\\t\"", ",", "\"\\n\"", ",", "\"\\r\"", ",", "\"\\f\"", ",", "\"\\v\"", ")", ",", "array", "(", "'\\\\t'", ",", "'\\\\n'", ",", "'\\\\r'", ",", "'\\\\f'", ",", "'\\\\v'", ")", ",", "$", "resourceId", ")", ";", "}", "$", "resourceId", "=", "strtr", "(", "$", "resourceId", ",", "'\\\\'", ",", "'/'", ")", ";", "$", "includePath", "=", "null", ";", "if", "(", "file_exists", "(", "$", "resourceId", ")", "===", "false", ")", "{", "if", "(", "$", "parentTemplate", "===", "null", ")", "{", "$", "parentTemplate", "=", "$", "dwoo", "->", "getTemplate", "(", ")", ";", "}", "if", "(", "$", "parentTemplate", "instanceof", "Dwoo_Template_File", ")", "{", "if", "(", "$", "includePath", "=", "$", "parentTemplate", "->", "getIncludePath", "(", ")", ")", "{", "if", "(", "strstr", "(", "$", "resourceId", ",", "'../'", ")", ")", "{", "throw", "new", "Dwoo_Exception", "(", "'When using an include path you can not reference a template into a parent directory (using ../)'", ")", ";", "}", "}", "else", "{", "$", "resourceId", "=", "dirname", "(", "$", "parentTemplate", "->", "getResourceIdentifier", "(", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "resourceId", ";", "if", "(", "file_exists", "(", "$", "resourceId", ")", "===", "false", ")", "{", "return", "null", ";", "}", "}", "}", "else", "{", "return", "null", ";", "}", "}", "if", "(", "$", "policy", "=", "$", "dwoo", "->", "getSecurityPolicy", "(", ")", ")", "{", "while", "(", "true", ")", "{", "if", "(", "preg_match", "(", "'{^([a-z]+?)://}i'", ",", "$", "resourceId", ")", ")", "{", "throw", "new", "Dwoo_Security_Exception", "(", "'The security policy prevents you to read files from external sources : <em>'", ".", "$", "resourceId", ".", "'</em>.'", ")", ";", "}", "if", "(", "$", "includePath", ")", "{", "break", ";", "}", "$", "resourceId", "=", "realpath", "(", "$", "resourceId", ")", ";", "$", "dirs", "=", "$", "policy", "->", "getAllowedDirectories", "(", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", "=>", "$", "dummy", ")", "{", "if", "(", "strpos", "(", "$", "resourceId", ",", "$", "dir", ")", "===", "0", ")", "{", "break", "2", ";", "}", "}", "throw", "new", "Dwoo_Security_Exception", "(", "'The security policy prevents you to read <em>'", ".", "$", "resourceId", ".", "'</em>'", ")", ";", "}", "}", "$", "class", "=", "'Dwoo_Template_File'", ";", "if", "(", "$", "parentTemplate", ")", "{", "$", "class", "=", "get_class", "(", "$", "parentTemplate", ")", ";", "}", "return", "new", "$", "class", "(", "$", "resourceId", ",", "$", "cacheTime", ",", "$", "cacheId", ",", "$", "compileId", ",", "$", "includePath", ")", ";", "}" ]
returns a new template object from the given include name, null if no include is possible (resource not found), or false if include is not permitted by this resource type @param Dwoo $dwoo the dwoo instance requiring it @param mixed $resourceId the filename (relative to this template's dir) of the template to include @param int $cacheTime duration of the cache validity for this template, if null it defaults to the Dwoo instance that will render this template @param string $cacheId the unique cache identifier of this page or anything else that makes this template's content unique, if null it defaults to the current url @param string $compileId the unique compiled identifier, which is used to distinguish this template from others, if null it defaults to the filename+bits of the path @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through an include, extends or any other plugin) @return Dwoo_Template_File|null
[ "returns", "a", "new", "template", "object", "from", "the", "given", "include", "name", "null", "if", "no", "include", "is", "possible", "(", "resource", "not", "found", ")", "or", "false", "if", "include", "is", "not", "permitted", "by", "this", "resource", "type" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php#L186-L241
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php
Dwoo_Template_File.getCompiledFilename
protected function getCompiledFilename(Dwoo $dwoo) { // no compile id was provided, set default if ($this->compileId===null) { $this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-')); } return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo::RELEASE_TAG.'.php'; }
php
protected function getCompiledFilename(Dwoo $dwoo) { // no compile id was provided, set default if ($this->compileId===null) { $this->compileId = str_replace('../', '__', strtr($this->getResourceIdentifier(), '\\:', '/-')); } return $dwoo->getCompileDir() . $this->compileId.'.d'.Dwoo::RELEASE_TAG.'.php'; }
[ "protected", "function", "getCompiledFilename", "(", "Dwoo", "$", "dwoo", ")", "{", "// no compile id was provided, set default", "if", "(", "$", "this", "->", "compileId", "===", "null", ")", "{", "$", "this", "->", "compileId", "=", "str_replace", "(", "'../'", ",", "'__'", ",", "strtr", "(", "$", "this", "->", "getResourceIdentifier", "(", ")", ",", "'\\\\:'", ",", "'/-'", ")", ")", ";", "}", "return", "$", "dwoo", "->", "getCompileDir", "(", ")", ".", "$", "this", "->", "compileId", ".", "'.d'", ".", "Dwoo", "::", "RELEASE_TAG", ".", "'.php'", ";", "}" ]
returns the full compiled file name and assigns a default value to it if required @param Dwoo $dwoo the dwoo instance that requests the file name @return string the full path to the compiled file
[ "returns", "the", "full", "compiled", "file", "name", "and", "assigns", "a", "default", "value", "to", "it", "if", "required" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Template/File.php#L250-L257
ClementIV/yii-rest-rbac2.0
controllers/RouteController.php
RouteController.actionCreate
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } try{ $routes = Yii::$app->getRequest()->post('route', ''); $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY); $methods = Yii::$app->getRequest()->post('methods', ''); $model = new Route(); $model->addNewMethod($routes,$methods); return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
php
public function actionCreate() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['create']); } try{ $routes = Yii::$app->getRequest()->post('route', ''); $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY); $methods = Yii::$app->getRequest()->post('methods', ''); $model = new Route(); $model->addNewMethod($routes,$methods); return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'create'", "]", ")", ";", "}", "try", "{", "$", "routes", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'route'", ",", "''", ")", ";", "$", "routes", "=", "preg_split", "(", "'/\\s*,\\s*/'", ",", "trim", "(", "$", "routes", ")", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "methods", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'methods'", ",", "''", ")", ";", "$", "model", "=", "new", "Route", "(", ")", ";", "$", "model", "->", "addNewMethod", "(", "$", "routes", ",", "$", "methods", ")", ";", "return", "$", "model", "->", "getRoutes", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Creates a new AuthItem model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "AuthItem", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RouteController.php#L67-L84
ClementIV/yii-rest-rbac2.0
controllers/RouteController.php
RouteController.actionAssign
public function actionAssign() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['assign']); } try{ $routes = Yii::$app->getRequest()->post('routes', []); $model = new Route(); $model->addNew($routes); //var_dump();die(); Yii::$app->getResponse()->format = 'json'; return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
php
public function actionAssign() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['assign']); } try{ $routes = Yii::$app->getRequest()->post('routes', []); $model = new Route(); $model->addNew($routes); //var_dump();die(); Yii::$app->getResponse()->format = 'json'; return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionAssign", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'assign'", "]", ")", ";", "}", "try", "{", "$", "routes", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'routes'", ",", "[", "]", ")", ";", "$", "model", "=", "new", "Route", "(", ")", ";", "$", "model", "->", "addNew", "(", "$", "routes", ")", ";", "//var_dump();die();", "Yii", "::", "$", "app", "->", "getResponse", "(", ")", "->", "format", "=", "'json'", ";", "return", "$", "model", "->", "getRoutes", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Assign routes @return array
[ "Assign", "routes" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RouteController.php#L90-L109
ClementIV/yii-rest-rbac2.0
controllers/RouteController.php
RouteController.actionRefresh
public function actionRefresh() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['refresh']); } try{ $model = new Route(); $model->invalidate(); Yii::$app->getResponse()->format = 'json'; return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
php
public function actionRefresh() { $request = \Yii::$app->request; if ($request->getIsOptions()) { return $this->ResponseOptions($this->verbs()['refresh']); } try{ $model = new Route(); $model->invalidate(); Yii::$app->getResponse()->format = 'json'; return $model->getRoutes(); }catch(Exception $e){ throw new Exception($e); } }
[ "public", "function", "actionRefresh", "(", ")", "{", "$", "request", "=", "\\", "Yii", "::", "$", "app", "->", "request", ";", "if", "(", "$", "request", "->", "getIsOptions", "(", ")", ")", "{", "return", "$", "this", "->", "ResponseOptions", "(", "$", "this", "->", "verbs", "(", ")", "[", "'refresh'", "]", ")", ";", "}", "try", "{", "$", "model", "=", "new", "Route", "(", ")", ";", "$", "model", "->", "invalidate", "(", ")", ";", "Yii", "::", "$", "app", "->", "getResponse", "(", ")", "->", "format", "=", "'json'", ";", "return", "$", "model", "->", "getRoutes", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", ")", ";", "}", "}" ]
Refresh cache @return type
[ "Refresh", "cache" ]
train
https://github.com/ClementIV/yii-rest-rbac2.0/blob/435ffceca8d51b4d369182db3a06c20f336e9ac4/controllers/RouteController.php#L137-L152
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.copy
private function copy() { $this->setCopied($this->getFilesystem()->get(app_path() . '/database/seeds/DatabaseSeeder.php')); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.old', $this->getCopied()); }
php
private function copy() { $this->setCopied($this->getFilesystem()->get(app_path() . '/database/seeds/DatabaseSeeder.php')); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.old', $this->getCopied()); }
[ "private", "function", "copy", "(", ")", "{", "$", "this", "->", "setCopied", "(", "$", "this", "->", "getFilesystem", "(", ")", "->", "get", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ")", ")", ";", "$", "this", "->", "getFilesystem", "(", ")", "->", "put", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.old'", ",", "$", "this", "->", "getCopied", "(", ")", ")", ";", "}" ]
@version 1.0.0 Copy the current DatabaseSeeder.php file and save it to the proper attribute. @version 1.0.1 Copy the current DatabaseSeeder.php file and save it to a new file called DatabaseSeeder.old
[ "@version", "1", ".", "0", ".", "0", "Copy", "the", "current", "DatabaseSeeder", ".", "php", "file", "and", "save", "it", "to", "the", "proper", "attribute", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L136-L141
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.read
private function read() { $files = $this->getFilesystem()->allFiles(app_path() . '/database/seeds'); $filtered = []; foreach ($files as $file) { if (strpos(file_get_contents($file->getPathName()), 'extends Seeder') != false) { if ($file->getFileName() != 'DatabaseSeeder.php') { $filtered[] = $file->getFileName(); } } } $this->setFiles($filtered); }
php
private function read() { $files = $this->getFilesystem()->allFiles(app_path() . '/database/seeds'); $filtered = []; foreach ($files as $file) { if (strpos(file_get_contents($file->getPathName()), 'extends Seeder') != false) { if ($file->getFileName() != 'DatabaseSeeder.php') { $filtered[] = $file->getFileName(); } } } $this->setFiles($filtered); }
[ "private", "function", "read", "(", ")", "{", "$", "files", "=", "$", "this", "->", "getFilesystem", "(", ")", "->", "allFiles", "(", "app_path", "(", ")", ".", "'/database/seeds'", ")", ";", "$", "filtered", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "strpos", "(", "file_get_contents", "(", "$", "file", "->", "getPathName", "(", ")", ")", ",", "'extends Seeder'", ")", "!=", "false", ")", "{", "if", "(", "$", "file", "->", "getFileName", "(", ")", "!=", "'DatabaseSeeder.php'", ")", "{", "$", "filtered", "[", "]", "=", "$", "file", "->", "getFileName", "(", ")", ";", "}", "}", "}", "$", "this", "->", "setFiles", "(", "$", "filtered", ")", ";", "}" ]
Get an array of all the files that is actually compatible with the files we're looking for.
[ "Get", "an", "array", "of", "all", "the", "files", "that", "is", "actually", "compatible", "with", "the", "files", "we", "re", "looking", "for", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L147-L165
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.write
private function write() { $content = ''; foreach ($this->getFiles() as $file) { $content .= '$this->call(\'' . str_replace('.php', '', $file) . '\');'; } $databaseSeeder = str_replace('{calls}', $content, $this->getPattern()); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $databaseSeeder); }
php
private function write() { $content = ''; foreach ($this->getFiles() as $file) { $content .= '$this->call(\'' . str_replace('.php', '', $file) . '\');'; } $databaseSeeder = str_replace('{calls}', $content, $this->getPattern()); $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $databaseSeeder); }
[ "private", "function", "write", "(", ")", "{", "$", "content", "=", "''", ";", "foreach", "(", "$", "this", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "content", ".=", "'$this->call(\\''", ".", "str_replace", "(", "'.php'", ",", "''", ",", "$", "file", ")", ".", "'\\');'", ";", "}", "$", "databaseSeeder", "=", "str_replace", "(", "'{calls}'", ",", "$", "content", ",", "$", "this", "->", "getPattern", "(", ")", ")", ";", "$", "this", "->", "getFilesystem", "(", ")", "->", "put", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ",", "$", "databaseSeeder", ")", ";", "}" ]
Write the new DatabaseSeeder.php
[ "Write", "the", "new", "DatabaseSeeder", ".", "php" ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L171-L183
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.restore
public function restore() { $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $this->getCopied()); $this->getFilesystem()->delete(app_path() . '/database/seeds/DatabaseSeeder.old'); }
php
public function restore() { $this->getFilesystem()->put(app_path() . '/database/seeds/DatabaseSeeder.php', $this->getCopied()); $this->getFilesystem()->delete(app_path() . '/database/seeds/DatabaseSeeder.old'); }
[ "public", "function", "restore", "(", ")", "{", "$", "this", "->", "getFilesystem", "(", ")", "->", "put", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.php'", ",", "$", "this", "->", "getCopied", "(", ")", ")", ";", "$", "this", "->", "getFilesystem", "(", ")", "->", "delete", "(", "app_path", "(", ")", ".", "'/database/seeds/DatabaseSeeder.old'", ")", ";", "}" ]
Restore the DatabaseSeeder.php file to it's previous version.
[ "Restore", "the", "DatabaseSeeder", ".", "php", "file", "to", "it", "s", "previous", "version", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L189-L194
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.all
public function all() { $this->copy(); $this->read(); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
php
public function all() { $this->copy(); $this->read(); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
[ "public", "function", "all", "(", ")", "{", "$", "this", "->", "copy", "(", ")", ";", "$", "this", "->", "read", "(", ")", ";", "$", "this", "->", "write", "(", ")", ";", "$", "this", "->", "setSeeded", "(", "count", "(", "$", "this", "->", "getFiles", "(", ")", ")", ")", ";", "return", "true", ";", "}" ]
Copy the current DatabaseSeeder.php file, read the /seeds directory in search for compatible files, write the new DatabaseSeeder.php file and return true if it's alright. @return boolean
[ "Copy", "the", "current", "DatabaseSeeder", ".", "php", "file", "read", "the", "/", "seeds", "directory", "in", "search", "for", "compatible", "files", "write", "the", "new", "DatabaseSeeder", ".", "php", "file", "and", "return", "true", "if", "it", "s", "alright", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L202-L213
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.getList
public function getList($list) { $filteredList = []; foreach (explode(',', $list) as $item) { if ($item != '') { $filteredList[] = $item; } } return $filteredList; }
php
public function getList($list) { $filteredList = []; foreach (explode(',', $list) as $item) { if ($item != '') { $filteredList[] = $item; } } return $filteredList; }
[ "public", "function", "getList", "(", "$", "list", ")", "{", "$", "filteredList", "=", "[", "]", ";", "foreach", "(", "explode", "(", "','", ",", "$", "list", ")", "as", "$", "item", ")", "{", "if", "(", "$", "item", "!=", "''", ")", "{", "$", "filteredList", "[", "]", "=", "$", "item", ";", "}", "}", "return", "$", "filteredList", ";", "}" ]
Recieves the string list entered by the developer, explode it and only return the ones filtered. @param string $list @return array
[ "Recieves", "the", "string", "list", "entered", "by", "the", "developer", "explode", "it", "and", "only", "return", "the", "ones", "filtered", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L221-L234
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.readForOnly
public function readForOnly($list) { $this->read(); $files = $this->getFiles(); $filtered = []; foreach ($this->getList($list) as $list) { $list = trim($list); if (in_array($list, $files) || in_array($list . '.php', $files)) { $filtered[] = $list; } } $this->setFiles($filtered); }
php
public function readForOnly($list) { $this->read(); $files = $this->getFiles(); $filtered = []; foreach ($this->getList($list) as $list) { $list = trim($list); if (in_array($list, $files) || in_array($list . '.php', $files)) { $filtered[] = $list; } } $this->setFiles($filtered); }
[ "public", "function", "readForOnly", "(", "$", "list", ")", "{", "$", "this", "->", "read", "(", ")", ";", "$", "files", "=", "$", "this", "->", "getFiles", "(", ")", ";", "$", "filtered", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getList", "(", "$", "list", ")", "as", "$", "list", ")", "{", "$", "list", "=", "trim", "(", "$", "list", ")", ";", "if", "(", "in_array", "(", "$", "list", ",", "$", "files", ")", "||", "in_array", "(", "$", "list", ".", "'.php'", ",", "$", "files", ")", ")", "{", "$", "filtered", "[", "]", "=", "$", "list", ";", "}", "}", "$", "this", "->", "setFiles", "(", "$", "filtered", ")", ";", "}" ]
Prepare the stage for the db:only command to work properly.
[ "Prepare", "the", "stage", "for", "the", "db", ":", "only", "command", "to", "work", "properly", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L240-L259
welderlourenco/laravel-seeder
src/WelderLourenco/LaravelSeeder/LaravelSeeder.php
LaravelSeeder.only
public function only($list) { $this->copy(); $this->readForOnly($list); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
php
public function only($list) { $this->copy(); $this->readForOnly($list); $this->write(); $this->setSeeded(count($this->getFiles())); return true; }
[ "public", "function", "only", "(", "$", "list", ")", "{", "$", "this", "->", "copy", "(", ")", ";", "$", "this", "->", "readForOnly", "(", "$", "list", ")", ";", "$", "this", "->", "write", "(", ")", ";", "$", "this", "->", "setSeeded", "(", "count", "(", "$", "this", "->", "getFiles", "(", ")", ")", ")", ";", "return", "true", ";", "}" ]
Copy the current DatabaseSeeder.php file, loop through each file and verify it's idententy with ther files array, write the new DatabaseSeeder.php file and return true if it's alright. @param string $list @return boolean
[ "Copy", "the", "current", "DatabaseSeeder", ".", "php", "file", "loop", "through", "each", "file", "and", "verify", "it", "s", "idententy", "with", "ther", "files", "array", "write", "the", "new", "DatabaseSeeder", ".", "php", "file", "and", "return", "true", "if", "it", "s", "alright", "." ]
train
https://github.com/welderlourenco/laravel-seeder/blob/165d1f3bd596e985d5ef6ddd5fe3ad21589f17ad/src/WelderLourenco/LaravelSeeder/LaravelSeeder.php#L268-L279
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.get
public function get($content, array $variables = []) { $replacements = []; $instruction = 'foreach'; foreach ($variables as $key => $values) { $inner = $this->getInnerInstruction($content, $instruction); foreach ($inner as $config) { if (!str_contains($config['cleared'], $key)) { continue; } $replacements[$key] = $inner; } } if (!empty($replacements)) { foreach ($replacements as $key => $value) { foreach ($value as $element) { $inner = $this->renderByTwig($element['cleared'], $variables); $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content); } } } $content = str_replace(['<p>', '</p>', '<br />'], '', $content); $filled = $this->fill($content); preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $filled; } foreach ($matches[0] as $index => $variable) { $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled); } return $this->renderByTwig($filled, array_merge($variables, $this->variables)); }
php
public function get($content, array $variables = []) { $replacements = []; $instruction = 'foreach'; foreach ($variables as $key => $values) { $inner = $this->getInnerInstruction($content, $instruction); foreach ($inner as $config) { if (!str_contains($config['cleared'], $key)) { continue; } $replacements[$key] = $inner; } } if (!empty($replacements)) { foreach ($replacements as $key => $value) { foreach ($value as $element) { $inner = $this->renderByTwig($element['cleared'], $variables); $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $element['to_replace']], ['', '', $inner], $content); } } } $content = str_replace(['<p>', '</p>', '<br />'], '', $content); $filled = $this->fill($content); preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $filled; } foreach ($matches[0] as $index => $variable) { $filled = str_replace($variable, '{{ ' . $matches[1][$index] . ' }}', $filled); } return $this->renderByTwig($filled, array_merge($variables, $this->variables)); }
[ "public", "function", "get", "(", "$", "content", ",", "array", "$", "variables", "=", "[", "]", ")", "{", "$", "replacements", "=", "[", "]", ";", "$", "instruction", "=", "'foreach'", ";", "foreach", "(", "$", "variables", "as", "$", "key", "=>", "$", "values", ")", "{", "$", "inner", "=", "$", "this", "->", "getInnerInstruction", "(", "$", "content", ",", "$", "instruction", ")", ";", "foreach", "(", "$", "inner", "as", "$", "config", ")", "{", "if", "(", "!", "str_contains", "(", "$", "config", "[", "'cleared'", "]", ",", "$", "key", ")", ")", "{", "continue", ";", "}", "$", "replacements", "[", "$", "key", "]", "=", "$", "inner", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "replacements", ")", ")", "{", "foreach", "(", "$", "replacements", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "value", "as", "$", "element", ")", "{", "$", "inner", "=", "$", "this", "->", "renderByTwig", "(", "$", "element", "[", "'cleared'", "]", ",", "$", "variables", ")", ";", "$", "content", "=", "str_replace", "(", "[", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ",", "$", "element", "[", "'to_replace'", "]", "]", ",", "[", "''", ",", "''", ",", "$", "inner", "]", ",", "$", "content", ")", ";", "}", "}", "}", "$", "content", "=", "str_replace", "(", "[", "'<p>'", ",", "'</p>'", ",", "'<br />'", "]", ",", "''", ",", "$", "content", ")", ";", "$", "filled", "=", "$", "this", "->", "fill", "(", "$", "content", ")", ";", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ")", "or", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "$", "filled", ";", "}", "foreach", "(", "$", "matches", "[", "0", "]", "as", "$", "index", "=>", "$", "variable", ")", "{", "$", "filled", "=", "str_replace", "(", "$", "variable", ",", "'{{ '", ".", "$", "matches", "[", "1", "]", "[", "$", "index", "]", ".", "' }}'", ",", "$", "filled", ")", ";", "}", "return", "$", "this", "->", "renderByTwig", "(", "$", "filled", ",", "array_merge", "(", "$", "variables", ",", "$", "this", "->", "variables", ")", ")", ";", "}" ]
Gets variables filled notification content @param string $content @param array $variables @return String
[ "Gets", "variables", "filled", "notification", "content" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L49-L85
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.getInnerInstruction
protected function getInnerInstruction($content, $instruction) { $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); $replacements = []; foreach ($sources as $index => $source) { $toReplace = $source; $source = $this->clearCondition($source); $replacements[$index] = [ 'to_replace' => $toReplace, 'cleared' => $source ]; } return $replacements; }
php
protected function getInnerInstruction($content, $instruction) { $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); $replacements = []; foreach ($sources as $index => $source) { $toReplace = $source; $source = $this->clearCondition($source); $replacements[$index] = [ 'to_replace' => $toReplace, 'cleared' => $source ]; } return $replacements; }
[ "protected", "function", "getInnerInstruction", "(", "$", "content", ",", "$", "instruction", ")", "{", "$", "sources", "=", "$", "this", "->", "getStringsBetween", "(", "$", "content", ",", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ")", ";", "$", "replacements", "=", "[", "]", ";", "foreach", "(", "$", "sources", "as", "$", "index", "=>", "$", "source", ")", "{", "$", "toReplace", "=", "$", "source", ";", "$", "source", "=", "$", "this", "->", "clearCondition", "(", "$", "source", ")", ";", "$", "replacements", "[", "$", "index", "]", "=", "[", "'to_replace'", "=>", "$", "toReplace", ",", "'cleared'", "=>", "$", "source", "]", ";", "}", "return", "$", "replacements", ";", "}" ]
Innser instruction @param string $content @param string $instruction @return array
[ "Innser", "instruction" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L104-L119
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.fill
public function fill($content) { if ($this->hasInstructions($content)) { $instructions = $this->getInstructions(); foreach ($instructions as $instruction) { $content = $this->parseInstructions($content, $instruction); } } return $this->fillContent($content); }
php
public function fill($content) { if ($this->hasInstructions($content)) { $instructions = $this->getInstructions(); foreach ($instructions as $instruction) { $content = $this->parseInstructions($content, $instruction); } } return $this->fillContent($content); }
[ "public", "function", "fill", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "hasInstructions", "(", "$", "content", ")", ")", "{", "$", "instructions", "=", "$", "this", "->", "getInstructions", "(", ")", ";", "foreach", "(", "$", "instructions", "as", "$", "instruction", ")", "{", "$", "content", "=", "$", "this", "->", "parseInstructions", "(", "$", "content", ",", "$", "instruction", ")", ";", "}", "}", "return", "$", "this", "->", "fillContent", "(", "$", "content", ")", ";", "}" ]
fill notification notification content with variables @param String $content @return String
[ "fill", "notification", "notification", "content", "with", "variables" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L127-L136
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.hasInstructions
protected function hasInstructions($content) { $instructionKeys = $this->getInstructions(); foreach ($instructionKeys as $instructionKey) { if (str_contains($content, ['[[' . $instructionKey . ']]', '[[/' . $instructionKey . ']]'])) { return true; } } return false; }
php
protected function hasInstructions($content) { $instructionKeys = $this->getInstructions(); foreach ($instructionKeys as $instructionKey) { if (str_contains($content, ['[[' . $instructionKey . ']]', '[[/' . $instructionKey . ']]'])) { return true; } } return false; }
[ "protected", "function", "hasInstructions", "(", "$", "content", ")", "{", "$", "instructionKeys", "=", "$", "this", "->", "getInstructions", "(", ")", ";", "foreach", "(", "$", "instructionKeys", "as", "$", "instructionKey", ")", "{", "if", "(", "str_contains", "(", "$", "content", ",", "[", "'[['", ".", "$", "instructionKey", ".", "']]'", ",", "'[[/'", ".", "$", "instructionKey", ".", "']]'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
whether notification has instructions @param String $content @return boolean
[ "whether", "notification", "has", "instructions" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L158-L167
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.parseInstructions
protected function parseInstructions($content, $instruction) { $twig = new Twig_Environment(new Twig_Loader_String()); $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); foreach ($sources as $source) { $toReplace = $source; $source = $this->clearCondition($source); if ($source === '') { return $content; } $variables = $this->extractVariables($source); $renderParams = []; foreach (array_keys($variables) as $index => $key) { $localVariable = 'var_' . $index; $source = str_replace($key, $localVariable, $source); $renderParams[$localVariable] = $variables[$key]; } $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content); } return $content; }
php
protected function parseInstructions($content, $instruction) { $twig = new Twig_Environment(new Twig_Loader_String()); $sources = $this->getStringsBetween($content, "[[{$instruction}]]", "[[/{$instruction}]]"); foreach ($sources as $source) { $toReplace = $source; $source = $this->clearCondition($source); if ($source === '') { return $content; } $variables = $this->extractVariables($source); $renderParams = []; foreach (array_keys($variables) as $index => $key) { $localVariable = 'var_' . $index; $source = str_replace($key, $localVariable, $source); $renderParams[$localVariable] = $variables[$key]; } $content = str_replace(["[[{$instruction}]]", "[[/{$instruction}]]", $toReplace], ['', '', $twig->render($source, $renderParams)], $content); } return $content; }
[ "protected", "function", "parseInstructions", "(", "$", "content", ",", "$", "instruction", ")", "{", "$", "twig", "=", "new", "Twig_Environment", "(", "new", "Twig_Loader_String", "(", ")", ")", ";", "$", "sources", "=", "$", "this", "->", "getStringsBetween", "(", "$", "content", ",", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ")", ";", "foreach", "(", "$", "sources", "as", "$", "source", ")", "{", "$", "toReplace", "=", "$", "source", ";", "$", "source", "=", "$", "this", "->", "clearCondition", "(", "$", "source", ")", ";", "if", "(", "$", "source", "===", "''", ")", "{", "return", "$", "content", ";", "}", "$", "variables", "=", "$", "this", "->", "extractVariables", "(", "$", "source", ")", ";", "$", "renderParams", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "variables", ")", "as", "$", "index", "=>", "$", "key", ")", "{", "$", "localVariable", "=", "'var_'", ".", "$", "index", ";", "$", "source", "=", "str_replace", "(", "$", "key", ",", "$", "localVariable", ",", "$", "source", ")", ";", "$", "renderParams", "[", "$", "localVariable", "]", "=", "$", "variables", "[", "$", "key", "]", ";", "}", "$", "content", "=", "str_replace", "(", "[", "\"[[{$instruction}]]\"", ",", "\"[[/{$instruction}]]\"", ",", "$", "toReplace", "]", ",", "[", "''", ",", "''", ",", "$", "twig", "->", "render", "(", "$", "source", ",", "$", "renderParams", ")", "]", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
parsing instructions in notification content @param String $content @param String $instruction @return String
[ "parsing", "instructions", "in", "notification", "content" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L176-L197
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.clearCondition
protected function clearCondition($source) { $line = $this->getStringBetween($source, '{%', '%}'); if (strlen($line) > 0) { return str_replace(['&#39;', '&nbsp;'], ["'", ' '], $source); } return $source; }
php
protected function clearCondition($source) { $line = $this->getStringBetween($source, '{%', '%}'); if (strlen($line) > 0) { return str_replace(['&#39;', '&nbsp;'], ["'", ' '], $source); } return $source; }
[ "protected", "function", "clearCondition", "(", "$", "source", ")", "{", "$", "line", "=", "$", "this", "->", "getStringBetween", "(", "$", "source", ",", "'{%'", ",", "'%}'", ")", ";", "if", "(", "strlen", "(", "$", "line", ")", ">", "0", ")", "{", "return", "str_replace", "(", "[", "'&#39;'", ",", "'&nbsp;'", "]", ",", "[", "\"'\"", ",", "' '", "]", ",", "$", "source", ")", ";", "}", "return", "$", "source", ";", "}" ]
clear conditions in notification @param String $source @return String
[ "clear", "conditions", "in", "notification" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L205-L212
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.getStringsBetween
public function getStringsBetween($string, $start, $end) { $lastPos = 0; $positions = array(); while (($lastPos = strpos($string, $start, $lastPos)) !== false) { $positions[] = $lastPos; $lastPos += strlen($start); } $lastPos = 0; $positionsEnd = array(); while (($lastPos = strpos($string, $end, $lastPos)) !== false) { $positionsEnd[] = $lastPos; $lastPos += strlen($end); } $return = []; foreach ($positions as $index => $position) { $return[] = str_replace([$start, $end], '', substr($string, $position, $positionsEnd[$index] - $position)); } return $return; }
php
public function getStringsBetween($string, $start, $end) { $lastPos = 0; $positions = array(); while (($lastPos = strpos($string, $start, $lastPos)) !== false) { $positions[] = $lastPos; $lastPos += strlen($start); } $lastPos = 0; $positionsEnd = array(); while (($lastPos = strpos($string, $end, $lastPos)) !== false) { $positionsEnd[] = $lastPos; $lastPos += strlen($end); } $return = []; foreach ($positions as $index => $position) { $return[] = str_replace([$start, $end], '', substr($string, $position, $positionsEnd[$index] - $position)); } return $return; }
[ "public", "function", "getStringsBetween", "(", "$", "string", ",", "$", "start", ",", "$", "end", ")", "{", "$", "lastPos", "=", "0", ";", "$", "positions", "=", "array", "(", ")", ";", "while", "(", "(", "$", "lastPos", "=", "strpos", "(", "$", "string", ",", "$", "start", ",", "$", "lastPos", ")", ")", "!==", "false", ")", "{", "$", "positions", "[", "]", "=", "$", "lastPos", ";", "$", "lastPos", "+=", "strlen", "(", "$", "start", ")", ";", "}", "$", "lastPos", "=", "0", ";", "$", "positionsEnd", "=", "array", "(", ")", ";", "while", "(", "(", "$", "lastPos", "=", "strpos", "(", "$", "string", ",", "$", "end", ",", "$", "lastPos", ")", ")", "!==", "false", ")", "{", "$", "positionsEnd", "[", "]", "=", "$", "lastPos", ";", "$", "lastPos", "+=", "strlen", "(", "$", "end", ")", ";", "}", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "positions", "as", "$", "index", "=>", "$", "position", ")", "{", "$", "return", "[", "]", "=", "str_replace", "(", "[", "$", "start", ",", "$", "end", "]", ",", "''", ",", "substr", "(", "$", "string", ",", "$", "position", ",", "$", "positionsEnd", "[", "$", "index", "]", "-", "$", "position", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
gets list of occurences between two strings @param String $string @param String $start @param String $end @return array
[ "gets", "list", "of", "occurences", "between", "two", "strings" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L222-L242
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.extractVariables
protected function extractVariables($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0], $matches[1])) { return []; } $return = []; $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ($matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); if (!$name) { continue; } $variables = $notifications[$name]['variables']; $return[$matches[0][$index]] = $this->resolveValue($var, $variables); } return $return; }
php
protected function extractVariables($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0], $matches[1])) { return []; } $return = []; $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ($matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); if (!$name) { continue; } $variables = $notifications[$name]['variables']; $return[$matches[0][$index]] = $this->resolveValue($var, $variables); } return $return; }
[ "protected", "function", "extractVariables", "(", "$", "content", ")", "{", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ",", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "[", "]", ";", "}", "$", "return", "=", "[", "]", ";", "$", "notifications", "=", "\\", "Antares", "\\", "Foundation", "\\", "Notification", "::", "getInstance", "(", ")", "->", "all", "(", ")", ";", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "index", "=>", "$", "match", ")", "{", "if", "(", "!", "str_contains", "(", "$", "match", ",", "'::'", ")", ")", "{", "continue", ";", "}", "list", "(", "$", "component", ",", "$", "var", ")", "=", "explode", "(", "'::'", ",", "trim", "(", "$", "match", ")", ")", ";", "$", "name", "=", "$", "this", "->", "findExtensionName", "(", "$", "component", ")", ";", "if", "(", "!", "$", "name", ")", "{", "continue", ";", "}", "$", "variables", "=", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ";", "$", "return", "[", "$", "matches", "[", "0", "]", "[", "$", "index", "]", "]", "=", "$", "this", "->", "resolveValue", "(", "$", "var", ",", "$", "variables", ")", ";", "}", "return", "$", "return", ";", "}" ]
extract variables from notification @param String $content @return array
[ "extract", "variables", "from", "notification" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L273-L296
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.fillContent
protected function fillContent($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $content; } $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ( (array) $matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); $variables = isset($notifications[$name]['variables']) ? $notifications[$name]['variables'] : []; event('notifications:notification.variables', [&$variables]); $value = $this->resolveValue($var, $variables); if (is_array($value)) { $value = $this->getDefaultNotificationForList($value)->render(); } $content = str_replace($matches[0][$index], $value, $content); } return $content; }
php
protected function fillContent($content) { preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); if (!isset($matches[0]) or ! isset($matches[1])) { return $content; } $notifications = \Antares\Foundation\Notification::getInstance()->all(); foreach ( (array) $matches[1] as $index => $match) { if (!str_contains($match, '::')) { continue; } list($component, $var) = explode('::', trim($match)); $name = $this->findExtensionName($component); $variables = isset($notifications[$name]['variables']) ? $notifications[$name]['variables'] : []; event('notifications:notification.variables', [&$variables]); $value = $this->resolveValue($var, $variables); if (is_array($value)) { $value = $this->getDefaultNotificationForList($value)->render(); } $content = str_replace($matches[0][$index], $value, $content); } return $content; }
[ "protected", "function", "fillContent", "(", "$", "content", ")", "{", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "0", "]", ")", "or", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "$", "content", ";", "}", "$", "notifications", "=", "\\", "Antares", "\\", "Foundation", "\\", "Notification", "::", "getInstance", "(", ")", "->", "all", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "matches", "[", "1", "]", "as", "$", "index", "=>", "$", "match", ")", "{", "if", "(", "!", "str_contains", "(", "$", "match", ",", "'::'", ")", ")", "{", "continue", ";", "}", "list", "(", "$", "component", ",", "$", "var", ")", "=", "explode", "(", "'::'", ",", "trim", "(", "$", "match", ")", ")", ";", "$", "name", "=", "$", "this", "->", "findExtensionName", "(", "$", "component", ")", ";", "$", "variables", "=", "isset", "(", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ")", "?", "$", "notifications", "[", "$", "name", "]", "[", "'variables'", "]", ":", "[", "]", ";", "event", "(", "'notifications:notification.variables'", ",", "[", "&", "$", "variables", "]", ")", ";", "$", "value", "=", "$", "this", "->", "resolveValue", "(", "$", "var", ",", "$", "variables", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getDefaultNotificationForList", "(", "$", "value", ")", "->", "render", "(", ")", ";", "}", "$", "content", "=", "str_replace", "(", "$", "matches", "[", "0", "]", "[", "$", "index", "]", ",", "$", "value", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
fills content with notification variables values @param String $content @return String
[ "fills", "content", "with", "notification", "variables", "values" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L304-L330
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.resolveValue
protected function resolveValue($name, $variables) { if (!empty($variables)) { foreach ($variables as $container => $vars) { foreach ($vars as $subname => $var) { $value = $var['value']; if(is_callable($value) && $var['name'] === $name) { return $value($this->variables); } if (isset($var['name']) and $name == $value and isset($value)) { return $value; } elseif (!isset($var['name']) and $subname == $name and isset($value)) { return $value; } } } } if (!isset($variables[$name])) { return false; } if (isset($variable['dataProvider'])) { $value = $this->resolveDataProviderValue($variable['dataProvider']); if (!$value) { return false; } return $value; } return array_get($variable, 'value', ''); }
php
protected function resolveValue($name, $variables) { if (!empty($variables)) { foreach ($variables as $container => $vars) { foreach ($vars as $subname => $var) { $value = $var['value']; if(is_callable($value) && $var['name'] === $name) { return $value($this->variables); } if (isset($var['name']) and $name == $value and isset($value)) { return $value; } elseif (!isset($var['name']) and $subname == $name and isset($value)) { return $value; } } } } if (!isset($variables[$name])) { return false; } if (isset($variable['dataProvider'])) { $value = $this->resolveDataProviderValue($variable['dataProvider']); if (!$value) { return false; } return $value; } return array_get($variable, 'value', ''); }
[ "protected", "function", "resolveValue", "(", "$", "name", ",", "$", "variables", ")", "{", "if", "(", "!", "empty", "(", "$", "variables", ")", ")", "{", "foreach", "(", "$", "variables", "as", "$", "container", "=>", "$", "vars", ")", "{", "foreach", "(", "$", "vars", "as", "$", "subname", "=>", "$", "var", ")", "{", "$", "value", "=", "$", "var", "[", "'value'", "]", ";", "if", "(", "is_callable", "(", "$", "value", ")", "&&", "$", "var", "[", "'name'", "]", "===", "$", "name", ")", "{", "return", "$", "value", "(", "$", "this", "->", "variables", ")", ";", "}", "if", "(", "isset", "(", "$", "var", "[", "'name'", "]", ")", "and", "$", "name", "==", "$", "value", "and", "isset", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "elseif", "(", "!", "isset", "(", "$", "var", "[", "'name'", "]", ")", "and", "$", "subname", "==", "$", "name", "and", "isset", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "}", "}", "}", "if", "(", "!", "isset", "(", "$", "variables", "[", "$", "name", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "variable", "[", "'dataProvider'", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "resolveDataProviderValue", "(", "$", "variable", "[", "'dataProvider'", "]", ")", ";", "if", "(", "!", "$", "value", ")", "{", "return", "false", ";", "}", "return", "$", "value", ";", "}", "return", "array_get", "(", "$", "variable", ",", "'value'", ",", "''", ")", ";", "}" ]
resolve notification variable value @param String $name @param array $variables @return mixed
[ "resolve", "notification", "variable", "value" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L339-L373
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.resolveDataProviderValue
protected function resolveDataProviderValue($dataProvider) { preg_match("/(.*)@(.*)/", $dataProvider, $matches); if (!isset($matches[1]) and ! isset($matches[2])) { return false; } if (!class_exists($matches[1])) { return false; } try { $instance = app($matches[1]); $return = call_user_func_array([$instance, $matches[2]], []); if ($return instanceof Builder) { return $return->get()->toArray(); } if ($return instanceof Collection) { return $return->toArray(); } return $return; } catch (Exception $ex) { return false; } }
php
protected function resolveDataProviderValue($dataProvider) { preg_match("/(.*)@(.*)/", $dataProvider, $matches); if (!isset($matches[1]) and ! isset($matches[2])) { return false; } if (!class_exists($matches[1])) { return false; } try { $instance = app($matches[1]); $return = call_user_func_array([$instance, $matches[2]], []); if ($return instanceof Builder) { return $return->get()->toArray(); } if ($return instanceof Collection) { return $return->toArray(); } return $return; } catch (Exception $ex) { return false; } }
[ "protected", "function", "resolveDataProviderValue", "(", "$", "dataProvider", ")", "{", "preg_match", "(", "\"/(.*)@(.*)/\"", ",", "$", "dataProvider", ",", "$", "matches", ")", ";", "if", "(", "!", "isset", "(", "$", "matches", "[", "1", "]", ")", "and", "!", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "class_exists", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "return", "false", ";", "}", "try", "{", "$", "instance", "=", "app", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "return", "=", "call_user_func_array", "(", "[", "$", "instance", ",", "$", "matches", "[", "2", "]", "]", ",", "[", "]", ")", ";", "if", "(", "$", "return", "instanceof", "Builder", ")", "{", "return", "$", "return", "->", "get", "(", ")", "->", "toArray", "(", ")", ";", "}", "if", "(", "$", "return", "instanceof", "Collection", ")", "{", "return", "$", "return", "->", "toArray", "(", ")", ";", "}", "return", "$", "return", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "false", ";", "}", "}" ]
resolve notification variable value from data provider @param mixed $dataProvider @return boolean|Collection
[ "resolve", "notification", "variable", "value", "from", "data", "provider" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L381-L403
antaresproject/notifications
src/Adapter/VariablesAdapter.php
VariablesAdapter.findExtensionName
protected function findExtensionName($name) { if ($name == 'foundation') { return $name; } $extensions = app('antares.memory')->make('component')->get('extensions.active'); foreach ($extensions as $keyname => $extension) { if ($name == $extension['name']) { return $keyname; } } return false; }
php
protected function findExtensionName($name) { if ($name == 'foundation') { return $name; } $extensions = app('antares.memory')->make('component')->get('extensions.active'); foreach ($extensions as $keyname => $extension) { if ($name == $extension['name']) { return $keyname; } } return false; }
[ "protected", "function", "findExtensionName", "(", "$", "name", ")", "{", "if", "(", "$", "name", "==", "'foundation'", ")", "{", "return", "$", "name", ";", "}", "$", "extensions", "=", "app", "(", "'antares.memory'", ")", "->", "make", "(", "'component'", ")", "->", "get", "(", "'extensions.active'", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "keyname", "=>", "$", "extension", ")", "{", "if", "(", "$", "name", "==", "$", "extension", "[", "'name'", "]", ")", "{", "return", "$", "keyname", ";", "}", "}", "return", "false", ";", "}" ]
get extension key name by name from manifest @param type $name @return boolean|String
[ "get", "extension", "key", "name", "by", "name", "from", "manifest" ]
train
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Adapter/VariablesAdapter.php#L411-L423
weew/http
src/Weew/Http/Cookies.php
Cookies.searchCookiesInHeaders
protected function searchCookiesInHeaders() { $headers = $this->holder->getHeaders()->get('set-cookie'); foreach ($headers as $header) { $cookie = $this->createCookieFromHeader($header); if ($cookie !== null) { $this->storeCookie($cookie); } } }
php
protected function searchCookiesInHeaders() { $headers = $this->holder->getHeaders()->get('set-cookie'); foreach ($headers as $header) { $cookie = $this->createCookieFromHeader($header); if ($cookie !== null) { $this->storeCookie($cookie); } } }
[ "protected", "function", "searchCookiesInHeaders", "(", ")", "{", "$", "headers", "=", "$", "this", "->", "holder", "->", "getHeaders", "(", ")", "->", "get", "(", "'set-cookie'", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "$", "cookie", "=", "$", "this", "->", "createCookieFromHeader", "(", "$", "header", ")", ";", "if", "(", "$", "cookie", "!==", "null", ")", "{", "$", "this", "->", "storeCookie", "(", "$", "cookie", ")", ";", "}", "}", "}" ]
Parse headers for cookies.
[ "Parse", "headers", "for", "cookies", "." ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/Cookies.php#L99-L109
Eresus/EresusCMS
src/core/PHP.php
Eresus_PHP.iniSizeToInt
public static function iniSizeToInt($size) { assert('is_string($size)'); preg_match('/([\d\.]+)\s*([KMG])?/', $size, $matches); $result = $matches[1]; if (isset($matches[2])) { switch ($matches[2]) { case 'K': $result *= 1024; break; case 'M': $result *= 1024 * 1024; break; case 'G': $result *= 1024 * 1024 * 1024; break; } } return $result; }
php
public static function iniSizeToInt($size) { assert('is_string($size)'); preg_match('/([\d\.]+)\s*([KMG])?/', $size, $matches); $result = $matches[1]; if (isset($matches[2])) { switch ($matches[2]) { case 'K': $result *= 1024; break; case 'M': $result *= 1024 * 1024; break; case 'G': $result *= 1024 * 1024 * 1024; break; } } return $result; }
[ "public", "static", "function", "iniSizeToInt", "(", "$", "size", ")", "{", "assert", "(", "'is_string($size)'", ")", ";", "preg_match", "(", "'/([\\d\\.]+)\\s*([KMG])?/'", ",", "$", "size", ",", "$", "matches", ")", ";", "$", "result", "=", "$", "matches", "[", "1", "]", ";", "if", "(", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "switch", "(", "$", "matches", "[", "2", "]", ")", "{", "case", "'K'", ":", "$", "result", "*=", "1024", ";", "break", ";", "case", "'M'", ":", "$", "result", "*=", "1024", "*", "1024", ";", "break", ";", "case", "'G'", ":", "$", "result", "*=", "1024", "*", "1024", "*", "1024", ";", "break", ";", "}", "}", "return", "$", "result", ";", "}" ]
Переводит значение параметра настройки в целое число с учётом сокращений См. {@link http://www.php.net/faq.using.php#faq.using.shorthandbytes документацию}. @param string $size @return int
[ "Переводит", "значение", "параметра", "настройки", "в", "целое", "число", "с", "учётом", "сокращений" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/PHP.php#L49-L71
Eresus/EresusCMS
src/core/PHP.php
Eresus_PHP.getMaxUploadSize
public static function getMaxUploadSize() { $limit = false; if ($value = self::iniSizeToInt(ini_get('upload_max_filesize'))) { $limit = $value; } $value = self::iniSizeToInt(ini_get('post_max_size')); $reserveForHeadersAndBody = 1024; if ($value && $value - $reserveForHeadersAndBody < $limit) { $limit = $value - $reserveForHeadersAndBody; } /* $value = self::iniValueToInt(ini_get('memory_limit')); $reserveForAppItself = memory_get_peak_usage(true); if ($value && $value < $limit) { $limit = $value - $reserveForAppItself; } */ return $limit; }
php
public static function getMaxUploadSize() { $limit = false; if ($value = self::iniSizeToInt(ini_get('upload_max_filesize'))) { $limit = $value; } $value = self::iniSizeToInt(ini_get('post_max_size')); $reserveForHeadersAndBody = 1024; if ($value && $value - $reserveForHeadersAndBody < $limit) { $limit = $value - $reserveForHeadersAndBody; } /* $value = self::iniValueToInt(ini_get('memory_limit')); $reserveForAppItself = memory_get_peak_usage(true); if ($value && $value < $limit) { $limit = $value - $reserveForAppItself; } */ return $limit; }
[ "public", "static", "function", "getMaxUploadSize", "(", ")", "{", "$", "limit", "=", "false", ";", "if", "(", "$", "value", "=", "self", "::", "iniSizeToInt", "(", "ini_get", "(", "'upload_max_filesize'", ")", ")", ")", "{", "$", "limit", "=", "$", "value", ";", "}", "$", "value", "=", "self", "::", "iniSizeToInt", "(", "ini_get", "(", "'post_max_size'", ")", ")", ";", "$", "reserveForHeadersAndBody", "=", "1024", ";", "if", "(", "$", "value", "&&", "$", "value", "-", "$", "reserveForHeadersAndBody", "<", "$", "limit", ")", "{", "$", "limit", "=", "$", "value", "-", "$", "reserveForHeadersAndBody", ";", "}", "/*\n $value = self::iniValueToInt(ini_get('memory_limit'));\n $reserveForAppItself = memory_get_peak_usage(true);\n if ($value && $value < $limit)\n {\n $limit = $value - $reserveForAppItself;\n }\n */", "return", "$", "limit", ";", "}" ]
Возвращает максимально допустимый размер загружаемого файла в байтах Во внимание принимаются настройки upload_max_filesize и post_max_size @return int|bool размер в байтах или false, если размер не ограничен
[ "Возвращает", "максимально", "допустимый", "размер", "загружаемого", "файла", "в", "байтах" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/PHP.php#L80-L104
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.setMessage
public function setMessage($content, $severity = 5, $facility = 16, $time = null) { $this->content = $this->checkLength($content); $facility = intval($facility); $severity = intval($severity); if ($facility < 0) { $facility = 0; } if ($facility > 23) { $facility = 23; } if ($severity < 0) { $severity = 0; } if ($severity > 7) { $severity = 7; } $this->process = $this->checkLength($this->process, 32, 'process'); $tstamp = $this->getTstamp($time); $priority = "<" . ($facility * 8 + $severity) . ">"; $header = $tstamp . " " . $this->hostname; $this->message = $priority . $header . " " . $this->process . ": " . $this->agent . $this->content; $this->message = $this->checkLength($this->message); return $this; }
php
public function setMessage($content, $severity = 5, $facility = 16, $time = null) { $this->content = $this->checkLength($content); $facility = intval($facility); $severity = intval($severity); if ($facility < 0) { $facility = 0; } if ($facility > 23) { $facility = 23; } if ($severity < 0) { $severity = 0; } if ($severity > 7) { $severity = 7; } $this->process = $this->checkLength($this->process, 32, 'process'); $tstamp = $this->getTstamp($time); $priority = "<" . ($facility * 8 + $severity) . ">"; $header = $tstamp . " " . $this->hostname; $this->message = $priority . $header . " " . $this->process . ": " . $this->agent . $this->content; $this->message = $this->checkLength($this->message); return $this; }
[ "public", "function", "setMessage", "(", "$", "content", ",", "$", "severity", "=", "5", ",", "$", "facility", "=", "16", ",", "$", "time", "=", "null", ")", "{", "$", "this", "->", "content", "=", "$", "this", "->", "checkLength", "(", "$", "content", ")", ";", "$", "facility", "=", "intval", "(", "$", "facility", ")", ";", "$", "severity", "=", "intval", "(", "$", "severity", ")", ";", "if", "(", "$", "facility", "<", "0", ")", "{", "$", "facility", "=", "0", ";", "}", "if", "(", "$", "facility", ">", "23", ")", "{", "$", "facility", "=", "23", ";", "}", "if", "(", "$", "severity", "<", "0", ")", "{", "$", "severity", "=", "0", ";", "}", "if", "(", "$", "severity", ">", "7", ")", "{", "$", "severity", "=", "7", ";", "}", "$", "this", "->", "process", "=", "$", "this", "->", "checkLength", "(", "$", "this", "->", "process", ",", "32", ",", "'process'", ")", ";", "$", "tstamp", "=", "$", "this", "->", "getTstamp", "(", "$", "time", ")", ";", "$", "priority", "=", "\"<\"", ".", "(", "$", "facility", "*", "8", "+", "$", "severity", ")", ".", "\">\"", ";", "$", "header", "=", "$", "tstamp", ".", "\" \"", ".", "$", "this", "->", "hostname", ";", "$", "this", "->", "message", "=", "$", "priority", ".", "$", "header", ".", "\" \"", ".", "$", "this", "->", "process", ".", "\": \"", ".", "$", "this", "->", "agent", ".", "$", "this", "->", "content", ";", "$", "this", "->", "message", "=", "$", "this", "->", "checkLength", "(", "$", "this", "->", "message", ")", ";", "return", "$", "this", ";", "}" ]
Set the message to send or save @param string $content The plain text log message, must be under 1024 Anything over 1024 will be truncated remember to allow space for the header which is ~40 chars @param integer $severity The severity of the message 0 Emergency: system is unusable 1 Alert: action must be taken immediately 2 Critical: critical conditions 3 Error: error conditions 4 Warning: warning conditions 5 Notice: normal but significant condition (default value) 6 Informational: informational messages 7 Debug: debug-level messages @param integer $facility 0 kernel messages 1 user-level messages 2 mail system 3 system daemons 4 security/authorization messages 5 messages generated internally by syslogd 6 line printer subsystem 7 network news subsystem 8 UUCP subsystem 9 clock daemon 10 security/authorization messages 11 FTP daemon 12 NTP subsystem 13 log audit 14 log alert 15 clock daemon 16 local user 0 (local0) (default value) 17 local user 1 (local1) 18 local user 2 (local2) 19 local user 3 (local3) 20 local user 4 (local4) 21 local user 5 (local5)Syslog 22 local user 6 (local6) 23 local user 7 (local7) @param integer $time The tstamp to override the current time @return object This so you can chain ->send or ->save
[ "Set", "the", "message", "to", "send", "or", "save", "@param", "string", "$content", "The", "plain", "text", "log", "message", "must", "be", "under", "1024", "Anything", "over", "1024", "will", "be", "truncated", "remember", "to", "allow", "space", "for", "the", "header", "which", "is", "~40", "chars" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L134-L166
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.getTstamp
protected function getTstamp($time = null) { $time = !is_null($time) ? strtotime($time) : time(); $month = date("M", $time); $day = substr(" " . date("j", $time), -2); $hhmmss = date("H:i:s", $time); return $month . " " . $day . " " . $hhmmss; }
php
protected function getTstamp($time = null) { $time = !is_null($time) ? strtotime($time) : time(); $month = date("M", $time); $day = substr(" " . date("j", $time), -2); $hhmmss = date("H:i:s", $time); return $month . " " . $day . " " . $hhmmss; }
[ "protected", "function", "getTstamp", "(", "$", "time", "=", "null", ")", "{", "$", "time", "=", "!", "is_null", "(", "$", "time", ")", "?", "strtotime", "(", "$", "time", ")", ":", "time", "(", ")", ";", "$", "month", "=", "date", "(", "\"M\"", ",", "$", "time", ")", ";", "$", "day", "=", "substr", "(", "\" \"", ".", "date", "(", "\"j\"", ",", "$", "time", ")", ",", "-", "2", ")", ";", "$", "hhmmss", "=", "date", "(", "\"H:i:s\"", ",", "$", "time", ")", ";", "return", "$", "month", ".", "\" \"", ".", "$", "day", ".", "\" \"", ".", "$", "hhmmss", ";", "}" ]
Gets the BSD syslog style timestamp Nov 17 12:30:19 @param The optional time to use, any format that strtotime understands @return string
[ "Gets", "the", "BSD", "syslog", "style", "timestamp", "Nov", "17", "12", ":", "30", ":", "19" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L173-L180
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.save
public function save($log_dir = '') { if (empty($log_dir)) { $log_dir = \ROOT . '/private/logs/syslog/'; } if (!is_dir($log_dir)) { mkdir($log_dir, 0777, true); } return file_put_contents($log_dir . date('Y_m_d') . '.log', $this->message . "\n", \FILE_APPEND); }
php
public function save($log_dir = '') { if (empty($log_dir)) { $log_dir = \ROOT . '/private/logs/syslog/'; } if (!is_dir($log_dir)) { mkdir($log_dir, 0777, true); } return file_put_contents($log_dir . date('Y_m_d') . '.log', $this->message . "\n", \FILE_APPEND); }
[ "public", "function", "save", "(", "$", "log_dir", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "log_dir", ")", ")", "{", "$", "log_dir", "=", "\\", "ROOT", ".", "'/private/logs/syslog/'", ";", "}", "if", "(", "!", "is_dir", "(", "$", "log_dir", ")", ")", "{", "mkdir", "(", "$", "log_dir", ",", "0777", ",", "true", ")", ";", "}", "return", "file_put_contents", "(", "$", "log_dir", ".", "date", "(", "'Y_m_d'", ")", ".", "'.log'", ",", "$", "this", "->", "message", ".", "\"\\n\"", ",", "\\", "FILE_APPEND", ")", ";", "}" ]
Saves data to local logs dir when syslog server is not available @param string $log_dir The log dir the data is written to @param string $log_type The log_type being written to @return boolean If the data was written or not
[ "Saves", "data", "to", "local", "logs", "dir", "when", "syslog", "server", "is", "not", "available" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L199-L211
surebert/surebert-framework
src/sb/Logger/Syslog.php
Syslog.checkLength
protected function checkLength($str, $max_length = '', $type = 'packet') { $max_length = $max_length ? $max_length : $this->max_length; if ($max_length == -1) { return $str; } $strlen = strlen($str); if ($strlen > $max_length) { throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated. Original str is: " . $str, E_USER_WARNING); return substr($str, 0, $max_length); } return $str; }
php
protected function checkLength($str, $max_length = '', $type = 'packet') { $max_length = $max_length ? $max_length : $this->max_length; if ($max_length == -1) { return $str; } $strlen = strlen($str); if ($strlen > $max_length) { throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated. Original str is: " . $str, E_USER_WARNING); return substr($str, 0, $max_length); } return $str; }
[ "protected", "function", "checkLength", "(", "$", "str", ",", "$", "max_length", "=", "''", ",", "$", "type", "=", "'packet'", ")", "{", "$", "max_length", "=", "$", "max_length", "?", "$", "max_length", ":", "$", "this", "->", "max_length", ";", "if", "(", "$", "max_length", "==", "-", "1", ")", "{", "return", "$", "str", ";", "}", "$", "strlen", "=", "strlen", "(", "$", "str", ")", ";", "if", "(", "$", "strlen", ">", "$", "max_length", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Syslog \"", ".", "$", "type", ".", "\" is > \"", ".", "$", "max_length", ".", "\" (\"", ".", "$", "strlen", ".", "\") in length and will be truncated. Original str is: \"", ".", "$", "str", ",", "E_USER_WARNING", ")", ";", "return", "substr", "(", "$", "str", ",", "0", ",", "$", "max_length", ")", ";", "}", "return", "$", "str", ";", "}" ]
Checks to make sure the length of something is expected or warn and truncate @param string $str The string to check @param int $max_length The maximun length to check for, -1 means infinite length @param string $type The type of thing to check packet or process @return string The string truncated to max length
[ "Checks", "to", "make", "sure", "the", "length", "of", "something", "is", "expected", "or", "warn", "and", "truncate" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/Syslog.php#L262-L276
jaxon-php/jaxon-jquery
src/Plugin.php
Plugin.element
public function element($sSelector, string $sContext = '') { $xElement = new Dom\Element($sSelector, $sContext); $this->addCommand(array('cmd' => 'jquery'), $xElement); return $xElement; }
php
public function element($sSelector, string $sContext = '') { $xElement = new Dom\Element($sSelector, $sContext); $this->addCommand(array('cmd' => 'jquery'), $xElement); return $xElement; }
[ "public", "function", "element", "(", "$", "sSelector", ",", "string", "$", "sContext", "=", "''", ")", "{", "$", "xElement", "=", "new", "Dom", "\\", "Element", "(", "$", "sSelector", ",", "$", "sContext", ")", ";", "$", "this", "->", "addCommand", "(", "array", "(", "'cmd'", "=>", "'jquery'", ")", ",", "$", "xElement", ")", ";", "return", "$", "xElement", ";", "}" ]
Create a JQuery Element with a given selector, and link it to the current response. Since this element is linked to a response, its code will be automatically sent to the client. The returned object can be used to call jQuery functions on the selected elements. @param string $sSelector The jQuery selector @param string $sContext A context associated to the selector @return Jaxon\JQuery\Dom\Element
[ "Create", "a", "JQuery", "Element", "with", "a", "given", "selector", "and", "link", "it", "to", "the", "current", "response", "." ]
train
https://github.com/jaxon-php/jaxon-jquery/blob/90766a8ea8a4124a3f110e96b316370f71762380/src/Plugin.php#L64-L69
php-lug/lug
src/Component/Grid/Batch/Batcher.php
Batcher.batch
public function batch(GridInterface $grid, $batch, $data) { $batch = $grid->getBatch($batch); $types = $this->resolveTypes($batch->getType()); if (!isset($this->cache[$hash = spl_object_hash($grid).':'.spl_object_hash($batch)])) { $resolver = new OptionsResolver(); foreach ($types as $type) { $type->configureOptions($resolver); } $this->cache[$hash] = $resolver->resolve(array_merge( ['batch' => $batch, 'grid' => $grid], $batch->getOptions() )); } reset($types)->batch($data, $this->cache[$hash]); }
php
public function batch(GridInterface $grid, $batch, $data) { $batch = $grid->getBatch($batch); $types = $this->resolveTypes($batch->getType()); if (!isset($this->cache[$hash = spl_object_hash($grid).':'.spl_object_hash($batch)])) { $resolver = new OptionsResolver(); foreach ($types as $type) { $type->configureOptions($resolver); } $this->cache[$hash] = $resolver->resolve(array_merge( ['batch' => $batch, 'grid' => $grid], $batch->getOptions() )); } reset($types)->batch($data, $this->cache[$hash]); }
[ "public", "function", "batch", "(", "GridInterface", "$", "grid", ",", "$", "batch", ",", "$", "data", ")", "{", "$", "batch", "=", "$", "grid", "->", "getBatch", "(", "$", "batch", ")", ";", "$", "types", "=", "$", "this", "->", "resolveTypes", "(", "$", "batch", "->", "getType", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "cache", "[", "$", "hash", "=", "spl_object_hash", "(", "$", "grid", ")", ".", "':'", ".", "spl_object_hash", "(", "$", "batch", ")", "]", ")", ")", "{", "$", "resolver", "=", "new", "OptionsResolver", "(", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type", "->", "configureOptions", "(", "$", "resolver", ")", ";", "}", "$", "this", "->", "cache", "[", "$", "hash", "]", "=", "$", "resolver", "->", "resolve", "(", "array_merge", "(", "[", "'batch'", "=>", "$", "batch", ",", "'grid'", "=>", "$", "grid", "]", ",", "$", "batch", "->", "getOptions", "(", ")", ")", ")", ";", "}", "reset", "(", "$", "types", ")", "->", "batch", "(", "$", "data", ",", "$", "this", "->", "cache", "[", "$", "hash", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Batch/Batcher.php#L45-L64
php-lug/lug
src/Component/Grid/Batch/Batcher.php
Batcher.resolveTypes
private function resolveTypes($type) { $batchTypes = []; do { $batchTypes[] = $batchType = $this->batchRegistry[$type]; } while (($type = $batchType->getParent()) !== null); return $batchTypes; }
php
private function resolveTypes($type) { $batchTypes = []; do { $batchTypes[] = $batchType = $this->batchRegistry[$type]; } while (($type = $batchType->getParent()) !== null); return $batchTypes; }
[ "private", "function", "resolveTypes", "(", "$", "type", ")", "{", "$", "batchTypes", "=", "[", "]", ";", "do", "{", "$", "batchTypes", "[", "]", "=", "$", "batchType", "=", "$", "this", "->", "batchRegistry", "[", "$", "type", "]", ";", "}", "while", "(", "(", "$", "type", "=", "$", "batchType", "->", "getParent", "(", ")", ")", "!==", "null", ")", ";", "return", "$", "batchTypes", ";", "}" ]
@param string $type @return TypeInterface[]
[ "@param", "string", "$type" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Batch/Batcher.php#L71-L80
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php
Yaml.parse
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { // if input is a file, process it $file = ''; if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input; $input = file_get_contents($file); } $yaml = new Parser(); try { return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); } throw $e; } }
php
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false) { // if input is a file, process it $file = ''; if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input; $input = file_get_contents($file); } $yaml = new Parser(); try { return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { if ($file) { $e->setParsedFile($file); } throw $e; } }
[ "public", "static", "function", "parse", "(", "$", "input", ",", "$", "exceptionOnInvalidType", "=", "false", ",", "$", "objectSupport", "=", "false", ")", "{", "// if input is a file, process it", "$", "file", "=", "''", ";", "if", "(", "strpos", "(", "$", "input", ",", "\"\\n\"", ")", "===", "false", "&&", "is_file", "(", "$", "input", ")", ")", "{", "if", "(", "false", "===", "is_readable", "(", "$", "input", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Unable to parse \"%s\" as the file is not readable.'", ",", "$", "input", ")", ")", ";", "}", "$", "file", "=", "$", "input", ";", "$", "input", "=", "file_get_contents", "(", "$", "file", ")", ";", "}", "$", "yaml", "=", "new", "Parser", "(", ")", ";", "try", "{", "return", "$", "yaml", "->", "parse", "(", "$", "input", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "if", "(", "$", "file", ")", "{", "$", "e", "->", "setParsedFile", "(", "$", "file", ")", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Parses YAML into a PHP array. The parse method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array. Usage: <code> $array = Yaml::parse('config.yml'); print_r($array); </code> As this method accepts both plain strings and file names as an input, you must validate the input before calling this method. Passing a file as an input is a deprecated feature and will be removed in 3.0. @param string $input Path to a YAML file or a string containing YAML @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise @param Boolean $objectSupport True if object support is enabled, false otherwise @return array The YAML converted to a PHP array @throws ParseException If the YAML is not valid @api
[ "Parses", "YAML", "into", "a", "PHP", "array", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php#L51-L75
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php
Yaml.dump
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false) { $yaml = new Dumper(); $yaml->setIndentation($indent); return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport); }
php
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false) { $yaml = new Dumper(); $yaml->setIndentation($indent); return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport); }
[ "public", "static", "function", "dump", "(", "$", "array", ",", "$", "inline", "=", "2", ",", "$", "indent", "=", "4", ",", "$", "exceptionOnInvalidType", "=", "false", ",", "$", "objectSupport", "=", "false", ")", "{", "$", "yaml", "=", "new", "Dumper", "(", ")", ";", "$", "yaml", "->", "setIndentation", "(", "$", "indent", ")", ";", "return", "$", "yaml", "->", "dump", "(", "$", "array", ",", "$", "inline", ",", "0", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}" ]
Dumps a PHP array to a YAML string. The dump method, when supplied with an array, will do its best to convert the array into friendly YAML. @param array $array PHP array @param integer $inline The level where you switch to inline YAML @param integer $indent The amount of spaces to use for indentation of nested nodes. @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise @param Boolean $objectSupport true if object support is enabled, false otherwise @return string A YAML string representing the original PHP array @api
[ "Dumps", "a", "PHP", "array", "to", "a", "YAML", "string", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Yaml.php#L93-L99
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getId
protected function getId() { if($this->currObj instanceof Server) { return "ts3_s" . $this->currObj->virtualserver_id; } elseif($this->currObj instanceof Channel) { return "ts3_c" . $this->currObj->cid; } elseif($this->currObj instanceof Client) { return "ts3_u" . $this->currObj->clid; } return FALSE; }
php
protected function getId() { if($this->currObj instanceof Server) { return "ts3_s" . $this->currObj->virtualserver_id; } elseif($this->currObj instanceof Channel) { return "ts3_c" . $this->currObj->cid; } elseif($this->currObj instanceof Client) { return "ts3_u" . $this->currObj->clid; } return FALSE; }
[ "protected", "function", "getId", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Server", ")", "{", "return", "\"ts3_s\"", ".", "$", "this", "->", "currObj", "->", "virtualserver_id", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Channel", ")", "{", "return", "\"ts3_c\"", ".", "$", "this", "->", "currObj", "->", "cid", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "return", "\"ts3_u\"", ".", "$", "this", "->", "currObj", "->", "clid", ";", "}", "return", "FALSE", ";", "}" ]
Returns the ID of the current element. @return mixed
[ "Returns", "the", "ID", "of", "the", "current", "element", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L119-L135
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getParent
protected function getParent() { if($this->currObj instanceof Channel) { return $this->currObj->pid ? "ts3_c" . $this->currObj->pid : "ts3_s" . $this->currObj->getParent()->getId(); } elseif($this->currObj instanceof Client) { return $this->currObj->cid ? "ts3_c" . $this->currObj->cid : "ts3_s" . $this->currObj->getParent()->getId(); } return "ts3"; }
php
protected function getParent() { if($this->currObj instanceof Channel) { return $this->currObj->pid ? "ts3_c" . $this->currObj->pid : "ts3_s" . $this->currObj->getParent()->getId(); } elseif($this->currObj instanceof Client) { return $this->currObj->cid ? "ts3_c" . $this->currObj->cid : "ts3_s" . $this->currObj->getParent()->getId(); } return "ts3"; }
[ "protected", "function", "getParent", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Channel", ")", "{", "return", "$", "this", "->", "currObj", "->", "pid", "?", "\"ts3_c\"", ".", "$", "this", "->", "currObj", "->", "pid", ":", "\"ts3_s\"", ".", "$", "this", "->", "currObj", "->", "getParent", "(", ")", "->", "getId", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "return", "$", "this", "->", "currObj", "->", "cid", "?", "\"ts3_c\"", ".", "$", "this", "->", "currObj", "->", "cid", ":", "\"ts3_s\"", ".", "$", "this", "->", "currObj", "->", "getParent", "(", ")", "->", "getId", "(", ")", ";", "}", "return", "\"ts3\"", ";", "}" ]
Returns the parent ID of the current element. @return mixed
[ "Returns", "the", "parent", "ID", "of", "the", "current", "element", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L142-L154
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getLevel
protected function getLevel() { if($this->currObj instanceof Channel) { return $this->currObj->getLevel()+2; } elseif($this->currObj instanceof Client) { return $this->currObj->channelGetById($this->currObj->cid)->getLevel()+3; } return 1; }
php
protected function getLevel() { if($this->currObj instanceof Channel) { return $this->currObj->getLevel()+2; } elseif($this->currObj instanceof Client) { return $this->currObj->channelGetById($this->currObj->cid)->getLevel()+3; } return 1; }
[ "protected", "function", "getLevel", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Channel", ")", "{", "return", "$", "this", "->", "currObj", "->", "getLevel", "(", ")", "+", "2", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "return", "$", "this", "->", "currObj", "->", "channelGetById", "(", "$", "this", "->", "currObj", "->", "cid", ")", "->", "getLevel", "(", ")", "+", "3", ";", "}", "return", "1", ";", "}" ]
Returns the level of the current element. @return integer
[ "Returns", "the", "level", "of", "the", "current", "element", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L161-L173
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getType
protected function getType() { if($this->currObj instanceof Server) { return "server"; } elseif($this->currObj instanceof Channel) { return "channel"; } elseif($this->currObj instanceof Client) { return "client"; } elseif($this->currObj instanceof ServerGroup || $this->currObj instanceof ChannelGroup) { return "group"; } return "host"; }
php
protected function getType() { if($this->currObj instanceof Server) { return "server"; } elseif($this->currObj instanceof Channel) { return "channel"; } elseif($this->currObj instanceof Client) { return "client"; } elseif($this->currObj instanceof ServerGroup || $this->currObj instanceof ChannelGroup) { return "group"; } return "host"; }
[ "protected", "function", "getType", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Server", ")", "{", "return", "\"server\"", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Channel", ")", "{", "return", "\"channel\"", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "return", "\"client\"", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "ServerGroup", "||", "$", "this", "->", "currObj", "instanceof", "ChannelGroup", ")", "{", "return", "\"group\"", ";", "}", "return", "\"host\"", ";", "}" ]
Returns a single type identifier for the current element. @return string
[ "Returns", "a", "single", "type", "identifier", "for", "the", "current", "element", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L180-L200
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getSpacerType
protected function getSpacerType() { $type = ""; if(!$this->currObj instanceof Channel || !$this->currObj->isSpacer()) { return "none"; } switch($this->currObj->spacerGetType()) { case (string) TeamSpeak3::SPACER_SOLIDLINE: $type .= "solidline"; break; case (string) TeamSpeak3::SPACER_DASHLINE: $type .= "dashline"; break; case (string) TeamSpeak3::SPACER_DASHDOTLINE: $type .= "dashdotline"; break; case (string) TeamSpeak3::SPACER_DASHDOTDOTLINE: $type .= "dashdotdotline"; break; case (string) TeamSpeak3::SPACER_DOTLINE: $type .= "dotline"; break; default: $type .= "custom"; } if($type == "custom") { switch($this->currObj->spacerGetAlign()) { case TeamSpeak3::SPACER_ALIGN_REPEAT: $type .= "repeat"; break; case TeamSpeak3::SPACER_ALIGN_CENTER: $type .= "center"; break; case TeamSpeak3::SPACER_ALIGN_RIGHT: $type .= "right"; break; default: $type .= "left"; } } return $type; }
php
protected function getSpacerType() { $type = ""; if(!$this->currObj instanceof Channel || !$this->currObj->isSpacer()) { return "none"; } switch($this->currObj->spacerGetType()) { case (string) TeamSpeak3::SPACER_SOLIDLINE: $type .= "solidline"; break; case (string) TeamSpeak3::SPACER_DASHLINE: $type .= "dashline"; break; case (string) TeamSpeak3::SPACER_DASHDOTLINE: $type .= "dashdotline"; break; case (string) TeamSpeak3::SPACER_DASHDOTDOTLINE: $type .= "dashdotdotline"; break; case (string) TeamSpeak3::SPACER_DOTLINE: $type .= "dotline"; break; default: $type .= "custom"; } if($type == "custom") { switch($this->currObj->spacerGetAlign()) { case TeamSpeak3::SPACER_ALIGN_REPEAT: $type .= "repeat"; break; case TeamSpeak3::SPACER_ALIGN_CENTER: $type .= "center"; break; case TeamSpeak3::SPACER_ALIGN_RIGHT: $type .= "right"; break; default: $type .= "left"; } } return $type; }
[ "protected", "function", "getSpacerType", "(", ")", "{", "$", "type", "=", "\"\"", ";", "if", "(", "!", "$", "this", "->", "currObj", "instanceof", "Channel", "||", "!", "$", "this", "->", "currObj", "->", "isSpacer", "(", ")", ")", "{", "return", "\"none\"", ";", "}", "switch", "(", "$", "this", "->", "currObj", "->", "spacerGetType", "(", ")", ")", "{", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_SOLIDLINE", ":", "$", "type", ".=", "\"solidline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHLINE", ":", "$", "type", ".=", "\"dashline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHDOTLINE", ":", "$", "type", ".=", "\"dashdotline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DASHDOTDOTLINE", ":", "$", "type", ".=", "\"dashdotdotline\"", ";", "break", ";", "case", "(", "string", ")", "TeamSpeak3", "::", "SPACER_DOTLINE", ":", "$", "type", ".=", "\"dotline\"", ";", "break", ";", "default", ":", "$", "type", ".=", "\"custom\"", ";", "}", "if", "(", "$", "type", "==", "\"custom\"", ")", "{", "switch", "(", "$", "this", "->", "currObj", "->", "spacerGetAlign", "(", ")", ")", "{", "case", "TeamSpeak3", "::", "SPACER_ALIGN_REPEAT", ":", "$", "type", ".=", "\"repeat\"", ";", "break", ";", "case", "TeamSpeak3", "::", "SPACER_ALIGN_CENTER", ":", "$", "type", ".=", "\"center\"", ";", "break", ";", "case", "TeamSpeak3", "::", "SPACER_ALIGN_RIGHT", ":", "$", "type", ".=", "\"right\"", ";", "break", ";", "default", ":", "$", "type", ".=", "\"left\"", ";", "}", "}", "return", "$", "type", ";", "}" ]
Returns an individual type for a spacer. @return string
[ "Returns", "an", "individual", "type", "for", "a", "spacer", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L266-L323
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Json.php
Json.getName
protected function getName() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) { return $this->currObj["channel_name"]->section("]", 1, 99)->toString(); } elseif($this->currObj instanceof Client) { $before = array(); $behind = array(); foreach($this->currObj->memberOf() as $group) { if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE) { $before[] = "[" . $group["name"] . "]"; } elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND) { $behind[] = "[" . $group["name"] . "]"; } } return trim(implode("", $before) . " " . $this->currObj . " " . implode("", $behind)); } return $this->currObj->toString(); }
php
protected function getName() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) { return $this->currObj["channel_name"]->section("]", 1, 99)->toString(); } elseif($this->currObj instanceof Client) { $before = array(); $behind = array(); foreach($this->currObj->memberOf() as $group) { if($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEFORE) { $before[] = "[" . $group["name"] . "]"; } elseif($group->getProperty("namemode") == TeamSpeak3::GROUP_NAMEMODE_BEHIND) { $behind[] = "[" . $group["name"] . "]"; } } return trim(implode("", $before) . " " . $this->currObj . " " . implode("", $behind)); } return $this->currObj->toString(); }
[ "protected", "function", "getName", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Channel", "&&", "$", "this", "->", "currObj", "->", "isSpacer", "(", ")", ")", "{", "return", "$", "this", "->", "currObj", "[", "\"channel_name\"", "]", "->", "section", "(", "\"]\"", ",", "1", ",", "99", ")", "->", "toString", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "$", "before", "=", "array", "(", ")", ";", "$", "behind", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "currObj", "->", "memberOf", "(", ")", "as", "$", "group", ")", "{", "if", "(", "$", "group", "->", "getProperty", "(", "\"namemode\"", ")", "==", "TeamSpeak3", "::", "GROUP_NAMEMODE_BEFORE", ")", "{", "$", "before", "[", "]", "=", "\"[\"", ".", "$", "group", "[", "\"name\"", "]", ".", "\"]\"", ";", "}", "elseif", "(", "$", "group", "->", "getProperty", "(", "\"namemode\"", ")", "==", "TeamSpeak3", "::", "GROUP_NAMEMODE_BEHIND", ")", "{", "$", "behind", "[", "]", "=", "\"[\"", ".", "$", "group", "[", "\"name\"", "]", ".", "\"]\"", ";", "}", "}", "return", "trim", "(", "implode", "(", "\"\"", ",", "$", "before", ")", ".", "\" \"", ".", "$", "this", "->", "currObj", ".", "\" \"", ".", "implode", "(", "\"\"", ",", "$", "behind", ")", ")", ";", "}", "return", "$", "this", "->", "currObj", "->", "toString", "(", ")", ";", "}" ]
Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object. @return string
[ "Returns", "a", "string", "for", "the", "current", "corpus", "element", "which", "contains", "the", "display", "name", "for", "the", "current", "TeamSpeak_Node_Abstract", "object", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Json.php#L331-L358
hanamura/wp-model
src/WPModel/Term.php
Term._initTerm
protected function _initTerm() { if (!isset($this->_term)) { $this->_term = get_term($this->_id, $this->_taxonomy); } }
php
protected function _initTerm() { if (!isset($this->_term)) { $this->_term = get_term($this->_id, $this->_taxonomy); } }
[ "protected", "function", "_initTerm", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_term", ")", ")", "{", "$", "this", "->", "_term", "=", "get_term", "(", "$", "this", "->", "_id", ",", "$", "this", "->", "_taxonomy", ")", ";", "}", "}" ]
init term
[ "init", "term" ]
train
https://github.com/hanamura/wp-model/blob/69925d1c2072e6e78a0b36b5e84d270839cc7419/src/WPModel/Term.php#L92-L97
hanamura/wp-model
src/WPModel/Term.php
Term._children
protected function _children($options = null) { if (!isset($this->_children)) { $this->_children = get_terms( $this->taxonomy, array_merge( array(), $options ?: array(), array('parent' => $this->id) ) ); $this->_children = array_map(array('WPModel\Term', 'create'), $this->_children); } return $this->_children; }
php
protected function _children($options = null) { if (!isset($this->_children)) { $this->_children = get_terms( $this->taxonomy, array_merge( array(), $options ?: array(), array('parent' => $this->id) ) ); $this->_children = array_map(array('WPModel\Term', 'create'), $this->_children); } return $this->_children; }
[ "protected", "function", "_children", "(", "$", "options", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_children", ")", ")", "{", "$", "this", "->", "_children", "=", "get_terms", "(", "$", "this", "->", "taxonomy", ",", "array_merge", "(", "array", "(", ")", ",", "$", "options", "?", ":", "array", "(", ")", ",", "array", "(", "'parent'", "=>", "$", "this", "->", "id", ")", ")", ")", ";", "$", "this", "->", "_children", "=", "array_map", "(", "array", "(", "'WPModel\\Term'", ",", "'create'", ")", ",", "$", "this", "->", "_children", ")", ";", "}", "return", "$", "this", "->", "_children", ";", "}" ]
children
[ "children" ]
train
https://github.com/hanamura/wp-model/blob/69925d1c2072e6e78a0b36b5e84d270839cc7419/src/WPModel/Term.php#L102-L117
surebert/surebert-framework
src/sb/Cache/APC.php
APC.store
public function store($key, $data, $lifetime = 0) { $key = $this->namespace . $key; $store = apc_store($key, $data, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
php
public function store($key, $data, $lifetime = 0) { $key = $this->namespace . $key; $store = apc_store($key, $data, $lifetime); if ($store && $key != $this->namespace . $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return $store; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", "=", "0", ")", "{", "$", "key", "=", "$", "this", "->", "namespace", ".", "$", "key", ";", "$", "store", "=", "apc_store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", ")", ";", "if", "(", "$", "store", "&&", "$", "key", "!=", "$", "this", "->", "namespace", ".", "$", "this", "->", "catalog_key", ")", "{", "$", "this", "->", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", ";", "}", "return", "$", "store", ";", "}" ]
Store the cache data in APC
[ "Store", "the", "cache", "data", "in", "APC" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/APC.php#L41-L51
surebert/surebert-framework
src/sb/Cache/APC.php
APC.catalogKeyAdd
private function catalogKeyAdd($key, $lifetime) { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $catalog[$key] = ($lifetime == 0) ? $lifetime : $lifetime + time(); return $this->store($this->catalog_key, $catalog); }
php
private function catalogKeyAdd($key, $lifetime) { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $catalog[$key] = ($lifetime == 0) ? $lifetime : $lifetime + time(); return $this->store($this->catalog_key, $catalog); }
[ "private", "function", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", "{", "$", "catalog", "=", "$", "this", "->", "fetch", "(", "$", "this", "->", "catalog_key", ")", ";", "$", "catalog", "=", "is_array", "(", "$", "catalog", ")", "?", "$", "catalog", ":", "Array", "(", ")", ";", "$", "catalog", "[", "$", "key", "]", "=", "(", "$", "lifetime", "==", "0", ")", "?", "$", "lifetime", ":", "$", "lifetime", "+", "time", "(", ")", ";", "return", "$", "this", "->", "store", "(", "$", "this", "->", "catalog_key", ",", "$", "catalog", ")", ";", "}" ]
Keeps track of the data stored in the cache to make deleting groups of data possible @param $key @return boolean If the catalog is stored or not
[ "Keeps", "track", "of", "the", "data", "stored", "in", "the", "cache", "to", "make", "deleting", "groups", "of", "data", "possible" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/APC.php#L101-L108
surebert/surebert-framework
src/sb/Cache/APC.php
APC.getKeys
public function getKeys() { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $arr = Array(); foreach ($catalog as $k => $v) { $arr[preg_replace("~^" . $this->namespace . "~", '', $k)] = $v; } ksort($arr); return $arr; }
php
public function getKeys() { $catalog = $this->fetch($this->catalog_key); $catalog = is_array($catalog) ? $catalog : Array(); $arr = Array(); foreach ($catalog as $k => $v) { $arr[preg_replace("~^" . $this->namespace . "~", '', $k)] = $v; } ksort($arr); return $arr; }
[ "public", "function", "getKeys", "(", ")", "{", "$", "catalog", "=", "$", "this", "->", "fetch", "(", "$", "this", "->", "catalog_key", ")", ";", "$", "catalog", "=", "is_array", "(", "$", "catalog", ")", "?", "$", "catalog", ":", "Array", "(", ")", ";", "$", "arr", "=", "Array", "(", ")", ";", "foreach", "(", "$", "catalog", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "arr", "[", "preg_replace", "(", "\"~^\"", ".", "$", "this", "->", "namespace", ".", "\"~\"", ",", "''", ",", "$", "k", ")", "]", "=", "$", "v", ";", "}", "ksort", "(", "$", "arr", ")", ";", "return", "$", "arr", ";", "}" ]
Loads the current catalog @return Array a list of all keys stored in the cache
[ "Loads", "the", "current", "catalog" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/APC.php#L130-L142
webdevvie/pheanstalk-task-queue-bundle
TaskDescription/AbstractTaskDescription.php
AbstractTaskDescription.getOptions
public function getOptions() { $options = array(); foreach ($this->commandOptions as $key => $value) { $options[$key]=$this->$value; } return $options; }
php
public function getOptions() { $options = array(); foreach ($this->commandOptions as $key => $value) { $options[$key]=$this->$value; } return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "commandOptions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "options", "[", "$", "key", "]", "=", "$", "this", "->", "$", "value", ";", "}", "return", "$", "options", ";", "}" ]
Returns a two dimensional array of options to pass to the command The key is the @return array
[ "Returns", "a", "two", "dimensional", "array", "of", "options", "to", "pass", "to", "the", "command", "The", "key", "is", "the" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/TaskDescription/AbstractTaskDescription.php#L68-L75
webdevvie/pheanstalk-task-queue-bundle
TaskDescription/AbstractTaskDescription.php
AbstractTaskDescription.getArguments
public function getArguments() { $arguments = array(); foreach ($this->commandArguments as $argument) { $arguments[] = $this->$argument; } return $arguments; }
php
public function getArguments() { $arguments = array(); foreach ($this->commandArguments as $argument) { $arguments[] = $this->$argument; } return $arguments; }
[ "public", "function", "getArguments", "(", ")", "{", "$", "arguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "commandArguments", "as", "$", "argument", ")", "{", "$", "arguments", "[", "]", "=", "$", "this", "->", "$", "argument", ";", "}", "return", "$", "arguments", ";", "}" ]
Returns a one dimensional array of arguments to pass to the command @return array
[ "Returns", "a", "one", "dimensional", "array", "of", "arguments", "to", "pass", "to", "the", "command" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/TaskDescription/AbstractTaskDescription.php#L82-L89
seagoj/devtools
Model.php
Model.reduceResult
protected function reduceResult($result) { if (is_array($result) && (count($result) == 1)) { reset($result); return $this->reduceResult($result[key($result)]); } else { return $result; } }
php
protected function reduceResult($result) { if (is_array($result) && (count($result) == 1)) { reset($result); return $this->reduceResult($result[key($result)]); } else { return $result; } }
[ "protected", "function", "reduceResult", "(", "$", "result", ")", "{", "if", "(", "is_array", "(", "$", "result", ")", "&&", "(", "count", "(", "$", "result", ")", "==", "1", ")", ")", "{", "reset", "(", "$", "result", ")", ";", "return", "$", "this", "->", "reduceResult", "(", "$", "result", "[", "key", "(", "$", "result", ")", "]", ")", ";", "}", "else", "{", "return", "$", "result", ";", "}", "}" ]
/* public abstract function connect($options);
[ "/", "*", "public", "abstract", "function", "connect", "(", "$options", ")", ";" ]
train
https://github.com/seagoj/devtools/blob/15dd451a0b00c272d3e1961f114342d5e0f526ba/Model.php#L13-L21
Eresus/EresusCMS
3rdparty/edit_area/edit_area_compressor.php
Compressor.file_get_contents
function file_get_contents($file) { $fd = fopen($file, 'rb'); $content = fread($fd, filesize($file)); fclose($fd); $this->file_loaded_size+= strlen($content); return $content; }
php
function file_get_contents($file) { $fd = fopen($file, 'rb'); $content = fread($fd, filesize($file)); fclose($fd); $this->file_loaded_size+= strlen($content); return $content; }
[ "function", "file_get_contents", "(", "$", "file", ")", "{", "$", "fd", "=", "fopen", "(", "$", "file", ",", "'rb'", ")", ";", "$", "content", "=", "fread", "(", "$", "fd", ",", "filesize", "(", "$", "file", ")", ")", ";", "fclose", "(", "$", "fd", ")", ";", "$", "this", "->", "file_loaded_size", "+=", "strlen", "(", "$", "content", ")", ";", "return", "$", "content", ";", "}" ]
/* for php version that have not thoses functions
[ "/", "*", "for", "php", "version", "that", "have", "not", "thoses", "functions" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/3rdparty/edit_area/edit_area_compressor.php#L399-L406
DevGroup-ru/yii2-users-module
src/models/UserModuleConfiguration.php
UserModuleConfiguration.commonApplicationAttributes
public function commonApplicationAttributes() { return [ 'modules' => [ 'users' => [ 'emailConfirmationNeeded' => (bool)$this->emailConfirmationNeeded, 'allowLoginInactiveAccounts' => (bool)$this->allowLoginInactiveAccounts, 'enableSocialNetworks' => (bool)$this->enableSocialNetworks, 'logLastLoginTime' => (bool)$this->logLastLoginTime, 'logLastLoginData' => (bool)$this->logLastLoginData, 'passwordResetTokenExpire' => (int)$this->passwordResetTokenExpire, 'loginDuration' => (int)$this->loginDuration, 'generatedPasswordLength' => (int)$this->generatedPasswordLength, ] ], ]; }
php
public function commonApplicationAttributes() { return [ 'modules' => [ 'users' => [ 'emailConfirmationNeeded' => (bool)$this->emailConfirmationNeeded, 'allowLoginInactiveAccounts' => (bool)$this->allowLoginInactiveAccounts, 'enableSocialNetworks' => (bool)$this->enableSocialNetworks, 'logLastLoginTime' => (bool)$this->logLastLoginTime, 'logLastLoginData' => (bool)$this->logLastLoginData, 'passwordResetTokenExpire' => (int)$this->passwordResetTokenExpire, 'loginDuration' => (int)$this->loginDuration, 'generatedPasswordLength' => (int)$this->generatedPasswordLength, ] ], ]; }
[ "public", "function", "commonApplicationAttributes", "(", ")", "{", "return", "[", "'modules'", "=>", "[", "'users'", "=>", "[", "'emailConfirmationNeeded'", "=>", "(", "bool", ")", "$", "this", "->", "emailConfirmationNeeded", ",", "'allowLoginInactiveAccounts'", "=>", "(", "bool", ")", "$", "this", "->", "allowLoginInactiveAccounts", ",", "'enableSocialNetworks'", "=>", "(", "bool", ")", "$", "this", "->", "enableSocialNetworks", ",", "'logLastLoginTime'", "=>", "(", "bool", ")", "$", "this", "->", "logLastLoginTime", ",", "'logLastLoginData'", "=>", "(", "bool", ")", "$", "this", "->", "logLastLoginData", ",", "'passwordResetTokenExpire'", "=>", "(", "int", ")", "$", "this", "->", "passwordResetTokenExpire", ",", "'loginDuration'", "=>", "(", "int", ")", "$", "this", "->", "loginDuration", ",", "'generatedPasswordLength'", "=>", "(", "int", ")", "$", "this", "->", "generatedPasswordLength", ",", "]", "]", ",", "]", ";", "}" ]
Returns array of module configuration that should be stored in application config. Array should be ready to merge in app config. Used both for web and console. @return array
[ "Returns", "array", "of", "module", "configuration", "that", "should", "be", "stored", "in", "application", "config", ".", "Array", "should", "be", "ready", "to", "merge", "in", "app", "config", ".", "Used", "both", "for", "web", "and", "console", "." ]
train
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/UserModuleConfiguration.php#L54-L70
tequila/mongodb-odm
src/Metadata/Field/DocumentField.php
DocumentField.generateProxy
public function generateProxy(AbstractGenerator $proxyGenerator) { $proxyGenerator->addUse($proxyGenerator->getOtherProxyClass($this->documentClass)); $proxyGenerator->addUse($this->documentClass); $proxyGenerator->addUse(NestedProxyInterface::class); parent::generateProxy($proxyGenerator); }
php
public function generateProxy(AbstractGenerator $proxyGenerator) { $proxyGenerator->addUse($proxyGenerator->getOtherProxyClass($this->documentClass)); $proxyGenerator->addUse($this->documentClass); $proxyGenerator->addUse(NestedProxyInterface::class); parent::generateProxy($proxyGenerator); }
[ "public", "function", "generateProxy", "(", "AbstractGenerator", "$", "proxyGenerator", ")", "{", "$", "proxyGenerator", "->", "addUse", "(", "$", "proxyGenerator", "->", "getOtherProxyClass", "(", "$", "this", "->", "documentClass", ")", ")", ";", "$", "proxyGenerator", "->", "addUse", "(", "$", "this", "->", "documentClass", ")", ";", "$", "proxyGenerator", "->", "addUse", "(", "NestedProxyInterface", "::", "class", ")", ";", "parent", "::", "generateProxy", "(", "$", "proxyGenerator", ")", ";", "}" ]
@param AbstractGenerator $proxyGenerator @throws \ReflectionException
[ "@param", "AbstractGenerator", "$proxyGenerator" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/Field/DocumentField.php#L60-L67
tequila/mongodb-odm
src/Metadata/Field/DocumentField.php
DocumentField.getUnserializationCode
public function getUnserializationCode(AbstractGenerator $proxyGenerator): string { $code = <<<'EOT' $objectData = null === $dbData ? null : \MongoDB\apply_type_map_to_document($dbData, [ 'root' => {{proxyClass}}::class, 'document' => 'array' ]); if ($objectData instanceof \Tequila\MongoDB\ODM\Proxy\NestedProxyInterface) { $objectData->setPathInDocument($pathInDocument); $objectData->setRootProxy($rootProxy); $objectData->doBsonUnserialize(); } EOT; $proxyClass = $proxyGenerator->getOtherProxyClass($this->documentClass); $proxyShortName = substr($proxyClass, strrpos($proxyClass, '\\')); return self::compileCode($code, ['proxyClass' => ltrim($proxyShortName, '\\')]); }
php
public function getUnserializationCode(AbstractGenerator $proxyGenerator): string { $code = <<<'EOT' $objectData = null === $dbData ? null : \MongoDB\apply_type_map_to_document($dbData, [ 'root' => {{proxyClass}}::class, 'document' => 'array' ]); if ($objectData instanceof \Tequila\MongoDB\ODM\Proxy\NestedProxyInterface) { $objectData->setPathInDocument($pathInDocument); $objectData->setRootProxy($rootProxy); $objectData->doBsonUnserialize(); } EOT; $proxyClass = $proxyGenerator->getOtherProxyClass($this->documentClass); $proxyShortName = substr($proxyClass, strrpos($proxyClass, '\\')); return self::compileCode($code, ['proxyClass' => ltrim($proxyShortName, '\\')]); }
[ "public", "function", "getUnserializationCode", "(", "AbstractGenerator", "$", "proxyGenerator", ")", ":", "string", "{", "$", "code", "=", " <<<'EOT'\n$objectData = null === $dbData \n ? null \n : \\MongoDB\\apply_type_map_to_document($dbData, [\n 'root' => {{proxyClass}}::class, \n 'document' => 'array'\n ]);\nif ($objectData instanceof \\Tequila\\MongoDB\\ODM\\Proxy\\NestedProxyInterface) {\n $objectData->setPathInDocument($pathInDocument);\n $objectData->setRootProxy($rootProxy);\n $objectData->doBsonUnserialize();\n}\nEOT", ";", "$", "proxyClass", "=", "$", "proxyGenerator", "->", "getOtherProxyClass", "(", "$", "this", "->", "documentClass", ")", ";", "$", "proxyShortName", "=", "substr", "(", "$", "proxyClass", ",", "strrpos", "(", "$", "proxyClass", ",", "'\\\\'", ")", ")", ";", "return", "self", "::", "compileCode", "(", "$", "code", ",", "[", "'proxyClass'", "=>", "ltrim", "(", "$", "proxyShortName", ",", "'\\\\'", ")", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Metadata/Field/DocumentField.php#L72-L92
philiplb/Valdi
src/Valdi/Validator/MinLength.php
MinLength.isValidComparison
protected function isValidComparison($value, $parameters) { $length = strlen($value); return is_numeric($parameters[0]) && $length >= $parameters[0]; }
php
protected function isValidComparison($value, $parameters) { $length = strlen($value); return is_numeric($parameters[0]) && $length >= $parameters[0]; }
[ "protected", "function", "isValidComparison", "(", "$", "value", ",", "$", "parameters", ")", "{", "$", "length", "=", "strlen", "(", "$", "value", ")", ";", "return", "is_numeric", "(", "$", "parameters", "[", "0", "]", ")", "&&", "$", "length", ">=", "$", "parameters", "[", "0", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/MinLength.php#L27-L30
GrupaZero/social
src/Gzero/Social/Controller/SocialAuthController.php
SocialAuthController.socialLogin
public function socialLogin($serviceName) { if (config('services.' . $serviceName)) { $this->setDynamicRedirectUrl($serviceName); return $this->socialite->driver($serviceName)->redirect(); } return redirect('/'); }
php
public function socialLogin($serviceName) { if (config('services.' . $serviceName)) { $this->setDynamicRedirectUrl($serviceName); return $this->socialite->driver($serviceName)->redirect(); } return redirect('/'); }
[ "public", "function", "socialLogin", "(", "$", "serviceName", ")", "{", "if", "(", "config", "(", "'services.'", ".", "$", "serviceName", ")", ")", "{", "$", "this", "->", "setDynamicRedirectUrl", "(", "$", "serviceName", ")", ";", "return", "$", "this", "->", "socialite", "->", "driver", "(", "$", "serviceName", ")", "->", "redirect", "(", ")", ";", "}", "return", "redirect", "(", "'/'", ")", ";", "}" ]
Function responsible for login the user by the given social service. @param $serviceName string social service name @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\RedirectResponse
[ "Function", "responsible", "for", "login", "the", "user", "by", "the", "given", "social", "service", "." ]
train
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/Controller/SocialAuthController.php#L48-L55
GrupaZero/social
src/Gzero/Social/Controller/SocialAuthController.php
SocialAuthController.socialCallback
public function socialCallback(Request $request, $serviceName) { try { $this->setDynamicRedirectUrl($serviceName); $user = $this->socialite->driver($serviceName)->user(); $this->authService->login($serviceName, $user); return redirect(session('url.intended', '/')); } catch (\Exception $e) { Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true)); if (session()->has('url.intended')) { // If redirect url exists show translated error to the user $reditectUrl = session('url.intended'); session()->forget('url.intended'); // remove intended url // Set flash message session()->flash( 'messages', [ [ 'code' => 'error', 'text' => $e->getMessage() ] ] ); return redirect($reditectUrl); } else { return app()->abort(500, $e->getMessage()); } } }
php
public function socialCallback(Request $request, $serviceName) { try { $this->setDynamicRedirectUrl($serviceName); $user = $this->socialite->driver($serviceName)->user(); $this->authService->login($serviceName, $user); return redirect(session('url.intended', '/')); } catch (\Exception $e) { Log::error('Social login failed: ' . $e->getMessage() . ' - ' . print_r($request->all(), true)); if (session()->has('url.intended')) { // If redirect url exists show translated error to the user $reditectUrl = session('url.intended'); session()->forget('url.intended'); // remove intended url // Set flash message session()->flash( 'messages', [ [ 'code' => 'error', 'text' => $e->getMessage() ] ] ); return redirect($reditectUrl); } else { return app()->abort(500, $e->getMessage()); } } }
[ "public", "function", "socialCallback", "(", "Request", "$", "request", ",", "$", "serviceName", ")", "{", "try", "{", "$", "this", "->", "setDynamicRedirectUrl", "(", "$", "serviceName", ")", ";", "$", "user", "=", "$", "this", "->", "socialite", "->", "driver", "(", "$", "serviceName", ")", "->", "user", "(", ")", ";", "$", "this", "->", "authService", "->", "login", "(", "$", "serviceName", ",", "$", "user", ")", ";", "return", "redirect", "(", "session", "(", "'url.intended'", ",", "'/'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Log", "::", "error", "(", "'Social login failed: '", ".", "$", "e", "->", "getMessage", "(", ")", ".", "' - '", ".", "print_r", "(", "$", "request", "->", "all", "(", ")", ",", "true", ")", ")", ";", "if", "(", "session", "(", ")", "->", "has", "(", "'url.intended'", ")", ")", "{", "// If redirect url exists show translated error to the user", "$", "reditectUrl", "=", "session", "(", "'url.intended'", ")", ";", "session", "(", ")", "->", "forget", "(", "'url.intended'", ")", ";", "// remove intended url", "// Set flash message", "session", "(", ")", "->", "flash", "(", "'messages'", ",", "[", "[", "'code'", "=>", "'error'", ",", "'text'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", "]", ")", ";", "return", "redirect", "(", "$", "reditectUrl", ")", ";", "}", "else", "{", "return", "app", "(", ")", "->", "abort", "(", "500", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "}" ]
Function responsible for handle a callback request from the given social service. @param Request $request Request object @param string $serviceName string social service name @return \Illuminate\Http\RedirectResponse
[ "Function", "responsible", "for", "handle", "a", "callback", "request", "from", "the", "given", "social", "service", "." ]
train
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Social/Controller/SocialAuthController.php#L65-L92
highday/glitter
src/Console/Commands/InstallCommand.php
InstallCommand.handle
public function handle() { $store = \Glitter\Eloquent\Models\Store::firstOrCreate([ 'name' => 'Highday Store', 'account_email' => '[email protected]', 'customer_email' => '[email protected]', 'timezone' => 'Asia/Tokyo', 'currency' => 'JPY', ]); $role = \Glitter\Eloquent\Models\Role::firstOrCreate([ 'store_id' => $store->getKey(), 'built_in' => true, 'name' => 'ストアオーナー', 'description' => 'ストアアカウントの所有者', ]); $role2 = \Glitter\Eloquent\Models\Role::firstOrCreate([ 'store_id' => $store->getKey(), 'built_in' => false, 'name' => 'ストアスタッフ', 'description' => '店員用アカウント', ]); $policy = \Glitter\Eloquent\Models\Policy::firstOrNew([ 'store_id' => $store->getKey(), 'name' => 'バックオフィス', 'description' => 'バックオフィスにアクセス可能', ]); if (!$policy->exists) { $policy->save(); $role->policies()->attach($policy); $role2->policies()->attach($policy); } $member = \Glitter\Eloquent\Models\Member::firstOrNew([ 'first_name' => 'Keisuke', 'last_name' => 'Nemoto', 'email' => '[email protected]', ]); if (!$member->exists) { $member->password = bcrypt('password'); $member->save(); $member->stores()->attach($store); $member->roles()->attach($role); } $customer = \Glitter\Eloquent\Models\Customer::firstOrNew([ 'first_name' => 'Keisuke', 'last_name' => 'Nemoto', 'email' => '[email protected]', 'mailmagazine_flag' => 1, ]); if (!$customer->exists) { // $customer->password = bcrypt('password'); $customer->save(); $customer->stores()->attach($store); } $product = \Glitter\Eloquent\Models\Product::firstOrCreate([ 'store_id' => $store->getKey(), 'name' => 'Highday original t-shirt', 'description' => 'My first sample product.', 'option1' => 'Color', 'option2' => 'Size', 'option3' => null, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'S', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'M', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'L', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'S', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'M', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'L', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); }
php
public function handle() { $store = \Glitter\Eloquent\Models\Store::firstOrCreate([ 'name' => 'Highday Store', 'account_email' => '[email protected]', 'customer_email' => '[email protected]', 'timezone' => 'Asia/Tokyo', 'currency' => 'JPY', ]); $role = \Glitter\Eloquent\Models\Role::firstOrCreate([ 'store_id' => $store->getKey(), 'built_in' => true, 'name' => 'ストアオーナー', 'description' => 'ストアアカウントの所有者', ]); $role2 = \Glitter\Eloquent\Models\Role::firstOrCreate([ 'store_id' => $store->getKey(), 'built_in' => false, 'name' => 'ストアスタッフ', 'description' => '店員用アカウント', ]); $policy = \Glitter\Eloquent\Models\Policy::firstOrNew([ 'store_id' => $store->getKey(), 'name' => 'バックオフィス', 'description' => 'バックオフィスにアクセス可能', ]); if (!$policy->exists) { $policy->save(); $role->policies()->attach($policy); $role2->policies()->attach($policy); } $member = \Glitter\Eloquent\Models\Member::firstOrNew([ 'first_name' => 'Keisuke', 'last_name' => 'Nemoto', 'email' => '[email protected]', ]); if (!$member->exists) { $member->password = bcrypt('password'); $member->save(); $member->stores()->attach($store); $member->roles()->attach($role); } $customer = \Glitter\Eloquent\Models\Customer::firstOrNew([ 'first_name' => 'Keisuke', 'last_name' => 'Nemoto', 'email' => '[email protected]', 'mailmagazine_flag' => 1, ]); if (!$customer->exists) { // $customer->password = bcrypt('password'); $customer->save(); $customer->stores()->attach($store); } $product = \Glitter\Eloquent\Models\Product::firstOrCreate([ 'store_id' => $store->getKey(), 'name' => 'Highday original t-shirt', 'description' => 'My first sample product.', 'option1' => 'Color', 'option2' => 'Size', 'option3' => null, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'S', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'M', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'Black', 'option2' => 'L', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'S', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'M', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); $variant[] = \Glitter\Eloquent\Models\Variant::firstOrCreate([ 'product_id' => $product->getKey(), 'option1' => 'White', 'option2' => 'L', 'option3' => null, 'sku' => null, 'barcode' => null, 'price' => 3000, 'reference_price' => null, 'taxes_included' => 1, 'inventory_management' => 'glitter', 'inventory_quantity' => 100, 'out_of_stock_purchase' => 1, 'requires_shipping' => true, 'fulfillment_service' => 1, ]); }
[ "public", "function", "handle", "(", ")", "{", "$", "store", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Store", "::", "firstOrCreate", "(", "[", "'name'", "=>", "'Highday Store'", ",", "'account_email'", "=>", "'[email protected]'", ",", "'customer_email'", "=>", "'[email protected]'", ",", "'timezone'", "=>", "'Asia/Tokyo'", ",", "'currency'", "=>", "'JPY'", ",", "]", ")", ";", "$", "role", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Role", "::", "firstOrCreate", "(", "[", "'store_id'", "=>", "$", "store", "->", "getKey", "(", ")", ",", "'built_in'", "=>", "true", ",", "'name'", "=>", "'ストアオーナー',", "", "'description'", "=>", "'ストアアカウントの所有者',", "", "]", ")", ";", "$", "role2", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Role", "::", "firstOrCreate", "(", "[", "'store_id'", "=>", "$", "store", "->", "getKey", "(", ")", ",", "'built_in'", "=>", "false", ",", "'name'", "=>", "'ストアスタッフ',", "", "'description'", "=>", "'店員用アカウント',", "", "]", ")", ";", "$", "policy", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Policy", "::", "firstOrNew", "(", "[", "'store_id'", "=>", "$", "store", "->", "getKey", "(", ")", ",", "'name'", "=>", "'バックオフィス',", "", "'description'", "=>", "'バックオフィスにアクセス可能',", "", "]", ")", ";", "if", "(", "!", "$", "policy", "->", "exists", ")", "{", "$", "policy", "->", "save", "(", ")", ";", "$", "role", "->", "policies", "(", ")", "->", "attach", "(", "$", "policy", ")", ";", "$", "role2", "->", "policies", "(", ")", "->", "attach", "(", "$", "policy", ")", ";", "}", "$", "member", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Member", "::", "firstOrNew", "(", "[", "'first_name'", "=>", "'Keisuke'", ",", "'last_name'", "=>", "'Nemoto'", ",", "'email'", "=>", "'[email protected]'", ",", "]", ")", ";", "if", "(", "!", "$", "member", "->", "exists", ")", "{", "$", "member", "->", "password", "=", "bcrypt", "(", "'password'", ")", ";", "$", "member", "->", "save", "(", ")", ";", "$", "member", "->", "stores", "(", ")", "->", "attach", "(", "$", "store", ")", ";", "$", "member", "->", "roles", "(", ")", "->", "attach", "(", "$", "role", ")", ";", "}", "$", "customer", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Customer", "::", "firstOrNew", "(", "[", "'first_name'", "=>", "'Keisuke'", ",", "'last_name'", "=>", "'Nemoto'", ",", "'email'", "=>", "'[email protected]'", ",", "'mailmagazine_flag'", "=>", "1", ",", "]", ")", ";", "if", "(", "!", "$", "customer", "->", "exists", ")", "{", "// $customer->password = bcrypt('password');", "$", "customer", "->", "save", "(", ")", ";", "$", "customer", "->", "stores", "(", ")", "->", "attach", "(", "$", "store", ")", ";", "}", "$", "product", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Product", "::", "firstOrCreate", "(", "[", "'store_id'", "=>", "$", "store", "->", "getKey", "(", ")", ",", "'name'", "=>", "'Highday original t-shirt'", ",", "'description'", "=>", "'My first sample product.'", ",", "'option1'", "=>", "'Color'", ",", "'option2'", "=>", "'Size'", ",", "'option3'", "=>", "null", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'Black'", ",", "'option2'", "=>", "'S'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'Black'", ",", "'option2'", "=>", "'M'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'Black'", ",", "'option2'", "=>", "'L'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'White'", ",", "'option2'", "=>", "'S'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'White'", ",", "'option2'", "=>", "'M'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "$", "variant", "[", "]", "=", "\\", "Glitter", "\\", "Eloquent", "\\", "Models", "\\", "Variant", "::", "firstOrCreate", "(", "[", "'product_id'", "=>", "$", "product", "->", "getKey", "(", ")", ",", "'option1'", "=>", "'White'", ",", "'option2'", "=>", "'L'", ",", "'option3'", "=>", "null", ",", "'sku'", "=>", "null", ",", "'barcode'", "=>", "null", ",", "'price'", "=>", "3000", ",", "'reference_price'", "=>", "null", ",", "'taxes_included'", "=>", "1", ",", "'inventory_management'", "=>", "'glitter'", ",", "'inventory_quantity'", "=>", "100", ",", "'out_of_stock_purchase'", "=>", "1", ",", "'requires_shipping'", "=>", "true", ",", "'fulfillment_service'", "=>", "1", ",", "]", ")", ";", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/highday/glitter/blob/d1c7a227fd2343806bd3ec0314e621ced57dfe66/src/Console/Commands/InstallCommand.php#L28-L197
expectation-php/expect
src/matcher/ToBeAn.php
ToBeAn.match
public function match($actual) { $this->actual = $actual; $this->actualType = $this->detectType($this->actual); return $this->actualType === $this->expected; }
php
public function match($actual) { $this->actual = $actual; $this->actualType = $this->detectType($this->actual); return $this->actualType === $this->expected; }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "$", "this", "->", "actualType", "=", "$", "this", "->", "detectType", "(", "$", "this", "->", "actual", ")", ";", "return", "$", "this", "->", "actualType", "===", "$", "this", "->", "expected", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeAn.php#L60-L66
expectation-php/expect
src/matcher/ToBeAn.php
ToBeAn.reportFailed
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' to be an ') ->appendText($this->expected) ->appendText("\n\n") ->appendText(' expected: ') ->appendText($this->expected) ->appendText("\n") ->appendText(' got: ') ->appendText($this->actualType); }
php
public function reportFailed(FailedMessage $message) { $message->appendText('Expected ') ->appendValue($this->actual) ->appendText(' to be an ') ->appendText($this->expected) ->appendText("\n\n") ->appendText(' expected: ') ->appendText($this->expected) ->appendText("\n") ->appendText(' got: ') ->appendText($this->actualType); }
[ "public", "function", "reportFailed", "(", "FailedMessage", "$", "message", ")", "{", "$", "message", "->", "appendText", "(", "'Expected '", ")", "->", "appendValue", "(", "$", "this", "->", "actual", ")", "->", "appendText", "(", "' to be an '", ")", "->", "appendText", "(", "$", "this", "->", "expected", ")", "->", "appendText", "(", "\"\\n\\n\"", ")", "->", "appendText", "(", "' expected: '", ")", "->", "appendText", "(", "$", "this", "->", "expected", ")", "->", "appendText", "(", "\"\\n\"", ")", "->", "appendText", "(", "' got: '", ")", "->", "appendText", "(", "$", "this", "->", "actualType", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeAn.php#L71-L83
philippfrenzel/yii2instafeed
yii2instafeed.php
yii2instafeed.init
public function init() { parent::init(); //checks for the element id if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } echo Html::beginTag('div', ['id' => $this->options['id']]); //opens the container }
php
public function init() { parent::init(); //checks for the element id if (!isset($this->options['id'])) { $this->options['id'] = $this->getId(); } echo Html::beginTag('div', ['id' => $this->options['id']]); //opens the container }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "//checks for the element id", "if", "(", "!", "isset", "(", "$", "this", "->", "options", "[", "'id'", "]", ")", ")", "{", "$", "this", "->", "options", "[", "'id'", "]", "=", "$", "this", "->", "getId", "(", ")", ";", "}", "echo", "Html", "::", "beginTag", "(", "'div'", ",", "[", "'id'", "=>", "$", "this", "->", "options", "[", "'id'", "]", "]", ")", ";", "//opens the container", "}" ]
Initializes the widget. If you override this method, make sure you call the parent implementation first.
[ "Initializes", "the", "widget", ".", "If", "you", "override", "this", "method", "make", "sure", "you", "call", "the", "parent", "implementation", "first", "." ]
train
https://github.com/philippfrenzel/yii2instafeed/blob/8578ce03db39088590e931b8e336d7aca863ed6f/yii2instafeed.php#L47-L56
philippfrenzel/yii2instafeed
yii2instafeed.php
yii2instafeed.registerPlugin
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); yii2instafeedAsset::register($view); $js = array(); $options = Json::encode($this->clientOptions); $js[] = "var feed$id = new Instafeed($options);"; $js[] = "feed$id.run();"; $view->registerJs(implode("\n", $js),View::POS_READY); }
php
protected function registerPlugin() { $id = $this->options['id']; //get the displayed view and register the needed assets $view = $this->getView(); yii2instafeedAsset::register($view); $js = array(); $options = Json::encode($this->clientOptions); $js[] = "var feed$id = new Instafeed($options);"; $js[] = "feed$id.run();"; $view->registerJs(implode("\n", $js),View::POS_READY); }
[ "protected", "function", "registerPlugin", "(", ")", "{", "$", "id", "=", "$", "this", "->", "options", "[", "'id'", "]", ";", "//get the displayed view and register the needed assets", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "yii2instafeedAsset", "::", "register", "(", "$", "view", ")", ";", "$", "js", "=", "array", "(", ")", ";", "$", "options", "=", "Json", "::", "encode", "(", "$", "this", "->", "clientOptions", ")", ";", "$", "js", "[", "]", "=", "\"var feed$id = new Instafeed($options);\"", ";", "$", "js", "[", "]", "=", "\"feed$id.run();\"", ";", "$", "view", "->", "registerJs", "(", "implode", "(", "\"\\n\"", ",", "$", "js", ")", ",", "View", "::", "POS_READY", ")", ";", "}" ]
Registers a specific dhtmlx widget and the related events @param string $name the name of the dhtmlx plugin
[ "Registers", "a", "specific", "dhtmlx", "widget", "and", "the", "related", "events" ]
train
https://github.com/philippfrenzel/yii2instafeed/blob/8578ce03db39088590e931b8e336d7aca863ed6f/yii2instafeed.php#L71-L86
phpnfe/tools
src/Certificado/Certificado.php
Certificado.carregarArquivo
public function carregarArquivo($arquivo) { //Lendo o arquivo xml $content = simplexml_load_file($arquivo); //Carregando as propriedades $this->chavePri = trim($content->chave_pri); $this->chavePub = trim($content->chave_pub); return true; }
php
public function carregarArquivo($arquivo) { //Lendo o arquivo xml $content = simplexml_load_file($arquivo); //Carregando as propriedades $this->chavePri = trim($content->chave_pri); $this->chavePub = trim($content->chave_pub); return true; }
[ "public", "function", "carregarArquivo", "(", "$", "arquivo", ")", "{", "//Lendo o arquivo xml", "$", "content", "=", "simplexml_load_file", "(", "$", "arquivo", ")", ";", "//Carregando as propriedades", "$", "this", "->", "chavePri", "=", "trim", "(", "$", "content", "->", "chave_pri", ")", ";", "$", "this", "->", "chavePub", "=", "trim", "(", "$", "content", "->", "chave_pub", ")", ";", "return", "true", ";", "}" ]
Carrega um arquivo já com as propriedades do certificado. @param $arquivo @return bool
[ "Carrega", "um", "arquivo", "já", "com", "as", "propriedades", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L30-L40
phpnfe/tools
src/Certificado/Certificado.php
Certificado.carregarPfx
public function carregarPfx($pfx, $senha) { $pfxContent = @is_file($pfx) ? file_get_contents($pfx) : $pfx; $data = []; if (! openssl_pkcs12_read($pfxContent, $data, $senha)) { throw new Exception('O certificado não pôde ser lido! Senha incorreta, arquivo corrompido ou formato inválido!'); } //Carregando propriedades $this->chavePub = trim($data['cert']); $this->chavePri = trim($data['pkey']); }
php
public function carregarPfx($pfx, $senha) { $pfxContent = @is_file($pfx) ? file_get_contents($pfx) : $pfx; $data = []; if (! openssl_pkcs12_read($pfxContent, $data, $senha)) { throw new Exception('O certificado não pôde ser lido! Senha incorreta, arquivo corrompido ou formato inválido!'); } //Carregando propriedades $this->chavePub = trim($data['cert']); $this->chavePri = trim($data['pkey']); }
[ "public", "function", "carregarPfx", "(", "$", "pfx", ",", "$", "senha", ")", "{", "$", "pfxContent", "=", "@", "is_file", "(", "$", "pfx", ")", "?", "file_get_contents", "(", "$", "pfx", ")", ":", "$", "pfx", ";", "$", "data", "=", "[", "]", ";", "if", "(", "!", "openssl_pkcs12_read", "(", "$", "pfxContent", ",", "$", "data", ",", "$", "senha", ")", ")", "{", "throw", "new", "Exception", "(", "'O certificado não pôde ser lido! Senha incorreta, arquivo corrompido ou formato inválido!');", "", "", "}", "//Carregando propriedades", "$", "this", "->", "chavePub", "=", "trim", "(", "$", "data", "[", "'cert'", "]", ")", ";", "$", "this", "->", "chavePri", "=", "trim", "(", "$", "data", "[", "'pkey'", "]", ")", ";", "}" ]
Carrega um arquivo .pfx para pegar as propriedades do certificado. @param $pfx @param $senha @throws Exception
[ "Carrega", "um", "arquivo", ".", "pfx", "para", "pegar", "as", "propriedades", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L49-L61
phpnfe/tools
src/Certificado/Certificado.php
Certificado.salvarArquivo
public function salvarArquivo($arquivo) { // Verificando se a chave pública está nula $this->verificaChaveNula(); $xml = file_get_contents(__DIR__ . '/../Templates/certificado.xml'); $xml = str_replace('{{chave_pub}}', $this->chavePub, $xml); $xml = str_replace('{{chave_pri}}', $this->chavePri, $xml); file_put_contents($arquivo, $xml); return true; }
php
public function salvarArquivo($arquivo) { // Verificando se a chave pública está nula $this->verificaChaveNula(); $xml = file_get_contents(__DIR__ . '/../Templates/certificado.xml'); $xml = str_replace('{{chave_pub}}', $this->chavePub, $xml); $xml = str_replace('{{chave_pri}}', $this->chavePri, $xml); file_put_contents($arquivo, $xml); return true; }
[ "public", "function", "salvarArquivo", "(", "$", "arquivo", ")", "{", "// Verificando se a chave pública está nula", "$", "this", "->", "verificaChaveNula", "(", ")", ";", "$", "xml", "=", "file_get_contents", "(", "__DIR__", ".", "'/../Templates/certificado.xml'", ")", ";", "$", "xml", "=", "str_replace", "(", "'{{chave_pub}}'", ",", "$", "this", "->", "chavePub", ",", "$", "xml", ")", ";", "$", "xml", "=", "str_replace", "(", "'{{chave_pri}}'", ",", "$", "this", "->", "chavePri", ",", "$", "xml", ")", ";", "file_put_contents", "(", "$", "arquivo", ",", "$", "xml", ")", ";", "return", "true", ";", "}" ]
Salva um arquivo com as propriedades do certificado. @param $arquivo @return bool
[ "Salva", "um", "arquivo", "com", "as", "propriedades", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L69-L81
phpnfe/tools
src/Certificado/Certificado.php
Certificado.getValidade
public function getValidade() { $this->verificaChaveNula(); $data = openssl_x509_read($this->chavePub); $certData = openssl_x509_parse($data); return Carbon::createFromFormat('ymdHis', str_replace('Z', '', $certData['validTo'])); }
php
public function getValidade() { $this->verificaChaveNula(); $data = openssl_x509_read($this->chavePub); $certData = openssl_x509_parse($data); return Carbon::createFromFormat('ymdHis', str_replace('Z', '', $certData['validTo'])); }
[ "public", "function", "getValidade", "(", ")", "{", "$", "this", "->", "verificaChaveNula", "(", ")", ";", "$", "data", "=", "openssl_x509_read", "(", "$", "this", "->", "chavePub", ")", ";", "$", "certData", "=", "openssl_x509_parse", "(", "$", "data", ")", ";", "return", "Carbon", "::", "createFromFormat", "(", "'ymdHis'", ",", "str_replace", "(", "'Z'", ",", "''", ",", "$", "certData", "[", "'validTo'", "]", ")", ")", ";", "}" ]
Retorna a data e hora da validade do certificado. @return Carbon
[ "Retorna", "a", "data", "e", "hora", "da", "validade", "do", "certificado", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L110-L118
phpnfe/tools
src/Certificado/Certificado.php
Certificado.salvaChave
public function salvaChave($arquivo, $chave = null) { switch ($chave) { case self::Publico: file_put_contents($arquivo, $this->chavePub); break; case self::Privado: file_put_contents($arquivo, $this->chavePri); break; case self::Certificado: file_put_contents($arquivo, $this->getCertificado()); break; default: if (! is_dir($arquivo)) { throw new Exception("Tipo de chave invalida!\r\nOpcoes: publico, privado, certificado."); } $this->salvaChave($arquivo . '/pri.key', self::Privado); $this->salvaChave($arquivo . '/pub.key', self::Publico); $this->salvaChave($arquivo . '/cert.key', self::Certificado); break; } }
php
public function salvaChave($arquivo, $chave = null) { switch ($chave) { case self::Publico: file_put_contents($arquivo, $this->chavePub); break; case self::Privado: file_put_contents($arquivo, $this->chavePri); break; case self::Certificado: file_put_contents($arquivo, $this->getCertificado()); break; default: if (! is_dir($arquivo)) { throw new Exception("Tipo de chave invalida!\r\nOpcoes: publico, privado, certificado."); } $this->salvaChave($arquivo . '/pri.key', self::Privado); $this->salvaChave($arquivo . '/pub.key', self::Publico); $this->salvaChave($arquivo . '/cert.key', self::Certificado); break; } }
[ "public", "function", "salvaChave", "(", "$", "arquivo", ",", "$", "chave", "=", "null", ")", "{", "switch", "(", "$", "chave", ")", "{", "case", "self", "::", "Publico", ":", "file_put_contents", "(", "$", "arquivo", ",", "$", "this", "->", "chavePub", ")", ";", "break", ";", "case", "self", "::", "Privado", ":", "file_put_contents", "(", "$", "arquivo", ",", "$", "this", "->", "chavePri", ")", ";", "break", ";", "case", "self", "::", "Certificado", ":", "file_put_contents", "(", "$", "arquivo", ",", "$", "this", "->", "getCertificado", "(", ")", ")", ";", "break", ";", "default", ":", "if", "(", "!", "is_dir", "(", "$", "arquivo", ")", ")", "{", "throw", "new", "Exception", "(", "\"Tipo de chave invalida!\\r\\nOpcoes: publico, privado, certificado.\"", ")", ";", "}", "$", "this", "->", "salvaChave", "(", "$", "arquivo", ".", "'/pri.key'", ",", "self", "::", "Privado", ")", ";", "$", "this", "->", "salvaChave", "(", "$", "arquivo", ".", "'/pub.key'", ",", "self", "::", "Publico", ")", ";", "$", "this", "->", "salvaChave", "(", "$", "arquivo", ".", "'/cert.key'", ",", "self", "::", "Certificado", ")", ";", "break", ";", "}", "}" ]
Salva a chave especificada no arquivo passado por parâmetro, caso não especificar a chave verifica se o $arquivo é um diretório, caso for, salva as 3 chaves lá. @param $arquivo @param null $chave @throws Exception
[ "Salva", "a", "chave", "especificada", "no", "arquivo", "passado", "por", "parâmetro", "caso", "não", "especificar", "a", "chave", "verifica", "se", "o", "$arquivo", "é", "um", "diretório", "caso", "for", "salva", "as", "3", "chaves", "lá", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L173-L198
phpnfe/tools
src/Certificado/Certificado.php
Certificado.assinarXML
public function assinarXML($xml, $tag, $ignoreValidCert = false) { $xmlDoc = new Dom(); //Limpando o XML //$order = ["\r\n", "\n", "\r", "\t"]; $order = ["\t"]; $xml = str_replace($order, '', $xml); $xmlDoc->loadXMLString($xml); $node = $xmlDoc->getElementsByTagName($tag)->item(0); // Raiz $root = $xmlDoc->getElementsByTagName($tag)->item(0)->parentNode; $pkcs = new Pkcs12('', $this->getChavePub(), $this->getChavePri(), $this->getCertificado(), $ignoreValidCert); // Assinando $objSSLPriKey = openssl_get_privatekey($this->chavePri); $sxml = $pkcs->zSignXML($xmlDoc, $root, $node, $objSSLPriKey); return $sxml; }
php
public function assinarXML($xml, $tag, $ignoreValidCert = false) { $xmlDoc = new Dom(); //Limpando o XML //$order = ["\r\n", "\n", "\r", "\t"]; $order = ["\t"]; $xml = str_replace($order, '', $xml); $xmlDoc->loadXMLString($xml); $node = $xmlDoc->getElementsByTagName($tag)->item(0); // Raiz $root = $xmlDoc->getElementsByTagName($tag)->item(0)->parentNode; $pkcs = new Pkcs12('', $this->getChavePub(), $this->getChavePri(), $this->getCertificado(), $ignoreValidCert); // Assinando $objSSLPriKey = openssl_get_privatekey($this->chavePri); $sxml = $pkcs->zSignXML($xmlDoc, $root, $node, $objSSLPriKey); return $sxml; }
[ "public", "function", "assinarXML", "(", "$", "xml", ",", "$", "tag", ",", "$", "ignoreValidCert", "=", "false", ")", "{", "$", "xmlDoc", "=", "new", "Dom", "(", ")", ";", "//Limpando o XML", "//$order = [\"\\r\\n\", \"\\n\", \"\\r\", \"\\t\"];", "$", "order", "=", "[", "\"\\t\"", "]", ";", "$", "xml", "=", "str_replace", "(", "$", "order", ",", "''", ",", "$", "xml", ")", ";", "$", "xmlDoc", "->", "loadXMLString", "(", "$", "xml", ")", ";", "$", "node", "=", "$", "xmlDoc", "->", "getElementsByTagName", "(", "$", "tag", ")", "->", "item", "(", "0", ")", ";", "// Raiz", "$", "root", "=", "$", "xmlDoc", "->", "getElementsByTagName", "(", "$", "tag", ")", "->", "item", "(", "0", ")", "->", "parentNode", ";", "$", "pkcs", "=", "new", "Pkcs12", "(", "''", ",", "$", "this", "->", "getChavePub", "(", ")", ",", "$", "this", "->", "getChavePri", "(", ")", ",", "$", "this", "->", "getCertificado", "(", ")", ",", "$", "ignoreValidCert", ")", ";", "// Assinando", "$", "objSSLPriKey", "=", "openssl_get_privatekey", "(", "$", "this", "->", "chavePri", ")", ";", "$", "sxml", "=", "$", "pkcs", "->", "zSignXML", "(", "$", "xmlDoc", ",", "$", "root", ",", "$", "node", ",", "$", "objSSLPriKey", ")", ";", "return", "$", "sxml", ";", "}" ]
Assina o xml passado por parâmetro com a tag também passada por parâmetro. @param $xml @param $tag @param bool $ignoreValidCert @return string @throws Exception
[ "Assina", "o", "xml", "passado", "por", "parâmetro", "com", "a", "tag", "também", "passada", "por", "parâmetro", "." ]
train
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/Certificado/Certificado.php#L209-L231
mothership-ec/composer
src/Composer/Cache.php
Cache.copyFrom
public function copyFrom($file, $source) { if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); $this->filesystem->ensureDirectoryExists(dirname($this->root . $file)); if ($this->io->isDebug()) { $this->io->writeError('Writing '.$this->root . $file.' into cache'); } return copy($source, $this->root . $file); } return false; }
php
public function copyFrom($file, $source) { if ($this->enabled) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); $this->filesystem->ensureDirectoryExists(dirname($this->root . $file)); if ($this->io->isDebug()) { $this->io->writeError('Writing '.$this->root . $file.' into cache'); } return copy($source, $this->root . $file); } return false; }
[ "public", "function", "copyFrom", "(", "$", "file", ",", "$", "source", ")", "{", "if", "(", "$", "this", "->", "enabled", ")", "{", "$", "file", "=", "preg_replace", "(", "'{[^'", ".", "$", "this", "->", "whitelist", ".", "']}i'", ",", "'-'", ",", "$", "file", ")", ";", "$", "this", "->", "filesystem", "->", "ensureDirectoryExists", "(", "dirname", "(", "$", "this", "->", "root", ".", "$", "file", ")", ")", ";", "if", "(", "$", "this", "->", "io", "->", "isDebug", "(", ")", ")", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Writing '", ".", "$", "this", "->", "root", ".", "$", "file", ".", "' into cache'", ")", ";", "}", "return", "copy", "(", "$", "source", ",", "$", "this", "->", "root", ".", "$", "file", ")", ";", "}", "return", "false", ";", "}" ]
Copy a file into the cache
[ "Copy", "a", "file", "into", "the", "cache" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Cache.php#L116-L130
mothership-ec/composer
src/Composer/Cache.php
Cache.copyTo
public function copyTo($file, $target) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { try { touch($this->root . $file, filemtime($this->root . $file), time()); } catch (\ErrorException $e) { // fallback in case the above failed due to incorrect ownership // see https://github.com/composer/composer/issues/4070 touch($this->root . $file); } if ($this->io->isDebug()) { $this->io->writeError('Reading '.$this->root . $file.' from cache'); } return copy($this->root . $file, $target); } return false; }
php
public function copyTo($file, $target) { $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file); if ($this->enabled && file_exists($this->root . $file)) { try { touch($this->root . $file, filemtime($this->root . $file), time()); } catch (\ErrorException $e) { // fallback in case the above failed due to incorrect ownership // see https://github.com/composer/composer/issues/4070 touch($this->root . $file); } if ($this->io->isDebug()) { $this->io->writeError('Reading '.$this->root . $file.' from cache'); } return copy($this->root . $file, $target); } return false; }
[ "public", "function", "copyTo", "(", "$", "file", ",", "$", "target", ")", "{", "$", "file", "=", "preg_replace", "(", "'{[^'", ".", "$", "this", "->", "whitelist", ".", "']}i'", ",", "'-'", ",", "$", "file", ")", ";", "if", "(", "$", "this", "->", "enabled", "&&", "file_exists", "(", "$", "this", "->", "root", ".", "$", "file", ")", ")", "{", "try", "{", "touch", "(", "$", "this", "->", "root", ".", "$", "file", ",", "filemtime", "(", "$", "this", "->", "root", ".", "$", "file", ")", ",", "time", "(", ")", ")", ";", "}", "catch", "(", "\\", "ErrorException", "$", "e", ")", "{", "// fallback in case the above failed due to incorrect ownership", "// see https://github.com/composer/composer/issues/4070", "touch", "(", "$", "this", "->", "root", ".", "$", "file", ")", ";", "}", "if", "(", "$", "this", "->", "io", "->", "isDebug", "(", ")", ")", "{", "$", "this", "->", "io", "->", "writeError", "(", "'Reading '", ".", "$", "this", "->", "root", ".", "$", "file", ".", "' from cache'", ")", ";", "}", "return", "copy", "(", "$", "this", "->", "root", ".", "$", "file", ",", "$", "target", ")", ";", "}", "return", "false", ";", "}" ]
Copy a file out of the cache
[ "Copy", "a", "file", "out", "of", "the", "cache" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Cache.php#L135-L155
raideer/twitch-api
src/Resources/Follows.php
Follows.getFollowers
public function getFollowers($channel, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'cursor' => null, ]; return $this->wrapper->request('GET', "channels/$channel/follows", ['query' => $this->resolveOptions($params, $defaults)]); }
php
public function getFollowers($channel, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'cursor' => null, ]; return $this->wrapper->request('GET', "channels/$channel/follows", ['query' => $this->resolveOptions($params, $defaults)]); }
[ "public", "function", "getFollowers", "(", "$", "channel", ",", "$", "params", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'limit'", "=>", "25", ",", "'offset'", "=>", "0", ",", "'direction'", "=>", "'desc'", ",", "'cursor'", "=>", "null", ",", "]", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'GET'", ",", "\"channels/$channel/follows\"", ",", "[", "'query'", "=>", "$", "this", "->", "resolveOptions", "(", "$", "params", ",", "$", "defaults", ")", "]", ")", ";", "}" ]
Returns a list of follow objects. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#get-channelschannelfollows @param string $channel Target channel @param array $params List of parameters @return object
[ "Returns", "a", "list", "of", "follow", "objects", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Follows.php#L31-L41
raideer/twitch-api
src/Resources/Follows.php
Follows.getFollows
public function getFollows($user, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'sortby' => 'created_at', ]; return $this->wrapper->request('GET', "users/$user/follows/channels", ['query' => $this->resolveOptions($params, $defaults)]); }
php
public function getFollows($user, $params = []) { $defaults = [ 'limit' => 25, 'offset' => 0, 'direction' => 'desc', 'sortby' => 'created_at', ]; return $this->wrapper->request('GET', "users/$user/follows/channels", ['query' => $this->resolveOptions($params, $defaults)]); }
[ "public", "function", "getFollows", "(", "$", "user", ",", "$", "params", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'limit'", "=>", "25", ",", "'offset'", "=>", "0", ",", "'direction'", "=>", "'desc'", ",", "'sortby'", "=>", "'created_at'", ",", "]", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'GET'", ",", "\"users/$user/follows/channels\"", ",", "[", "'query'", "=>", "$", "this", "->", "resolveOptions", "(", "$", "params", ",", "$", "defaults", ")", "]", ")", ";", "}" ]
Returns a list of follows objects. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#get-usersuserfollowschannels @param string $user Target user @param array $params List of parameters @return object
[ "Returns", "a", "list", "of", "follows", "objects", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Follows.php#L54-L64
raideer/twitch-api
src/Resources/Follows.php
Follows.followChannel
public function followChannel($user, $target, $notifications = false) { $this->wrapper->checkScope('user_follows_edit'); return $this->wrapper->request('PUT', "users/$user/follows/channels/$target", ['form_params' => ['notifications' => $notifications]], true); }
php
public function followChannel($user, $target, $notifications = false) { $this->wrapper->checkScope('user_follows_edit'); return $this->wrapper->request('PUT', "users/$user/follows/channels/$target", ['form_params' => ['notifications' => $notifications]], true); }
[ "public", "function", "followChannel", "(", "$", "user", ",", "$", "target", ",", "$", "notifications", "=", "false", ")", "{", "$", "this", "->", "wrapper", "->", "checkScope", "(", "'user_follows_edit'", ")", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'PUT'", ",", "\"users/$user/follows/channels/$target\"", ",", "[", "'form_params'", "=>", "[", "'notifications'", "=>", "$", "notifications", "]", "]", ",", "true", ")", ";", "}" ]
Adds $user to $target's followers. $user is authenticated user's name and $target is the name of the channel to be followed. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#put-usersuserfollowschannelstarget @param string $user Authenticated user @param string $target Target channel @param bool $notifications Wether $user wants to receive notifications when $target goes live @return array
[ "Adds", "$user", "to", "$target", "s", "followers", ".", "$user", "is", "authenticated", "user", "s", "name", "and", "$target", "is", "the", "name", "of", "the", "channel", "to", "be", "followed", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Follows.php#L95-L100
raideer/twitch-api
src/Resources/Follows.php
Follows.unfollowChannel
public function unfollowChannel($user, $target) { $this->wrapper->checkScope('user_follows_edit'); return $this->wrapper->request('DELETE', "users/$user/follows/channels/$target", [], true); }
php
public function unfollowChannel($user, $target) { $this->wrapper->checkScope('user_follows_edit'); return $this->wrapper->request('DELETE', "users/$user/follows/channels/$target", [], true); }
[ "public", "function", "unfollowChannel", "(", "$", "user", ",", "$", "target", ")", "{", "$", "this", "->", "wrapper", "->", "checkScope", "(", "'user_follows_edit'", ")", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'DELETE'", ",", "\"users/$user/follows/channels/$target\"", ",", "[", "]", ",", "true", ")", ";", "}" ]
Removes $user from $target's followers. $user is authenticated user's name and $target is the name of the channel to be unfollowed. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/follows.md#delete-usersuserfollowschannelstarget @param string $user Authenticated user @param string $target Target channel @return array
[ "Removes", "$user", "from", "$target", "s", "followers", ".", "$user", "is", "authenticated", "user", "s", "name", "and", "$target", "is", "the", "name", "of", "the", "channel", "to", "be", "unfollowed", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Follows.php#L114-L119
Rxnet/rabbitmq
Client.php
Client.channel
public function channel($bind = []): Observable { $this->bunny = $this->bunny ?? new BaseAsynchClient($this->loop, $this->configuration); if (!\is_array($bind)) { $bind = \func_get_args(); } return Observable::fromPromise( $this->bunny ->connect() ->then(function (BaseAsynchClient $client) { return $client->channel(); }) ->then(function (Channel $channel) use ($bind) { foreach ($bind as $obj) { $obj->setChannel($channel); } return $channel; }) ); }
php
public function channel($bind = []): Observable { $this->bunny = $this->bunny ?? new BaseAsynchClient($this->loop, $this->configuration); if (!\is_array($bind)) { $bind = \func_get_args(); } return Observable::fromPromise( $this->bunny ->connect() ->then(function (BaseAsynchClient $client) { return $client->channel(); }) ->then(function (Channel $channel) use ($bind) { foreach ($bind as $obj) { $obj->setChannel($channel); } return $channel; }) ); }
[ "public", "function", "channel", "(", "$", "bind", "=", "[", "]", ")", ":", "Observable", "{", "$", "this", "->", "bunny", "=", "$", "this", "->", "bunny", "??", "new", "BaseAsynchClient", "(", "$", "this", "->", "loop", ",", "$", "this", "->", "configuration", ")", ";", "if", "(", "!", "\\", "is_array", "(", "$", "bind", ")", ")", "{", "$", "bind", "=", "\\", "func_get_args", "(", ")", ";", "}", "return", "Observable", "::", "fromPromise", "(", "$", "this", "->", "bunny", "->", "connect", "(", ")", "->", "then", "(", "function", "(", "BaseAsynchClient", "$", "client", ")", "{", "return", "$", "client", "->", "channel", "(", ")", ";", "}", ")", "->", "then", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "bind", ")", "{", "foreach", "(", "$", "bind", "as", "$", "obj", ")", "{", "$", "obj", "->", "setChannel", "(", "$", "channel", ")", ";", "}", "return", "$", "channel", ";", "}", ")", ")", ";", "}" ]
Open a new channel and attribute it to given queues or exchanges. @param Queue[]|Exchange[] $bind
[ "Open", "a", "new", "channel", "and", "attribute", "it", "to", "given", "queues", "or", "exchanges", "." ]
train
https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Client.php#L64-L86
Rxnet/rabbitmq
Client.php
Client.consume
public function consume($queue, $prefetchCount = null, $prefetchSize = null, $consumerId = null): Observable { return $this->channel() ->do(function (Channel $channel) use ($prefetchCount, $prefetchSize) { $channel->qos($prefetchSize, $prefetchCount); }) ->flatMap( function (Channel $channel) use ($queue, $consumerId) { return $this->queue($queue, $channel) ->consume($consumerId); } ); }
php
public function consume($queue, $prefetchCount = null, $prefetchSize = null, $consumerId = null): Observable { return $this->channel() ->do(function (Channel $channel) use ($prefetchCount, $prefetchSize) { $channel->qos($prefetchSize, $prefetchCount); }) ->flatMap( function (Channel $channel) use ($queue, $consumerId) { return $this->queue($queue, $channel) ->consume($consumerId); } ); }
[ "public", "function", "consume", "(", "$", "queue", ",", "$", "prefetchCount", "=", "null", ",", "$", "prefetchSize", "=", "null", ",", "$", "consumerId", "=", "null", ")", ":", "Observable", "{", "return", "$", "this", "->", "channel", "(", ")", "->", "do", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "prefetchCount", ",", "$", "prefetchSize", ")", "{", "$", "channel", "->", "qos", "(", "$", "prefetchSize", ",", "$", "prefetchCount", ")", ";", "}", ")", "->", "flatMap", "(", "function", "(", "Channel", "$", "channel", ")", "use", "(", "$", "queue", ",", "$", "consumerId", ")", "{", "return", "$", "this", "->", "queue", "(", "$", "queue", ",", "$", "channel", ")", "->", "consume", "(", "$", "consumerId", ")", ";", "}", ")", ";", "}" ]
Consume given queue at.
[ "Consume", "given", "queue", "at", "." ]
train
https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Client.php#L91-L103
php-comp/lite-database
src/LitePdo.php
LitePdo.disconnect
public function disconnect() { $this->log('disconnect from DB server', [], 'connect'); $this->fire(self::DISCONNECT, [$this->config]); $this->pdo = null; }
php
public function disconnect() { $this->log('disconnect from DB server', [], 'connect'); $this->fire(self::DISCONNECT, [$this->config]); $this->pdo = null; }
[ "public", "function", "disconnect", "(", ")", "{", "$", "this", "->", "log", "(", "'disconnect from DB server'", ",", "[", "]", ",", "'connect'", ")", ";", "$", "this", "->", "fire", "(", "self", "::", "DISCONNECT", ",", "[", "$", "this", "->", "config", "]", ")", ";", "$", "this", "->", "pdo", "=", "null", ";", "}" ]
disconnect
[ "disconnect" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L177-L182
php-comp/lite-database
src/LitePdo.php
LitePdo.queryOne
public function queryOne(string $from, $wheres = 1, $select = '*', array $options = []) { $options['select'] = $this->qns($select ?: '*'); $options['from'] = $this->qn($from); list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['where'] = $where; $options['limit'] = 1; $statement = $this->compileSelect($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } if ($class = $options['class'] ?? null) { return $this->fetchObject($statement, $bindings, $class); } $method = 'fetchAssoc'; if (isset($options['fetchType'])) { if ($options['fetchType'] === 'column') { $method = 'fetchColumn'; } elseif ($options['fetchType'] === 'value') { $method = 'fetchValue'; } } return $this->$method($statement, $bindings); }
php
public function queryOne(string $from, $wheres = 1, $select = '*', array $options = []) { $options['select'] = $this->qns($select ?: '*'); $options['from'] = $this->qn($from); list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['where'] = $where; $options['limit'] = 1; $statement = $this->compileSelect($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } if ($class = $options['class'] ?? null) { return $this->fetchObject($statement, $bindings, $class); } $method = 'fetchAssoc'; if (isset($options['fetchType'])) { if ($options['fetchType'] === 'column') { $method = 'fetchColumn'; } elseif ($options['fetchType'] === 'value') { $method = 'fetchValue'; } } return $this->$method($statement, $bindings); }
[ "public", "function", "queryOne", "(", "string", "$", "from", ",", "$", "wheres", "=", "1", ",", "$", "select", "=", "'*'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'select'", "]", "=", "$", "this", "->", "qns", "(", "$", "select", "?", ":", "'*'", ")", ";", "$", "options", "[", "'from'", "]", "=", "$", "this", "->", "qn", "(", "$", "from", ")", ";", "list", "(", "$", "where", ",", "$", "bindings", ")", "=", "DBHelper", "::", "handleConditions", "(", "$", "wheres", ",", "$", "this", ")", ";", "$", "options", "[", "'where'", "]", "=", "$", "where", ";", "$", "options", "[", "'limit'", "]", "=", "1", ";", "$", "statement", "=", "$", "this", "->", "compileSelect", "(", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "if", "(", "$", "class", "=", "$", "options", "[", "'class'", "]", "??", "null", ")", "{", "return", "$", "this", "->", "fetchObject", "(", "$", "statement", ",", "$", "bindings", ",", "$", "class", ")", ";", "}", "$", "method", "=", "'fetchAssoc'", ";", "if", "(", "isset", "(", "$", "options", "[", "'fetchType'", "]", ")", ")", "{", "if", "(", "$", "options", "[", "'fetchType'", "]", "===", "'column'", ")", "{", "$", "method", "=", "'fetchColumn'", ";", "}", "elseif", "(", "$", "options", "[", "'fetchType'", "]", "===", "'value'", ")", "{", "$", "method", "=", "'fetchValue'", ";", "}", "}", "return", "$", "this", "->", "$", "method", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a select statement, fetch one @param string $from @param array|string|int $wheres @param string|array $select @param array $options allowed options: - returnSql Will not be executed, just return the built SQL. more option please @see LitePdoInterface::QUERY_OPTIONS @return array|mixed @throws \InvalidArgumentException
[ "Run", "a", "select", "statement", "fetch", "one" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L219-L250
php-comp/lite-database
src/LitePdo.php
LitePdo.queryAll
public function queryAll(string $from, $wheres = 1, $select = '*', array $options = []): array { $options['select'] = $this->qns($select ?: '*'); $options['from'] = $this->qn($from); list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['where'] = $where; if (!isset($options['limit'])) { $options['limit'] = 1000; } $statement = $this->compileSelect($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } $indexKey = $options['indexKey'] ?? null; if ($class = $options['class'] ?? null) { return $this->fetchObjects($statement, $bindings, $class, $indexKey); } $method = 'fetchAssocs'; if (isset($options['fetchType'])) { if ($options['fetchType'] === 'column') { // for get columns, indexKey is column number. $method = 'fetchColumns'; $indexKey = (int)$indexKey; } elseif ($options['fetchType'] === 'value') { $method = 'fetchValues'; } } return $this->$method($statement, $bindings, $indexKey); }
php
public function queryAll(string $from, $wheres = 1, $select = '*', array $options = []): array { $options['select'] = $this->qns($select ?: '*'); $options['from'] = $this->qn($from); list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['where'] = $where; if (!isset($options['limit'])) { $options['limit'] = 1000; } $statement = $this->compileSelect($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } $indexKey = $options['indexKey'] ?? null; if ($class = $options['class'] ?? null) { return $this->fetchObjects($statement, $bindings, $class, $indexKey); } $method = 'fetchAssocs'; if (isset($options['fetchType'])) { if ($options['fetchType'] === 'column') { // for get columns, indexKey is column number. $method = 'fetchColumns'; $indexKey = (int)$indexKey; } elseif ($options['fetchType'] === 'value') { $method = 'fetchValues'; } } return $this->$method($statement, $bindings, $indexKey); }
[ "public", "function", "queryAll", "(", "string", "$", "from", ",", "$", "wheres", "=", "1", ",", "$", "select", "=", "'*'", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "options", "[", "'select'", "]", "=", "$", "this", "->", "qns", "(", "$", "select", "?", ":", "'*'", ")", ";", "$", "options", "[", "'from'", "]", "=", "$", "this", "->", "qn", "(", "$", "from", ")", ";", "list", "(", "$", "where", ",", "$", "bindings", ")", "=", "DBHelper", "::", "handleConditions", "(", "$", "wheres", ",", "$", "this", ")", ";", "$", "options", "[", "'where'", "]", "=", "$", "where", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "options", "[", "'limit'", "]", "=", "1000", ";", "}", "$", "statement", "=", "$", "this", "->", "compileSelect", "(", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "$", "indexKey", "=", "$", "options", "[", "'indexKey'", "]", "??", "null", ";", "if", "(", "$", "class", "=", "$", "options", "[", "'class'", "]", "??", "null", ")", "{", "return", "$", "this", "->", "fetchObjects", "(", "$", "statement", ",", "$", "bindings", ",", "$", "class", ",", "$", "indexKey", ")", ";", "}", "$", "method", "=", "'fetchAssocs'", ";", "if", "(", "isset", "(", "$", "options", "[", "'fetchType'", "]", ")", ")", "{", "if", "(", "$", "options", "[", "'fetchType'", "]", "===", "'column'", ")", "{", "// for get columns, indexKey is column number.", "$", "method", "=", "'fetchColumns'", ";", "$", "indexKey", "=", "(", "int", ")", "$", "indexKey", ";", "}", "elseif", "(", "$", "options", "[", "'fetchType'", "]", "===", "'value'", ")", "{", "$", "method", "=", "'fetchValues'", ";", "}", "}", "return", "$", "this", "->", "$", "method", "(", "$", "statement", ",", "$", "bindings", ",", "$", "indexKey", ")", ";", "}" ]
Run a select statement, fetch all @param string $from @param array|string|int $wheres @param string|array $select @param array $options allowed options: - returnSql Will not be executed, just return the built SQL. more option please @see LitePdoInterface::QUERY_OPTIONS @return array @throws \InvalidArgumentException
[ "Run", "a", "select", "statement", "fetch", "all" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L264-L302
php-comp/lite-database
src/LitePdo.php
LitePdo.insertBatch
public function insertBatch(string $from, array $dataSet, array $options = []) { list($statement, $bindings) = $this->compileInsert($from, $dataSet, $options['columns'] ?? [], true); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
php
public function insertBatch(string $from, array $dataSet, array $options = []) { list($statement, $bindings) = $this->compileInsert($from, $dataSet, $options['columns'] ?? [], true); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
[ "public", "function", "insertBatch", "(", "string", "$", "from", ",", "array", "$", "dataSet", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "statement", ",", "$", "bindings", ")", "=", "$", "this", "->", "compileInsert", "(", "$", "from", ",", "$", "dataSet", ",", "$", "options", "[", "'columns'", "]", "??", "[", "]", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "return", "$", "this", "->", "fetchAffected", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a statement for insert multi row @param string $from @param array $dataSet @param array $options - returnSql Will not be executed, just return the built SQL. - columns Setting the table columns to insert. @return int|array @throws \PDOException @throws \InvalidArgumentException
[ "Run", "a", "statement", "for", "insert", "multi", "row" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L343-L352
php-comp/lite-database
src/LitePdo.php
LitePdo.update
public function update(string $from, $wheres, array $values, array $options = []) { list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['update'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileUpdate($values, $bindings, $options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
php
public function update(string $from, $wheres, array $values, array $options = []) { list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['update'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileUpdate($values, $bindings, $options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
[ "public", "function", "update", "(", "string", "$", "from", ",", "$", "wheres", ",", "array", "$", "values", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "where", ",", "$", "bindings", ")", "=", "DBHelper", "::", "handleConditions", "(", "$", "wheres", ",", "$", "this", ")", ";", "$", "options", "[", "'update'", "]", "=", "$", "this", "->", "qn", "(", "$", "from", ")", ";", "$", "options", "[", "'where'", "]", "=", "$", "where", ";", "$", "statement", "=", "$", "this", "->", "compileUpdate", "(", "$", "values", ",", "$", "bindings", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "return", "$", "this", "->", "fetchAffected", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a update statement @param string $from @param array|string $wheres @param array $values @param array $options @return int|array @throws \InvalidArgumentException
[ "Run", "a", "update", "statement" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L363-L377
php-comp/lite-database
src/LitePdo.php
LitePdo.delete
public function delete(string $from, $wheres, array $options = []) { if (!$wheres) { throw new \InvalidArgumentException('Safety considerations, where conditions can not be empty'); } list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['from'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileDelete($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
php
public function delete(string $from, $wheres, array $options = []) { if (!$wheres) { throw new \InvalidArgumentException('Safety considerations, where conditions can not be empty'); } list($where, $bindings) = DBHelper::handleConditions($wheres, $this); $options['from'] = $this->qn($from); $options['where'] = $where; $statement = $this->compileDelete($options); if (isset($options['returnSql'])) { return [$statement, $bindings]; } return $this->fetchAffected($statement, $bindings); }
[ "public", "function", "delete", "(", "string", "$", "from", ",", "$", "wheres", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "wheres", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Safety considerations, where conditions can not be empty'", ")", ";", "}", "list", "(", "$", "where", ",", "$", "bindings", ")", "=", "DBHelper", "::", "handleConditions", "(", "$", "wheres", ",", "$", "this", ")", ";", "$", "options", "[", "'from'", "]", "=", "$", "this", "->", "qn", "(", "$", "from", ")", ";", "$", "options", "[", "'where'", "]", "=", "$", "where", ";", "$", "statement", "=", "$", "this", "->", "compileDelete", "(", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'returnSql'", "]", ")", ")", "{", "return", "[", "$", "statement", ",", "$", "bindings", "]", ";", "}", "return", "$", "this", "->", "fetchAffected", "(", "$", "statement", ",", "$", "bindings", ")", ";", "}" ]
Run a delete statement @param string $from @param array|string $wheres @param array $options @return int|array @throws \InvalidArgumentException
[ "Run", "a", "delete", "statement" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L387-L405
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchColumn
public function fetchColumn(string $statement, array $bindings = [], int $columnNum = 0) { $sth = $this->execute($statement, $bindings); $result = $sth->fetchColumn($columnNum); $this->freeResource($sth); return $result; }
php
public function fetchColumn(string $statement, array $bindings = [], int $columnNum = 0) { $sth = $this->execute($statement, $bindings); $result = $sth->fetchColumn($columnNum); $this->freeResource($sth); return $result; }
[ "public", "function", "fetchColumn", "(", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ",", "int", "$", "columnNum", "=", "0", ")", "{", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "$", "result", "=", "$", "sth", "->", "fetchColumn", "(", "$", "columnNum", ")", ";", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "result", ";", "}" ]
从结果集中的下一行返回单独的一列 @param string $statement @param array $bindings @param int $columnNum 你想从行里取回的列的索引数字(以0开始的索引) @return mixed @throws \PDOException @throws \InvalidArgumentException
[ "从结果集中的下一行返回单独的一列" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L511-L519
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchObject
public function fetchObject(string $statement, array $bindings = [], $class = 'stdClass', array $args = []) { $sth = $this->execute($statement, $bindings); if (!empty($args)) { $result = $sth->fetchObject($class, $args); } else { $result = $sth->fetchObject($class); } $this->freeResource($sth); return $result; }
php
public function fetchObject(string $statement, array $bindings = [], $class = 'stdClass', array $args = []) { $sth = $this->execute($statement, $bindings); if (!empty($args)) { $result = $sth->fetchObject($class, $args); } else { $result = $sth->fetchObject($class); } $this->freeResource($sth); return $result; }
[ "public", "function", "fetchObject", "(", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ",", "$", "class", "=", "'stdClass'", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "if", "(", "!", "empty", "(", "$", "args", ")", ")", "{", "$", "result", "=", "$", "sth", "->", "fetchObject", "(", "$", "class", ",", "$", "args", ")", ";", "}", "else", "{", "$", "result", "=", "$", "sth", "->", "fetchObject", "(", "$", "class", ")", ";", "}", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "result", ";", "}" ]
{@inheritdoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L543-L556
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchAssocs
public function fetchAssocs(string $statement, array $bindings = [], $indexKey = null): array { $data = []; $sth = $this->execute($statement, $bindings); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { if ($indexKey) { $data[$row[$indexKey]] = $row; } else { $data[] = $row; } // $data[current($row)] = $row; } $this->freeResource($sth); return $data; }
php
public function fetchAssocs(string $statement, array $bindings = [], $indexKey = null): array { $data = []; $sth = $this->execute($statement, $bindings); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { if ($indexKey) { $data[$row[$indexKey]] = $row; } else { $data[] = $row; } // $data[current($row)] = $row; } $this->freeResource($sth); return $data; }
[ "public", "function", "fetchAssocs", "(", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ",", "$", "indexKey", "=", "null", ")", ":", "array", "{", "$", "data", "=", "[", "]", ";", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "while", "(", "$", "row", "=", "$", "sth", "->", "fetch", "(", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "if", "(", "$", "indexKey", ")", "{", "$", "data", "[", "$", "row", "[", "$", "indexKey", "]", "]", "=", "$", "row", ";", "}", "else", "{", "$", "data", "[", "]", "=", "$", "row", ";", "}", "// $data[current($row)] = $row;", "}", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "data", ";", "}" ]
{@inheritdoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L592-L609
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchFuns
public function fetchFuns(callable $func, string $statement, array $bindings = []): array { $sth = $this->execute($statement, $bindings); $result = $sth->fetchAll(PDO::FETCH_FUNC, $func); $this->freeResource($sth); return $result; }
php
public function fetchFuns(callable $func, string $statement, array $bindings = []): array { $sth = $this->execute($statement, $bindings); $result = $sth->fetchAll(PDO::FETCH_FUNC, $func); $this->freeResource($sth); return $result; }
[ "public", "function", "fetchFuns", "(", "callable", "$", "func", ",", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ")", ":", "array", "{", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "$", "result", "=", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_FUNC", ",", "$", "func", ")", ";", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "result", ";", "}" ]
每行调用一次函数. 将每行的列值作为参数传递给指定的函数,并返回调用函数后的结果。 @param string $statement @param array $bindings @param callable $func ```php function ($col1, $col2) { return $col1 . $col2; } ``` @return array @throws \PDOException @throws \InvalidArgumentException
[ "每行调用一次函数", ".", "将每行的列值作为参数传递给指定的函数,并返回调用函数后的结果。" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L695-L703
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchGroups
public function fetchGroups(string $statement, array $bindings = [], $style = PDO::FETCH_COLUMN): array { $sth = $this->execute($statement, $bindings); $group = $sth->fetchAll(PDO::FETCH_GROUP | $style); $this->freeResource($sth); return $group; }
php
public function fetchGroups(string $statement, array $bindings = [], $style = PDO::FETCH_COLUMN): array { $sth = $this->execute($statement, $bindings); $group = $sth->fetchAll(PDO::FETCH_GROUP | $style); $this->freeResource($sth); return $group; }
[ "public", "function", "fetchGroups", "(", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ",", "$", "style", "=", "PDO", "::", "FETCH_COLUMN", ")", ":", "array", "{", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "$", "group", "=", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_GROUP", "|", "$", "style", ")", ";", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "group", ";", "}" ]
{@inheritdoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L710-L718
php-comp/lite-database
src/LitePdo.php
LitePdo.fetchPairs
public function fetchPairs(string $statement, array $bindings = []): array { $sth = $this->execute($statement, $bindings); $result = $sth->fetchAll(PDO::FETCH_KEY_PAIR); $this->freeResource($sth); return $result; }
php
public function fetchPairs(string $statement, array $bindings = []): array { $sth = $this->execute($statement, $bindings); $result = $sth->fetchAll(PDO::FETCH_KEY_PAIR); $this->freeResource($sth); return $result; }
[ "public", "function", "fetchPairs", "(", "string", "$", "statement", ",", "array", "$", "bindings", "=", "[", "]", ")", ":", "array", "{", "$", "sth", "=", "$", "this", "->", "execute", "(", "$", "statement", ",", "$", "bindings", ")", ";", "$", "result", "=", "$", "sth", "->", "fetchAll", "(", "PDO", "::", "FETCH_KEY_PAIR", ")", ";", "$", "this", "->", "freeResource", "(", "$", "sth", ")", ";", "return", "$", "result", ";", "}" ]
{@inheritdoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L725-L734
php-comp/lite-database
src/LitePdo.php
LitePdo.transactional
public function transactional(callable $func) { if (!\is_callable($func)) { throw new \InvalidArgumentException('Expected argument of type "callable", got "' . \gettype($func) . '"'); } $this->connect(); $this->pdo->beginTransaction(); try { $return = $func($this); $this->pdo->commit(); return $return ?: true; } catch (\Throwable $e) { $this->pdo->rollBack(); throw $e; } }
php
public function transactional(callable $func) { if (!\is_callable($func)) { throw new \InvalidArgumentException('Expected argument of type "callable", got "' . \gettype($func) . '"'); } $this->connect(); $this->pdo->beginTransaction(); try { $return = $func($this); $this->pdo->commit(); return $return ?: true; } catch (\Throwable $e) { $this->pdo->rollBack(); throw $e; } }
[ "public", "function", "transactional", "(", "callable", "$", "func", ")", "{", "if", "(", "!", "\\", "is_callable", "(", "$", "func", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expected argument of type \"callable\", got \"'", ".", "\\", "gettype", "(", "$", "func", ")", ".", "'\"'", ")", ";", "}", "$", "this", "->", "connect", "(", ")", ";", "$", "this", "->", "pdo", "->", "beginTransaction", "(", ")", ";", "try", "{", "$", "return", "=", "$", "func", "(", "$", "this", ")", ";", "$", "this", "->", "pdo", "->", "commit", "(", ")", ";", "return", "$", "return", "?", ":", "true", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "this", "->", "pdo", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
事务 {@inheritDoc} @throws \InvalidArgumentException @throws \PDOException
[ "事务", "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L938-L956
php-comp/lite-database
src/LitePdo.php
LitePdo.query
public function query($statement, ...$fetch): PDOStatement { $this->connect(); $statement = DBHelper::replaceTablePrefix($statement, $this->tablePrefix, $this->prefixPlaceholder); // trigger before event $this->fire(self::BEFORE_EXECUTE, [$statement]); $sth = $this->pdo->query($statement, ...$fetch); // trigger after event $this->fire(self::AFTER_EXECUTE, [$statement]); return $sth; }
php
public function query($statement, ...$fetch): PDOStatement { $this->connect(); $statement = DBHelper::replaceTablePrefix($statement, $this->tablePrefix, $this->prefixPlaceholder); // trigger before event $this->fire(self::BEFORE_EXECUTE, [$statement]); $sth = $this->pdo->query($statement, ...$fetch); // trigger after event $this->fire(self::AFTER_EXECUTE, [$statement]); return $sth; }
[ "public", "function", "query", "(", "$", "statement", ",", "...", "$", "fetch", ")", ":", "PDOStatement", "{", "$", "this", "->", "connect", "(", ")", ";", "$", "statement", "=", "DBHelper", "::", "replaceTablePrefix", "(", "$", "statement", ",", "$", "this", "->", "tablePrefix", ",", "$", "this", "->", "prefixPlaceholder", ")", ";", "// trigger before event", "$", "this", "->", "fire", "(", "self", "::", "BEFORE_EXECUTE", ",", "[", "$", "statement", "]", ")", ";", "$", "sth", "=", "$", "this", "->", "pdo", "->", "query", "(", "$", "statement", ",", "...", "$", "fetch", ")", ";", "// trigger after event", "$", "this", "->", "fire", "(", "self", "::", "AFTER_EXECUTE", ",", "[", "$", "statement", "]", ")", ";", "return", "$", "sth", ";", "}" ]
{@inheritDoc} @return PDOStatement @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L1337-L1352
php-comp/lite-database
src/LitePdo.php
LitePdo.lastInsertId
public function lastInsertId(string $name = null): string { $this->connect(); return $this->pdo->lastInsertId($name); }
php
public function lastInsertId(string $name = null): string { $this->connect(); return $this->pdo->lastInsertId($name); }
[ "public", "function", "lastInsertId", "(", "string", "$", "name", "=", "null", ")", ":", "string", "{", "$", "this", "->", "connect", "(", ")", ";", "return", "$", "this", "->", "pdo", "->", "lastInsertId", "(", "$", "name", ")", ";", "}" ]
{@inheritDoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L1448-L1453
php-comp/lite-database
src/LitePdo.php
LitePdo.setAttribute
public function setAttribute($attribute, $value): bool { $this->connect(); return $this->pdo->setAttribute($attribute, $value); }
php
public function setAttribute($attribute, $value): bool { $this->connect(); return $this->pdo->setAttribute($attribute, $value); }
[ "public", "function", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", ":", "bool", "{", "$", "this", "->", "connect", "(", ")", ";", "return", "$", "this", "->", "pdo", "->", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", ";", "}" ]
{@inheritDoc} @throws \PDOException @throws \InvalidArgumentException
[ "{" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/LitePdo.php#L1472-L1477
skmetaly/laravel-twitch-restful-api
src/API/Users.php
Users.authenticatedUser
public function authenticatedUser($token = null) { $token = $this->getToken($token); $user = $this->client->get('https://api.twitch.tv/kraken/user?oauth_token=' . $token); return $user->json(); }
php
public function authenticatedUser($token = null) { $token = $this->getToken($token); $user = $this->client->get('https://api.twitch.tv/kraken/user?oauth_token=' . $token); return $user->json(); }
[ "public", "function", "authenticatedUser", "(", "$", "token", "=", "null", ")", "{", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "token", ")", ";", "$", "user", "=", "$", "this", "->", "client", "->", "get", "(", "'https://api.twitch.tv/kraken/user?oauth_token='", ".", "$", "token", ")", ";", "return", "$", "user", "->", "json", "(", ")", ";", "}" ]
Returns a user object. Authenticated, required scope: user_read @param null $token @return json
[ "Returns", "a", "user", "object", "." ]
train
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Users.php#L39-L46
skmetaly/laravel-twitch-restful-api
src/API/Users.php
Users.streamsFollowed
public function streamsFollowed($token = null) { $token = $this->getToken($token); $streams = $this->client->get('https://api.twitch.tv/kraken/streams/followed?oauth_token=' . $token); return $streams->json(); }
php
public function streamsFollowed($token = null) { $token = $this->getToken($token); $streams = $this->client->get('https://api.twitch.tv/kraken/streams/followed?oauth_token=' . $token); return $streams->json(); }
[ "public", "function", "streamsFollowed", "(", "$", "token", "=", "null", ")", "{", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "token", ")", ";", "$", "streams", "=", "$", "this", "->", "client", "->", "get", "(", "'https://api.twitch.tv/kraken/streams/followed?oauth_token='", ".", "$", "token", ")", ";", "return", "$", "streams", "->", "json", "(", ")", ";", "}" ]
Returns a list of stream objects that the authenticated user is following. Authenticated, required scope: user_read @param null $token @return json @throws \Skmetaly\TwitchApi\Exceptions\RequestRequiresAuthenticationException
[ "Returns", "a", "list", "of", "stream", "objects", "that", "the", "authenticated", "user", "is", "following", "." ]
train
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Users.php#L58-L65