repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/MetadataDrivers.php
MetadataDrivers.getDefinitionDirs
private function getDefinitionDirs(array $driverConfig, ContainerBuilder $container) { $modelDir = $this->getDefinitionDir('model', $driverConfig, $container); $mixinDir = $this->getDefinitionDir('mixin', $driverConfig, $container); $embedDir = $this->getDefinitionDir('embed', $driverConfig, $container); return [$modelDir, $mixinDir, $embedDir]; }
php
private function getDefinitionDirs(array $driverConfig, ContainerBuilder $container) { $modelDir = $this->getDefinitionDir('model', $driverConfig, $container); $mixinDir = $this->getDefinitionDir('mixin', $driverConfig, $container); $embedDir = $this->getDefinitionDir('embed', $driverConfig, $container); return [$modelDir, $mixinDir, $embedDir]; }
[ "private", "function", "getDefinitionDirs", "(", "array", "$", "driverConfig", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "modelDir", "=", "$", "this", "->", "getDefinitionDir", "(", "'model'", ",", "$", "driverConfig", ",", "$", "container", ")", ";", "$", "mixinDir", "=", "$", "this", "->", "getDefinitionDir", "(", "'mixin'", ",", "$", "driverConfig", ",", "$", "container", ")", ";", "$", "embedDir", "=", "$", "this", "->", "getDefinitionDir", "(", "'embed'", ",", "$", "driverConfig", ",", "$", "container", ")", ";", "return", "[", "$", "modelDir", ",", "$", "mixinDir", ",", "$", "embedDir", "]", ";", "}" ]
Gets the definition directories for models and mixins and returns as a tuple. @param array $driverConfig @param ContainerBuilder $container @return string[]
[ "Gets", "the", "definition", "directories", "for", "models", "and", "mixins", "and", "returns", "as", "a", "tuple", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/MetadataDrivers.php#L96-L102
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.bodyFormat
public function bodyFormat(string $format): self { return tap($this, function ($request) use ($format) { $this->bodyFormat = $format; }); }
php
public function bodyFormat(string $format): self { return tap($this, function ($request) use ($format) { $this->bodyFormat = $format; }); }
[ "public", "function", "bodyFormat", "(", "string", "$", "format", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", "$", "request", ")", "use", "(", "$", "format", ")", "{", "$", "this", "->", "bodyFormat", "=", "$", "format", ";", "}", ")", ";", "}" ]
Set the request body fomrat. @param string $format @return \BrianFaust\Http\PendingHttpRequest
[ "Set", "the", "request", "body", "fomrat", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L86-L91
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.withBaseUri
public function withBaseUri(string $uri): self { return tap($this, function ($request) use ($uri) { return $this->options = array_merge_recursive($this->options, [ 'base_uri' => $uri, ]); }); }
php
public function withBaseUri(string $uri): self { return tap($this, function ($request) use ($uri) { return $this->options = array_merge_recursive($this->options, [ 'base_uri' => $uri, ]); }); }
[ "public", "function", "withBaseUri", "(", "string", "$", "uri", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", "$", "request", ")", "use", "(", "$", "uri", ")", "{", "return", "$", "this", "->", "options", "=", "array_merge_recursive", "(", "$", "this", "->", "options", ",", "[", "'base_uri'", "=>", "$", "uri", ",", "]", ")", ";", "}", ")", ";", "}" ]
Set the base uri for all requests. @param string $uri @return \BrianFaust\Http\PendingHttpRequest
[ "Set", "the", "base", "uri", "for", "all", "requests", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L164-L171
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.withHeaders
public function withHeaders(array $headers): self { return tap($this, function ($request) use ($headers) { return $this->options = array_merge_recursive($this->options, [ 'headers' => $headers, ]); }); }
php
public function withHeaders(array $headers): self { return tap($this, function ($request) use ($headers) { return $this->options = array_merge_recursive($this->options, [ 'headers' => $headers, ]); }); }
[ "public", "function", "withHeaders", "(", "array", "$", "headers", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", "$", "request", ")", "use", "(", "$", "headers", ")", "{", "return", "$", "this", "->", "options", "=", "array_merge_recursive", "(", "$", "this", "->", "options", ",", "[", "'headers'", "=>", "$", "headers", ",", "]", ")", ";", "}", ")", ";", "}" ]
Send headers with the request. @param array $headers @return \BrianFaust\Http\PendingHttpRequest
[ "Send", "headers", "with", "the", "request", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L239-L246
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.withCookies
public function withCookies(): self { return tap($this, function ($request) { return $this->options = array_merge_recursive($this->options, [ 'cookies' => static::getCookieJar(), ]); }); }
php
public function withCookies(): self { return tap($this, function ($request) { return $this->options = array_merge_recursive($this->options, [ 'cookies' => static::getCookieJar(), ]); }); }
[ "public", "function", "withCookies", "(", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", "$", "request", ")", "{", "return", "$", "this", "->", "options", "=", "array_merge_recursive", "(", "$", "this", "->", "options", ",", "[", "'cookies'", "=>", "static", "::", "getCookieJar", "(", ")", ",", "]", ")", ";", "}", ")", ";", "}" ]
Store any cookies in a cookie jar. @return \BrianFaust\Http\PendingHttpRequest
[ "Store", "any", "cookies", "in", "a", "cookie", "jar", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L281-L288
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.withHandler
public function withHandler($handler): self { return tap($this, function ($request) use ($handler) { return $this->handler = $handler; }); }
php
public function withHandler($handler): self { return tap($this, function ($request) use ($handler) { return $this->handler = $handler; }); }
[ "public", "function", "withHandler", "(", "$", "handler", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", "$", "request", ")", "use", "(", "$", "handler", ")", "{", "return", "$", "this", "->", "handler", "=", "$", "handler", ";", "}", ")", ";", "}" ]
Handle requests with the given class. @param mixed $handler @return \BrianFaust\Http\PendingHttpRequest
[ "Handle", "requests", "with", "the", "given", "class", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L307-L312
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.timeout
public function timeout(int $seconds): self { return tap($this, function () use ($seconds) { return $this->options = array_merge_recursive($this->options, [ 'timeout' => $seconds, ]); }); }
php
public function timeout(int $seconds): self { return tap($this, function () use ($seconds) { return $this->options = array_merge_recursive($this->options, [ 'timeout' => $seconds, ]); }); }
[ "public", "function", "timeout", "(", "int", "$", "seconds", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", ")", "use", "(", "$", "seconds", ")", "{", "return", "$", "this", "->", "options", "=", "array_merge_recursive", "(", "$", "this", "->", "options", ",", "[", "'timeout'", "=>", "$", "seconds", ",", "]", ")", ";", "}", ")", ";", "}" ]
Timeout of the request in seconds. @param int $seconds @return \BrianFaust\Http\PendingHttpRequest
[ "Timeout", "of", "the", "request", "in", "seconds", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L321-L328
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.beforeSending
public function beforeSending(Closure $callback): self { return tap($this, function () use ($callback) { $this->beforeSendingCallbacks[] = $callback; }); }
php
public function beforeSending(Closure $callback): self { return tap($this, function () use ($callback) { $this->beforeSendingCallbacks[] = $callback; }); }
[ "public", "function", "beforeSending", "(", "Closure", "$", "callback", ")", ":", "self", "{", "return", "tap", "(", "$", "this", ",", "function", "(", ")", "use", "(", "$", "callback", ")", "{", "$", "this", "->", "beforeSendingCallbacks", "[", "]", "=", "$", "callback", ";", "}", ")", ";", "}" ]
Set the pre-request Callback. @param \Closure $callback @return \BrianFaust\Http\PendingHttpRequest
[ "Set", "the", "pre", "-", "request", "Callback", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L337-L342
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.post
public function post(string $url, $params = null): HttpResponse { return $this->send('POST', $url, [ $this->bodyFormat => $params, ]); }
php
public function post(string $url, $params = null): HttpResponse { return $this->send('POST', $url, [ $this->bodyFormat => $params, ]); }
[ "public", "function", "post", "(", "string", "$", "url", ",", "$", "params", "=", "null", ")", ":", "HttpResponse", "{", "return", "$", "this", "->", "send", "(", "'POST'", ",", "$", "url", ",", "[", "$", "this", "->", "bodyFormat", "=>", "$", "params", ",", "]", ")", ";", "}" ]
Create and send an Http "POST" request. @param string $url @param null|string|array $params @return \BrianFaust\Http\HttpResponse
[ "Create", "and", "send", "an", "Http", "POST", "request", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L367-L372
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.delete
public function delete(string $url, array $params = []): HttpResponse { return $this->send('DELETE', $url, [ $this->bodyFormat => $params, ]); }
php
public function delete(string $url, array $params = []): HttpResponse { return $this->send('DELETE', $url, [ $this->bodyFormat => $params, ]); }
[ "public", "function", "delete", "(", "string", "$", "url", ",", "array", "$", "params", "=", "[", "]", ")", ":", "HttpResponse", "{", "return", "$", "this", "->", "send", "(", "'DELETE'", ",", "$", "url", ",", "[", "$", "this", "->", "bodyFormat", "=>", "$", "params", ",", "]", ")", ";", "}" ]
Create and send an Http "DELETE" request. @param string $url @param array $params @return \BrianFaust\Http\HttpResponse
[ "Create", "and", "send", "an", "Http", "DELETE", "request", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L412-L417
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.send
public function send(string $method, string $url, array $options): HttpResponse { try { return new HttpResponse($this->buildClient()->request($method, $url, $this->mergeOptions([ 'query' => $this->parseQueryParams($url), ], $options))); } catch (\GuzzleHttp\Exception\ConnectException $e) { throw new Exceptions\ConnectionException($e->getMessage(), 0, $e); } }
php
public function send(string $method, string $url, array $options): HttpResponse { try { return new HttpResponse($this->buildClient()->request($method, $url, $this->mergeOptions([ 'query' => $this->parseQueryParams($url), ], $options))); } catch (\GuzzleHttp\Exception\ConnectException $e) { throw new Exceptions\ConnectionException($e->getMessage(), 0, $e); } }
[ "public", "function", "send", "(", "string", "$", "method", ",", "string", "$", "url", ",", "array", "$", "options", ")", ":", "HttpResponse", "{", "try", "{", "return", "new", "HttpResponse", "(", "$", "this", "->", "buildClient", "(", ")", "->", "request", "(", "$", "method", ",", "$", "url", ",", "$", "this", "->", "mergeOptions", "(", "[", "'query'", "=>", "$", "this", "->", "parseQueryParams", "(", "$", "url", ")", ",", "]", ",", "$", "options", ")", ")", ")", ";", "}", "catch", "(", "\\", "GuzzleHttp", "\\", "Exception", "\\", "ConnectException", "$", "e", ")", "{", "throw", "new", "Exceptions", "\\", "ConnectionException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Create and send an Http request. @param string $method @param string $url @param array $options @return \BrianFaust\Http\HttpResponse
[ "Create", "and", "send", "an", "Http", "request", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L428-L437
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.buildHandlerStack
public function buildHandlerStack(): HandlerStack { static $handler; if (!$handler) { $handler = $this->handler ?? \GuzzleHttp\choose_handler(); } if ($handler instanceof HandlerStack) { $stack = $handler; } return tap($stack ?? HandlerStack::create(), function ($stack) { $stack->push($this->buildBeforeSendingHandler()); }); }
php
public function buildHandlerStack(): HandlerStack { static $handler; if (!$handler) { $handler = $this->handler ?? \GuzzleHttp\choose_handler(); } if ($handler instanceof HandlerStack) { $stack = $handler; } return tap($stack ?? HandlerStack::create(), function ($stack) { $stack->push($this->buildBeforeSendingHandler()); }); }
[ "public", "function", "buildHandlerStack", "(", ")", ":", "HandlerStack", "{", "static", "$", "handler", ";", "if", "(", "!", "$", "handler", ")", "{", "$", "handler", "=", "$", "this", "->", "handler", "??", "\\", "GuzzleHttp", "\\", "choose_handler", "(", ")", ";", "}", "if", "(", "$", "handler", "instanceof", "HandlerStack", ")", "{", "$", "stack", "=", "$", "handler", ";", "}", "return", "tap", "(", "$", "stack", "??", "HandlerStack", "::", "create", "(", ")", ",", "function", "(", "$", "stack", ")", "{", "$", "stack", "->", "push", "(", "$", "this", "->", "buildBeforeSendingHandler", "(", ")", ")", ";", "}", ")", ";", "}" ]
Create a new Guzzle HandlerStack instance. @return \GuzzleHttp\HandlerStack
[ "Create", "a", "new", "Guzzle", "HandlerStack", "instance", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L454-L469
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.runBeforeSendingCallbacks
public function runBeforeSendingCallbacks(Request $request): Request { return tap($request, function ($request) { $this->beforeSendingCallbacks->each->__invoke(new HttpRequest($request)); }); }
php
public function runBeforeSendingCallbacks(Request $request): Request { return tap($request, function ($request) { $this->beforeSendingCallbacks->each->__invoke(new HttpRequest($request)); }); }
[ "public", "function", "runBeforeSendingCallbacks", "(", "Request", "$", "request", ")", ":", "Request", "{", "return", "tap", "(", "$", "request", ",", "function", "(", "$", "request", ")", "{", "$", "this", "->", "beforeSendingCallbacks", "->", "each", "->", "__invoke", "(", "new", "HttpRequest", "(", "$", "request", ")", ")", ";", "}", ")", ";", "}" ]
Run the pre-request callback. @param \GuzzleHttp\Psr7\Request $request @return \GuzzleHttp\Psr7\Request
[ "Run", "the", "pre", "-", "request", "callback", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L492-L497
train
faustbrian/HTTP
src/PendingHttpRequest.php
PendingHttpRequest.parseQueryParams
public function parseQueryParams(string $url): array { return tap([], function (&$query) use ($url) { parse_str(parse_url($url, PHP_URL_QUERY) ?? '', $query); }); }
php
public function parseQueryParams(string $url): array { return tap([], function (&$query) use ($url) { parse_str(parse_url($url, PHP_URL_QUERY) ?? '', $query); }); }
[ "public", "function", "parseQueryParams", "(", "string", "$", "url", ")", ":", "array", "{", "return", "tap", "(", "[", "]", ",", "function", "(", "&", "$", "query", ")", "use", "(", "$", "url", ")", "{", "parse_str", "(", "parse_url", "(", "$", "url", ",", "PHP_URL_QUERY", ")", "??", "''", ",", "$", "query", ")", ";", "}", ")", ";", "}" ]
Parse the given URL and return its query. @param string $url @return array
[ "Parse", "the", "given", "URL", "and", "return", "its", "query", "." ]
ab24b37ea211eb106237a813ec8d47ec1d4fe199
https://github.com/faustbrian/HTTP/blob/ab24b37ea211eb106237a813ec8d47ec1d4fe199/src/PendingHttpRequest.php#L518-L523
train
DavidePastore/paris-model-generator
src/DavidePastore/ParisModelGenerator/Config.php
Config.createFromComposer
public function createFromComposer($file = 'composer.json'){ $composer = $this->readComposerDotJson($file); //Default values $this->setNamespace(''); $this->setDestinationFolder('generated\\'); if(isset($composer['extra']) && isset($composer['extra']['paris-model-generator'])){ $configuration = $composer['extra']['paris-model-generator']; //Namespace if(isset($configuration['namespace'])){ $this->setNamespace($configuration['namespace']); } //Destination Folder if(isset($configuration['destination-folder'])){ $this->setDestinationFolder($configuration['destination-folder']); } } //Licenses if(isset($composer['license'])){ $licenses = $composer['license']; if(!is_array($licenses)){ $licenses = array($licenses); } //Convert to another format foreach ($licenses as $license){ $tag = array( 'name' => 'license', 'description' => $license, ); $this->addTag($tag); } } //Authors if(isset($composer['authors'])){ $authors = $composer['authors']; //Authors foreach ($authors as $author){ $tag = array( 'name' => 'author', 'description' => $author['name'] . ' <' . $author['email'] . '>', ); $this->addTag($tag); } } }
php
public function createFromComposer($file = 'composer.json'){ $composer = $this->readComposerDotJson($file); //Default values $this->setNamespace(''); $this->setDestinationFolder('generated\\'); if(isset($composer['extra']) && isset($composer['extra']['paris-model-generator'])){ $configuration = $composer['extra']['paris-model-generator']; //Namespace if(isset($configuration['namespace'])){ $this->setNamespace($configuration['namespace']); } //Destination Folder if(isset($configuration['destination-folder'])){ $this->setDestinationFolder($configuration['destination-folder']); } } //Licenses if(isset($composer['license'])){ $licenses = $composer['license']; if(!is_array($licenses)){ $licenses = array($licenses); } //Convert to another format foreach ($licenses as $license){ $tag = array( 'name' => 'license', 'description' => $license, ); $this->addTag($tag); } } //Authors if(isset($composer['authors'])){ $authors = $composer['authors']; //Authors foreach ($authors as $author){ $tag = array( 'name' => 'author', 'description' => $author['name'] . ' <' . $author['email'] . '>', ); $this->addTag($tag); } } }
[ "public", "function", "createFromComposer", "(", "$", "file", "=", "'composer.json'", ")", "{", "$", "composer", "=", "$", "this", "->", "readComposerDotJson", "(", "$", "file", ")", ";", "//Default values", "$", "this", "->", "setNamespace", "(", "''", ")", ";", "$", "this", "->", "setDestinationFolder", "(", "'generated\\\\'", ")", ";", "if", "(", "isset", "(", "$", "composer", "[", "'extra'", "]", ")", "&&", "isset", "(", "$", "composer", "[", "'extra'", "]", "[", "'paris-model-generator'", "]", ")", ")", "{", "$", "configuration", "=", "$", "composer", "[", "'extra'", "]", "[", "'paris-model-generator'", "]", ";", "//Namespace", "if", "(", "isset", "(", "$", "configuration", "[", "'namespace'", "]", ")", ")", "{", "$", "this", "->", "setNamespace", "(", "$", "configuration", "[", "'namespace'", "]", ")", ";", "}", "//Destination Folder", "if", "(", "isset", "(", "$", "configuration", "[", "'destination-folder'", "]", ")", ")", "{", "$", "this", "->", "setDestinationFolder", "(", "$", "configuration", "[", "'destination-folder'", "]", ")", ";", "}", "}", "//Licenses", "if", "(", "isset", "(", "$", "composer", "[", "'license'", "]", ")", ")", "{", "$", "licenses", "=", "$", "composer", "[", "'license'", "]", ";", "if", "(", "!", "is_array", "(", "$", "licenses", ")", ")", "{", "$", "licenses", "=", "array", "(", "$", "licenses", ")", ";", "}", "//Convert to another format", "foreach", "(", "$", "licenses", "as", "$", "license", ")", "{", "$", "tag", "=", "array", "(", "'name'", "=>", "'license'", ",", "'description'", "=>", "$", "license", ",", ")", ";", "$", "this", "->", "addTag", "(", "$", "tag", ")", ";", "}", "}", "//Authors", "if", "(", "isset", "(", "$", "composer", "[", "'authors'", "]", ")", ")", "{", "$", "authors", "=", "$", "composer", "[", "'authors'", "]", ";", "//Authors", "foreach", "(", "$", "authors", "as", "$", "author", ")", "{", "$", "tag", "=", "array", "(", "'name'", "=>", "'author'", ",", "'description'", "=>", "$", "author", "[", "'name'", "]", ".", "' <'", ".", "$", "author", "[", "'email'", "]", ".", "'>'", ",", ")", ";", "$", "this", "->", "addTag", "(", "$", "tag", ")", ";", "}", "}", "}" ]
Set parameters from the given composer.json file path. @param string $file The composer.json file path.
[ "Set", "parameters", "from", "the", "given", "composer", ".", "json", "file", "path", "." ]
cd056dd7a2218b1c56fa17dcc6311e01a2570030
https://github.com/DavidePastore/paris-model-generator/blob/cd056dd7a2218b1c56fa17dcc6311e01a2570030/src/DavidePastore/ParisModelGenerator/Config.php#L99-L151
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.cmdUpdateImageStyle
public function cmdUpdateImageStyle() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmittedList('actions'); $this->setSubmitted('update', $params[0]); $this->validateComponent('image_style'); $this->updateImageStyle($params[0]); $this->output(); }
php
public function cmdUpdateImageStyle() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmittedList('actions'); $this->setSubmitted('update', $params[0]); $this->validateComponent('image_style'); $this->updateImageStyle($params[0]); $this->output(); }
[ "public", "function", "cmdUpdateImageStyle", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getParam", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "0", "]", ")", "||", "count", "(", "$", "params", ")", "<", "2", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "params", ")", ";", "$", "this", "->", "setSubmittedList", "(", "'actions'", ")", ";", "$", "this", "->", "setSubmitted", "(", "'update'", ",", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "validateComponent", "(", "'image_style'", ")", ";", "$", "this", "->", "updateImageStyle", "(", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "imagestyle-update"
[ "Callback", "for", "imagestyle", "-", "update" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L40-L59
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.cmdDeleteImageStyle
public function cmdDeleteImageStyle() { $id = $this->getParam(0); if (empty($id) || !is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->image_style->delete($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdDeleteImageStyle() { $id = $this->getParam(0); if (empty($id) || !is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } if (!$this->image_style->delete($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdDeleteImageStyle", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "empty", "(", "$", "id", ")", "||", "!", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "image_style", "->", "delete", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "imagestyle-delete" command
[ "Callback", "for", "imagestyle", "-", "delete", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L78-L91
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.cmdClearImageStyle
public function cmdClearImageStyle() { $id = $this->getParam(0); $all = $this->getParam('all'); if (!isset($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $result = false; if (isset($id)) { if (!is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->image_style->clearCache($id); } else if (!empty($all)) { $result = $this->image_style->clearCache(); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdClearImageStyle() { $id = $this->getParam(0); $all = $this->getParam('all'); if (!isset($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $result = false; if (isset($id)) { if (!is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->image_style->clearCache($id); } else if (!empty($all)) { $result = $this->image_style->clearCache(); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdClearImageStyle", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "if", "(", "!", "isset", "(", "$", "id", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "result", "=", "false", ";", "if", "(", "isset", "(", "$", "id", ")", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "image_style", "->", "clearCache", "(", "$", "id", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "result", "=", "$", "this", "->", "image_style", "->", "clearCache", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "imagestyle-clear" command
[ "Callback", "for", "imagestyle", "-", "clear", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L96-L123
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.cmdGetImageStyle
public function cmdGetImageStyle() { $list = $this->getListImageStyle(); $this->outputFormat($list); $this->outputFormatTableImageStyle($list); $this->output(); }
php
public function cmdGetImageStyle() { $list = $this->getListImageStyle(); $this->outputFormat($list); $this->outputFormatTableImageStyle($list); $this->output(); }
[ "public", "function", "cmdGetImageStyle", "(", ")", "{", "$", "list", "=", "$", "this", "->", "getListImageStyle", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "list", ")", ";", "$", "this", "->", "outputFormatTableImageStyle", "(", "$", "list", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "imagestyle-get" command
[ "Callback", "for", "imagestyle", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L128-L134
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.submitAddImageStyle
protected function submitAddImageStyle() { $this->setSubmitted(null, $this->getParam()); $this->setSubmittedList('actions'); $this->validateComponent('image_style'); $this->addImageStyle(); }
php
protected function submitAddImageStyle() { $this->setSubmitted(null, $this->getParam()); $this->setSubmittedList('actions'); $this->validateComponent('image_style'); $this->addImageStyle(); }
[ "protected", "function", "submitAddImageStyle", "(", ")", "{", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "this", "->", "getParam", "(", ")", ")", ";", "$", "this", "->", "setSubmittedList", "(", "'actions'", ")", ";", "$", "this", "->", "validateComponent", "(", "'image_style'", ")", ";", "$", "this", "->", "addImageStyle", "(", ")", ";", "}" ]
Add an image style at once
[ "Add", "an", "image", "style", "at", "once" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L220-L226
train
gplcart/cli
controllers/commands/ImageStyle.php
ImageStyle.wizardAddImageStyle
protected function wizardAddImageStyle() { $this->validatePrompt('name', $this->text('Name'), 'image_style'); $this->validatePromptList('actions', $this->text('Actions'), 'image_style'); $this->validatePrompt('status', $this->text('Status'), 'image_style', 0); $this->setSubmittedList('actions'); $this->validateComponent('image_style'); $this->addImageStyle(); }
php
protected function wizardAddImageStyle() { $this->validatePrompt('name', $this->text('Name'), 'image_style'); $this->validatePromptList('actions', $this->text('Actions'), 'image_style'); $this->validatePrompt('status', $this->text('Status'), 'image_style', 0); $this->setSubmittedList('actions'); $this->validateComponent('image_style'); $this->addImageStyle(); }
[ "protected", "function", "wizardAddImageStyle", "(", ")", "{", "$", "this", "->", "validatePrompt", "(", "'name'", ",", "$", "this", "->", "text", "(", "'Name'", ")", ",", "'image_style'", ")", ";", "$", "this", "->", "validatePromptList", "(", "'actions'", ",", "$", "this", "->", "text", "(", "'Actions'", ")", ",", "'image_style'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'status'", ",", "$", "this", "->", "text", "(", "'Status'", ")", ",", "'image_style'", ",", "0", ")", ";", "$", "this", "->", "setSubmittedList", "(", "'actions'", ")", ";", "$", "this", "->", "validateComponent", "(", "'image_style'", ")", ";", "$", "this", "->", "addImageStyle", "(", ")", ";", "}" ]
Adds an image style step-by-step
[ "Adds", "an", "image", "style", "step", "-", "by", "-", "step" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/ImageStyle.php#L231-L240
train
oliverde8/AssociativeArraySimplified
src/AssociativeArray.php
AssociativeArray.set
public function set($key, $value) { $this->checkReadOnly(); self::setFromKey($this->data, $key, $value, $this->separator); }
php
public function set($key, $value) { $this->checkReadOnly(); self::setFromKey($this->data, $key, $value, $this->separator); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "checkReadOnly", "(", ")", ";", "self", "::", "setFromKey", "(", "$", "this", "->", "data", ",", "$", "key", ",", "$", "value", ",", "$", "this", "->", "separator", ")", ";", "}" ]
Set data inside @param string[]|string $key Key or path to the value to set (either array or string separated with the separator) @param mixed $value Value to put
[ "Set", "data", "inside" ]
aa1af7c404d62879140a76e8e9404584c7776b5f
https://github.com/oliverde8/AssociativeArraySimplified/blob/aa1af7c404d62879140a76e8e9404584c7776b5f/src/AssociativeArray.php#L82-L85
train
oliverde8/AssociativeArraySimplified
src/AssociativeArray.php
AssociativeArray.recursiveGetFromKey
private static function recursiveGetFromKey($data, $key, $default) { if (empty($key)) { return $data; } else { $currentKey = array_shift($key); return isset($data[$currentKey]) ? self::recursiveGetFromKey($data[$currentKey], $key, $default) : $default; } }
php
private static function recursiveGetFromKey($data, $key, $default) { if (empty($key)) { return $data; } else { $currentKey = array_shift($key); return isset($data[$currentKey]) ? self::recursiveGetFromKey($data[$currentKey], $key, $default) : $default; } }
[ "private", "static", "function", "recursiveGetFromKey", "(", "$", "data", ",", "$", "key", ",", "$", "default", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "data", ";", "}", "else", "{", "$", "currentKey", "=", "array_shift", "(", "$", "key", ")", ";", "return", "isset", "(", "$", "data", "[", "$", "currentKey", "]", ")", "?", "self", "::", "recursiveGetFromKey", "(", "$", "data", "[", "$", "currentKey", "]", ",", "$", "key", ",", "$", "default", ")", ":", "$", "default", ";", "}", "}" ]
Private unsecured function for getFromKey @param $data @param $key @param $default @return mixed
[ "Private", "unsecured", "function", "for", "getFromKey" ]
aa1af7c404d62879140a76e8e9404584c7776b5f
https://github.com/oliverde8/AssociativeArraySimplified/blob/aa1af7c404d62879140a76e8e9404584c7776b5f/src/AssociativeArray.php#L163-L171
train
oliverde8/AssociativeArraySimplified
src/AssociativeArray.php
AssociativeArray.setFromKey
public static function setFromKey(&$data, $key, $value, $separator = '/') { if (is_string($key)) { $key = explode($separator, $key); } $data = self::recursiveSetFromKey($data, $key, $value); }
php
public static function setFromKey(&$data, $key, $value, $separator = '/') { if (is_string($key)) { $key = explode($separator, $key); } $data = self::recursiveSetFromKey($data, $key, $value); }
[ "public", "static", "function", "setFromKey", "(", "&", "$", "data", ",", "$", "key", ",", "$", "value", ",", "$", "separator", "=", "'/'", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "key", "=", "explode", "(", "$", "separator", ",", "$", "key", ")", ";", "}", "$", "data", "=", "self", "::", "recursiveSetFromKey", "(", "$", "data", ",", "$", "key", ",", "$", "value", ")", ";", "}" ]
Set data inside an array @param array $data array to set new value in @param string[]|string $key Key or path to the value to set (either array or string separated with the separator) @param mixed $value Value to put @param string $separator separator to use with the string
[ "Set", "data", "inside", "an", "array" ]
aa1af7c404d62879140a76e8e9404584c7776b5f
https://github.com/oliverde8/AssociativeArraySimplified/blob/aa1af7c404d62879140a76e8e9404584c7776b5f/src/AssociativeArray.php#L219-L225
train
oliverde8/AssociativeArraySimplified
src/AssociativeArray.php
AssociativeArray.recursiveSetFromKey
private static function recursiveSetFromKey($data, $key, $value) { if (empty($key)) { return $value; } else { if (!is_array($data)) { $data = []; } $currentKey = array_shift($key); if (!isset($data[$currentKey])) { $data[$currentKey] = []; } $data[$currentKey] = self::recursiveSetFromKey($data[$currentKey], $key, $value); return $data; } }
php
private static function recursiveSetFromKey($data, $key, $value) { if (empty($key)) { return $value; } else { if (!is_array($data)) { $data = []; } $currentKey = array_shift($key); if (!isset($data[$currentKey])) { $data[$currentKey] = []; } $data[$currentKey] = self::recursiveSetFromKey($data[$currentKey], $key, $value); return $data; } }
[ "private", "static", "function", "recursiveSetFromKey", "(", "$", "data", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "value", ";", "}", "else", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "[", "]", ";", "}", "$", "currentKey", "=", "array_shift", "(", "$", "key", ")", ";", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "currentKey", "]", ")", ")", "{", "$", "data", "[", "$", "currentKey", "]", "=", "[", "]", ";", "}", "$", "data", "[", "$", "currentKey", "]", "=", "self", "::", "recursiveSetFromKey", "(", "$", "data", "[", "$", "currentKey", "]", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "data", ";", "}", "}" ]
Private unsecured method to set data in array @param $data @param $key @param $value @return array
[ "Private", "unsecured", "method", "to", "set", "data", "in", "array" ]
aa1af7c404d62879140a76e8e9404584c7776b5f
https://github.com/oliverde8/AssociativeArraySimplified/blob/aa1af7c404d62879140a76e8e9404584c7776b5f/src/AssociativeArray.php#L236-L253
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.id
public function id() { if ( $this->loggedOut ) return null; $id = $this->session->get( $this->getName() ); if ( is_null( $id ) && $this->acct() ) $id = $this->acct()->getId(); return $id; }
php
public function id() { if ( $this->loggedOut ) return null; $id = $this->session->get( $this->getName() ); if ( is_null( $id ) && $this->acct() ) $id = $this->acct()->getId(); return $id; }
[ "public", "function", "id", "(", ")", "{", "if", "(", "$", "this", "->", "loggedOut", ")", "return", "null", ";", "$", "id", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "if", "(", "is_null", "(", "$", "id", ")", "&&", "$", "this", "->", "acct", "(", ")", ")", "$", "id", "=", "$", "this", "->", "acct", "(", ")", "->", "getId", "(", ")", ";", "return", "$", "id", ";", "}" ]
Get the ID for the currently authenticated acct. @return int|null
[ "Get", "the", "ID", "for", "the", "currently", "authenticated", "acct", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L142-L153
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.getAcctByRecaller
protected function getAcctByRecaller( $recaller ) { if ( $this->validRecaller( $recaller ) && !$this->tokenRetrievalAttempted ) { $this->tokenRetrievalAttempted = true; list( $id, $token ) = explode( '|', $recaller, 2 ); $this->viaRemember = !is_null( $acct = $this->auth->retrieveByToken( $id, $token ) ); return $acct; } return null; }
php
protected function getAcctByRecaller( $recaller ) { if ( $this->validRecaller( $recaller ) && !$this->tokenRetrievalAttempted ) { $this->tokenRetrievalAttempted = true; list( $id, $token ) = explode( '|', $recaller, 2 ); $this->viaRemember = !is_null( $acct = $this->auth->retrieveByToken( $id, $token ) ); return $acct; } return null; }
[ "protected", "function", "getAcctByRecaller", "(", "$", "recaller", ")", "{", "if", "(", "$", "this", "->", "validRecaller", "(", "$", "recaller", ")", "&&", "!", "$", "this", "->", "tokenRetrievalAttempted", ")", "{", "$", "this", "->", "tokenRetrievalAttempted", "=", "true", ";", "list", "(", "$", "id", ",", "$", "token", ")", "=", "explode", "(", "'|'", ",", "$", "recaller", ",", "2", ")", ";", "$", "this", "->", "viaRemember", "=", "!", "is_null", "(", "$", "acct", "=", "$", "this", "->", "auth", "->", "retrieveByToken", "(", "$", "id", ",", "$", "token", ")", ")", ";", "return", "$", "acct", ";", "}", "return", "null", ";", "}" ]
Pull a acct from the repository by its recaller ID. @param string $recaller @return mixed
[ "Pull", "a", "acct", "from", "the", "repository", "by", "its", "recaller", "ID", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L161-L173
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.getRecallerId
protected function getRecallerId() { if ( $this->validRecaller( $recaller = $this->getRecaller() ) ) return head( explode( '|', $recaller ) ); return null; }
php
protected function getRecallerId() { if ( $this->validRecaller( $recaller = $this->getRecaller() ) ) return head( explode( '|', $recaller ) ); return null; }
[ "protected", "function", "getRecallerId", "(", ")", "{", "if", "(", "$", "this", "->", "validRecaller", "(", "$", "recaller", "=", "$", "this", "->", "getRecaller", "(", ")", ")", ")", "return", "head", "(", "explode", "(", "'|'", ",", "$", "recaller", ")", ")", ";", "return", "null", ";", "}" ]
Get the acct ID from the recaller cookie. @return string|null
[ "Get", "the", "acct", "ID", "from", "the", "recaller", "cookie", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L190-L196
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.once
public function once( array $credentials = [] ) { if ( $this->validate( $credentials ) ) { $this->setAcct( $this->lastAttempted ); return true; } return false; }
php
public function once( array $credentials = [] ) { if ( $this->validate( $credentials ) ) { $this->setAcct( $this->lastAttempted ); return true; } return false; }
[ "public", "function", "once", "(", "array", "$", "credentials", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "validate", "(", "$", "credentials", ")", ")", "{", "$", "this", "->", "setAcct", "(", "$", "this", "->", "lastAttempted", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Log a acct into the application without sessions or cookies. @param array $credentials @return bool
[ "Log", "a", "acct", "into", "the", "application", "without", "sessions", "or", "cookies", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L220-L230
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.hasValidCredentials
protected function hasValidCredentials( $acct, $credentials ) { return !is_null( $acct ) && $this->auth->validateCredentials( $acct, $credentials ); }
php
protected function hasValidCredentials( $acct, $credentials ) { return !is_null( $acct ) && $this->auth->validateCredentials( $acct, $credentials ); }
[ "protected", "function", "hasValidCredentials", "(", "$", "acct", ",", "$", "credentials", ")", "{", "return", "!", "is_null", "(", "$", "acct", ")", "&&", "$", "this", "->", "auth", "->", "validateCredentials", "(", "$", "acct", ",", "$", "credentials", ")", ";", "}" ]
Determine if the acct matches the credentials. @param mixed $acct @param array $credentials @return bool
[ "Determine", "if", "the", "acct", "matches", "the", "credentials", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L364-L367
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.onceUsingId
public function onceUsingId( $id ) { $acct = $this->auth->retrieveById( $id ); if ( !is_null( $acct ) ) { $this->setAcct( $acct ); return true; } return false; }
php
public function onceUsingId( $id ) { $acct = $this->auth->retrieveById( $id ); if ( !is_null( $acct ) ) { $this->setAcct( $acct ); return true; } return false; }
[ "public", "function", "onceUsingId", "(", "$", "id", ")", "{", "$", "acct", "=", "$", "this", "->", "auth", "->", "retrieveById", "(", "$", "id", ")", ";", "if", "(", "!", "is_null", "(", "$", "acct", ")", ")", "{", "$", "this", "->", "setAcct", "(", "$", "acct", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Log the given acct ID into the application without sessions or cookies. @param mixed $id @return bool
[ "Log", "the", "given", "acct", "ID", "into", "the", "application", "without", "sessions", "or", "cookies", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L480-L492
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.logout
public function logout() { $acct = $this->acct(); // If we have an event dispatcher instance, we can fire off the logout event // so any further processing can be done. This allows the developer to be // listening for anytime a acct signs out of this application manually. $this->clearAcctDataFromStorage(); if ( !is_null( $this->acct ) ) $this->refreshRememberToken( $acct ); Hooks::trigger( 'acct.logout', compact( 'acct' ) ); // Once we have fired the logout event we will clear the accts out of memory // so they are no longer available as the acct is no longer considered as // being signed into this application and should not be available here. $this->acct = null; $this->loggedOut = true; }
php
public function logout() { $acct = $this->acct(); // If we have an event dispatcher instance, we can fire off the logout event // so any further processing can be done. This allows the developer to be // listening for anytime a acct signs out of this application manually. $this->clearAcctDataFromStorage(); if ( !is_null( $this->acct ) ) $this->refreshRememberToken( $acct ); Hooks::trigger( 'acct.logout', compact( 'acct' ) ); // Once we have fired the logout event we will clear the accts out of memory // so they are no longer available as the acct is no longer considered as // being signed into this application and should not be available here. $this->acct = null; $this->loggedOut = true; }
[ "public", "function", "logout", "(", ")", "{", "$", "acct", "=", "$", "this", "->", "acct", "(", ")", ";", "// If we have an event dispatcher instance, we can fire off the logout event", "// so any further processing can be done. This allows the developer to be", "// listening for anytime a acct signs out of this application manually.", "$", "this", "->", "clearAcctDataFromStorage", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "acct", ")", ")", "$", "this", "->", "refreshRememberToken", "(", "$", "acct", ")", ";", "Hooks", "::", "trigger", "(", "'acct.logout'", ",", "compact", "(", "'acct'", ")", ")", ";", "// Once we have fired the logout event we will clear the accts out of memory", "// so they are no longer available as the acct is no longer considered as", "// being signed into this application and should not be available here.", "$", "this", "->", "acct", "=", "null", ";", "$", "this", "->", "loggedOut", "=", "true", ";", "}" ]
Log the acct out of the application.
[ "Log", "the", "acct", "out", "of", "the", "application", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L521-L540
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.clearAcctDataFromStorage
protected function clearAcctDataFromStorage() { $this->session->remove( $this->getName() ); if ( !is_null( $this->getRecaller() ) ) { $recaller = $this->getRecallerName(); $this->getCookieJar()->queue( $this->getCookieJar()->forget( $recaller ) ); } }
php
protected function clearAcctDataFromStorage() { $this->session->remove( $this->getName() ); if ( !is_null( $this->getRecaller() ) ) { $recaller = $this->getRecallerName(); $this->getCookieJar()->queue( $this->getCookieJar()->forget( $recaller ) ); } }
[ "protected", "function", "clearAcctDataFromStorage", "(", ")", "{", "$", "this", "->", "session", "->", "remove", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "getRecaller", "(", ")", ")", ")", "{", "$", "recaller", "=", "$", "this", "->", "getRecallerName", "(", ")", ";", "$", "this", "->", "getCookieJar", "(", ")", "->", "queue", "(", "$", "this", "->", "getCookieJar", "(", ")", "->", "forget", "(", "$", "recaller", ")", ")", ";", "}", "}" ]
Remove the acct data from the session and cookies.
[ "Remove", "the", "acct", "data", "from", "the", "session", "and", "cookies", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L546-L555
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.refreshRememberToken
protected function refreshRememberToken( Account $acct ) { $acct->setRememberToken( $token = Str::random( 60 ) ); $this->auth->updateRememberToken( $acct, $token ); }
php
protected function refreshRememberToken( Account $acct ) { $acct->setRememberToken( $token = Str::random( 60 ) ); $this->auth->updateRememberToken( $acct, $token ); }
[ "protected", "function", "refreshRememberToken", "(", "Account", "$", "acct", ")", "{", "$", "acct", "->", "setRememberToken", "(", "$", "token", "=", "Str", "::", "random", "(", "60", ")", ")", ";", "$", "this", "->", "auth", "->", "updateRememberToken", "(", "$", "acct", ",", "$", "token", ")", ";", "}" ]
Refresh the "remember me" token for the acct. @param Account $acct
[ "Refresh", "the", "remember", "me", "token", "for", "the", "acct", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L562-L566
train
PenoaksDev/Milky-Framework
src/Milky/Account/Guards/SessionGuard.php
SessionGuard.setAcct
public function setAcct( Account $acct ) { $this->acct = $acct; $this->loggedOut = false; return $this; }
php
public function setAcct( Account $acct ) { $this->acct = $acct; $this->loggedOut = false; return $this; }
[ "public", "function", "setAcct", "(", "Account", "$", "acct", ")", "{", "$", "this", "->", "acct", "=", "$", "acct", ";", "$", "this", "->", "loggedOut", "=", "false", ";", "return", "$", "this", ";", "}" ]
Set the current acct. @param Account $acct @return $this
[ "Set", "the", "current", "acct", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Account/Guards/SessionGuard.php#L630-L636
train
zapheus/zapheus
src/Http/Server/Dispatcher.php
Dispatcher.transform
protected function transform($middleware) { if (is_string($middleware)) { return $this->container->get($middleware); } if (is_callable($middleware)) { return new ClosureMiddleware($middleware); } return $middleware; }
php
protected function transform($middleware) { if (is_string($middleware)) { return $this->container->get($middleware); } if (is_callable($middleware)) { return new ClosureMiddleware($middleware); } return $middleware; }
[ "protected", "function", "transform", "(", "$", "middleware", ")", "{", "if", "(", "is_string", "(", "$", "middleware", ")", ")", "{", "return", "$", "this", "->", "container", "->", "get", "(", "$", "middleware", ")", ";", "}", "if", "(", "is_callable", "(", "$", "middleware", ")", ")", "{", "return", "new", "ClosureMiddleware", "(", "$", "middleware", ")", ";", "}", "return", "$", "middleware", ";", "}" ]
Transforms the specified input into a middleware. @param mixed $middleware @return \Zapheus\Http\Server\MiddlewareInterface
[ "Transforms", "the", "specified", "input", "into", "a", "middleware", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Server/Dispatcher.php#L108-L121
train
zapheus/zapheus
src/Http/Server/Dispatcher.php
Dispatcher.resolve
protected function resolve($index) { if (! isset($this->stack[$index])) { return new ErrorHandler; } $next = $this->resolve($index + 1); $item = $this->stack[(integer) $index]; return new NextHandler($item, $next); }
php
protected function resolve($index) { if (! isset($this->stack[$index])) { return new ErrorHandler; } $next = $this->resolve($index + 1); $item = $this->stack[(integer) $index]; return new NextHandler($item, $next); }
[ "protected", "function", "resolve", "(", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stack", "[", "$", "index", "]", ")", ")", "{", "return", "new", "ErrorHandler", ";", "}", "$", "next", "=", "$", "this", "->", "resolve", "(", "$", "index", "+", "1", ")", ";", "$", "item", "=", "$", "this", "->", "stack", "[", "(", "integer", ")", "$", "index", "]", ";", "return", "new", "NextHandler", "(", "$", "item", ",", "$", "next", ")", ";", "}" ]
Resolves the whole stack through its index. @param integer $index @return \Zapheus\Http\Server\HandlerInterface
[ "Resolves", "the", "whole", "stack", "through", "its", "index", "." ]
96618b5cee7d20b6700d0475e4334ae4b5163a6b
https://github.com/zapheus/zapheus/blob/96618b5cee7d20b6700d0475e4334ae4b5163a6b/src/Http/Server/Dispatcher.php#L129-L141
train
freialib/hlin.tools
src/Text.php
Text.reindent
static function reindent($source, $indent = '', $tabs_to_spaces = 4, $ignore_zero_indent = true) { // unify tabs if ($tabs_to_spaces !== null) { $source = str_replace("\t", str_repeat(' ', $tabs_to_spaces), $source); } // split into lines $lines = explode("\n", $source); // detect indent level $min_length = null; foreach ($lines as $line) { if (preg_match('#^([ \t]+)([^ ])#', $line, $matches)) { if ($min_length === null) { $min_length = strlen($matches[1]); } else if (strlen($matches[1]) < $min_length) { $min_length = strlen($matches[1]); } } else if ( ! $ignore_zero_indent) { $min_length = 0; break; } } // unify foreach ($lines as &$line) { if (preg_match('#^[ \t].*#', $line)) { $line = $indent.substr($line, $min_length); } else { # zero line $line = $indent.$line; } } return implode("\n", $lines); }
php
static function reindent($source, $indent = '', $tabs_to_spaces = 4, $ignore_zero_indent = true) { // unify tabs if ($tabs_to_spaces !== null) { $source = str_replace("\t", str_repeat(' ', $tabs_to_spaces), $source); } // split into lines $lines = explode("\n", $source); // detect indent level $min_length = null; foreach ($lines as $line) { if (preg_match('#^([ \t]+)([^ ])#', $line, $matches)) { if ($min_length === null) { $min_length = strlen($matches[1]); } else if (strlen($matches[1]) < $min_length) { $min_length = strlen($matches[1]); } } else if ( ! $ignore_zero_indent) { $min_length = 0; break; } } // unify foreach ($lines as &$line) { if (preg_match('#^[ \t].*#', $line)) { $line = $indent.substr($line, $min_length); } else { # zero line $line = $indent.$line; } } return implode("\n", $lines); }
[ "static", "function", "reindent", "(", "$", "source", ",", "$", "indent", "=", "''", ",", "$", "tabs_to_spaces", "=", "4", ",", "$", "ignore_zero_indent", "=", "true", ")", "{", "// unify tabs", "if", "(", "$", "tabs_to_spaces", "!==", "null", ")", "{", "$", "source", "=", "str_replace", "(", "\"\\t\"", ",", "str_repeat", "(", "' '", ",", "$", "tabs_to_spaces", ")", ",", "$", "source", ")", ";", "}", "// split into lines", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "source", ")", ";", "// detect indent level", "$", "min_length", "=", "null", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "if", "(", "preg_match", "(", "'#^([ \\t]+)([^ ])#'", ",", "$", "line", ",", "$", "matches", ")", ")", "{", "if", "(", "$", "min_length", "===", "null", ")", "{", "$", "min_length", "=", "strlen", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "else", "if", "(", "strlen", "(", "$", "matches", "[", "1", "]", ")", "<", "$", "min_length", ")", "{", "$", "min_length", "=", "strlen", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "}", "else", "if", "(", "!", "$", "ignore_zero_indent", ")", "{", "$", "min_length", "=", "0", ";", "break", ";", "}", "}", "// unify", "foreach", "(", "$", "lines", "as", "&", "$", "line", ")", "{", "if", "(", "preg_match", "(", "'#^[ \\t].*#'", ",", "$", "line", ")", ")", "{", "$", "line", "=", "$", "indent", ".", "substr", "(", "$", "line", ",", "$", "min_length", ")", ";", "}", "else", "{", "# zero line", "$", "line", "=", "$", "indent", ".", "$", "line", ";", "}", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "lines", ")", ";", "}" ]
Uniforms indentation. Useful when printing. If you do not wish tabs to be converted to spaces set the value of $tabs_to_spaces to null. @return string
[ "Uniforms", "indentation", ".", "Useful", "when", "printing", "." ]
42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7
https://github.com/freialib/hlin.tools/blob/42ad9e9fe081918d2ee5d52b72d174ccdcf7cbe7/src/Text.php#L18-L55
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.make
public static function make(string $path, int $ifExists = Directory::MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION) : Directory { $exists = Directory::exists($path); if($exists) { if($ifExists === Directory::MAKE_DIRECTORY_EXISTS_OVERWRITE) { unlink($path); } else if($ifExists === Directory::MAKE_DIRECTORY_EXISTS_OPEN) { return new Directory($path); } else { throw new DirectoryAlreadyExists($path); } } if(!mkdir($path)) { throw new CouldntCreateDirectory($path); } return new Directory($path); }
php
public static function make(string $path, int $ifExists = Directory::MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION) : Directory { $exists = Directory::exists($path); if($exists) { if($ifExists === Directory::MAKE_DIRECTORY_EXISTS_OVERWRITE) { unlink($path); } else if($ifExists === Directory::MAKE_DIRECTORY_EXISTS_OPEN) { return new Directory($path); } else { throw new DirectoryAlreadyExists($path); } } if(!mkdir($path)) { throw new CouldntCreateDirectory($path); } return new Directory($path); }
[ "public", "static", "function", "make", "(", "string", "$", "path", ",", "int", "$", "ifExists", "=", "Directory", "::", "MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION", ")", ":", "Directory", "{", "$", "exists", "=", "Directory", "::", "exists", "(", "$", "path", ")", ";", "if", "(", "$", "exists", ")", "{", "if", "(", "$", "ifExists", "===", "Directory", "::", "MAKE_DIRECTORY_EXISTS_OVERWRITE", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "else", "if", "(", "$", "ifExists", "===", "Directory", "::", "MAKE_DIRECTORY_EXISTS_OPEN", ")", "{", "return", "new", "Directory", "(", "$", "path", ")", ";", "}", "else", "{", "throw", "new", "DirectoryAlreadyExists", "(", "$", "path", ")", ";", "}", "}", "if", "(", "!", "mkdir", "(", "$", "path", ")", ")", "{", "throw", "new", "CouldntCreateDirectory", "(", "$", "path", ")", ";", "}", "return", "new", "Directory", "(", "$", "path", ")", ";", "}" ]
Makes a directory. The second parameter specifies what to do in case directory already exists: * `\Alexya\FileSystem\Directory::MAKE_DIRECTORY_EXISTS_THROW_EXCEPTION`, throws an exception (default). * `\Alexya\FileSystem\Directory::MAKE_DIRECTORY_EXISTS_OVERWRITE`, deletes the directory and recreates it. * `\Alexya\FileSystem\Directory::MAKE_DIRECTORY_EXISTS_OPEN`, opens the directory. @param string $path Path to the directory. @param int $ifExists What to do if directory exists. @return Directory Directory object. @throws DirectoryAlreadyExists If $path already exists as a directory. @throws CouldntCreateDirectory If the directory can't be created.
[ "Makes", "a", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L96-L115
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.fileExists
public function fileExists(string $name) { if(!$this->_isLoaded) { $this->load(); } return in_array($name, $this->_files); }
php
public function fileExists(string $name) { if(!$this->_isLoaded) { $this->load(); } return in_array($name, $this->_files); }
[ "public", "function", "fileExists", "(", "string", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "_isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "in_array", "(", "$", "name", ",", "$", "this", "->", "_files", ")", ";", "}" ]
Checks if a file exists in this directory. @param string $name File name. @return bool `true` if `$name` exists as a file in this directory, `false` if not.
[ "Checks", "if", "a", "file", "exists", "in", "this", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L211-L218
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.getFile
public function getFile(string $name, int $ifNotExists = Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION) : File { $path = $this->getPath(). DIRECTORY_SEPARATOR .$name; if($this->fileExists($name)) { return new File($path); } if($ifNotExists === Directory::GET_FILE_NOT_EXISTS_CREATE) { $this->_files[$name] = $name; return File::make($path, File::MAKE_FILE_EXISTS_OPEN); } throw new FileDoesntExist($path); }
php
public function getFile(string $name, int $ifNotExists = Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION) : File { $path = $this->getPath(). DIRECTORY_SEPARATOR .$name; if($this->fileExists($name)) { return new File($path); } if($ifNotExists === Directory::GET_FILE_NOT_EXISTS_CREATE) { $this->_files[$name] = $name; return File::make($path, File::MAKE_FILE_EXISTS_OPEN); } throw new FileDoesntExist($path); }
[ "public", "function", "getFile", "(", "string", "$", "name", ",", "int", "$", "ifNotExists", "=", "Directory", "::", "GET_FILE_NOT_EXISTS_THROW_EXCEPTION", ")", ":", "File", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "if", "(", "$", "this", "->", "fileExists", "(", "$", "name", ")", ")", "{", "return", "new", "File", "(", "$", "path", ")", ";", "}", "if", "(", "$", "ifNotExists", "===", "Directory", "::", "GET_FILE_NOT_EXISTS_CREATE", ")", "{", "$", "this", "->", "_files", "[", "$", "name", "]", "=", "$", "name", ";", "return", "File", "::", "make", "(", "$", "path", ",", "File", "::", "MAKE_FILE_EXISTS_OPEN", ")", ";", "}", "throw", "new", "FileDoesntExist", "(", "$", "path", ")", ";", "}" ]
Returns a file from the directory. The second parameter specifies what to do in case file doesn't exist: * `\Alexya\FileSystem\Directory::GET_FILE_NOT_EXISTS_THROW_EXCEPTION`, throws an exception (default). * `\Alexya\FileSystem\Directory::GET_FILE_NOT_EXISTS_CREATE`, creates the file. @param string $name File name. @param int $ifNotExists What to do if file exists. @return File File object. @throws FileDoesntExist If $path doesn't exist as a file. @throws CouldntCreateFile If the file can't be created.
[ "Returns", "a", "file", "from", "the", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L236-L251
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.getFiles
public function getFiles() : array { if(!$this->_isLoaded) { $this->load(); } return array_map(function($file) { return new File($this->getPath(). DIRECTORY_SEPARATOR .$file); }, $this->_files); }
php
public function getFiles() : array { if(!$this->_isLoaded) { $this->load(); } return array_map(function($file) { return new File($this->getPath(). DIRECTORY_SEPARATOR .$file); }, $this->_files); }
[ "public", "function", "getFiles", "(", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "_isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "array_map", "(", "function", "(", "$", "file", ")", "{", "return", "new", "File", "(", "$", "this", "->", "getPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ")", ";", "}", ",", "$", "this", "->", "_files", ")", ";", "}" ]
Returns an array with all files of the directory. @return File[] Array with `\Alexya\FileSystem\File` objects for each file on the directory.
[ "Returns", "an", "array", "with", "all", "files", "of", "the", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L258-L267
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.directoryExists
public function directoryExists(string $name) { if(!$this->_isLoaded) { $this->load(); } return in_array($name, $this->_directories); }
php
public function directoryExists(string $name) { if(!$this->_isLoaded) { $this->load(); } return in_array($name, $this->_directories); }
[ "public", "function", "directoryExists", "(", "string", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "_isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "in_array", "(", "$", "name", ",", "$", "this", "->", "_directories", ")", ";", "}" ]
Checks if a directory exists in this directory. @param string $name Directory name. @return bool `true` if `$name` exists as a directory in this directory, `false` if not.
[ "Checks", "if", "a", "directory", "exists", "in", "this", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L276-L283
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.getDirectory
public function getDirectory(string $name, int $ifNotExists = Directory::GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION) : Directory { $path = $this->getPath(). DIRECTORY_SEPARATOR .$name; if($this->directoryExists($name)) { return new Directory($path); } if($ifNotExists === Directory::GET_DIRECTORY_NOT_EXISTS_CREATE) { return Directory::make($path); } throw new DirectoryDoesntExist($path); }
php
public function getDirectory(string $name, int $ifNotExists = Directory::GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION) : Directory { $path = $this->getPath(). DIRECTORY_SEPARATOR .$name; if($this->directoryExists($name)) { return new Directory($path); } if($ifNotExists === Directory::GET_DIRECTORY_NOT_EXISTS_CREATE) { return Directory::make($path); } throw new DirectoryDoesntExist($path); }
[ "public", "function", "getDirectory", "(", "string", "$", "name", ",", "int", "$", "ifNotExists", "=", "Directory", "::", "GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION", ")", ":", "Directory", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "if", "(", "$", "this", "->", "directoryExists", "(", "$", "name", ")", ")", "{", "return", "new", "Directory", "(", "$", "path", ")", ";", "}", "if", "(", "$", "ifNotExists", "===", "Directory", "::", "GET_DIRECTORY_NOT_EXISTS_CREATE", ")", "{", "return", "Directory", "::", "make", "(", "$", "path", ")", ";", "}", "throw", "new", "DirectoryDoesntExist", "(", "$", "path", ")", ";", "}" ]
Returns a directory from the directory. The second parameter specifies what to do in case directory doesn't exist: * `\Alexya\FileSystem\Directory::GET_DIRECTORY_NOT_EXISTS_THROW_EXCEPTION`, throws an exception (default). * `\Alexya\FileSystem\Directory::GET_DIRECTORY_NOT_EXISTS_CREATE`, creates the directory. @param string $name Directory name. @param int $ifNotExists What to do if directory exists. @return Directory Directory object. @throws DirectoryDoesntExist If $path doesn't exist as a directory. @throws CouldntCreateDirectory If the directory can't be created.
[ "Returns", "a", "directory", "from", "the", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L301-L314
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.getDirectories
public function getDirectories() : array { if(!$this->_isLoaded) { $this->load(); } return array_map(function($directory) { return new Directory($this->getPath(). DIRECTORY_SEPARATOR .$directory); }, $this->_directories); }
php
public function getDirectories() : array { if(!$this->_isLoaded) { $this->load(); } return array_map(function($directory) { return new Directory($this->getPath(). DIRECTORY_SEPARATOR .$directory); }, $this->_directories); }
[ "public", "function", "getDirectories", "(", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "_isLoaded", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "return", "array_map", "(", "function", "(", "$", "directory", ")", "{", "return", "new", "Directory", "(", "$", "this", "->", "getPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "directory", ")", ";", "}", ",", "$", "this", "->", "_directories", ")", ";", "}" ]
Returns an array with all directories of the directory. @return Directory[] Array with `\Alexya\FileSystem\Directory` objects for each directory on the directory.
[ "Returns", "an", "array", "with", "all", "directories", "of", "the", "directory", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L321-L330
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.load
public function load() { $files = scandir($this->getPath()); foreach($files as $file) { if( $file === "." || $file === ".." ) { continue; } if(is_file($this->getPath().$file)) { $this->_files[$file] = $file; } else if(is_dir($this->getPath().$file)) { $this->_directories[$file] = $file; } } }
php
public function load() { $files = scandir($this->getPath()); foreach($files as $file) { if( $file === "." || $file === ".." ) { continue; } if(is_file($this->getPath().$file)) { $this->_files[$file] = $file; } else if(is_dir($this->getPath().$file)) { $this->_directories[$file] = $file; } } }
[ "public", "function", "load", "(", ")", "{", "$", "files", "=", "scandir", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "file", "===", "\".\"", "||", "$", "file", "===", "\"..\"", ")", "{", "continue", ";", "}", "if", "(", "is_file", "(", "$", "this", "->", "getPath", "(", ")", ".", "$", "file", ")", ")", "{", "$", "this", "->", "_files", "[", "$", "file", "]", "=", "$", "file", ";", "}", "else", "if", "(", "is_dir", "(", "$", "this", "->", "getPath", "(", ")", ".", "$", "file", ")", ")", "{", "$", "this", "->", "_directories", "[", "$", "file", "]", "=", "$", "file", ";", "}", "}", "}" ]
Loads directories and files.
[ "Loads", "directories", "and", "files", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L335-L353
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.setLocation
public function setLocation(string $location) { $dir = Directory::make($location, Directory::MAKE_DIRECTORY_EXISTS_OPEN); $old = $this->getPath(); $new = $dir->getPath(); if(rename($old, $new)) { $this->_location = $dir->getPath(); } }
php
public function setLocation(string $location) { $dir = Directory::make($location, Directory::MAKE_DIRECTORY_EXISTS_OPEN); $old = $this->getPath(); $new = $dir->getPath(); if(rename($old, $new)) { $this->_location = $dir->getPath(); } }
[ "public", "function", "setLocation", "(", "string", "$", "location", ")", "{", "$", "dir", "=", "Directory", "::", "make", "(", "$", "location", ",", "Directory", "::", "MAKE_DIRECTORY_EXISTS_OPEN", ")", ";", "$", "old", "=", "$", "this", "->", "getPath", "(", ")", ";", "$", "new", "=", "$", "dir", "->", "getPath", "(", ")", ";", "if", "(", "rename", "(", "$", "old", ",", "$", "new", ")", ")", "{", "$", "this", "->", "_location", "=", "$", "dir", "->", "getPath", "(", ")", ";", "}", "}" ]
Moves the file to the specified location. @param string $location New file location.
[ "Moves", "the", "file", "to", "the", "specified", "location", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L363-L373
train
AlexyaFramework/FileSystem
Alexya/FileSystem/Directory.php
Directory.setPath
public function setPath(string $path) { $info = pathinfo($path); $this->setLocation($info["dirname"] ?? ""); $this->setName($info["filename"] ?? ""); }
php
public function setPath(string $path) { $info = pathinfo($path); $this->setLocation($info["dirname"] ?? ""); $this->setName($info["filename"] ?? ""); }
[ "public", "function", "setPath", "(", "string", "$", "path", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "path", ")", ";", "$", "this", "->", "setLocation", "(", "$", "info", "[", "\"dirname\"", "]", "??", "\"\"", ")", ";", "$", "this", "->", "setName", "(", "$", "info", "[", "\"filename\"", "]", "??", "\"\"", ")", ";", "}" ]
Sets new file location, name and extension. @param string $path New path to file (location + name + extension).
[ "Sets", "new", "file", "location", "name", "and", "extension", "." ]
1f2a848c4bd508c0ce0e14f49e231522cc059424
https://github.com/AlexyaFramework/FileSystem/blob/1f2a848c4bd508c0ce0e14f49e231522cc059424/Alexya/FileSystem/Directory.php#L395-L401
train
linpax/microphp-framework
src/cli/Threads.php
Threads.createIPCSegment
protected function createIPCSegment() { $this->fileIPC1 = '/tmp/'.mt_rand().md5($this->getName()).'.shm'; touch($this->fileIPC1); $shm_key = ftok($this->fileIPC1, 't'); if ($shm_key === -1) { throw new Exception('Fatal exception creating SHM segment (ftok)'); } $this->internalIPCKey = shmop_open($shm_key, 'c', 0644, 10240); if (!$this->internalIPCKey) { return false; } return true; }
php
protected function createIPCSegment() { $this->fileIPC1 = '/tmp/'.mt_rand().md5($this->getName()).'.shm'; touch($this->fileIPC1); $shm_key = ftok($this->fileIPC1, 't'); if ($shm_key === -1) { throw new Exception('Fatal exception creating SHM segment (ftok)'); } $this->internalIPCKey = shmop_open($shm_key, 'c', 0644, 10240); if (!$this->internalIPCKey) { return false; } return true; }
[ "protected", "function", "createIPCSegment", "(", ")", "{", "$", "this", "->", "fileIPC1", "=", "'/tmp/'", ".", "mt_rand", "(", ")", ".", "md5", "(", "$", "this", "->", "getName", "(", ")", ")", ".", "'.shm'", ";", "touch", "(", "$", "this", "->", "fileIPC1", ")", ";", "$", "shm_key", "=", "ftok", "(", "$", "this", "->", "fileIPC1", ",", "'t'", ")", ";", "if", "(", "$", "shm_key", "===", "-", "1", ")", "{", "throw", "new", "Exception", "(", "'Fatal exception creating SHM segment (ftok)'", ")", ";", "}", "$", "this", "->", "internalIPCKey", "=", "shmop_open", "(", "$", "shm_key", ",", "'c'", ",", "0644", ",", "10240", ")", ";", "if", "(", "!", "$", "this", "->", "internalIPCKey", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Create IPC segment @access protected @return bool @throws Exception
[ "Create", "IPC", "segment" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L91-L108
train
linpax/microphp-framework
src/cli/Threads.php
Threads.createIPCSemaphore
protected function createIPCSemaphore() { $this->fileIPC2 = '/tmp/'.mt_rand().md5($this->getName()).'.sem'; touch($this->fileIPC2); $sem_key = ftok($this->fileIPC2, 't'); if ($sem_key === -1) { throw new Exception('Fatal exception creating semaphore (ftok)'); } $this->internalSemaphoreKey = shmop_open($sem_key, 'c', 0644, 10); if (!$this->internalSemaphoreKey) { return false; } return true; }
php
protected function createIPCSemaphore() { $this->fileIPC2 = '/tmp/'.mt_rand().md5($this->getName()).'.sem'; touch($this->fileIPC2); $sem_key = ftok($this->fileIPC2, 't'); if ($sem_key === -1) { throw new Exception('Fatal exception creating semaphore (ftok)'); } $this->internalSemaphoreKey = shmop_open($sem_key, 'c', 0644, 10); if (!$this->internalSemaphoreKey) { return false; } return true; }
[ "protected", "function", "createIPCSemaphore", "(", ")", "{", "$", "this", "->", "fileIPC2", "=", "'/tmp/'", ".", "mt_rand", "(", ")", ".", "md5", "(", "$", "this", "->", "getName", "(", ")", ")", ".", "'.sem'", ";", "touch", "(", "$", "this", "->", "fileIPC2", ")", ";", "$", "sem_key", "=", "ftok", "(", "$", "this", "->", "fileIPC2", ",", "'t'", ")", ";", "if", "(", "$", "sem_key", "===", "-", "1", ")", "{", "throw", "new", "Exception", "(", "'Fatal exception creating semaphore (ftok)'", ")", ";", "}", "$", "this", "->", "internalSemaphoreKey", "=", "shmop_open", "(", "$", "sem_key", ",", "'c'", ",", "0644", ",", "10", ")", ";", "if", "(", "!", "$", "this", "->", "internalSemaphoreKey", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Create IPC semaphore @access protected @return bool @throws Exception
[ "Create", "IPC", "semaphore" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L143-L160
train
linpax/microphp-framework
src/cli/Threads.php
Threads.writeToIPCSegment
protected function writeToIPCSegment() { if (shmop_read($this->internalSemaphoreKey, 1, 1) === 1) { return; } $serialized_IPC_array = serialize($this->internalIPCArray); $shm_bytes_written = shmop_write($this->internalIPCKey, $serialized_IPC_array, 0); if ($shm_bytes_written !== strlen($serialized_IPC_array)) { throw new Exception( 'Fatal exception writing SHM segment (shmop_write)'.strlen($serialized_IPC_array). '-'.shmop_size($this->internalIPCKey) ); } }
php
protected function writeToIPCSegment() { if (shmop_read($this->internalSemaphoreKey, 1, 1) === 1) { return; } $serialized_IPC_array = serialize($this->internalIPCArray); $shm_bytes_written = shmop_write($this->internalIPCKey, $serialized_IPC_array, 0); if ($shm_bytes_written !== strlen($serialized_IPC_array)) { throw new Exception( 'Fatal exception writing SHM segment (shmop_write)'.strlen($serialized_IPC_array). '-'.shmop_size($this->internalIPCKey) ); } }
[ "protected", "function", "writeToIPCSegment", "(", ")", "{", "if", "(", "shmop_read", "(", "$", "this", "->", "internalSemaphoreKey", ",", "1", ",", "1", ")", "===", "1", ")", "{", "return", ";", "}", "$", "serialized_IPC_array", "=", "serialize", "(", "$", "this", "->", "internalIPCArray", ")", ";", "$", "shm_bytes_written", "=", "shmop_write", "(", "$", "this", "->", "internalIPCKey", ",", "$", "serialized_IPC_array", ",", "0", ")", ";", "if", "(", "$", "shm_bytes_written", "!==", "strlen", "(", "$", "serialized_IPC_array", ")", ")", "{", "throw", "new", "Exception", "(", "'Fatal exception writing SHM segment (shmop_write)'", ".", "strlen", "(", "$", "serialized_IPC_array", ")", ".", "'-'", ".", "shmop_size", "(", "$", "this", "->", "internalIPCKey", ")", ")", ";", "}", "}" ]
Write to IPC segment @access protected @return void @throws Exception
[ "Write", "to", "IPC", "segment" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L210-L225
train
linpax/microphp-framework
src/cli/Threads.php
Threads.readFromIPCSegment
protected function readFromIPCSegment() { $serialized_IPC_array = shmop_read($this->internalIPCKey, 0, shmop_size($this->internalIPCKey)); if (!$serialized_IPC_array) { throw new Exception('Fatal exception reading SHM segment (shmop_read)'."\n"); } unset($this->internalIPCArray); $this->internalIPCArray = @unserialize($serialized_IPC_array); }
php
protected function readFromIPCSegment() { $serialized_IPC_array = shmop_read($this->internalIPCKey, 0, shmop_size($this->internalIPCKey)); if (!$serialized_IPC_array) { throw new Exception('Fatal exception reading SHM segment (shmop_read)'."\n"); } unset($this->internalIPCArray); $this->internalIPCArray = @unserialize($serialized_IPC_array); }
[ "protected", "function", "readFromIPCSegment", "(", ")", "{", "$", "serialized_IPC_array", "=", "shmop_read", "(", "$", "this", "->", "internalIPCKey", ",", "0", ",", "shmop_size", "(", "$", "this", "->", "internalIPCKey", ")", ")", ";", "if", "(", "!", "$", "serialized_IPC_array", ")", "{", "throw", "new", "Exception", "(", "'Fatal exception reading SHM segment (shmop_read)'", ".", "\"\\n\"", ")", ";", "}", "unset", "(", "$", "this", "->", "internalIPCArray", ")", ";", "$", "this", "->", "internalIPCArray", "=", "@", "unserialize", "(", "$", "serialized_IPC_array", ")", ";", "}" ]
Read from IPC segment @access public @return void @throws Exception
[ "Read", "from", "IPC", "segment" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L268-L279
train
linpax/microphp-framework
src/cli/Threads.php
Threads.register_callback_func
public function register_callback_func($argList, $methodName) { if (is_array($argList) && count($argList) > 1) { if ($argList[1] === -2) { $this->internalIPCArray['_call_type'] = -2; } else { $this->internalIPCArray['_call_type'] = -1; } } else { $this->internalIPCArray['_call_type'] = -1; } $this->internalIPCArray['_call_method'] = $methodName; $this->internalIPCArray['_call_input'] = $argList; $this->writeToIPCSegment(); switch ($this->internalIPCArray['_call_type']) { case -1: $this->sendSigUsr1(); break; case -2: shmop_write($this->internalSemaphoreKey, 1, 0); $this->sendSigUsr1(); $this->waitIPCSemaphore(); $this->readFromIPCSegment(); shmop_write($this->internalSemaphoreKey, 0, 1); return $this->internalIPCArray['_call_output']; } return false; }
php
public function register_callback_func($argList, $methodName) { if (is_array($argList) && count($argList) > 1) { if ($argList[1] === -2) { $this->internalIPCArray['_call_type'] = -2; } else { $this->internalIPCArray['_call_type'] = -1; } } else { $this->internalIPCArray['_call_type'] = -1; } $this->internalIPCArray['_call_method'] = $methodName; $this->internalIPCArray['_call_input'] = $argList; $this->writeToIPCSegment(); switch ($this->internalIPCArray['_call_type']) { case -1: $this->sendSigUsr1(); break; case -2: shmop_write($this->internalSemaphoreKey, 1, 0); $this->sendSigUsr1(); $this->waitIPCSemaphore(); $this->readFromIPCSegment(); shmop_write($this->internalSemaphoreKey, 0, 1); return $this->internalIPCArray['_call_output']; } return false; }
[ "public", "function", "register_callback_func", "(", "$", "argList", ",", "$", "methodName", ")", "{", "if", "(", "is_array", "(", "$", "argList", ")", "&&", "count", "(", "$", "argList", ")", ">", "1", ")", "{", "if", "(", "$", "argList", "[", "1", "]", "===", "-", "2", ")", "{", "$", "this", "->", "internalIPCArray", "[", "'_call_type'", "]", "=", "-", "2", ";", "}", "else", "{", "$", "this", "->", "internalIPCArray", "[", "'_call_type'", "]", "=", "-", "1", ";", "}", "}", "else", "{", "$", "this", "->", "internalIPCArray", "[", "'_call_type'", "]", "=", "-", "1", ";", "}", "$", "this", "->", "internalIPCArray", "[", "'_call_method'", "]", "=", "$", "methodName", ";", "$", "this", "->", "internalIPCArray", "[", "'_call_input'", "]", "=", "$", "argList", ";", "$", "this", "->", "writeToIPCSegment", "(", ")", ";", "switch", "(", "$", "this", "->", "internalIPCArray", "[", "'_call_type'", "]", ")", "{", "case", "-", "1", ":", "$", "this", "->", "sendSigUsr1", "(", ")", ";", "break", ";", "case", "-", "2", ":", "shmop_write", "(", "$", "this", "->", "internalSemaphoreKey", ",", "1", ",", "0", ")", ";", "$", "this", "->", "sendSigUsr1", "(", ")", ";", "$", "this", "->", "waitIPCSemaphore", "(", ")", ";", "$", "this", "->", "readFromIPCSegment", "(", ")", ";", "shmop_write", "(", "$", "this", "->", "internalSemaphoreKey", ",", "0", ",", "1", ")", ";", "return", "$", "this", "->", "internalIPCArray", "[", "'_call_output'", "]", ";", "}", "return", "false", ";", "}" ]
Register callback func into shared memory @access public @param mixed $argList @param string $methodName @return mixed|void @throws \Micro\Base\Exception
[ "Register", "callback", "func", "into", "shared", "memory" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L303-L338
train
linpax/microphp-framework
src/cli/Threads.php
Threads.cleanThreadContext
protected function cleanThreadContext() { shmop_delete($this->internalIPCKey); shmop_delete($this->internalSemaphoreKey); shmop_close($this->internalIPCKey); shmop_close($this->internalSemaphoreKey); unlink($this->fileIPC1); unlink($this->fileIPC2); $this->running = false; unset($this->pid); }
php
protected function cleanThreadContext() { shmop_delete($this->internalIPCKey); shmop_delete($this->internalSemaphoreKey); shmop_close($this->internalIPCKey); shmop_close($this->internalSemaphoreKey); unlink($this->fileIPC1); unlink($this->fileIPC2); $this->running = false; unset($this->pid); }
[ "protected", "function", "cleanThreadContext", "(", ")", "{", "shmop_delete", "(", "$", "this", "->", "internalIPCKey", ")", ";", "shmop_delete", "(", "$", "this", "->", "internalSemaphoreKey", ")", ";", "shmop_close", "(", "$", "this", "->", "internalIPCKey", ")", ";", "shmop_close", "(", "$", "this", "->", "internalSemaphoreKey", ")", ";", "unlink", "(", "$", "this", "->", "fileIPC1", ")", ";", "unlink", "(", "$", "this", "->", "fileIPC2", ")", ";", "$", "this", "->", "running", "=", "false", ";", "unset", "(", "$", "this", "->", "pid", ")", ";", "}" ]
Clean thread context @access protected @return void
[ "Clean", "thread", "context" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/Threads.php#L447-L460
train
joomla-x/orm-joomla3
src/ORM.php
ORM.createContainer
protected static function createContainer() { $app = JFactory::getApplication(); if (is_null($app->get('container', null))) { $app->set('container', new Container()); } $container = $app->get('container'); if (!method_exists($container, 'set')) { $container = new Container($container); } return $container; }
php
protected static function createContainer() { $app = JFactory::getApplication(); if (is_null($app->get('container', null))) { $app->set('container', new Container()); } $container = $app->get('container'); if (!method_exists($container, 'set')) { $container = new Container($container); } return $container; }
[ "protected", "static", "function", "createContainer", "(", ")", "{", "$", "app", "=", "JFactory", "::", "getApplication", "(", ")", ";", "if", "(", "is_null", "(", "$", "app", "->", "get", "(", "'container'", ",", "null", ")", ")", ")", "{", "$", "app", "->", "set", "(", "'container'", ",", "new", "Container", "(", ")", ")", ";", "}", "$", "container", "=", "$", "app", "->", "get", "(", "'container'", ")", ";", "if", "(", "!", "method_exists", "(", "$", "container", ",", "'set'", ")", ")", "{", "$", "container", "=", "new", "Container", "(", "$", "container", ")", ";", "}", "return", "$", "container", ";", "}" ]
Ensure container exists @return Container
[ "Ensure", "container", "exists" ]
560c4a1ea9f00760d7c05f36147e7e33fdf7e234
https://github.com/joomla-x/orm-joomla3/blob/560c4a1ea9f00760d7c05f36147e7e33fdf7e234/src/ORM.php#L47-L62
train
joomla-x/orm-joomla3
src/ORM.php
ORM.createDatabaseConfiguration
protected static function createDatabaseConfiguration() { $config = new JConfig(); $dsn = $config->dbtype . '://' . $config->user . ':' . $config->password . '@' . $config->host . '/' . $config->db; $dataMapperClass = PrefixedDoctrineDataMapper::class; $ini = <<<INI databaseUrl="$dsn" definitionPath="entities" dataMapper="$dataMapperClass" INI; file_put_contents(JPATH_ROOT . '/config/database.ini', $ini); }
php
protected static function createDatabaseConfiguration() { $config = new JConfig(); $dsn = $config->dbtype . '://' . $config->user . ':' . $config->password . '@' . $config->host . '/' . $config->db; $dataMapperClass = PrefixedDoctrineDataMapper::class; $ini = <<<INI databaseUrl="$dsn" definitionPath="entities" dataMapper="$dataMapperClass" INI; file_put_contents(JPATH_ROOT . '/config/database.ini', $ini); }
[ "protected", "static", "function", "createDatabaseConfiguration", "(", ")", "{", "$", "config", "=", "new", "JConfig", "(", ")", ";", "$", "dsn", "=", "$", "config", "->", "dbtype", ".", "'://'", ".", "$", "config", "->", "user", ".", "':'", ".", "$", "config", "->", "password", ".", "'@'", ".", "$", "config", "->", "host", ".", "'/'", ".", "$", "config", "->", "db", ";", "$", "dataMapperClass", "=", "PrefixedDoctrineDataMapper", "::", "class", ";", "$", "ini", "=", " <<<INI\ndatabaseUrl=\"$dsn\"\ndefinitionPath=\"entities\"\ndataMapper=\"$dataMapperClass\"\nINI", ";", "file_put_contents", "(", "JPATH_ROOT", ".", "'/config/database.ini'", ",", "$", "ini", ")", ";", "}" ]
Create DB configuration
[ "Create", "DB", "configuration" ]
560c4a1ea9f00760d7c05f36147e7e33fdf7e234
https://github.com/joomla-x/orm-joomla3/blob/560c4a1ea9f00760d7c05f36147e7e33fdf7e234/src/ORM.php#L67-L79
train
mtils/cmsable
src/Cmsable/Routing/TreeScope/RootNodeRepository.php
RootNodeRepository.getByModelRootId
public function getByModelRootId($rootId){ $this->fillScopes(); if(!isset($this->scopeByModelRootId[$rootId])){ throw new OutOfBoundsException("No scope with modelRootId '$rootId' found"); } return $this->scopeByModelRootId[$rootId]; }
php
public function getByModelRootId($rootId){ $this->fillScopes(); if(!isset($this->scopeByModelRootId[$rootId])){ throw new OutOfBoundsException("No scope with modelRootId '$rootId' found"); } return $this->scopeByModelRootId[$rootId]; }
[ "public", "function", "getByModelRootId", "(", "$", "rootId", ")", "{", "$", "this", "->", "fillScopes", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "scopeByModelRootId", "[", "$", "rootId", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"No scope with modelRootId '$rootId' found\"", ")", ";", "}", "return", "$", "this", "->", "scopeByModelRootId", "[", "$", "rootId", "]", ";", "}" ]
Returns the scope by modelRootId @throws OutOfBoundsException If no scope with root-id $rootId was found @return \Cmsable\Routing\TreeScope\TreeScope
[ "Returns", "the", "scope", "by", "modelRootId" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/TreeScope/RootNodeRepository.php#L113-L123
train
mtils/cmsable
src/Cmsable/Routing/TreeScope/RootNodeRepository.php
RootNodeRepository.fillScopes
protected function fillScopes(){ if($this->scopes !== null){ return; } $this->scopes = []; foreach($this->treeModel->rootNodes() as $rootNode){ $this->addToScopes($this->node2Scope($rootNode)); } foreach ($this->manualScopes as $scope) { $this->addToScopes($scope); } }
php
protected function fillScopes(){ if($this->scopes !== null){ return; } $this->scopes = []; foreach($this->treeModel->rootNodes() as $rootNode){ $this->addToScopes($this->node2Scope($rootNode)); } foreach ($this->manualScopes as $scope) { $this->addToScopes($scope); } }
[ "protected", "function", "fillScopes", "(", ")", "{", "if", "(", "$", "this", "->", "scopes", "!==", "null", ")", "{", "return", ";", "}", "$", "this", "->", "scopes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "treeModel", "->", "rootNodes", "(", ")", "as", "$", "rootNode", ")", "{", "$", "this", "->", "addToScopes", "(", "$", "this", "->", "node2Scope", "(", "$", "rootNode", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "manualScopes", "as", "$", "scope", ")", "{", "$", "this", "->", "addToScopes", "(", "$", "scope", ")", ";", "}", "}" ]
Fills the scope array for fast lookups @return void
[ "Fills", "the", "scope", "array", "for", "fast", "lookups" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/TreeScope/RootNodeRepository.php#L140-L159
train
mtils/cmsable
src/Cmsable/Routing/TreeScope/RootNodeRepository.php
RootNodeRepository.addToScopes
protected function addToScopes(TreeScope $scope) { $this->scopes[] = $scope; $this->scopeByName[$scope->getName()] = $scope; $this->scopeByModelRootId[$scope->getModelRootId()] = $scope; $this->scopeByPathPrefix[$scope->getPathPrefix()] = $scope; }
php
protected function addToScopes(TreeScope $scope) { $this->scopes[] = $scope; $this->scopeByName[$scope->getName()] = $scope; $this->scopeByModelRootId[$scope->getModelRootId()] = $scope; $this->scopeByPathPrefix[$scope->getPathPrefix()] = $scope; }
[ "protected", "function", "addToScopes", "(", "TreeScope", "$", "scope", ")", "{", "$", "this", "->", "scopes", "[", "]", "=", "$", "scope", ";", "$", "this", "->", "scopeByName", "[", "$", "scope", "->", "getName", "(", ")", "]", "=", "$", "scope", ";", "$", "this", "->", "scopeByModelRootId", "[", "$", "scope", "->", "getModelRootId", "(", ")", "]", "=", "$", "scope", ";", "$", "this", "->", "scopeByPathPrefix", "[", "$", "scope", "->", "getPathPrefix", "(", ")", "]", "=", "$", "scope", ";", "}" ]
Adds the passed scope to the scope array @param \Cmsable\Routing\TreeScope\TreeScope $treeScope @return void
[ "Adds", "the", "passed", "scope", "to", "the", "scope", "array" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/TreeScope/RootNodeRepository.php#L167-L173
train
mtils/cmsable
src/Cmsable/Routing/TreeScope/RootNodeRepository.php
RootNodeRepository.node2Scope
public function node2Scope(SiteTreeNodeInterface $node){ $scope = new TreeScope(); $urlSegment = trim($node->getUrlSegment(),'/'); $name = $urlSegment ? $urlSegment : TreeScope::DEFAULT_NAME; $scope->setPathPrefix($node->getUrlSegment()); $scope->setName($name); $scope->setTitle($node->getMenuTitle()); $scope->setModelRootId($node->{$this->treeModel->rootCol()}); return $scope; }
php
public function node2Scope(SiteTreeNodeInterface $node){ $scope = new TreeScope(); $urlSegment = trim($node->getUrlSegment(),'/'); $name = $urlSegment ? $urlSegment : TreeScope::DEFAULT_NAME; $scope->setPathPrefix($node->getUrlSegment()); $scope->setName($name); $scope->setTitle($node->getMenuTitle()); $scope->setModelRootId($node->{$this->treeModel->rootCol()}); return $scope; }
[ "public", "function", "node2Scope", "(", "SiteTreeNodeInterface", "$", "node", ")", "{", "$", "scope", "=", "new", "TreeScope", "(", ")", ";", "$", "urlSegment", "=", "trim", "(", "$", "node", "->", "getUrlSegment", "(", ")", ",", "'/'", ")", ";", "$", "name", "=", "$", "urlSegment", "?", "$", "urlSegment", ":", "TreeScope", "::", "DEFAULT_NAME", ";", "$", "scope", "->", "setPathPrefix", "(", "$", "node", "->", "getUrlSegment", "(", ")", ")", ";", "$", "scope", "->", "setName", "(", "$", "name", ")", ";", "$", "scope", "->", "setTitle", "(", "$", "node", "->", "getMenuTitle", "(", ")", ")", ";", "$", "scope", "->", "setModelRootId", "(", "$", "node", "->", "{", "$", "this", "->", "treeModel", "->", "rootCol", "(", ")", "}", ")", ";", "return", "$", "scope", ";", "}" ]
Convert a root node to a scope @param \Cmsable\Model\SiteTreeNodeInterface $node @return \Cmsable\Routing\TreeScope\TreeScope
[ "Convert", "a", "root", "node", "to", "a", "scope" ]
03ae84ee3c7d46146f2a1cf687e5c29d6de4286d
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/TreeScope/RootNodeRepository.php#L181-L195
train
brunschgi/TerrificComposerBundle
Service/PageManager.php
PageManager.getPages
public function getPages() { $pages = array(); foreach ($this->router->getRouteCollection()->all() as $route) { if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) { if ($composerAnnotation = $this->reader->getMethodAnnotation($method, self::COMPOSER_ANNOTATION_CLASS)) { if ($composerAnnotation !== null) { // setup a fresh page object $page = new Page(); $page->setName($composerAnnotation->getName()); // create url from route annotation or from route pattern $routeAnnotation = $this->reader->getMethodAnnotation($method, self::ROUTE_ANNOTATION_CLASS); try { $page->setUrl($this->router->generate($routeAnnotation->getName())); } catch (RouteNotFoundException $e) { $this->container->get('logger')->info('The @Route annotation of '.$route->getDefault('_controller').' has no name. Please specify it for better page linking.'); $page->setUrl($this->router->getContext()->getBaseUrl().$route->getPattern()); } // add page $pages[] = $page; } } } } return $pages; }
php
public function getPages() { $pages = array(); foreach ($this->router->getRouteCollection()->all() as $route) { if ($method = $this->getReflectionMethod($route->getDefault('_controller'))) { if ($composerAnnotation = $this->reader->getMethodAnnotation($method, self::COMPOSER_ANNOTATION_CLASS)) { if ($composerAnnotation !== null) { // setup a fresh page object $page = new Page(); $page->setName($composerAnnotation->getName()); // create url from route annotation or from route pattern $routeAnnotation = $this->reader->getMethodAnnotation($method, self::ROUTE_ANNOTATION_CLASS); try { $page->setUrl($this->router->generate($routeAnnotation->getName())); } catch (RouteNotFoundException $e) { $this->container->get('logger')->info('The @Route annotation of '.$route->getDefault('_controller').' has no name. Please specify it for better page linking.'); $page->setUrl($this->router->getContext()->getBaseUrl().$route->getPattern()); } // add page $pages[] = $page; } } } } return $pages; }
[ "public", "function", "getPages", "(", ")", "{", "$", "pages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "router", "->", "getRouteCollection", "(", ")", "->", "all", "(", ")", "as", "$", "route", ")", "{", "if", "(", "$", "method", "=", "$", "this", "->", "getReflectionMethod", "(", "$", "route", "->", "getDefault", "(", "'_controller'", ")", ")", ")", "{", "if", "(", "$", "composerAnnotation", "=", "$", "this", "->", "reader", "->", "getMethodAnnotation", "(", "$", "method", ",", "self", "::", "COMPOSER_ANNOTATION_CLASS", ")", ")", "{", "if", "(", "$", "composerAnnotation", "!==", "null", ")", "{", "// setup a fresh page object", "$", "page", "=", "new", "Page", "(", ")", ";", "$", "page", "->", "setName", "(", "$", "composerAnnotation", "->", "getName", "(", ")", ")", ";", "// create url from route annotation or from route pattern", "$", "routeAnnotation", "=", "$", "this", "->", "reader", "->", "getMethodAnnotation", "(", "$", "method", ",", "self", "::", "ROUTE_ANNOTATION_CLASS", ")", ";", "try", "{", "$", "page", "->", "setUrl", "(", "$", "this", "->", "router", "->", "generate", "(", "$", "routeAnnotation", "->", "getName", "(", ")", ")", ")", ";", "}", "catch", "(", "RouteNotFoundException", "$", "e", ")", "{", "$", "this", "->", "container", "->", "get", "(", "'logger'", ")", "->", "info", "(", "'The @Route annotation of '", ".", "$", "route", "->", "getDefault", "(", "'_controller'", ")", ".", "' has no name. Please specify it for better page linking.'", ")", ";", "$", "page", "->", "setUrl", "(", "$", "this", "->", "router", "->", "getContext", "(", ")", "->", "getBaseUrl", "(", ")", ".", "$", "route", "->", "getPattern", "(", ")", ")", ";", "}", "// add page", "$", "pages", "[", "]", "=", "$", "page", ";", "}", "}", "}", "}", "return", "$", "pages", ";", "}" ]
Gets all existing Pages @return array All existing Page instances
[ "Gets", "all", "existing", "Pages" ]
6eef4ace887c19ef166ab6654de385bc1ffbf5f1
https://github.com/brunschgi/TerrificComposerBundle/blob/6eef4ace887c19ef166ab6654de385bc1ffbf5f1/Service/PageManager.php#L62-L93
train
brunschgi/TerrificComposerBundle
Service/PageManager.php
PageManager.getReflectionMethod
private function getReflectionMethod($controller) { if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) { $class = $matches[1]; $method = $matches[2]; } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) { $controller = $matches[1]; $method = $matches[2]; if ($this->container->has($controller)) { $this->container->enterScope('request'); $this->container->set('request', new Request); $class = get_class($this->container->get($controller)); $this->container->leaveScope('request'); } } if (isset($class) && isset($method)) { try { return new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { } } return null; }
php
private function getReflectionMethod($controller) { if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) { $class = $matches[1]; $method = $matches[2]; } elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) { $controller = $matches[1]; $method = $matches[2]; if ($this->container->has($controller)) { $this->container->enterScope('request'); $this->container->set('request', new Request); $class = get_class($this->container->get($controller)); $this->container->leaveScope('request'); } } if (isset($class) && isset($method)) { try { return new \ReflectionMethod($class, $method); } catch (\ReflectionException $e) { } } return null; }
[ "private", "function", "getReflectionMethod", "(", "$", "controller", ")", "{", "if", "(", "preg_match", "(", "'#(.+)::([\\w]+)#'", ",", "$", "controller", ",", "$", "matches", ")", ")", "{", "$", "class", "=", "$", "matches", "[", "1", "]", ";", "$", "method", "=", "$", "matches", "[", "2", "]", ";", "}", "elseif", "(", "preg_match", "(", "'#(.+):([\\w]+)#'", ",", "$", "controller", ",", "$", "matches", ")", ")", "{", "$", "controller", "=", "$", "matches", "[", "1", "]", ";", "$", "method", "=", "$", "matches", "[", "2", "]", ";", "if", "(", "$", "this", "->", "container", "->", "has", "(", "$", "controller", ")", ")", "{", "$", "this", "->", "container", "->", "enterScope", "(", "'request'", ")", ";", "$", "this", "->", "container", "->", "set", "(", "'request'", ",", "new", "Request", ")", ";", "$", "class", "=", "get_class", "(", "$", "this", "->", "container", "->", "get", "(", "$", "controller", ")", ")", ";", "$", "this", "->", "container", "->", "leaveScope", "(", "'request'", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "class", ")", "&&", "isset", "(", "$", "method", ")", ")", "{", "try", "{", "return", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "$", "method", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "}", "}", "return", "null", ";", "}" ]
Returns the ReflectionMethod for the given controller string @param string $controller @return ReflectionMethod|null
[ "Returns", "the", "ReflectionMethod", "for", "the", "given", "controller", "string" ]
6eef4ace887c19ef166ab6654de385bc1ffbf5f1
https://github.com/brunschgi/TerrificComposerBundle/blob/6eef4ace887c19ef166ab6654de385bc1ffbf5f1/Service/PageManager.php#L101-L125
train
fulgurio/LightCMSBundle
Repository/PageRepository.php
PageRepository.upPagesPosition
public function upPagesPosition($parentId, $position, $positionLimit = NULL) { if (is_null($positionLimit)) { $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:pageType'); } else { $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.position<=:positionLimit AND p.parent=:parentId AND p.page_type=:pageType'); $query->setParameter('positionLimit', $positionLimit); } $query->setParameter('pageType', 'page'); $query->setParameter('position', $position); $query->setParameter('parentId', $parentId); $query->getResult(); }
php
public function upPagesPosition($parentId, $position, $positionLimit = NULL) { if (is_null($positionLimit)) { $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:pageType'); } else { $query = $this->getEntityManager()->createQuery('UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.position<=:positionLimit AND p.parent=:parentId AND p.page_type=:pageType'); $query->setParameter('positionLimit', $positionLimit); } $query->setParameter('pageType', 'page'); $query->setParameter('position', $position); $query->setParameter('parentId', $parentId); $query->getResult(); }
[ "public", "function", "upPagesPosition", "(", "$", "parentId", ",", "$", "position", ",", "$", "positionLimit", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "positionLimit", ")", ")", "{", "$", "query", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQuery", "(", "'UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.parent=:parentId AND p.page_type=:pageType'", ")", ";", "}", "else", "{", "$", "query", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQuery", "(", "'UPDATE FulgurioLightCMSBundle:Page p SET p.position=p.position-1 WHERE p.position>=:position AND p.position<=:positionLimit AND p.parent=:parentId AND p.page_type=:pageType'", ")", ";", "$", "query", "->", "setParameter", "(", "'positionLimit'", ",", "$", "positionLimit", ")", ";", "}", "$", "query", "->", "setParameter", "(", "'pageType'", ",", "'page'", ")", ";", "$", "query", "->", "setParameter", "(", "'position'", ",", "$", "position", ")", ";", "$", "query", "->", "setParameter", "(", "'parentId'", ",", "$", "parentId", ")", ";", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Up pages position @param number $parentId @param number $position @param number $positionLimit
[ "Up", "pages", "position" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Repository/PageRepository.php#L30-L45
train
fulgurio/LightCMSBundle
Repository/PageRepository.php
PageRepository.getNextPosition
public function getNextPosition($parentId) { $query = $this->getEntityManager()->createQuery('SELECT MAX(p.position) FROM FulgurioLightCMSBundle:Page p WHERE p.parent=:parentId AND p.page_type=:pageType'); $query->setParameter('pageType', 'page'); $query->setParameter('parentId', $parentId); return $query->getSingleScalarResult() + 1; }
php
public function getNextPosition($parentId) { $query = $this->getEntityManager()->createQuery('SELECT MAX(p.position) FROM FulgurioLightCMSBundle:Page p WHERE p.parent=:parentId AND p.page_type=:pageType'); $query->setParameter('pageType', 'page'); $query->setParameter('parentId', $parentId); return $query->getSingleScalarResult() + 1; }
[ "public", "function", "getNextPosition", "(", "$", "parentId", ")", "{", "$", "query", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "createQuery", "(", "'SELECT MAX(p.position) FROM FulgurioLightCMSBundle:Page p WHERE p.parent=:parentId AND p.page_type=:pageType'", ")", ";", "$", "query", "->", "setParameter", "(", "'pageType'", ",", "'page'", ")", ";", "$", "query", "->", "setParameter", "(", "'parentId'", ",", "$", "parentId", ")", ";", "return", "$", "query", "->", "getSingleScalarResult", "(", ")", "+", "1", ";", "}" ]
Get next position in tree @param number $parentId @return number
[ "Get", "next", "position", "in", "tree" ]
66319af52b97b6552b7c391ee370538263f42d10
https://github.com/fulgurio/LightCMSBundle/blob/66319af52b97b6552b7c391ee370538263f42d10/Repository/PageRepository.php#L77-L83
train
wb-crowdfusion/crowdfusion
system/core/classes/nodedb/utils/TagUtils.php
TagUtils.validateTags
public static function validateTags(array &$array, $direction = null) { foreach ($array as $key => $tag) { $array[$key] = self::validateTag($tag, $direction); } return $array; }
php
public static function validateTags(array &$array, $direction = null) { foreach ($array as $key => $tag) { $array[$key] = self::validateTag($tag, $direction); } return $array; }
[ "public", "static", "function", "validateTags", "(", "array", "&", "$", "array", ",", "$", "direction", "=", "null", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "tag", ")", "{", "$", "array", "[", "$", "key", "]", "=", "self", "::", "validateTag", "(", "$", "tag", ",", "$", "direction", ")", ";", "}", "return", "$", "array", ";", "}" ]
Validates that the given array contains all valid Tag entries @param array &$array An array of strings or Tag objects @param string $direction Either 'in' or 'out'. Used to specify the direction for all tags in the array @return void @throws Exception if any items are invalid.
[ "Validates", "that", "the", "given", "array", "contains", "all", "valid", "Tag", "entries" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/utils/TagUtils.php#L49-L56
train
wb-crowdfusion/crowdfusion
system/core/classes/nodedb/utils/TagUtils.php
TagUtils.matchTags
public static function matchTags(array $tags1, array $tags2) { if (count(self::diffTags($tags1, $tags2)) == 0 && count(self::diffTags($tags2, $tags1)) == 0) return true; return false; }
php
public static function matchTags(array $tags1, array $tags2) { if (count(self::diffTags($tags1, $tags2)) == 0 && count(self::diffTags($tags2, $tags1)) == 0) return true; return false; }
[ "public", "static", "function", "matchTags", "(", "array", "$", "tags1", ",", "array", "$", "tags2", ")", "{", "if", "(", "count", "(", "self", "::", "diffTags", "(", "$", "tags1", ",", "$", "tags2", ")", ")", "==", "0", "&&", "count", "(", "self", "::", "diffTags", "(", "$", "tags2", ",", "$", "tags1", ")", ")", "==", "0", ")", "return", "true", ";", "return", "false", ";", "}" ]
Determines if the tags in both arrays are a match @param array $tags1 An array of Tag objects @param array $tags2 An Array of Tag objects @return boolean true if both array contain the same tags
[ "Determines", "if", "the", "tags", "in", "both", "arrays", "are", "a", "match" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/nodedb/utils/TagUtils.php#L220-L228
train
Xsaven/laravel-intelect-admin
src/Addons/JWTAuth/Claims/Claim.php
Claim.setValue
public function setValue($value) { if (! $this->validate($value)) { throw new InvalidClaimException('Invalid value provided for claim "'.$this->getName().'": '.$value); } $this->value = $value; return $this; }
php
public function setValue($value) { if (! $this->validate($value)) { throw new InvalidClaimException('Invalid value provided for claim "'.$this->getName().'": '.$value); } $this->value = $value; return $this; }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "validate", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidClaimException", "(", "'Invalid value provided for claim \"'", ".", "$", "this", "->", "getName", "(", ")", ".", "'\": '", ".", "$", "value", ")", ";", "}", "$", "this", "->", "value", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set the claim value, and call a validate method if available. @param $value @throws \Lia\Addons\JWTAuth\Exceptions\InvalidClaimException @return $this
[ "Set", "the", "claim", "value", "and", "call", "a", "validate", "method", "if", "available", "." ]
592574633d12c74cf25b43dd6694fee496abefcb
https://github.com/Xsaven/laravel-intelect-admin/blob/592574633d12c74cf25b43dd6694fee496abefcb/src/Addons/JWTAuth/Claims/Claim.php#L38-L47
train
betasyntax/Betasyntax-Framework-Core
src/Betasyntax/Router/Router.php
Router.fakeUrl
public function fakeUrl($route, $params) { if (preg_match_all('/\[[\s\S]+?]/', $route, $matches, PREG_SET_ORDER)) { for ($i=0;$i<count($matches);$i++) { $route = preg_replace('/\[[\s\S]+?]/', $params[$i], $route); } } return($route); }
php
public function fakeUrl($route, $params) { if (preg_match_all('/\[[\s\S]+?]/', $route, $matches, PREG_SET_ORDER)) { for ($i=0;$i<count($matches);$i++) { $route = preg_replace('/\[[\s\S]+?]/', $params[$i], $route); } } return($route); }
[ "public", "function", "fakeUrl", "(", "$", "route", ",", "$", "params", ")", "{", "if", "(", "preg_match_all", "(", "'/\\[[\\s\\S]+?]/'", ",", "$", "route", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "matches", ")", ";", "$", "i", "++", ")", "{", "$", "route", "=", "preg_replace", "(", "'/\\[[\\s\\S]+?]/'", ",", "$", "params", "[", "$", "i", "]", ",", "$", "route", ")", ";", "}", "}", "return", "(", "$", "route", ")", ";", "}" ]
Return the real url genereted from a named route @param string $route The untouched route from the link_to function @param array $params Data to be injected into the route @return string Return the generated url from the named route provided to the link_to function
[ "Return", "the", "real", "url", "genereted", "from", "a", "named", "route" ]
2d135ec1f7dd98e6ef21512a069ac2595f1eb78e
https://github.com/betasyntax/Betasyntax-Framework-Core/blob/2d135ec1f7dd98e6ef21512a069ac2595f1eb78e/src/Betasyntax/Router/Router.php#L174-L182
train
cubicmushroom/valueobjects
src/Number/Complex.php
Complex.fromNative
public static function fromNative() { $args = \func_get_args(); if (\count($args) != 2) { throw new \BadMethodCallException('You must provide 2 arguments: 1) real part, 2) imaginary part'); } $real = Real::fromNative($args[0]); $im = Real::fromNative($args[1]); $complex = new self($real, $im); return $complex; }
php
public static function fromNative() { $args = \func_get_args(); if (\count($args) != 2) { throw new \BadMethodCallException('You must provide 2 arguments: 1) real part, 2) imaginary part'); } $real = Real::fromNative($args[0]); $im = Real::fromNative($args[1]); $complex = new self($real, $im); return $complex; }
[ "public", "static", "function", "fromNative", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "args", ")", "!=", "2", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'You must provide 2 arguments: 1) real part, 2) imaginary part'", ")", ";", "}", "$", "real", "=", "Real", "::", "fromNative", "(", "$", "args", "[", "0", "]", ")", ";", "$", "im", "=", "Real", "::", "fromNative", "(", "$", "args", "[", "1", "]", ")", ";", "$", "complex", "=", "new", "self", "(", "$", "real", ",", "$", "im", ")", ";", "return", "$", "complex", ";", "}" ]
Returns a new Complex object from native PHP arguments @param float $real Real part of the complex number @param float $im Imaginary part of the complex number @return Complex|ValueObjectInterface @throws \BadMethodCallException
[ "Returns", "a", "new", "Complex", "object", "from", "native", "PHP", "arguments" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Number/Complex.php#L24-L37
train
cubicmushroom/valueobjects
src/Number/Complex.php
Complex.fromPolar
public static function fromPolar(Real $modulus, Real $argument) { $realValue = $modulus->toNative() * \cos($argument->toNative()); $imValue = $modulus->toNative() * \sin($argument->toNative()); $real = new Real($realValue); $im = new Real($imValue); $complex = new self($real, $im); return $complex; }
php
public static function fromPolar(Real $modulus, Real $argument) { $realValue = $modulus->toNative() * \cos($argument->toNative()); $imValue = $modulus->toNative() * \sin($argument->toNative()); $real = new Real($realValue); $im = new Real($imValue); $complex = new self($real, $im); return $complex; }
[ "public", "static", "function", "fromPolar", "(", "Real", "$", "modulus", ",", "Real", "$", "argument", ")", "{", "$", "realValue", "=", "$", "modulus", "->", "toNative", "(", ")", "*", "\\", "cos", "(", "$", "argument", "->", "toNative", "(", ")", ")", ";", "$", "imValue", "=", "$", "modulus", "->", "toNative", "(", ")", "*", "\\", "sin", "(", "$", "argument", "->", "toNative", "(", ")", ")", ";", "$", "real", "=", "new", "Real", "(", "$", "realValue", ")", ";", "$", "im", "=", "new", "Real", "(", "$", "imValue", ")", ";", "$", "complex", "=", "new", "self", "(", "$", "real", ",", "$", "im", ")", ";", "return", "$", "complex", ";", "}" ]
Returns a Complex given polar coordinates @param Real $modulus @param Real $argument @return Complex
[ "Returns", "a", "Complex", "given", "polar", "coordinates" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/Number/Complex.php#L46-L55
train
stubbles/stubbles-peer
src/main/php/http/AcceptHeader.php
AcceptHeader.parse
public static function parse(string $headerValue): self { $self = new self(); foreach (explode(',', $headerValue) as $acceptable) { // seems to be impossible to parse acceptables with regular // expressions or even scanf(), so we do some string crunching here if (strstr($acceptable, 'q=') !== false) { list($acceptable, $priority) = explode('q=', trim($acceptable)); } else { $priority = 1; } settype($priority, 'float'); $acceptable = trim($acceptable); if (substr($acceptable, -1) === ';') { $acceptable = substr($acceptable, 0, -1); } $self->addAcceptable($acceptable, $priority); } return $self; }
php
public static function parse(string $headerValue): self { $self = new self(); foreach (explode(',', $headerValue) as $acceptable) { // seems to be impossible to parse acceptables with regular // expressions or even scanf(), so we do some string crunching here if (strstr($acceptable, 'q=') !== false) { list($acceptable, $priority) = explode('q=', trim($acceptable)); } else { $priority = 1; } settype($priority, 'float'); $acceptable = trim($acceptable); if (substr($acceptable, -1) === ';') { $acceptable = substr($acceptable, 0, -1); } $self->addAcceptable($acceptable, $priority); } return $self; }
[ "public", "static", "function", "parse", "(", "string", "$", "headerValue", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", ")", ";", "foreach", "(", "explode", "(", "','", ",", "$", "headerValue", ")", "as", "$", "acceptable", ")", "{", "// seems to be impossible to parse acceptables with regular", "// expressions or even scanf(), so we do some string crunching here", "if", "(", "strstr", "(", "$", "acceptable", ",", "'q='", ")", "!==", "false", ")", "{", "list", "(", "$", "acceptable", ",", "$", "priority", ")", "=", "explode", "(", "'q='", ",", "trim", "(", "$", "acceptable", ")", ")", ";", "}", "else", "{", "$", "priority", "=", "1", ";", "}", "settype", "(", "$", "priority", ",", "'float'", ")", ";", "$", "acceptable", "=", "trim", "(", "$", "acceptable", ")", ";", "if", "(", "substr", "(", "$", "acceptable", ",", "-", "1", ")", "===", "';'", ")", "{", "$", "acceptable", "=", "substr", "(", "$", "acceptable", ",", "0", ",", "-", "1", ")", ";", "}", "$", "self", "->", "addAcceptable", "(", "$", "acceptable", ",", "$", "priority", ")", ";", "}", "return", "$", "self", ";", "}" ]
method to create an instance from a string header value @param string $headerValue @return \stubbles\peer\http\AcceptHeader
[ "method", "to", "create", "an", "instance", "from", "a", "string", "header", "value" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/AcceptHeader.php#L32-L54
train
stubbles/stubbles-peer
src/main/php/http/AcceptHeader.php
AcceptHeader.addAcceptable
public function addAcceptable(string $acceptable, float $priority = 1.0): self { if (0 > $priority || 1.0 < $priority) { throw new \InvalidArgumentException( 'Invalid priority, must be between 0 and 1.0' ); } $this->acceptables[$acceptable] = $priority; return $this; }
php
public function addAcceptable(string $acceptable, float $priority = 1.0): self { if (0 > $priority || 1.0 < $priority) { throw new \InvalidArgumentException( 'Invalid priority, must be between 0 and 1.0' ); } $this->acceptables[$acceptable] = $priority; return $this; }
[ "public", "function", "addAcceptable", "(", "string", "$", "acceptable", ",", "float", "$", "priority", "=", "1.0", ")", ":", "self", "{", "if", "(", "0", ">", "$", "priority", "||", "1.0", "<", "$", "priority", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid priority, must be between 0 and 1.0'", ")", ";", "}", "$", "this", "->", "acceptables", "[", "$", "acceptable", "]", "=", "$", "priority", ";", "return", "$", "this", ";", "}" ]
add an acceptable to the list @param string $acceptable @param float $priority defaults to 1.0 @return \stubbles\peer\http\AcceptHeader @throws \InvalidArgumentException
[ "add", "an", "acceptable", "to", "the", "list" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/AcceptHeader.php#L74-L84
train
stubbles/stubbles-peer
src/main/php/http/AcceptHeader.php
AcceptHeader.priorityFor
public function priorityFor(string $mimeType): float { if (!isset($this->acceptables[$mimeType])) { if ($this->count() === 0) { return 1.0; } elseif (isset($this->acceptables['*/*'])) { return $this->acceptables['*/*']; } list($maintype) = explode('/', $mimeType); return $this->acceptables[$maintype . '/*'] ?? 0; } return $this->acceptables[$mimeType]; }
php
public function priorityFor(string $mimeType): float { if (!isset($this->acceptables[$mimeType])) { if ($this->count() === 0) { return 1.0; } elseif (isset($this->acceptables['*/*'])) { return $this->acceptables['*/*']; } list($maintype) = explode('/', $mimeType); return $this->acceptables[$maintype . '/*'] ?? 0; } return $this->acceptables[$mimeType]; }
[ "public", "function", "priorityFor", "(", "string", "$", "mimeType", ")", ":", "float", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "acceptables", "[", "$", "mimeType", "]", ")", ")", "{", "if", "(", "$", "this", "->", "count", "(", ")", "===", "0", ")", "{", "return", "1.0", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "acceptables", "[", "'*/*'", "]", ")", ")", "{", "return", "$", "this", "->", "acceptables", "[", "'*/*'", "]", ";", "}", "list", "(", "$", "maintype", ")", "=", "explode", "(", "'/'", ",", "$", "mimeType", ")", ";", "return", "$", "this", "->", "acceptables", "[", "$", "maintype", ".", "'/*'", "]", "??", "0", ";", "}", "return", "$", "this", "->", "acceptables", "[", "$", "mimeType", "]", ";", "}" ]
returns priority for given acceptable If returned priority is 0 the requested acceptable is not in the list. In case no acceptables were added before every requested acceptable has a priority of 1.0. @param string $mimeType @return float
[ "returns", "priority", "for", "given", "acceptable" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/AcceptHeader.php#L96-L110
train
stubbles/stubbles-peer
src/main/php/http/AcceptHeader.php
AcceptHeader.asString
public function asString(): string { $parts = []; foreach ($this->acceptables as $acceptable => $priority) { if (1.0 === $priority) { $parts[] = $acceptable; } else { $parts[] = $acceptable . ';q=' . $priority; } } return join(',', $parts); }
php
public function asString(): string { $parts = []; foreach ($this->acceptables as $acceptable => $priority) { if (1.0 === $priority) { $parts[] = $acceptable; } else { $parts[] = $acceptable . ';q=' . $priority; } } return join(',', $parts); }
[ "public", "function", "asString", "(", ")", ":", "string", "{", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "acceptables", "as", "$", "acceptable", "=>", "$", "priority", ")", "{", "if", "(", "1.0", "===", "$", "priority", ")", "{", "$", "parts", "[", "]", "=", "$", "acceptable", ";", "}", "else", "{", "$", "parts", "[", "]", "=", "$", "acceptable", ".", "';q='", ".", "$", "priority", ";", "}", "}", "return", "join", "(", "','", ",", "$", "parts", ")", ";", "}" ]
returns current list as string @return string
[ "returns", "current", "list", "as", "string" ]
dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc
https://github.com/stubbles/stubbles-peer/blob/dc8b0a517dc4c84b615cc3c88f0d64a2b742f9cc/src/main/php/http/AcceptHeader.php#L211-L223
train
miaoxing/plugin
src/Model/CastTrait.php
CastTrait.castToPhp
protected function castToPhp($value, $column) { if ($value !== null && $this->hasCast($column) && !$this->isIgnoreCast($value)) { $value = $this->toPhpType($value, $this->casts[$column]); } return $value; }
php
protected function castToPhp($value, $column) { if ($value !== null && $this->hasCast($column) && !$this->isIgnoreCast($value)) { $value = $this->toPhpType($value, $this->casts[$column]); } return $value; }
[ "protected", "function", "castToPhp", "(", "$", "value", ",", "$", "column", ")", "{", "if", "(", "$", "value", "!==", "null", "&&", "$", "this", "->", "hasCast", "(", "$", "column", ")", "&&", "!", "$", "this", "->", "isIgnoreCast", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "toPhpType", "(", "$", "value", ",", "$", "this", "->", "casts", "[", "$", "column", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
Cast column value to PHP type @param mixed $value @param string $column @return mixed @throws \Exception
[ "Cast", "column", "value", "to", "PHP", "type" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Model/CastTrait.php#L33-L40
train
miaoxing/plugin
src/Model/CastTrait.php
CastTrait.castToDb
protected function castToDb($value, $column) { if ($this->hasCast($column) && !$this->isIgnoreCast($value)) { $value = $this->toDbType($value, $this->casts[$column]); } return $value; }
php
protected function castToDb($value, $column) { if ($this->hasCast($column) && !$this->isIgnoreCast($value)) { $value = $this->toDbType($value, $this->casts[$column]); } return $value; }
[ "protected", "function", "castToDb", "(", "$", "value", ",", "$", "column", ")", "{", "if", "(", "$", "this", "->", "hasCast", "(", "$", "column", ")", "&&", "!", "$", "this", "->", "isIgnoreCast", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "toDbType", "(", "$", "value", ",", "$", "this", "->", "casts", "[", "$", "column", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
Cast column value for saving to database @param mixed $value @param string $column @return mixed
[ "Cast", "column", "value", "for", "saving", "to", "database" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Model/CastTrait.php#L49-L56
train
miaoxing/plugin
src/Model/CastTrait.php
CastTrait.toDbType
protected function toDbType($value, $type) { switch ($type) { case 'int': return (int) $value; case 'bool': return (bool) $value; case 'string': case 'datetime': // Coverts by database case 'date': case 'float': return (string) $value; case 'array': case 'json': return json_encode((array) $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); default: throw new InvalidArgumentException('Unsupported cast type: ' . $type); } }
php
protected function toDbType($value, $type) { switch ($type) { case 'int': return (int) $value; case 'bool': return (bool) $value; case 'string': case 'datetime': // Coverts by database case 'date': case 'float': return (string) $value; case 'array': case 'json': return json_encode((array) $value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); default: throw new InvalidArgumentException('Unsupported cast type: ' . $type); } }
[ "protected", "function", "toDbType", "(", "$", "value", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "return", "(", "int", ")", "$", "value", ";", "case", "'bool'", ":", "return", "(", "bool", ")", "$", "value", ";", "case", "'string'", ":", "case", "'datetime'", ":", "// Coverts by database", "case", "'date'", ":", "case", "'float'", ":", "return", "(", "string", ")", "$", "value", ";", "case", "'array'", ":", "case", "'json'", ":", "return", "json_encode", "(", "(", "array", ")", "$", "value", ",", "JSON_UNESCAPED_SLASHES", "|", "JSON_UNESCAPED_UNICODE", ")", ";", "default", ":", "throw", "new", "InvalidArgumentException", "(", "'Unsupported cast type: '", ".", "$", "type", ")", ";", "}", "}" ]
Cast value for saving to database @param mixed $value @param string $type @return mixed
[ "Cast", "value", "for", "saving", "to", "database" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Model/CastTrait.php#L114-L136
train
miaoxing/plugin
src/Model/CastTrait.php
CastTrait.cacheJsonDecode
protected function cacheJsonDecode($value, $assoc = false) { if (!isset(static::$castCache[$value][$assoc])) { static::$castCache[$value][$assoc] = json_decode($value, $assoc); } return static::$castCache[$value][$assoc]; }
php
protected function cacheJsonDecode($value, $assoc = false) { if (!isset(static::$castCache[$value][$assoc])) { static::$castCache[$value][$assoc] = json_decode($value, $assoc); } return static::$castCache[$value][$assoc]; }
[ "protected", "function", "cacheJsonDecode", "(", "$", "value", ",", "$", "assoc", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "castCache", "[", "$", "value", "]", "[", "$", "assoc", "]", ")", ")", "{", "static", "::", "$", "castCache", "[", "$", "value", "]", "[", "$", "assoc", "]", "=", "json_decode", "(", "$", "value", ",", "$", "assoc", ")", ";", "}", "return", "static", "::", "$", "castCache", "[", "$", "value", "]", "[", "$", "assoc", "]", ";", "}" ]
Cache json decode value @param string $value @param bool $assoc @return mixed
[ "Cache", "json", "decode", "value" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Model/CastTrait.php#L145-L152
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.makeApp
static public function makeApp($envPath = null, array $config = [], $kernel = null) { $envPath = is_null($envPath) ? static::getRuntimePath() : $envPath; $kernel = is_null($kernel) ? static::defaultKernel() : $kernel; $config = empty($config) ? static::defaultConfig() : $config; return new static($envPath, $kernel, $config); }
php
static public function makeApp($envPath = null, array $config = [], $kernel = null) { $envPath = is_null($envPath) ? static::getRuntimePath() : $envPath; $kernel = is_null($kernel) ? static::defaultKernel() : $kernel; $config = empty($config) ? static::defaultConfig() : $config; return new static($envPath, $kernel, $config); }
[ "static", "public", "function", "makeApp", "(", "$", "envPath", "=", "null", ",", "array", "$", "config", "=", "[", "]", ",", "$", "kernel", "=", "null", ")", "{", "$", "envPath", "=", "is_null", "(", "$", "envPath", ")", "?", "static", "::", "getRuntimePath", "(", ")", ":", "$", "envPath", ";", "$", "kernel", "=", "is_null", "(", "$", "kernel", ")", "?", "static", "::", "defaultKernel", "(", ")", ":", "$", "kernel", ";", "$", "config", "=", "empty", "(", "$", "config", ")", "?", "static", "::", "defaultConfig", "(", ")", ":", "$", "config", ";", "return", "new", "static", "(", "$", "envPath", ",", "$", "kernel", ",", "$", "config", ")", ";", "}" ]
Static factor constructor. @param string $kernel @param string $envPath @param array $segments @return Kernel instance
[ "Static", "factor", "constructor", "." ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L58-L65
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.config
public function config() { if ($this->appConfig) { return $this->appConfig; } return $this->appConfig = $this->app->make('config'); }
php
public function config() { if ($this->appConfig) { return $this->appConfig; } return $this->appConfig = $this->app->make('config'); }
[ "public", "function", "config", "(", ")", "{", "if", "(", "$", "this", "->", "appConfig", ")", "{", "return", "$", "this", "->", "appConfig", ";", "}", "return", "$", "this", "->", "appConfig", "=", "$", "this", "->", "app", "->", "make", "(", "'config'", ")", ";", "}" ]
Get application config repository; @return Repository
[ "Get", "application", "config", "repository", ";" ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L142-L149
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.bootComponents
protected function bootComponents() { $config = $this->config(); foreach ($this->componentInstances as $instance) { $instance->boot($this->app, $config); } }
php
protected function bootComponents() { $config = $this->config(); foreach ($this->componentInstances as $instance) { $instance->boot($this->app, $config); } }
[ "protected", "function", "bootComponents", "(", ")", "{", "$", "config", "=", "$", "this", "->", "config", "(", ")", ";", "foreach", "(", "$", "this", "->", "componentInstances", "as", "$", "instance", ")", "{", "$", "instance", "->", "boot", "(", "$", "this", "->", "app", ",", "$", "config", ")", ";", "}", "}" ]
Boot setup components. @return void
[ "Boot", "setup", "components", "." ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L156-L163
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.setupComponents
protected function setupComponents() { $components = Arr::get($this->config, 'components'); foreach ($components as $component) { $instance = new $component($this->config); $instance->setup(); $this->componentInstances[ $component ] = $instance; } }
php
protected function setupComponents() { $components = Arr::get($this->config, 'components'); foreach ($components as $component) { $instance = new $component($this->config); $instance->setup(); $this->componentInstances[ $component ] = $instance; } }
[ "protected", "function", "setupComponents", "(", ")", "{", "$", "components", "=", "Arr", "::", "get", "(", "$", "this", "->", "config", ",", "'components'", ")", ";", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "$", "instance", "=", "new", "$", "component", "(", "$", "this", "->", "config", ")", ";", "$", "instance", "->", "setup", "(", ")", ";", "$", "this", "->", "componentInstances", "[", "$", "component", "]", "=", "$", "instance", ";", "}", "}" ]
Build component instances and run setup method. @return void
[ "Build", "component", "instances", "and", "run", "setup", "method", "." ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L170-L179
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.buildAppConfig
protected function buildAppConfig($configPath) { $config = require($configPath); $callback = Arr::get($this->config, 'callback.vendor_config'); if ($callback instanceof Closure) { $config = call_user_func($callback, $config); } return $config; }
php
protected function buildAppConfig($configPath) { $config = require($configPath); $callback = Arr::get($this->config, 'callback.vendor_config'); if ($callback instanceof Closure) { $config = call_user_func($callback, $config); } return $config; }
[ "protected", "function", "buildAppConfig", "(", "$", "configPath", ")", "{", "$", "config", "=", "require", "(", "$", "configPath", ")", ";", "$", "callback", "=", "Arr", "::", "get", "(", "$", "this", "->", "config", ",", "'callback.vendor_config'", ")", ";", "if", "(", "$", "callback", "instanceof", "Closure", ")", "{", "$", "config", "=", "call_user_func", "(", "$", "callback", ",", "$", "config", ")", ";", "}", "return", "$", "config", ";", "}" ]
Include and add our Service Provider to the App config. @param string $configPath @return array
[ "Include", "and", "add", "our", "Service", "Provider", "to", "the", "App", "config", "." ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L238-L248
train
web-chefs/LaraAppSpawn
src/ApplicationResolver.php
ApplicationResolver.getRuntimePath
static public function getRuntimePath($depth = 2) { $stack = debug_backtrace(); $frame = $stack[count($stack) - $depth]; return dirname($frame['file']); }
php
static public function getRuntimePath($depth = 2) { $stack = debug_backtrace(); $frame = $stack[count($stack) - $depth]; return dirname($frame['file']); }
[ "static", "public", "function", "getRuntimePath", "(", "$", "depth", "=", "2", ")", "{", "$", "stack", "=", "debug_backtrace", "(", ")", ";", "$", "frame", "=", "$", "stack", "[", "count", "(", "$", "stack", ")", "-", "$", "depth", "]", ";", "return", "dirname", "(", "$", "frame", "[", "'file'", "]", ")", ";", "}" ]
Get the file location of the calling file. @param integer $depth @return string
[ "Get", "the", "file", "location", "of", "the", "calling", "file", "." ]
0eda486590fe7ca450836b9927a2498ff853cba6
https://github.com/web-chefs/LaraAppSpawn/blob/0eda486590fe7ca450836b9927a2498ff853cba6/src/ApplicationResolver.php#L320-L325
train
bazzline/php_component_template
source/ExpressiveTemplateAdapter.php
ExpressiveTemplateAdapter.addDefaultParam
public function addDefaultParam($templateName, $param, $value) { $isDefaultForAllTemplates = ($templateName === self::TEMPLATE_ALL); if ($isDefaultForAllTemplates) { $this->defaultParameters[$param] = $value; $this->defaultParametersProvided = true; } else { $this->fullQualifiedPathNameWithDefaultParameters[$templateName] = array($param => $value); } }
php
public function addDefaultParam($templateName, $param, $value) { $isDefaultForAllTemplates = ($templateName === self::TEMPLATE_ALL); if ($isDefaultForAllTemplates) { $this->defaultParameters[$param] = $value; $this->defaultParametersProvided = true; } else { $this->fullQualifiedPathNameWithDefaultParameters[$templateName] = array($param => $value); } }
[ "public", "function", "addDefaultParam", "(", "$", "templateName", ",", "$", "param", ",", "$", "value", ")", "{", "$", "isDefaultForAllTemplates", "=", "(", "$", "templateName", "===", "self", "::", "TEMPLATE_ALL", ")", ";", "if", "(", "$", "isDefaultForAllTemplates", ")", "{", "$", "this", "->", "defaultParameters", "[", "$", "param", "]", "=", "$", "value", ";", "$", "this", "->", "defaultParametersProvided", "=", "true", ";", "}", "else", "{", "$", "this", "->", "fullQualifiedPathNameWithDefaultParameters", "[", "$", "templateName", "]", "=", "array", "(", "$", "param", "=>", "$", "value", ")", ";", "}", "}" ]
Add a default parameter to use with a template. Use this method to provide a default parameter to use when a template is rendered. The parameter may be overridden by providing it when calling `render()`, or by calling this method again with a null value. The parameter will be specific to the template name provided. To make the parameter available to any template, pass the TEMPLATE_ALL constant for the template name. If the default parameter existed previously, subsequent invocations with the same template name and parameter name will overwrite. @param string $templateName Name of template to which the param applies; use TEMPLATE_ALL to apply to all templates. @param string $param Param name. @param mixed $value
[ "Add", "a", "default", "parameter", "to", "use", "with", "a", "template", "." ]
1e0e2b83a7336c457f6e6d38e7d4e091bf2521f4
https://github.com/bazzline/php_component_template/blob/1e0e2b83a7336c457f6e6d38e7d4e091bf2521f4/source/ExpressiveTemplateAdapter.php#L119-L129
train
comodojo/foundation
src/Comodojo/Foundation/Utils/UniqueId.php
UniqueId.generateCustom
public static function generateCustom($prefix, $length=128) { if ( $length <= (strlen($prefix)+1) ) { throw new InvalidArgumentException("Uid length cannot be smaller than prefix length +1"); } return "$prefix-".self::generate($length-(strlen($prefix)+1)); }
php
public static function generateCustom($prefix, $length=128) { if ( $length <= (strlen($prefix)+1) ) { throw new InvalidArgumentException("Uid length cannot be smaller than prefix length +1"); } return "$prefix-".self::generate($length-(strlen($prefix)+1)); }
[ "public", "static", "function", "generateCustom", "(", "$", "prefix", ",", "$", "length", "=", "128", ")", "{", "if", "(", "$", "length", "<=", "(", "strlen", "(", "$", "prefix", ")", "+", "1", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Uid length cannot be smaller than prefix length +1\"", ")", ";", "}", "return", "\"$prefix-\"", ".", "self", "::", "generate", "(", "$", "length", "-", "(", "strlen", "(", "$", "prefix", ")", "+", "1", ")", ")", ";", "}" ]
Generate a custom uid starting from a prefix The result uid format will be $string-[random] @param string $prefix @param int $length @return string
[ "Generate", "a", "custom", "uid", "starting", "from", "a", "prefix" ]
21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a
https://github.com/comodojo/foundation/blob/21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a/src/Comodojo/Foundation/Utils/UniqueId.php#L32-L41
train
comodojo/foundation
src/Comodojo/Foundation/Utils/UniqueId.php
UniqueId.generate
public static function generate($length=128) { if ($length < 32) { return substr(self::getUid(), 0, $length); } else if ($length == 32) { return self::getUid(); } else { $numString = (int)($length/32) + 1; $randNum = ""; for ($i = 0; $i < $numString; $i++) $randNum .= self::getUid(); return substr($randNum, 0, $length); } }
php
public static function generate($length=128) { if ($length < 32) { return substr(self::getUid(), 0, $length); } else if ($length == 32) { return self::getUid(); } else { $numString = (int)($length/32) + 1; $randNum = ""; for ($i = 0; $i < $numString; $i++) $randNum .= self::getUid(); return substr($randNum, 0, $length); } }
[ "public", "static", "function", "generate", "(", "$", "length", "=", "128", ")", "{", "if", "(", "$", "length", "<", "32", ")", "{", "return", "substr", "(", "self", "::", "getUid", "(", ")", ",", "0", ",", "$", "length", ")", ";", "}", "else", "if", "(", "$", "length", "==", "32", ")", "{", "return", "self", "::", "getUid", "(", ")", ";", "}", "else", "{", "$", "numString", "=", "(", "int", ")", "(", "$", "length", "/", "32", ")", "+", "1", ";", "$", "randNum", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numString", ";", "$", "i", "++", ")", "$", "randNum", ".=", "self", "::", "getUid", "(", ")", ";", "return", "substr", "(", "$", "randNum", ",", "0", ",", "$", "length", ")", ";", "}", "}" ]
Generate an uid @param int $length @return string
[ "Generate", "an", "uid" ]
21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a
https://github.com/comodojo/foundation/blob/21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a/src/Comodojo/Foundation/Utils/UniqueId.php#L49-L69
train
stubbles/stubbles-image
src/main/php/Image.php
Image.load
public static function load(string $fileName, ImageDriver $driver = null): self { $self = new self($fileName, $driver); $self->handle = $self->driver->load($fileName); return $self; }
php
public static function load(string $fileName, ImageDriver $driver = null): self { $self = new self($fileName, $driver); $self->handle = $self->driver->load($fileName); return $self; }
[ "public", "static", "function", "load", "(", "string", "$", "fileName", ",", "ImageDriver", "$", "driver", "=", "null", ")", ":", "self", "{", "$", "self", "=", "new", "self", "(", "$", "fileName", ",", "$", "driver", ")", ";", "$", "self", "->", "handle", "=", "$", "self", "->", "driver", "->", "load", "(", "$", "fileName", ")", ";", "return", "$", "self", ";", "}" ]
loads image from file @param string $fileName file name of image to load @param \stubbles\img\ImageDriver $driver optional defaults to PngDriver @return \stubbles\img\Image
[ "loads", "image", "from", "file" ]
5ae6488a94c7b2eb97e042875a19ba43efc414fa
https://github.com/stubbles/stubbles-image/blob/5ae6488a94c7b2eb97e042875a19ba43efc414fa/src/main/php/Image.php#L66-L71
train
stubbles/stubbles-image
src/main/php/Image.php
Image.store
public function store(string $fileName): self { $this->driver->store($fileName, $this->handle); return $this; }
php
public function store(string $fileName): self { $this->driver->store($fileName, $this->handle); return $this; }
[ "public", "function", "store", "(", "string", "$", "fileName", ")", ":", "self", "{", "$", "this", "->", "driver", "->", "store", "(", "$", "fileName", ",", "$", "this", "->", "handle", ")", ";", "return", "$", "this", ";", "}" ]
stores image under given file name @param string $fileName @return \stubbles\img\Image
[ "stores", "image", "under", "given", "file", "name" ]
5ae6488a94c7b2eb97e042875a19ba43efc414fa
https://github.com/stubbles/stubbles-image/blob/5ae6488a94c7b2eb97e042875a19ba43efc414fa/src/main/php/Image.php#L99-L103
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.MemberCheckList
static function MemberCheckList($name, Member $member) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::MemberMembergroups($member)); $field->SetValue($groupIDs); return $field; }
php
static function MemberCheckList($name, Member $member) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::MemberMembergroups($member)); $field->SetValue($groupIDs); return $field; }
[ "static", "function", "MemberCheckList", "(", "$", "name", ",", "Member", "$", "member", ")", "{", "$", "field", "=", "new", "CheckList", "(", "$", "name", ")", ";", "self", "::", "AddMembergroupOptions", "(", "$", "field", ")", ";", "$", "groupIDs", "=", "Membergroup", "::", "GetKeyList", "(", "self", "::", "MemberMembergroups", "(", "$", "member", ")", ")", ";", "$", "field", "->", "SetValue", "(", "$", "groupIDs", ")", ";", "return", "$", "field", ";", "}" ]
Creates a check list field for groups of a member @param string $name The field name @param Member $member The member @return CheckList Returns the check list
[ "Creates", "a", "check", "list", "field", "for", "groups", "of", "a", "member" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L27-L34
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.PageCheckList
static function PageCheckList($name, Page $page) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::PageMembergroups($page)); $field->SetValue($groupIDs); return $field; }
php
static function PageCheckList($name, Page $page) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::PageMembergroups($page)); $field->SetValue($groupIDs); return $field; }
[ "static", "function", "PageCheckList", "(", "$", "name", ",", "Page", "$", "page", ")", "{", "$", "field", "=", "new", "CheckList", "(", "$", "name", ")", ";", "self", "::", "AddMembergroupOptions", "(", "$", "field", ")", ";", "$", "groupIDs", "=", "Membergroup", "::", "GetKeyList", "(", "self", "::", "PageMembergroups", "(", "$", "page", ")", ")", ";", "$", "field", "->", "SetValue", "(", "$", "groupIDs", ")", ";", "return", "$", "field", ";", "}" ]
Creates a check list field for groups of a page @param string $name The field name @param Page $page The page @return CheckList Returns the check list
[ "Creates", "a", "check", "list", "field", "for", "groups", "of", "a", "page" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L42-L49
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.ContentCheckList
static function ContentCheckList($name, Content $content) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::ContentMembergroups($content)); $field->SetValue($groupIDs); return $field; }
php
static function ContentCheckList($name, Content $content) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::ContentMembergroups($content)); $field->SetValue($groupIDs); return $field; }
[ "static", "function", "ContentCheckList", "(", "$", "name", ",", "Content", "$", "content", ")", "{", "$", "field", "=", "new", "CheckList", "(", "$", "name", ")", ";", "self", "::", "AddMembergroupOptions", "(", "$", "field", ")", ";", "$", "groupIDs", "=", "Membergroup", "::", "GetKeyList", "(", "self", "::", "ContentMembergroups", "(", "$", "content", ")", ")", ";", "$", "field", "->", "SetValue", "(", "$", "groupIDs", ")", ";", "return", "$", "field", ";", "}" ]
Creates a check list field for groups of a content @param string $name The field name @param Content $content The content @return CheckList Returns the check list
[ "Creates", "a", "check", "list", "field", "for", "groups", "of", "a", "content" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L57-L64
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.MemberMembergroups
static function MemberMembergroups(Member $member) { if (!$member->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblMmg = MemberMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblMmg); $joinCondition = $sql->Equals($tblMmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($member->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
php
static function MemberMembergroups(Member $member) { if (!$member->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblMmg = MemberMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblMmg); $joinCondition = $sql->Equals($tblMmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblMmg->Field('Member'), $sql->Value($member->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
[ "static", "function", "MemberMembergroups", "(", "Member", "$", "member", ")", "{", "if", "(", "!", "$", "member", "->", "Exists", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tblMmg", "=", "MemberMembergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "tblMg", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "join", "=", "$", "sql", "->", "Join", "(", "$", "tblMmg", ")", ";", "$", "joinCondition", "=", "$", "sql", "->", "Equals", "(", "$", "tblMmg", "->", "Field", "(", "'MemberGroup'", ")", ",", "$", "tblMg", "->", "Field", "(", "'ID'", ")", ")", ";", "$", "where", "=", "$", "sql", "->", "Equals", "(", "$", "tblMmg", "->", "Field", "(", "'Member'", ")", ",", "$", "sql", "->", "Value", "(", "$", "member", "->", "GetID", "(", ")", ")", ")", ";", "$", "orderBy", "=", "$", "sql", "->", "OrderList", "(", "$", "sql", "->", "OrderAsc", "(", "$", "tblMg", "->", "Field", "(", "'Name'", ")", ")", ")", ";", "return", "Membergroup", "::", "Schema", "(", ")", "->", "Fetch", "(", "false", ",", "$", "where", ",", "$", "orderBy", ",", "null", ",", "0", ",", "null", ",", "$", "join", ",", "JoinType", "::", "Inner", "(", ")", ",", "$", "joinCondition", ")", ";", "}" ]
Gets the member's member groups @param Member $member @return Membergroup[] Returns the member groups assigned to the user
[ "Gets", "the", "member", "s", "member", "groups" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L72-L87
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.PageMembergroups
static function PageMembergroups(Page $page) { if (!$page->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblPmg = PageMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblPmg); $joinCondition = $sql->Equals($tblPmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblPmg->Field('Page'), $sql->Value($page->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
php
static function PageMembergroups(Page $page) { if (!$page->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblPmg = PageMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblPmg); $joinCondition = $sql->Equals($tblPmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblPmg->Field('Page'), $sql->Value($page->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
[ "static", "function", "PageMembergroups", "(", "Page", "$", "page", ")", "{", "if", "(", "!", "$", "page", "->", "Exists", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tblPmg", "=", "PageMembergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "tblMg", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "join", "=", "$", "sql", "->", "Join", "(", "$", "tblPmg", ")", ";", "$", "joinCondition", "=", "$", "sql", "->", "Equals", "(", "$", "tblPmg", "->", "Field", "(", "'MemberGroup'", ")", ",", "$", "tblMg", "->", "Field", "(", "'ID'", ")", ")", ";", "$", "where", "=", "$", "sql", "->", "Equals", "(", "$", "tblPmg", "->", "Field", "(", "'Page'", ")", ",", "$", "sql", "->", "Value", "(", "$", "page", "->", "GetID", "(", ")", ")", ")", ";", "$", "orderBy", "=", "$", "sql", "->", "OrderList", "(", "$", "sql", "->", "OrderAsc", "(", "$", "tblMg", "->", "Field", "(", "'Name'", ")", ")", ")", ";", "return", "Membergroup", "::", "Schema", "(", ")", "->", "Fetch", "(", "false", ",", "$", "where", ",", "$", "orderBy", ",", "null", ",", "0", ",", "null", ",", "$", "join", ",", "JoinType", "::", "Inner", "(", ")", ",", "$", "joinCondition", ")", ";", "}" ]
Gets the page's member groups @param Page $page @return Membergroup[] Returns the member groups assigned to the page
[ "Gets", "the", "page", "s", "member", "groups" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L94-L109
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.ContentMembergroups
static function ContentMembergroups(Content $content) { if (!$content->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblCmg = ContentMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblCmg); $joinCondition = $sql->Equals($tblCmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblCmg->Field('Content'), $sql->Value($content->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
php
static function ContentMembergroups(Content $content) { if (!$content->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblCmg = ContentMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblCmg); $joinCondition = $sql->Equals($tblCmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblCmg->Field('Content'), $sql->Value($content->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }
[ "static", "function", "ContentMembergroups", "(", "Content", "$", "content", ")", "{", "if", "(", "!", "$", "content", "->", "Exists", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tblCmg", "=", "ContentMembergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "tblMg", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "join", "=", "$", "sql", "->", "Join", "(", "$", "tblCmg", ")", ";", "$", "joinCondition", "=", "$", "sql", "->", "Equals", "(", "$", "tblCmg", "->", "Field", "(", "'MemberGroup'", ")", ",", "$", "tblMg", "->", "Field", "(", "'ID'", ")", ")", ";", "$", "where", "=", "$", "sql", "->", "Equals", "(", "$", "tblCmg", "->", "Field", "(", "'Content'", ")", ",", "$", "sql", "->", "Value", "(", "$", "content", "->", "GetID", "(", ")", ")", ")", ";", "$", "orderBy", "=", "$", "sql", "->", "OrderList", "(", "$", "sql", "->", "OrderAsc", "(", "$", "tblMg", "->", "Field", "(", "'Name'", ")", ")", ")", ";", "return", "Membergroup", "::", "Schema", "(", ")", "->", "Fetch", "(", "false", ",", "$", "where", ",", "$", "orderBy", ",", "null", ",", "0", ",", "null", ",", "$", "join", ",", "JoinType", "::", "Inner", "(", ")", ",", "$", "joinCondition", ")", ";", "}" ]
Gets the content's member groups @param Content $content @return Membergroup[] Returns the member groups assigned to the content
[ "Gets", "the", "content", "s", "member", "groups" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L116-L131
train
agentmedia/phine-core
src/Core/Logic/Util/MembergroupUtil.php
MembergroupUtil.AddMembergroupOptions
private static function AddMembergroupOptions(CheckList $field) { $sql = Access::SqlBuilder(); $tbl = Membergroup::Schema()->Table(); $orderBy = $sql->OrderList($sql->OrderAsc($tbl->Field('Name'))); $groups = Membergroup::Schema()->Fetch(false, null, $orderBy); foreach ($groups as $group) { $field->AddOption($group->GetID(), $group->GetName()); } }
php
private static function AddMembergroupOptions(CheckList $field) { $sql = Access::SqlBuilder(); $tbl = Membergroup::Schema()->Table(); $orderBy = $sql->OrderList($sql->OrderAsc($tbl->Field('Name'))); $groups = Membergroup::Schema()->Fetch(false, null, $orderBy); foreach ($groups as $group) { $field->AddOption($group->GetID(), $group->GetName()); } }
[ "private", "static", "function", "AddMembergroupOptions", "(", "CheckList", "$", "field", ")", "{", "$", "sql", "=", "Access", "::", "SqlBuilder", "(", ")", ";", "$", "tbl", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Table", "(", ")", ";", "$", "orderBy", "=", "$", "sql", "->", "OrderList", "(", "$", "sql", "->", "OrderAsc", "(", "$", "tbl", "->", "Field", "(", "'Name'", ")", ")", ")", ";", "$", "groups", "=", "Membergroup", "::", "Schema", "(", ")", "->", "Fetch", "(", "false", ",", "null", ",", "$", "orderBy", ")", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "$", "field", "->", "AddOption", "(", "$", "group", "->", "GetID", "(", ")", ",", "$", "group", "->", "GetName", "(", ")", ")", ";", "}", "}" ]
Adds the member group options to the checklist @param CheckList $field
[ "Adds", "the", "member", "group", "options", "to", "the", "checklist" ]
38c1be8d03ebffae950d00a96da3c612aff67832
https://github.com/agentmedia/phine-core/blob/38c1be8d03ebffae950d00a96da3c612aff67832/src/Core/Logic/Util/MembergroupUtil.php#L137-L147
train
wobblecode/WobbleCodeUserBundle
Document/User.php
User.getRoles
public function getRoles() { $roles = $this->roles; foreach ($this->getGroups() as $group) { $roles = array_merge($roles, $group->getRoles()); } $newRoles = []; if ($this->getActiveRole()) { $newRoles = $this->getActiveRole()->getRoles(); } $finalRoles = array_merge($roles, $newRoles); // we need to make sure to have at least one role $finalRoles[] = static::ROLE_DEFAULT; return array_unique($finalRoles); }
php
public function getRoles() { $roles = $this->roles; foreach ($this->getGroups() as $group) { $roles = array_merge($roles, $group->getRoles()); } $newRoles = []; if ($this->getActiveRole()) { $newRoles = $this->getActiveRole()->getRoles(); } $finalRoles = array_merge($roles, $newRoles); // we need to make sure to have at least one role $finalRoles[] = static::ROLE_DEFAULT; return array_unique($finalRoles); }
[ "public", "function", "getRoles", "(", ")", "{", "$", "roles", "=", "$", "this", "->", "roles", ";", "foreach", "(", "$", "this", "->", "getGroups", "(", ")", "as", "$", "group", ")", "{", "$", "roles", "=", "array_merge", "(", "$", "roles", ",", "$", "group", "->", "getRoles", "(", ")", ")", ";", "}", "$", "newRoles", "=", "[", "]", ";", "if", "(", "$", "this", "->", "getActiveRole", "(", ")", ")", "{", "$", "newRoles", "=", "$", "this", "->", "getActiveRole", "(", ")", "->", "getRoles", "(", ")", ";", "}", "$", "finalRoles", "=", "array_merge", "(", "$", "roles", ",", "$", "newRoles", ")", ";", "// we need to make sure to have at least one role", "$", "finalRoles", "[", "]", "=", "static", "::", "ROLE_DEFAULT", ";", "return", "array_unique", "(", "$", "finalRoles", ")", ";", "}" ]
Returns the user roles @return array The roles
[ "Returns", "the", "user", "roles" ]
7b8206f8b4a50fbc61f7bfe4f83eb466cad96440
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/User.php#L299-L319
train
linguisticteam/xml-sitemap
src/news.php
SitemapNews.build
public function build() { $values = array( 'access' => false, 'genres' => false, 'publication_date' => false, 'title' => true, 'keywords' => true, 'stock_tickers' => true ); foreach ($values as $value => $isEscaped) { if ( ! is_null( $this->{$value} )) { $this->addChild( sprintf( 'news:%s', $value ), $this->{$value}, $isEscaped ); } } }
php
public function build() { $values = array( 'access' => false, 'genres' => false, 'publication_date' => false, 'title' => true, 'keywords' => true, 'stock_tickers' => true ); foreach ($values as $value => $isEscaped) { if ( ! is_null( $this->{$value} )) { $this->addChild( sprintf( 'news:%s', $value ), $this->{$value}, $isEscaped ); } } }
[ "public", "function", "build", "(", ")", "{", "$", "values", "=", "array", "(", "'access'", "=>", "false", ",", "'genres'", "=>", "false", ",", "'publication_date'", "=>", "false", ",", "'title'", "=>", "true", ",", "'keywords'", "=>", "true", ",", "'stock_tickers'", "=>", "true", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", "=>", "$", "isEscaped", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "{", "$", "value", "}", ")", ")", "{", "$", "this", "->", "addChild", "(", "sprintf", "(", "'news:%s'", ",", "$", "value", ")", ",", "$", "this", "->", "{", "$", "value", "}", ",", "$", "isEscaped", ")", ";", "}", "}", "}" ]
Adds all the nodes in our news sitemap, with some values being escaped.
[ "Adds", "all", "the", "nodes", "in", "our", "news", "sitemap", "with", "some", "values", "being", "escaped", "." ]
b600a31ad9c1c136fa6f3d3b6a394002121d42f0
https://github.com/linguisticteam/xml-sitemap/blob/b600a31ad9c1c136fa6f3d3b6a394002121d42f0/src/news.php#L161-L175
train
Aviogram/Common
src/PHPClass/Element/DocBlock/TagColumnLength.php
TagColumnLength.setMaxLengths
public function setMaxLengths($column1 = null, $column2 = null, $_ = null) { foreach (func_get_args() as $index => $argument) { $length = strlen((string) $argument); if ($this->columns->offsetExists($index) === false || $this->columns->offsetGet($index) < $length) { $this->columns->offsetSet($index, $length); } } return $this; }
php
public function setMaxLengths($column1 = null, $column2 = null, $_ = null) { foreach (func_get_args() as $index => $argument) { $length = strlen((string) $argument); if ($this->columns->offsetExists($index) === false || $this->columns->offsetGet($index) < $length) { $this->columns->offsetSet($index, $length); } } return $this; }
[ "public", "function", "setMaxLengths", "(", "$", "column1", "=", "null", ",", "$", "column2", "=", "null", ",", "$", "_", "=", "null", ")", "{", "foreach", "(", "func_get_args", "(", ")", "as", "$", "index", "=>", "$", "argument", ")", "{", "$", "length", "=", "strlen", "(", "(", "string", ")", "$", "argument", ")", ";", "if", "(", "$", "this", "->", "columns", "->", "offsetExists", "(", "$", "index", ")", "===", "false", "||", "$", "this", "->", "columns", "->", "offsetGet", "(", "$", "index", ")", "<", "$", "length", ")", "{", "$", "this", "->", "columns", "->", "offsetSet", "(", "$", "index", ",", "$", "length", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set the max column lengths for later use @param null $column1 @param null $column2 @param null $_ @return self
[ "Set", "the", "max", "column", "lengths", "for", "later", "use" ]
bcff2e409cccd4791a3f9bca0b2cdd70c25ddec5
https://github.com/Aviogram/Common/blob/bcff2e409cccd4791a3f9bca0b2cdd70c25ddec5/src/PHPClass/Element/DocBlock/TagColumnLength.php#L30-L41
train
Aviogram/Common
src/PHPClass/Element/DocBlock/TagColumnLength.php
TagColumnLength.getColumnPaddingLength
public function getColumnPaddingLength($columnIndex, $columnValue) { if ($this->columns->offsetExists($columnIndex) === false) { return 0; } return $this->columns->offsetGet($columnIndex) - strlen($columnValue); }
php
public function getColumnPaddingLength($columnIndex, $columnValue) { if ($this->columns->offsetExists($columnIndex) === false) { return 0; } return $this->columns->offsetGet($columnIndex) - strlen($columnValue); }
[ "public", "function", "getColumnPaddingLength", "(", "$", "columnIndex", ",", "$", "columnValue", ")", "{", "if", "(", "$", "this", "->", "columns", "->", "offsetExists", "(", "$", "columnIndex", ")", "===", "false", ")", "{", "return", "0", ";", "}", "return", "$", "this", "->", "columns", "->", "offsetGet", "(", "$", "columnIndex", ")", "-", "strlen", "(", "$", "columnValue", ")", ";", "}" ]
Get the padding needed based on the max column length and the column value given @param integer $columnIndex @param string $columnValue @return integer
[ "Get", "the", "padding", "needed", "based", "on", "the", "max", "column", "length", "and", "the", "column", "value", "given" ]
bcff2e409cccd4791a3f9bca0b2cdd70c25ddec5
https://github.com/Aviogram/Common/blob/bcff2e409cccd4791a3f9bca0b2cdd70c25ddec5/src/PHPClass/Element/DocBlock/TagColumnLength.php#L51-L58
train