repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
aedart/laravel-helpers
src/Traits/Cookie/QueueingCookieTrait.php
QueueingCookieTrait.getQueueingCookie
public function getQueueingCookie(): ?QueueingFactory { if (!$this->hasQueueingCookie()) { $this->setQueueingCookie($this->getDefaultQueueingCookie()); } return $this->queueingCookie; }
php
public function getQueueingCookie(): ?QueueingFactory { if (!$this->hasQueueingCookie()) { $this->setQueueingCookie($this->getDefaultQueueingCookie()); } return $this->queueingCookie; }
[ "public", "function", "getQueueingCookie", "(", ")", ":", "?", "QueueingFactory", "{", "if", "(", "!", "$", "this", "->", "hasQueueingCookie", "(", ")", ")", "{", "$", "this", "->", "setQueueingCookie", "(", "$", "this", "->", "getDefaultQueueingCookie", "(", ")", ")", ";", "}", "return", "$", "this", "->", "queueingCookie", ";", "}" ]
Get queueing cookie If no queueing cookie has been set, this method will set and return a default queueing cookie, if any such value is available @see getDefaultQueueingCookie() @return QueueingFactory|null queueing cookie or null if none queueing cookie has been set
[ "Get", "queueing", "cookie" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cookie/QueueingCookieTrait.php#L53-L59
digitalkaoz/versioneye-php
src/Http/HttpPlugHttpAdapterClient.php
HttpPlugHttpAdapterClient.request
public function request($method, $path, array $params = []) { list($params, $files) = $this->splitParams($params); $url = $this->url . $path; try { $request = $this->createRequest($params, $files, $method, $url); $response = $this->adapter->sendRequest($request); return json_decode($response->getBody(), true); } catch (PlugException $e) { throw $this->buildRequestError($e); } }
php
public function request($method, $path, array $params = []) { list($params, $files) = $this->splitParams($params); $url = $this->url . $path; try { $request = $this->createRequest($params, $files, $method, $url); $response = $this->adapter->sendRequest($request); return json_decode($response->getBody(), true); } catch (PlugException $e) { throw $this->buildRequestError($e); } }
[ "public", "function", "request", "(", "$", "method", ",", "$", "path", ",", "array", "$", "params", "=", "[", "]", ")", "{", "list", "(", "$", "params", ",", "$", "files", ")", "=", "$", "this", "->", "splitParams", "(", "$", "params", ")", ";", "$", "url", "=", "$", "this", "->", "url", ".", "$", "path", ";", "try", "{", "$", "request", "=", "$", "this", "->", "createRequest", "(", "$", "params", ",", "$", "files", ",", "$", "method", ",", "$", "url", ")", ";", "$", "response", "=", "$", "this", "->", "adapter", "->", "sendRequest", "(", "$", "request", ")", ";", "return", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "}", "catch", "(", "PlugException", "$", "e", ")", "{", "throw", "$", "this", "->", "buildRequestError", "(", "$", "e", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Http/HttpPlugHttpAdapterClient.php#L50-L63
digitalkaoz/versioneye-php
src/Http/HttpPlugHttpAdapterClient.php
HttpPlugHttpAdapterClient.splitParams
private function splitParams(array $params) { $parameters = []; $files = []; foreach ($params as $name => $value) { if (is_readable($value)) { //file $files[$name] = $value; } else { $parameters[$name] = $value; } } return [$parameters, $files]; }
php
private function splitParams(array $params) { $parameters = []; $files = []; foreach ($params as $name => $value) { if (is_readable($value)) { //file $files[$name] = $value; } else { $parameters[$name] = $value; } } return [$parameters, $files]; }
[ "private", "function", "splitParams", "(", "array", "$", "params", ")", "{", "$", "parameters", "=", "[", "]", ";", "$", "files", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_readable", "(", "$", "value", ")", ")", "{", "//file", "$", "files", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "$", "parameters", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "[", "$", "parameters", ",", "$", "files", "]", ";", "}" ]
splits arguments into parameters and files (if any). @param array $params @return array
[ "splits", "arguments", "into", "parameters", "and", "files", "(", "if", "any", ")", "." ]
train
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Http/HttpPlugHttpAdapterClient.php#L72-L86
digitalkaoz/versioneye-php
src/Http/HttpPlugHttpAdapterClient.php
HttpPlugHttpAdapterClient.buildRequestError
private function buildRequestError(PlugException $e) { $data = $e->getResponse() ? json_decode($e->getResponse()->getBody(), true) : ['error' => $e->getMessage()]; $message = isset($data['error']) ? $data['error'] : 'Server Error'; $status = $e->getResponse() ? $e->getResponse()->getStatusCode() : 500; return new CommunicationException(sprintf('%s : %s', $status, $message)); }
php
private function buildRequestError(PlugException $e) { $data = $e->getResponse() ? json_decode($e->getResponse()->getBody(), true) : ['error' => $e->getMessage()]; $message = isset($data['error']) ? $data['error'] : 'Server Error'; $status = $e->getResponse() ? $e->getResponse()->getStatusCode() : 500; return new CommunicationException(sprintf('%s : %s', $status, $message)); }
[ "private", "function", "buildRequestError", "(", "PlugException", "$", "e", ")", "{", "$", "data", "=", "$", "e", "->", "getResponse", "(", ")", "?", "json_decode", "(", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ",", "true", ")", ":", "[", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ";", "$", "message", "=", "isset", "(", "$", "data", "[", "'error'", "]", ")", "?", "$", "data", "[", "'error'", "]", ":", "'Server Error'", ";", "$", "status", "=", "$", "e", "->", "getResponse", "(", ")", "?", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ":", "500", ";", "return", "new", "CommunicationException", "(", "sprintf", "(", "'%s : %s'", ",", "$", "status", ",", "$", "message", ")", ")", ";", "}" ]
builds the error exception. @param PlugException $e @return CommunicationException
[ "builds", "the", "error", "exception", "." ]
train
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Http/HttpPlugHttpAdapterClient.php#L95-L102
digitalkaoz/versioneye-php
src/Http/HttpPlugHttpAdapterClient.php
HttpPlugHttpAdapterClient.createRequest
private function createRequest(array $params, array $files, $method, $url) { if (!count($params) && !count($files)) { return $this->factory->createRequest($method, $url); } $builder = clone $this->multipartStreamBuilder; foreach ($params as $k => $v) { $builder->addResource($k, $v); } foreach ($files as $k => $file) { $builder->addResource($k, fopen($file, 'r'), ['filename' => $file]); } return $this->factory->createRequest( $method, $url, ['Content-Type' => 'multipart/form-data; boundary=' . $builder->getBoundary()], $builder->build() ); }
php
private function createRequest(array $params, array $files, $method, $url) { if (!count($params) && !count($files)) { return $this->factory->createRequest($method, $url); } $builder = clone $this->multipartStreamBuilder; foreach ($params as $k => $v) { $builder->addResource($k, $v); } foreach ($files as $k => $file) { $builder->addResource($k, fopen($file, 'r'), ['filename' => $file]); } return $this->factory->createRequest( $method, $url, ['Content-Type' => 'multipart/form-data; boundary=' . $builder->getBoundary()], $builder->build() ); }
[ "private", "function", "createRequest", "(", "array", "$", "params", ",", "array", "$", "files", ",", "$", "method", ",", "$", "url", ")", "{", "if", "(", "!", "count", "(", "$", "params", ")", "&&", "!", "count", "(", "$", "files", ")", ")", "{", "return", "$", "this", "->", "factory", "->", "createRequest", "(", "$", "method", ",", "$", "url", ")", ";", "}", "$", "builder", "=", "clone", "$", "this", "->", "multipartStreamBuilder", ";", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "builder", "->", "addResource", "(", "$", "k", ",", "$", "v", ")", ";", "}", "foreach", "(", "$", "files", "as", "$", "k", "=>", "$", "file", ")", "{", "$", "builder", "->", "addResource", "(", "$", "k", ",", "fopen", "(", "$", "file", ",", "'r'", ")", ",", "[", "'filename'", "=>", "$", "file", "]", ")", ";", "}", "return", "$", "this", "->", "factory", "->", "createRequest", "(", "$", "method", ",", "$", "url", ",", "[", "'Content-Type'", "=>", "'multipart/form-data; boundary='", ".", "$", "builder", "->", "getBoundary", "(", ")", "]", ",", "$", "builder", "->", "build", "(", ")", ")", ";", "}" ]
@param array $params @param array $files @param string $method @param string $url @return RequestInterface
[ "@param", "array", "$params", "@param", "array", "$files", "@param", "string", "$method", "@param", "string", "$url" ]
train
https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Http/HttpPlugHttpAdapterClient.php#L112-L134
whisller/IrcBotBundle
EventListener/Plugins/Commands/QuitCommandListener.php
QuitCommandListener.onCommand
public function onCommand(BotCommandFoundEvent $event) { $data = $event->getArguments(); $this->connection->sendCommand(new QuitCommand(new Message((isset($data[0]) ? $data[0] : '')))); }
php
public function onCommand(BotCommandFoundEvent $event) { $data = $event->getArguments(); $this->connection->sendCommand(new QuitCommand(new Message((isset($data[0]) ? $data[0] : '')))); }
[ "public", "function", "onCommand", "(", "BotCommandFoundEvent", "$", "event", ")", "{", "$", "data", "=", "$", "event", "->", "getArguments", "(", ")", ";", "$", "this", "->", "connection", "->", "sendCommand", "(", "new", "QuitCommand", "(", "new", "Message", "(", "(", "isset", "(", "$", "data", "[", "0", "]", ")", "?", "$", "data", "[", "0", "]", ":", "''", ")", ")", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/whisller/IrcBotBundle/blob/d8bcafc1599cbbc7756b0a59f51ee988a2de0f2e/EventListener/Plugins/Commands/QuitCommandListener.php#L19-L24
webforge-labs/psc-cms
lib/Psc/Doctrine/ActionsCollectionSynchronizer.php
ActionsCollectionSynchronizer.setAction
public function setAction($name, Closure $action) { if (!array_key_exists($name, $this->actions)) { throw new \InvalidArgumentException($name.' ist keine bekannte action: '.implode(',',array_keys($this->actions))); } $this->actions[$name] = $action; return $this; }
php
public function setAction($name, Closure $action) { if (!array_key_exists($name, $this->actions)) { throw new \InvalidArgumentException($name.' ist keine bekannte action: '.implode(',',array_keys($this->actions))); } $this->actions[$name] = $action; return $this; }
[ "public", "function", "setAction", "(", "$", "name", ",", "Closure", "$", "action", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "actions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "name", ".", "' ist keine bekannte action: '", ".", "implode", "(", "','", ",", "array_keys", "(", "$", "this", "->", "actions", ")", ")", ")", ";", "}", "$", "this", "->", "actions", "[", "$", "name", "]", "=", "$", "action", ";", "return", "$", "this", ";", "}" ]
Setzt die Action (ausführbarer Code) für ein bestimmtes Event
[ "Setzt", "die", "Action", "(", "ausführbarer", "Code", ")", "für", "ein", "bestimmtes", "Event" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/ActionsCollectionSynchronizer.php#L120-L127
OpenClassrooms/ServiceProxy
src/Proxy/ProxyGenerator/ServiceProxyGenerator.php
ServiceProxyGenerator.generate
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) { CanProxyAssertion::assertClassCanBeProxied($originalClass); $classGenerator->setExtendedClass($originalClass->getName()); $additionalInterfaces = ['OpenClassrooms\\ServiceProxy\\ServiceProxyInterface']; $additionalProperties['proxy_realSubject'] = new PropertyGenerator( 'proxy_realSubject', null, PropertyGenerator::FLAG_PRIVATE ); $additionalMethods['setProxy_realSubject'] = new MethodGenerator( 'setProxy_realSubject', [['name' => 'realSubject']], MethodGenerator::FLAG_PUBLIC, '$this->proxy_realSubject = $realSubject;' ); $methods = $originalClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($methods as $method) { $preSource = ''; $postSource = ''; $exceptionSource = ''; $methodAnnotations = $this->annotationReader->getMethodAnnotations($method); foreach ($methodAnnotations as $methodAnnotation) { if ($methodAnnotation instanceof Cache) { $this->addCacheAnnotation($classGenerator); $additionalInterfaces['cache'] = 'OpenClassrooms\\ServiceProxy\\ServiceProxyCacheInterface'; $response = $this->cacheStrategy->execute( $this->serviceProxyStrategyRequestBuilder ->create() ->withAnnotation($methodAnnotation) ->withClass($originalClass) ->withMethod($method) ->build() ); foreach ($response->getMethods() as $methodToAdd) { $additionalMethods[$methodToAdd->getName()] = $methodToAdd; } foreach ($response->getProperties() as $propertyToAdd) { $additionalProperties[$propertyToAdd->getName()] = $propertyToAdd; } $preSource .= $response->getPreSource(); $postSource .= $response->getPostSource(); $exceptionSource .= $response->getExceptionSource(); } } $classGenerator->addMethodFromGenerator( $this->generateProxyMethod($method, $preSource, $postSource, $exceptionSource) ); } $classGenerator->setImplementedInterfaces($additionalInterfaces); $classGenerator->addProperties($additionalProperties); $classGenerator->addMethods($additionalMethods); }
php
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) { CanProxyAssertion::assertClassCanBeProxied($originalClass); $classGenerator->setExtendedClass($originalClass->getName()); $additionalInterfaces = ['OpenClassrooms\\ServiceProxy\\ServiceProxyInterface']; $additionalProperties['proxy_realSubject'] = new PropertyGenerator( 'proxy_realSubject', null, PropertyGenerator::FLAG_PRIVATE ); $additionalMethods['setProxy_realSubject'] = new MethodGenerator( 'setProxy_realSubject', [['name' => 'realSubject']], MethodGenerator::FLAG_PUBLIC, '$this->proxy_realSubject = $realSubject;' ); $methods = $originalClass->getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($methods as $method) { $preSource = ''; $postSource = ''; $exceptionSource = ''; $methodAnnotations = $this->annotationReader->getMethodAnnotations($method); foreach ($methodAnnotations as $methodAnnotation) { if ($methodAnnotation instanceof Cache) { $this->addCacheAnnotation($classGenerator); $additionalInterfaces['cache'] = 'OpenClassrooms\\ServiceProxy\\ServiceProxyCacheInterface'; $response = $this->cacheStrategy->execute( $this->serviceProxyStrategyRequestBuilder ->create() ->withAnnotation($methodAnnotation) ->withClass($originalClass) ->withMethod($method) ->build() ); foreach ($response->getMethods() as $methodToAdd) { $additionalMethods[$methodToAdd->getName()] = $methodToAdd; } foreach ($response->getProperties() as $propertyToAdd) { $additionalProperties[$propertyToAdd->getName()] = $propertyToAdd; } $preSource .= $response->getPreSource(); $postSource .= $response->getPostSource(); $exceptionSource .= $response->getExceptionSource(); } } $classGenerator->addMethodFromGenerator( $this->generateProxyMethod($method, $preSource, $postSource, $exceptionSource) ); } $classGenerator->setImplementedInterfaces($additionalInterfaces); $classGenerator->addProperties($additionalProperties); $classGenerator->addMethods($additionalMethods); }
[ "public", "function", "generate", "(", "ReflectionClass", "$", "originalClass", ",", "ClassGenerator", "$", "classGenerator", ")", "{", "CanProxyAssertion", "::", "assertClassCanBeProxied", "(", "$", "originalClass", ")", ";", "$", "classGenerator", "->", "setExtendedClass", "(", "$", "originalClass", "->", "getName", "(", ")", ")", ";", "$", "additionalInterfaces", "=", "[", "'OpenClassrooms\\\\ServiceProxy\\\\ServiceProxyInterface'", "]", ";", "$", "additionalProperties", "[", "'proxy_realSubject'", "]", "=", "new", "PropertyGenerator", "(", "'proxy_realSubject'", ",", "null", ",", "PropertyGenerator", "::", "FLAG_PRIVATE", ")", ";", "$", "additionalMethods", "[", "'setProxy_realSubject'", "]", "=", "new", "MethodGenerator", "(", "'setProxy_realSubject'", ",", "[", "[", "'name'", "=>", "'realSubject'", "]", "]", ",", "MethodGenerator", "::", "FLAG_PUBLIC", ",", "'$this->proxy_realSubject = $realSubject;'", ")", ";", "$", "methods", "=", "$", "originalClass", "->", "getMethods", "(", "\\", "ReflectionMethod", "::", "IS_PUBLIC", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "preSource", "=", "''", ";", "$", "postSource", "=", "''", ";", "$", "exceptionSource", "=", "''", ";", "$", "methodAnnotations", "=", "$", "this", "->", "annotationReader", "->", "getMethodAnnotations", "(", "$", "method", ")", ";", "foreach", "(", "$", "methodAnnotations", "as", "$", "methodAnnotation", ")", "{", "if", "(", "$", "methodAnnotation", "instanceof", "Cache", ")", "{", "$", "this", "->", "addCacheAnnotation", "(", "$", "classGenerator", ")", ";", "$", "additionalInterfaces", "[", "'cache'", "]", "=", "'OpenClassrooms\\\\ServiceProxy\\\\ServiceProxyCacheInterface'", ";", "$", "response", "=", "$", "this", "->", "cacheStrategy", "->", "execute", "(", "$", "this", "->", "serviceProxyStrategyRequestBuilder", "->", "create", "(", ")", "->", "withAnnotation", "(", "$", "methodAnnotation", ")", "->", "withClass", "(", "$", "originalClass", ")", "->", "withMethod", "(", "$", "method", ")", "->", "build", "(", ")", ")", ";", "foreach", "(", "$", "response", "->", "getMethods", "(", ")", "as", "$", "methodToAdd", ")", "{", "$", "additionalMethods", "[", "$", "methodToAdd", "->", "getName", "(", ")", "]", "=", "$", "methodToAdd", ";", "}", "foreach", "(", "$", "response", "->", "getProperties", "(", ")", "as", "$", "propertyToAdd", ")", "{", "$", "additionalProperties", "[", "$", "propertyToAdd", "->", "getName", "(", ")", "]", "=", "$", "propertyToAdd", ";", "}", "$", "preSource", ".=", "$", "response", "->", "getPreSource", "(", ")", ";", "$", "postSource", ".=", "$", "response", "->", "getPostSource", "(", ")", ";", "$", "exceptionSource", ".=", "$", "response", "->", "getExceptionSource", "(", ")", ";", "}", "}", "$", "classGenerator", "->", "addMethodFromGenerator", "(", "$", "this", "->", "generateProxyMethod", "(", "$", "method", ",", "$", "preSource", ",", "$", "postSource", ",", "$", "exceptionSource", ")", ")", ";", "}", "$", "classGenerator", "->", "setImplementedInterfaces", "(", "$", "additionalInterfaces", ")", ";", "$", "classGenerator", "->", "addProperties", "(", "$", "additionalProperties", ")", ";", "$", "classGenerator", "->", "addMethods", "(", "$", "additionalMethods", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/OpenClassrooms/ServiceProxy/blob/31f9f8be8f064b4ca36873df83fc3833f53da438/src/Proxy/ProxyGenerator/ServiceProxyGenerator.php#L40-L94
ruvents/ruwork-upload-bundle
Path/PathGenerator.php
PathGenerator.generatePath
public function generatePath(?string $extension = null): string { $random = bin2hex(random_bytes(16)); return $this->uploadsDir.'/'.substr($random, 0, 2).'/'.substr($random, 2).($extension ? '.'.$extension : ''); }
php
public function generatePath(?string $extension = null): string { $random = bin2hex(random_bytes(16)); return $this->uploadsDir.'/'.substr($random, 0, 2).'/'.substr($random, 2).($extension ? '.'.$extension : ''); }
[ "public", "function", "generatePath", "(", "?", "string", "$", "extension", "=", "null", ")", ":", "string", "{", "$", "random", "=", "bin2hex", "(", "random_bytes", "(", "16", ")", ")", ";", "return", "$", "this", "->", "uploadsDir", ".", "'/'", ".", "substr", "(", "$", "random", ",", "0", ",", "2", ")", ".", "'/'", ".", "substr", "(", "$", "random", ",", "2", ")", ".", "(", "$", "extension", "?", "'.'", ".", "$", "extension", ":", "''", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Path/PathGenerator.php#L23-L28
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.lists
public function lists($column, $key = null) { return parent::lists( $this->getColumnName($column), $key ); }
php
public function lists($column, $key = null) { return parent::lists( $this->getColumnName($column), $key ); }
[ "public", "function", "lists", "(", "$", "column", ",", "$", "key", "=", "null", ")", "{", "return", "parent", "::", "lists", "(", "$", "this", "->", "getColumnName", "(", "$", "column", ")", ",", "$", "key", ")", ";", "}" ]
@param string $column @param null $key @return array|\Illuminate\Support\Collection
[ "@param", "string", "$column", "@param", "null", "$key" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L42-L48
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.pluck
public function pluck($column, $key = null) { return parent::pluck( $this->getColumnName($column), $key ); }
php
public function pluck($column, $key = null) { return parent::pluck( $this->getColumnName($column), $key ); }
[ "public", "function", "pluck", "(", "$", "column", ",", "$", "key", "=", "null", ")", "{", "return", "parent", "::", "pluck", "(", "$", "this", "->", "getColumnName", "(", "$", "column", ")", ",", "$", "key", ")", ";", "}" ]
@param string $column @param null $key @return array|\Illuminate\Support\Collection
[ "@param", "string", "$column", "@param", "null", "$key" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L56-L62
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.findByField
public function findByField($field, $value = null, $columns = ['*']) { return parent::findByField( $this->getColumnName($field), $value, $this->getColumnsNames($columns) ); }
php
public function findByField($field, $value = null, $columns = ['*']) { return parent::findByField( $this->getColumnName($field), $value, $this->getColumnsNames($columns) ); }
[ "public", "function", "findByField", "(", "$", "field", ",", "$", "value", "=", "null", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "return", "parent", "::", "findByField", "(", "$", "this", "->", "getColumnName", "(", "$", "field", ")", ",", "$", "value", ",", "$", "this", "->", "getColumnsNames", "(", "$", "columns", ")", ")", ";", "}" ]
@param $field @param null $value @param array $columns @return mixed
[ "@param", "$field", "@param", "null", "$value", "@param", "array", "$columns" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L85-L92
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.findWhere
public function findWhere(array $where, $columns = ['*']) { $fields = array_keys($where); $fields = $this->getColumnsNames($fields); return parent::findWhere( array_combine($fields, array_values($where)), $this->getColumnsNames($columns) ); }
php
public function findWhere(array $where, $columns = ['*']) { $fields = array_keys($where); $fields = $this->getColumnsNames($fields); return parent::findWhere( array_combine($fields, array_values($where)), $this->getColumnsNames($columns) ); }
[ "public", "function", "findWhere", "(", "array", "$", "where", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "fields", "=", "array_keys", "(", "$", "where", ")", ";", "$", "fields", "=", "$", "this", "->", "getColumnsNames", "(", "$", "fields", ")", ";", "return", "parent", "::", "findWhere", "(", "array_combine", "(", "$", "fields", ",", "array_values", "(", "$", "where", ")", ")", ",", "$", "this", "->", "getColumnsNames", "(", "$", "columns", ")", ")", ";", "}" ]
@param array $where @param array $columns @return mixed
[ "@param", "array", "$where", "@param", "array", "$columns" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L100-L109
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.findWhereIn
public function findWhereIn($field, array $values, $columns = ['*']) { return parent::findWhereIn( $this->getColumnName($field), $values, $this->getColumnsNames($columns) ); }
php
public function findWhereIn($field, array $values, $columns = ['*']) { return parent::findWhereIn( $this->getColumnName($field), $values, $this->getColumnsNames($columns) ); }
[ "public", "function", "findWhereIn", "(", "$", "field", ",", "array", "$", "values", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "return", "parent", "::", "findWhereIn", "(", "$", "this", "->", "getColumnName", "(", "$", "field", ")", ",", "$", "values", ",", "$", "this", "->", "getColumnsNames", "(", "$", "columns", ")", ")", ";", "}" ]
@param $field @param array $values @param array $columns @return mixed
[ "@param", "$field", "@param", "array", "$values", "@param", "array", "$columns" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L118-L125
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.findWhereNotIn
public function findWhereNotIn($field, array $values, $columns = ['*']) { return parent::findWhereNotIn( $this->getColumnName($field), $values, $this->getColumnsNames($columns) ); }
php
public function findWhereNotIn($field, array $values, $columns = ['*']) { return parent::findWhereNotIn( $this->getColumnName($field), $values, $this->getColumnsNames($columns) ); }
[ "public", "function", "findWhereNotIn", "(", "$", "field", ",", "array", "$", "values", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "return", "parent", "::", "findWhereNotIn", "(", "$", "this", "->", "getColumnName", "(", "$", "field", ")", ",", "$", "values", ",", "$", "this", "->", "getColumnsNames", "(", "$", "columns", ")", ")", ";", "}" ]
@param $field @param array $values @param array $columns @return mixed
[ "@param", "$field", "@param", "array", "$values", "@param", "array", "$columns" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L134-L141
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.paginate
public function paginate($limit = null, $columns = ['*'], $method = "paginate") { return parent::paginate( $limit, $this->getColumnsNames($columns), $method ); }
php
public function paginate($limit = null, $columns = ['*'], $method = "paginate") { return parent::paginate( $limit, $this->getColumnsNames($columns), $method ); }
[ "public", "function", "paginate", "(", "$", "limit", "=", "null", ",", "$", "columns", "=", "[", "'*'", "]", ",", "$", "method", "=", "\"paginate\"", ")", "{", "return", "parent", "::", "paginate", "(", "$", "limit", ",", "$", "this", "->", "getColumnsNames", "(", "$", "columns", ")", ",", "$", "method", ")", ";", "}" ]
@param null $limit @param array $columns @param string $method @return mixed
[ "@param", "null", "$limit", "@param", "array", "$columns", "@param", "string", "$method" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L150-L157
iocaste/microservice-foundation
src/Repository/SqlRepository.php
SqlRepository.getColumnName
public function getColumnName($column, $model = null): string { $model = $model ?? $this->model; return !strpos($column, '.') ? $this->getTableName($model) . '.' . $column : $column; }
php
public function getColumnName($column, $model = null): string { $model = $model ?? $this->model; return !strpos($column, '.') ? $this->getTableName($model) . '.' . $column : $column; }
[ "public", "function", "getColumnName", "(", "$", "column", ",", "$", "model", "=", "null", ")", ":", "string", "{", "$", "model", "=", "$", "model", "??", "$", "this", "->", "model", ";", "return", "!", "strpos", "(", "$", "column", ",", "'.'", ")", "?", "$", "this", "->", "getTableName", "(", "$", "model", ")", ".", "'.'", ".", "$", "column", ":", "$", "column", ";", "}" ]
@param string $column @param mixed $model @return string
[ "@param", "string", "$column", "@param", "mixed", "$model" ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Repository/SqlRepository.php#L179-L186
webforge-labs/psc-cms
lib/Psc/CMS/GridPanel.php
GridPanel.createColumn
public function createColumn($name, Type $type, $label = NULL, Array $additionalClasses = array(), Closure $toHTMLCallback = NULL) { if (!isset($label)) $label = $name; $column = new GridPanelColumn($name, $type, $label, $additionalClasses); if ($toHTMLCallback) { $column->setConverter($toHTMLCallback); } else { $column->setConverter($this->getDefaultConverter($column)); } $this->addColumn($column); return $column; }
php
public function createColumn($name, Type $type, $label = NULL, Array $additionalClasses = array(), Closure $toHTMLCallback = NULL) { if (!isset($label)) $label = $name; $column = new GridPanelColumn($name, $type, $label, $additionalClasses); if ($toHTMLCallback) { $column->setConverter($toHTMLCallback); } else { $column->setConverter($this->getDefaultConverter($column)); } $this->addColumn($column); return $column; }
[ "public", "function", "createColumn", "(", "$", "name", ",", "Type", "$", "type", ",", "$", "label", "=", "NULL", ",", "Array", "$", "additionalClasses", "=", "array", "(", ")", ",", "Closure", "$", "toHTMLCallback", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "label", ")", ")", "$", "label", "=", "$", "name", ";", "$", "column", "=", "new", "GridPanelColumn", "(", "$", "name", ",", "$", "type", ",", "$", "label", ",", "$", "additionalClasses", ")", ";", "if", "(", "$", "toHTMLCallback", ")", "{", "$", "column", "->", "setConverter", "(", "$", "toHTMLCallback", ")", ";", "}", "else", "{", "$", "column", "->", "setConverter", "(", "$", "this", "->", "getDefaultConverter", "(", "$", "column", ")", ")", ";", "}", "$", "this", "->", "addColumn", "(", "$", "column", ")", ";", "return", "$", "column", ";", "}" ]
Erstellt eine Column und fügt diese direkt hinzu @return GridPanelColumn
[ "Erstellt", "eine", "Column", "und", "fügt", "diese", "direkt", "hinzu" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/GridPanel.php#L87-L100
webforge-labs/psc-cms
lib/Psc/TPL/ContentStream/ContentStreamEntity.php
ContentStreamEntity.findAfter
public function findAfter(Entry $entry, $length = NULL) { $entries = $this->entries->getValues(); // get entries correctly numbered $pos = array_search($entry, $entries, TRUE); if ($pos === FALSE) { throw new RuntimeException('Das Element '.$entry.' ist nicht im ContentStream. findAfter() ist deshalb undefiniert'); } return array_merge(array_slice($entries, $pos+1, $length)); }
php
public function findAfter(Entry $entry, $length = NULL) { $entries = $this->entries->getValues(); // get entries correctly numbered $pos = array_search($entry, $entries, TRUE); if ($pos === FALSE) { throw new RuntimeException('Das Element '.$entry.' ist nicht im ContentStream. findAfter() ist deshalb undefiniert'); } return array_merge(array_slice($entries, $pos+1, $length)); }
[ "public", "function", "findAfter", "(", "Entry", "$", "entry", ",", "$", "length", "=", "NULL", ")", "{", "$", "entries", "=", "$", "this", "->", "entries", "->", "getValues", "(", ")", ";", "// get entries correctly numbered", "$", "pos", "=", "array_search", "(", "$", "entry", ",", "$", "entries", ",", "TRUE", ")", ";", "if", "(", "$", "pos", "===", "FALSE", ")", "{", "throw", "new", "RuntimeException", "(", "'Das Element '", ".", "$", "entry", ".", "' ist nicht im ContentStream. findAfter() ist deshalb undefiniert'", ")", ";", "}", "return", "array_merge", "(", "array_slice", "(", "$", "entries", ",", "$", "pos", "+", "1", ",", "$", "length", ")", ")", ";", "}" ]
Gibt alle Elemente nach dem angegeben Element im CS zurück gibt es keine Element danach wird ein leerer Array zurückgegeben gibt es das Element nicht, wird eine Exception geschmissen (damit ist es einfacher zu kontrollieren, was man machen will) das element wird nicht im Array zurückgegeben if $length is provided only $length elements will be returned @return array @throws RuntimeException
[ "Gibt", "alle", "Elemente", "nach", "dem", "angegeben", "Element", "im", "CS", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/ContentStream/ContentStreamEntity.php#L143-L152
webforge-labs/psc-cms
lib/Psc/TPL/ContentStream/ContentStreamEntity.php
ContentStreamEntity.findNextEntry
public function findNextEntry(Entry $entry) { $list = $this->findAfter($entry, 1); if (count($list) === 1) { return current($list); } return NULL; }
php
public function findNextEntry(Entry $entry) { $list = $this->findAfter($entry, 1); if (count($list) === 1) { return current($list); } return NULL; }
[ "public", "function", "findNextEntry", "(", "Entry", "$", "entry", ")", "{", "$", "list", "=", "$", "this", "->", "findAfter", "(", "$", "entry", ",", "1", ")", ";", "if", "(", "count", "(", "$", "list", ")", "===", "1", ")", "{", "return", "current", "(", "$", "list", ")", ";", "}", "return", "NULL", ";", "}" ]
Returns the element right after the given element if no element is after this NULL will be returned the $entry has to be in this contentstream otherwise an exception will thrown @return Entry|NULL
[ "Returns", "the", "element", "right", "after", "the", "given", "element" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/ContentStream/ContentStreamEntity.php#L162-L170
webforge-labs/psc-cms
lib/Psc/TPL/ContentStream/ContentStreamEntity.php
ContentStreamEntity.findFirst
public function findFirst($type, \Closure $withFilter = NULL) { $class = $this->getTypeClass($type); $withFilter = $withFilter ?: function () { return TRUE; }; foreach ($this->entries as $entry) { if ($entry instanceof $class && $withFilter($entry)) { return $entry; } } }
php
public function findFirst($type, \Closure $withFilter = NULL) { $class = $this->getTypeClass($type); $withFilter = $withFilter ?: function () { return TRUE; }; foreach ($this->entries as $entry) { if ($entry instanceof $class && $withFilter($entry)) { return $entry; } } }
[ "public", "function", "findFirst", "(", "$", "type", ",", "\\", "Closure", "$", "withFilter", "=", "NULL", ")", "{", "$", "class", "=", "$", "this", "->", "getTypeClass", "(", "$", "type", ")", ";", "$", "withFilter", "=", "$", "withFilter", "?", ":", "function", "(", ")", "{", "return", "TRUE", ";", "}", ";", "foreach", "(", "$", "this", "->", "entries", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "instanceof", "$", "class", "&&", "$", "withFilter", "(", "$", "entry", ")", ")", "{", "return", "$", "entry", ";", "}", "}", "}" ]
Gibt das erste Vorkommen der Klasse im Stream zurück gibt es kein Vorkommen wird NULL zurückgegeben @param string type ohne Namespace davor z.b. downloadlist für Downloadlist
[ "Gibt", "das", "erste", "Vorkommen", "der", "Klasse", "im", "Stream", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/TPL/ContentStream/ContentStreamEntity.php#L191-L199
php-rise/rise
src/Container.php
Container.has
public function has($class) { if (isset($this->singletons[$class])) { return true; } if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } try { $this->getReflectionClass($class); } catch (Exception $e) { return false; } return true; }
php
public function has($class) { if (isset($this->singletons[$class])) { return true; } if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } try { $this->getReflectionClass($class); } catch (Exception $e) { return false; } return true; }
[ "public", "function", "has", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "singletons", "[", "$", "class", "]", ")", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "class", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "aliases", "[", "$", "class", "]", ";", "}", "try", "{", "$", "this", "->", "getReflectionClass", "(", "$", "class", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if the class is resolvable. @param string $class @return bool
[ "Check", "if", "the", "class", "is", "resolvable", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L134-L150
php-rise/rise
src/Container.php
Container.configMethod
public function configMethod($class, $method, $rules) { foreach ($rules as $param => $rule) { if (ctype_upper($param[0]) && (!is_string($rule) && !($rule instanceof Closure)) ) { throw new InvalidRuleException("Type $param only allowed string or Closure as an extra rule."); } } $this->rules[$class][$method] = $rules; return $this; }
php
public function configMethod($class, $method, $rules) { foreach ($rules as $param => $rule) { if (ctype_upper($param[0]) && (!is_string($rule) && !($rule instanceof Closure)) ) { throw new InvalidRuleException("Type $param only allowed string or Closure as an extra rule."); } } $this->rules[$class][$method] = $rules; return $this; }
[ "public", "function", "configMethod", "(", "$", "class", ",", "$", "method", ",", "$", "rules", ")", "{", "foreach", "(", "$", "rules", "as", "$", "param", "=>", "$", "rule", ")", "{", "if", "(", "ctype_upper", "(", "$", "param", "[", "0", "]", ")", "&&", "(", "!", "is_string", "(", "$", "rule", ")", "&&", "!", "(", "$", "rule", "instanceof", "Closure", ")", ")", ")", "{", "throw", "new", "InvalidRuleException", "(", "\"Type $param only allowed string or Closure as an extra rule.\"", ")", ";", "}", "}", "$", "this", "->", "rules", "[", "$", "class", "]", "[", "$", "method", "]", "=", "$", "rules", ";", "return", "$", "this", ";", "}" ]
Configure method parameters of a class. @param string $class Class name. @param string $method Method name. @param array $rules @return self
[ "Configure", "method", "parameters", "of", "a", "class", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L172-L182
php-rise/rise
src/Container.php
Container.get
public function get($class) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } if (isset($this->resolvingClasses[$class])) { throw new CyclicDependencyException("Cyclic dependency detected when resolving $class"); } $this->resolvingClasses[$class] = true; if (array_key_exists($class, $this->factories)) { $instance = $this->getFactory($class); } else { $instance = $this->getSingleton($class); } unset($this->resolvingClasses[$class]); return $instance; }
php
public function get($class) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } if (isset($this->resolvingClasses[$class])) { throw new CyclicDependencyException("Cyclic dependency detected when resolving $class"); } $this->resolvingClasses[$class] = true; if (array_key_exists($class, $this->factories)) { $instance = $this->getFactory($class); } else { $instance = $this->getSingleton($class); } unset($this->resolvingClasses[$class]); return $instance; }
[ "public", "function", "get", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "class", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "aliases", "[", "$", "class", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "resolvingClasses", "[", "$", "class", "]", ")", ")", "{", "throw", "new", "CyclicDependencyException", "(", "\"Cyclic dependency detected when resolving $class\"", ")", ";", "}", "$", "this", "->", "resolvingClasses", "[", "$", "class", "]", "=", "true", ";", "if", "(", "array_key_exists", "(", "$", "class", ",", "$", "this", "->", "factories", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getFactory", "(", "$", "class", ")", ";", "}", "else", "{", "$", "instance", "=", "$", "this", "->", "getSingleton", "(", "$", "class", ")", ";", "}", "unset", "(", "$", "this", "->", "resolvingClasses", "[", "$", "class", "]", ")", ";", "return", "$", "instance", ";", "}" ]
Resolve a class. @param string $class @return object
[ "Resolve", "a", "class", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L190-L210
php-rise/rise
src/Container.php
Container.getMethod
public function getMethod($class, $method, $extraMappings = []) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } return [ $this->getSingleton($class), $this->resolveArgs($class, $method, " when resolving method $class::$method", $extraMappings) ]; }
php
public function getMethod($class, $method, $extraMappings = []) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } return [ $this->getSingleton($class), $this->resolveArgs($class, $method, " when resolving method $class::$method", $extraMappings) ]; }
[ "public", "function", "getMethod", "(", "$", "class", ",", "$", "method", ",", "$", "extraMappings", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "class", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "aliases", "[", "$", "class", "]", ";", "}", "return", "[", "$", "this", "->", "getSingleton", "(", "$", "class", ")", ",", "$", "this", "->", "resolveArgs", "(", "$", "class", ",", "$", "method", ",", "\" when resolving method $class::$method\"", ",", "$", "extraMappings", ")", "]", ";", "}" ]
Resolve a method for method injection. @param string $class @param string $method @param array $extraMappings Optional @return array [$instance, (string)$method, (array)$args]
[ "Resolve", "a", "method", "for", "method", "injection", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L220-L229
php-rise/rise
src/Container.php
Container.getNewInstance
public function getNewInstance($class) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } $args = $this->resolveArgs($class, '__construct', " when constructing $class"); if ($args) { $instance = new $class(...$args); } else { $instance = new $class; } return $instance; }
php
public function getNewInstance($class) { if (isset($this->aliases[$class])) { $class = $this->aliases[$class]; } $args = $this->resolveArgs($class, '__construct', " when constructing $class"); if ($args) { $instance = new $class(...$args); } else { $instance = new $class; } return $instance; }
[ "public", "function", "getNewInstance", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "class", "]", ")", ")", "{", "$", "class", "=", "$", "this", "->", "aliases", "[", "$", "class", "]", ";", "}", "$", "args", "=", "$", "this", "->", "resolveArgs", "(", "$", "class", ",", "'__construct'", ",", "\" when constructing $class\"", ")", ";", "if", "(", "$", "args", ")", "{", "$", "instance", "=", "new", "$", "class", "(", "...", "$", "args", ")", ";", "}", "else", "{", "$", "instance", "=", "new", "$", "class", ";", "}", "return", "$", "instance", ";", "}" ]
Construct an new instance of a class with its dependencies. @param string $class @return object
[ "Construct", "an", "new", "instance", "of", "a", "class", "with", "its", "dependencies", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L237-L250
php-rise/rise
src/Container.php
Container.getSingleton
protected function getSingleton($class) { if (isset($this->singletons[$class])) { return $this->singletons[$class]; } $instance = $this->getNewInstance($class); $this->singletons[$class] = $instance; return $instance; }
php
protected function getSingleton($class) { if (isset($this->singletons[$class])) { return $this->singletons[$class]; } $instance = $this->getNewInstance($class); $this->singletons[$class] = $instance; return $instance; }
[ "protected", "function", "getSingleton", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "singletons", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "singletons", "[", "$", "class", "]", ";", "}", "$", "instance", "=", "$", "this", "->", "getNewInstance", "(", "$", "class", ")", ";", "$", "this", "->", "singletons", "[", "$", "class", "]", "=", "$", "instance", ";", "return", "$", "instance", ";", "}" ]
Get singleton of a class. @param string $class @param string $method Optional @return object|array
[ "Get", "singleton", "of", "a", "class", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L259-L267
php-rise/rise
src/Container.php
Container.getFactory
protected function getFactory($class) { if (isset($this->factories[$class])) { return $this->factories[$class]; } $factory = new $class($this); $this->factories[$class] = $factory; return $factory; }
php
protected function getFactory($class) { if (isset($this->factories[$class])) { return $this->factories[$class]; } $factory = new $class($this); $this->factories[$class] = $factory; return $factory; }
[ "protected", "function", "getFactory", "(", "$", "class", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "factories", "[", "$", "class", "]", ")", ")", "{", "return", "$", "this", "->", "factories", "[", "$", "class", "]", ";", "}", "$", "factory", "=", "new", "$", "class", "(", "$", "this", ")", ";", "$", "this", "->", "factories", "[", "$", "class", "]", "=", "$", "factory", ";", "return", "$", "factory", ";", "}" ]
Construct a factory instance and inject this container to the instance. @param string $class @return object
[ "Construct", "a", "factory", "instance", "and", "inject", "this", "container", "to", "the", "instance", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L275-L283
php-rise/rise
src/Container.php
Container.getReflectionClass
protected function getReflectionClass($className) { if (isset($this->reflectionClasses[$className])) { return $this->reflectionClasses[$className]; } try { $reflectionClass = new ReflectionClass($className); } catch (ReflectionException $e) { throw new NotFoundException("Class $className is not found"); } if (!$reflectionClass->isInstantiable()) { throw new NotInstantiableException("$className is not an instantiable class"); } $this->reflectionClasses[$className] = $reflectionClass; return $reflectionClass; }
php
protected function getReflectionClass($className) { if (isset($this->reflectionClasses[$className])) { return $this->reflectionClasses[$className]; } try { $reflectionClass = new ReflectionClass($className); } catch (ReflectionException $e) { throw new NotFoundException("Class $className is not found"); } if (!$reflectionClass->isInstantiable()) { throw new NotInstantiableException("$className is not an instantiable class"); } $this->reflectionClasses[$className] = $reflectionClass; return $reflectionClass; }
[ "protected", "function", "getReflectionClass", "(", "$", "className", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "reflectionClasses", "[", "$", "className", "]", ")", ")", "{", "return", "$", "this", "->", "reflectionClasses", "[", "$", "className", "]", ";", "}", "try", "{", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "NotFoundException", "(", "\"Class $className is not found\"", ")", ";", "}", "if", "(", "!", "$", "reflectionClass", "->", "isInstantiable", "(", ")", ")", "{", "throw", "new", "NotInstantiableException", "(", "\"$className is not an instantiable class\"", ")", ";", "}", "$", "this", "->", "reflectionClasses", "[", "$", "className", "]", "=", "$", "reflectionClass", ";", "return", "$", "reflectionClass", ";", "}" ]
Create and cache a ReflectionClass. @param string $className @return \ReflectionClass
[ "Create", "and", "cache", "a", "ReflectionClass", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L291-L309
php-rise/rise
src/Container.php
Container.getReflectionMethod
protected function getReflectionMethod($className, $methodName = '__construct') { if (isset($this->reflectionMethods[$className]) && array_key_exists($methodName, $this->reflectionMethods[$className]) ) { return $this->reflectionMethods[$className][$methodName]; } try { $reflectionClass = $this->getReflectionClass($className); if ($methodName === '__construct') { $reflectionMethod = $reflectionClass->getConstructor(); } else { $reflectionMethod = $reflectionClass->getMethod($methodName); } $this->reflectionMethods[$className][$methodName] = $reflectionMethod; } catch (ReflectionException $e) { throw new NotFoundException("Method $className::$methodName is not found"); } return $reflectionMethod; }
php
protected function getReflectionMethod($className, $methodName = '__construct') { if (isset($this->reflectionMethods[$className]) && array_key_exists($methodName, $this->reflectionMethods[$className]) ) { return $this->reflectionMethods[$className][$methodName]; } try { $reflectionClass = $this->getReflectionClass($className); if ($methodName === '__construct') { $reflectionMethod = $reflectionClass->getConstructor(); } else { $reflectionMethod = $reflectionClass->getMethod($methodName); } $this->reflectionMethods[$className][$methodName] = $reflectionMethod; } catch (ReflectionException $e) { throw new NotFoundException("Method $className::$methodName is not found"); } return $reflectionMethod; }
[ "protected", "function", "getReflectionMethod", "(", "$", "className", ",", "$", "methodName", "=", "'__construct'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "reflectionMethods", "[", "$", "className", "]", ")", "&&", "array_key_exists", "(", "$", "methodName", ",", "$", "this", "->", "reflectionMethods", "[", "$", "className", "]", ")", ")", "{", "return", "$", "this", "->", "reflectionMethods", "[", "$", "className", "]", "[", "$", "methodName", "]", ";", "}", "try", "{", "$", "reflectionClass", "=", "$", "this", "->", "getReflectionClass", "(", "$", "className", ")", ";", "if", "(", "$", "methodName", "===", "'__construct'", ")", "{", "$", "reflectionMethod", "=", "$", "reflectionClass", "->", "getConstructor", "(", ")", ";", "}", "else", "{", "$", "reflectionMethod", "=", "$", "reflectionClass", "->", "getMethod", "(", "$", "methodName", ")", ";", "}", "$", "this", "->", "reflectionMethods", "[", "$", "className", "]", "[", "$", "methodName", "]", "=", "$", "reflectionMethod", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "NotFoundException", "(", "\"Method $className::$methodName is not found\"", ")", ";", "}", "return", "$", "reflectionMethod", ";", "}" ]
Create and cache a ReflectionMethod. @param string $className @param string $methodName @return \ReflectionMethod
[ "Create", "and", "cache", "a", "ReflectionMethod", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L318-L338
php-rise/rise
src/Container.php
Container.resolveArgs
protected function resolveArgs($className, $methodName, $errorMessageSuffix = '', $extraMappings = []) { $reflectionMethod = $this->getReflectionMethod($className, $methodName); if (is_null($reflectionMethod) && $methodName === '__construct') { return []; } $extraMappings = (array)$extraMappings; if (isset($this->rules[$className][$methodName])) { $extraMappings += $this->rules[$className][$methodName]; } $args = []; try { foreach ($reflectionMethod->getParameters() as $param) { if ($extraMappings) { $paramName = $param->getName(); // Add argument according to parameter name. if (array_key_exists($paramName, $extraMappings)) { $args[] = $extraMappings[$paramName]; continue; } } $paramType = $param->getType(); // Disallow primitive types. if ($paramType->isBuiltin()) { throw new NotAllowedException("Parameter type \"$paramType\" is not allowed" . $errorMessageSuffix); } $paramClassName = $param->getClass()->getName(); // Resolve by class. if (array_key_exists($paramClassName, $extraMappings)) { if (is_string($extraMappings[$paramClassName])) { $args[] = $this->get($extraMappings[$paramClassName]); } else { $args[] = $extraMappings[$paramClassName]; } } else { $args[] = $this->get($paramClassName); } } } catch (ReflectionException $e) { throw new NotFoundException("Parameter class $paramType is not found" . $errorMessageSuffix); } return $args; }
php
protected function resolveArgs($className, $methodName, $errorMessageSuffix = '', $extraMappings = []) { $reflectionMethod = $this->getReflectionMethod($className, $methodName); if (is_null($reflectionMethod) && $methodName === '__construct') { return []; } $extraMappings = (array)$extraMappings; if (isset($this->rules[$className][$methodName])) { $extraMappings += $this->rules[$className][$methodName]; } $args = []; try { foreach ($reflectionMethod->getParameters() as $param) { if ($extraMappings) { $paramName = $param->getName(); // Add argument according to parameter name. if (array_key_exists($paramName, $extraMappings)) { $args[] = $extraMappings[$paramName]; continue; } } $paramType = $param->getType(); // Disallow primitive types. if ($paramType->isBuiltin()) { throw new NotAllowedException("Parameter type \"$paramType\" is not allowed" . $errorMessageSuffix); } $paramClassName = $param->getClass()->getName(); // Resolve by class. if (array_key_exists($paramClassName, $extraMappings)) { if (is_string($extraMappings[$paramClassName])) { $args[] = $this->get($extraMappings[$paramClassName]); } else { $args[] = $extraMappings[$paramClassName]; } } else { $args[] = $this->get($paramClassName); } } } catch (ReflectionException $e) { throw new NotFoundException("Parameter class $paramType is not found" . $errorMessageSuffix); } return $args; }
[ "protected", "function", "resolveArgs", "(", "$", "className", ",", "$", "methodName", ",", "$", "errorMessageSuffix", "=", "''", ",", "$", "extraMappings", "=", "[", "]", ")", "{", "$", "reflectionMethod", "=", "$", "this", "->", "getReflectionMethod", "(", "$", "className", ",", "$", "methodName", ")", ";", "if", "(", "is_null", "(", "$", "reflectionMethod", ")", "&&", "$", "methodName", "===", "'__construct'", ")", "{", "return", "[", "]", ";", "}", "$", "extraMappings", "=", "(", "array", ")", "$", "extraMappings", ";", "if", "(", "isset", "(", "$", "this", "->", "rules", "[", "$", "className", "]", "[", "$", "methodName", "]", ")", ")", "{", "$", "extraMappings", "+=", "$", "this", "->", "rules", "[", "$", "className", "]", "[", "$", "methodName", "]", ";", "}", "$", "args", "=", "[", "]", ";", "try", "{", "foreach", "(", "$", "reflectionMethod", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "extraMappings", ")", "{", "$", "paramName", "=", "$", "param", "->", "getName", "(", ")", ";", "// Add argument according to parameter name.", "if", "(", "array_key_exists", "(", "$", "paramName", ",", "$", "extraMappings", ")", ")", "{", "$", "args", "[", "]", "=", "$", "extraMappings", "[", "$", "paramName", "]", ";", "continue", ";", "}", "}", "$", "paramType", "=", "$", "param", "->", "getType", "(", ")", ";", "// Disallow primitive types.", "if", "(", "$", "paramType", "->", "isBuiltin", "(", ")", ")", "{", "throw", "new", "NotAllowedException", "(", "\"Parameter type \\\"$paramType\\\" is not allowed\"", ".", "$", "errorMessageSuffix", ")", ";", "}", "$", "paramClassName", "=", "$", "param", "->", "getClass", "(", ")", "->", "getName", "(", ")", ";", "// Resolve by class.", "if", "(", "array_key_exists", "(", "$", "paramClassName", ",", "$", "extraMappings", ")", ")", "{", "if", "(", "is_string", "(", "$", "extraMappings", "[", "$", "paramClassName", "]", ")", ")", "{", "$", "args", "[", "]", "=", "$", "this", "->", "get", "(", "$", "extraMappings", "[", "$", "paramClassName", "]", ")", ";", "}", "else", "{", "$", "args", "[", "]", "=", "$", "extraMappings", "[", "$", "paramClassName", "]", ";", "}", "}", "else", "{", "$", "args", "[", "]", "=", "$", "this", "->", "get", "(", "$", "paramClassName", ")", ";", "}", "}", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "throw", "new", "NotFoundException", "(", "\"Parameter class $paramType is not found\"", ".", "$", "errorMessageSuffix", ")", ";", "}", "return", "$", "args", ";", "}" ]
Resolve parameters of ReflectionMethod. @param string $className @param string $methodName @param string $errorMessageSuffix Optional @param array $extraMappings Optional @return array
[ "Resolve", "parameters", "of", "ReflectionMethod", "." ]
train
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Container.php#L348-L400
VincentChalnot/SidusEAVFilterBundle
Filter/Type/AutocompleteDataFilterType.php
AutocompleteDataFilterType.getFormOptions
public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array { if (isset($filter->getFormOptions()['attribute'])) { return parent::getFormOptions($queryHandler, $filter); } if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } $eavAttributes = $queryHandler->getEAVAttributes($filter); if (\count($eavAttributes) > 1) { throw new \UnexpectedValueException( "Autocomplete filters does not support multiple attributes ({$filter->getCode()})" ); } return array_merge( $this->getDefaultFormOptions($queryHandler, $filter), [ 'attribute' => reset($eavAttributes), ], $filter->getFormOptions() ); }
php
public function getFormOptions(QueryHandlerInterface $queryHandler, FilterInterface $filter): array { if (isset($filter->getFormOptions()['attribute'])) { return parent::getFormOptions($queryHandler, $filter); } if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } $eavAttributes = $queryHandler->getEAVAttributes($filter); if (\count($eavAttributes) > 1) { throw new \UnexpectedValueException( "Autocomplete filters does not support multiple attributes ({$filter->getCode()})" ); } return array_merge( $this->getDefaultFormOptions($queryHandler, $filter), [ 'attribute' => reset($eavAttributes), ], $filter->getFormOptions() ); }
[ "public", "function", "getFormOptions", "(", "QueryHandlerInterface", "$", "queryHandler", ",", "FilterInterface", "$", "filter", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "filter", "->", "getFormOptions", "(", ")", "[", "'attribute'", "]", ")", ")", "{", "return", "parent", "::", "getFormOptions", "(", "$", "queryHandler", ",", "$", "filter", ")", ";", "}", "if", "(", "!", "$", "queryHandler", "instanceof", "EAVQueryHandlerInterface", ")", "{", "throw", "new", "BadQueryHandlerException", "(", "$", "queryHandler", ",", "EAVQueryHandlerInterface", "::", "class", ")", ";", "}", "$", "eavAttributes", "=", "$", "queryHandler", "->", "getEAVAttributes", "(", "$", "filter", ")", ";", "if", "(", "\\", "count", "(", "$", "eavAttributes", ")", ">", "1", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Autocomplete filters does not support multiple attributes ({$filter->getCode()})\"", ")", ";", "}", "return", "array_merge", "(", "$", "this", "->", "getDefaultFormOptions", "(", "$", "queryHandler", ",", "$", "filter", ")", ",", "[", "'attribute'", "=>", "reset", "(", "$", "eavAttributes", ")", ",", "]", ",", "$", "filter", "->", "getFormOptions", "(", ")", ")", ";", "}" ]
{@inheritdoc} @throws \UnexpectedValueException
[ "{" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/AutocompleteDataFilterType.php#L19-L43
lmammino/e-foundation
src/Order/Model/OrderItemAdjustment.php
OrderItemAdjustment.setAdjustable
public function setAdjustable(AdjustableInterface $adjustable = null) { $this->adjustable = $this->orderItem = $adjustable; return $this; }
php
public function setAdjustable(AdjustableInterface $adjustable = null) { $this->adjustable = $this->orderItem = $adjustable; return $this; }
[ "public", "function", "setAdjustable", "(", "AdjustableInterface", "$", "adjustable", "=", "null", ")", "{", "$", "this", "->", "adjustable", "=", "$", "this", "->", "orderItem", "=", "$", "adjustable", ";", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Order/Model/OrderItemAdjustment.php#L39-L44
kevintweber/phpunit-markup-validators
src/Kevintweber/PhpunitMarkupValidators/Connector/HTML5ValidatorNuConnector.php
HTML5ValidatorNuConnector.setInput
public function setInput($value) { if (stripos($value, 'html>') === false) { $this->input = '<!DOCTYPE html><html><head><meta charset="utf-8" /><title>Title</title></head><body>'. $value.'</body></html>'; } else { $this->input = $value; } }
php
public function setInput($value) { if (stripos($value, 'html>') === false) { $this->input = '<!DOCTYPE html><html><head><meta charset="utf-8" /><title>Title</title></head><body>'. $value.'</body></html>'; } else { $this->input = $value; } }
[ "public", "function", "setInput", "(", "$", "value", ")", "{", "if", "(", "stripos", "(", "$", "value", ",", "'html>'", ")", "===", "false", ")", "{", "$", "this", "->", "input", "=", "'<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><title>Title</title></head><body>'", ".", "$", "value", ".", "'</body></html>'", ";", "}", "else", "{", "$", "this", "->", "input", "=", "$", "value", ";", "}", "}" ]
Ensure that HTML fragments are submitted as complete webpages. @param string $value The HTML markup, either a fragment or a complete webpage.
[ "Ensure", "that", "HTML", "fragments", "are", "submitted", "as", "complete", "webpages", "." ]
train
https://github.com/kevintweber/phpunit-markup-validators/blob/bee48f48c7c1c9e811d1a4bedeca8f413d049cb3/src/Kevintweber/PhpunitMarkupValidators/Connector/HTML5ValidatorNuConnector.php#L74-L82
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.setStatusMessage
public function setStatusMessage($message) { $message = (string) trim($message); if ($message === '') { $this->statusMessage = $this->getStatusMessage(); } else { $this->statusMessage = $message; } return $this; }
php
public function setStatusMessage($message) { $message = (string) trim($message); if ($message === '') { $this->statusMessage = $this->getStatusMessage(); } else { $this->statusMessage = $message; } return $this; }
[ "public", "function", "setStatusMessage", "(", "$", "message", ")", "{", "$", "message", "=", "(", "string", ")", "trim", "(", "$", "message", ")", ";", "if", "(", "$", "message", "===", "''", ")", "{", "$", "this", "->", "statusMessage", "=", "$", "this", "->", "getStatusMessage", "(", ")", ";", "}", "else", "{", "$", "this", "->", "statusMessage", "=", "$", "message", ";", "}", "return", "$", "this", ";", "}" ]
Sets the HTTP response message @param string $message @return self
[ "Sets", "the", "HTTP", "response", "message" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L95-L106
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.setErrorMessage
public function setErrorMessage($message) { switch (gettype($message)) { case 'string': $this->errorMessage = trim($message); break; case 'array': $this->errorMessage = empty($message) ? '' : $message; break; default: $this->errorMessage = ''; break; } return $this; }
php
public function setErrorMessage($message) { switch (gettype($message)) { case 'string': $this->errorMessage = trim($message); break; case 'array': $this->errorMessage = empty($message) ? '' : $message; break; default: $this->errorMessage = ''; break; } return $this; }
[ "public", "function", "setErrorMessage", "(", "$", "message", ")", "{", "switch", "(", "gettype", "(", "$", "message", ")", ")", "{", "case", "'string'", ":", "$", "this", "->", "errorMessage", "=", "trim", "(", "$", "message", ")", ";", "break", ";", "case", "'array'", ":", "$", "this", "->", "errorMessage", "=", "empty", "(", "$", "message", ")", "?", "''", ":", "$", "message", ";", "break", ";", "default", ":", "$", "this", "->", "errorMessage", "=", "''", ";", "break", ";", "}", "return", "$", "this", ";", "}" ]
Sets the error message @param string|array $message @return self
[ "Sets", "the", "error", "message" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L124-L139
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.setResponseHeaders
protected function setResponseHeaders(array $headers) { // reset headers $this->headers = []; // set response status header $this->headers[] = 'HTTP/1.1 ' . $this->getStatusCode() . ' ' . $this->getStatusText(); // set content type header $this->headers['Content-Type'] = 'application/json'; // set user supplied headers foreach ($headers as $key => $value) { $this->headers[$key] = $value; } }
php
protected function setResponseHeaders(array $headers) { // reset headers $this->headers = []; // set response status header $this->headers[] = 'HTTP/1.1 ' . $this->getStatusCode() . ' ' . $this->getStatusText(); // set content type header $this->headers['Content-Type'] = 'application/json'; // set user supplied headers foreach ($headers as $key => $value) { $this->headers[$key] = $value; } }
[ "protected", "function", "setResponseHeaders", "(", "array", "$", "headers", ")", "{", "// reset headers", "$", "this", "->", "headers", "=", "[", "]", ";", "// set response status header", "$", "this", "->", "headers", "[", "]", "=", "'HTTP/1.1 '", ".", "$", "this", "->", "getStatusCode", "(", ")", ".", "' '", ".", "$", "this", "->", "getStatusText", "(", ")", ";", "// set content type header", "$", "this", "->", "headers", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "// set user supplied headers", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "headers", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Sets the response headers @param array $headers @return void
[ "Sets", "the", "response", "headers" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L182-L197
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.getSuccessResponse
protected function getSuccessResponse($data, $statusText, $headers = []) { return $this->setStatusText($this->statusTexts[$statusText]) ->setStatusCode($statusText) ->setStatusMessage(self::SUCCESS_TEXT) ->respondWithSuccessMessage($data, $headers); }
php
protected function getSuccessResponse($data, $statusText, $headers = []) { return $this->setStatusText($this->statusTexts[$statusText]) ->setStatusCode($statusText) ->setStatusMessage(self::SUCCESS_TEXT) ->respondWithSuccessMessage($data, $headers); }
[ "protected", "function", "getSuccessResponse", "(", "$", "data", ",", "$", "statusText", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "setStatusText", "(", "$", "this", "->", "statusTexts", "[", "$", "statusText", "]", ")", "->", "setStatusCode", "(", "$", "statusText", ")", "->", "setStatusMessage", "(", "self", "::", "SUCCESS_TEXT", ")", "->", "respondWithSuccessMessage", "(", "$", "data", ",", "$", "headers", ")", ";", "}" ]
Gets the success response @param array $data @param string $statusText @param array $headers @return json
[ "Gets", "the", "success", "response" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L207-L213
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.getErrorResponse
protected function getErrorResponse($msg, $errorCode, $statusText, $headers = []) { return $this->setStatusText($this->statusTexts[$statusText]) ->setStatusCode($statusText) ->setStatusMessage(self::ERROR_TEXT) ->setErrorCode($errorCode) ->setErrorMessage($msg) ->respondWithErrorMessage($headers); }
php
protected function getErrorResponse($msg, $errorCode, $statusText, $headers = []) { return $this->setStatusText($this->statusTexts[$statusText]) ->setStatusCode($statusText) ->setStatusMessage(self::ERROR_TEXT) ->setErrorCode($errorCode) ->setErrorMessage($msg) ->respondWithErrorMessage($headers); }
[ "protected", "function", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "$", "statusText", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "setStatusText", "(", "$", "this", "->", "statusTexts", "[", "$", "statusText", "]", ")", "->", "setStatusCode", "(", "$", "statusText", ")", "->", "setStatusMessage", "(", "self", "::", "ERROR_TEXT", ")", "->", "setErrorCode", "(", "$", "errorCode", ")", "->", "setErrorMessage", "(", "$", "msg", ")", "->", "respondWithErrorMessage", "(", "$", "headers", ")", ";", "}" ]
Gets the error response @param string $msg @param int $errorCode @param string $statusText @param array $headers @return json
[ "Gets", "the", "error", "response" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L224-L232
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.respondWithSuccessMessage
protected function respondWithSuccessMessage($data = [], $headers = []) { $response = []; $response['success'] = true; if (!empty($data)) { $response['response'] = $data; } return $this->respond($response, $headers); }
php
protected function respondWithSuccessMessage($data = [], $headers = []) { $response = []; $response['success'] = true; if (!empty($data)) { $response['response'] = $data; } return $this->respond($response, $headers); }
[ "protected", "function", "respondWithSuccessMessage", "(", "$", "data", "=", "[", "]", ",", "$", "headers", "=", "[", "]", ")", "{", "$", "response", "=", "[", "]", ";", "$", "response", "[", "'success'", "]", "=", "true", ";", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "response", "[", "'response'", "]", "=", "$", "data", ";", "}", "return", "$", "this", "->", "respond", "(", "$", "response", ",", "$", "headers", ")", ";", "}" ]
Returns JSON Encoded Response based on the set HTTP Status Code @param array $data @param array $headers @return json
[ "Returns", "JSON", "Encoded", "Response", "based", "on", "the", "set", "HTTP", "Status", "Code" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L241-L251
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.respondWithErrorMessage
protected function respondWithErrorMessage($headers = []) { $reponse = []; $response['success'] = false; if ($this->getErrorCode() !== null) { $response['error_code'] = (int) $this->getErrorCode(); } if (is_string($this->getErrorMessage()) && $this->getErrorMessage() !== '') { $response['error'] = $this->getErrorMessage(); } else if (is_array($this->getErrorMessage()) && !empty($this->getErrorMessage())) { $response['errors'] = $this->getErrorMessage(); } return $this->respond($response, $headers); }
php
protected function respondWithErrorMessage($headers = []) { $reponse = []; $response['success'] = false; if ($this->getErrorCode() !== null) { $response['error_code'] = (int) $this->getErrorCode(); } if (is_string($this->getErrorMessage()) && $this->getErrorMessage() !== '') { $response['error'] = $this->getErrorMessage(); } else if (is_array($this->getErrorMessage()) && !empty($this->getErrorMessage())) { $response['errors'] = $this->getErrorMessage(); } return $this->respond($response, $headers); }
[ "protected", "function", "respondWithErrorMessage", "(", "$", "headers", "=", "[", "]", ")", "{", "$", "reponse", "=", "[", "]", ";", "$", "response", "[", "'success'", "]", "=", "false", ";", "if", "(", "$", "this", "->", "getErrorCode", "(", ")", "!==", "null", ")", "{", "$", "response", "[", "'error_code'", "]", "=", "(", "int", ")", "$", "this", "->", "getErrorCode", "(", ")", ";", "}", "if", "(", "is_string", "(", "$", "this", "->", "getErrorMessage", "(", ")", ")", "&&", "$", "this", "->", "getErrorMessage", "(", ")", "!==", "''", ")", "{", "$", "response", "[", "'error'", "]", "=", "$", "this", "->", "getErrorMessage", "(", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "this", "->", "getErrorMessage", "(", ")", ")", "&&", "!", "empty", "(", "$", "this", "->", "getErrorMessage", "(", ")", ")", ")", "{", "$", "response", "[", "'errors'", "]", "=", "$", "this", "->", "getErrorMessage", "(", ")", ";", "}", "return", "$", "this", "->", "respond", "(", "$", "response", ",", "$", "headers", ")", ";", "}" ]
Returns JSON Encoded Response based on the set HTTP Status Code @param array $headers @return json
[ "Returns", "JSON", "Encoded", "Response", "based", "on", "the", "set", "HTTP", "Status", "Code" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L259-L276
nicklaw5/larapi
src/ResponseTrait.php
ResponseTrait.respond
protected function respond($data, $headers = []) { $this->setResponseHeaders($headers); return response()->json($data, $this->getStatusCode(), $this->getResponseHeaders()); }
php
protected function respond($data, $headers = []) { $this->setResponseHeaders($headers); return response()->json($data, $this->getStatusCode(), $this->getResponseHeaders()); }
[ "protected", "function", "respond", "(", "$", "data", ",", "$", "headers", "=", "[", "]", ")", "{", "$", "this", "->", "setResponseHeaders", "(", "$", "headers", ")", ";", "return", "response", "(", ")", "->", "json", "(", "$", "data", ",", "$", "this", "->", "getStatusCode", "(", ")", ",", "$", "this", "->", "getResponseHeaders", "(", ")", ")", ";", "}" ]
Returns JSON Encoded HTTP Reponse @param array $data @param array $headers @return json
[ "Returns", "JSON", "Encoded", "HTTP", "Reponse" ]
train
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/ResponseTrait.php#L285-L290
vi-kon/laravel-auth
src/database/migrations/2014_08_27_000000_create_users_table.php
CreateUsersTable.up
public function up() { $schema = app()->make('db')->connection()->getSchemaBuilder(); $schema->create(config('vi-kon.auth.table.users'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('username'); $table->string('password'); $table->string('email'); $table->string('remember_token') ->nullable(true) ->default(null); $table->string('home') ->nullable(true) ->default(null); $table->string('namespace') ->default(''); $table->boolean('blocked') ->default(false); $table->boolean('static') ->default(false); $table->boolean('hidden') ->default(false); $table->timestamps(); $table->unique(['username', 'namespace']); }); }
php
public function up() { $schema = app()->make('db')->connection()->getSchemaBuilder(); $schema->create(config('vi-kon.auth.table.users'), function (Blueprint $table) { $table->engine = 'InnoDB'; $table->increments('id'); $table->string('username'); $table->string('password'); $table->string('email'); $table->string('remember_token') ->nullable(true) ->default(null); $table->string('home') ->nullable(true) ->default(null); $table->string('namespace') ->default(''); $table->boolean('blocked') ->default(false); $table->boolean('static') ->default(false); $table->boolean('hidden') ->default(false); $table->timestamps(); $table->unique(['username', 'namespace']); }); }
[ "public", "function", "up", "(", ")", "{", "$", "schema", "=", "app", "(", ")", "->", "make", "(", "'db'", ")", "->", "connection", "(", ")", "->", "getSchemaBuilder", "(", ")", ";", "$", "schema", "->", "create", "(", "config", "(", "'vi-kon.auth.table.users'", ")", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "engine", "=", "'InnoDB'", ";", "$", "table", "->", "increments", "(", "'id'", ")", ";", "$", "table", "->", "string", "(", "'username'", ")", ";", "$", "table", "->", "string", "(", "'password'", ")", ";", "$", "table", "->", "string", "(", "'email'", ")", ";", "$", "table", "->", "string", "(", "'remember_token'", ")", "->", "nullable", "(", "true", ")", "->", "default", "(", "null", ")", ";", "$", "table", "->", "string", "(", "'home'", ")", "->", "nullable", "(", "true", ")", "->", "default", "(", "null", ")", ";", "$", "table", "->", "string", "(", "'namespace'", ")", "->", "default", "(", "''", ")", ";", "$", "table", "->", "boolean", "(", "'blocked'", ")", "->", "default", "(", "false", ")", ";", "$", "table", "->", "boolean", "(", "'static'", ")", "->", "default", "(", "false", ")", ";", "$", "table", "->", "boolean", "(", "'hidden'", ")", "->", "default", "(", "false", ")", ";", "$", "table", "->", "timestamps", "(", ")", ";", "$", "table", "->", "unique", "(", "[", "'username'", ",", "'namespace'", "]", ")", ";", "}", ")", ";", "}" ]
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/database/migrations/2014_08_27_000000_create_users_table.php#L18-L47
ThrusterIO/http-router
src/Router.php
Router.handleRequest
public function handleRequest(ServerRequestInterface $request) : ResponseInterface { list($callback, $params) = $this->internalRequestHandle($request); return call_user_func($callback, $params); }
php
public function handleRequest(ServerRequestInterface $request) : ResponseInterface { list($callback, $params) = $this->internalRequestHandle($request); return call_user_func($callback, $params); }
[ "public", "function", "handleRequest", "(", "ServerRequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "list", "(", "$", "callback", ",", "$", "params", ")", "=", "$", "this", "->", "internalRequestHandle", "(", "$", "request", ")", ";", "return", "call_user_func", "(", "$", "callback", ",", "$", "params", ")", ";", "}" ]
@param ServerRequestInterface $request @return ResponseInterface @throws RouteMethodNotAllowedException @throws RouteNotFoundException
[ "@param", "ServerRequestInterface", "$request" ]
train
https://github.com/ThrusterIO/http-router/blob/4cb461693d0815308e4c58ec59e238df2ef56a03/src/Router.php#L105-L110
benmanu/silverstripe-knowledgebase
code/search/KnowledgebaseSearchIndex.php
KnowledgebaseSearchIndex.uploadConfig
public function uploadConfig($store) { parent::uploadConfig($store); // Upload configured synonyms {@see SynonymsKnowlegebaseSiteConfig} // Getting the Main site Configuration. because Synonyms text field only // enabled in main site( subsite 0) $siteConfig = SiteConfig::get()->filter([ "SubsiteID" => 0, ])->First(); if ($siteConfig->SearchSynonyms) { $store->uploadString( $this->getIndexName(), 'synonyms.txt', $siteConfig->SearchSynonyms ); } }
php
public function uploadConfig($store) { parent::uploadConfig($store); // Upload configured synonyms {@see SynonymsKnowlegebaseSiteConfig} // Getting the Main site Configuration. because Synonyms text field only // enabled in main site( subsite 0) $siteConfig = SiteConfig::get()->filter([ "SubsiteID" => 0, ])->First(); if ($siteConfig->SearchSynonyms) { $store->uploadString( $this->getIndexName(), 'synonyms.txt', $siteConfig->SearchSynonyms ); } }
[ "public", "function", "uploadConfig", "(", "$", "store", ")", "{", "parent", "::", "uploadConfig", "(", "$", "store", ")", ";", "// Upload configured synonyms {@see SynonymsKnowlegebaseSiteConfig}", "// Getting the Main site Configuration. because Synonyms text field only", "// enabled in main site( subsite 0)", "$", "siteConfig", "=", "SiteConfig", "::", "get", "(", ")", "->", "filter", "(", "[", "\"SubsiteID\"", "=>", "0", ",", "]", ")", "->", "First", "(", ")", ";", "if", "(", "$", "siteConfig", "->", "SearchSynonyms", ")", "{", "$", "store", "->", "uploadString", "(", "$", "this", "->", "getIndexName", "(", ")", ",", "'synonyms.txt'", ",", "$", "siteConfig", "->", "SearchSynonyms", ")", ";", "}", "}" ]
Upload config for this index to the given store @param SolrConfigStore $store
[ "Upload", "config", "for", "this", "index", "to", "the", "given", "store" ]
train
https://github.com/benmanu/silverstripe-knowledgebase/blob/db19bfd4836f43da17ab52e8b53e72a11be64210/code/search/KnowledgebaseSearchIndex.php#L27-L45
praxisnetau/silverware-spam-guard
src/Extensions/UserDefinedFormExtension.php
UserDefinedFormExtension.updateCMSFields
public function updateCMSFields(FieldList $fields) { // Update Field Objects: $fields->addFieldToTab( 'Root.FormOptions', CheckboxField::create( 'EnableSpamGuard', $this->owner->fieldLabel('EnableSpamGuard') ) ); }
php
public function updateCMSFields(FieldList $fields) { // Update Field Objects: $fields->addFieldToTab( 'Root.FormOptions', CheckboxField::create( 'EnableSpamGuard', $this->owner->fieldLabel('EnableSpamGuard') ) ); }
[ "public", "function", "updateCMSFields", "(", "FieldList", "$", "fields", ")", "{", "// Update Field Objects:", "$", "fields", "->", "addFieldToTab", "(", "'Root.FormOptions'", ",", "CheckboxField", "::", "create", "(", "'EnableSpamGuard'", ",", "$", "this", "->", "owner", "->", "fieldLabel", "(", "'EnableSpamGuard'", ")", ")", ")", ";", "}" ]
Updates the CMS fields of the extended object. @param FieldList $fields List of CMS fields from the extended object. @return void
[ "Updates", "the", "CMS", "fields", "of", "the", "extended", "object", "." ]
train
https://github.com/praxisnetau/silverware-spam-guard/blob/c5f8836a09141bd675173892a1e3d8c8cc8c1886/src/Extensions/UserDefinedFormExtension.php#L62-L73
laraning/surveyor
src/Traits/AppliesScopes.php
AppliesScopes.bootAppliesScopes
public static function bootAppliesScopes() { if (SurveyorProvider::isActive()) { $repository = SurveyorProvider::retrieve(); foreach ($repository['scopes'] as $model => $scopes) { foreach ($scopes as $scope) { if (get_called_class() == $model) { static::addGlobalScope(new $scope()); } } } } else { if (Auth::user() != null) { // Surveyor needs to be active. Throw exception. throw RepositoryException::notInitialized(); } } }
php
public static function bootAppliesScopes() { if (SurveyorProvider::isActive()) { $repository = SurveyorProvider::retrieve(); foreach ($repository['scopes'] as $model => $scopes) { foreach ($scopes as $scope) { if (get_called_class() == $model) { static::addGlobalScope(new $scope()); } } } } else { if (Auth::user() != null) { // Surveyor needs to be active. Throw exception. throw RepositoryException::notInitialized(); } } }
[ "public", "static", "function", "bootAppliesScopes", "(", ")", "{", "if", "(", "SurveyorProvider", "::", "isActive", "(", ")", ")", "{", "$", "repository", "=", "SurveyorProvider", "::", "retrieve", "(", ")", ";", "foreach", "(", "$", "repository", "[", "'scopes'", "]", "as", "$", "model", "=>", "$", "scopes", ")", "{", "foreach", "(", "$", "scopes", "as", "$", "scope", ")", "{", "if", "(", "get_called_class", "(", ")", "==", "$", "model", ")", "{", "static", "::", "addGlobalScope", "(", "new", "$", "scope", "(", ")", ")", ";", "}", "}", "}", "}", "else", "{", "if", "(", "Auth", "::", "user", "(", ")", "!=", "null", ")", "{", "// Surveyor needs to be active. Throw exception.", "throw", "RepositoryException", "::", "notInitialized", "(", ")", ";", "}", "}", "}" ]
Apply model global scopes given the current logged user profiles. @return void
[ "Apply", "model", "global", "scopes", "given", "the", "current", "logged", "user", "profiles", "." ]
train
https://github.com/laraning/surveyor/blob/d845b74d20f9a4a307991019502c1b14b1730e86/src/Traits/AppliesScopes.php#L16-L33
2amigos/yiifoundation
widgets/base/Widget.php
Widget.init
public function init() { Foundation::registerCoreCss(); Foundation::registerCoreScripts(false, !YII_DEBUG, \CClientScript::POS_HEAD); $this->registerAssets(); }
php
public function init() { Foundation::registerCoreCss(); Foundation::registerCoreScripts(false, !YII_DEBUG, \CClientScript::POS_HEAD); $this->registerAssets(); }
[ "public", "function", "init", "(", ")", "{", "Foundation", "::", "registerCoreCss", "(", ")", ";", "Foundation", "::", "registerCoreScripts", "(", "false", ",", "!", "YII_DEBUG", ",", "\\", "CClientScript", "::", "POS_HEAD", ")", ";", "$", "this", "->", "registerAssets", "(", ")", ";", "}" ]
Initializes the widget
[ "Initializes", "the", "widget" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/base/Widget.php#L53-L58
2amigos/yiifoundation
widgets/base/Widget.php
Widget.registerPlugin
public function registerPlugin($name, $selector, $options = array(), $position = \CClientScript::POS_READY) { Foundation::registerPlugin($name, $selector, $options, $position); }
php
public function registerPlugin($name, $selector, $options = array(), $position = \CClientScript::POS_READY) { Foundation::registerPlugin($name, $selector, $options, $position); }
[ "public", "function", "registerPlugin", "(", "$", "name", ",", "$", "selector", ",", "$", "options", "=", "array", "(", ")", ",", "$", "position", "=", "\\", "CClientScript", "::", "POS_READY", ")", "{", "Foundation", "::", "registerPlugin", "(", "$", "name", ",", "$", "selector", ",", "$", "options", ",", "$", "position", ")", ";", "}" ]
Registers a specific plugin using the given selector and options. @param string $name the plugin name. @param string $selector the CSS selector. @param array $options the JavaScript options for the plugin. @param int $position the position of the JavaScript code.
[ "Registers", "a", "specific", "plugin", "using", "the", "given", "selector", "and", "options", "." ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/base/Widget.php#L67-L70
2amigos/yiifoundation
widgets/base/Widget.php
Widget.registerEvents
public function registerEvents($selector, $events, $position = \CClientScript::POS_READY) { Foundation::registerEvents($selector, $events, $position); }
php
public function registerEvents($selector, $events, $position = \CClientScript::POS_READY) { Foundation::registerEvents($selector, $events, $position); }
[ "public", "function", "registerEvents", "(", "$", "selector", ",", "$", "events", ",", "$", "position", "=", "\\", "CClientScript", "::", "POS_READY", ")", "{", "Foundation", "::", "registerEvents", "(", "$", "selector", ",", "$", "events", ",", "$", "position", ")", ";", "}" ]
Registers events using the given selector. @param string $selector the CSS selector. @param string[] $events the JavaScript event configuration (name=>handler). @param int $position the position of the JavaScript code.
[ "Registers", "events", "using", "the", "given", "selector", "." ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/base/Widget.php#L78-L81
2amigos/yiifoundation
widgets/base/Widget.php
Widget.registerAssets
public function registerAssets() { // make sure core hasn't been registered previously $dirs = array('css', 'js'); foreach ($this->assets as $key => $files) { if (in_array($key, $dirs)) { $files = is_array($files) ? $files : array($files); foreach ($files as $file) { $filePath = Foundation::getAssetsPath() . DIRECTORY_SEPARATOR . $key . DIRECTORY_SEPARATOR . $file; if (file_exists($filePath) && is_file($filePath)) { $method = strcasecmp($key, 'css') === 0 ? 'registerCssFile' : 'registerScriptFile'; call_user_func( array(\Yii::app()->clientScript, "$method"), Foundation::getAssetsUrl() . "/$key/$file" ); } } } } }
php
public function registerAssets() { // make sure core hasn't been registered previously $dirs = array('css', 'js'); foreach ($this->assets as $key => $files) { if (in_array($key, $dirs)) { $files = is_array($files) ? $files : array($files); foreach ($files as $file) { $filePath = Foundation::getAssetsPath() . DIRECTORY_SEPARATOR . $key . DIRECTORY_SEPARATOR . $file; if (file_exists($filePath) && is_file($filePath)) { $method = strcasecmp($key, 'css') === 0 ? 'registerCssFile' : 'registerScriptFile'; call_user_func( array(\Yii::app()->clientScript, "$method"), Foundation::getAssetsUrl() . "/$key/$file" ); } } } } }
[ "public", "function", "registerAssets", "(", ")", "{", "// make sure core hasn't been registered previously", "$", "dirs", "=", "array", "(", "'css'", ",", "'js'", ")", ";", "foreach", "(", "$", "this", "->", "assets", "as", "$", "key", "=>", "$", "files", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "dirs", ")", ")", "{", "$", "files", "=", "is_array", "(", "$", "files", ")", "?", "$", "files", ":", "array", "(", "$", "files", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "filePath", "=", "Foundation", "::", "getAssetsPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "key", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ";", "if", "(", "file_exists", "(", "$", "filePath", ")", "&&", "is_file", "(", "$", "filePath", ")", ")", "{", "$", "method", "=", "strcasecmp", "(", "$", "key", ",", "'css'", ")", "===", "0", "?", "'registerCssFile'", ":", "'registerScriptFile'", ";", "call_user_func", "(", "array", "(", "\\", "Yii", "::", "app", "(", ")", "->", "clientScript", ",", "\"$method\"", ")", ",", "Foundation", "::", "getAssetsUrl", "(", ")", ".", "\"/$key/$file\"", ")", ";", "}", "}", "}", "}", "}" ]
Registers the assets. Makes sure the assets pre-existed on the published folder prior registration.
[ "Registers", "the", "assets", ".", "Makes", "sure", "the", "assets", "pre", "-", "existed", "on", "the", "published", "folder", "prior", "registration", "." ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/base/Widget.php#L86-L107
2amigos/yiifoundation
widgets/base/Widget.php
Widget.display
public static function display($config = array()) { ob_start(); ob_implicit_flush(false); /** @var Widget $widget */ $config['class'] = get_called_class(); $widget = \Yii::createComponent($config); $widget->init(); $widget->run(); return ob_get_clean(); }
php
public static function display($config = array()) { ob_start(); ob_implicit_flush(false); /** @var Widget $widget */ $config['class'] = get_called_class(); $widget = \Yii::createComponent($config); $widget->init(); $widget->run(); return ob_get_clean(); }
[ "public", "static", "function", "display", "(", "$", "config", "=", "array", "(", ")", ")", "{", "ob_start", "(", ")", ";", "ob_implicit_flush", "(", "false", ")", ";", "/** @var Widget $widget */", "$", "config", "[", "'class'", "]", "=", "get_called_class", "(", ")", ";", "$", "widget", "=", "\\", "Yii", "::", "createComponent", "(", "$", "config", ")", ";", "$", "widget", "->", "init", "(", ")", ";", "$", "widget", "->", "run", "(", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
Ported from Yii2 widget's function. Creates a widget instance and runs it. We cannot use 'widget' name as it conflicts with CBaseController component. The widget rendering result is returned by this method. @param array $config name-value pairs that will be used to initialize the object properties @return string the rendering result of the widget.
[ "Ported", "from", "Yii2", "widget", "s", "function", ".", "Creates", "a", "widget", "instance", "and", "runs", "it", ".", "We", "cannot", "use", "widget", "name", "as", "it", "conflicts", "with", "CBaseController", "component", "." ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/base/Widget.php#L117-L127
uthando-cms/uthando-dompdf
src/UthandoDomPdf/Mvc/Service/ViewPdfStrategyFactory.php
ViewPdfStrategyFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $pdfRenderer = $serviceLocator->get(PdfRenderer::class); $pdfStrategy = new PdfStrategy($pdfRenderer); return $pdfStrategy; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $pdfRenderer = $serviceLocator->get(PdfRenderer::class); $pdfStrategy = new PdfStrategy($pdfRenderer); return $pdfStrategy; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "pdfRenderer", "=", "$", "serviceLocator", "->", "get", "(", "PdfRenderer", "::", "class", ")", ";", "$", "pdfStrategy", "=", "new", "PdfStrategy", "(", "$", "pdfRenderer", ")", ";", "return", "$", "pdfStrategy", ";", "}" ]
Create and return the PDF view strategy Retrieves the ViewPdfRenderer service from the service locator, and injects it into the constructor for the PDF strategy. @param ServiceLocatorInterface $serviceLocator @return PdfStrategy
[ "Create", "and", "return", "the", "PDF", "view", "strategy" ]
train
https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/Mvc/Service/ViewPdfStrategyFactory.php#L34-L40
timiki/rpc-common
src/JsonResponse.php
JsonResponse.setRequest
public function setRequest(JsonRequest $request) { $this->id = $request->getId(); $this->jsonrpc = $request->getJsonrpc(); $this->method = $request->getMethod(); $this->request = $request; if (!$request->getResponse()) { $request->setResponse($this); } return $this; }
php
public function setRequest(JsonRequest $request) { $this->id = $request->getId(); $this->jsonrpc = $request->getJsonrpc(); $this->method = $request->getMethod(); $this->request = $request; if (!$request->getResponse()) { $request->setResponse($this); } return $this; }
[ "public", "function", "setRequest", "(", "JsonRequest", "$", "request", ")", "{", "$", "this", "->", "id", "=", "$", "request", "->", "getId", "(", ")", ";", "$", "this", "->", "jsonrpc", "=", "$", "request", "->", "getJsonrpc", "(", ")", ";", "$", "this", "->", "method", "=", "$", "request", "->", "getMethod", "(", ")", ";", "$", "this", "->", "request", "=", "$", "request", ";", "if", "(", "!", "$", "request", "->", "getResponse", "(", ")", ")", "{", "$", "request", "->", "setResponse", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set request. @param JsonRequest|null $request @return $this
[ "Set", "request", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonResponse.php#L85-L97
timiki/rpc-common
src/JsonResponse.php
JsonResponse.getArrayResponse
public function getArrayResponse() { $json = []; $json['jsonrpc'] = '2.0'; if ($this->errorCode) { $json['error'] = []; $json['error']['code'] = $this->errorCode; $json['error']['message'] = $this->errorMessage; if (!empty($this->errorData)) { $json['error']['data'] = $this->errorData; } } else { $json['result'] = $this->result; } $json['id'] = !empty($this->id) ? $this->id : null; return $json; }
php
public function getArrayResponse() { $json = []; $json['jsonrpc'] = '2.0'; if ($this->errorCode) { $json['error'] = []; $json['error']['code'] = $this->errorCode; $json['error']['message'] = $this->errorMessage; if (!empty($this->errorData)) { $json['error']['data'] = $this->errorData; } } else { $json['result'] = $this->result; } $json['id'] = !empty($this->id) ? $this->id : null; return $json; }
[ "public", "function", "getArrayResponse", "(", ")", "{", "$", "json", "=", "[", "]", ";", "$", "json", "[", "'jsonrpc'", "]", "=", "'2.0'", ";", "if", "(", "$", "this", "->", "errorCode", ")", "{", "$", "json", "[", "'error'", "]", "=", "[", "]", ";", "$", "json", "[", "'error'", "]", "[", "'code'", "]", "=", "$", "this", "->", "errorCode", ";", "$", "json", "[", "'error'", "]", "[", "'message'", "]", "=", "$", "this", "->", "errorMessage", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "errorData", ")", ")", "{", "$", "json", "[", "'error'", "]", "[", "'data'", "]", "=", "$", "this", "->", "errorData", ";", "}", "}", "else", "{", "$", "json", "[", "'result'", "]", "=", "$", "this", "->", "result", ";", "}", "$", "json", "[", "'id'", "]", "=", "!", "empty", "(", "$", "this", "->", "id", ")", "?", "$", "this", "->", "id", ":", "null", ";", "return", "$", "json", ";", "}" ]
Return array response. @return array
[ "Return", "array", "response", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonResponse.php#L229-L251
timiki/rpc-common
src/JsonResponse.php
JsonResponse.get
public function get($name, $default = null) { if ($this->isError()) { if (array_key_exists($name, (array)$this->getErrorData())) { return $this->getErrorData()[$name]; } } else { if (array_key_exists($name, (array)$this->getResult())) { return $this->getResult()[$name]; } } return $default; }
php
public function get($name, $default = null) { if ($this->isError()) { if (array_key_exists($name, (array)$this->getErrorData())) { return $this->getErrorData()[$name]; } } else { if (array_key_exists($name, (array)$this->getResult())) { return $this->getResult()[$name]; } } return $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isError", "(", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "(", "array", ")", "$", "this", "->", "getErrorData", "(", ")", ")", ")", "{", "return", "$", "this", "->", "getErrorData", "(", ")", "[", "$", "name", "]", ";", "}", "}", "else", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "(", "array", ")", "$", "this", "->", "getResult", "(", ")", ")", ")", "{", "return", "$", "this", "->", "getResult", "(", ")", "[", "$", "name", "]", ";", "}", "}", "return", "$", "default", ";", "}" ]
Get result (error) value. @param $name @param null $default @return null|mixed
[ "Get", "result", "(", "error", ")", "value", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonResponse.php#L331-L344
milkyway-multimedia/ss-mwm-formfields
src/Composite/InlineFormField.php
InlineFormField.saveInto
public function saveInto(DataObjectInterface $record) { if (!$this->actionToExecuteOnSaveInto) { return; } if ($this->actionToExecuteOnSaveInto instanceof FormAction) { $this->actionToExecuteOnSaveInto = $this->actionToExecuteOnSaveInto->actionName(); } $funcName = $this->actionToExecuteOnSaveInto; if (!$funcName && $defaultAction = $this->inlineForm->defaultAction()) { $funcName = $defaultAction->actionName(); } if ($funcName) { $this->inlineForm->setButtonClicked($funcName); } else { if($this->inlineForm->Record) { $record = $this->inlineForm->Record; } $this->unprependName($this->inlineForm->Fields()); $this->inlineForm->loadDataFrom($this->value); $this->inlineForm->saveInto($record); return; } if ( // Ensure that the action is actually a button or method on the form, // and not just a method on the controller. ( $this->form && $this->form->Controller && $this->form->Controller->hasMethod($funcName) && !$this->form->Controller->checkAccessAction($funcName) // If a button exists, allow it on the controller && !$this->form->dataFieldByName('action_' . $funcName) ) && ( $this->inlineForm && $this->inlineForm->Controller && $this->inlineForm->Controller->hasMethod($funcName) && !$this->inlineForm->Controller->checkAccessAction($funcName) // If a button exists, allow it on the controller && !$this->inlineForm->dataFieldByName('action_' . $funcName) ) && ($this->form->hasMethod($funcName) && !$this->form->checkAccessAction($funcName)) && ($this->inlineForm->hasMethod($funcName) && !$this->inlineForm->checkAccessAction($funcName)) // No checks for button existence or $allowed_actions is performed - // all form methods are callable (e.g. the legacy "callfieldmethod()") ) { return; } $this->unprependName($this->inlineForm->Fields()); $this->inlineForm->loadDataFrom($this->value); $request = \Controller::curr()->Request; if ($this->inlineForm->Controller->hasMethod($funcName)) { $this->inlineForm->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request); // Otherwise, try a handler method on the form object. } elseif ($this->inlineForm->hasMethod($funcName)) { $this->inlineForm->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($this->form && $this->form->Controller->hasMethod($funcName)) { $this->form->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($this->form && $this->inlineForm->hasMethod($funcName)) { $this->form->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($field = $this->inlineForm->checkFieldsForAction($this->inlineForm->Fields(), $funcName)) { $field->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } }
php
public function saveInto(DataObjectInterface $record) { if (!$this->actionToExecuteOnSaveInto) { return; } if ($this->actionToExecuteOnSaveInto instanceof FormAction) { $this->actionToExecuteOnSaveInto = $this->actionToExecuteOnSaveInto->actionName(); } $funcName = $this->actionToExecuteOnSaveInto; if (!$funcName && $defaultAction = $this->inlineForm->defaultAction()) { $funcName = $defaultAction->actionName(); } if ($funcName) { $this->inlineForm->setButtonClicked($funcName); } else { if($this->inlineForm->Record) { $record = $this->inlineForm->Record; } $this->unprependName($this->inlineForm->Fields()); $this->inlineForm->loadDataFrom($this->value); $this->inlineForm->saveInto($record); return; } if ( // Ensure that the action is actually a button or method on the form, // and not just a method on the controller. ( $this->form && $this->form->Controller && $this->form->Controller->hasMethod($funcName) && !$this->form->Controller->checkAccessAction($funcName) // If a button exists, allow it on the controller && !$this->form->dataFieldByName('action_' . $funcName) ) && ( $this->inlineForm && $this->inlineForm->Controller && $this->inlineForm->Controller->hasMethod($funcName) && !$this->inlineForm->Controller->checkAccessAction($funcName) // If a button exists, allow it on the controller && !$this->inlineForm->dataFieldByName('action_' . $funcName) ) && ($this->form->hasMethod($funcName) && !$this->form->checkAccessAction($funcName)) && ($this->inlineForm->hasMethod($funcName) && !$this->inlineForm->checkAccessAction($funcName)) // No checks for button existence or $allowed_actions is performed - // all form methods are callable (e.g. the legacy "callfieldmethod()") ) { return; } $this->unprependName($this->inlineForm->Fields()); $this->inlineForm->loadDataFrom($this->value); $request = \Controller::curr()->Request; if ($this->inlineForm->Controller->hasMethod($funcName)) { $this->inlineForm->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request); // Otherwise, try a handler method on the form object. } elseif ($this->inlineForm->hasMethod($funcName)) { $this->inlineForm->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($this->form && $this->form->Controller->hasMethod($funcName)) { $this->form->Controller->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($this->form && $this->inlineForm->hasMethod($funcName)) { $this->form->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } elseif ($field = $this->inlineForm->checkFieldsForAction($this->inlineForm->Fields(), $funcName)) { $field->$funcName($this->inlineForm->Data, $this->inlineForm, $request); } }
[ "public", "function", "saveInto", "(", "DataObjectInterface", "$", "record", ")", "{", "if", "(", "!", "$", "this", "->", "actionToExecuteOnSaveInto", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "actionToExecuteOnSaveInto", "instanceof", "FormAction", ")", "{", "$", "this", "->", "actionToExecuteOnSaveInto", "=", "$", "this", "->", "actionToExecuteOnSaveInto", "->", "actionName", "(", ")", ";", "}", "$", "funcName", "=", "$", "this", "->", "actionToExecuteOnSaveInto", ";", "if", "(", "!", "$", "funcName", "&&", "$", "defaultAction", "=", "$", "this", "->", "inlineForm", "->", "defaultAction", "(", ")", ")", "{", "$", "funcName", "=", "$", "defaultAction", "->", "actionName", "(", ")", ";", "}", "if", "(", "$", "funcName", ")", "{", "$", "this", "->", "inlineForm", "->", "setButtonClicked", "(", "$", "funcName", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "inlineForm", "->", "Record", ")", "{", "$", "record", "=", "$", "this", "->", "inlineForm", "->", "Record", ";", "}", "$", "this", "->", "unprependName", "(", "$", "this", "->", "inlineForm", "->", "Fields", "(", ")", ")", ";", "$", "this", "->", "inlineForm", "->", "loadDataFrom", "(", "$", "this", "->", "value", ")", ";", "$", "this", "->", "inlineForm", "->", "saveInto", "(", "$", "record", ")", ";", "return", ";", "}", "if", "(", "// Ensure that the action is actually a button or method on the form,", "// and not just a method on the controller.", "(", "$", "this", "->", "form", "&&", "$", "this", "->", "form", "->", "Controller", "&&", "$", "this", "->", "form", "->", "Controller", "->", "hasMethod", "(", "$", "funcName", ")", "&&", "!", "$", "this", "->", "form", "->", "Controller", "->", "checkAccessAction", "(", "$", "funcName", ")", "// If a button exists, allow it on the controller", "&&", "!", "$", "this", "->", "form", "->", "dataFieldByName", "(", "'action_'", ".", "$", "funcName", ")", ")", "&&", "(", "$", "this", "->", "inlineForm", "&&", "$", "this", "->", "inlineForm", "->", "Controller", "&&", "$", "this", "->", "inlineForm", "->", "Controller", "->", "hasMethod", "(", "$", "funcName", ")", "&&", "!", "$", "this", "->", "inlineForm", "->", "Controller", "->", "checkAccessAction", "(", "$", "funcName", ")", "// If a button exists, allow it on the controller", "&&", "!", "$", "this", "->", "inlineForm", "->", "dataFieldByName", "(", "'action_'", ".", "$", "funcName", ")", ")", "&&", "(", "$", "this", "->", "form", "->", "hasMethod", "(", "$", "funcName", ")", "&&", "!", "$", "this", "->", "form", "->", "checkAccessAction", "(", "$", "funcName", ")", ")", "&&", "(", "$", "this", "->", "inlineForm", "->", "hasMethod", "(", "$", "funcName", ")", "&&", "!", "$", "this", "->", "inlineForm", "->", "checkAccessAction", "(", "$", "funcName", ")", ")", "// No checks for button existence or $allowed_actions is performed -", "// all form methods are callable (e.g. the legacy \"callfieldmethod()\")", ")", "{", "return", ";", "}", "$", "this", "->", "unprependName", "(", "$", "this", "->", "inlineForm", "->", "Fields", "(", ")", ")", ";", "$", "this", "->", "inlineForm", "->", "loadDataFrom", "(", "$", "this", "->", "value", ")", ";", "$", "request", "=", "\\", "Controller", "::", "curr", "(", ")", "->", "Request", ";", "if", "(", "$", "this", "->", "inlineForm", "->", "Controller", "->", "hasMethod", "(", "$", "funcName", ")", ")", "{", "$", "this", "->", "inlineForm", "->", "Controller", "->", "$", "funcName", "(", "$", "this", "->", "inlineForm", "->", "Data", ",", "$", "this", "->", "inlineForm", ",", "$", "request", ")", ";", "// Otherwise, try a handler method on the form object.", "}", "elseif", "(", "$", "this", "->", "inlineForm", "->", "hasMethod", "(", "$", "funcName", ")", ")", "{", "$", "this", "->", "inlineForm", "->", "$", "funcName", "(", "$", "this", "->", "inlineForm", "->", "Data", ",", "$", "this", "->", "inlineForm", ",", "$", "request", ")", ";", "}", "elseif", "(", "$", "this", "->", "form", "&&", "$", "this", "->", "form", "->", "Controller", "->", "hasMethod", "(", "$", "funcName", ")", ")", "{", "$", "this", "->", "form", "->", "Controller", "->", "$", "funcName", "(", "$", "this", "->", "inlineForm", "->", "Data", ",", "$", "this", "->", "inlineForm", ",", "$", "request", ")", ";", "}", "elseif", "(", "$", "this", "->", "form", "&&", "$", "this", "->", "inlineForm", "->", "hasMethod", "(", "$", "funcName", ")", ")", "{", "$", "this", "->", "form", "->", "$", "funcName", "(", "$", "this", "->", "inlineForm", "->", "Data", ",", "$", "this", "->", "inlineForm", ",", "$", "request", ")", ";", "}", "elseif", "(", "$", "field", "=", "$", "this", "->", "inlineForm", "->", "checkFieldsForAction", "(", "$", "this", "->", "inlineForm", "->", "Fields", "(", ")", ",", "$", "funcName", ")", ")", "{", "$", "field", "->", "$", "funcName", "(", "$", "this", "->", "inlineForm", "->", "Data", ",", "$", "this", "->", "inlineForm", ",", "$", "request", ")", ";", "}", "}" ]
This method takes care of saving all the form data @param \DataObjectInterface $record
[ "This", "method", "takes", "care", "of", "saving", "all", "the", "form", "data" ]
train
https://github.com/milkyway-multimedia/ss-mwm-formfields/blob/b98d84d494c92d6881dcea50c9c8334e5f487e1d/src/Composite/InlineFormField.php#L68-L141
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addColumn
public function addColumn($column, $options) { if (is_string($options)) { $options = ['type' => $options]; } $options = $options + [ 'field' => $column, 'type' => '', 'length' => '', 'default' => '', 'comment' => '', 'charset' => '', 'collate' => '', 'null' => true, 'ai' => false, 'index' => false, // KEY index (field[, field]) 'primary' => false, // [CONSTRAINT symbol] PRIMARY KEY (field[, field]) 'unique' => false, // [CONSTRAINT symbol] UNIQUE KEY index (field[, field]) 'foreign' => false // [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc] ]; // Force to NOT NULL for primary or auto increment columns if ($options['primary'] || $options['ai']) { $options['null'] = false; } // Filter out values so that type defaults can be inherited $this->_columns[$column] = array_filter($options, function($value) { return ($value !== '' && $value !== false); }); if ($options['primary']) { $this->addPrimary($column, $options['primary']); } else if ($options['unique']) { $this->addUnique($column, $options['unique']); } else if ($options['foreign']) { $this->addForeign($column, $options['foreign']); } if ($options['index']) { $this->addIndex($column, $options['index']); } return $this; }
php
public function addColumn($column, $options) { if (is_string($options)) { $options = ['type' => $options]; } $options = $options + [ 'field' => $column, 'type' => '', 'length' => '', 'default' => '', 'comment' => '', 'charset' => '', 'collate' => '', 'null' => true, 'ai' => false, 'index' => false, // KEY index (field[, field]) 'primary' => false, // [CONSTRAINT symbol] PRIMARY KEY (field[, field]) 'unique' => false, // [CONSTRAINT symbol] UNIQUE KEY index (field[, field]) 'foreign' => false // [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc] ]; // Force to NOT NULL for primary or auto increment columns if ($options['primary'] || $options['ai']) { $options['null'] = false; } // Filter out values so that type defaults can be inherited $this->_columns[$column] = array_filter($options, function($value) { return ($value !== '' && $value !== false); }); if ($options['primary']) { $this->addPrimary($column, $options['primary']); } else if ($options['unique']) { $this->addUnique($column, $options['unique']); } else if ($options['foreign']) { $this->addForeign($column, $options['foreign']); } if ($options['index']) { $this->addIndex($column, $options['index']); } return $this; }
[ "public", "function", "addColumn", "(", "$", "column", ",", "$", "options", ")", "{", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "'type'", "=>", "$", "options", "]", ";", "}", "$", "options", "=", "$", "options", "+", "[", "'field'", "=>", "$", "column", ",", "'type'", "=>", "''", ",", "'length'", "=>", "''", ",", "'default'", "=>", "''", ",", "'comment'", "=>", "''", ",", "'charset'", "=>", "''", ",", "'collate'", "=>", "''", ",", "'null'", "=>", "true", ",", "'ai'", "=>", "false", ",", "'index'", "=>", "false", ",", "// KEY index (field[, field])", "'primary'", "=>", "false", ",", "// [CONSTRAINT symbol] PRIMARY KEY (field[, field])", "'unique'", "=>", "false", ",", "// [CONSTRAINT symbol] UNIQUE KEY index (field[, field])", "'foreign'", "=>", "false", "// [CONSTRAINT symbol] FOREIGN KEY (field) REFERENCES table(field) [ON DELETE CASCADE, etc]", "]", ";", "// Force to NOT NULL for primary or auto increment columns", "if", "(", "$", "options", "[", "'primary'", "]", "||", "$", "options", "[", "'ai'", "]", ")", "{", "$", "options", "[", "'null'", "]", "=", "false", ";", "}", "// Filter out values so that type defaults can be inherited", "$", "this", "->", "_columns", "[", "$", "column", "]", "=", "array_filter", "(", "$", "options", ",", "function", "(", "$", "value", ")", "{", "return", "(", "$", "value", "!==", "''", "&&", "$", "value", "!==", "false", ")", ";", "}", ")", ";", "if", "(", "$", "options", "[", "'primary'", "]", ")", "{", "$", "this", "->", "addPrimary", "(", "$", "column", ",", "$", "options", "[", "'primary'", "]", ")", ";", "}", "else", "if", "(", "$", "options", "[", "'unique'", "]", ")", "{", "$", "this", "->", "addUnique", "(", "$", "column", ",", "$", "options", "[", "'unique'", "]", ")", ";", "}", "else", "if", "(", "$", "options", "[", "'foreign'", "]", ")", "{", "$", "this", "->", "addForeign", "(", "$", "column", ",", "$", "options", "[", "'foreign'", "]", ")", ";", "}", "if", "(", "$", "options", "[", "'index'", "]", ")", "{", "$", "this", "->", "addIndex", "(", "$", "column", ",", "$", "options", "[", "'index'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a column to the table schema. @param string $column @param array $options { @type string $type The column data type (one of Titon\Db\Driver\Type) @type int $length The column data length @type mixed $default The default value @type string $comment The comment @type string $charset The character set for encoding @type string $collation The collation set @type bool $null Does the column allow nulls @type bool $ai Is this an auto incrementing column @type mixed $index Is this an index @type mixed $primary Is this a primary key @type mixed $unique Is this a unique key @type mixed $foreign Is this a foreign key } @return $this
[ "Add", "a", "column", "to", "the", "table", "schema", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L101-L147
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addColumns
public function addColumns(array $columns) { foreach ($columns as $column => $options) { $this->addColumn($column, $options); } return $this; }
php
public function addColumns(array $columns) { foreach ($columns as $column => $options) { $this->addColumn($column, $options); } return $this; }
[ "public", "function", "addColumns", "(", "array", "$", "columns", ")", "{", "foreach", "(", "$", "columns", "as", "$", "column", "=>", "$", "options", ")", "{", "$", "this", "->", "addColumn", "(", "$", "column", ",", "$", "options", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add multiple columns. Index is the column name, the value is the array of options. @param array $columns @return $this
[ "Add", "multiple", "columns", ".", "Index", "is", "the", "column", "name", "the", "value", "is", "the", "array", "of", "options", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L155-L161
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addForeign
public function addForeign($column, $options = []) { if (is_string($options)) { $options = ['references' => $options]; } if (empty($options['references'])) { throw new InvalidArgumentException(sprintf('Foreign key for %s must reference an external table', $column)); } $this->_foreignKeys[$column] = $options + [ 'column' => $column, 'constraint' => '' ]; }
php
public function addForeign($column, $options = []) { if (is_string($options)) { $options = ['references' => $options]; } if (empty($options['references'])) { throw new InvalidArgumentException(sprintf('Foreign key for %s must reference an external table', $column)); } $this->_foreignKeys[$column] = $options + [ 'column' => $column, 'constraint' => '' ]; }
[ "public", "function", "addForeign", "(", "$", "column", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "'references'", "=>", "$", "options", "]", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'references'", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Foreign key for %s must reference an external table'", ",", "$", "column", ")", ")", ";", "}", "$", "this", "->", "_foreignKeys", "[", "$", "column", "]", "=", "$", "options", "+", "[", "'column'", "=>", "$", "column", ",", "'constraint'", "=>", "''", "]", ";", "}" ]
Add a foreign key for a column. Multiple foreign keys can exist so group by column. @param string $column @param string|array $options { @type string $references A table and field that the foreign key references, should be in a "user.id" format @type string $onUpdate Action to use for ON UPDATE clauses @type string $onDelete Action to use for ON DELETE clauses } @return $this @throws \Titon\Db\Exception\InvalidArgumentException
[ "Add", "a", "foreign", "key", "for", "a", "column", ".", "Multiple", "foreign", "keys", "can", "exist", "so", "group", "by", "column", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L176-L189
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addIndex
public function addIndex($column, $group = null) { if (!is_string($group)) { $group = $column; } $this->_indexes[$group][] = $column; return $this; }
php
public function addIndex($column, $group = null) { if (!is_string($group)) { $group = $column; } $this->_indexes[$group][] = $column; return $this; }
[ "public", "function", "addIndex", "(", "$", "column", ",", "$", "group", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "group", ")", ")", "{", "$", "group", "=", "$", "column", ";", "}", "$", "this", "->", "_indexes", "[", "$", "group", "]", "[", "]", "=", "$", "column", ";", "return", "$", "this", ";", "}" ]
Add an index for a column. If $group is provided, allows for grouping of columns. @param string $column @param string $group @return $this
[ "Add", "an", "index", "for", "a", "column", ".", "If", "$group", "is", "provided", "allows", "for", "grouping", "of", "columns", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L198-L206
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addPrimary
public function addPrimary($column, $options = false) { $symbol = is_string($options) ? $options : ''; if (empty($this->_primaryKey)) { $this->_primaryKey = [ 'constraint' => $symbol, 'columns' => [$column] ]; } else { $this->_primaryKey['columns'][] = $column; } return $this; }
php
public function addPrimary($column, $options = false) { $symbol = is_string($options) ? $options : ''; if (empty($this->_primaryKey)) { $this->_primaryKey = [ 'constraint' => $symbol, 'columns' => [$column] ]; } else { $this->_primaryKey['columns'][] = $column; } return $this; }
[ "public", "function", "addPrimary", "(", "$", "column", ",", "$", "options", "=", "false", ")", "{", "$", "symbol", "=", "is_string", "(", "$", "options", ")", "?", "$", "options", ":", "''", ";", "if", "(", "empty", "(", "$", "this", "->", "_primaryKey", ")", ")", "{", "$", "this", "->", "_primaryKey", "=", "[", "'constraint'", "=>", "$", "symbol", ",", "'columns'", "=>", "[", "$", "column", "]", "]", ";", "}", "else", "{", "$", "this", "->", "_primaryKey", "[", "'columns'", "]", "[", "]", "=", "$", "column", ";", "}", "return", "$", "this", ";", "}" ]
Add a primary key for a column. Only one primary key can exist. However, multiple columns can exist in a primary key. @param string $column @param string|bool $options Provide a name to reference the constraint by @return $this
[ "Add", "a", "primary", "key", "for", "a", "column", ".", "Only", "one", "primary", "key", "can", "exist", ".", "However", "multiple", "columns", "can", "exist", "in", "a", "primary", "key", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L241-L254
titon/db
src/Titon/Db/Driver/Schema.php
Schema.addUnique
public function addUnique($column, $options = []) { $symbol = ''; $index = $column; if (is_array($options)) { if (isset($options['constraint'])) { $symbol = $options['constraint']; } if (isset($options['index'])) { $index = $options['index']; } } else if (is_string($options)) { $index = $options; } if (empty($this->_uniqueKeys[$index])) { $this->_uniqueKeys[$index] = [ 'index' => $index, 'constraint' => $symbol, 'columns' => [$column] ]; } else { $this->_uniqueKeys[$index]['columns'][] = $column; } }
php
public function addUnique($column, $options = []) { $symbol = ''; $index = $column; if (is_array($options)) { if (isset($options['constraint'])) { $symbol = $options['constraint']; } if (isset($options['index'])) { $index = $options['index']; } } else if (is_string($options)) { $index = $options; } if (empty($this->_uniqueKeys[$index])) { $this->_uniqueKeys[$index] = [ 'index' => $index, 'constraint' => $symbol, 'columns' => [$column] ]; } else { $this->_uniqueKeys[$index]['columns'][] = $column; } }
[ "public", "function", "addUnique", "(", "$", "column", ",", "$", "options", "=", "[", "]", ")", "{", "$", "symbol", "=", "''", ";", "$", "index", "=", "$", "column", ";", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'constraint'", "]", ")", ")", "{", "$", "symbol", "=", "$", "options", "[", "'constraint'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'index'", "]", ")", ")", "{", "$", "index", "=", "$", "options", "[", "'index'", "]", ";", "}", "}", "else", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "$", "index", "=", "$", "options", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "_uniqueKeys", "[", "$", "index", "]", ")", ")", "{", "$", "this", "->", "_uniqueKeys", "[", "$", "index", "]", "=", "[", "'index'", "=>", "$", "index", ",", "'constraint'", "=>", "$", "symbol", ",", "'columns'", "=>", "[", "$", "column", "]", "]", ";", "}", "else", "{", "$", "this", "->", "_uniqueKeys", "[", "$", "index", "]", "[", "'columns'", "]", "[", "]", "=", "$", "column", ";", "}", "}" ]
Add a unique key for a column. Multiple unique keys can exist, so group by index. @param string $column @param string|array $options { @type string $constraint Provide a name to reference the constraint by @type string $index Custom name for the index key, defaults to the column name } @return $this
[ "Add", "a", "unique", "key", "for", "a", "column", ".", "Multiple", "unique", "keys", "can", "exist", "so", "group", "by", "index", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L267-L292
titon/db
src/Titon/Db/Driver/Schema.php
Schema.getColumn
public function getColumn($name) { if ($this->hasColumn($name)) { return $this->_columns[$name]; } throw new MissingColumnException(sprintf('Repository column %s does not exist', $name)); }
php
public function getColumn($name) { if ($this->hasColumn($name)) { return $this->_columns[$name]; } throw new MissingColumnException(sprintf('Repository column %s does not exist', $name)); }
[ "public", "function", "getColumn", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasColumn", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "_columns", "[", "$", "name", "]", ";", "}", "throw", "new", "MissingColumnException", "(", "sprintf", "(", "'Repository column %s does not exist'", ",", "$", "name", ")", ")", ";", "}" ]
Return column options by name. @param string $name @return array @throws \Titon\Db\Exception\MissingColumnException
[ "Return", "column", "options", "by", "name", "." ]
train
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Schema.php#L301-L307
forxer/tao
src/Tao/Application.php
Application.run
public function run() { try { $this['triggers']->callTrigger('before-match-request', $this); $this['request']->attributes->add( $this['router']->matchRequest($this['request']) ); $this['triggers']->callTrigger('before-controller-resolver', $this); $this['response'] = $this->controllerResolver(); } catch (ResourceNotFoundException $e) { $this['response'] = (new Controller($this))->serve404(); } catch (\Exception $e) { $this['response'] = new Response(); $this['response']->headers->set('Content-Type', 'text/plain'); $this['response']->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); $this['response']->setContent($e->getMessage()); } if ($this['x-frame-options']) { $this['response']->headers->set('x-frame-options', $this['x-frame-options']); } $this['response']->prepare($this['request']); $this['triggers']->callTrigger('before-send-response', $this); $this['response']->send(); }
php
public function run() { try { $this['triggers']->callTrigger('before-match-request', $this); $this['request']->attributes->add( $this['router']->matchRequest($this['request']) ); $this['triggers']->callTrigger('before-controller-resolver', $this); $this['response'] = $this->controllerResolver(); } catch (ResourceNotFoundException $e) { $this['response'] = (new Controller($this))->serve404(); } catch (\Exception $e) { $this['response'] = new Response(); $this['response']->headers->set('Content-Type', 'text/plain'); $this['response']->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); $this['response']->setContent($e->getMessage()); } if ($this['x-frame-options']) { $this['response']->headers->set('x-frame-options', $this['x-frame-options']); } $this['response']->prepare($this['request']); $this['triggers']->callTrigger('before-send-response', $this); $this['response']->send(); }
[ "public", "function", "run", "(", ")", "{", "try", "{", "$", "this", "[", "'triggers'", "]", "->", "callTrigger", "(", "'before-match-request'", ",", "$", "this", ")", ";", "$", "this", "[", "'request'", "]", "->", "attributes", "->", "add", "(", "$", "this", "[", "'router'", "]", "->", "matchRequest", "(", "$", "this", "[", "'request'", "]", ")", ")", ";", "$", "this", "[", "'triggers'", "]", "->", "callTrigger", "(", "'before-controller-resolver'", ",", "$", "this", ")", ";", "$", "this", "[", "'response'", "]", "=", "$", "this", "->", "controllerResolver", "(", ")", ";", "}", "catch", "(", "ResourceNotFoundException", "$", "e", ")", "{", "$", "this", "[", "'response'", "]", "=", "(", "new", "Controller", "(", "$", "this", ")", ")", "->", "serve404", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "[", "'response'", "]", "=", "new", "Response", "(", ")", ";", "$", "this", "[", "'response'", "]", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/plain'", ")", ";", "$", "this", "[", "'response'", "]", "->", "setStatusCode", "(", "Response", "::", "HTTP_INTERNAL_SERVER_ERROR", ")", ";", "$", "this", "[", "'response'", "]", "->", "setContent", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "this", "[", "'x-frame-options'", "]", ")", "{", "$", "this", "[", "'response'", "]", "->", "headers", "->", "set", "(", "'x-frame-options'", ",", "$", "this", "[", "'x-frame-options'", "]", ")", ";", "}", "$", "this", "[", "'response'", "]", "->", "prepare", "(", "$", "this", "[", "'request'", "]", ")", ";", "$", "this", "[", "'triggers'", "]", "->", "callTrigger", "(", "'before-send-response'", ",", "$", "this", ")", ";", "$", "this", "[", "'response'", "]", "->", "send", "(", ")", ";", "}" ]
Run the application.
[ "Run", "the", "application", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Application.php#L95-L130
forxer/tao
src/Tao/Application.php
Application.getModel
public function getModel($sModel) { $namespacedClass = $this['database.models_namespace'] . '\\' . $sModel; if (!isset(static::$models[$sModel])) { static::$models[$sModel] = new $namespacedClass($this); } return static::$models[$sModel]; }
php
public function getModel($sModel) { $namespacedClass = $this['database.models_namespace'] . '\\' . $sModel; if (!isset(static::$models[$sModel])) { static::$models[$sModel] = new $namespacedClass($this); } return static::$models[$sModel]; }
[ "public", "function", "getModel", "(", "$", "sModel", ")", "{", "$", "namespacedClass", "=", "$", "this", "[", "'database.models_namespace'", "]", ".", "'\\\\'", ".", "$", "sModel", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "models", "[", "$", "sModel", "]", ")", ")", "{", "static", "::", "$", "models", "[", "$", "sModel", "]", "=", "new", "$", "namespacedClass", "(", "$", "this", ")", ";", "}", "return", "static", "::", "$", "models", "[", "$", "sModel", "]", ";", "}" ]
Return the instance of specified model. @param string $sModel @return \Tao\Database\Model
[ "Return", "the", "instance", "of", "specified", "model", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Application.php#L173-L182
hpkns/laravel-front-matter
src/Hpkns/FrontMatter/Parser.php
Parser.parse
public function parse($fm, array $default = []) { $pieces = []; $parsed = []; $regexp = '/^-{3}(?:\n|\r)(.+?)-{3}(.*)$/ms'; if(preg_match($regexp, $fm, $pieces) && $yaml = $pieces[1]) { $parsed = $this->yaml->parse($yaml, true); if(is_array($parsed)) { $parsed['content'] = trim($pieces[2]); return $this->fillDefault($parsed, $default); } } throw new Exceptions\FrontMatterHeaderNotFoundException('Parser failed to find a proper Front Matter header'); }
php
public function parse($fm, array $default = []) { $pieces = []; $parsed = []; $regexp = '/^-{3}(?:\n|\r)(.+?)-{3}(.*)$/ms'; if(preg_match($regexp, $fm, $pieces) && $yaml = $pieces[1]) { $parsed = $this->yaml->parse($yaml, true); if(is_array($parsed)) { $parsed['content'] = trim($pieces[2]); return $this->fillDefault($parsed, $default); } } throw new Exceptions\FrontMatterHeaderNotFoundException('Parser failed to find a proper Front Matter header'); }
[ "public", "function", "parse", "(", "$", "fm", ",", "array", "$", "default", "=", "[", "]", ")", "{", "$", "pieces", "=", "[", "]", ";", "$", "parsed", "=", "[", "]", ";", "$", "regexp", "=", "'/^-{3}(?:\\n|\\r)(.+?)-{3}(.*)$/ms'", ";", "if", "(", "preg_match", "(", "$", "regexp", ",", "$", "fm", ",", "$", "pieces", ")", "&&", "$", "yaml", "=", "$", "pieces", "[", "1", "]", ")", "{", "$", "parsed", "=", "$", "this", "->", "yaml", "->", "parse", "(", "$", "yaml", ",", "true", ")", ";", "if", "(", "is_array", "(", "$", "parsed", ")", ")", "{", "$", "parsed", "[", "'content'", "]", "=", "trim", "(", "$", "pieces", "[", "2", "]", ")", ";", "return", "$", "this", "->", "fillDefault", "(", "$", "parsed", ",", "$", "default", ")", ";", "}", "}", "throw", "new", "Exceptions", "\\", "FrontMatterHeaderNotFoundException", "(", "'Parser failed to find a proper Front Matter header'", ")", ";", "}" ]
Parse a front matter file and return an array with its content @param string $fm @param array $default @return array
[ "Parse", "a", "front", "matter", "file", "and", "return", "an", "array", "with", "its", "content" ]
train
https://github.com/hpkns/laravel-front-matter/blob/3bcfb442f2d5b38cefdbf79a9841770e4d3a060f/src/Hpkns/FrontMatter/Parser.php#L31-L49
hpkns/laravel-front-matter
src/Hpkns/FrontMatter/Parser.php
Parser.fillDefault
protected function fillDefault(array $parsed, array $default = []) { foreach($default as $key => $value) { if( ! isset($parsed[$key])) { $parsed[$key] = $value; } } return $parsed; }
php
protected function fillDefault(array $parsed, array $default = []) { foreach($default as $key => $value) { if( ! isset($parsed[$key])) { $parsed[$key] = $value; } } return $parsed; }
[ "protected", "function", "fillDefault", "(", "array", "$", "parsed", ",", "array", "$", "default", "=", "[", "]", ")", "{", "foreach", "(", "$", "default", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "parsed", "[", "$", "key", "]", ")", ")", "{", "$", "parsed", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "parsed", ";", "}" ]
Add default value to key that are not defined in the front matter @param array $parsed @param array $default @return array
[ "Add", "default", "value", "to", "key", "that", "are", "not", "defined", "in", "the", "front", "matter" ]
train
https://github.com/hpkns/laravel-front-matter/blob/3bcfb442f2d5b38cefdbf79a9841770e4d3a060f/src/Hpkns/FrontMatter/Parser.php#L58-L69
Lansoweb/LosReCaptcha
src/Service/Response.php
Response.fromJson
public static function fromJson($json) { $responseData = json_decode($json, true); if (! $responseData) { return new Response(false, ['invalid-json']); } if (isset($responseData['success']) && $responseData['success'] == true) { return new Response(true); } if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) { return new Response(false, $responseData['error-codes']); } return new Response(false); }
php
public static function fromJson($json) { $responseData = json_decode($json, true); if (! $responseData) { return new Response(false, ['invalid-json']); } if (isset($responseData['success']) && $responseData['success'] == true) { return new Response(true); } if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) { return new Response(false, $responseData['error-codes']); } return new Response(false); }
[ "public", "static", "function", "fromJson", "(", "$", "json", ")", "{", "$", "responseData", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "!", "$", "responseData", ")", "{", "return", "new", "Response", "(", "false", ",", "[", "'invalid-json'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "responseData", "[", "'success'", "]", ")", "&&", "$", "responseData", "[", "'success'", "]", "==", "true", ")", "{", "return", "new", "Response", "(", "true", ")", ";", "}", "if", "(", "isset", "(", "$", "responseData", "[", "'error-codes'", "]", ")", "&&", "is_array", "(", "$", "responseData", "[", "'error-codes'", "]", ")", ")", "{", "return", "new", "Response", "(", "false", ",", "$", "responseData", "[", "'error-codes'", "]", ")", ";", "}", "return", "new", "Response", "(", "false", ")", ";", "}" ]
Build the response from the expected JSON returned by the service. @param string $json @return \LosReCaptcha\Service\Response
[ "Build", "the", "response", "from", "the", "expected", "JSON", "returned", "by", "the", "service", "." ]
train
https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Service/Response.php#L24-L41
SignpostMarv/daft-object
src/AbstractDaftObject.php
AbstractDaftObject.DoGetSet
protected function DoGetSet(string $property, bool $setter, $v = null) { $props = $setter ? static::DaftObjectPublicSetters() : static::DaftObjectPublicGetters(); $this->MaybeThrowOnDoGetSet($property, $setter, $props); /** * @var callable */ $callable = [$this, TypeUtilities::MethodNameFromProperty($property, $setter)]; $closure = Closure::fromCallable($callable); /** * @var scalar|array|object|null */ $out = $closure->__invoke($v); return $out; }
php
protected function DoGetSet(string $property, bool $setter, $v = null) { $props = $setter ? static::DaftObjectPublicSetters() : static::DaftObjectPublicGetters(); $this->MaybeThrowOnDoGetSet($property, $setter, $props); /** * @var callable */ $callable = [$this, TypeUtilities::MethodNameFromProperty($property, $setter)]; $closure = Closure::fromCallable($callable); /** * @var scalar|array|object|null */ $out = $closure->__invoke($v); return $out; }
[ "protected", "function", "DoGetSet", "(", "string", "$", "property", ",", "bool", "$", "setter", ",", "$", "v", "=", "null", ")", "{", "$", "props", "=", "$", "setter", "?", "static", "::", "DaftObjectPublicSetters", "(", ")", ":", "static", "::", "DaftObjectPublicGetters", "(", ")", ";", "$", "this", "->", "MaybeThrowOnDoGetSet", "(", "$", "property", ",", "$", "setter", ",", "$", "props", ")", ";", "/**\n * @var callable\n */", "$", "callable", "=", "[", "$", "this", ",", "TypeUtilities", "::", "MethodNameFromProperty", "(", "$", "property", ",", "$", "setter", ")", "]", ";", "$", "closure", "=", "Closure", "::", "fromCallable", "(", "$", "callable", ")", ";", "/**\n * @var scalar|array|object|null\n */", "$", "out", "=", "$", "closure", "->", "__invoke", "(", "$", "v", ")", ";", "return", "$", "out", ";", "}" ]
@param scalar|array|object|null $v @return scalar|array|object|null
[ "@param", "scalar|array|object|null", "$v" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/AbstractDaftObject.php#L243-L261
VincentChalnot/SidusAdminBundle
Configuration/AdminRegistry.php
AdminRegistry.getAdmin
public function getAdmin(string $code): Admin { if (empty($this->admins[$code])) { throw new UnexpectedValueException("No admin with code: {$code}"); } return $this->admins[$code]; }
php
public function getAdmin(string $code): Admin { if (empty($this->admins[$code])) { throw new UnexpectedValueException("No admin with code: {$code}"); } return $this->admins[$code]; }
[ "public", "function", "getAdmin", "(", "string", "$", "code", ")", ":", "Admin", "{", "if", "(", "empty", "(", "$", "this", "->", "admins", "[", "$", "code", "]", ")", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"No admin with code: {$code}\"", ")", ";", "}", "return", "$", "this", "->", "admins", "[", "$", "code", "]", ";", "}" ]
@param string $code @throws UnexpectedValueException @return Admin
[ "@param", "string", "$code" ]
train
https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/Configuration/AdminRegistry.php#L52-L59
flownative/flow-gravatar
Classes/ViewHelpers/GravatarViewHelper.php
GravatarViewHelper.render
public function render() { $sanitizedEmail = strtolower(trim((string)$this->arguments['email'])); $gravatarUri = 'https://www.gravatar.com/avatar/' . md5($sanitizedEmail); $uriParts = array(); if ($this->arguments['default']) { $uriParts[] = 'd=' . urlencode($this->arguments['default']); } if ($this->arguments['size']) { $uriParts[] = 's=' . $this->arguments['size']; if (!isset($this->arguments['width']) && !isset($this->arguments['height'])) { $this->tag->addAttribute('width', $this->arguments['size']); $this->tag->addAttribute('height', $this->arguments['size']); } } if (!isset($this->arguments['alt'])) { $this->tag->addAttribute('alt', 'Gravatar'); } if (count($uriParts)) { $gravatarUri .= '?' . implode('&', $uriParts); } $this->tag->addAttribute('src', $gravatarUri); return $this->tag->render(); }
php
public function render() { $sanitizedEmail = strtolower(trim((string)$this->arguments['email'])); $gravatarUri = 'https://www.gravatar.com/avatar/' . md5($sanitizedEmail); $uriParts = array(); if ($this->arguments['default']) { $uriParts[] = 'd=' . urlencode($this->arguments['default']); } if ($this->arguments['size']) { $uriParts[] = 's=' . $this->arguments['size']; if (!isset($this->arguments['width']) && !isset($this->arguments['height'])) { $this->tag->addAttribute('width', $this->arguments['size']); $this->tag->addAttribute('height', $this->arguments['size']); } } if (!isset($this->arguments['alt'])) { $this->tag->addAttribute('alt', 'Gravatar'); } if (count($uriParts)) { $gravatarUri .= '?' . implode('&', $uriParts); } $this->tag->addAttribute('src', $gravatarUri); return $this->tag->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "sanitizedEmail", "=", "strtolower", "(", "trim", "(", "(", "string", ")", "$", "this", "->", "arguments", "[", "'email'", "]", ")", ")", ";", "$", "gravatarUri", "=", "'https://www.gravatar.com/avatar/'", ".", "md5", "(", "$", "sanitizedEmail", ")", ";", "$", "uriParts", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "arguments", "[", "'default'", "]", ")", "{", "$", "uriParts", "[", "]", "=", "'d='", ".", "urlencode", "(", "$", "this", "->", "arguments", "[", "'default'", "]", ")", ";", "}", "if", "(", "$", "this", "->", "arguments", "[", "'size'", "]", ")", "{", "$", "uriParts", "[", "]", "=", "'s='", ".", "$", "this", "->", "arguments", "[", "'size'", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "arguments", "[", "'width'", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "arguments", "[", "'height'", "]", ")", ")", "{", "$", "this", "->", "tag", "->", "addAttribute", "(", "'width'", ",", "$", "this", "->", "arguments", "[", "'size'", "]", ")", ";", "$", "this", "->", "tag", "->", "addAttribute", "(", "'height'", ",", "$", "this", "->", "arguments", "[", "'size'", "]", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "arguments", "[", "'alt'", "]", ")", ")", "{", "$", "this", "->", "tag", "->", "addAttribute", "(", "'alt'", ",", "'Gravatar'", ")", ";", "}", "if", "(", "count", "(", "$", "uriParts", ")", ")", "{", "$", "gravatarUri", ".=", "'?'", ".", "implode", "(", "'&'", ",", "$", "uriParts", ")", ";", "}", "$", "this", "->", "tag", "->", "addAttribute", "(", "'src'", ",", "$", "gravatarUri", ")", ";", "return", "$", "this", "->", "tag", "->", "render", "(", ")", ";", "}" ]
Render the link. @return string The rendered link
[ "Render", "the", "link", "." ]
train
https://github.com/flownative/flow-gravatar/blob/ae5c641f0699a6c5c4190c6177af090b5d50a22d/Classes/ViewHelpers/GravatarViewHelper.php#L59-L81
yuncms/framework
src/authclient/QQ.php
QQ.processResult
protected function processResult(Response $response) { $content = $response->getContent(); if (strpos($content, "callback(") === 0) { $count = 0; $jsonData = preg_replace('/^callback\(\s*(\\{.*\\})\s*\);$/is', '\1', $content, 1, $count); if ($count === 1) { $response->setContent($jsonData); } } }
php
protected function processResult(Response $response) { $content = $response->getContent(); if (strpos($content, "callback(") === 0) { $count = 0; $jsonData = preg_replace('/^callback\(\s*(\\{.*\\})\s*\);$/is', '\1', $content, 1, $count); if ($count === 1) { $response->setContent($jsonData); } } }
[ "protected", "function", "processResult", "(", "Response", "$", "response", ")", "{", "$", "content", "=", "$", "response", "->", "getContent", "(", ")", ";", "if", "(", "strpos", "(", "$", "content", ",", "\"callback(\"", ")", "===", "0", ")", "{", "$", "count", "=", "0", ";", "$", "jsonData", "=", "preg_replace", "(", "'/^callback\\(\\s*(\\\\{.*\\\\})\\s*\\);$/is'", ",", "'\\1'", ",", "$", "content", ",", "1", ",", "$", "count", ")", ";", "if", "(", "$", "count", "===", "1", ")", "{", "$", "response", "->", "setContent", "(", "$", "jsonData", ")", ";", "}", "}", "}" ]
处理响应 @param Response $response @since 2.1
[ "处理响应" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/authclient/QQ.php#L127-L137
webforge-labs/psc-cms
lib/Psc/Doctrine/ProjectFixture.php
ProjectFixture.load
public function load(ObjectManager $manager) { $c = $this->project->getUserClass(); $user = new $c('[email protected]'); $user->setPassword('583cdd008f2ea237bfe4d39a2d827f42'); $manager->persist($user); $user = new $c('[email protected]'); $user->setPassword('9606fe7ecf5e4e76e4fa0f07c97e3e49'); $manager->persist($user); $hostConfig = $this->project->getHostConfig(); $user = new $c($hostConfig->req('cmf.user')); $user->hashPassword($hostConfig->req('cmf.password')); $manager->persist($user); }
php
public function load(ObjectManager $manager) { $c = $this->project->getUserClass(); $user = new $c('[email protected]'); $user->setPassword('583cdd008f2ea237bfe4d39a2d827f42'); $manager->persist($user); $user = new $c('[email protected]'); $user->setPassword('9606fe7ecf5e4e76e4fa0f07c97e3e49'); $manager->persist($user); $hostConfig = $this->project->getHostConfig(); $user = new $c($hostConfig->req('cmf.user')); $user->hashPassword($hostConfig->req('cmf.password')); $manager->persist($user); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "$", "c", "=", "$", "this", "->", "project", "->", "getUserClass", "(", ")", ";", "$", "user", "=", "new", "$", "c", "(", "'[email protected]'", ")", ";", "$", "user", "->", "setPassword", "(", "'583cdd008f2ea237bfe4d39a2d827f42'", ")", ";", "$", "manager", "->", "persist", "(", "$", "user", ")", ";", "$", "user", "=", "new", "$", "c", "(", "'[email protected]'", ")", ";", "$", "user", "->", "setPassword", "(", "'9606fe7ecf5e4e76e4fa0f07c97e3e49'", ")", ";", "$", "manager", "->", "persist", "(", "$", "user", ")", ";", "$", "hostConfig", "=", "$", "this", "->", "project", "->", "getHostConfig", "(", ")", ";", "$", "user", "=", "new", "$", "c", "(", "$", "hostConfig", "->", "req", "(", "'cmf.user'", ")", ")", ";", "$", "user", "->", "hashPassword", "(", "$", "hostConfig", "->", "req", "(", "'cmf.password'", ")", ")", ";", "$", "manager", "->", "persist", "(", "$", "user", ")", ";", "}" ]
Load data fixtures with the passed EntityManager flush in ableitender Klasse machen! @param Doctrine\Common\Persistence\ObjectManager $manager
[ "Load", "data", "fixtures", "with", "the", "passed", "EntityManager" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Doctrine/ProjectFixture.php#L22-L37
GrahamDeprecated/CMS-Core
src/Seeds/EventsTableSeeder.php
EventsTableSeeder.run
public function run() { DB::table('events')->delete(); $date = Carbon::now(); $event = array( 'title' => 'Example Event', 'date' => $date->addWeeks(2), 'location' => 'Example Location', 'body' => 'This is an example event.', 'user_id' => 1, 'created_at' => new DateTime, 'updated_at' => new DateTime ); DB::table('events')->insert($event); }
php
public function run() { DB::table('events')->delete(); $date = Carbon::now(); $event = array( 'title' => 'Example Event', 'date' => $date->addWeeks(2), 'location' => 'Example Location', 'body' => 'This is an example event.', 'user_id' => 1, 'created_at' => new DateTime, 'updated_at' => new DateTime ); DB::table('events')->insert($event); }
[ "public", "function", "run", "(", ")", "{", "DB", "::", "table", "(", "'events'", ")", "->", "delete", "(", ")", ";", "$", "date", "=", "Carbon", "::", "now", "(", ")", ";", "$", "event", "=", "array", "(", "'title'", "=>", "'Example Event'", ",", "'date'", "=>", "$", "date", "->", "addWeeks", "(", "2", ")", ",", "'location'", "=>", "'Example Location'", ",", "'body'", "=>", "'This is an example event.'", ",", "'user_id'", "=>", "1", ",", "'created_at'", "=>", "new", "DateTime", ",", "'updated_at'", "=>", "new", "DateTime", ")", ";", "DB", "::", "table", "(", "'events'", ")", "->", "insert", "(", "$", "event", ")", ";", "}" ]
Run the database seeding. @return void
[ "Run", "the", "database", "seeding", "." ]
train
https://github.com/GrahamDeprecated/CMS-Core/blob/5603e2bfa2fac6cf46ca3ed62d21518f2f653675/src/Seeds/EventsTableSeeder.php#L40-L57
dms-org/package.blog
src/Domain/Services/Loader/BlogCategoryLoader.php
BlogCategoryLoader.loadFromSlug
public function loadFromSlug(string $slug) : BlogCategory { $categories = $this->blogCategoryRepo->matching( $this->blogCategoryRepo->criteria() ->where(BlogCategory::SLUG, '=', $slug) ->where(BlogCategory::PUBLISHED, '=', true) ); if (!$categories) { throw new EntityNotFoundException(BlogCategory::class, $slug, BlogCategory::SLUG); } return reset($categories); }
php
public function loadFromSlug(string $slug) : BlogCategory { $categories = $this->blogCategoryRepo->matching( $this->blogCategoryRepo->criteria() ->where(BlogCategory::SLUG, '=', $slug) ->where(BlogCategory::PUBLISHED, '=', true) ); if (!$categories) { throw new EntityNotFoundException(BlogCategory::class, $slug, BlogCategory::SLUG); } return reset($categories); }
[ "public", "function", "loadFromSlug", "(", "string", "$", "slug", ")", ":", "BlogCategory", "{", "$", "categories", "=", "$", "this", "->", "blogCategoryRepo", "->", "matching", "(", "$", "this", "->", "blogCategoryRepo", "->", "criteria", "(", ")", "->", "where", "(", "BlogCategory", "::", "SLUG", ",", "'='", ",", "$", "slug", ")", "->", "where", "(", "BlogCategory", "::", "PUBLISHED", ",", "'='", ",", "true", ")", ")", ";", "if", "(", "!", "$", "categories", ")", "{", "throw", "new", "EntityNotFoundException", "(", "BlogCategory", "::", "class", ",", "$", "slug", ",", "BlogCategory", "::", "SLUG", ")", ";", "}", "return", "reset", "(", "$", "categories", ")", ";", "}" ]
@param string $slug @return BlogCategory @throws EntityNotFoundException
[ "@param", "string", "$slug" ]
train
https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Domain/Services/Loader/BlogCategoryLoader.php#L47-L60
steeffeen/FancyManiaLinks
FML/Script/Features/EntrySubmit.php
EntrySubmit.setEntry
public function setEntry(Entry $entry) { $entry->setScriptEvents(true) ->checkId(); $this->entry = $entry; return $this; }
php
public function setEntry(Entry $entry) { $entry->setScriptEvents(true) ->checkId(); $this->entry = $entry; return $this; }
[ "public", "function", "setEntry", "(", "Entry", "$", "entry", ")", "{", "$", "entry", "->", "setScriptEvents", "(", "true", ")", "->", "checkId", "(", ")", ";", "$", "this", "->", "entry", "=", "$", "entry", ";", "return", "$", "this", ";", "}" ]
Set the Entry @api @param Entry $entry Entry Control @return static
[ "Set", "the", "Entry" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/EntrySubmit.php#L66-L72
steeffeen/FancyManiaLinks
FML/Script/Features/EntrySubmit.php
EntrySubmit.getEntrySubmitScriptText
protected function getEntrySubmitScriptText() { $url = $this->buildCompatibleUrl(); $entryName = $this->entry->getName(); $link = Builder::escapeText($url . $entryName . "="); return " declare Value = TextLib::URLEncode(Entry.Value); OpenLink({$link}^Value, CMlScript::LinkType::Goto); "; }
php
protected function getEntrySubmitScriptText() { $url = $this->buildCompatibleUrl(); $entryName = $this->entry->getName(); $link = Builder::escapeText($url . $entryName . "="); return " declare Value = TextLib::URLEncode(Entry.Value); OpenLink({$link}^Value, CMlScript::LinkType::Goto); "; }
[ "protected", "function", "getEntrySubmitScriptText", "(", ")", "{", "$", "url", "=", "$", "this", "->", "buildCompatibleUrl", "(", ")", ";", "$", "entryName", "=", "$", "this", "->", "entry", "->", "getName", "(", ")", ";", "$", "link", "=", "Builder", "::", "escapeText", "(", "$", "url", ".", "$", "entryName", ".", "\"=\"", ")", ";", "return", "\"\ndeclare Value = TextLib::URLEncode(Entry.Value);\nOpenLink({$link}^Value, CMlScript::LinkType::Goto);\n\"", ";", "}" ]
Get the entry submit event script text @return string
[ "Get", "the", "entry", "submit", "event", "script", "text" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/EntrySubmit.php#L114-L123
steeffeen/FancyManiaLinks
FML/Script/Features/EntrySubmit.php
EntrySubmit.buildCompatibleUrl
protected function buildCompatibleUrl() { $url = $this->url; $parametersIndex = stripos($url, "?"); if (!is_int($parametersIndex) || $parametersIndex < 0) { $url .= "?"; } else { $url .= "&"; } return $url; }
php
protected function buildCompatibleUrl() { $url = $this->url; $parametersIndex = stripos($url, "?"); if (!is_int($parametersIndex) || $parametersIndex < 0) { $url .= "?"; } else { $url .= "&"; } return $url; }
[ "protected", "function", "buildCompatibleUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "url", ";", "$", "parametersIndex", "=", "stripos", "(", "$", "url", ",", "\"?\"", ")", ";", "if", "(", "!", "is_int", "(", "$", "parametersIndex", ")", "||", "$", "parametersIndex", "<", "0", ")", "{", "$", "url", ".=", "\"?\"", ";", "}", "else", "{", "$", "url", ".=", "\"&\"", ";", "}", "return", "$", "url", ";", "}" ]
Build the submit url compatible for the entry parameter @return string
[ "Build", "the", "submit", "url", "compatible", "for", "the", "entry", "parameter" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/EntrySubmit.php#L130-L140
helthe/Chronos
Field/DayOfWeekField.php
DayOfWeekField.matches
public function matches(\DateTime $date) { if ('?' === $this->value) { return true; } $found = parent::matches($date); if (!$found) { $values = $this->getValueArray(); foreach ($values as $value) { if ($found) { break; } if (strpos($value, '#') !== false) { $found = $this->matchesHash($value, $date); } elseif (strpos($value, 'L') !== false) { $found = $this->matchesLastDay($value, $date); } } } return $found; }
php
public function matches(\DateTime $date) { if ('?' === $this->value) { return true; } $found = parent::matches($date); if (!$found) { $values = $this->getValueArray(); foreach ($values as $value) { if ($found) { break; } if (strpos($value, '#') !== false) { $found = $this->matchesHash($value, $date); } elseif (strpos($value, 'L') !== false) { $found = $this->matchesLastDay($value, $date); } } } return $found; }
[ "public", "function", "matches", "(", "\\", "DateTime", "$", "date", ")", "{", "if", "(", "'?'", "===", "$", "this", "->", "value", ")", "{", "return", "true", ";", "}", "$", "found", "=", "parent", "::", "matches", "(", "$", "date", ")", ";", "if", "(", "!", "$", "found", ")", "{", "$", "values", "=", "$", "this", "->", "getValueArray", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "$", "found", ")", "{", "break", ";", "}", "if", "(", "strpos", "(", "$", "value", ",", "'#'", ")", "!==", "false", ")", "{", "$", "found", "=", "$", "this", "->", "matchesHash", "(", "$", "value", ",", "$", "date", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "value", ",", "'L'", ")", "!==", "false", ")", "{", "$", "found", "=", "$", "this", "->", "matchesLastDay", "(", "$", "value", ",", "$", "date", ")", ";", "}", "}", "}", "return", "$", "found", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/DayOfWeekField.php#L38-L63
helthe/Chronos
Field/DayOfWeekField.php
DayOfWeekField.matchesHash
private function matchesHash($hash, \DateTime $date) { $ordinals = array( '1' => 'first', '2' => 'second', '3' => 'third', '4' => 'fourth', '5' => 'fifth' ); $hashParts = explode('#', $hash); if ($hashParts[0] != $this->getFieldValueFromDate($date)) { return false; } return $this->matchesRelativeDate($date, $ordinals[$hashParts[1]]); }
php
private function matchesHash($hash, \DateTime $date) { $ordinals = array( '1' => 'first', '2' => 'second', '3' => 'third', '4' => 'fourth', '5' => 'fifth' ); $hashParts = explode('#', $hash); if ($hashParts[0] != $this->getFieldValueFromDate($date)) { return false; } return $this->matchesRelativeDate($date, $ordinals[$hashParts[1]]); }
[ "private", "function", "matchesHash", "(", "$", "hash", ",", "\\", "DateTime", "$", "date", ")", "{", "$", "ordinals", "=", "array", "(", "'1'", "=>", "'first'", ",", "'2'", "=>", "'second'", ",", "'3'", "=>", "'third'", ",", "'4'", "=>", "'fourth'", ",", "'5'", "=>", "'fifth'", ")", ";", "$", "hashParts", "=", "explode", "(", "'#'", ",", "$", "hash", ")", ";", "if", "(", "$", "hashParts", "[", "0", "]", "!=", "$", "this", "->", "getFieldValueFromDate", "(", "$", "date", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "matchesRelativeDate", "(", "$", "date", ",", "$", "ordinals", "[", "$", "hashParts", "[", "1", "]", "]", ")", ";", "}" ]
Checks if the hash value matches the given date. @param string $hash @param \DateTime $date @return Boolean
[ "Checks", "if", "the", "hash", "value", "matches", "the", "given", "date", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/DayOfWeekField.php#L101-L117
helthe/Chronos
Field/DayOfWeekField.php
DayOfWeekField.matchesLastDay
private function matchesLastDay($day, \DateTime $date) { $day = substr($day, 0, -1); if ($day != $this->getFieldValueFromDate($date)) { return false; } return $this->matchesRelativeDate($date, 'last'); }
php
private function matchesLastDay($day, \DateTime $date) { $day = substr($day, 0, -1); if ($day != $this->getFieldValueFromDate($date)) { return false; } return $this->matchesRelativeDate($date, 'last'); }
[ "private", "function", "matchesLastDay", "(", "$", "day", ",", "\\", "DateTime", "$", "date", ")", "{", "$", "day", "=", "substr", "(", "$", "day", ",", "0", ",", "-", "1", ")", ";", "if", "(", "$", "day", "!=", "$", "this", "->", "getFieldValueFromDate", "(", "$", "date", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "matchesRelativeDate", "(", "$", "date", ",", "'last'", ")", ";", "}" ]
Checks if the given last day matches the given date. @param string $day @param \DateTime $date @return Boolean
[ "Checks", "if", "the", "given", "last", "day", "matches", "the", "given", "date", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/DayOfWeekField.php#L127-L136
helthe/Chronos
Field/DayOfWeekField.php
DayOfWeekField.matchesRelativeDate
private function matchesRelativeDate(\DateTime $date, $prefix) { $correctDate = new \DateTime($prefix . ' ' . $date->format('D') . ' of ' . $date->format('F') . ' ' . $date->format('Y')); return $date->format('Y-m-d') == $correctDate->format('Y-m-d'); }
php
private function matchesRelativeDate(\DateTime $date, $prefix) { $correctDate = new \DateTime($prefix . ' ' . $date->format('D') . ' of ' . $date->format('F') . ' ' . $date->format('Y')); return $date->format('Y-m-d') == $correctDate->format('Y-m-d'); }
[ "private", "function", "matchesRelativeDate", "(", "\\", "DateTime", "$", "date", ",", "$", "prefix", ")", "{", "$", "correctDate", "=", "new", "\\", "DateTime", "(", "$", "prefix", ".", "' '", ".", "$", "date", "->", "format", "(", "'D'", ")", ".", "' of '", ".", "$", "date", "->", "format", "(", "'F'", ")", ".", "' '", ".", "$", "date", "->", "format", "(", "'Y'", ")", ")", ";", "return", "$", "date", "->", "format", "(", "'Y-m-d'", ")", "==", "$", "correctDate", "->", "format", "(", "'Y-m-d'", ")", ";", "}" ]
Checks if the given date matches the relative date with the given prefix (ordinal or last). @param \DateTime $date @param string $prefix @return Boolean
[ "Checks", "if", "the", "given", "date", "matches", "the", "relative", "date", "with", "the", "given", "prefix", "(", "ordinal", "or", "last", ")", "." ]
train
https://github.com/helthe/Chronos/blob/6c783c55c32b323550fc6f21cd644c2be82720b0/Field/DayOfWeekField.php#L146-L151
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/PDOStatement.php
PDOStatement.bindColumn
public function bindColumn($column, &$param, $type = null) { if ($type === null) : $this->_statement->bindColumn($column, $param); else : $this->_statement->bindColumn($column, $param, $type); endif; }
php
public function bindColumn($column, &$param, $type = null) { if ($type === null) : $this->_statement->bindColumn($column, $param); else : $this->_statement->bindColumn($column, $param, $type); endif; }
[ "public", "function", "bindColumn", "(", "$", "column", ",", "&", "$", "param", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "===", "null", ")", ":", "$", "this", "->", "_statement", "->", "bindColumn", "(", "$", "column", ",", "$", "param", ")", ";", "else", ":", "$", "this", "->", "_statement", "->", "bindColumn", "(", "$", "column", ",", "$", "param", ",", "$", "type", ")", ";", "endif", ";", "}" ]
Bind a value of the column or field table @access public @param string $column @param mixed $param @param string $type @return void
[ "Bind", "a", "value", "of", "the", "column", "or", "field", "table" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDOStatement.php#L62-L69
simple-php-mvc/simple-php-mvc
src/MVC/DataBase/PDOStatement.php
PDOStatement.bindParam
public function bindParam($column, &$param, $type = null) { if ($type === null) : $this->_statement->bindParam($column, $param); else : $this->_statement->bindParam($column, $param, $type); endif; }
php
public function bindParam($column, &$param, $type = null) { if ($type === null) : $this->_statement->bindParam($column, $param); else : $this->_statement->bindParam($column, $param, $type); endif; }
[ "public", "function", "bindParam", "(", "$", "column", ",", "&", "$", "param", ",", "$", "type", "=", "null", ")", "{", "if", "(", "$", "type", "===", "null", ")", ":", "$", "this", "->", "_statement", "->", "bindParam", "(", "$", "column", ",", "$", "param", ")", ";", "else", ":", "$", "this", "->", "_statement", "->", "bindParam", "(", "$", "column", ",", "$", "param", ",", "$", "type", ")", ";", "endif", ";", "}" ]
Bind a value of the param SQL @access public @param string $column @param mixed $param @param string $type @return void
[ "Bind", "a", "value", "of", "the", "param", "SQL" ]
train
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/DataBase/PDOStatement.php#L79-L86
voda/php-translator
Antee/i18n/GettextTranslator.php
GettextTranslator.gettext
public function gettext($message) { if (strlen($message) === 0) { return $message; } if ($this->reader === null) { return $message; } return $this->reader->translate((string)$message); }
php
public function gettext($message) { if (strlen($message) === 0) { return $message; } if ($this->reader === null) { return $message; } return $this->reader->translate((string)$message); }
[ "public", "function", "gettext", "(", "$", "message", ")", "{", "if", "(", "strlen", "(", "$", "message", ")", "===", "0", ")", "{", "return", "$", "message", ";", "}", "if", "(", "$", "this", "->", "reader", "===", "null", ")", "{", "return", "$", "message", ";", "}", "return", "$", "this", "->", "reader", "->", "translate", "(", "(", "string", ")", "$", "message", ")", ";", "}" ]
Translate a message. @param string $message @return string
[ "Translate", "a", "message", "." ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L78-L86
voda/php-translator
Antee/i18n/GettextTranslator.php
GettextTranslator.ngettext
public function ngettext($singular, $plural, $count) { if ($this->reader === null) { return $count > 1 ? $plural : $singular; } return $this->reader->ngettext((string)$singular, (string)$plural, $count); }
php
public function ngettext($singular, $plural, $count) { if ($this->reader === null) { return $count > 1 ? $plural : $singular; } return $this->reader->ngettext((string)$singular, (string)$plural, $count); }
[ "public", "function", "ngettext", "(", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", "{", "if", "(", "$", "this", "->", "reader", "===", "null", ")", "{", "return", "$", "count", ">", "1", "?", "$", "plural", ":", "$", "singular", ";", "}", "return", "$", "this", "->", "reader", "->", "ngettext", "(", "(", "string", ")", "$", "singular", ",", "(", "string", ")", "$", "plural", ",", "$", "count", ")", ";", "}" ]
Plural version of gettext. @param string $singular @param string $plural @param int $count @return string
[ "Plural", "version", "of", "gettext", "." ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L96-L101
voda/php-translator
Antee/i18n/GettextTranslator.php
GettextTranslator.pgettext
public function pgettext($context, $message) { if ($this->reader === null) { return $message; } return $this->reader->pgettext((string)$context, (string)$message); }
php
public function pgettext($context, $message) { if ($this->reader === null) { return $message; } return $this->reader->pgettext((string)$context, (string)$message); }
[ "public", "function", "pgettext", "(", "$", "context", ",", "$", "message", ")", "{", "if", "(", "$", "this", "->", "reader", "===", "null", ")", "{", "return", "$", "message", ";", "}", "return", "$", "this", "->", "reader", "->", "pgettext", "(", "(", "string", ")", "$", "context", ",", "(", "string", ")", "$", "message", ")", ";", "}" ]
gettext with contect. @param string $context @param string $message @return string
[ "gettext", "with", "contect", "." ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L110-L115
voda/php-translator
Antee/i18n/GettextTranslator.php
GettextTranslator.npgettext
public function npgettext($context, $singular, $plural, $count) { if ($this->reader === null) { return $count > 1 ? $plural : $singular; } return $this->reader->npgettext((string)$context, (string)$singular, (string)$plural, $count); }
php
public function npgettext($context, $singular, $plural, $count) { if ($this->reader === null) { return $count > 1 ? $plural : $singular; } return $this->reader->npgettext((string)$context, (string)$singular, (string)$plural, $count); }
[ "public", "function", "npgettext", "(", "$", "context", ",", "$", "singular", ",", "$", "plural", ",", "$", "count", ")", "{", "if", "(", "$", "this", "->", "reader", "===", "null", ")", "{", "return", "$", "count", ">", "1", "?", "$", "plural", ":", "$", "singular", ";", "}", "return", "$", "this", "->", "reader", "->", "npgettext", "(", "(", "string", ")", "$", "context", ",", "(", "string", ")", "$", "singular", ",", "(", "string", ")", "$", "plural", ",", "$", "count", ")", ";", "}" ]
Plural version of gettext with context. @param string $context @param string $singular @param string $plural @param int $count @return string
[ "Plural", "version", "of", "gettext", "with", "context", "." ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/GettextTranslator.php#L126-L131
npbtrac/yii2-enpii-cms
libs/override/web/NpView.php
NpView.addBaseUrlScript
public function addBaseUrlScript() { // Add base Url and absolute base Url to the head $arrJsPosHEad = empty($this->js[static::POS_HEAD]) ? [] : $this->js[static::POS_HEAD]; array_unshift($arrJsPosHEad, "var absoluteBaseUrl = \"" . Yii::$app->urlManager->createAbsoluteUrl('site/index') . "\";"); array_unshift($arrJsPosHEad, "var baseUrl = \"" . Yii::$app->urlManager->baseUrl . "\";"); $this->js[static::POS_HEAD] = $arrJsPosHEad; }
php
public function addBaseUrlScript() { // Add base Url and absolute base Url to the head $arrJsPosHEad = empty($this->js[static::POS_HEAD]) ? [] : $this->js[static::POS_HEAD]; array_unshift($arrJsPosHEad, "var absoluteBaseUrl = \"" . Yii::$app->urlManager->createAbsoluteUrl('site/index') . "\";"); array_unshift($arrJsPosHEad, "var baseUrl = \"" . Yii::$app->urlManager->baseUrl . "\";"); $this->js[static::POS_HEAD] = $arrJsPosHEad; }
[ "public", "function", "addBaseUrlScript", "(", ")", "{", "// Add base Url and absolute base Url to the head", "$", "arrJsPosHEad", "=", "empty", "(", "$", "this", "->", "js", "[", "static", "::", "POS_HEAD", "]", ")", "?", "[", "]", ":", "$", "this", "->", "js", "[", "static", "::", "POS_HEAD", "]", ";", "array_unshift", "(", "$", "arrJsPosHEad", ",", "\"var absoluteBaseUrl = \\\"\"", ".", "Yii", "::", "$", "app", "->", "urlManager", "->", "createAbsoluteUrl", "(", "'site/index'", ")", ".", "\"\\\";\"", ")", ";", "array_unshift", "(", "$", "arrJsPosHEad", ",", "\"var baseUrl = \\\"\"", ".", "Yii", "::", "$", "app", "->", "urlManager", "->", "baseUrl", ".", "\"\\\";\"", ")", ";", "$", "this", "->", "js", "[", "static", "::", "POS_HEAD", "]", "=", "$", "arrJsPosHEad", ";", "}" ]
Put javascript for base url to head
[ "Put", "javascript", "for", "base", "url", "to", "head" ]
train
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/web/NpView.php#L70-L78
npbtrac/yii2-enpii-cms
libs/override/web/NpView.php
NpView.setBrowserTitle
public function setBrowserTitle($title, $isFrontend = true, $prefix = 'Backend') { $strResult = ($isFrontend ? $title : $prefix . ' :: ' . $title); $this->title = $strResult; }
php
public function setBrowserTitle($title, $isFrontend = true, $prefix = 'Backend') { $strResult = ($isFrontend ? $title : $prefix . ' :: ' . $title); $this->title = $strResult; }
[ "public", "function", "setBrowserTitle", "(", "$", "title", ",", "$", "isFrontend", "=", "true", ",", "$", "prefix", "=", "'Backend'", ")", "{", "$", "strResult", "=", "(", "$", "isFrontend", "?", "$", "title", ":", "$", "prefix", ".", "' :: '", ".", "$", "title", ")", ";", "$", "this", "->", "title", "=", "$", "strResult", ";", "}" ]
Set title for browser with prefix @param $title @param bool $isFrontend @param string $prefix
[ "Set", "title", "for", "browser", "with", "prefix" ]
train
https://github.com/npbtrac/yii2-enpii-cms/blob/3495e697509a57a573983f552629ff9f707a63b9/libs/override/web/NpView.php#L86-L90
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/EnvironmentHelper.php
EnvironmentHelper.getVar
public static function getVar(string $name, $defaultValue = null) { $value = getenv($name); return $value !== false ? $value : $defaultValue; }
php
public static function getVar(string $name, $defaultValue = null) { $value = getenv($name); return $value !== false ? $value : $defaultValue; }
[ "public", "static", "function", "getVar", "(", "string", "$", "name", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "value", "=", "getenv", "(", "$", "name", ")", ";", "return", "$", "value", "!==", "false", "?", "$", "value", ":", "$", "defaultValue", ";", "}" ]
Returns value of environment variable or default value @param string $name @param null $defaultValue @return mixed value from env or defaultValue
[ "Returns", "value", "of", "environment", "variable", "or", "default", "value" ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L14-L18
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/EnvironmentHelper.php
EnvironmentHelper.getRequiredVar
public static function getRequiredVar(string $name) { $value = getenv($name); if ($value === false) { throw EnvVarNotFoundException::create($name); } return $value; }
php
public static function getRequiredVar(string $name) { $value = getenv($name); if ($value === false) { throw EnvVarNotFoundException::create($name); } return $value; }
[ "public", "static", "function", "getRequiredVar", "(", "string", "$", "name", ")", "{", "$", "value", "=", "getenv", "(", "$", "name", ")", ";", "if", "(", "$", "value", "===", "false", ")", "{", "throw", "EnvVarNotFoundException", "::", "create", "(", "$", "name", ")", ";", "}", "return", "$", "value", ";", "}" ]
Returns value of environment variable or throws Exception when is not defined @param string $name @return mixed value from env @throws EnvVarNotFoundException
[ "Returns", "value", "of", "environment", "variable", "or", "throws", "Exception", "when", "is", "not", "defined" ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L26-L33
SAREhub/PHP_Commons
src/SAREhub/Commons/Misc/EnvironmentHelper.php
EnvironmentHelper.getVars
public static function getVars(array $schema, string $prefix = ""): array { $env = []; foreach ($schema as $name => $default) { $env[$name] = self::getVar($prefix . $name, $default); } return $env; }
php
public static function getVars(array $schema, string $prefix = ""): array { $env = []; foreach ($schema as $name => $default) { $env[$name] = self::getVar($prefix . $name, $default); } return $env; }
[ "public", "static", "function", "getVars", "(", "array", "$", "schema", ",", "string", "$", "prefix", "=", "\"\"", ")", ":", "array", "{", "$", "env", "=", "[", "]", ";", "foreach", "(", "$", "schema", "as", "$", "name", "=>", "$", "default", ")", "{", "$", "env", "[", "$", "name", "]", "=", "self", "::", "getVar", "(", "$", "prefix", ".", "$", "name", ",", "$", "default", ")", ";", "}", "return", "$", "env", ";", "}" ]
Returns values of environment variables defined in schema parameter @param array $schema Format: ["variableName" => defaultValue] @param string $prefix Its added to variableName when getting value from env @return array ["variableName" => valueFromEnv|defaultValue]
[ "Returns", "values", "of", "environment", "variables", "defined", "in", "schema", "parameter" ]
train
https://github.com/SAREhub/PHP_Commons/blob/4e1769ab6411a584112df1151dcc90e6b82fe2bb/src/SAREhub/Commons/Misc/EnvironmentHelper.php#L41-L48
iocaste/microservice-foundation
src/Data/Models/Uuidable.php
Uuidable.bootUuidable
protected static function bootUuidable() { /** * Attach to the 'creating' Model Event to provide a UUID * for the `id` field (provided by $model->getKeyName()). */ static::creating(function ($model) { $key = $model->uuidKeyName ?? 'uuid'; if (empty($model->$key)) { $model->$key = (string) $model->generateNewUuid(); } }); static::created(function ($model) { if ($model->positionable) { $model->weight = $model->id * 1000; $model->save(); } }); }
php
protected static function bootUuidable() { /** * Attach to the 'creating' Model Event to provide a UUID * for the `id` field (provided by $model->getKeyName()). */ static::creating(function ($model) { $key = $model->uuidKeyName ?? 'uuid'; if (empty($model->$key)) { $model->$key = (string) $model->generateNewUuid(); } }); static::created(function ($model) { if ($model->positionable) { $model->weight = $model->id * 1000; $model->save(); } }); }
[ "protected", "static", "function", "bootUuidable", "(", ")", "{", "/**\n * Attach to the 'creating' Model Event to provide a UUID\n * for the `id` field (provided by $model->getKeyName()).\n */", "static", "::", "creating", "(", "function", "(", "$", "model", ")", "{", "$", "key", "=", "$", "model", "->", "uuidKeyName", "??", "'uuid'", ";", "if", "(", "empty", "(", "$", "model", "->", "$", "key", ")", ")", "{", "$", "model", "->", "$", "key", "=", "(", "string", ")", "$", "model", "->", "generateNewUuid", "(", ")", ";", "}", "}", ")", ";", "static", "::", "created", "(", "function", "(", "$", "model", ")", "{", "if", "(", "$", "model", "->", "positionable", ")", "{", "$", "model", "->", "weight", "=", "$", "model", "->", "id", "*", "1000", ";", "$", "model", "->", "save", "(", ")", ";", "}", "}", ")", ";", "}" ]
The "booting" method of the model. @return void
[ "The", "booting", "method", "of", "the", "model", "." ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Data/Models/Uuidable.php#L17-L36
iocaste/microservice-foundation
src/Data/Models/Uuidable.php
Uuidable.generateNewUuid
public function generateNewUuid(): string { $uuid = (string) Uuid::generate(4); return $this->uuidPrefix . str_replace('-', '', $uuid); }
php
public function generateNewUuid(): string { $uuid = (string) Uuid::generate(4); return $this->uuidPrefix . str_replace('-', '', $uuid); }
[ "public", "function", "generateNewUuid", "(", ")", ":", "string", "{", "$", "uuid", "=", "(", "string", ")", "Uuid", "::", "generate", "(", "4", ")", ";", "return", "$", "this", "->", "uuidPrefix", ".", "str_replace", "(", "'-'", ",", "''", ",", "$", "uuid", ")", ";", "}" ]
Get a new version 4 ( random ) UUID. @throws \Exception @return string
[ "Get", "a", "new", "version", "4", "(", "random", ")", "UUID", "." ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Data/Models/Uuidable.php#L44-L49
steeffeen/FancyManiaLinks
FML/Controls/Control.php
Control.setPosition
public function setPosition($posX, $posY, $posZ = null) { $this->setX($posX) ->setY($posY); if ($posZ !== null) { $this->setZ($posZ); } return $this; }
php
public function setPosition($posX, $posY, $posZ = null) { $this->setX($posX) ->setY($posY); if ($posZ !== null) { $this->setZ($posZ); } return $this; }
[ "public", "function", "setPosition", "(", "$", "posX", ",", "$", "posY", ",", "$", "posZ", "=", "null", ")", "{", "$", "this", "->", "setX", "(", "$", "posX", ")", "->", "setY", "(", "$", "posY", ")", ";", "if", "(", "$", "posZ", "!==", "null", ")", "{", "$", "this", "->", "setZ", "(", "$", "posZ", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the Control position @api @param float $posX Horizontal position @param float $posY Vertical position @param float $posZ (optional) Depth @return static
[ "Set", "the", "Control", "position" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L253-L261
steeffeen/FancyManiaLinks
FML/Controls/Control.php
Control.getDataAttribute
public function getDataAttribute($name) { if (isset($this->dataAttributes[$name])) { return $this->dataAttributes[$name]; } return null; }
php
public function getDataAttribute($name) { if (isset($this->dataAttributes[$name])) { return $this->dataAttributes[$name]; } return null; }
[ "public", "function", "getDataAttribute", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dataAttributes", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "dataAttributes", "[", "$", "name", "]", ";", "}", "return", "null", ";", "}" ]
Get data attribute @api @param string $name Name @return mixed
[ "Get", "data", "attribute" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L663-L669
steeffeen/FancyManiaLinks
FML/Controls/Control.php
Control.addDataAttributes
public function addDataAttributes(array $dataAttributes) { foreach ($dataAttributes as $name => $value) { $this->addDataAttribute($name, $value); } return $this; }
php
public function addDataAttributes(array $dataAttributes) { foreach ($dataAttributes as $name => $value) { $this->addDataAttribute($name, $value); } return $this; }
[ "public", "function", "addDataAttributes", "(", "array", "$", "dataAttributes", ")", "{", "foreach", "(", "$", "dataAttributes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "addDataAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add multiple data attributes @api @param mixed[] $dataAttributes Data attributes @return static
[ "Add", "multiple", "data", "attributes" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L703-L709
steeffeen/FancyManiaLinks
FML/Controls/Control.php
Control.addScriptFeature
public function addScriptFeature(ScriptFeature $scriptFeature) { if (!in_array($scriptFeature, $this->scriptFeatures, true)) { array_push($this->scriptFeatures, $scriptFeature); } return $this; }
php
public function addScriptFeature(ScriptFeature $scriptFeature) { if (!in_array($scriptFeature, $this->scriptFeatures, true)) { array_push($this->scriptFeatures, $scriptFeature); } return $this; }
[ "public", "function", "addScriptFeature", "(", "ScriptFeature", "$", "scriptFeature", ")", "{", "if", "(", "!", "in_array", "(", "$", "scriptFeature", ",", "$", "this", "->", "scriptFeatures", ",", "true", ")", ")", "{", "array_push", "(", "$", "this", "->", "scriptFeatures", ",", "$", "scriptFeature", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a new Script Feature @api @param ScriptFeature $scriptFeature Script Feature @return static
[ "Add", "a", "new", "Script", "Feature" ]
train
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Controls/Control.php#L764-L770