repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.preIntercept
public function preIntercept($preInterceptor): ConfigurableRoute { if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PreInterceptor::class . ' or a class name of an existing pre interceptor class' ); } $this->preInterceptors[] = $preInterceptor; return $this; }
php
public function preIntercept($preInterceptor): ConfigurableRoute { if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PreInterceptor::class . ' or a class name of an existing pre interceptor class' ); } $this->preInterceptors[] = $preInterceptor; return $this; }
[ "public", "function", "preIntercept", "(", "$", "preInterceptor", ")", ":", "ConfigurableRoute", "{", "if", "(", "!", "is_callable", "(", "$", "preInterceptor", ")", "&&", "!", "(", "$", "preInterceptor", "instanceof", "PreInterceptor", ")", "&&", "!", "class_exists", "(", "(", "string", ")", "$", "preInterceptor", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Given pre interceptor must be a callable, an instance of '", ".", "PreInterceptor", "::", "class", ".", "' or a class name of an existing pre interceptor class'", ")", ";", "}", "$", "this", "->", "preInterceptors", "[", "]", "=", "$", "preInterceptor", ";", "return", "$", "this", ";", "}" ]
add a pre interceptor for this route @param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor @return \stubbles\webapp\routing\Route @throws \InvalidArgumentException
[ "add", "a", "pre", "interceptor", "for", "this", "route" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L226-L238
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.postIntercept
public function postIntercept($postInterceptor): ConfigurableRoute { if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PostInterceptor::class . ' or a class name of an existing post interceptor class' ); } $this->postInterceptors[] = $postInterceptor; return $this; }
php
public function postIntercept($postInterceptor): ConfigurableRoute { if (!is_callable($postInterceptor) && !($postInterceptor instanceof PostInterceptor) && !class_exists((string) $postInterceptor)) { throw new \InvalidArgumentException( 'Given pre interceptor must be a callable, an instance of ' . PostInterceptor::class . ' or a class name of an existing post interceptor class' ); } $this->postInterceptors[] = $postInterceptor; return $this; }
[ "public", "function", "postIntercept", "(", "$", "postInterceptor", ")", ":", "ConfigurableRoute", "{", "if", "(", "!", "is_callable", "(", "$", "postInterceptor", ")", "&&", "!", "(", "$", "postInterceptor", "instanceof", "PostInterceptor", ")", "&&", "!", "class_exists", "(", "(", "string", ")", "$", "postInterceptor", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Given pre interceptor must be a callable, an instance of '", ".", "PostInterceptor", "::", "class", ".", "' or a class name of an existing post interceptor class'", ")", ";", "}", "$", "this", "->", "postInterceptors", "[", "]", "=", "$", "postInterceptor", ";", "return", "$", "this", ";", "}" ]
add a post interceptor for this route @param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor @return \stubbles\webapp\routing\Route @throws \InvalidArgumentException
[ "add", "a", "post", "interceptor", "for", "this", "route" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L257-L269
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.requiresHttps
public function requiresHttps(): bool { if ($this->requiresHttps) { return true; } $this->requiresHttps = $this->routingAnnotations()->requiresHttps(); return $this->requiresHttps; }
php
public function requiresHttps(): bool { if ($this->requiresHttps) { return true; } $this->requiresHttps = $this->routingAnnotations()->requiresHttps(); return $this->requiresHttps; }
[ "public", "function", "requiresHttps", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "requiresHttps", ")", "{", "return", "true", ";", "}", "$", "this", "->", "requiresHttps", "=", "$", "this", "->", "routingAnnotations", "(", ")", "->", "requiresHttps", "(", ")", ";", "return", "$", "this", "->", "requiresHttps", ";", "}" ]
whether route is only available via https @return bool
[ "whether", "route", "is", "only", "available", "via", "https" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L297-L305
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.authConstraint
public function authConstraint(): AuthConstraint { if (null === $this->authConstraint) { $this->authConstraint = new AuthConstraint($this->routingAnnotations()); } return $this->authConstraint; }
php
public function authConstraint(): AuthConstraint { if (null === $this->authConstraint) { $this->authConstraint = new AuthConstraint($this->routingAnnotations()); } return $this->authConstraint; }
[ "public", "function", "authConstraint", "(", ")", ":", "AuthConstraint", "{", "if", "(", "null", "===", "$", "this", "->", "authConstraint", ")", "{", "$", "this", "->", "authConstraint", "=", "new", "AuthConstraint", "(", "$", "this", "->", "routingAnnotations", "(", ")", ")", ";", "}", "return", "$", "this", "->", "authConstraint", ";", "}" ]
returns auth constraint for this route @return \stubbles\webapp\auth\AuthConstraint
[ "returns", "auth", "constraint", "for", "this", "route" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L363-L370
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.supportsMimeType
public function supportsMimeType(string $mimeType, string $class = null): ConfigurableRoute { if (null === $class && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) { throw new \InvalidArgumentException( 'No default class known for mime type ' . $mimeType . ', please provide a class' ); } $this->mimeTypes[] = $mimeType; if (null !== $class) { $this->mimeTypeClasses[$mimeType] = $class; } return $this; }
php
public function supportsMimeType(string $mimeType, string $class = null): ConfigurableRoute { if (null === $class && !SupportedMimeTypes::provideDefaultClassFor($mimeType)) { throw new \InvalidArgumentException( 'No default class known for mime type ' . $mimeType . ', please provide a class' ); } $this->mimeTypes[] = $mimeType; if (null !== $class) { $this->mimeTypeClasses[$mimeType] = $class; } return $this; }
[ "public", "function", "supportsMimeType", "(", "string", "$", "mimeType", ",", "string", "$", "class", "=", "null", ")", ":", "ConfigurableRoute", "{", "if", "(", "null", "===", "$", "class", "&&", "!", "SupportedMimeTypes", "::", "provideDefaultClassFor", "(", "$", "mimeType", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No default class known for mime type '", ".", "$", "mimeType", ".", "', please provide a class'", ")", ";", "}", "$", "this", "->", "mimeTypes", "[", "]", "=", "$", "mimeType", ";", "if", "(", "null", "!==", "$", "class", ")", "{", "$", "this", "->", "mimeTypeClasses", "[", "$", "mimeType", "]", "=", "$", "class", ";", "}", "return", "$", "this", ";", "}" ]
add a mime type which this route supports @param string $mimeType @param string $class optional special class to be used for given mime type on this route @return \stubbles\webapp\routing\Route @throws \InvalidArgumentException
[ "add", "a", "mime", "type", "which", "this", "route", "supports" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L380-L395
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.supportedMimeTypes
public function supportedMimeTypes( array $globalMimeTypes = [], array $globalClasses = [] ): SupportedMimeTypes { if ($this->disableContentNegotation || $this->routingAnnotations()->isContentNegotiationDisabled()) { return SupportedMimeTypes::createWithDisabledContentNegotation(); } return new SupportedMimeTypes( array_merge( $this->routingAnnotations()->mimeTypes(), $this->mimeTypes, $globalMimeTypes ), array_merge( $globalClasses, $this->routingAnnotations()->mimeTypeClasses(), $this->mimeTypeClasses ) ); }
php
public function supportedMimeTypes( array $globalMimeTypes = [], array $globalClasses = [] ): SupportedMimeTypes { if ($this->disableContentNegotation || $this->routingAnnotations()->isContentNegotiationDisabled()) { return SupportedMimeTypes::createWithDisabledContentNegotation(); } return new SupportedMimeTypes( array_merge( $this->routingAnnotations()->mimeTypes(), $this->mimeTypes, $globalMimeTypes ), array_merge( $globalClasses, $this->routingAnnotations()->mimeTypeClasses(), $this->mimeTypeClasses ) ); }
[ "public", "function", "supportedMimeTypes", "(", "array", "$", "globalMimeTypes", "=", "[", "]", ",", "array", "$", "globalClasses", "=", "[", "]", ")", ":", "SupportedMimeTypes", "{", "if", "(", "$", "this", "->", "disableContentNegotation", "||", "$", "this", "->", "routingAnnotations", "(", ")", "->", "isContentNegotiationDisabled", "(", ")", ")", "{", "return", "SupportedMimeTypes", "::", "createWithDisabledContentNegotation", "(", ")", ";", "}", "return", "new", "SupportedMimeTypes", "(", "array_merge", "(", "$", "this", "->", "routingAnnotations", "(", ")", "->", "mimeTypes", "(", ")", ",", "$", "this", "->", "mimeTypes", ",", "$", "globalMimeTypes", ")", ",", "array_merge", "(", "$", "globalClasses", ",", "$", "this", "->", "routingAnnotations", "(", ")", "->", "mimeTypeClasses", "(", ")", ",", "$", "this", "->", "mimeTypeClasses", ")", ")", ";", "}" ]
returns list of mime types supported by this route @param string[] $globalMimeTypes optional list of globally supported mime types @param string[] $globalClasses optional list of globally defined mime type classes @return \stubbles\webapp\routing\SupportedMimeTypes
[ "returns", "list", "of", "mime", "types", "supported", "by", "this", "route" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L404-L425
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.routingAnnotations
private function routingAnnotations(): RoutingAnnotations { if (null === $this->routingAnnotations) { $this->routingAnnotations = new RoutingAnnotations($this->target); } return $this->routingAnnotations; }
php
private function routingAnnotations(): RoutingAnnotations { if (null === $this->routingAnnotations) { $this->routingAnnotations = new RoutingAnnotations($this->target); } return $this->routingAnnotations; }
[ "private", "function", "routingAnnotations", "(", ")", ":", "RoutingAnnotations", "{", "if", "(", "null", "===", "$", "this", "->", "routingAnnotations", ")", "{", "$", "this", "->", "routingAnnotations", "=", "new", "RoutingAnnotations", "(", "$", "this", "->", "target", ")", ";", "}", "return", "$", "this", "->", "routingAnnotations", ";", "}" ]
returns list of callback annotations @return \stubbles\webapp\routing\RoutingAnnotations
[ "returns", "list", "of", "callback", "annotations" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L444-L451
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.asResource
public function asResource(HttpUri $uri, array $globalMimeTypes = []): Resource { $routeUri = $uri->withPath($this->normalizePath()); return new Resource( $this->resourceName(), $this->allowedRequestMethods, $this->requiresHttps() ? $routeUri->toHttps() : $routeUri, $this->supportedMimeTypes($globalMimeTypes)->asArray(), $this->routingAnnotations(), $this->authConstraint() ); }
php
public function asResource(HttpUri $uri, array $globalMimeTypes = []): Resource { $routeUri = $uri->withPath($this->normalizePath()); return new Resource( $this->resourceName(), $this->allowedRequestMethods, $this->requiresHttps() ? $routeUri->toHttps() : $routeUri, $this->supportedMimeTypes($globalMimeTypes)->asArray(), $this->routingAnnotations(), $this->authConstraint() ); }
[ "public", "function", "asResource", "(", "HttpUri", "$", "uri", ",", "array", "$", "globalMimeTypes", "=", "[", "]", ")", ":", "Resource", "{", "$", "routeUri", "=", "$", "uri", "->", "withPath", "(", "$", "this", "->", "normalizePath", "(", ")", ")", ";", "return", "new", "Resource", "(", "$", "this", "->", "resourceName", "(", ")", ",", "$", "this", "->", "allowedRequestMethods", ",", "$", "this", "->", "requiresHttps", "(", ")", "?", "$", "routeUri", "->", "toHttps", "(", ")", ":", "$", "routeUri", ",", "$", "this", "->", "supportedMimeTypes", "(", "$", "globalMimeTypes", ")", "->", "asArray", "(", ")", ",", "$", "this", "->", "routingAnnotations", "(", ")", ",", "$", "this", "->", "authConstraint", "(", ")", ")", ";", "}" ]
returns route as resource @param \stubbles\peer\http\HttpUri $uri @param string[] $globalMimeTypes list of globally supported mime types @return \stubbles\webapp\routing\api\Resource @since 6.1.0
[ "returns", "route", "as", "resource" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L488-L499
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.normalizePath
private function normalizePath(): string { $path = $this->path; if (substr($path, -1) === '$') { $path = substr($path, 0, strlen($path) - 1); } if (substr($path, -1) === '?') { $path = substr($path, 0, strlen($path) - 1); } return $path; }
php
private function normalizePath(): string { $path = $this->path; if (substr($path, -1) === '$') { $path = substr($path, 0, strlen($path) - 1); } if (substr($path, -1) === '?') { $path = substr($path, 0, strlen($path) - 1); } return $path; }
[ "private", "function", "normalizePath", "(", ")", ":", "string", "{", "$", "path", "=", "$", "this", "->", "path", ";", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "===", "'$'", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "0", ",", "strlen", "(", "$", "path", ")", "-", "1", ")", ";", "}", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "===", "'?'", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "0", ",", "strlen", "(", "$", "path", ")", "-", "1", ")", ";", "}", "return", "$", "path", ";", "}" ]
normalizes path for better understanding @return string
[ "normalizes", "path", "for", "better", "understanding" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L506-L518
stubbles/stubbles-webapp-core
src/main/php/routing/Route.php
Route.resourceName
private function resourceName() { if ($this->routingAnnotations()->hasName()) { return $this->routingAnnotations()->name(); } if (is_string($this->target) && class_exists($this->target)) { return substr( $this->target, strrpos($this->target, '\\') + 1 ); } elseif (!is_callable($this->target) && is_object($this->target)) { return substr( get_class($this->target), strrpos(get_class($this->target), '\\') + 1 ); } return null; }
php
private function resourceName() { if ($this->routingAnnotations()->hasName()) { return $this->routingAnnotations()->name(); } if (is_string($this->target) && class_exists($this->target)) { return substr( $this->target, strrpos($this->target, '\\') + 1 ); } elseif (!is_callable($this->target) && is_object($this->target)) { return substr( get_class($this->target), strrpos(get_class($this->target), '\\') + 1 ); } return null; }
[ "private", "function", "resourceName", "(", ")", "{", "if", "(", "$", "this", "->", "routingAnnotations", "(", ")", "->", "hasName", "(", ")", ")", "{", "return", "$", "this", "->", "routingAnnotations", "(", ")", "->", "name", "(", ")", ";", "}", "if", "(", "is_string", "(", "$", "this", "->", "target", ")", "&&", "class_exists", "(", "$", "this", "->", "target", ")", ")", "{", "return", "substr", "(", "$", "this", "->", "target", ",", "strrpos", "(", "$", "this", "->", "target", ",", "'\\\\'", ")", "+", "1", ")", ";", "}", "elseif", "(", "!", "is_callable", "(", "$", "this", "->", "target", ")", "&&", "is_object", "(", "$", "this", "->", "target", ")", ")", "{", "return", "substr", "(", "get_class", "(", "$", "this", "->", "target", ")", ",", "strrpos", "(", "get_class", "(", "$", "this", "->", "target", ")", ",", "'\\\\'", ")", "+", "1", ")", ";", "}", "return", "null", ";", "}" ]
returns useful name for resource @return string|null
[ "returns", "useful", "name", "for", "resource" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Route.php#L525-L544
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.getSimpleXMLElement
private function getSimpleXMLElement($elem) { if (gettype($elem) == 'string') { return $this->initFromString($elem); } if (gettype($elem) == 'object') { return $this->initFromObject($elem); } }
php
private function getSimpleXMLElement($elem) { if (gettype($elem) == 'string') { return $this->initFromString($elem); } if (gettype($elem) == 'object') { return $this->initFromObject($elem); } }
[ "private", "function", "getSimpleXMLElement", "(", "$", "elem", ")", "{", "if", "(", "gettype", "(", "$", "elem", ")", "==", "'string'", ")", "{", "return", "$", "this", "->", "initFromString", "(", "$", "elem", ")", ";", "}", "if", "(", "gettype", "(", "$", "elem", ")", "==", "'object'", ")", "{", "return", "$", "this", "->", "initFromObject", "(", "$", "elem", ")", ";", "}", "}" ]
Internal helper method to get a SimpleXMLElement from either a string or a SimpleXMLElement/QuiteSimpleXMLElement object. @param string|SimpleXMLElement|QuiteSimpleXMLElement $elem @return SimpleXMLElement @throws InvalidXMLException @throws InvalidArgumentException
[ "Internal", "helper", "method", "to", "get", "a", "SimpleXMLElement", "from", "either", "a", "string", "or", "a", "SimpleXMLElement", "/", "QuiteSimpleXMLElement", "object", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L98-L107
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.registerXPathNamespace
public function registerXPathNamespace($prefix, $uri) { $this->el->registerXPathNamespace($prefix, $uri); $this->namespaces[$prefix] = $uri; }
php
public function registerXPathNamespace($prefix, $uri) { $this->el->registerXPathNamespace($prefix, $uri); $this->namespaces[$prefix] = $uri; }
[ "public", "function", "registerXPathNamespace", "(", "$", "prefix", ",", "$", "uri", ")", "{", "$", "this", "->", "el", "->", "registerXPathNamespace", "(", "$", "prefix", ",", "$", "uri", ")", ";", "$", "this", "->", "namespaces", "[", "$", "prefix", "]", "=", "$", "uri", ";", "}" ]
Register a new xpath namespace. @param string $prefix @param string $uri
[ "Register", "a", "new", "xpath", "namespace", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L146-L150
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.registerXPathNamespaces
public function registerXPathNamespaces($namespaces) { // Convenience method to add multiple namespaces at once foreach ($namespaces as $prefix => $uri) { $this->registerXPathNamespace($prefix, $uri); } }
php
public function registerXPathNamespaces($namespaces) { // Convenience method to add multiple namespaces at once foreach ($namespaces as $prefix => $uri) { $this->registerXPathNamespace($prefix, $uri); } }
[ "public", "function", "registerXPathNamespaces", "(", "$", "namespaces", ")", "{", "// Convenience method to add multiple namespaces at once", "foreach", "(", "$", "namespaces", "as", "$", "prefix", "=>", "$", "uri", ")", "{", "$", "this", "->", "registerXPathNamespace", "(", "$", "prefix", ",", "$", "uri", ")", ";", "}", "}" ]
Register an array of new xpath namespaces. @param array $namespaces
[ "Register", "an", "array", "of", "new", "xpath", "namespaces", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L157-L163
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.children
public function children($ns = null) { $ch = is_null($ns) ? $this->el->children() : $this->el->children($this->namespaces[$ns]); $o = []; foreach ($ch as $c) { $o[] = new static($c, $this); } return $o; }
php
public function children($ns = null) { $ch = is_null($ns) ? $this->el->children() : $this->el->children($this->namespaces[$ns]); $o = []; foreach ($ch as $c) { $o[] = new static($c, $this); } return $o; }
[ "public", "function", "children", "(", "$", "ns", "=", "null", ")", "{", "$", "ch", "=", "is_null", "(", "$", "ns", ")", "?", "$", "this", "->", "el", "->", "children", "(", ")", ":", "$", "this", "->", "el", "->", "children", "(", "$", "this", "->", "namespaces", "[", "$", "ns", "]", ")", ";", "$", "o", "=", "[", "]", ";", "foreach", "(", "$", "ch", "as", "$", "c", ")", "{", "$", "o", "[", "]", "=", "new", "static", "(", "$", "c", ",", "$", "this", ")", ";", "}", "return", "$", "o", ";", "}" ]
Returns child elements. Note: By default, only children without namespace will be returned! You can specify a namespace prefix to get children with that namespace prefix. If you want all child elements, namespaced or not, use `$record->all('child::*')` instead. @param string $ns @return QuiteSimpleXMLElement[]
[ "Returns", "child", "elements", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L196-L208
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.attributes
public function attributes($ns = null, $is_prefix = false) { return $this->el->attributes($ns, $is_prefix); }
php
public function attributes($ns = null, $is_prefix = false) { return $this->el->attributes($ns, $is_prefix); }
[ "public", "function", "attributes", "(", "$", "ns", "=", "null", ",", "$", "is_prefix", "=", "false", ")", "{", "return", "$", "this", "->", "el", "->", "attributes", "(", "$", "ns", ",", "$", "is_prefix", ")", ";", "}" ]
Returns and element's attributes. @param string $ns @param bool $is_prefix @return SimpleXMLElement a `SimpleXMLElement` object that can be iterated over to loop through the attributes on the tag.
[ "Returns", "and", "element", "s", "attributes", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L235-L238
danmichaelo/quitesimplexmlelement
src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php
SimpleXMLElementWrapper.replace
public function replace(QuiteSimpleXMLElement $element) { $oldNode = $this->asDOMElement(); $newNode = $oldNode->ownerDocument->importNode( $element->asDOMElement(), true ); $oldNode->parentNode->replaceChild($newNode, $oldNode); }
php
public function replace(QuiteSimpleXMLElement $element) { $oldNode = $this->asDOMElement(); $newNode = $oldNode->ownerDocument->importNode( $element->asDOMElement(), true ); $oldNode->parentNode->replaceChild($newNode, $oldNode); }
[ "public", "function", "replace", "(", "QuiteSimpleXMLElement", "$", "element", ")", "{", "$", "oldNode", "=", "$", "this", "->", "asDOMElement", "(", ")", ";", "$", "newNode", "=", "$", "oldNode", "->", "ownerDocument", "->", "importNode", "(", "$", "element", "->", "asDOMElement", "(", ")", ",", "true", ")", ";", "$", "oldNode", "->", "parentNode", "->", "replaceChild", "(", "$", "newNode", ",", "$", "oldNode", ")", ";", "}" ]
Replaces the current node. Thanks to @hakre <http://stackoverflow.com/questions/17661167/how-to-replace-xml-node-with-simplexmlelement-php>. @param QuiteSimpleXMLElement $element
[ "Replaces", "the", "current", "node", ".", "Thanks", "to", "@hakre", "<http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "17661167", "/", "how", "-", "to", "-", "replace", "-", "xml", "-", "node", "-", "with", "-", "simplexmlelement", "-", "php", ">", "." ]
train
https://github.com/danmichaelo/quitesimplexmlelement/blob/566261ac5a789d63fda4ffc328501213772c1b27/src/Danmichaelo/QuiteSimpleXMLElement/SimpleXMLElementWrapper.php#L296-L304
pageon/SlackWebhookMonolog
src/Monolog/SlackWebhookHandler.php
SlackWebhookHandler.write
public function write(array $record) { $curlUtil = $this->curlUtil; $curlSession = curl_init(); curl_setopt($curlSession, CURLOPT_URL, $this->slackConfig->getWebhook()); curl_setopt($curlSession, CURLOPT_POST, true); curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlSession, CURLOPT_POSTFIELDS, $this->getPayload($record)); // we return this because our mock will return the curl session return $curlUtil::execute($curlSession); }
php
public function write(array $record) { $curlUtil = $this->curlUtil; $curlSession = curl_init(); curl_setopt($curlSession, CURLOPT_URL, $this->slackConfig->getWebhook()); curl_setopt($curlSession, CURLOPT_POST, true); curl_setopt($curlSession, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlSession, CURLOPT_POSTFIELDS, $this->getPayload($record)); // we return this because our mock will return the curl session return $curlUtil::execute($curlSession); }
[ "public", "function", "write", "(", "array", "$", "record", ")", "{", "$", "curlUtil", "=", "$", "this", "->", "curlUtil", ";", "$", "curlSession", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "curlSession", ",", "CURLOPT_URL", ",", "$", "this", "->", "slackConfig", "->", "getWebhook", "(", ")", ")", ";", "curl_setopt", "(", "$", "curlSession", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "curlSession", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curlSession", ",", "CURLOPT_POSTFIELDS", ",", "$", "this", "->", "getPayload", "(", "$", "record", ")", ")", ";", "// we return this because our mock will return the curl session", "return", "$", "curlUtil", "::", "execute", "(", "$", "curlSession", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Monolog/SlackWebhookHandler.php#L54-L66
phramework/jsonapi
src/Controller/DELETE.php
DELETE.handleDELETE
protected static function handleDELETE( $parameters, $method, $headers, $id, $modelClass, $primaryDataParameters = [], $validationCallbacks = [], $viewCallback = null ) { if ($viewCallback !== null && !is_callable($viewCallback)) { throw new ServerException('View callback is not callable!'); } //Fetch data, in order to check if resource exists (and/or is accessible) $resource = $modelClass::getById( $id, null, //fields ...$primaryDataParameters ); //Check if resource exists static::exists($resource); //Call validation callbacks if set foreach ($validationCallbacks as $callback) { call_user_func( $callback, $id, $resource ); } $delete = $modelClass::delete($id, $primaryDataParameters); if (!$delete) { throw new RequestException( 'Unable to delete record' ); } if ($viewCallback !== null) { return call_user_func( $viewCallback, $id ); } \Phramework\JSONAPI\Viewers\JSONAPI::header(); \Phramework\Models\Response::noContent(); return true; }
php
protected static function handleDELETE( $parameters, $method, $headers, $id, $modelClass, $primaryDataParameters = [], $validationCallbacks = [], $viewCallback = null ) { if ($viewCallback !== null && !is_callable($viewCallback)) { throw new ServerException('View callback is not callable!'); } //Fetch data, in order to check if resource exists (and/or is accessible) $resource = $modelClass::getById( $id, null, //fields ...$primaryDataParameters ); //Check if resource exists static::exists($resource); //Call validation callbacks if set foreach ($validationCallbacks as $callback) { call_user_func( $callback, $id, $resource ); } $delete = $modelClass::delete($id, $primaryDataParameters); if (!$delete) { throw new RequestException( 'Unable to delete record' ); } if ($viewCallback !== null) { return call_user_func( $viewCallback, $id ); } \Phramework\JSONAPI\Viewers\JSONAPI::header(); \Phramework\Models\Response::noContent(); return true; }
[ "protected", "static", "function", "handleDELETE", "(", "$", "parameters", ",", "$", "method", ",", "$", "headers", ",", "$", "id", ",", "$", "modelClass", ",", "$", "primaryDataParameters", "=", "[", "]", ",", "$", "validationCallbacks", "=", "[", "]", ",", "$", "viewCallback", "=", "null", ")", "{", "if", "(", "$", "viewCallback", "!==", "null", "&&", "!", "is_callable", "(", "$", "viewCallback", ")", ")", "{", "throw", "new", "ServerException", "(", "'View callback is not callable!'", ")", ";", "}", "//Fetch data, in order to check if resource exists (and/or is accessible)", "$", "resource", "=", "$", "modelClass", "::", "getById", "(", "$", "id", ",", "null", ",", "//fields", "...", "$", "primaryDataParameters", ")", ";", "//Check if resource exists", "static", "::", "exists", "(", "$", "resource", ")", ";", "//Call validation callbacks if set", "foreach", "(", "$", "validationCallbacks", "as", "$", "callback", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "id", ",", "$", "resource", ")", ";", "}", "$", "delete", "=", "$", "modelClass", "::", "delete", "(", "$", "id", ",", "$", "primaryDataParameters", ")", ";", "if", "(", "!", "$", "delete", ")", "{", "throw", "new", "RequestException", "(", "'Unable to delete record'", ")", ";", "}", "if", "(", "$", "viewCallback", "!==", "null", ")", "{", "return", "call_user_func", "(", "$", "viewCallback", ",", "$", "id", ")", ";", "}", "\\", "Phramework", "\\", "JSONAPI", "\\", "Viewers", "\\", "JSONAPI", "::", "header", "(", ")", ";", "\\", "Phramework", "\\", "Models", "\\", "Response", "::", "noContent", "(", ")", ";", "return", "true", ";", "}" ]
Handle DELETE method On success will respond with 204 No Content @param object $parameters Request parameters @param string $method Request method @param array $headers Request headers @param integer|string $id Requested resource's id @param string $modelClass Resource's primary model to be used @param array $primaryDataParameters [Optional] Array with any additional arguments that the primary data is requiring @throws \Phramework\Exceptions\NotFound If resource not found @throws \Phramework\Exceptions\RequestException If unable to delete @uses model's `getById` method to fetch resource @uses $modelClass::delete method to delete resources @return bool
[ "Handle", "DELETE", "method", "On", "success", "will", "respond", "with", "204", "No", "Content" ]
train
https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/DELETE.php#L49-L102
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.getConfigByName
static function getConfigByName($namespace, $name) { $info = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->first(); if (!empty($info)) { return $info; } return array(); }
php
static function getConfigByName($namespace, $name) { $info = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->first(); if (!empty($info)) { return $info; } return array(); }
[ "static", "function", "getConfigByName", "(", "$", "namespace", ",", "$", "name", ")", "{", "$", "info", "=", "CommonConfigModel", "::", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "where", "(", "'name'", ",", "$", "name", ")", "->", "first", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "info", ")", ")", "{", "return", "$", "info", ";", "}", "return", "array", "(", ")", ";", "}" ]
获取某个配置 ok @param string $namespace @param string $name @return array
[ "获取某个配置", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L43-L52
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.storeConfigs
static function storeConfigs($data) { foreach ($data as $value) { $value['issystem'] = isset($value['issystem']) && $value['issystem'] ? intval($value['issystem']) : 0 ; $value['desc'] = isset($value['desc']) && $value['desc'] ? $value['desc'] : '' ; $value['value'] = isset($value['value']) && $value['value'] ? $value['value'] : ''; self::storeConfig($value['namespace'], $value['name'], $value['value'], $value['issystem'], $value['desc']); } return true; }
php
static function storeConfigs($data) { foreach ($data as $value) { $value['issystem'] = isset($value['issystem']) && $value['issystem'] ? intval($value['issystem']) : 0 ; $value['desc'] = isset($value['desc']) && $value['desc'] ? $value['desc'] : '' ; $value['value'] = isset($value['value']) && $value['value'] ? $value['value'] : ''; self::storeConfig($value['namespace'], $value['name'], $value['value'], $value['issystem'], $value['desc']); } return true; }
[ "static", "function", "storeConfigs", "(", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "value", ")", "{", "$", "value", "[", "'issystem'", "]", "=", "isset", "(", "$", "value", "[", "'issystem'", "]", ")", "&&", "$", "value", "[", "'issystem'", "]", "?", "intval", "(", "$", "value", "[", "'issystem'", "]", ")", ":", "0", ";", "$", "value", "[", "'desc'", "]", "=", "isset", "(", "$", "value", "[", "'desc'", "]", ")", "&&", "$", "value", "[", "'desc'", "]", "?", "$", "value", "[", "'desc'", "]", ":", "''", ";", "$", "value", "[", "'value'", "]", "=", "isset", "(", "$", "value", "[", "'value'", "]", ")", "&&", "$", "value", "[", "'value'", "]", "?", "$", "value", "[", "'value'", "]", ":", "''", ";", "self", "::", "storeConfig", "(", "$", "value", "[", "'namespace'", "]", ",", "$", "value", "[", "'name'", "]", ",", "$", "value", "[", "'value'", "]", ",", "$", "value", "[", "'issystem'", "]", ",", "$", "value", "[", "'desc'", "]", ")", ";", "}", "return", "true", ";", "}" ]
批量设置配置项 ok @param array $data 待设置的配置项 @return boolean
[ "批量设置配置项", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L60-L69
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.storeConfig
static function storeConfig($namespace, $name, $value = '', $issystem = 0, $desc = null) { $array = []; list($array['vtype'], $array['value']) = self::_toString($value); $array['desc'] = isset($desc) && $desc ? $desc : '' ; isset($issystem) && $array['issystem'] = $issystem; if (self::getConfigByName($namespace, $name)) { $result = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->update($array); } else { $array['name'] = $name; $array['namespace'] = $namespace; $result = CommonConfigModel::insert($array); } self::setCache($namespace); return $result; }
php
static function storeConfig($namespace, $name, $value = '', $issystem = 0, $desc = null) { $array = []; list($array['vtype'], $array['value']) = self::_toString($value); $array['desc'] = isset($desc) && $desc ? $desc : '' ; isset($issystem) && $array['issystem'] = $issystem; if (self::getConfigByName($namespace, $name)) { $result = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->update($array); } else { $array['name'] = $name; $array['namespace'] = $namespace; $result = CommonConfigModel::insert($array); } self::setCache($namespace); return $result; }
[ "static", "function", "storeConfig", "(", "$", "namespace", ",", "$", "name", ",", "$", "value", "=", "''", ",", "$", "issystem", "=", "0", ",", "$", "desc", "=", "null", ")", "{", "$", "array", "=", "[", "]", ";", "list", "(", "$", "array", "[", "'vtype'", "]", ",", "$", "array", "[", "'value'", "]", ")", "=", "self", "::", "_toString", "(", "$", "value", ")", ";", "$", "array", "[", "'desc'", "]", "=", "isset", "(", "$", "desc", ")", "&&", "$", "desc", "?", "$", "desc", ":", "''", ";", "isset", "(", "$", "issystem", ")", "&&", "$", "array", "[", "'issystem'", "]", "=", "$", "issystem", ";", "if", "(", "self", "::", "getConfigByName", "(", "$", "namespace", ",", "$", "name", ")", ")", "{", "$", "result", "=", "CommonConfigModel", "::", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "where", "(", "'name'", ",", "$", "name", ")", "->", "update", "(", "$", "array", ")", ";", "}", "else", "{", "$", "array", "[", "'name'", "]", "=", "$", "name", ";", "$", "array", "[", "'namespace'", "]", "=", "$", "namespace", ";", "$", "result", "=", "CommonConfigModel", "::", "insert", "(", "$", "array", ")", ";", "}", "self", "::", "setCache", "(", "$", "namespace", ")", ";", "return", "$", "result", ";", "}" ]
存储配置项 ok @param string $namespace 配置项命名空间 @param string $name 配置项名 @param mixed $value 配置项的值 @param string $issystem 是否为系统 @param string $desc 配置项描述 @return boolean
[ "存储配置项", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L81-L98
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.deleteConfig
static function deleteConfig($namespace) { $result = CommonConfigModel::where('namespace', $namespace)->delete(); $cacheName = 'config:'.$namespace; Cache::forget($cacheName); return $result; }
php
static function deleteConfig($namespace) { $result = CommonConfigModel::where('namespace', $namespace)->delete(); $cacheName = 'config:'.$namespace; Cache::forget($cacheName); return $result; }
[ "static", "function", "deleteConfig", "(", "$", "namespace", ")", "{", "$", "result", "=", "CommonConfigModel", "::", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "delete", "(", ")", ";", "$", "cacheName", "=", "'config:'", ".", "$", "namespace", ";", "Cache", "::", "forget", "(", "$", "cacheName", ")", ";", "return", "$", "result", ";", "}" ]
删除配置项 @param string $namespace 配置项所属空间 @return boolean
[ "删除配置项" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L106-L112
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.deleteConfigByName
static function deleteConfigByName($namespace, $name) { $result = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->delete(); self::setCache($namespace); return $result; }
php
static function deleteConfigByName($namespace, $name) { $result = CommonConfigModel::where('namespace', $namespace) ->where('name', $name) ->delete(); self::setCache($namespace); return $result; }
[ "static", "function", "deleteConfigByName", "(", "$", "namespace", ",", "$", "name", ")", "{", "$", "result", "=", "CommonConfigModel", "::", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "where", "(", "'name'", ",", "$", "name", ")", "->", "delete", "(", ")", ";", "self", "::", "setCache", "(", "$", "namespace", ")", ";", "return", "$", "result", ";", "}" ]
删除配置项 ok @param string $namespace 配置项所属空间 @param string $name 配置项名字 @return boolean
[ "删除配置项", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L121-L128
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel._toString
static function _toString($value) { $vtype = 'string'; if (is_array($value)) { $value = serialize($value); $vtype = 'array'; } elseif (is_object($value)) { $value = serialize($value); $vtype = 'object'; } return array($vtype, $value); }
php
static function _toString($value) { $vtype = 'string'; if (is_array($value)) { $value = serialize($value); $vtype = 'array'; } elseif (is_object($value)) { $value = serialize($value); $vtype = 'object'; } return array($vtype, $value); }
[ "static", "function", "_toString", "(", "$", "value", ")", "{", "$", "vtype", "=", "'string'", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "serialize", "(", "$", "value", ")", ";", "$", "vtype", "=", "'array'", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "serialize", "(", "$", "value", ")", ";", "$", "vtype", "=", "'object'", ";", "}", "return", "array", "(", "$", "vtype", ",", "$", "value", ")", ";", "}" ]
将数据转换为字符串 ok @param mixed $value 待处理的数据 @return array 返回处理后的数据,第一个代表该数据的类型,第二个代表该数据处理后的数据串
[ "将数据转换为字符串", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L136-L147
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel._getInfo
static function _getInfo($vtype, $value) { $val = $value; if($vtype =='array' || $vtype == 'object') { $val = unserialize($value); } return $val; }
php
static function _getInfo($vtype, $value) { $val = $value; if($vtype =='array' || $vtype == 'object') { $val = unserialize($value); } return $val; }
[ "static", "function", "_getInfo", "(", "$", "vtype", ",", "$", "value", ")", "{", "$", "val", "=", "$", "value", ";", "if", "(", "$", "vtype", "==", "'array'", "||", "$", "vtype", "==", "'object'", ")", "{", "$", "val", "=", "unserialize", "(", "$", "value", ")", ";", "}", "return", "$", "val", ";", "}" ]
将字符串转为数据 ok @param string $vtype 数据类型 @param mixed $value 待处理的数据 @return array|string 返回处理后的数据
[ "将字符串转为数据", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L156-L163
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.setCache
static function setCache($namespace) { $cacheData = []; $data = CommonConfigModel::getConfigByNamespace($namespace); foreach ($data as $key => $value) { $cacheData[$value['name']] = [ 'value'=>self::_getInfo($value['vtype'], $value['value']), 'issystem'=>$value['issystem'], 'desc'=>$value['desc'] ]; } $cacheName = 'config:'.$namespace; Cache::forever($cacheName, $cacheData); return $cacheData; }
php
static function setCache($namespace) { $cacheData = []; $data = CommonConfigModel::getConfigByNamespace($namespace); foreach ($data as $key => $value) { $cacheData[$value['name']] = [ 'value'=>self::_getInfo($value['vtype'], $value['value']), 'issystem'=>$value['issystem'], 'desc'=>$value['desc'] ]; } $cacheName = 'config:'.$namespace; Cache::forever($cacheName, $cacheData); return $cacheData; }
[ "static", "function", "setCache", "(", "$", "namespace", ")", "{", "$", "cacheData", "=", "[", "]", ";", "$", "data", "=", "CommonConfigModel", "::", "getConfigByNamespace", "(", "$", "namespace", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "cacheData", "[", "$", "value", "[", "'name'", "]", "]", "=", "[", "'value'", "=>", "self", "::", "_getInfo", "(", "$", "value", "[", "'vtype'", "]", ",", "$", "value", "[", "'value'", "]", ")", ",", "'issystem'", "=>", "$", "value", "[", "'issystem'", "]", ",", "'desc'", "=>", "$", "value", "[", "'desc'", "]", "]", ";", "}", "$", "cacheName", "=", "'config:'", ".", "$", "namespace", ";", "Cache", "::", "forever", "(", "$", "cacheName", ",", "$", "cacheData", ")", ";", "return", "$", "cacheData", ";", "}" ]
设置数据缓存 ok @param string $namespace @return array 返回处理后的数据
[ "设置数据缓存", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L171-L185
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.setAllCache
static function setAllCache() { $list = CommonConfigModel::select('namespace')->get(); if($list) { foreach ($list as $key => $value) { self::setCache($value['namespace']); } } return true; }
php
static function setAllCache() { $list = CommonConfigModel::select('namespace')->get(); if($list) { foreach ($list as $key => $value) { self::setCache($value['namespace']); } } return true; }
[ "static", "function", "setAllCache", "(", ")", "{", "$", "list", "=", "CommonConfigModel", "::", "select", "(", "'namespace'", ")", "->", "get", "(", ")", ";", "if", "(", "$", "list", ")", "{", "foreach", "(", "$", "list", "as", "$", "key", "=>", "$", "value", ")", "{", "self", "::", "setCache", "(", "$", "value", "[", "'namespace'", "]", ")", ";", "}", "}", "return", "true", ";", "}" ]
更新全部缓存 ok
[ "更新全部缓存", "ok" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L190-L199
huasituo/hstcms
src/Model/CommonConfigModel.php
CommonConfigModel.get
static function get($namespace, $name = null, $isall = false) { $cacheName = 'config:'.$namespace; if (!Cache::has($cacheName)) { $data = self::setCache($namespace); } else { $data = Cache::get($cacheName, []); if($name) { if(!$isall) return isset($data[$name]['value']) ? $data[$name]['value'] : null; return isset($data[$name]) ? $data[$name] : []; } } if(!$isall) { $rdata = array(); foreach ($data as $key => $value) { $rdata[$key] = $value['value']; } return $rdata; } return $data; }
php
static function get($namespace, $name = null, $isall = false) { $cacheName = 'config:'.$namespace; if (!Cache::has($cacheName)) { $data = self::setCache($namespace); } else { $data = Cache::get($cacheName, []); if($name) { if(!$isall) return isset($data[$name]['value']) ? $data[$name]['value'] : null; return isset($data[$name]) ? $data[$name] : []; } } if(!$isall) { $rdata = array(); foreach ($data as $key => $value) { $rdata[$key] = $value['value']; } return $rdata; } return $data; }
[ "static", "function", "get", "(", "$", "namespace", ",", "$", "name", "=", "null", ",", "$", "isall", "=", "false", ")", "{", "$", "cacheName", "=", "'config:'", ".", "$", "namespace", ";", "if", "(", "!", "Cache", "::", "has", "(", "$", "cacheName", ")", ")", "{", "$", "data", "=", "self", "::", "setCache", "(", "$", "namespace", ")", ";", "}", "else", "{", "$", "data", "=", "Cache", "::", "get", "(", "$", "cacheName", ",", "[", "]", ")", ";", "if", "(", "$", "name", ")", "{", "if", "(", "!", "$", "isall", ")", "return", "isset", "(", "$", "data", "[", "$", "name", "]", "[", "'value'", "]", ")", "?", "$", "data", "[", "$", "name", "]", "[", "'value'", "]", ":", "null", ";", "return", "isset", "(", "$", "data", "[", "$", "name", "]", ")", "?", "$", "data", "[", "$", "name", "]", ":", "[", "]", ";", "}", "}", "if", "(", "!", "$", "isall", ")", "{", "$", "rdata", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "rdata", "[", "$", "key", "]", "=", "$", "value", "[", "'value'", "]", ";", "}", "return", "$", "rdata", ";", "}", "return", "$", "data", ";", "}" ]
======================================================================================================================
[ "======================================================================================================================" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Model/CommonConfigModel.php#L203-L223
dantleech/glob
lib/DTL/Glob/Finder/PhpcrOdmTraversalFinder.php
PhpcrOdmTraversalFinder.getNode
protected function getNode(array $pathSegments) { $absPath = '/' . implode('/', $pathSegments); return $this->getManager()->find(null, $absPath); }
php
protected function getNode(array $pathSegments) { $absPath = '/' . implode('/', $pathSegments); return $this->getManager()->find(null, $absPath); }
[ "protected", "function", "getNode", "(", "array", "$", "pathSegments", ")", "{", "$", "absPath", "=", "'/'", ".", "implode", "(", "'/'", ",", "$", "pathSegments", ")", ";", "return", "$", "this", "->", "getManager", "(", ")", "->", "find", "(", "null", ",", "$", "absPath", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/Finder/PhpcrOdmTraversalFinder.php#L47-L51
fuelphp/display
src/Parser/Mustache.php
Mustache.setupMustache
public function setupMustache() { $mustacheLoader = new MustacheLoader($this->viewManager); $config = ['loader' => $mustacheLoader]; if ($this->viewManager->cachePath) { $config['cache'] = $this->viewManager->cachePath.'mustache/'; } $this->mustache = new Mustache_Engine($config); }
php
public function setupMustache() { $mustacheLoader = new MustacheLoader($this->viewManager); $config = ['loader' => $mustacheLoader]; if ($this->viewManager->cachePath) { $config['cache'] = $this->viewManager->cachePath.'mustache/'; } $this->mustache = new Mustache_Engine($config); }
[ "public", "function", "setupMustache", "(", ")", "{", "$", "mustacheLoader", "=", "new", "MustacheLoader", "(", "$", "this", "->", "viewManager", ")", ";", "$", "config", "=", "[", "'loader'", "=>", "$", "mustacheLoader", "]", ";", "if", "(", "$", "this", "->", "viewManager", "->", "cachePath", ")", "{", "$", "config", "[", "'cache'", "]", "=", "$", "this", "->", "viewManager", "->", "cachePath", ".", "'mustache/'", ";", "}", "$", "this", "->", "mustache", "=", "new", "Mustache_Engine", "(", "$", "config", ")", ";", "}" ]
Sets up Mustache_Engine
[ "Sets", "up", "Mustache_Engine" ]
train
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/Parser/Mustache.php#L51-L62
fuelphp/display
src/Parser/Mustache.php
Mustache.parse
public function parse($file, array $data = []) { $mustache = $this->getMustache(); return $mustache->render($file, $data); }
php
public function parse($file, array $data = []) { $mustache = $this->getMustache(); return $mustache->render($file, $data); }
[ "public", "function", "parse", "(", "$", "file", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "mustache", "=", "$", "this", "->", "getMustache", "(", ")", ";", "return", "$", "mustache", "->", "render", "(", "$", "file", ",", "$", "data", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fuelphp/display/blob/d9a3eddbf80f0fd81beb40d9f4507600ac6611a4/src/Parser/Mustache.php#L67-L72
php-ddd/command
src/Handler/Locator/CommandHandlerLocator.php
CommandHandlerLocator.getCommandHandlerForCommand
public function getCommandHandlerForCommand(CommandInterface $command) { $commandClassName = get_class($command); if (!$this->isCommandRegistered($commandClassName)) { throw new NoCommandHandlerRegisteredException( sprintf( 'No handler registered to handle command "%s".', $commandClassName ) ); } return $this->handlers[strtolower($commandClassName)]; }
php
public function getCommandHandlerForCommand(CommandInterface $command) { $commandClassName = get_class($command); if (!$this->isCommandRegistered($commandClassName)) { throw new NoCommandHandlerRegisteredException( sprintf( 'No handler registered to handle command "%s".', $commandClassName ) ); } return $this->handlers[strtolower($commandClassName)]; }
[ "public", "function", "getCommandHandlerForCommand", "(", "CommandInterface", "$", "command", ")", "{", "$", "commandClassName", "=", "get_class", "(", "$", "command", ")", ";", "if", "(", "!", "$", "this", "->", "isCommandRegistered", "(", "$", "commandClassName", ")", ")", "{", "throw", "new", "NoCommandHandlerRegisteredException", "(", "sprintf", "(", "'No handler registered to handle command \"%s\".'", ",", "$", "commandClassName", ")", ")", ";", "}", "return", "$", "this", "->", "handlers", "[", "strtolower", "(", "$", "commandClassName", ")", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/Locator/CommandHandlerLocator.php#L24-L38
php-ddd/command
src/Handler/Locator/CommandHandlerLocator.php
CommandHandlerLocator.register
public function register($commandClassName, CommandHandlerInterface $commandHandler) { $this->assertNamingConventionSatisfied($commandClassName, get_class($commandHandler)); $this->assertImplementsCommandInterface($commandClassName); if ($this->isCommandRegistered($commandClassName)) { throw new InvalidArgumentException( sprintf( 'A command handler has already been defined for the command "%s". Previous handler: %s. New handler: %s', $commandClassName, get_class($this->handlers[strtolower($commandClassName)]), get_class($commandHandler) ) ); } $this->handlers[strtolower($commandClassName)] = $commandHandler; }
php
public function register($commandClassName, CommandHandlerInterface $commandHandler) { $this->assertNamingConventionSatisfied($commandClassName, get_class($commandHandler)); $this->assertImplementsCommandInterface($commandClassName); if ($this->isCommandRegistered($commandClassName)) { throw new InvalidArgumentException( sprintf( 'A command handler has already been defined for the command "%s". Previous handler: %s. New handler: %s', $commandClassName, get_class($this->handlers[strtolower($commandClassName)]), get_class($commandHandler) ) ); } $this->handlers[strtolower($commandClassName)] = $commandHandler; }
[ "public", "function", "register", "(", "$", "commandClassName", ",", "CommandHandlerInterface", "$", "commandHandler", ")", "{", "$", "this", "->", "assertNamingConventionSatisfied", "(", "$", "commandClassName", ",", "get_class", "(", "$", "commandHandler", ")", ")", ";", "$", "this", "->", "assertImplementsCommandInterface", "(", "$", "commandClassName", ")", ";", "if", "(", "$", "this", "->", "isCommandRegistered", "(", "$", "commandClassName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'A command handler has already been defined for the command \"%s\". Previous handler: %s. New handler: %s'", ",", "$", "commandClassName", ",", "get_class", "(", "$", "this", "->", "handlers", "[", "strtolower", "(", "$", "commandClassName", ")", "]", ")", ",", "get_class", "(", "$", "commandHandler", ")", ")", ")", ";", "}", "$", "this", "->", "handlers", "[", "strtolower", "(", "$", "commandClassName", ")", "]", "=", "$", "commandHandler", ";", "}" ]
@param string $commandClassName @param CommandHandlerInterface $commandHandler @throws InvalidArgumentException
[ "@param", "string", "$commandClassName", "@param", "CommandHandlerInterface", "$commandHandler" ]
train
https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/Locator/CommandHandlerLocator.php#L54-L70
php-ddd/command
src/Handler/Locator/CommandHandlerLocator.php
CommandHandlerLocator.assertNamingConventionSatisfied
private function assertNamingConventionSatisfied($commandClassName, $handlerClassName) { if (!$this->isNamingConventionSatisfied($commandClassName, $handlerClassName)) { throw new InvalidArgumentException( sprintf( 'Command Handler does not follow naming convention. Expected: "%s". "%s" given.', $this->getExpectedHandlerName($commandClassName), ClassUtils::shortName($handlerClassName) ) ); } }
php
private function assertNamingConventionSatisfied($commandClassName, $handlerClassName) { if (!$this->isNamingConventionSatisfied($commandClassName, $handlerClassName)) { throw new InvalidArgumentException( sprintf( 'Command Handler does not follow naming convention. Expected: "%s". "%s" given.', $this->getExpectedHandlerName($commandClassName), ClassUtils::shortName($handlerClassName) ) ); } }
[ "private", "function", "assertNamingConventionSatisfied", "(", "$", "commandClassName", ",", "$", "handlerClassName", ")", "{", "if", "(", "!", "$", "this", "->", "isNamingConventionSatisfied", "(", "$", "commandClassName", ",", "$", "handlerClassName", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Command Handler does not follow naming convention. Expected: \"%s\". \"%s\" given.'", ",", "$", "this", "->", "getExpectedHandlerName", "(", "$", "commandClassName", ")", ",", "ClassUtils", "::", "shortName", "(", "$", "handlerClassName", ")", ")", ")", ";", "}", "}" ]
@param string $commandClassName @param string $handlerClassName @throws InvalidArgumentException
[ "@param", "string", "$commandClassName", "@param", "string", "$handlerClassName" ]
train
https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/Locator/CommandHandlerLocator.php#L78-L89
php-ddd/command
src/Handler/Locator/CommandHandlerLocator.php
CommandHandlerLocator.isNamingConventionSatisfied
private function isNamingConventionSatisfied($commandClassName, $handlerClassName) { $handlerClassName = ClassUtils::shortName($handlerClassName); return $this->getExpectedHandlerName($commandClassName) === $handlerClassName; }
php
private function isNamingConventionSatisfied($commandClassName, $handlerClassName) { $handlerClassName = ClassUtils::shortName($handlerClassName); return $this->getExpectedHandlerName($commandClassName) === $handlerClassName; }
[ "private", "function", "isNamingConventionSatisfied", "(", "$", "commandClassName", ",", "$", "handlerClassName", ")", "{", "$", "handlerClassName", "=", "ClassUtils", "::", "shortName", "(", "$", "handlerClassName", ")", ";", "return", "$", "this", "->", "getExpectedHandlerName", "(", "$", "commandClassName", ")", "===", "$", "handlerClassName", ";", "}" ]
@param string $commandClassName @param string $handlerClassName @return bool
[ "@param", "string", "$commandClassName", "@param", "string", "$handlerClassName" ]
train
https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/Locator/CommandHandlerLocator.php#L97-L102
php-ddd/command
src/Handler/Locator/CommandHandlerLocator.php
CommandHandlerLocator.getExpectedHandlerName
private function getExpectedHandlerName($commandClassName) { $commandClassName = ClassUtils::shortName($commandClassName); if ('Command' === substr($commandClassName, -7)) { $commandClassName = substr($commandClassName, 0, -7); } return $commandClassName.'CommandHandler'; }
php
private function getExpectedHandlerName($commandClassName) { $commandClassName = ClassUtils::shortName($commandClassName); if ('Command' === substr($commandClassName, -7)) { $commandClassName = substr($commandClassName, 0, -7); } return $commandClassName.'CommandHandler'; }
[ "private", "function", "getExpectedHandlerName", "(", "$", "commandClassName", ")", "{", "$", "commandClassName", "=", "ClassUtils", "::", "shortName", "(", "$", "commandClassName", ")", ";", "if", "(", "'Command'", "===", "substr", "(", "$", "commandClassName", ",", "-", "7", ")", ")", "{", "$", "commandClassName", "=", "substr", "(", "$", "commandClassName", ",", "0", ",", "-", "7", ")", ";", "}", "return", "$", "commandClassName", ".", "'CommandHandler'", ";", "}" ]
@param string $commandClassName @return string
[ "@param", "string", "$commandClassName" ]
train
https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/Locator/CommandHandlerLocator.php#L109-L117
opis/storages
cache/Redis.php
Redis.write
public function write($key, $value, $ttl = 0) { $this->redis->set($this->prefix . $key, is_numeric($value) ? $value : serialize($value)); if ($ttl != 0) { $this->redis->expire($this->prefix . $key, $ttl); } return true; }
php
public function write($key, $value, $ttl = 0) { $this->redis->set($this->prefix . $key, is_numeric($value) ? $value : serialize($value)); if ($ttl != 0) { $this->redis->expire($this->prefix . $key, $ttl); } return true; }
[ "public", "function", "write", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "$", "this", "->", "redis", "->", "set", "(", "$", "this", "->", "prefix", ".", "$", "key", ",", "is_numeric", "(", "$", "value", ")", "?", "$", "value", ":", "serialize", "(", "$", "value", ")", ")", ";", "if", "(", "$", "ttl", "!=", "0", ")", "{", "$", "this", "->", "redis", "->", "expire", "(", "$", "this", "->", "prefix", ".", "$", "key", ",", "$", "ttl", ")", ";", "}", "return", "true", ";", "}" ]
Store variable in the cache. @param string $key Cache key @param mixed $value The variable to store @param int $ttl (optional) Time to live @return boolean
[ "Store", "variable", "in", "the", "cache", "." ]
train
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/cache/Redis.php#L63-L70
opis/storages
cache/Redis.php
Redis.read
public function read($key) { $data = $this->redis->get($this->prefix . $key); return $data === null ? false : (is_numeric($data) ? $data : unserialize($data)); }
php
public function read($key) { $data = $this->redis->get($this->prefix . $key); return $data === null ? false : (is_numeric($data) ? $data : unserialize($data)); }
[ "public", "function", "read", "(", "$", "key", ")", "{", "$", "data", "=", "$", "this", "->", "redis", "->", "get", "(", "$", "this", "->", "prefix", ".", "$", "key", ")", ";", "return", "$", "data", "===", "null", "?", "false", ":", "(", "is_numeric", "(", "$", "data", ")", "?", "$", "data", ":", "unserialize", "(", "$", "data", ")", ")", ";", "}" ]
Fetch variable from the cache. @param string $key Cache key @return mixed
[ "Fetch", "variable", "from", "the", "cache", "." ]
train
https://github.com/opis/storages/blob/548dd631239c7cd75c04d17878b677e646540fde/cache/Redis.php#L79-L83
huasituo/hstcms
src/Console/Generators/MakeManageFounderCommand.php
MakeManageFounderCommand.stepOne
private function stepOne() { $t = $this->option('t'); if($t === 'add') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->container['password'] = $this->ask('Please enter the password:', 'admin888'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); $this->comment('Password: '.$this->container['password']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { if(ManageUserModel::where('username', $this->container['username'])->count()) { $this->error(hst_lang('hstcms::manage.founder.username.noone')); return $this->stepOne(); } $salt = hst_random(6); $postData = [ 'username'=>trim($this->container['username']), 'password'=>trim(hst_md5(trim($this->container['password']), $salt)), 'salt'=>$salt, 'status'=>1, 'gid'=>99 ]; ManageUserModel::insert($postData); ManageUserModel::setCache(); $this->info('Add Success'); } } else if($t === 'edit') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->container['password'] = $this->ask('Please enter the new password:', 'admin888'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); $this->comment('Password: '.$this->container['password']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { $user = ManageUserModel::where('username', $this->container['username'])->first(); if(!$user) { $this->error(hst_lang('hstcms::manage.no.username')); return true; } $postData = [ 'username'=>trim($this->container['username']), 'password'=>trim(hst_md5(trim($this->container['password']), $user['salt'])), ]; ManageUserModel::where('username', $this->container['username'])->update($postData); ManageUserModel::setCache(); $this->info('Edit Success'); } } else if($t === 'delete') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { $user = ManageUserModel::where('username', $this->container['username'])->first(); if(!$user) { $this->error(hst_lang('hstcms::manage.no.username')); return true; } ManageUserModel::where('username', $this->container['username'])->delete(); ManageUserModel::setCache(); $this->info('Delete Success'); } } return true; }
php
private function stepOne() { $t = $this->option('t'); if($t === 'add') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->container['password'] = $this->ask('Please enter the password:', 'admin888'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); $this->comment('Password: '.$this->container['password']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { if(ManageUserModel::where('username', $this->container['username'])->count()) { $this->error(hst_lang('hstcms::manage.founder.username.noone')); return $this->stepOne(); } $salt = hst_random(6); $postData = [ 'username'=>trim($this->container['username']), 'password'=>trim(hst_md5(trim($this->container['password']), $salt)), 'salt'=>$salt, 'status'=>1, 'gid'=>99 ]; ManageUserModel::insert($postData); ManageUserModel::setCache(); $this->info('Add Success'); } } else if($t === 'edit') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->container['password'] = $this->ask('Please enter the new password:', 'admin888'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); $this->comment('Password: '.$this->container['password']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { $user = ManageUserModel::where('username', $this->container['username'])->first(); if(!$user) { $this->error(hst_lang('hstcms::manage.no.username')); return true; } $postData = [ 'username'=>trim($this->container['username']), 'password'=>trim(hst_md5(trim($this->container['password']), $user['salt'])), ]; ManageUserModel::where('username', $this->container['username'])->update($postData); ManageUserModel::setCache(); $this->info('Edit Success'); } } else if($t === 'delete') { $this->container['username'] = $this->ask('Please enter the username:', 'admin1'); $this->comment('You have provided the following manifest information:'); $this->comment('Username: '.$this->container['username']); if ($this->confirm('If the provided information is correct, type "yes" to generate.')) { $user = ManageUserModel::where('username', $this->container['username'])->first(); if(!$user) { $this->error(hst_lang('hstcms::manage.no.username')); return true; } ManageUserModel::where('username', $this->container['username'])->delete(); ManageUserModel::setCache(); $this->info('Delete Success'); } } return true; }
[ "private", "function", "stepOne", "(", ")", "{", "$", "t", "=", "$", "this", "->", "option", "(", "'t'", ")", ";", "if", "(", "$", "t", "===", "'add'", ")", "{", "$", "this", "->", "container", "[", "'username'", "]", "=", "$", "this", "->", "ask", "(", "'Please enter the username:'", ",", "'admin1'", ")", ";", "$", "this", "->", "container", "[", "'password'", "]", "=", "$", "this", "->", "ask", "(", "'Please enter the password:'", ",", "'admin888'", ")", ";", "$", "this", "->", "comment", "(", "'You have provided the following manifest information:'", ")", ";", "$", "this", "->", "comment", "(", "'Username: '", ".", "$", "this", "->", "container", "[", "'username'", "]", ")", ";", "$", "this", "->", "comment", "(", "'Password: '", ".", "$", "this", "->", "container", "[", "'password'", "]", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "'If the provided information is correct, type \"yes\" to generate.'", ")", ")", "{", "if", "(", "ManageUserModel", "::", "where", "(", "'username'", ",", "$", "this", "->", "container", "[", "'username'", "]", ")", "->", "count", "(", ")", ")", "{", "$", "this", "->", "error", "(", "hst_lang", "(", "'hstcms::manage.founder.username.noone'", ")", ")", ";", "return", "$", "this", "->", "stepOne", "(", ")", ";", "}", "$", "salt", "=", "hst_random", "(", "6", ")", ";", "$", "postData", "=", "[", "'username'", "=>", "trim", "(", "$", "this", "->", "container", "[", "'username'", "]", ")", ",", "'password'", "=>", "trim", "(", "hst_md5", "(", "trim", "(", "$", "this", "->", "container", "[", "'password'", "]", ")", ",", "$", "salt", ")", ")", ",", "'salt'", "=>", "$", "salt", ",", "'status'", "=>", "1", ",", "'gid'", "=>", "99", "]", ";", "ManageUserModel", "::", "insert", "(", "$", "postData", ")", ";", "ManageUserModel", "::", "setCache", "(", ")", ";", "$", "this", "->", "info", "(", "'Add Success'", ")", ";", "}", "}", "else", "if", "(", "$", "t", "===", "'edit'", ")", "{", "$", "this", "->", "container", "[", "'username'", "]", "=", "$", "this", "->", "ask", "(", "'Please enter the username:'", ",", "'admin1'", ")", ";", "$", "this", "->", "container", "[", "'password'", "]", "=", "$", "this", "->", "ask", "(", "'Please enter the new password:'", ",", "'admin888'", ")", ";", "$", "this", "->", "comment", "(", "'You have provided the following manifest information:'", ")", ";", "$", "this", "->", "comment", "(", "'Username: '", ".", "$", "this", "->", "container", "[", "'username'", "]", ")", ";", "$", "this", "->", "comment", "(", "'Password: '", ".", "$", "this", "->", "container", "[", "'password'", "]", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "'If the provided information is correct, type \"yes\" to generate.'", ")", ")", "{", "$", "user", "=", "ManageUserModel", "::", "where", "(", "'username'", ",", "$", "this", "->", "container", "[", "'username'", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "user", ")", "{", "$", "this", "->", "error", "(", "hst_lang", "(", "'hstcms::manage.no.username'", ")", ")", ";", "return", "true", ";", "}", "$", "postData", "=", "[", "'username'", "=>", "trim", "(", "$", "this", "->", "container", "[", "'username'", "]", ")", ",", "'password'", "=>", "trim", "(", "hst_md5", "(", "trim", "(", "$", "this", "->", "container", "[", "'password'", "]", ")", ",", "$", "user", "[", "'salt'", "]", ")", ")", ",", "]", ";", "ManageUserModel", "::", "where", "(", "'username'", ",", "$", "this", "->", "container", "[", "'username'", "]", ")", "->", "update", "(", "$", "postData", ")", ";", "ManageUserModel", "::", "setCache", "(", ")", ";", "$", "this", "->", "info", "(", "'Edit Success'", ")", ";", "}", "}", "else", "if", "(", "$", "t", "===", "'delete'", ")", "{", "$", "this", "->", "container", "[", "'username'", "]", "=", "$", "this", "->", "ask", "(", "'Please enter the username:'", ",", "'admin1'", ")", ";", "$", "this", "->", "comment", "(", "'You have provided the following manifest information:'", ")", ";", "$", "this", "->", "comment", "(", "'Username: '", ".", "$", "this", "->", "container", "[", "'username'", "]", ")", ";", "if", "(", "$", "this", "->", "confirm", "(", "'If the provided information is correct, type \"yes\" to generate.'", ")", ")", "{", "$", "user", "=", "ManageUserModel", "::", "where", "(", "'username'", ",", "$", "this", "->", "container", "[", "'username'", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "$", "user", ")", "{", "$", "this", "->", "error", "(", "hst_lang", "(", "'hstcms::manage.no.username'", ")", ")", ";", "return", "true", ";", "}", "ManageUserModel", "::", "where", "(", "'username'", ",", "$", "this", "->", "container", "[", "'username'", "]", ")", "->", "delete", "(", ")", ";", "ManageUserModel", "::", "setCache", "(", ")", ";", "$", "this", "->", "info", "(", "'Delete Success'", ")", ";", "}", "}", "return", "true", ";", "}" ]
Step 1: Configure module manifest. @return mixed
[ "Step", "1", ":", "Configure", "module", "manifest", "." ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Console/Generators/MakeManageFounderCommand.php#L84-L146
activecollab/databasestructure
src/Builder/BaseManagerDirBuilder.php
BaseManagerDirBuilder.preBuild
public function preBuild() { $build_path = $this->getBuildPath(); if ($build_path) { if (is_dir($build_path)) { $build_path = rtrim($build_path, DIRECTORY_SEPARATOR); if (!is_dir("$build_path/Manager/Base")) { $old_umask = umask(0); $dir_created = mkdir("$build_path/Manager/Base"); umask($old_umask); if ($dir_created) { $this->triggerEvent('on_dir_created', ["$build_path/Manager/Base"]); } else { throw new RuntimeException("Failed to create '$build_path/Manager/Base' directory"); } } } else { throw new InvalidArgumentException("Directory '$build_path' not found"); } } }
php
public function preBuild() { $build_path = $this->getBuildPath(); if ($build_path) { if (is_dir($build_path)) { $build_path = rtrim($build_path, DIRECTORY_SEPARATOR); if (!is_dir("$build_path/Manager/Base")) { $old_umask = umask(0); $dir_created = mkdir("$build_path/Manager/Base"); umask($old_umask); if ($dir_created) { $this->triggerEvent('on_dir_created', ["$build_path/Manager/Base"]); } else { throw new RuntimeException("Failed to create '$build_path/Manager/Base' directory"); } } } else { throw new InvalidArgumentException("Directory '$build_path' not found"); } } }
[ "public", "function", "preBuild", "(", ")", "{", "$", "build_path", "=", "$", "this", "->", "getBuildPath", "(", ")", ";", "if", "(", "$", "build_path", ")", "{", "if", "(", "is_dir", "(", "$", "build_path", ")", ")", "{", "$", "build_path", "=", "rtrim", "(", "$", "build_path", ",", "DIRECTORY_SEPARATOR", ")", ";", "if", "(", "!", "is_dir", "(", "\"$build_path/Manager/Base\"", ")", ")", "{", "$", "old_umask", "=", "umask", "(", "0", ")", ";", "$", "dir_created", "=", "mkdir", "(", "\"$build_path/Manager/Base\"", ")", ";", "umask", "(", "$", "old_umask", ")", ";", "if", "(", "$", "dir_created", ")", "{", "$", "this", "->", "triggerEvent", "(", "'on_dir_created'", ",", "[", "\"$build_path/Manager/Base\"", "]", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Failed to create '$build_path/Manager/Base' directory\"", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "\"Directory '$build_path' not found\"", ")", ";", "}", "}", "}" ]
Execute prior to type build.
[ "Execute", "prior", "to", "type", "build", "." ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Builder/BaseManagerDirBuilder.php#L22-L45
stubbles/stubbles-webapp-core
src/main/php/response/Headers.php
Headers.add
public function add(string $name, $value): self { $this->headers[$name] = $value; return $this; }
php
public function add(string $name, $value): self { $this->headers[$name] = $value; return $this; }
[ "public", "function", "add", "(", "string", "$", "name", ",", "$", "value", ")", ":", "self", "{", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
adds header with given name @param string $name @param mixed $value @return \stubbles\webapp\response\Headers
[ "adds", "header", "with", "given", "name" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Headers.php#L34-L38
stubbles/stubbles-webapp-core
src/main/php/response/Headers.php
Headers.location
public function location($uri): self { return $this->add( 'Location', (($uri instanceof HttpUri) ? ($uri->asStringWithNonDefaultPort()) : ($uri)) ); }
php
public function location($uri): self { return $this->add( 'Location', (($uri instanceof HttpUri) ? ($uri->asStringWithNonDefaultPort()) : ($uri)) ); }
[ "public", "function", "location", "(", "$", "uri", ")", ":", "self", "{", "return", "$", "this", "->", "add", "(", "'Location'", ",", "(", "(", "$", "uri", "instanceof", "HttpUri", ")", "?", "(", "$", "uri", "->", "asStringWithNonDefaultPort", "(", ")", ")", ":", "(", "$", "uri", ")", ")", ")", ";", "}" ]
adds location header with given uri @param string|\stubbles\peer\http\HttpUri $uri @return \stubbles\webapp\response\Headers
[ "adds", "location", "header", "with", "given", "uri" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Headers.php#L59-L65
stubbles/stubbles-webapp-core
src/main/php/response/Headers.php
Headers.acceptable
public function acceptable(array $supportedMimeTypes): self { if (count($supportedMimeTypes) > 0) { $this->add('X-Acceptable', join(', ', $supportedMimeTypes)); } return $this; }
php
public function acceptable(array $supportedMimeTypes): self { if (count($supportedMimeTypes) > 0) { $this->add('X-Acceptable', join(', ', $supportedMimeTypes)); } return $this; }
[ "public", "function", "acceptable", "(", "array", "$", "supportedMimeTypes", ")", ":", "self", "{", "if", "(", "count", "(", "$", "supportedMimeTypes", ")", ">", "0", ")", "{", "$", "this", "->", "add", "(", "'X-Acceptable'", ",", "join", "(", "', '", ",", "$", "supportedMimeTypes", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
adds non-standard acceptable header with list of supported mime types @param string[] $supportedMimeTypes @return \stubbles\webapp\response\Headers
[ "adds", "non", "-", "standard", "acceptable", "header", "with", "list", "of", "supported", "mime", "types" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Headers.php#L84-L91
stubbles/stubbles-webapp-core
src/main/php/response/Headers.php
Headers.cacheControl
public function cacheControl(): CacheControl { $cacheControl = new CacheControl(); $this->add(CacheControl::HEADER_NAME, $cacheControl); return $cacheControl; }
php
public function cacheControl(): CacheControl { $cacheControl = new CacheControl(); $this->add(CacheControl::HEADER_NAME, $cacheControl); return $cacheControl; }
[ "public", "function", "cacheControl", "(", ")", ":", "CacheControl", "{", "$", "cacheControl", "=", "new", "CacheControl", "(", ")", ";", "$", "this", "->", "add", "(", "CacheControl", "::", "HEADER_NAME", ",", "$", "cacheControl", ")", ";", "return", "$", "cacheControl", ";", "}" ]
enables the Cache-Control header If no specific directives are enabled the value will be <code>Cache-Control: private</code> by default. @return \stubbles\webapp\response\CacheControl @see http://tools.ietf.org/html/rfc7234#section-5.2 @since 5.1.0
[ "enables", "the", "Cache", "-", "Control", "header" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Headers.php#L115-L120
czim/laravel-pxlcms
src/Generator/Writer/Model/Steps/StubReplaceAccessorsAndMutators.php
StubReplaceAccessorsAndMutators.collectNormalBelongsToRelationAccessors
protected function collectNormalBelongsToRelationAccessors() { $accessors = []; foreach ($this->data['relationships']['normal'] as $name => $relationship) { if ($relationship['type'] != Generator::RELATIONSHIP_BELONGS_TO) continue; if ( ! empty($relationship['key']) && snake_case($name) !== $relationship['key']) continue; $attributeName = snake_case($name); $content = $this->tab(2) . "return \$this->getBelongsToRelationAttributeValue('{$name}');\n"; $accessors[ $name ] = [ 'attribute' => $attributeName, 'content' => $content, ]; } return $accessors; }
php
protected function collectNormalBelongsToRelationAccessors() { $accessors = []; foreach ($this->data['relationships']['normal'] as $name => $relationship) { if ($relationship['type'] != Generator::RELATIONSHIP_BELONGS_TO) continue; if ( ! empty($relationship['key']) && snake_case($name) !== $relationship['key']) continue; $attributeName = snake_case($name); $content = $this->tab(2) . "return \$this->getBelongsToRelationAttributeValue('{$name}');\n"; $accessors[ $name ] = [ 'attribute' => $attributeName, 'content' => $content, ]; } return $accessors; }
[ "protected", "function", "collectNormalBelongsToRelationAccessors", "(", ")", "{", "$", "accessors", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "data", "[", "'relationships'", "]", "[", "'normal'", "]", "as", "$", "name", "=>", "$", "relationship", ")", "{", "if", "(", "$", "relationship", "[", "'type'", "]", "!=", "Generator", "::", "RELATIONSHIP_BELONGS_TO", ")", "continue", ";", "if", "(", "!", "empty", "(", "$", "relationship", "[", "'key'", "]", ")", "&&", "snake_case", "(", "$", "name", ")", "!==", "$", "relationship", "[", "'key'", "]", ")", "continue", ";", "$", "attributeName", "=", "snake_case", "(", "$", "name", ")", ";", "$", "content", "=", "$", "this", "->", "tab", "(", "2", ")", ".", "\"return \\$this->getBelongsToRelationAttributeValue('{$name}');\\n\"", ";", "$", "accessors", "[", "$", "name", "]", "=", "[", "'attribute'", "=>", "$", "attributeName", ",", "'content'", "=>", "$", "content", ",", "]", ";", "}", "return", "$", "accessors", ";", "}" ]
For belongs-to relationships that share foreign key & relation name @return array name => array with properties
[ "For", "belongs", "-", "to", "relationships", "that", "share", "foreign", "key", "&", "relation", "name" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceAccessorsAndMutators.php#L75-L94
gdbots/pbjx-bundle-php
src/Command/ReindexEventsCommand.php
ReindexEventsCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $dryRun = $input->getOption('dry-run'); $skipErrors = $input->getOption('skip-errors'); $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 1000); $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 100, 600000); $since = $input->getOption('since'); $until = $input->getOption('until'); $context = json_decode($input->getOption('context') ?: '{}', true); $context['tenant_id'] = (string)$input->getOption('tenant-id'); $context['skip_errors'] = $skipErrors; $context['reindexing'] = true; $streamId = $input->getArgument('stream-id') ? StreamId::fromString($input->getArgument('stream-id')) : null; if (!empty($since)) { $since = Microtime::fromString(str_pad($since, 16, '0')); } if (!empty($until)) { $until = Microtime::fromString(str_pad($until, 16, '0')); } $io = new SymfonyStyle($input, $output); $io->title(sprintf('Reindexing events from stream "%s"', $streamId ?? 'ALL')); if (!$this->readyForPbjxTraffic($io)) { return; } $this->createConsoleRequest(); $batch = 1; $i = 0; $reindexed = 0; $queue = []; //$io->comment(sprintf('Processing batch %d from stream "%s".', $batch, $streamId ?? 'ALL')); $io->comment(sprintf('context: %s', json_encode($context))); $io->newLine(); $receiver = function (Event $event, StreamId $streamId) use ( $output, $io, $context, $dryRun, $skipErrors, $batchSize, $batchDelay, &$batch, &$reindexed, &$i, &$queue ) { if (!$event instanceof Indexed) { $io->note(sprintf( 'IGNORING - Event [%s] does not have mixin [gdbots:pbjx:mixin:indexed].', $event->generateMessageRef() )); return; } ++$i; $output->writeln( sprintf( '<info>%d.</info> <comment>stream:</comment>%s, <comment>occurred_at:</comment>%s, ' . '<comment>curie:</comment>%s, <comment>event_id:</comment>%s', $i, $streamId, $event->get('occurred_at'), $event::schema()->getCurie()->toString(), $event->get('event_id') ) ); $queue[] = $event->freeze(); if (count($queue) >= $batchSize) { $events = $queue; $queue = []; $this->reindex($events, $reindexed, $io, $context, $batch, $dryRun, $skipErrors); ++$batch; if ($batchDelay > 0) { //$io->newLine(); //$io->note(sprintf('Pausing for %d milliseconds.', $batchDelay)); usleep($batchDelay * 1000); } //$io->comment(sprintf('Processing batch %d.', $batch)); //$io->newLine(); } }; if ($streamId) { $this->getPbjx()->getEventStore()->pipeEvents($streamId, $receiver, $since, $until, $context); } else { $this->getPbjx()->getEventStore()->pipeAllEvents($receiver, $since, $until, $context); } $this->reindex($queue, $reindexed, $io, $context, $batch, $dryRun, $skipErrors); $io->newLine(); $io->success(sprintf('Reindexed %s events from stream "%s".', number_format($reindexed), $streamId ?? 'ALL')); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $dryRun = $input->getOption('dry-run'); $skipErrors = $input->getOption('skip-errors'); $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 1000); $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 100, 600000); $since = $input->getOption('since'); $until = $input->getOption('until'); $context = json_decode($input->getOption('context') ?: '{}', true); $context['tenant_id'] = (string)$input->getOption('tenant-id'); $context['skip_errors'] = $skipErrors; $context['reindexing'] = true; $streamId = $input->getArgument('stream-id') ? StreamId::fromString($input->getArgument('stream-id')) : null; if (!empty($since)) { $since = Microtime::fromString(str_pad($since, 16, '0')); } if (!empty($until)) { $until = Microtime::fromString(str_pad($until, 16, '0')); } $io = new SymfonyStyle($input, $output); $io->title(sprintf('Reindexing events from stream "%s"', $streamId ?? 'ALL')); if (!$this->readyForPbjxTraffic($io)) { return; } $this->createConsoleRequest(); $batch = 1; $i = 0; $reindexed = 0; $queue = []; //$io->comment(sprintf('Processing batch %d from stream "%s".', $batch, $streamId ?? 'ALL')); $io->comment(sprintf('context: %s', json_encode($context))); $io->newLine(); $receiver = function (Event $event, StreamId $streamId) use ( $output, $io, $context, $dryRun, $skipErrors, $batchSize, $batchDelay, &$batch, &$reindexed, &$i, &$queue ) { if (!$event instanceof Indexed) { $io->note(sprintf( 'IGNORING - Event [%s] does not have mixin [gdbots:pbjx:mixin:indexed].', $event->generateMessageRef() )); return; } ++$i; $output->writeln( sprintf( '<info>%d.</info> <comment>stream:</comment>%s, <comment>occurred_at:</comment>%s, ' . '<comment>curie:</comment>%s, <comment>event_id:</comment>%s', $i, $streamId, $event->get('occurred_at'), $event::schema()->getCurie()->toString(), $event->get('event_id') ) ); $queue[] = $event->freeze(); if (count($queue) >= $batchSize) { $events = $queue; $queue = []; $this->reindex($events, $reindexed, $io, $context, $batch, $dryRun, $skipErrors); ++$batch; if ($batchDelay > 0) { //$io->newLine(); //$io->note(sprintf('Pausing for %d milliseconds.', $batchDelay)); usleep($batchDelay * 1000); } //$io->comment(sprintf('Processing batch %d.', $batch)); //$io->newLine(); } }; if ($streamId) { $this->getPbjx()->getEventStore()->pipeEvents($streamId, $receiver, $since, $until, $context); } else { $this->getPbjx()->getEventStore()->pipeAllEvents($receiver, $since, $until, $context); } $this->reindex($queue, $reindexed, $io, $context, $batch, $dryRun, $skipErrors); $io->newLine(); $io->success(sprintf('Reindexed %s events from stream "%s".', number_format($reindexed), $streamId ?? 'ALL')); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "dryRun", "=", "$", "input", "->", "getOption", "(", "'dry-run'", ")", ";", "$", "skipErrors", "=", "$", "input", "->", "getOption", "(", "'skip-errors'", ")", ";", "$", "batchSize", "=", "NumberUtils", "::", "bound", "(", "$", "input", "->", "getOption", "(", "'batch-size'", ")", ",", "1", ",", "1000", ")", ";", "$", "batchDelay", "=", "NumberUtils", "::", "bound", "(", "$", "input", "->", "getOption", "(", "'batch-delay'", ")", ",", "100", ",", "600000", ")", ";", "$", "since", "=", "$", "input", "->", "getOption", "(", "'since'", ")", ";", "$", "until", "=", "$", "input", "->", "getOption", "(", "'until'", ")", ";", "$", "context", "=", "json_decode", "(", "$", "input", "->", "getOption", "(", "'context'", ")", "?", ":", "'{}'", ",", "true", ")", ";", "$", "context", "[", "'tenant_id'", "]", "=", "(", "string", ")", "$", "input", "->", "getOption", "(", "'tenant-id'", ")", ";", "$", "context", "[", "'skip_errors'", "]", "=", "$", "skipErrors", ";", "$", "context", "[", "'reindexing'", "]", "=", "true", ";", "$", "streamId", "=", "$", "input", "->", "getArgument", "(", "'stream-id'", ")", "?", "StreamId", "::", "fromString", "(", "$", "input", "->", "getArgument", "(", "'stream-id'", ")", ")", ":", "null", ";", "if", "(", "!", "empty", "(", "$", "since", ")", ")", "{", "$", "since", "=", "Microtime", "::", "fromString", "(", "str_pad", "(", "$", "since", ",", "16", ",", "'0'", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "until", ")", ")", "{", "$", "until", "=", "Microtime", "::", "fromString", "(", "str_pad", "(", "$", "until", ",", "16", ",", "'0'", ")", ")", ";", "}", "$", "io", "=", "new", "SymfonyStyle", "(", "$", "input", ",", "$", "output", ")", ";", "$", "io", "->", "title", "(", "sprintf", "(", "'Reindexing events from stream \"%s\"'", ",", "$", "streamId", "??", "'ALL'", ")", ")", ";", "if", "(", "!", "$", "this", "->", "readyForPbjxTraffic", "(", "$", "io", ")", ")", "{", "return", ";", "}", "$", "this", "->", "createConsoleRequest", "(", ")", ";", "$", "batch", "=", "1", ";", "$", "i", "=", "0", ";", "$", "reindexed", "=", "0", ";", "$", "queue", "=", "[", "]", ";", "//$io->comment(sprintf('Processing batch %d from stream \"%s\".', $batch, $streamId ?? 'ALL'));", "$", "io", "->", "comment", "(", "sprintf", "(", "'context: %s'", ",", "json_encode", "(", "$", "context", ")", ")", ")", ";", "$", "io", "->", "newLine", "(", ")", ";", "$", "receiver", "=", "function", "(", "Event", "$", "event", ",", "StreamId", "$", "streamId", ")", "use", "(", "$", "output", ",", "$", "io", ",", "$", "context", ",", "$", "dryRun", ",", "$", "skipErrors", ",", "$", "batchSize", ",", "$", "batchDelay", ",", "&", "$", "batch", ",", "&", "$", "reindexed", ",", "&", "$", "i", ",", "&", "$", "queue", ")", "{", "if", "(", "!", "$", "event", "instanceof", "Indexed", ")", "{", "$", "io", "->", "note", "(", "sprintf", "(", "'IGNORING - Event [%s] does not have mixin [gdbots:pbjx:mixin:indexed].'", ",", "$", "event", "->", "generateMessageRef", "(", ")", ")", ")", ";", "return", ";", "}", "++", "$", "i", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "'<info>%d.</info> <comment>stream:</comment>%s, <comment>occurred_at:</comment>%s, '", ".", "'<comment>curie:</comment>%s, <comment>event_id:</comment>%s'", ",", "$", "i", ",", "$", "streamId", ",", "$", "event", "->", "get", "(", "'occurred_at'", ")", ",", "$", "event", "::", "schema", "(", ")", "->", "getCurie", "(", ")", "->", "toString", "(", ")", ",", "$", "event", "->", "get", "(", "'event_id'", ")", ")", ")", ";", "$", "queue", "[", "]", "=", "$", "event", "->", "freeze", "(", ")", ";", "if", "(", "count", "(", "$", "queue", ")", ">=", "$", "batchSize", ")", "{", "$", "events", "=", "$", "queue", ";", "$", "queue", "=", "[", "]", ";", "$", "this", "->", "reindex", "(", "$", "events", ",", "$", "reindexed", ",", "$", "io", ",", "$", "context", ",", "$", "batch", ",", "$", "dryRun", ",", "$", "skipErrors", ")", ";", "++", "$", "batch", ";", "if", "(", "$", "batchDelay", ">", "0", ")", "{", "//$io->newLine();", "//$io->note(sprintf('Pausing for %d milliseconds.', $batchDelay));", "usleep", "(", "$", "batchDelay", "*", "1000", ")", ";", "}", "//$io->comment(sprintf('Processing batch %d.', $batch));", "//$io->newLine();", "}", "}", ";", "if", "(", "$", "streamId", ")", "{", "$", "this", "->", "getPbjx", "(", ")", "->", "getEventStore", "(", ")", "->", "pipeEvents", "(", "$", "streamId", ",", "$", "receiver", ",", "$", "since", ",", "$", "until", ",", "$", "context", ")", ";", "}", "else", "{", "$", "this", "->", "getPbjx", "(", ")", "->", "getEventStore", "(", ")", "->", "pipeAllEvents", "(", "$", "receiver", ",", "$", "since", ",", "$", "until", ",", "$", "context", ")", ";", "}", "$", "this", "->", "reindex", "(", "$", "queue", ",", "$", "reindexed", ",", "$", "io", ",", "$", "context", ",", "$", "batch", ",", "$", "dryRun", ",", "$", "skipErrors", ")", ";", "$", "io", "->", "newLine", "(", ")", ";", "$", "io", "->", "success", "(", "sprintf", "(", "'Reindexed %s events from stream \"%s\".'", ",", "number_format", "(", "$", "reindexed", ")", ",", "$", "streamId", "??", "'ALL'", ")", ")", ";", "}" ]
@param InputInterface $input @param OutputInterface $output @return null
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output" ]
train
https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Command/ReindexEventsCommand.php#L113-L211
gdbots/pbjx-bundle-php
src/Command/ReindexEventsCommand.php
ReindexEventsCommand.reindex
protected function reindex(array $events, int &$reindexed, SymfonyStyle $io, array $context, int $batch, bool $dryRun = false, bool $skipErrors = false): void { if ($dryRun) { $io->note(sprintf('DRY RUN - Would reindex event batch %d here.', $batch)); } else { try { $this->getPbjx()->getEventSearch()->indexEvents($events, $context); } catch (\Throwable $e) { $io->error($e->getMessage()); $io->note(sprintf('Failed to index batch %d.', $batch)); $io->newLine(2); if (!$skipErrors) { throw $e; } } } $reindexed += count($events); }
php
protected function reindex(array $events, int &$reindexed, SymfonyStyle $io, array $context, int $batch, bool $dryRun = false, bool $skipErrors = false): void { if ($dryRun) { $io->note(sprintf('DRY RUN - Would reindex event batch %d here.', $batch)); } else { try { $this->getPbjx()->getEventSearch()->indexEvents($events, $context); } catch (\Throwable $e) { $io->error($e->getMessage()); $io->note(sprintf('Failed to index batch %d.', $batch)); $io->newLine(2); if (!$skipErrors) { throw $e; } } } $reindexed += count($events); }
[ "protected", "function", "reindex", "(", "array", "$", "events", ",", "int", "&", "$", "reindexed", ",", "SymfonyStyle", "$", "io", ",", "array", "$", "context", ",", "int", "$", "batch", ",", "bool", "$", "dryRun", "=", "false", ",", "bool", "$", "skipErrors", "=", "false", ")", ":", "void", "{", "if", "(", "$", "dryRun", ")", "{", "$", "io", "->", "note", "(", "sprintf", "(", "'DRY RUN - Would reindex event batch %d here.'", ",", "$", "batch", ")", ")", ";", "}", "else", "{", "try", "{", "$", "this", "->", "getPbjx", "(", ")", "->", "getEventSearch", "(", ")", "->", "indexEvents", "(", "$", "events", ",", "$", "context", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "io", "->", "error", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "io", "->", "note", "(", "sprintf", "(", "'Failed to index batch %d.'", ",", "$", "batch", ")", ")", ";", "$", "io", "->", "newLine", "(", "2", ")", ";", "if", "(", "!", "$", "skipErrors", ")", "{", "throw", "$", "e", ";", "}", "}", "}", "$", "reindexed", "+=", "count", "(", "$", "events", ")", ";", "}" ]
@param Event[] $events @param int $reindexed @param SymfonyStyle $io @param array $context @param int $batch @param bool $dryRun @param bool $skipErrors @throws \Exception
[ "@param", "Event", "[]", "$events", "@param", "int", "$reindexed", "@param", "SymfonyStyle", "$io", "@param", "array", "$context", "@param", "int", "$batch", "@param", "bool", "$dryRun", "@param", "bool", "$skipErrors" ]
train
https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Command/ReindexEventsCommand.php#L224-L243
acasademont/wurfl
WURFL/WURFLService.php
WURFL_WURFLService.getDeviceForRequest
public function getDeviceForRequest(WURFL_Request_GenericRequest $request) { $deviceId = $this->deviceIdForRequest($request); return $this->getWrappedDevice($deviceId, $request); }
php
public function getDeviceForRequest(WURFL_Request_GenericRequest $request) { $deviceId = $this->deviceIdForRequest($request); return $this->getWrappedDevice($deviceId, $request); }
[ "public", "function", "getDeviceForRequest", "(", "WURFL_Request_GenericRequest", "$", "request", ")", "{", "$", "deviceId", "=", "$", "this", "->", "deviceIdForRequest", "(", "$", "request", ")", ";", "return", "$", "this", "->", "getWrappedDevice", "(", "$", "deviceId", ",", "$", "request", ")", ";", "}" ]
Returns the Device for the given WURFL_Request_GenericRequest @param WURFL_Request_GenericRequest $request @return WURFL_CustomDevice
[ "Returns", "the", "Device", "for", "the", "given", "WURFL_Request_GenericRequest" ]
train
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLService.php#L62-L66
acasademont/wurfl
WURFL/WURFLService.php
WURFL_WURFLService.getDevice
public function getDevice($deviceID, $request=null) { if ($request !== null) { if (!($request instanceof WURFL_Request_GenericRequest)) { throw new InvalidArgumentException("Error: Request parameter must be null or instance of WURFL_Request_GenericRequest"); } // Normalization must be performed if request is passed so virtual capabilities can be // resolved correctly. This is normally handled in self::deviceIdForRequest() $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent); } return $this->getWrappedDevice($deviceID, $request); }
php
public function getDevice($deviceID, $request=null) { if ($request !== null) { if (!($request instanceof WURFL_Request_GenericRequest)) { throw new InvalidArgumentException("Error: Request parameter must be null or instance of WURFL_Request_GenericRequest"); } // Normalization must be performed if request is passed so virtual capabilities can be // resolved correctly. This is normally handled in self::deviceIdForRequest() $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent); } return $this->getWrappedDevice($deviceID, $request); }
[ "public", "function", "getDevice", "(", "$", "deviceID", ",", "$", "request", "=", "null", ")", "{", "if", "(", "$", "request", "!==", "null", ")", "{", "if", "(", "!", "(", "$", "request", "instanceof", "WURFL_Request_GenericRequest", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Error: Request parameter must be null or instance of WURFL_Request_GenericRequest\"", ")", ";", "}", "// Normalization must be performed if request is passed so virtual capabilities can be", "// resolved correctly. This is normally handled in self::deviceIdForRequest()", "$", "generic_normalizer", "=", "WURFL_UserAgentHandlerChainFactory", "::", "createGenericNormalizers", "(", ")", ";", "$", "request", "->", "userAgentNormalized", "=", "$", "generic_normalizer", "->", "normalize", "(", "$", "request", "->", "userAgent", ")", ";", "}", "return", "$", "this", "->", "getWrappedDevice", "(", "$", "deviceID", ",", "$", "request", ")", ";", "}" ]
Retun a WURFL_Xml_ModelDevice for the given device id. If $request is included, it will be used to resolve virtual capabilties. @param string $deviceID @param WURFL_Request_GenericRequest $request @return WURFL_Xml_ModelDevice
[ "Retun", "a", "WURFL_Xml_ModelDevice", "for", "the", "given", "device", "id", ".", "If", "$request", "is", "included", "it", "will", "be", "used", "to", "resolve", "virtual", "capabilties", "." ]
train
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLService.php#L76-L89
acasademont/wurfl
WURFL/WURFLService.php
WURFL_WURFLService.deviceIdForRequest
private function deviceIdForRequest($request) { $deviceId = $this->_cacheProvider->load($request->id); if (empty($deviceId)) { $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent); if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance() && WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($request->userAgentNormalized)) { // This device has been identified as a web browser programatically, so no call to WURFL is necessary return WURFL_Constants::GENERIC_WEB_BROWSER; } $deviceId = $this->_userAgentHandlerChain->match($request); // save it in cache $this->_cacheProvider->save($request->id, $deviceId); } else { $request->matchInfo->from_cache = true; $request->matchInfo->lookup_time = 0.0; } return $deviceId; }
php
private function deviceIdForRequest($request) { $deviceId = $this->_cacheProvider->load($request->id); if (empty($deviceId)) { $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent); if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance() && WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($request->userAgentNormalized)) { // This device has been identified as a web browser programatically, so no call to WURFL is necessary return WURFL_Constants::GENERIC_WEB_BROWSER; } $deviceId = $this->_userAgentHandlerChain->match($request); // save it in cache $this->_cacheProvider->save($request->id, $deviceId); } else { $request->matchInfo->from_cache = true; $request->matchInfo->lookup_time = 0.0; } return $deviceId; }
[ "private", "function", "deviceIdForRequest", "(", "$", "request", ")", "{", "$", "deviceId", "=", "$", "this", "->", "_cacheProvider", "->", "load", "(", "$", "request", "->", "id", ")", ";", "if", "(", "empty", "(", "$", "deviceId", ")", ")", "{", "$", "generic_normalizer", "=", "WURFL_UserAgentHandlerChainFactory", "::", "createGenericNormalizers", "(", ")", ";", "$", "request", "->", "userAgentNormalized", "=", "$", "generic_normalizer", "->", "normalize", "(", "$", "request", "->", "userAgent", ")", ";", "if", "(", "WURFL_Configuration_ConfigHolder", "::", "getWURFLConfig", "(", ")", "->", "isHighPerformance", "(", ")", "&&", "WURFL_Handlers_Utils", "::", "isDesktopBrowserHeavyDutyAnalysis", "(", "$", "request", "->", "userAgentNormalized", ")", ")", "{", "// This device has been identified as a web browser programatically, so no call to WURFL is necessary", "return", "WURFL_Constants", "::", "GENERIC_WEB_BROWSER", ";", "}", "$", "deviceId", "=", "$", "this", "->", "_userAgentHandlerChain", "->", "match", "(", "$", "request", ")", ";", "// save it in cache", "$", "this", "->", "_cacheProvider", "->", "save", "(", "$", "request", "->", "id", ",", "$", "deviceId", ")", ";", "}", "else", "{", "$", "request", "->", "matchInfo", "->", "from_cache", "=", "true", ";", "$", "request", "->", "matchInfo", "->", "lookup_time", "=", "0.0", ";", "}", "return", "$", "deviceId", ";", "}" ]
Returns the device id for the device that matches the $request @param WURFL_Request_GenericRequest $request WURFL Request object @return string WURFL device id
[ "Returns", "the", "device", "id", "for", "the", "device", "that", "matches", "the", "$request" ]
train
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLService.php#L132-L152
acasademont/wurfl
WURFL/WURFLService.php
WURFL_WURFLService.getWrappedDevice
private function getWrappedDevice($deviceID, $request = null) { $modelDevices = $this->_cacheProvider->load('DEVS_'.$deviceID); if (empty($modelDevices)) { $modelDevices = $this->_deviceRepository->getDeviceHierarchy($deviceID); } $this->_cacheProvider->save('DEVS_'.$deviceID, $modelDevices); if ($request === null) { // If a request was not provided, we generate one from the WURFL entry itself // to help resolve the virtual capabilities $requestFactory = new WURFL_Request_GenericRequestFactory(); $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent); $genericNormalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $genericNormalizer->normalize($request->userAgent); } // The CustomDevice is not cached since virtual capabilities must be recalculated // for every different request. return new WURFL_CustomDevice($modelDevices, $request); }
php
private function getWrappedDevice($deviceID, $request = null) { $modelDevices = $this->_cacheProvider->load('DEVS_'.$deviceID); if (empty($modelDevices)) { $modelDevices = $this->_deviceRepository->getDeviceHierarchy($deviceID); } $this->_cacheProvider->save('DEVS_'.$deviceID, $modelDevices); if ($request === null) { // If a request was not provided, we generate one from the WURFL entry itself // to help resolve the virtual capabilities $requestFactory = new WURFL_Request_GenericRequestFactory(); $request = $requestFactory->createRequestForUserAgent($modelDevices[0]->userAgent); $genericNormalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers(); $request->userAgentNormalized = $genericNormalizer->normalize($request->userAgent); } // The CustomDevice is not cached since virtual capabilities must be recalculated // for every different request. return new WURFL_CustomDevice($modelDevices, $request); }
[ "private", "function", "getWrappedDevice", "(", "$", "deviceID", ",", "$", "request", "=", "null", ")", "{", "$", "modelDevices", "=", "$", "this", "->", "_cacheProvider", "->", "load", "(", "'DEVS_'", ".", "$", "deviceID", ")", ";", "if", "(", "empty", "(", "$", "modelDevices", ")", ")", "{", "$", "modelDevices", "=", "$", "this", "->", "_deviceRepository", "->", "getDeviceHierarchy", "(", "$", "deviceID", ")", ";", "}", "$", "this", "->", "_cacheProvider", "->", "save", "(", "'DEVS_'", ".", "$", "deviceID", ",", "$", "modelDevices", ")", ";", "if", "(", "$", "request", "===", "null", ")", "{", "// If a request was not provided, we generate one from the WURFL entry itself", "// to help resolve the virtual capabilities", "$", "requestFactory", "=", "new", "WURFL_Request_GenericRequestFactory", "(", ")", ";", "$", "request", "=", "$", "requestFactory", "->", "createRequestForUserAgent", "(", "$", "modelDevices", "[", "0", "]", "->", "userAgent", ")", ";", "$", "genericNormalizer", "=", "WURFL_UserAgentHandlerChainFactory", "::", "createGenericNormalizers", "(", ")", ";", "$", "request", "->", "userAgentNormalized", "=", "$", "genericNormalizer", "->", "normalize", "(", "$", "request", "->", "userAgent", ")", ";", "}", "// The CustomDevice is not cached since virtual capabilities must be recalculated", "// for every different request.", "return", "new", "WURFL_CustomDevice", "(", "$", "modelDevices", ",", "$", "request", ")", ";", "}" ]
Wraps the model device with WURFL_Xml_ModelDevice. This function takes the Device ID and returns the WURFL_CustomDevice with all capabilities. @param string $deviceID @param WURFL_Request_GenericRequest|null $request @return WURFL_CustomDevice
[ "Wraps", "the", "model", "device", "with", "WURFL_Xml_ModelDevice", ".", "This", "function", "takes", "the", "Device", "ID", "and", "returns", "the", "WURFL_CustomDevice", "with", "all", "capabilities", "." ]
train
https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/WURFLService.php#L162-L184
sohenk/wangeditor3forlaravel
src/WangEditorProvider.php
WangEditorProvider.boot
public function boot(Router $router) { $this->loadViewsFrom(__DIR__ . '/views', 'initialize'); $this->publishes([ __DIR__.'/config/wangeditor.php' => config_path('wangeditor.php'), ], 'config'); $this->publishes([ __DIR__ . '/assets/wangeditor' => public_path('vendor/wangeditor'), ], 'assets'); $this->publishes([ __DIR__ . '/views' => base_path('resources/views/vendor/wangeditor') ], 'resources'); if (!app()->runningInConsole()) { $this->registerRoute($router); } }
php
public function boot(Router $router) { $this->loadViewsFrom(__DIR__ . '/views', 'initialize'); $this->publishes([ __DIR__.'/config/wangeditor.php' => config_path('wangeditor.php'), ], 'config'); $this->publishes([ __DIR__ . '/assets/wangeditor' => public_path('vendor/wangeditor'), ], 'assets'); $this->publishes([ __DIR__ . '/views' => base_path('resources/views/vendor/wangeditor') ], 'resources'); if (!app()->runningInConsole()) { $this->registerRoute($router); } }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "$", "this", "->", "loadViewsFrom", "(", "__DIR__", ".", "'/views'", ",", "'initialize'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/config/wangeditor.php'", "=>", "config_path", "(", "'wangeditor.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/assets/wangeditor'", "=>", "public_path", "(", "'vendor/wangeditor'", ")", ",", "]", ",", "'assets'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/views'", "=>", "base_path", "(", "'resources/views/vendor/wangeditor'", ")", "]", ",", "'resources'", ")", ";", "if", "(", "!", "app", "(", ")", "->", "runningInConsole", "(", ")", ")", "{", "$", "this", "->", "registerRoute", "(", "$", "router", ")", ";", "}", "}" ]
Bootstrap the application services. @return void
[ "Bootstrap", "the", "application", "services", "." ]
train
https://github.com/sohenk/wangeditor3forlaravel/blob/a67c6b69926774c9c157920c5380de4aae06fea3/src/WangEditorProvider.php#L24-L43
sohenk/wangeditor3forlaravel
src/WangEditorProvider.php
WangEditorProvider.registerRoute
public function registerRoute($router) { if (!$this->app->routesAreCached()) { $router->group( array_merge( ['namespace' => __NAMESPACE__], config('wangeditor.route.options' ) ), function ($router) { $router->any( config('wangeditor.route.url', '/wangeditor/server'), 'WangEditorController@serve' ); }); } }
php
public function registerRoute($router) { if (!$this->app->routesAreCached()) { $router->group( array_merge( ['namespace' => __NAMESPACE__], config('wangeditor.route.options' ) ), function ($router) { $router->any( config('wangeditor.route.url', '/wangeditor/server'), 'WangEditorController@serve' ); }); } }
[ "public", "function", "registerRoute", "(", "$", "router", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "$", "router", "->", "group", "(", "array_merge", "(", "[", "'namespace'", "=>", "__NAMESPACE__", "]", ",", "config", "(", "'wangeditor.route.options'", ")", ")", ",", "function", "(", "$", "router", ")", "{", "$", "router", "->", "any", "(", "config", "(", "'wangeditor.route.url'", ",", "'/wangeditor/server'", ")", ",", "'WangEditorController@serve'", ")", ";", "}", ")", ";", "}", "}" ]
Register routes. @param $router
[ "Register", "routes", "." ]
train
https://github.com/sohenk/wangeditor3forlaravel/blob/a67c6b69926774c9c157920c5380de4aae06fea3/src/WangEditorProvider.php#L60-L75
o2system/filesystem
src/File.php
File.getContents
public function getContents($useIncludePath = false, $context = null, $offset = 0, $maxlen = 0) { $params[] = $this->getRealPath(); $params[] = $useIncludePath; $params[] = $context; $params[] = $offset; if ($maxlen > 0) { $params[] = $maxlen; } return call_user_func_array('file_get_contents', $params); }
php
public function getContents($useIncludePath = false, $context = null, $offset = 0, $maxlen = 0) { $params[] = $this->getRealPath(); $params[] = $useIncludePath; $params[] = $context; $params[] = $offset; if ($maxlen > 0) { $params[] = $maxlen; } return call_user_func_array('file_get_contents', $params); }
[ "public", "function", "getContents", "(", "$", "useIncludePath", "=", "false", ",", "$", "context", "=", "null", ",", "$", "offset", "=", "0", ",", "$", "maxlen", "=", "0", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "$", "useIncludePath", ";", "$", "params", "[", "]", "=", "$", "context", ";", "$", "params", "[", "]", "=", "$", "offset", ";", "if", "(", "$", "maxlen", ">", "0", ")", "{", "$", "params", "[", "]", "=", "$", "maxlen", ";", "}", "return", "call_user_func_array", "(", "'file_get_contents'", ",", "$", "params", ")", ";", "}" ]
File::getContents Reads entire file into a string. @param bool $useIncludePath As of PHP 5 the FILE_USE_INCLUDE_PATH constant can be used to trigger include path search. @param resource $context A valid context resource created with stream_context_create(). If you don't need to use a custom context, you can skip this parameter by NULL. @param int $offset The offset where the reading starts on the original stream. Negative offsets count from the end of the stream. Seeking (offset) is not supported with remote files. Attempting to seek on non-local files may work with small offsets, but this is unpredictable because it works on the buffered stream. @param int $maxlen Maximum length of data read. The default is to read until end of file is reached. Note that this parameter is applied to the stream processed by the filters. @return string The function returns the read data or FALSE on failure.
[ "File", "::", "getContents" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L158-L170
o2system/filesystem
src/File.php
File.touch
public function touch($time = null, $atime = null) { $params[] = $this->getRealPath(); $params[] = (isset($time) ? $time : time()); $params[] = (isset($atime) ? $atime : time()); return call_user_func_array('touch', $params); }
php
public function touch($time = null, $atime = null) { $params[] = $this->getRealPath(); $params[] = (isset($time) ? $time : time()); $params[] = (isset($atime) ? $atime : time()); return call_user_func_array('touch', $params); }
[ "public", "function", "touch", "(", "$", "time", "=", "null", ",", "$", "atime", "=", "null", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "(", "isset", "(", "$", "time", ")", "?", "$", "time", ":", "time", "(", ")", ")", ";", "$", "params", "[", "]", "=", "(", "isset", "(", "$", "atime", ")", "?", "$", "atime", ":", "time", "(", ")", ")", ";", "return", "call_user_func_array", "(", "'touch'", ",", "$", "params", ")", ";", "}" ]
File::touch @param int $time The touch time. If time is not supplied, the current system time is used. @param int $atime If present, the access time of the given filename is set to the value of atime. Otherwise, it is set to the value passed to the time parameter. If neither are present, the current system time is used. @return bool Returns TRUE on success or FALSE on failure.
[ "File", "::", "touch" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L184-L191
o2system/filesystem
src/File.php
File.show
public function show() { if ($mime = $this->getMime()) { $mime = is_array($mime) ? $mime[ 0 ] : $mime; } elseif (is_file($this->getRealPath())) { $mime = 'application/octet-stream'; } $fileSize = filesize($this->getRealPath()); $filename = pathinfo($this->getRealPath(), PATHINFO_BASENAME); // Common headers $expires = 604800; // (60*60*24*7) header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); header('Accept-Ranges: bytes', true); header("Cache-control: private", true); header('Pragma: private', true); header('Content-Type: ' . $mime); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); $ETag = '"' . md5($filename) . '"'; if ( ! empty($_SERVER[ 'HTTP_IF_NONE_MATCH' ]) && $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == $ETag ) { header('HTTP/1.1 304 Not Modified'); header('Content-Length: ' . $fileSize); exit; } $expires = 604800; // (60*60*24*7) header('ETag: ' . $ETag); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); // Open file // @readfile($file_path); $file = @fopen($filename, "rb"); if ($file) { while ( ! feof($file)) { print(fread($file, 1024 * 8)); flush(); if (connection_status() != 0) { @fclose($file); die(); } } @fclose($file); } }
php
public function show() { if ($mime = $this->getMime()) { $mime = is_array($mime) ? $mime[ 0 ] : $mime; } elseif (is_file($this->getRealPath())) { $mime = 'application/octet-stream'; } $fileSize = filesize($this->getRealPath()); $filename = pathinfo($this->getRealPath(), PATHINFO_BASENAME); // Common headers $expires = 604800; // (60*60*24*7) header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); header('Accept-Ranges: bytes', true); header("Cache-control: private", true); header('Pragma: private', true); header('Content-Type: ' . $mime); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); $ETag = '"' . md5($filename) . '"'; if ( ! empty($_SERVER[ 'HTTP_IF_NONE_MATCH' ]) && $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == $ETag ) { header('HTTP/1.1 304 Not Modified'); header('Content-Length: ' . $fileSize); exit; } $expires = 604800; // (60*60*24*7) header('ETag: ' . $ETag); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Expires:' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT'); // Open file // @readfile($file_path); $file = @fopen($filename, "rb"); if ($file) { while ( ! feof($file)) { print(fread($file, 1024 * 8)); flush(); if (connection_status() != 0) { @fclose($file); die(); } } @fclose($file); } }
[ "public", "function", "show", "(", ")", "{", "if", "(", "$", "mime", "=", "$", "this", "->", "getMime", "(", ")", ")", "{", "$", "mime", "=", "is_array", "(", "$", "mime", ")", "?", "$", "mime", "[", "0", "]", ":", "$", "mime", ";", "}", "elseif", "(", "is_file", "(", "$", "this", "->", "getRealPath", "(", ")", ")", ")", "{", "$", "mime", "=", "'application/octet-stream'", ";", "}", "$", "fileSize", "=", "filesize", "(", "$", "this", "->", "getRealPath", "(", ")", ")", ";", "$", "filename", "=", "pathinfo", "(", "$", "this", "->", "getRealPath", "(", ")", ",", "PATHINFO_BASENAME", ")", ";", "// Common headers\r", "$", "expires", "=", "604800", ";", "// (60*60*24*7)\r", "header", "(", "'Expires:'", ".", "gmdate", "(", "'D, d M Y H:i:s'", ",", "time", "(", ")", "+", "$", "expires", ")", ".", "' GMT'", ")", ";", "header", "(", "'Accept-Ranges: bytes'", ",", "true", ")", ";", "header", "(", "\"Cache-control: private\"", ",", "true", ")", ";", "header", "(", "'Pragma: private'", ",", "true", ")", ";", "header", "(", "'Content-Type: '", ".", "$", "mime", ")", ";", "header", "(", "'Content-Disposition: inline; filename=\"'", ".", "$", "filename", ".", "'\"'", ")", ";", "header", "(", "'Content-Transfer-Encoding: binary'", ")", ";", "header", "(", "'Accept-Ranges: bytes'", ")", ";", "$", "ETag", "=", "'\"'", ".", "md5", "(", "$", "filename", ")", ".", "'\"'", ";", "if", "(", "!", "empty", "(", "$", "_SERVER", "[", "'HTTP_IF_NONE_MATCH'", "]", ")", "&&", "$", "_SERVER", "[", "'HTTP_IF_NONE_MATCH'", "]", "==", "$", "ETag", ")", "{", "header", "(", "'HTTP/1.1 304 Not Modified'", ")", ";", "header", "(", "'Content-Length: '", ".", "$", "fileSize", ")", ";", "exit", ";", "}", "$", "expires", "=", "604800", ";", "// (60*60*24*7)\r", "header", "(", "'ETag: '", ".", "$", "ETag", ")", ";", "header", "(", "'Last-Modified: '", ".", "gmdate", "(", "'D, d M Y H:i:s'", ",", "time", "(", ")", ")", ".", "' GMT'", ")", ";", "header", "(", "'Expires:'", ".", "gmdate", "(", "'D, d M Y H:i:s'", ",", "time", "(", ")", "+", "$", "expires", ")", ".", "' GMT'", ")", ";", "// Open file\r", "// @readfile($file_path);\r", "$", "file", "=", "@", "fopen", "(", "$", "filename", ",", "\"rb\"", ")", ";", "if", "(", "$", "file", ")", "{", "while", "(", "!", "feof", "(", "$", "file", ")", ")", "{", "print", "(", "fread", "(", "$", "file", ",", "1024", "*", "8", ")", ")", ";", "flush", "(", ")", ";", "if", "(", "connection_status", "(", ")", "!=", "0", ")", "{", "@", "fclose", "(", "$", "file", ")", ";", "die", "(", ")", ";", "}", "}", "@", "fclose", "(", "$", "file", ")", ";", "}", "}" ]
File::show Show file with header. @return void
[ "File", "::", "show" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L202-L255
o2system/filesystem
src/File.php
File.getMime
public function getMime() { $mimes = $this->getMimes(); $ext = strtolower($this->getExtension()); if (isset($mimes[ $ext ])) { return $mimes[ $ext ]; } return false; }
php
public function getMime() { $mimes = $this->getMimes(); $ext = strtolower($this->getExtension()); if (isset($mimes[ $ext ])) { return $mimes[ $ext ]; } return false; }
[ "public", "function", "getMime", "(", ")", "{", "$", "mimes", "=", "$", "this", "->", "getMimes", "(", ")", ";", "$", "ext", "=", "strtolower", "(", "$", "this", "->", "getExtension", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "mimes", "[", "$", "ext", "]", ")", ")", "{", "return", "$", "mimes", "[", "$", "ext", "]", ";", "}", "return", "false", ";", "}" ]
File::getMime Get mime info based on MIME config. @return bool|string|array
[ "File", "::", "getMime" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L266-L276
o2system/filesystem
src/File.php
File.read
public function read($useIncludePath = false, $context = null) { $params[] = $this->getRealPath(); $params[] = $useIncludePath; $params[] = $context; return call_user_func_array('readfile', $params); }
php
public function read($useIncludePath = false, $context = null) { $params[] = $this->getRealPath(); $params[] = $useIncludePath; $params[] = $context; return call_user_func_array('readfile', $params); }
[ "public", "function", "read", "(", "$", "useIncludePath", "=", "false", ",", "$", "context", "=", "null", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "$", "useIncludePath", ";", "$", "params", "[", "]", "=", "$", "context", ";", "return", "call_user_func_array", "(", "'readfile'", ",", "$", "params", ")", ";", "}" ]
File::read Outputs a file. @param bool $useIncludePath You can use the optional second parameter and set it to TRUE, if you want to search for the file in the include_path, too. @param resource $context A context stream resource. @return int Returns the number of bytes read from the file. If an error occurs, FALSE is returned and unless the function was called as @readfile(), an error message is printed.
[ "File", "::", "read" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L315-L322
o2system/filesystem
src/File.php
File.write
public function write($filePath, $contents, $mode = 'wb') { if (false !== ($fp = $this->create($filePath, $mode))) { flock($fp, LOCK_EX); for ($result = $written = 0, $length = strlen($contents); $written < $length; $written += $result) { if (($result = fwrite($fp, substr($contents, $written))) === false) { break; } } flock($fp, LOCK_UN); fclose($fp); return is_int($result); } return false; }
php
public function write($filePath, $contents, $mode = 'wb') { if (false !== ($fp = $this->create($filePath, $mode))) { flock($fp, LOCK_EX); for ($result = $written = 0, $length = strlen($contents); $written < $length; $written += $result) { if (($result = fwrite($fp, substr($contents, $written))) === false) { break; } } flock($fp, LOCK_UN); fclose($fp); return is_int($result); } return false; }
[ "public", "function", "write", "(", "$", "filePath", ",", "$", "contents", ",", "$", "mode", "=", "'wb'", ")", "{", "if", "(", "false", "!==", "(", "$", "fp", "=", "$", "this", "->", "create", "(", "$", "filePath", ",", "$", "mode", ")", ")", ")", "{", "flock", "(", "$", "fp", ",", "LOCK_EX", ")", ";", "for", "(", "$", "result", "=", "$", "written", "=", "0", ",", "$", "length", "=", "strlen", "(", "$", "contents", ")", ";", "$", "written", "<", "$", "length", ";", "$", "written", "+=", "$", "result", ")", "{", "if", "(", "(", "$", "result", "=", "fwrite", "(", "$", "fp", ",", "substr", "(", "$", "contents", ",", "$", "written", ")", ")", ")", "===", "false", ")", "{", "break", ";", "}", "}", "flock", "(", "$", "fp", ",", "LOCK_UN", ")", ";", "fclose", "(", "$", "fp", ")", ";", "return", "is_int", "(", "$", "result", ")", ";", "}", "return", "false", ";", "}" ]
File::write Writes a file. @param string $contents File contents to write. @param string $mode File handle mode. @return bool
[ "File", "::", "write" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L336-L354
o2system/filesystem
src/File.php
File.create
public function create($filePath = null, $mode = 'wb') { $filePath = isset($filePath) ? $filePath : $this->filePath; $dir = dirname($filePath); if ( ! is_writable($dir)) { if ( ! file_exists($dir)) { mkdir($dir, 0777, true); } } if ( ! $fp = @fopen($filePath, $mode)) { return false; } parent::__construct($filePath); return $fp; }
php
public function create($filePath = null, $mode = 'wb') { $filePath = isset($filePath) ? $filePath : $this->filePath; $dir = dirname($filePath); if ( ! is_writable($dir)) { if ( ! file_exists($dir)) { mkdir($dir, 0777, true); } } if ( ! $fp = @fopen($filePath, $mode)) { return false; } parent::__construct($filePath); return $fp; }
[ "public", "function", "create", "(", "$", "filePath", "=", "null", ",", "$", "mode", "=", "'wb'", ")", "{", "$", "filePath", "=", "isset", "(", "$", "filePath", ")", "?", "$", "filePath", ":", "$", "this", "->", "filePath", ";", "$", "dir", "=", "dirname", "(", "$", "filePath", ")", ";", "if", "(", "!", "is_writable", "(", "$", "dir", ")", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "}", "}", "if", "(", "!", "$", "fp", "=", "@", "fopen", "(", "$", "filePath", ",", "$", "mode", ")", ")", "{", "return", "false", ";", "}", "parent", "::", "__construct", "(", "$", "filePath", ")", ";", "return", "$", "fp", ";", "}" ]
File::create Create a File @param string|null $filePath @param string $mode @return resource
[ "File", "::", "create" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L368-L386
o2system/filesystem
src/File.php
File.rename
public function rename($newFilename, $context = null) { $params[] = $this->getRealPath(); $params[] = dirname($this->getRealPath()) . DIRECTORY_SEPARATOR . $newFilename; $params[] = $context; return call_user_func_array('rename', $params); }
php
public function rename($newFilename, $context = null) { $params[] = $this->getRealPath(); $params[] = dirname($this->getRealPath()) . DIRECTORY_SEPARATOR . $newFilename; $params[] = $context; return call_user_func_array('rename', $params); }
[ "public", "function", "rename", "(", "$", "newFilename", ",", "$", "context", "=", "null", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "dirname", "(", "$", "this", "->", "getRealPath", "(", ")", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "newFilename", ";", "$", "params", "[", "]", "=", "$", "context", ";", "return", "call_user_func_array", "(", "'rename'", ",", "$", "params", ")", ";", "}" ]
File::rename Renames a file. @param string $newFilename The new filename. @param null $context Context support was added with PHP 5.0.0. For a description of contexts, refer to Streams. @return bool Returns TRUE on success or FALSE on failure.
[ "File", "::", "rename" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L401-L408
o2system/filesystem
src/File.php
File.copy
public function copy($destination, $context = null) { $params[] = $this->getRealPath(); $params[] = $destination; $params[] = $context; return call_user_func_array('copy', $params); }
php
public function copy($destination, $context = null) { $params[] = $this->getRealPath(); $params[] = $destination; $params[] = $context; return call_user_func_array('copy', $params); }
[ "public", "function", "copy", "(", "$", "destination", ",", "$", "context", "=", "null", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "$", "destination", ";", "$", "params", "[", "]", "=", "$", "context", ";", "return", "call_user_func_array", "(", "'copy'", ",", "$", "params", ")", ";", "}" ]
File::copy Makes a copy of the file source to destination. @param string $destination The destination path. If destination is a URL, the copy operation may fail if the wrapper does not support overwriting of existing files. @param resource $context A valid context resource created with stream_context_create(). @return bool Returns TRUE on success or FALSE on failure.
[ "File", "::", "copy" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L423-L430
o2system/filesystem
src/File.php
File.delete
public function delete($context = null) { $params[] = $this->getRealPath(); $params[] = $context; return call_user_func_array('unlink', $params); }
php
public function delete($context = null) { $params[] = $this->getRealPath(); $params[] = $context; return call_user_func_array('unlink', $params); }
[ "public", "function", "delete", "(", "$", "context", "=", "null", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "getRealPath", "(", ")", ";", "$", "params", "[", "]", "=", "$", "context", ";", "return", "call_user_func_array", "(", "'unlink'", ",", "$", "params", ")", ";", "}" ]
File::delete Deletes a file. @param resource $context Context support was added with PHP 5.0.0. For a description of contexts, refer to Streams. @return bool Returns TRUE on success or FALSE on failure.
[ "File", "::", "delete" ]
train
https://github.com/o2system/filesystem/blob/58f6515f56bcc92408dc155add570c99a0abb6e8/src/File.php#L444-L450
drpdigital/json-api-parser
src/RelationshipResourceFinder.php
RelationshipResourceFinder.fromRelationshipType
public function fromRelationshipType($type) { $relationships = $this->getRelationshipsThatMatchType($type); if (count($relationships) === 0) { return null; } $resource = reset($relationships); return new RelationshipResource( key($relationships), $resource ); }
php
public function fromRelationshipType($type) { $relationships = $this->getRelationshipsThatMatchType($type); if (count($relationships) === 0) { return null; } $resource = reset($relationships); return new RelationshipResource( key($relationships), $resource ); }
[ "public", "function", "fromRelationshipType", "(", "$", "type", ")", "{", "$", "relationships", "=", "$", "this", "->", "getRelationshipsThatMatchType", "(", "$", "type", ")", ";", "if", "(", "count", "(", "$", "relationships", ")", "===", "0", ")", "{", "return", "null", ";", "}", "$", "resource", "=", "reset", "(", "$", "relationships", ")", ";", "return", "new", "RelationshipResource", "(", "key", "(", "$", "relationships", ")", ",", "$", "resource", ")", ";", "}" ]
Get a resource from just the relationship type. @param string $type @return \Drp\JsonApiParser\RelationshipResource|null
[ "Get", "a", "resource", "from", "just", "the", "relationship", "type", "." ]
train
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L29-L43
drpdigital/json-api-parser
src/RelationshipResourceFinder.php
RelationshipResourceFinder.getRelationshipsThatMatchType
protected function getRelationshipsThatMatchType($type) { return array_filter( $this->mapRelationshipsToIdAndData(), function ($relationship) use ($type) { $relationshipType = Arr::get($relationship, 'type'); return Str::snakeCase($type) === Str::snakeCase($relationshipType); } ); }
php
protected function getRelationshipsThatMatchType($type) { return array_filter( $this->mapRelationshipsToIdAndData(), function ($relationship) use ($type) { $relationshipType = Arr::get($relationship, 'type'); return Str::snakeCase($type) === Str::snakeCase($relationshipType); } ); }
[ "protected", "function", "getRelationshipsThatMatchType", "(", "$", "type", ")", "{", "return", "array_filter", "(", "$", "this", "->", "mapRelationshipsToIdAndData", "(", ")", ",", "function", "(", "$", "relationship", ")", "use", "(", "$", "type", ")", "{", "$", "relationshipType", "=", "Arr", "::", "get", "(", "$", "relationship", ",", "'type'", ")", ";", "return", "Str", "::", "snakeCase", "(", "$", "type", ")", "===", "Str", "::", "snakeCase", "(", "$", "relationshipType", ")", ";", "}", ")", ";", "}" ]
Get all the relationships that their type matches the given type. @param string $type @return array|mixed
[ "Get", "all", "the", "relationships", "that", "their", "type", "matches", "the", "given", "type", "." ]
train
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L51-L61
drpdigital/json-api-parser
src/RelationshipResourceFinder.php
RelationshipResourceFinder.fromFullyQualifiedRelationships
public function fromFullyQualifiedRelationships(array $relationshipNames) { foreach ($relationshipNames as $relationshipName) { $relationship = $this->getRelationshipResourceForReference($relationshipName); if ($relationship !== null) { return $relationship; } } return null; }
php
public function fromFullyQualifiedRelationships(array $relationshipNames) { foreach ($relationshipNames as $relationshipName) { $relationship = $this->getRelationshipResourceForReference($relationshipName); if ($relationship !== null) { return $relationship; } } return null; }
[ "public", "function", "fromFullyQualifiedRelationships", "(", "array", "$", "relationshipNames", ")", "{", "foreach", "(", "$", "relationshipNames", "as", "$", "relationshipName", ")", "{", "$", "relationship", "=", "$", "this", "->", "getRelationshipResourceForReference", "(", "$", "relationshipName", ")", ";", "if", "(", "$", "relationship", "!==", "null", ")", "{", "return", "$", "relationship", ";", "}", "}", "return", "null", ";", "}" ]
Get a relationship resource from one of the fully qualified relationship referneces. E.g. ['test.test-relationship.test-child'] @param array $relationshipNames @return \Drp\JsonApiParser\RelationshipResource|null
[ "Get", "a", "relationship", "resource", "from", "one", "of", "the", "fully", "qualified", "relationship", "referneces", ".", "E", ".", "g", ".", "[", "test", ".", "test", "-", "relationship", ".", "test", "-", "child", "]" ]
train
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L70-L81
drpdigital/json-api-parser
src/RelationshipResourceFinder.php
RelationshipResourceFinder.getRelationshipResourceForReference
protected function getRelationshipResourceForReference($fullRelationshipReference) { $relationshipParts = explode('.', $fullRelationshipReference); if (count($relationshipParts) !== 3) { return null; } if ($this->resourceType() !== array_shift($relationshipParts)) { return null; } $relationshipName = array_shift($relationshipParts); $relationshipReference = Arr::get( $this->mapRelationshipsToIdAndData(), $relationshipName ); if ($relationshipReference === null) { return null; } if (Arr::get($relationshipReference, 'type') === array_shift($relationshipParts)) { return new RelationshipResource($relationshipName, $relationshipReference); } return null; }
php
protected function getRelationshipResourceForReference($fullRelationshipReference) { $relationshipParts = explode('.', $fullRelationshipReference); if (count($relationshipParts) !== 3) { return null; } if ($this->resourceType() !== array_shift($relationshipParts)) { return null; } $relationshipName = array_shift($relationshipParts); $relationshipReference = Arr::get( $this->mapRelationshipsToIdAndData(), $relationshipName ); if ($relationshipReference === null) { return null; } if (Arr::get($relationshipReference, 'type') === array_shift($relationshipParts)) { return new RelationshipResource($relationshipName, $relationshipReference); } return null; }
[ "protected", "function", "getRelationshipResourceForReference", "(", "$", "fullRelationshipReference", ")", "{", "$", "relationshipParts", "=", "explode", "(", "'.'", ",", "$", "fullRelationshipReference", ")", ";", "if", "(", "count", "(", "$", "relationshipParts", ")", "!==", "3", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "resourceType", "(", ")", "!==", "array_shift", "(", "$", "relationshipParts", ")", ")", "{", "return", "null", ";", "}", "$", "relationshipName", "=", "array_shift", "(", "$", "relationshipParts", ")", ";", "$", "relationshipReference", "=", "Arr", "::", "get", "(", "$", "this", "->", "mapRelationshipsToIdAndData", "(", ")", ",", "$", "relationshipName", ")", ";", "if", "(", "$", "relationshipReference", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "Arr", "::", "get", "(", "$", "relationshipReference", ",", "'type'", ")", "===", "array_shift", "(", "$", "relationshipParts", ")", ")", "{", "return", "new", "RelationshipResource", "(", "$", "relationshipName", ",", "$", "relationshipReference", ")", ";", "}", "return", "null", ";", "}" ]
Get a relationship resource for a fully qualified reference. @param string $fullRelationshipReference @return \Drp\JsonApiParser\RelationshipResource|null
[ "Get", "a", "relationship", "resource", "for", "a", "fully", "qualified", "reference", "." ]
train
https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L89-L115
Konstantin-Vl/yii2-ulogin-widget
UloginWidget.php
UloginWidget.setStateListener
public function setStateListener($event, $listener) { $js = sprintf( 'uLogin.setStateListener("%s", "%s", %s);', $this->id, $event, $listener ); $this->getView()->registerJs($js); return $this; }
php
public function setStateListener($event, $listener) { $js = sprintf( 'uLogin.setStateListener("%s", "%s", %s);', $this->id, $event, $listener ); $this->getView()->registerJs($js); return $this; }
[ "public", "function", "setStateListener", "(", "$", "event", ",", "$", "listener", ")", "{", "$", "js", "=", "sprintf", "(", "'uLogin.setStateListener(\"%s\", \"%s\", %s);'", ",", "$", "this", "->", "id", ",", "$", "event", ",", "$", "listener", ")", ";", "$", "this", "->", "getView", "(", ")", "->", "registerJs", "(", "$", "js", ")", ";", "return", "$", "this", ";", "}" ]
Sets the event handler in the event ulogin @param string $event Js event name @param string $listener Js event handler @return $this @see https://ulogin.ru/help.php#listeners
[ "Sets", "the", "event", "handler", "in", "the", "event", "ulogin" ]
train
https://github.com/Konstantin-Vl/yii2-ulogin-widget/blob/b562b671dbb71926941df148d0d3d5a169a7b489/UloginWidget.php#L110-L121
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/HttpClient/SymfonyHttpClient.php
SymfonyHttpClient.get
public function get($uri, array $params = array()) { $request = HttpFoundation\Request::create($uri, 'GET', $params); $uri = $request->getUri(); $ch = $this->initCurlHandler($uri); return $this->makeRequest($ch); }
php
public function get($uri, array $params = array()) { $request = HttpFoundation\Request::create($uri, 'GET', $params); $uri = $request->getUri(); $ch = $this->initCurlHandler($uri); return $this->makeRequest($ch); }
[ "public", "function", "get", "(", "$", "uri", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "request", "=", "HttpFoundation", "\\", "Request", "::", "create", "(", "$", "uri", ",", "'GET'", ",", "$", "params", ")", ";", "$", "uri", "=", "$", "request", "->", "getUri", "(", ")", ";", "$", "ch", "=", "$", "this", "->", "initCurlHandler", "(", "$", "uri", ")", ";", "return", "$", "this", "->", "makeRequest", "(", "$", "ch", ")", ";", "}" ]
(non-PHPdoc) @see \TheTwelve\Foursquare.HttpClient::get()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/HttpClient/SymfonyHttpClient.php#L14-L23
devhelp/piwik-api
src/Method/Method.php
Method.call
public function call(array $params) { $this->initResolver(); /** * makes sure that 'format' is passed and that 'API' and 'method' * parameters are not overwritten by defaults nor by call parameters */ $defaults = array_merge(array('format' => $this->format), $this->defaultParams); $this->resolver->setDefaults($defaults); $this->resolver->setMandatory(array( 'module' => 'API', 'method' => $this->name() )); return $this->piwikClient->call($this->url(), $this->resolver->resolve($params)); }
php
public function call(array $params) { $this->initResolver(); /** * makes sure that 'format' is passed and that 'API' and 'method' * parameters are not overwritten by defaults nor by call parameters */ $defaults = array_merge(array('format' => $this->format), $this->defaultParams); $this->resolver->setDefaults($defaults); $this->resolver->setMandatory(array( 'module' => 'API', 'method' => $this->name() )); return $this->piwikClient->call($this->url(), $this->resolver->resolve($params)); }
[ "public", "function", "call", "(", "array", "$", "params", ")", "{", "$", "this", "->", "initResolver", "(", ")", ";", "/**\n * makes sure that 'format' is passed and that 'API' and 'method'\n * parameters are not overwritten by defaults nor by call parameters\n */", "$", "defaults", "=", "array_merge", "(", "array", "(", "'format'", "=>", "$", "this", "->", "format", ")", ",", "$", "this", "->", "defaultParams", ")", ";", "$", "this", "->", "resolver", "->", "setDefaults", "(", "$", "defaults", ")", ";", "$", "this", "->", "resolver", "->", "setMandatory", "(", "array", "(", "'module'", "=>", "'API'", ",", "'method'", "=>", "$", "this", "->", "name", "(", ")", ")", ")", ";", "return", "$", "this", "->", "piwikClient", "->", "call", "(", "$", "this", "->", "url", "(", ")", ",", "$", "this", "->", "resolver", "->", "resolve", "(", "$", "params", ")", ")", ";", "}" ]
calls piwik api @param array $params @return ResponseInterface
[ "calls", "piwik", "api" ]
train
https://github.com/devhelp/piwik-api/blob/b50569fac9736a87be48228d8a336a84418be8da/src/Method/Method.php#L79-L95
bocharsky-bw/FileNamingResolver
src/NamingStrategy/CallbackNamingStrategy.php
CallbackNamingStrategy.provideName
public function provideName(FileInfo $srcFileInfo) { $func = $this->callback; $dstFileInfo = $func($srcFileInfo); if (!$dstFileInfo instanceof FileInfo) { throw new \RuntimeException( sprintf('Callback naming strategy should return an instance of FileNamingResolver\FileInfo class') ); } return $dstFileInfo; }
php
public function provideName(FileInfo $srcFileInfo) { $func = $this->callback; $dstFileInfo = $func($srcFileInfo); if (!$dstFileInfo instanceof FileInfo) { throw new \RuntimeException( sprintf('Callback naming strategy should return an instance of FileNamingResolver\FileInfo class') ); } return $dstFileInfo; }
[ "public", "function", "provideName", "(", "FileInfo", "$", "srcFileInfo", ")", "{", "$", "func", "=", "$", "this", "->", "callback", ";", "$", "dstFileInfo", "=", "$", "func", "(", "$", "srcFileInfo", ")", ";", "if", "(", "!", "$", "dstFileInfo", "instanceof", "FileInfo", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Callback naming strategy should return an instance of FileNamingResolver\\FileInfo class'", ")", ")", ";", "}", "return", "$", "dstFileInfo", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/bocharsky-bw/FileNamingResolver/blob/0a0fe86fee0e7acf1ab43a84c1abd51954ce2fbe/src/NamingStrategy/CallbackNamingStrategy.php#L28-L40
awesomite/chariot
src/Pattern/PatternRouter.php
PatternRouter.matchKeyValue
private function matchKeyValue(string $path, array $methods) { foreach ($methods as $method) { $keyValue = $this->keyValueRoutes[$method][$path] ?? null; if (!\is_null($keyValue)) { list($handler, $extraParams) = $keyValue; return new InternalRoute($handler, $extraParams); } } return null; }
php
private function matchKeyValue(string $path, array $methods) { foreach ($methods as $method) { $keyValue = $this->keyValueRoutes[$method][$path] ?? null; if (!\is_null($keyValue)) { list($handler, $extraParams) = $keyValue; return new InternalRoute($handler, $extraParams); } } return null; }
[ "private", "function", "matchKeyValue", "(", "string", "$", "path", ",", "array", "$", "methods", ")", "{", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "keyValue", "=", "$", "this", "->", "keyValueRoutes", "[", "$", "method", "]", "[", "$", "path", "]", "??", "null", ";", "if", "(", "!", "\\", "is_null", "(", "$", "keyValue", ")", ")", "{", "list", "(", "$", "handler", ",", "$", "extraParams", ")", "=", "$", "keyValue", ";", "return", "new", "InternalRoute", "(", "$", "handler", ",", "$", "extraParams", ")", ";", "}", "}", "return", "null", ";", "}" ]
@param string $path @param array $methods @return InternalRouteInterface|null
[ "@param", "string", "$path", "@param", "array", "$methods" ]
train
https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/PatternRouter.php#L303-L315
awesomite/chariot
src/Pattern/PatternRouter.php
PatternRouter.matchSequentiallyForMethods
private function matchSequentiallyForMethods(array $methods, string $path) { if ($result = $this->matchKeyValue($path, $methods)) { return $result; } foreach ($methods as $currentMethod) { foreach ($this->routes[$currentMethod] ?? [] as $handler => $handlerData) { foreach ($handlerData as list($patternRoute, $extraParams)) { /** @var PatternRoute $patternRoute */ /** @var array $extraParams */ if ($patternRoute->match($path, $queryParams)) { return new InternalRoute($handler, \array_replace($extraParams, $queryParams)); } } } } return null; }
php
private function matchSequentiallyForMethods(array $methods, string $path) { if ($result = $this->matchKeyValue($path, $methods)) { return $result; } foreach ($methods as $currentMethod) { foreach ($this->routes[$currentMethod] ?? [] as $handler => $handlerData) { foreach ($handlerData as list($patternRoute, $extraParams)) { /** @var PatternRoute $patternRoute */ /** @var array $extraParams */ if ($patternRoute->match($path, $queryParams)) { return new InternalRoute($handler, \array_replace($extraParams, $queryParams)); } } } } return null; }
[ "private", "function", "matchSequentiallyForMethods", "(", "array", "$", "methods", ",", "string", "$", "path", ")", "{", "if", "(", "$", "result", "=", "$", "this", "->", "matchKeyValue", "(", "$", "path", ",", "$", "methods", ")", ")", "{", "return", "$", "result", ";", "}", "foreach", "(", "$", "methods", "as", "$", "currentMethod", ")", "{", "foreach", "(", "$", "this", "->", "routes", "[", "$", "currentMethod", "]", "??", "[", "]", "as", "$", "handler", "=>", "$", "handlerData", ")", "{", "foreach", "(", "$", "handlerData", "as", "list", "(", "$", "patternRoute", ",", "$", "extraParams", ")", ")", "{", "/** @var PatternRoute $patternRoute */", "/** @var array $extraParams */", "if", "(", "$", "patternRoute", "->", "match", "(", "$", "path", ",", "$", "queryParams", ")", ")", "{", "return", "new", "InternalRoute", "(", "$", "handler", ",", "\\", "array_replace", "(", "$", "extraParams", ",", "$", "queryParams", ")", ")", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
@param array $methods @param string $path @return InternalRouteInterface|null
[ "@param", "array", "$methods", "@param", "string", "$path" ]
train
https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/PatternRouter.php#L356-L375
awesomite/chariot
src/Pattern/PatternRouter.php
PatternRouter.matchTreeForMethods
private function matchTreeForMethods(array $methods, string $path) { if ($result = $this->matchKeyValue($path, $methods)) { return $result; } $nodesPointer = &$this->nodesTree; $chars = \str_split($path); while (true) { $candidates = \array_merge( $nodesPointer['regex'] ?? [], $nodesPointer['all'] ?? [] ); foreach ($candidates as list($route, $handler, $params, $method)) { if (!\in_array($method, $methods, true)) { continue; } /** @var PatternRoute $route */ if ($route->match($path, $queryParams)) { return new InternalRoute($handler, \array_replace($params, $queryParams)); } } $char = \array_shift($chars); if (!\is_string($char) || !isset($nodesPointer[$char])) { break; } $nodesPointer = &$nodesPointer[$char]; } return null; }
php
private function matchTreeForMethods(array $methods, string $path) { if ($result = $this->matchKeyValue($path, $methods)) { return $result; } $nodesPointer = &$this->nodesTree; $chars = \str_split($path); while (true) { $candidates = \array_merge( $nodesPointer['regex'] ?? [], $nodesPointer['all'] ?? [] ); foreach ($candidates as list($route, $handler, $params, $method)) { if (!\in_array($method, $methods, true)) { continue; } /** @var PatternRoute $route */ if ($route->match($path, $queryParams)) { return new InternalRoute($handler, \array_replace($params, $queryParams)); } } $char = \array_shift($chars); if (!\is_string($char) || !isset($nodesPointer[$char])) { break; } $nodesPointer = &$nodesPointer[$char]; } return null; }
[ "private", "function", "matchTreeForMethods", "(", "array", "$", "methods", ",", "string", "$", "path", ")", "{", "if", "(", "$", "result", "=", "$", "this", "->", "matchKeyValue", "(", "$", "path", ",", "$", "methods", ")", ")", "{", "return", "$", "result", ";", "}", "$", "nodesPointer", "=", "&", "$", "this", "->", "nodesTree", ";", "$", "chars", "=", "\\", "str_split", "(", "$", "path", ")", ";", "while", "(", "true", ")", "{", "$", "candidates", "=", "\\", "array_merge", "(", "$", "nodesPointer", "[", "'regex'", "]", "??", "[", "]", ",", "$", "nodesPointer", "[", "'all'", "]", "??", "[", "]", ")", ";", "foreach", "(", "$", "candidates", "as", "list", "(", "$", "route", ",", "$", "handler", ",", "$", "params", ",", "$", "method", ")", ")", "{", "if", "(", "!", "\\", "in_array", "(", "$", "method", ",", "$", "methods", ",", "true", ")", ")", "{", "continue", ";", "}", "/** @var PatternRoute $route */", "if", "(", "$", "route", "->", "match", "(", "$", "path", ",", "$", "queryParams", ")", ")", "{", "return", "new", "InternalRoute", "(", "$", "handler", ",", "\\", "array_replace", "(", "$", "params", ",", "$", "queryParams", ")", ")", ";", "}", "}", "$", "char", "=", "\\", "array_shift", "(", "$", "chars", ")", ";", "if", "(", "!", "\\", "is_string", "(", "$", "char", ")", "||", "!", "isset", "(", "$", "nodesPointer", "[", "$", "char", "]", ")", ")", "{", "break", ";", "}", "$", "nodesPointer", "=", "&", "$", "nodesPointer", "[", "$", "char", "]", ";", "}", "return", "null", ";", "}" ]
@param array $methods @param string $path @return InternalRouteInterface|null
[ "@param", "array", "$methods", "@param", "string", "$path" ]
train
https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/PatternRouter.php#L398-L431
prooph/event-store-zf2-adapter
src/Zf2EventStoreAdapter.php
Zf2EventStoreAdapter.dropSchemaFor
public function dropSchemaFor(StreamName $streamName, $returnSql = false) { $dropTable = new DropTable($this->getTable($streamName)); if ($returnSql) { return $dropTable->getSqlString($this->dbAdapter->getPlatform()); } $this->dbAdapter->getDriver() ->getConnection() ->execute($dropTable->getSqlString($this->dbAdapter->getPlatform())); }
php
public function dropSchemaFor(StreamName $streamName, $returnSql = false) { $dropTable = new DropTable($this->getTable($streamName)); if ($returnSql) { return $dropTable->getSqlString($this->dbAdapter->getPlatform()); } $this->dbAdapter->getDriver() ->getConnection() ->execute($dropTable->getSqlString($this->dbAdapter->getPlatform())); }
[ "public", "function", "dropSchemaFor", "(", "StreamName", "$", "streamName", ",", "$", "returnSql", "=", "false", ")", "{", "$", "dropTable", "=", "new", "DropTable", "(", "$", "this", "->", "getTable", "(", "$", "streamName", ")", ")", ";", "if", "(", "$", "returnSql", ")", "{", "return", "$", "dropTable", "->", "getSqlString", "(", "$", "this", "->", "dbAdapter", "->", "getPlatform", "(", ")", ")", ";", "}", "$", "this", "->", "dbAdapter", "->", "getDriver", "(", ")", "->", "getConnection", "(", ")", "->", "execute", "(", "$", "dropTable", "->", "getSqlString", "(", "$", "this", "->", "dbAdapter", "->", "getPlatform", "(", ")", ")", ")", ";", "}" ]
Drops a stream table Use this function with caution. All your events will be lost! But it can be useful in migration scenarios. @param StreamName $streamName @param bool $returnSql @return string|null Whether $returnSql is true or not function will return generated sql or execute it directly
[ "Drops", "a", "stream", "table" ]
train
https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L256-L267
prooph/event-store-zf2-adapter
src/Zf2EventStoreAdapter.php
Zf2EventStoreAdapter.insertEvent
protected function insertEvent(StreamName $streamName, DomainEvent $e) { $eventData = array( 'event_id' => $e->uuid()->toString(), 'version' => $e->version(), 'event_name' => $e->messageName(), 'event_class' => get_class($e), 'payload' => Serializer::serialize($e->payload(), $this->serializerAdapter), 'created_at' => $e->createdAt()->format(\DateTime::ISO8601) ); foreach ($e->metadata() as $key => $value) { $eventData[$key] = (string)$value; } $tableGateway = $this->getTablegateway($streamName); $tableGateway->insert($eventData); }
php
protected function insertEvent(StreamName $streamName, DomainEvent $e) { $eventData = array( 'event_id' => $e->uuid()->toString(), 'version' => $e->version(), 'event_name' => $e->messageName(), 'event_class' => get_class($e), 'payload' => Serializer::serialize($e->payload(), $this->serializerAdapter), 'created_at' => $e->createdAt()->format(\DateTime::ISO8601) ); foreach ($e->metadata() as $key => $value) { $eventData[$key] = (string)$value; } $tableGateway = $this->getTablegateway($streamName); $tableGateway->insert($eventData); }
[ "protected", "function", "insertEvent", "(", "StreamName", "$", "streamName", ",", "DomainEvent", "$", "e", ")", "{", "$", "eventData", "=", "array", "(", "'event_id'", "=>", "$", "e", "->", "uuid", "(", ")", "->", "toString", "(", ")", ",", "'version'", "=>", "$", "e", "->", "version", "(", ")", ",", "'event_name'", "=>", "$", "e", "->", "messageName", "(", ")", ",", "'event_class'", "=>", "get_class", "(", "$", "e", ")", ",", "'payload'", "=>", "Serializer", "::", "serialize", "(", "$", "e", "->", "payload", "(", ")", ",", "$", "this", "->", "serializerAdapter", ")", ",", "'created_at'", "=>", "$", "e", "->", "createdAt", "(", ")", "->", "format", "(", "\\", "DateTime", "::", "ISO8601", ")", ")", ";", "foreach", "(", "$", "e", "->", "metadata", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "eventData", "[", "$", "key", "]", "=", "(", "string", ")", "$", "value", ";", "}", "$", "tableGateway", "=", "$", "this", "->", "getTablegateway", "(", "$", "streamName", ")", ";", "$", "tableGateway", "->", "insert", "(", "$", "eventData", ")", ";", "}" ]
Insert an event @param StreamName $streamName @param DomainEvent $e @return void
[ "Insert", "an", "event" ]
train
https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L276-L294
prooph/event-store-zf2-adapter
src/Zf2EventStoreAdapter.php
Zf2EventStoreAdapter.getTablegateway
protected function getTablegateway(StreamName $streamName) { if (!isset($this->tableGateways[$streamName->toString()])) { $this->tableGateways[$streamName->toString()] = new TableGateway($this->getTable($streamName), $this->dbAdapter); } return $this->tableGateways[$streamName->toString()]; }
php
protected function getTablegateway(StreamName $streamName) { if (!isset($this->tableGateways[$streamName->toString()])) { $this->tableGateways[$streamName->toString()] = new TableGateway($this->getTable($streamName), $this->dbAdapter); } return $this->tableGateways[$streamName->toString()]; }
[ "protected", "function", "getTablegateway", "(", "StreamName", "$", "streamName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "tableGateways", "[", "$", "streamName", "->", "toString", "(", ")", "]", ")", ")", "{", "$", "this", "->", "tableGateways", "[", "$", "streamName", "->", "toString", "(", ")", "]", "=", "new", "TableGateway", "(", "$", "this", "->", "getTable", "(", "$", "streamName", ")", ",", "$", "this", "->", "dbAdapter", ")", ";", "}", "return", "$", "this", "->", "tableGateways", "[", "$", "streamName", "->", "toString", "(", ")", "]", ";", "}" ]
Get the corresponding Tablegateway of the given stream name @param StreamName $streamName @return TableGateway
[ "Get", "the", "corresponding", "Tablegateway", "of", "the", "given", "stream", "name" ]
train
https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L303-L310
prooph/event-store-zf2-adapter
src/Zf2EventStoreAdapter.php
Zf2EventStoreAdapter.getTable
protected function getTable(StreamName $streamName) { if (isset($this->streamTableMap[$streamName->toString()])) { $tableName = $this->streamTableMap[$streamName->toString()]; } else { $tableName = strtolower($this->getShortStreamName($streamName)); if (strpos($tableName, "_stream") === false) { $tableName.= "_stream"; } } return $tableName; }
php
protected function getTable(StreamName $streamName) { if (isset($this->streamTableMap[$streamName->toString()])) { $tableName = $this->streamTableMap[$streamName->toString()]; } else { $tableName = strtolower($this->getShortStreamName($streamName)); if (strpos($tableName, "_stream") === false) { $tableName.= "_stream"; } } return $tableName; }
[ "protected", "function", "getTable", "(", "StreamName", "$", "streamName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "streamTableMap", "[", "$", "streamName", "->", "toString", "(", ")", "]", ")", ")", "{", "$", "tableName", "=", "$", "this", "->", "streamTableMap", "[", "$", "streamName", "->", "toString", "(", ")", "]", ";", "}", "else", "{", "$", "tableName", "=", "strtolower", "(", "$", "this", "->", "getShortStreamName", "(", "$", "streamName", ")", ")", ";", "if", "(", "strpos", "(", "$", "tableName", ",", "\"_stream\"", ")", "===", "false", ")", "{", "$", "tableName", ".=", "\"_stream\"", ";", "}", "}", "return", "$", "tableName", ";", "}" ]
Get table name for given stream name @param StreamName $streamName @return string
[ "Get", "table", "name", "for", "given", "stream", "name" ]
train
https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L318-L331
activecollab/databasestructure
src/Association/HasOneAssociation.php
HasOneAssociation.buildClassMethods
public function buildClassMethods(StructureInterface $structure, TypeInterface $source_type, TypeInterface $target_type, array &$result) { $namespace = $structure->getNamespace(); if ($namespace) { $namespace = '\\' . ltrim($namespace, '\\'); } $target_instance_class = $namespace . '\\' . Inflector::classify(Inflector::singularize($target_type->getName())); $classified_association_name = Inflector::classify($this->getName()); $getter_name = "get{$classified_association_name}"; $setter_name = "set{$classified_association_name}"; $fk_getter_name = "get{$classified_association_name}Id"; $fk_setter_name = "set{$classified_association_name}Id"; $result[] = ''; $result[] = ' /**'; $result[] = ' * Return ' . Inflector::singularize($source_type->getName()) . ' ' . $this->getName() . '.'; $result[] = ' *'; $result[] = ' * @return ' . $target_instance_class; $result[] = ' */'; $result[] = ' public function ' . $getter_name . '()'; $result[] = ' {'; $result[] = ' return $this->pool->getById(' . var_export($target_instance_class, true) . ', $this->' . $fk_getter_name . '());'; $result[] = ' }'; $setter_access_level = $this->getProtectSetter() ? 'protected' : 'public'; $result[] = ''; $result[] = ' /**'; $result[] = ' * Set ' . Inflector::singularize($source_type->getName()) . ' ' . $this->getName() . '.'; $result[] = ' *'; $result[] = ' * @param ' . $target_instance_class . ' $value'; $result[] = ' * @return $this'; $result[] = ' */'; $result[] = ' ' . $setter_access_level . ' function &' . $setter_name . '(' . $target_instance_class . ' $value' . ($this->isRequired() ? '' : ' = null') . ')'; $result[] = ' {'; if ($this->isRequired()) { $result[] = ' if (empty($value) || !$value->isLoaded()) {'; $result[] = ' throw new \\InvalidArgumentException(\'Valid related instance is required\');'; $result[] = ' }'; $result[] = ''; $result[] = ' $this->' . $fk_setter_name . '($value->getId());'; $result[] = ''; $result[] = ' return $this;'; } else { $result[] = ' if (empty($value)) {'; $result[] = ' $this->' . $fk_setter_name . '(0);'; $result[] = ' } else {'; $result[] = ' $this->' . $fk_setter_name . '($value->getId());'; $result[] = ' }'; $result[] = ''; $result[] = ' return $this;'; } $result[] = ' }'; }
php
public function buildClassMethods(StructureInterface $structure, TypeInterface $source_type, TypeInterface $target_type, array &$result) { $namespace = $structure->getNamespace(); if ($namespace) { $namespace = '\\' . ltrim($namespace, '\\'); } $target_instance_class = $namespace . '\\' . Inflector::classify(Inflector::singularize($target_type->getName())); $classified_association_name = Inflector::classify($this->getName()); $getter_name = "get{$classified_association_name}"; $setter_name = "set{$classified_association_name}"; $fk_getter_name = "get{$classified_association_name}Id"; $fk_setter_name = "set{$classified_association_name}Id"; $result[] = ''; $result[] = ' /**'; $result[] = ' * Return ' . Inflector::singularize($source_type->getName()) . ' ' . $this->getName() . '.'; $result[] = ' *'; $result[] = ' * @return ' . $target_instance_class; $result[] = ' */'; $result[] = ' public function ' . $getter_name . '()'; $result[] = ' {'; $result[] = ' return $this->pool->getById(' . var_export($target_instance_class, true) . ', $this->' . $fk_getter_name . '());'; $result[] = ' }'; $setter_access_level = $this->getProtectSetter() ? 'protected' : 'public'; $result[] = ''; $result[] = ' /**'; $result[] = ' * Set ' . Inflector::singularize($source_type->getName()) . ' ' . $this->getName() . '.'; $result[] = ' *'; $result[] = ' * @param ' . $target_instance_class . ' $value'; $result[] = ' * @return $this'; $result[] = ' */'; $result[] = ' ' . $setter_access_level . ' function &' . $setter_name . '(' . $target_instance_class . ' $value' . ($this->isRequired() ? '' : ' = null') . ')'; $result[] = ' {'; if ($this->isRequired()) { $result[] = ' if (empty($value) || !$value->isLoaded()) {'; $result[] = ' throw new \\InvalidArgumentException(\'Valid related instance is required\');'; $result[] = ' }'; $result[] = ''; $result[] = ' $this->' . $fk_setter_name . '($value->getId());'; $result[] = ''; $result[] = ' return $this;'; } else { $result[] = ' if (empty($value)) {'; $result[] = ' $this->' . $fk_setter_name . '(0);'; $result[] = ' } else {'; $result[] = ' $this->' . $fk_setter_name . '($value->getId());'; $result[] = ' }'; $result[] = ''; $result[] = ' return $this;'; } $result[] = ' }'; }
[ "public", "function", "buildClassMethods", "(", "StructureInterface", "$", "structure", ",", "TypeInterface", "$", "source_type", ",", "TypeInterface", "$", "target_type", ",", "array", "&", "$", "result", ")", "{", "$", "namespace", "=", "$", "structure", "->", "getNamespace", "(", ")", ";", "if", "(", "$", "namespace", ")", "{", "$", "namespace", "=", "'\\\\'", ".", "ltrim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "}", "$", "target_instance_class", "=", "$", "namespace", ".", "'\\\\'", ".", "Inflector", "::", "classify", "(", "Inflector", "::", "singularize", "(", "$", "target_type", "->", "getName", "(", ")", ")", ")", ";", "$", "classified_association_name", "=", "Inflector", "::", "classify", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "getter_name", "=", "\"get{$classified_association_name}\"", ";", "$", "setter_name", "=", "\"set{$classified_association_name}\"", ";", "$", "fk_getter_name", "=", "\"get{$classified_association_name}Id\"", ";", "$", "fk_setter_name", "=", "\"set{$classified_association_name}Id\"", ";", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "' /**'", ";", "$", "result", "[", "]", "=", "' * Return '", ".", "Inflector", "::", "singularize", "(", "$", "source_type", "->", "getName", "(", ")", ")", ".", "' '", ".", "$", "this", "->", "getName", "(", ")", ".", "'.'", ";", "$", "result", "[", "]", "=", "' *'", ";", "$", "result", "[", "]", "=", "' * @return '", ".", "$", "target_instance_class", ";", "$", "result", "[", "]", "=", "' */'", ";", "$", "result", "[", "]", "=", "' public function '", ".", "$", "getter_name", ".", "'()'", ";", "$", "result", "[", "]", "=", "' {'", ";", "$", "result", "[", "]", "=", "' return $this->pool->getById('", ".", "var_export", "(", "$", "target_instance_class", ",", "true", ")", ".", "', $this->'", ".", "$", "fk_getter_name", ".", "'());'", ";", "$", "result", "[", "]", "=", "' }'", ";", "$", "setter_access_level", "=", "$", "this", "->", "getProtectSetter", "(", ")", "?", "'protected'", ":", "'public'", ";", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "' /**'", ";", "$", "result", "[", "]", "=", "' * Set '", ".", "Inflector", "::", "singularize", "(", "$", "source_type", "->", "getName", "(", ")", ")", ".", "' '", ".", "$", "this", "->", "getName", "(", ")", ".", "'.'", ";", "$", "result", "[", "]", "=", "' *'", ";", "$", "result", "[", "]", "=", "' * @param '", ".", "$", "target_instance_class", ".", "' $value'", ";", "$", "result", "[", "]", "=", "' * @return $this'", ";", "$", "result", "[", "]", "=", "' */'", ";", "$", "result", "[", "]", "=", "' '", ".", "$", "setter_access_level", ".", "' function &'", ".", "$", "setter_name", ".", "'('", ".", "$", "target_instance_class", ".", "' $value'", ".", "(", "$", "this", "->", "isRequired", "(", ")", "?", "''", ":", "' = null'", ")", ".", "')'", ";", "$", "result", "[", "]", "=", "' {'", ";", "if", "(", "$", "this", "->", "isRequired", "(", ")", ")", "{", "$", "result", "[", "]", "=", "' if (empty($value) || !$value->isLoaded()) {'", ";", "$", "result", "[", "]", "=", "' throw new \\\\InvalidArgumentException(\\'Valid related instance is required\\');'", ";", "$", "result", "[", "]", "=", "' }'", ";", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "' $this->'", ".", "$", "fk_setter_name", ".", "'($value->getId());'", ";", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "' return $this;'", ";", "}", "else", "{", "$", "result", "[", "]", "=", "' if (empty($value)) {'", ";", "$", "result", "[", "]", "=", "' $this->'", ".", "$", "fk_setter_name", ".", "'(0);'", ";", "$", "result", "[", "]", "=", "' } else {'", ";", "$", "result", "[", "]", "=", "' $this->'", ".", "$", "fk_setter_name", ".", "'($value->getId());'", ";", "$", "result", "[", "]", "=", "' }'", ";", "$", "result", "[", "]", "=", "''", ";", "$", "result", "[", "]", "=", "' return $this;'", ";", "}", "$", "result", "[", "]", "=", "' }'", ";", "}" ]
Build class methods. @param StructureInterface $structure @param TypeInterface $source_type @param TypeInterface $target_type @param array $result
[ "Build", "class", "methods", "." ]
train
https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Association/HasOneAssociation.php#L118-L177
stubbles/stubbles-webapp-core
src/main/php/session/id/WebBoundSessionId.php
WebBoundSessionId.read
private function read() { if ($this->request->hasParam($this->sessionName)) { return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX); } elseif ($this->request->hasCookie($this->sessionName)) { return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX); } return null; }
php
private function read() { if ($this->request->hasParam($this->sessionName)) { return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX); } elseif ($this->request->hasCookie($this->sessionName)) { return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX); } return null; }
[ "private", "function", "read", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "hasParam", "(", "$", "this", "->", "sessionName", ")", ")", "{", "return", "$", "this", "->", "request", "->", "readParam", "(", "$", "this", "->", "sessionName", ")", "->", "ifMatches", "(", "self", "::", "SESSION_ID_REGEX", ")", ";", "}", "elseif", "(", "$", "this", "->", "request", "->", "hasCookie", "(", "$", "this", "->", "sessionName", ")", ")", "{", "return", "$", "this", "->", "request", "->", "readCookie", "(", "$", "this", "->", "sessionName", ")", "->", "ifMatches", "(", "self", "::", "SESSION_ID_REGEX", ")", ";", "}", "return", "null", ";", "}" ]
reads session id @return string|null
[ "reads", "session", "id" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/id/WebBoundSessionId.php#L100-L109
stubbles/stubbles-webapp-core
src/main/php/session/id/WebBoundSessionId.php
WebBoundSessionId.regenerate
public function regenerate(): SessionId { $this->id = $this->create(); $this->response->addCookie( Cookie::create($this->sessionName, $this->id)->forPath('/') ); return $this; }
php
public function regenerate(): SessionId { $this->id = $this->create(); $this->response->addCookie( Cookie::create($this->sessionName, $this->id)->forPath('/') ); return $this; }
[ "public", "function", "regenerate", "(", ")", ":", "SessionId", "{", "$", "this", "->", "id", "=", "$", "this", "->", "create", "(", ")", ";", "$", "this", "->", "response", "->", "addCookie", "(", "Cookie", "::", "create", "(", "$", "this", "->", "sessionName", ",", "$", "this", "->", "id", ")", "->", "forPath", "(", "'/'", ")", ")", ";", "return", "$", "this", ";", "}" ]
stores session id for given session name @return \stubbles\webapp\session\id\SessionId
[ "stores", "session", "id", "for", "given", "session", "name" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/id/WebBoundSessionId.php#L126-L133
harp-orm/query
src/Compiler/Aliased.php
Aliased.render
public static function render(SQL\Aliased $aliased) { $content = $aliased->getContent(); if ($content instanceof Query\Select) { $content = "(".Select::render($content).")"; } else { $content = Compiler::name($content); } return Compiler::expression(array( $content, Compiler::word('AS', Compiler::name($aliased->getAlias())) )); }
php
public static function render(SQL\Aliased $aliased) { $content = $aliased->getContent(); if ($content instanceof Query\Select) { $content = "(".Select::render($content).")"; } else { $content = Compiler::name($content); } return Compiler::expression(array( $content, Compiler::word('AS', Compiler::name($aliased->getAlias())) )); }
[ "public", "static", "function", "render", "(", "SQL", "\\", "Aliased", "$", "aliased", ")", "{", "$", "content", "=", "$", "aliased", "->", "getContent", "(", ")", ";", "if", "(", "$", "content", "instanceof", "Query", "\\", "Select", ")", "{", "$", "content", "=", "\"(\"", ".", "Select", "::", "render", "(", "$", "content", ")", ".", "\")\"", ";", "}", "else", "{", "$", "content", "=", "Compiler", "::", "name", "(", "$", "content", ")", ";", "}", "return", "Compiler", "::", "expression", "(", "array", "(", "$", "content", ",", "Compiler", "::", "word", "(", "'AS'", ",", "Compiler", "::", "name", "(", "$", "aliased", "->", "getAlias", "(", ")", ")", ")", ")", ")", ";", "}" ]
Render SQL for Aliased @param SQL\Aliased $aliased @return string
[ "Render", "SQL", "for", "Aliased" ]
train
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Aliased.php#L33-L47
ejsmont-artur/phpProxyBuilder
src/PhpProxyBuilder/Aop/Advice/InstrumentationAdvice.php
InstrumentationAdvice.interceptMethodCall
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { $time = $this->monitor->getTime(); if ($this->namePrefix) { $name = $this->namePrefix; } else { $name = get_class($jointPoint->getTarget()); } if ($this->metricPerMethod) { $name .= '.' . $jointPoint->getMethodName(); } try { $result = $jointPoint->proceed(); $this->monitor->incrementTimer($name . self::SUFFIX_SUCCESS, $time); $this->monitor->incrementCounter($name . self::SUFFIX_SUCCESS); return $result; } catch (Exception $e) { $this->monitor->incrementTimer($name . self::SUFFIX_EXCEPTION, $time); $this->monitor->incrementCounter($name . self::SUFFIX_EXCEPTION); throw $e; } }
php
public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) { $time = $this->monitor->getTime(); if ($this->namePrefix) { $name = $this->namePrefix; } else { $name = get_class($jointPoint->getTarget()); } if ($this->metricPerMethod) { $name .= '.' . $jointPoint->getMethodName(); } try { $result = $jointPoint->proceed(); $this->monitor->incrementTimer($name . self::SUFFIX_SUCCESS, $time); $this->monitor->incrementCounter($name . self::SUFFIX_SUCCESS); return $result; } catch (Exception $e) { $this->monitor->incrementTimer($name . self::SUFFIX_EXCEPTION, $time); $this->monitor->incrementCounter($name . self::SUFFIX_EXCEPTION); throw $e; } }
[ "public", "function", "interceptMethodCall", "(", "ProceedingJoinPointInterface", "$", "jointPoint", ")", "{", "$", "time", "=", "$", "this", "->", "monitor", "->", "getTime", "(", ")", ";", "if", "(", "$", "this", "->", "namePrefix", ")", "{", "$", "name", "=", "$", "this", "->", "namePrefix", ";", "}", "else", "{", "$", "name", "=", "get_class", "(", "$", "jointPoint", "->", "getTarget", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "metricPerMethod", ")", "{", "$", "name", ".=", "'.'", ".", "$", "jointPoint", "->", "getMethodName", "(", ")", ";", "}", "try", "{", "$", "result", "=", "$", "jointPoint", "->", "proceed", "(", ")", ";", "$", "this", "->", "monitor", "->", "incrementTimer", "(", "$", "name", ".", "self", "::", "SUFFIX_SUCCESS", ",", "$", "time", ")", ";", "$", "this", "->", "monitor", "->", "incrementCounter", "(", "$", "name", ".", "self", "::", "SUFFIX_SUCCESS", ")", ";", "return", "$", "result", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "monitor", "->", "incrementTimer", "(", "$", "name", ".", "self", "::", "SUFFIX_EXCEPTION", ",", "$", "time", ")", ";", "$", "this", "->", "monitor", "->", "incrementCounter", "(", "$", "name", ".", "self", "::", "SUFFIX_EXCEPTION", ")", ";", "throw", "$", "e", ";", "}", "}" ]
In this implementation we measure time and count every method call @param ProceedingJoinPointInterface $jointPoint @return mixed
[ "In", "this", "implementation", "we", "measure", "time", "and", "count", "every", "method", "call" ]
train
https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Aop/Advice/InstrumentationAdvice.php#L85-L107
drupol/valuewrapper
src/Object/ObjectValue.php
ObjectValue.equals
public function equals(ValueInterface $item, bool $strict = true): bool { return $this->hash() === $item->hash(); }
php
public function equals(ValueInterface $item, bool $strict = true): bool { return $this->hash() === $item->hash(); }
[ "public", "function", "equals", "(", "ValueInterface", "$", "item", ",", "bool", "$", "strict", "=", "true", ")", ":", "bool", "{", "return", "$", "this", "->", "hash", "(", ")", "===", "$", "item", "->", "hash", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/drupol/valuewrapper/blob/49cc07e4d0284718c24ba6e9cf524c1f4226694e/src/Object/ObjectValue.php#L36-L39
WellCommerce/OrderBundle
DataSet/Transformer/OrderProductsTransformer.php
OrderProductsTransformer.transformValue
public function transformValue($value) { $identifiers = explode(',', $value); $criteria = new Criteria(); $criteria->where($criteria->expr()->in('id', $identifiers)); $orderProducts = $this->repository->matching($criteria); $lines = []; $orderProducts->map(function (OrderProduct $orderProduct) use (&$lines) { $product = $orderProduct->getProduct(); $fullName = $product->translate()->getName(); if ($orderProduct->hasVariant()) { foreach ($orderProduct->getOptions() as $name => $value) { $fullName .= ' - ' . $value; } } $lines[] = sprintf('%s x %s', $orderProduct->getQuantity(), $fullName); }); return implode('<br /><br />', $lines); }
php
public function transformValue($value) { $identifiers = explode(',', $value); $criteria = new Criteria(); $criteria->where($criteria->expr()->in('id', $identifiers)); $orderProducts = $this->repository->matching($criteria); $lines = []; $orderProducts->map(function (OrderProduct $orderProduct) use (&$lines) { $product = $orderProduct->getProduct(); $fullName = $product->translate()->getName(); if ($orderProduct->hasVariant()) { foreach ($orderProduct->getOptions() as $name => $value) { $fullName .= ' - ' . $value; } } $lines[] = sprintf('%s x %s', $orderProduct->getQuantity(), $fullName); }); return implode('<br /><br />', $lines); }
[ "public", "function", "transformValue", "(", "$", "value", ")", "{", "$", "identifiers", "=", "explode", "(", "','", ",", "$", "value", ")", ";", "$", "criteria", "=", "new", "Criteria", "(", ")", ";", "$", "criteria", "->", "where", "(", "$", "criteria", "->", "expr", "(", ")", "->", "in", "(", "'id'", ",", "$", "identifiers", ")", ")", ";", "$", "orderProducts", "=", "$", "this", "->", "repository", "->", "matching", "(", "$", "criteria", ")", ";", "$", "lines", "=", "[", "]", ";", "$", "orderProducts", "->", "map", "(", "function", "(", "OrderProduct", "$", "orderProduct", ")", "use", "(", "&", "$", "lines", ")", "{", "$", "product", "=", "$", "orderProduct", "->", "getProduct", "(", ")", ";", "$", "fullName", "=", "$", "product", "->", "translate", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "$", "orderProduct", "->", "hasVariant", "(", ")", ")", "{", "foreach", "(", "$", "orderProduct", "->", "getOptions", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "fullName", ".=", "' - '", ".", "$", "value", ";", "}", "}", "$", "lines", "[", "]", "=", "sprintf", "(", "'%s x %s'", ",", "$", "orderProduct", "->", "getQuantity", "(", ")", ",", "$", "fullName", ")", ";", "}", ")", ";", "return", "implode", "(", "'<br /><br />'", ",", "$", "lines", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/DataSet/Transformer/OrderProductsTransformer.php#L45-L67
crossjoin/Css
src/Crossjoin/Css/Format/Rule/ConditionAbstract.php
ConditionAbstract.setValue
protected function setValue($value) { if (is_string($value)) { $this->value = $value; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value). "' for argument 'value' given." ); } return $this; }
php
protected function setValue($value) { if (is_string($value)) { $this->value = $value; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value). "' for argument 'value' given." ); } return $this; }
[ "protected", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "this", "->", "value", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for argument 'value' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the condition value. @param string $value @return $this
[ "Sets", "the", "condition", "value", "." ]
train
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/ConditionAbstract.php#L29-L40
prooph/link-app-core
src/Service/Factory/DataLocationFactory.php
DataLocationFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); if (!is_array($config)) { throw new \RuntimeException("Expected application config to be an array. Got " . gettype($config)); } if (! isset($config['system_data_dir'])) { throw new \RuntimeException("Missing system_data_dir key in application configuration. Please add the key to your config and point it to the data directory of your application!"); } return DataLocation::fromPath($serviceLocator->get('config')['system_data_dir']); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); if (!is_array($config)) { throw new \RuntimeException("Expected application config to be an array. Got " . gettype($config)); } if (! isset($config['system_data_dir'])) { throw new \RuntimeException("Missing system_data_dir key in application configuration. Please add the key to your config and point it to the data directory of your application!"); } return DataLocation::fromPath($serviceLocator->get('config')['system_data_dir']); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'config'", ")", ";", "if", "(", "!", "is_array", "(", "$", "config", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Expected application config to be an array. Got \"", ".", "gettype", "(", "$", "config", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'system_data_dir'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Missing system_data_dir key in application configuration. Please add the key to your config and point it to the data directory of your application!\"", ")", ";", "}", "return", "DataLocation", "::", "fromPath", "(", "$", "serviceLocator", "->", "get", "(", "'config'", ")", "[", "'system_data_dir'", "]", ")", ";", "}" ]
Create service @param ServiceLocatorInterface $serviceLocator @throws \RuntimeException @return mixed
[ "Create", "service" ]
train
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Service/Factory/DataLocationFactory.php#L33-L46
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getUser
public function getUser() { $resource = '/users/' . $this->userId; $response = $this->makeAuthenticatedApiRequest($resource); return $response->user; }
php
public function getUser() { $resource = '/users/' . $this->userId; $response = $this->makeAuthenticatedApiRequest($resource); return $response->user; }
[ "public", "function", "getUser", "(", ")", "{", "$", "resource", "=", "'/users/'", ".", "$", "this", "->", "userId", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "resource", ")", ";", "return", "$", "response", "->", "user", ";", "}" ]
get a user @see https://developer.foursquare.com/docs/users/users @return \stdClass
[ "get", "a", "user" ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L39-L46
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getBadges
public function getBadges() { $uri = $this->buildUserResourceUri('badges'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->badges; }
php
public function getBadges() { $uri = $this->buildUserResourceUri('badges'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->badges; }
[ "public", "function", "getBadges", "(", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'badges'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "badges", ";", "}" ]
Returns badges for a given user. @see https://developer.foursquare.com/docs/users/badges
[ "Returns", "badges", "for", "a", "given", "user", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L96-L104
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getCheckins
public function getCheckins(array $options = array()) { $uri = $this->buildUserResourceUri('checkins'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->checkins->items; }
php
public function getCheckins(array $options = array()) { $uri = $this->buildUserResourceUri('checkins'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->checkins->items; }
[ "public", "function", "getCheckins", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'checkins'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ",", "$", "options", ")", ";", "return", "$", "response", "->", "checkins", "->", "items", ";", "}" ]
Returns a history of checkins for the authenticated user. @see https://developer.foursquare.com/docs/users/checkins @param array $options @return array
[ "Returns", "a", "history", "of", "checkins", "for", "the", "authenticated", "user", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L112-L120
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getFriends
public function getFriends(array $options = array()) { $uri = $this->buildUserResourceUri('friends'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->friends->items; }
php
public function getFriends(array $options = array()) { $uri = $this->buildUserResourceUri('friends'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->friends->items; }
[ "public", "function", "getFriends", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'friends'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ",", "$", "options", ")", ";", "return", "$", "response", "->", "friends", "->", "items", ";", "}" ]
Returns an array of a user's friends. @see https://developer.foursquare.com/docs/users/friends @param array $options
[ "Returns", "an", "array", "of", "a", "user", "s", "friends", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L127-L135
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getTips
public function getTips(array $options = array()) { $uri = $this->buildUserResourceUri('tips'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->tips->items; }
php
public function getTips(array $options = array()) { $uri = $this->buildUserResourceUri('tips'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->tips->items; }
[ "public", "function", "getTips", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'tips'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ",", "$", "options", ")", ";", "return", "$", "response", "->", "tips", "->", "items", ";", "}" ]
Returns an array of a user's tips. @see https://developer.foursquare.com/docs/users/tips @param array $options
[ "Returns", "an", "array", "of", "a", "user", "s", "tips", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L142-L150
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getLists
public function getLists(array $options = array()) { $uri = $this->buildUserResourceUri('lists'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->lists; }
php
public function getLists(array $options = array()) { $uri = $this->buildUserResourceUri('lists'); $response = $this->makeAuthenticatedApiRequest($uri, $options); return $response->lists; }
[ "public", "function", "getLists", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'lists'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ",", "$", "options", ")", ";", "return", "$", "response", "->", "lists", ";", "}" ]
A User's Lists. @see https://developer.foursquare.com/docs/users/lists @param array $options
[ "A", "User", "s", "Lists", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L157-L165
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getMayorships
public function getMayorships() { $uri = $this->buildUserResourceUri('mayorships'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->mayorships->items; }
php
public function getMayorships() { $uri = $this->buildUserResourceUri('mayorships'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->mayorships->items; }
[ "public", "function", "getMayorships", "(", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'mayorships'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "mayorships", "->", "items", ";", "}" ]
Returns a user's mayorships. @see https://developer.foursquare.com/docs/users/mayorships
[ "Returns", "a", "user", "s", "mayorships", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L171-L179
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getPhotos
public function getPhotos(array $options = array()) { $uri = $this->buildUserResourceUri('photos'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->photos->items; }
php
public function getPhotos(array $options = array()) { $uri = $this->buildUserResourceUri('photos'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->photos->items; }
[ "public", "function", "getPhotos", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'photos'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "photos", "->", "items", ";", "}" ]
Returns photos from a user. @see https://developer.foursquare.com/docs/users/photos @param array $options
[ "Returns", "photos", "from", "a", "user", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L186-L194
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.getVenueHistory
public function getVenueHistory(array $options = array()) { $uri = $this->buildUserResourceUri('venuehistory'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->venues->items; }
php
public function getVenueHistory(array $options = array()) { $uri = $this->buildUserResourceUri('venuehistory'); $response = $this->makeAuthenticatedApiRequest($uri); return $response->venues->items; }
[ "public", "function", "getVenueHistory", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'venuehistory'", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "venues", "->", "items", ";", "}" ]
Returns a list of all venues visited by the specified user, along with how many visits and when they were last there. @see https://developer.foursquare.com/docs/users/venuehistory @param array $options
[ "Returns", "a", "list", "of", "all", "venues", "visited", "by", "the", "specified", "user", "along", "with", "how", "many", "visits", "and", "when", "they", "were", "last", "there", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L202-L210
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.approve
public function approve($friendId) { $uri = $this->buildUserResourceUri('approve', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
php
public function approve($friendId) { $uri = $this->buildUserResourceUri('approve', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
[ "public", "function", "approve", "(", "$", "friendId", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'approve'", ",", "$", "friendId", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "user", ";", "}" ]
Approves a pending friend request from another user. @param string $friendId @return \stdClass
[ "Approves", "a", "pending", "friend", "request", "from", "another", "user", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L217-L225
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.deny
public function deny($friendId) { $uri = $this->buildUserResourceUri('deny', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
php
public function deny($friendId) { $uri = $this->buildUserResourceUri('deny', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
[ "public", "function", "deny", "(", "$", "friendId", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'deny'", ",", "$", "friendId", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "user", ";", "}" ]
Denies a pending friend request from another user. @param string $friendId @return \stdClass
[ "Denies", "a", "pending", "friend", "request", "from", "another", "user", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L232-L240
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.request
public function request($friendId) { $uri = $this->buildUserResourceUri('request', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
php
public function request($friendId) { $uri = $this->buildUserResourceUri('request', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
[ "public", "function", "request", "(", "$", "friendId", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'request'", ",", "$", "friendId", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "user", ";", "}" ]
Sends a friend request to another user. If the other user is a page then the requesting user will automatically start following the page. @param string $friendId @return \stdClass
[ "Sends", "a", "friend", "request", "to", "another", "user", ".", "If", "the", "other", "user", "is", "a", "page", "then", "the", "requesting", "user", "will", "automatically", "start", "following", "the", "page", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L248-L256
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/UsersGateway.php
UsersGateway.unfriend
public function unfriend($friendId) { $uri = $this->buildUserResourceUri('unfriend', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
php
public function unfriend($friendId) { $uri = $this->buildUserResourceUri('unfriend', $friendId); $response = $this->makeAuthenticatedApiRequest($uri); return $response->user; }
[ "public", "function", "unfriend", "(", "$", "friendId", ")", "{", "$", "uri", "=", "$", "this", "->", "buildUserResourceUri", "(", "'unfriend'", ",", "$", "friendId", ")", ";", "$", "response", "=", "$", "this", "->", "makeAuthenticatedApiRequest", "(", "$", "uri", ")", ";", "return", "$", "response", "->", "user", ";", "}" ]
Cancels any relationship between the acting user and the specified user Removes a friend, unfollows a celebrity, or cancels a pending friend request. @param string $friendId @return \stdClass
[ "Cancels", "any", "relationship", "between", "the", "acting", "user", "and", "the", "specified", "user", "Removes", "a", "friend", "unfollows", "a", "celebrity", "or", "cancels", "a", "pending", "friend", "request", "." ]
train
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L265-L273