repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
ray-di/Ray.WebFormModule
src/AuraInputInterceptor.php
AuraInputInterceptor.invoke
public function invoke(MethodInvocation $invocation) { $object = $invocation->getThis(); /* @var $formValidation FormValidation */ $method = $invocation->getMethod(); $formValidation = $this->reader->getMethodAnnotation($method, AbstractValidation::class); $form = $this->getFormProperty($formValidation, $object); $data = $form instanceof SubmitInterface ? $form->submit() : $this->getNamedArguments($invocation); $isValid = $this->isValid($data, $form); if ($isValid === true) { // validation success return $invocation->proceed(); } return $this->failureHandler->handle($formValidation, $invocation, $form); }
php
public function invoke(MethodInvocation $invocation) { $object = $invocation->getThis(); /* @var $formValidation FormValidation */ $method = $invocation->getMethod(); $formValidation = $this->reader->getMethodAnnotation($method, AbstractValidation::class); $form = $this->getFormProperty($formValidation, $object); $data = $form instanceof SubmitInterface ? $form->submit() : $this->getNamedArguments($invocation); $isValid = $this->isValid($data, $form); if ($isValid === true) { // validation success return $invocation->proceed(); } return $this->failureHandler->handle($formValidation, $invocation, $form); }
[ "public", "function", "invoke", "(", "MethodInvocation", "$", "invocation", ")", "{", "$", "object", "=", "$", "invocation", "->", "getThis", "(", ")", ";", "/* @var $formValidation FormValidation */", "$", "method", "=", "$", "invocation", "->", "getMethod", "(", ")", ";", "$", "formValidation", "=", "$", "this", "->", "reader", "->", "getMethodAnnotation", "(", "$", "method", ",", "AbstractValidation", "::", "class", ")", ";", "$", "form", "=", "$", "this", "->", "getFormProperty", "(", "$", "formValidation", ",", "$", "object", ")", ";", "$", "data", "=", "$", "form", "instanceof", "SubmitInterface", "?", "$", "form", "->", "submit", "(", ")", ":", "$", "this", "->", "getNamedArguments", "(", "$", "invocation", ")", ";", "$", "isValid", "=", "$", "this", "->", "isValid", "(", "$", "data", ",", "$", "form", ")", ";", "if", "(", "$", "isValid", "===", "true", ")", "{", "// validation success", "return", "$", "invocation", "->", "proceed", "(", ")", ";", "}", "return", "$", "this", "->", "failureHandler", "->", "handle", "(", "$", "formValidation", ",", "$", "invocation", ",", "$", "form", ")", ";", "}" ]
{@inheritdoc} @throws InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/AuraInputInterceptor.php#L44-L59
ray-di/Ray.WebFormModule
src/AuraInputInterceptor.php
AuraInputInterceptor.getNamedArguments
private function getNamedArguments(MethodInvocation $invocation) { $submit = []; $params = $invocation->getMethod()->getParameters(); $args = $invocation->getArguments()->getArrayCopy(); foreach ($params as $param) { $arg = array_shift($args); $submit[$param->getName()] = $arg; } // has token ? if (isset($_POST[AntiCsrf::TOKEN_KEY])) { $submit[AntiCsrf::TOKEN_KEY] = $_POST[AntiCsrf::TOKEN_KEY]; } return $submit; }
php
private function getNamedArguments(MethodInvocation $invocation) { $submit = []; $params = $invocation->getMethod()->getParameters(); $args = $invocation->getArguments()->getArrayCopy(); foreach ($params as $param) { $arg = array_shift($args); $submit[$param->getName()] = $arg; } // has token ? if (isset($_POST[AntiCsrf::TOKEN_KEY])) { $submit[AntiCsrf::TOKEN_KEY] = $_POST[AntiCsrf::TOKEN_KEY]; } return $submit; }
[ "private", "function", "getNamedArguments", "(", "MethodInvocation", "$", "invocation", ")", "{", "$", "submit", "=", "[", "]", ";", "$", "params", "=", "$", "invocation", "->", "getMethod", "(", ")", "->", "getParameters", "(", ")", ";", "$", "args", "=", "$", "invocation", "->", "getArguments", "(", ")", "->", "getArrayCopy", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "arg", "=", "array_shift", "(", "$", "args", ")", ";", "$", "submit", "[", "$", "param", "->", "getName", "(", ")", "]", "=", "$", "arg", ";", "}", "// has token ?", "if", "(", "isset", "(", "$", "_POST", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", ")", ")", "{", "$", "submit", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", "=", "$", "_POST", "[", "AntiCsrf", "::", "TOKEN_KEY", "]", ";", "}", "return", "$", "submit", ";", "}" ]
Return arguments as named arguments. @param MethodInvocation $invocation @return array
[ "Return", "arguments", "as", "named", "arguments", "." ]
train
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/AuraInputInterceptor.php#L83-L98
ray-di/Ray.WebFormModule
src/AuraInputInterceptor.php
AuraInputInterceptor.getFormProperty
private function getFormProperty(AbstractValidation $formValidation, $object) { if (! property_exists($object, $formValidation->form)) { throw new InvalidFormPropertyException($formValidation->form); } $prop = (new \ReflectionClass($object))->getProperty($formValidation->form); $prop->setAccessible(true); $form = $prop->getValue($object); if (! $form instanceof AbstractForm) { throw new InvalidFormPropertyException($formValidation->form); } return $form; }
php
private function getFormProperty(AbstractValidation $formValidation, $object) { if (! property_exists($object, $formValidation->form)) { throw new InvalidFormPropertyException($formValidation->form); } $prop = (new \ReflectionClass($object))->getProperty($formValidation->form); $prop->setAccessible(true); $form = $prop->getValue($object); if (! $form instanceof AbstractForm) { throw new InvalidFormPropertyException($formValidation->form); } return $form; }
[ "private", "function", "getFormProperty", "(", "AbstractValidation", "$", "formValidation", ",", "$", "object", ")", "{", "if", "(", "!", "property_exists", "(", "$", "object", ",", "$", "formValidation", "->", "form", ")", ")", "{", "throw", "new", "InvalidFormPropertyException", "(", "$", "formValidation", "->", "form", ")", ";", "}", "$", "prop", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ")", "->", "getProperty", "(", "$", "formValidation", "->", "form", ")", ";", "$", "prop", "->", "setAccessible", "(", "true", ")", ";", "$", "form", "=", "$", "prop", "->", "getValue", "(", "$", "object", ")", ";", "if", "(", "!", "$", "form", "instanceof", "AbstractForm", ")", "{", "throw", "new", "InvalidFormPropertyException", "(", "$", "formValidation", "->", "form", ")", ";", "}", "return", "$", "form", ";", "}" ]
Return form property @param AbstractValidation $formValidation @param object $object @return mixed
[ "Return", "form", "property" ]
train
https://github.com/ray-di/Ray.WebFormModule/blob/4b6d33adb4a5c285278a068f3e7a5afdc4e680d9/src/AuraInputInterceptor.php#L108-L121
DevGroup-ru/yii2-intent-analytics
src/models/Visitor.php
Visitor.hasUserId
public function hasUserId() { if (Yii::$app->user->isGuest) { return $this->user_id !== 0; } return $this->user_id == Yii::$app->user->identity->getId(); }
php
public function hasUserId() { if (Yii::$app->user->isGuest) { return $this->user_id !== 0; } return $this->user_id == Yii::$app->user->identity->getId(); }
[ "public", "function", "hasUserId", "(", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "user", "->", "isGuest", ")", "{", "return", "$", "this", "->", "user_id", "!==", "0", ";", "}", "return", "$", "this", "->", "user_id", "==", "Yii", "::", "$", "app", "->", "user", "->", "identity", "->", "getId", "(", ")", ";", "}" ]
Detect is visitor connected with User @return bool
[ "Detect", "is", "visitor", "connected", "with", "User" ]
train
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/models/Visitor.php#L165-L171
keiosweb/moneyright
src/Math.php
Math.bcRoundHalfUp
final private static function bcRoundHalfUp($number, $precision) { return self::truncate(bcadd($number, self::getHalfUpValue($number, $precision), $precision + 1), $precision); }
php
final private static function bcRoundHalfUp($number, $precision) { return self::truncate(bcadd($number, self::getHalfUpValue($number, $precision), $precision + 1), $precision); }
[ "final", "private", "static", "function", "bcRoundHalfUp", "(", "$", "number", ",", "$", "precision", ")", "{", "return", "self", "::", "truncate", "(", "bcadd", "(", "$", "number", ",", "self", "::", "getHalfUpValue", "(", "$", "number", ",", "$", "precision", ")", ",", "$", "precision", "+", "1", ")", ",", "$", "precision", ")", ";", "}" ]
Round decimals from 5 up, less than 5 down @param $number @param $precision @return string
[ "Round", "decimals", "from", "5", "up", "less", "than", "5", "down" ]
train
https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Math.php#L216-L219
ARCANEDEV/SpamBlocker
src/SpamBlockerServiceProvider.php
SpamBlockerServiceProvider.registerSpamBlocker
private function registerSpamBlocker() { $this->singleton(Contracts\SpamBlocker::class, function ($app) { /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $app['config']; return new SpamBlocker( $config->get('spam-blocker') ); }); }
php
private function registerSpamBlocker() { $this->singleton(Contracts\SpamBlocker::class, function ($app) { /** @var \Illuminate\Contracts\Config\Repository $config */ $config = $app['config']; return new SpamBlocker( $config->get('spam-blocker') ); }); }
[ "private", "function", "registerSpamBlocker", "(", ")", "{", "$", "this", "->", "singleton", "(", "Contracts", "\\", "SpamBlocker", "::", "class", ",", "function", "(", "$", "app", ")", "{", "/** @var \\Illuminate\\Contracts\\Config\\Repository $config */", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "return", "new", "SpamBlocker", "(", "$", "config", "->", "get", "(", "'spam-blocker'", ")", ")", ";", "}", ")", ";", "}" ]
Register the spam blocker
[ "Register", "the", "spam", "blocker" ]
train
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/SpamBlockerServiceProvider.php#L72-L82
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.getType
public function getType() { if ((is_null($this->type) || empty($this->type)) && $this->needsType()) { return 'mixed'; } return $this->type; }
php
public function getType() { if ((is_null($this->type) || empty($this->type)) && $this->needsType()) { return 'mixed'; } return $this->type; }
[ "public", "function", "getType", "(", ")", "{", "if", "(", "(", "is_null", "(", "$", "this", "->", "type", ")", "||", "empty", "(", "$", "this", "->", "type", ")", ")", "&&", "$", "this", "->", "needsType", "(", ")", ")", "{", "return", "'mixed'", ";", "}", "return", "$", "this", "->", "type", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L99-L106
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.toString
public function toString() { $name = $this->getName(); $variable = $this->getVariable(); $type = $this->getType(); $description = $this->getDescription(); $string = '@' . $name . ((!is_null($type) && !empty($type)) ? ' ' . $type : '') . ((!is_null($variable) && !empty($variable)) ? ' $' . $variable : '') . ((!is_null($description) && !empty($description)) ? ' ' . $description : ''); $string = trim($string); if ($this->isInline()) { return '{' . $string . '}' . PHP_EOL; } return $string . PHP_EOL; }
php
public function toString() { $name = $this->getName(); $variable = $this->getVariable(); $type = $this->getType(); $description = $this->getDescription(); $string = '@' . $name . ((!is_null($type) && !empty($type)) ? ' ' . $type : '') . ((!is_null($variable) && !empty($variable)) ? ' $' . $variable : '') . ((!is_null($description) && !empty($description)) ? ' ' . $description : ''); $string = trim($string); if ($this->isInline()) { return '{' . $string . '}' . PHP_EOL; } return $string . PHP_EOL; }
[ "public", "function", "toString", "(", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "$", "variable", "=", "$", "this", "->", "getVariable", "(", ")", ";", "$", "type", "=", "$", "this", "->", "getType", "(", ")", ";", "$", "description", "=", "$", "this", "->", "getDescription", "(", ")", ";", "$", "string", "=", "'@'", ".", "$", "name", ".", "(", "(", "!", "is_null", "(", "$", "type", ")", "&&", "!", "empty", "(", "$", "type", ")", ")", "?", "' '", ".", "$", "type", ":", "''", ")", ".", "(", "(", "!", "is_null", "(", "$", "variable", ")", "&&", "!", "empty", "(", "$", "variable", ")", ")", "?", "' $'", ".", "$", "variable", ":", "''", ")", ".", "(", "(", "!", "is_null", "(", "$", "description", ")", "&&", "!", "empty", "(", "$", "description", ")", ")", "?", "' '", ".", "$", "description", ":", "''", ")", ";", "$", "string", "=", "trim", "(", "$", "string", ")", ";", "if", "(", "$", "this", "->", "isInline", "(", ")", ")", "{", "return", "'{'", ".", "$", "string", ".", "'}'", ".", "PHP_EOL", ";", "}", "return", "$", "string", ".", "PHP_EOL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L202-L220
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.createFromArgument
public static function createFromArgument(ArgumentInterface $argument) { $tag = new self(); $tag ->setName(self::TAG_PARAM) ->setType($argument->getType()) ->setVariable($argument->getName()) ->setDescription($argument->getDescription()) ->setReferenced($argument); return $tag; }
php
public static function createFromArgument(ArgumentInterface $argument) { $tag = new self(); $tag ->setName(self::TAG_PARAM) ->setType($argument->getType()) ->setVariable($argument->getName()) ->setDescription($argument->getDescription()) ->setReferenced($argument); return $tag; }
[ "public", "static", "function", "createFromArgument", "(", "ArgumentInterface", "$", "argument", ")", "{", "$", "tag", "=", "new", "self", "(", ")", ";", "$", "tag", "->", "setName", "(", "self", "::", "TAG_PARAM", ")", "->", "setType", "(", "$", "argument", "->", "getType", "(", ")", ")", "->", "setVariable", "(", "$", "argument", "->", "getName", "(", ")", ")", "->", "setDescription", "(", "$", "argument", "->", "getDescription", "(", ")", ")", "->", "setReferenced", "(", "$", "argument", ")", ";", "return", "$", "tag", ";", "}" ]
Creating a Tag from an Argument Object. @param ArgumentInterface $argument @return TagInterface
[ "Creating", "a", "Tag", "from", "an", "Argument", "Object", "." ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L229-L240
tonicospinelli/class-generation
src/ClassGeneration/DocBlock/Tag.php
Tag.createFromProperty
public static function createFromProperty(PropertyInterface $property) { $tag = new self(); $tag->setName(self::TAG_VAR); $tag->setType($property->getType()); return $tag; }
php
public static function createFromProperty(PropertyInterface $property) { $tag = new self(); $tag->setName(self::TAG_VAR); $tag->setType($property->getType()); return $tag; }
[ "public", "static", "function", "createFromProperty", "(", "PropertyInterface", "$", "property", ")", "{", "$", "tag", "=", "new", "self", "(", ")", ";", "$", "tag", "->", "setName", "(", "self", "::", "TAG_VAR", ")", ";", "$", "tag", "->", "setType", "(", "$", "property", "->", "getType", "(", ")", ")", ";", "return", "$", "tag", ";", "}" ]
Create var tag from property. @param PropertyInterface $property @return Tag
[ "Create", "var", "tag", "from", "property", "." ]
train
https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/DocBlock/Tag.php#L249-L256
FrenchFrogs/framework
src/Core/Configurator.php
Configurator.build
public function build($index, $default = null, $params = []) { $class = $this->get($index, $default); if (!class_exists($class)) { throw new \Exception('Class doesn\'t exist for the index : ' .$index); } $class = new \ReflectionClass($class); return $class->newInstanceArgs($params); }
php
public function build($index, $default = null, $params = []) { $class = $this->get($index, $default); if (!class_exists($class)) { throw new \Exception('Class doesn\'t exist for the index : ' .$index); } $class = new \ReflectionClass($class); return $class->newInstanceArgs($params); }
[ "public", "function", "build", "(", "$", "index", ",", "$", "default", "=", "null", ",", "$", "params", "=", "[", "]", ")", "{", "$", "class", "=", "$", "this", "->", "get", "(", "$", "index", ",", "$", "default", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Class doesn\\'t exist for the index : '", ".", "$", "index", ")", ";", "}", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "return", "$", "class", "->", "newInstanceArgs", "(", "$", "params", ")", ";", "}" ]
Return an instantiated object @param $index @param null $default @param array $params @return object @throws \Exception
[ "Return", "an", "instantiated", "object" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/Configurator.php#L134-L143
jenky/laravel-api-helper
src/Factory.php
Factory.parseBuilder
protected function parseBuilder($builder) { if ($builder instanceof EloquentBuilder) { return $this->createHandler($builder->getQuery(), $builder); } if (is_subclass_of($builder, Model::class)) { return $this->createHandler($builder->getQuery(), $builder->newQuery()); } if ($builder instanceof QueryBuilder) { return $this->createHandler($builder, $builder); } }
php
protected function parseBuilder($builder) { if ($builder instanceof EloquentBuilder) { return $this->createHandler($builder->getQuery(), $builder); } if (is_subclass_of($builder, Model::class)) { return $this->createHandler($builder->getQuery(), $builder->newQuery()); } if ($builder instanceof QueryBuilder) { return $this->createHandler($builder, $builder); } }
[ "protected", "function", "parseBuilder", "(", "$", "builder", ")", "{", "if", "(", "$", "builder", "instanceof", "EloquentBuilder", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", "->", "getQuery", "(", ")", ",", "$", "builder", ")", ";", "}", "if", "(", "is_subclass_of", "(", "$", "builder", ",", "Model", "::", "class", ")", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", "->", "getQuery", "(", ")", ",", "$", "builder", "->", "newQuery", "(", ")", ")", ";", "}", "if", "(", "$", "builder", "instanceof", "QueryBuilder", ")", "{", "return", "$", "this", "->", "createHandler", "(", "$", "builder", ",", "$", "builder", ")", ";", "}", "}" ]
Parse the builder. @param mixed $builder
[ "Parse", "the", "builder", "." ]
train
https://github.com/jenky/laravel-api-helper/blob/9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367/src/Factory.php#L47-L58
jenky/laravel-api-helper
src/Factory.php
Factory.createHandler
protected function createHandler($query, $builder = null) { $handler = new Handler($this->request, $this->config); $handler->setQuery($query); if (! is_null($builder)) { $handler->setBuilder($builder); } return $handler; }
php
protected function createHandler($query, $builder = null) { $handler = new Handler($this->request, $this->config); $handler->setQuery($query); if (! is_null($builder)) { $handler->setBuilder($builder); } return $handler; }
[ "protected", "function", "createHandler", "(", "$", "query", ",", "$", "builder", "=", "null", ")", "{", "$", "handler", "=", "new", "Handler", "(", "$", "this", "->", "request", ",", "$", "this", "->", "config", ")", ";", "$", "handler", "->", "setQuery", "(", "$", "query", ")", ";", "if", "(", "!", "is_null", "(", "$", "builder", ")", ")", "{", "$", "handler", "->", "setBuilder", "(", "$", "builder", ")", ";", "}", "return", "$", "handler", ";", "}" ]
Create the handler. @param mixed $query @param mixed $builder @return \Jenky\LaravelApiHelper\Handler
[ "Create", "the", "handler", "." ]
train
https://github.com/jenky/laravel-api-helper/blob/9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367/src/Factory.php#L68-L79
heyday/heystack
src/Input/Handler.php
Handler.process
public function process($identifier, \SS_HTTPRequest $request) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($request); } else { return false; } }
php
public function process($identifier, \SS_HTTPRequest $request) { if ($this->hasProcessor($identifier)) { return $this->processors[$identifier]->process($request); } else { return false; } }
[ "public", "function", "process", "(", "$", "identifier", ",", "\\", "SS_HTTPRequest", "$", "request", ")", "{", "if", "(", "$", "this", "->", "hasProcessor", "(", "$", "identifier", ")", ")", "{", "return", "$", "this", "->", "processors", "[", "$", "identifier", "]", "->", "process", "(", "$", "request", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Process an input processor by identifier if it exists @param string $identifier The identifier of the input processor @param \SS_HTTPRequest $request The request object to process from @return mixed
[ "Process", "an", "input", "processor", "by", "identifier", "if", "it", "exists" ]
train
https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/Input/Handler.php#L41-L48
polidog/esa-php
src/Api.php
Api.comments
public function comments($number = null, array $params = []) { if (empty($number)) { return $this->client->request('GET', $this->getCurrentTeamUrl('comments'), [ 'query' => $params, ]); } return $this->client->request('GET', $this->getCurrentTeamUrl("posts/{$number}/comments"), [ 'query' => $params, ]); }
php
public function comments($number = null, array $params = []) { if (empty($number)) { return $this->client->request('GET', $this->getCurrentTeamUrl('comments'), [ 'query' => $params, ]); } return $this->client->request('GET', $this->getCurrentTeamUrl("posts/{$number}/comments"), [ 'query' => $params, ]); }
[ "public", "function", "comments", "(", "$", "number", "=", "null", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "number", ")", ")", "{", "return", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "this", "->", "getCurrentTeamUrl", "(", "'comments'", ")", ",", "[", "'query'", "=>", "$", "params", ",", "]", ")", ";", "}", "return", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "this", "->", "getCurrentTeamUrl", "(", "\"posts/{$number}/comments\"", ")", ",", "[", "'query'", "=>", "$", "params", ",", "]", ")", ";", "}" ]
@param int $number @param array $params @return array
[ "@param", "int", "$number", "@param", "array", "$params" ]
train
https://github.com/polidog/esa-php/blob/c5badbd027d73eebcd3cd388487b7c793323bb14/src/Api.php#L146-L157
polidog/esa-php
src/Api.php
Api.factory
public static function factory($accessToken, $currentTeam) { $client = Client::factory($accessToken); return new self($client, $currentTeam); }
php
public static function factory($accessToken, $currentTeam) { $client = Client::factory($accessToken); return new self($client, $currentTeam); }
[ "public", "static", "function", "factory", "(", "$", "accessToken", ",", "$", "currentTeam", ")", "{", "$", "client", "=", "Client", "::", "factory", "(", "$", "accessToken", ")", ";", "return", "new", "self", "(", "$", "client", ",", "$", "currentTeam", ")", ";", "}" ]
@param $accessToken @param $currentTeam @return Api
[ "@param", "$accessToken", "@param", "$currentTeam" ]
train
https://github.com/polidog/esa-php/blob/c5badbd027d73eebcd3cd388487b7c793323bb14/src/Api.php#L459-L464
ARCANEDEV/SpamBlocker
src/Http/Middleware/BlockReferralSpam.php
BlockReferralSpam.handle
public function handle(Request $request, Closure $next) { $referer = $request->headers->get('referer'); return $this->blocker->isBlocked($referer) ? $this->getBlockedResponse() : $next($request); }
php
public function handle(Request $request, Closure $next) { $referer = $request->headers->get('referer'); return $this->blocker->isBlocked($referer) ? $this->getBlockedResponse() : $next($request); }
[ "public", "function", "handle", "(", "Request", "$", "request", ",", "Closure", "$", "next", ")", "{", "$", "referer", "=", "$", "request", "->", "headers", "->", "get", "(", "'referer'", ")", ";", "return", "$", "this", "->", "blocker", "->", "isBlocked", "(", "$", "referer", ")", "?", "$", "this", "->", "getBlockedResponse", "(", ")", ":", "$", "next", "(", "$", "request", ")", ";", "}" ]
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/ARCANEDEV/SpamBlocker/blob/708c9d5363616e0b257451256c4ca9fb9a9ff55f/src/Http/Middleware/BlockReferralSpam.php#L51-L58
jelix/version
lib/Parser.php
Parser.parse
public static function parse($version, $options = array()) { $options = array_merge(array( 'removeWildcard' => true ), $options); // extract meta data $vers = explode('+', $version, 2); $metadata = ''; if (count($vers) > 1) { $metadata = $vers[1]; } $version = $vers[0]; // extract secondary version $allVersions = preg_split('/(-|:)([0-9]+|\*)($|\.|-)/', $version, 2, PREG_SPLIT_DELIM_CAPTURE); $version = $allVersions[0]; if (count($allVersions) > 1 && $allVersions[1] != '') { if ($allVersions[2] == '*' && $options['removeWildcard']) { $secondaryVersion = null; $secondaryVersionSeparator = '-'; } else { $secondaryVersion = self::parse($allVersions[2].$allVersions[3].$allVersions[4], $options); $secondaryVersionSeparator = $allVersions[1]; } } else { $secondaryVersion = null; $secondaryVersionSeparator = '-'; } // extract stability part $vers = explode('-', $version, 2); $stabilityVersion = array(); if (count($vers) > 1) { $stabilityVersion = explode('.', $vers[1]); } // extract version parts $vers = explode('.', $vers[0]); foreach ($vers as $k => $number) { if (!is_numeric($number)) { if (preg_match('/^([0-9]+)(.*)$/', $number, $m)) { $vers[$k] = $m[1]; $stabilityVersion = array_merge( array($m[2]), array_slice($vers, $k + 1), $stabilityVersion ); $vers = array_slice($vers, 0, $k + 1); break; } elseif ($number == '*') { $vers = array_slice($vers, 0, $k); if (!$options['removeWildcard']) { $vers[$k] = '*'; } break; } else { throw new \Exception('Bad version syntax'); } } else { $vers[$k] = intval($number); } } $stab = array(); foreach ($stabilityVersion as $k => $part) { if (preg_match('/^[a-z]+$/', $part)) { $stab[] = self::normalizeStability($part); } elseif (preg_match('/^[0-9]+$/', $part)) { $stab[] = $part; } else { $m = preg_split('/([0-9]+)/', $part, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); foreach ($m as $p) { $stab[] = self::normalizeStability($p); } } } if (count($stab) == 0 && $secondaryVersion && !$options['removeWildcard']) { if ($secondaryVersion->getMajor() == '*' && $secondaryVersionSeparator == '-') { $secondaryVersion = null; $stab = array('*'); } } return new Version($vers, $stab, $metadata, $secondaryVersion, $secondaryVersionSeparator); }
php
public static function parse($version, $options = array()) { $options = array_merge(array( 'removeWildcard' => true ), $options); // extract meta data $vers = explode('+', $version, 2); $metadata = ''; if (count($vers) > 1) { $metadata = $vers[1]; } $version = $vers[0]; // extract secondary version $allVersions = preg_split('/(-|:)([0-9]+|\*)($|\.|-)/', $version, 2, PREG_SPLIT_DELIM_CAPTURE); $version = $allVersions[0]; if (count($allVersions) > 1 && $allVersions[1] != '') { if ($allVersions[2] == '*' && $options['removeWildcard']) { $secondaryVersion = null; $secondaryVersionSeparator = '-'; } else { $secondaryVersion = self::parse($allVersions[2].$allVersions[3].$allVersions[4], $options); $secondaryVersionSeparator = $allVersions[1]; } } else { $secondaryVersion = null; $secondaryVersionSeparator = '-'; } // extract stability part $vers = explode('-', $version, 2); $stabilityVersion = array(); if (count($vers) > 1) { $stabilityVersion = explode('.', $vers[1]); } // extract version parts $vers = explode('.', $vers[0]); foreach ($vers as $k => $number) { if (!is_numeric($number)) { if (preg_match('/^([0-9]+)(.*)$/', $number, $m)) { $vers[$k] = $m[1]; $stabilityVersion = array_merge( array($m[2]), array_slice($vers, $k + 1), $stabilityVersion ); $vers = array_slice($vers, 0, $k + 1); break; } elseif ($number == '*') { $vers = array_slice($vers, 0, $k); if (!$options['removeWildcard']) { $vers[$k] = '*'; } break; } else { throw new \Exception('Bad version syntax'); } } else { $vers[$k] = intval($number); } } $stab = array(); foreach ($stabilityVersion as $k => $part) { if (preg_match('/^[a-z]+$/', $part)) { $stab[] = self::normalizeStability($part); } elseif (preg_match('/^[0-9]+$/', $part)) { $stab[] = $part; } else { $m = preg_split('/([0-9]+)/', $part, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); foreach ($m as $p) { $stab[] = self::normalizeStability($p); } } } if (count($stab) == 0 && $secondaryVersion && !$options['removeWildcard']) { if ($secondaryVersion->getMajor() == '*' && $secondaryVersionSeparator == '-') { $secondaryVersion = null; $stab = array('*'); } } return new Version($vers, $stab, $metadata, $secondaryVersion, $secondaryVersionSeparator); }
[ "public", "static", "function", "parse", "(", "$", "version", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "array", "(", "'removeWildcard'", "=>", "true", ")", ",", "$", "options", ")", ";", "// extract meta data", "$", "vers", "=", "explode", "(", "'+'", ",", "$", "version", ",", "2", ")", ";", "$", "metadata", "=", "''", ";", "if", "(", "count", "(", "$", "vers", ")", ">", "1", ")", "{", "$", "metadata", "=", "$", "vers", "[", "1", "]", ";", "}", "$", "version", "=", "$", "vers", "[", "0", "]", ";", "// extract secondary version", "$", "allVersions", "=", "preg_split", "(", "'/(-|:)([0-9]+|\\*)($|\\.|-)/'", ",", "$", "version", ",", "2", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "version", "=", "$", "allVersions", "[", "0", "]", ";", "if", "(", "count", "(", "$", "allVersions", ")", ">", "1", "&&", "$", "allVersions", "[", "1", "]", "!=", "''", ")", "{", "if", "(", "$", "allVersions", "[", "2", "]", "==", "'*'", "&&", "$", "options", "[", "'removeWildcard'", "]", ")", "{", "$", "secondaryVersion", "=", "null", ";", "$", "secondaryVersionSeparator", "=", "'-'", ";", "}", "else", "{", "$", "secondaryVersion", "=", "self", "::", "parse", "(", "$", "allVersions", "[", "2", "]", ".", "$", "allVersions", "[", "3", "]", ".", "$", "allVersions", "[", "4", "]", ",", "$", "options", ")", ";", "$", "secondaryVersionSeparator", "=", "$", "allVersions", "[", "1", "]", ";", "}", "}", "else", "{", "$", "secondaryVersion", "=", "null", ";", "$", "secondaryVersionSeparator", "=", "'-'", ";", "}", "// extract stability part", "$", "vers", "=", "explode", "(", "'-'", ",", "$", "version", ",", "2", ")", ";", "$", "stabilityVersion", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "vers", ")", ">", "1", ")", "{", "$", "stabilityVersion", "=", "explode", "(", "'.'", ",", "$", "vers", "[", "1", "]", ")", ";", "}", "// extract version parts", "$", "vers", "=", "explode", "(", "'.'", ",", "$", "vers", "[", "0", "]", ")", ";", "foreach", "(", "$", "vers", "as", "$", "k", "=>", "$", "number", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "number", ")", ")", "{", "if", "(", "preg_match", "(", "'/^([0-9]+)(.*)$/'", ",", "$", "number", ",", "$", "m", ")", ")", "{", "$", "vers", "[", "$", "k", "]", "=", "$", "m", "[", "1", "]", ";", "$", "stabilityVersion", "=", "array_merge", "(", "array", "(", "$", "m", "[", "2", "]", ")", ",", "array_slice", "(", "$", "vers", ",", "$", "k", "+", "1", ")", ",", "$", "stabilityVersion", ")", ";", "$", "vers", "=", "array_slice", "(", "$", "vers", ",", "0", ",", "$", "k", "+", "1", ")", ";", "break", ";", "}", "elseif", "(", "$", "number", "==", "'*'", ")", "{", "$", "vers", "=", "array_slice", "(", "$", "vers", ",", "0", ",", "$", "k", ")", ";", "if", "(", "!", "$", "options", "[", "'removeWildcard'", "]", ")", "{", "$", "vers", "[", "$", "k", "]", "=", "'*'", ";", "}", "break", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Bad version syntax'", ")", ";", "}", "}", "else", "{", "$", "vers", "[", "$", "k", "]", "=", "intval", "(", "$", "number", ")", ";", "}", "}", "$", "stab", "=", "array", "(", ")", ";", "foreach", "(", "$", "stabilityVersion", "as", "$", "k", "=>", "$", "part", ")", "{", "if", "(", "preg_match", "(", "'/^[a-z]+$/'", ",", "$", "part", ")", ")", "{", "$", "stab", "[", "]", "=", "self", "::", "normalizeStability", "(", "$", "part", ")", ";", "}", "elseif", "(", "preg_match", "(", "'/^[0-9]+$/'", ",", "$", "part", ")", ")", "{", "$", "stab", "[", "]", "=", "$", "part", ";", "}", "else", "{", "$", "m", "=", "preg_split", "(", "'/([0-9]+)/'", ",", "$", "part", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", "|", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "foreach", "(", "$", "m", "as", "$", "p", ")", "{", "$", "stab", "[", "]", "=", "self", "::", "normalizeStability", "(", "$", "p", ")", ";", "}", "}", "}", "if", "(", "count", "(", "$", "stab", ")", "==", "0", "&&", "$", "secondaryVersion", "&&", "!", "$", "options", "[", "'removeWildcard'", "]", ")", "{", "if", "(", "$", "secondaryVersion", "->", "getMajor", "(", ")", "==", "'*'", "&&", "$", "secondaryVersionSeparator", "==", "'-'", ")", "{", "$", "secondaryVersion", "=", "null", ";", "$", "stab", "=", "array", "(", "'*'", ")", ";", "}", "}", "return", "new", "Version", "(", "$", "vers", ",", "$", "stab", ",", "$", "metadata", ",", "$", "secondaryVersion", ",", "$", "secondaryVersionSeparator", ")", ";", "}" ]
Is able to parse semantic version syntax or any other version syntax. @param string $version @param array $options list of options for the parser. 'removeWildcard' => true @return Version
[ "Is", "able", "to", "parse", "semantic", "version", "syntax", "or", "any", "other", "version", "syntax", "." ]
train
https://github.com/jelix/version/blob/1bdcea2beb7943f347fb453e3106702a460d51c2/lib/Parser.php#L27-L115
dpi/ak
src/AvatarServiceFactory.php
AvatarServiceFactory.createService
public function createService(string $id, AvatarConfigurationInterface $configuration) : AvatarServiceInterface { // @todo if plugin is remote, require a destination for avatars. $metadata = $this->discovery->getMetadata($id); // Protocol. if (!empty($metadata->protocols)) { $protocols = $metadata->protocols; $protocol = $configuration->getProtocol(); if (is_string($protocol)) { if (!in_array($protocol, $protocols)) { throw new AvatarFactoryException('Invalid or undefined protocol.'); } } } // Dimensions. $width = $configuration->getWidth(); $height = $configuration->getHeight(); if ($width || $height) { if (!empty($metadata->dimensions)) { // Dimensions validator. $regex = '/^(?<minx>\d*)x(?<miny>\d*)\-(?<maxx>\d*)x(?<maxy>\d*)$/D'; $dimensions = $metadata->dimensions; preg_match_all($regex, $dimensions, $matches, PREG_SET_ORDER); $valid_x = !$width || ($width >= $matches[0]['minx'] && $width <= $matches[0]['maxx']); $valid_y = !$height || ($height >= $matches[0]['miny'] && $height <= $matches[0]['maxy']); if (!($valid_x && $valid_y)) { throw new AvatarFactoryException('Requested dimensions failed validation.'); } } } $class = $this->discovery->getClass($id); $instance = $this->newInstance($class, $configuration); return $instance; }
php
public function createService(string $id, AvatarConfigurationInterface $configuration) : AvatarServiceInterface { // @todo if plugin is remote, require a destination for avatars. $metadata = $this->discovery->getMetadata($id); // Protocol. if (!empty($metadata->protocols)) { $protocols = $metadata->protocols; $protocol = $configuration->getProtocol(); if (is_string($protocol)) { if (!in_array($protocol, $protocols)) { throw new AvatarFactoryException('Invalid or undefined protocol.'); } } } // Dimensions. $width = $configuration->getWidth(); $height = $configuration->getHeight(); if ($width || $height) { if (!empty($metadata->dimensions)) { // Dimensions validator. $regex = '/^(?<minx>\d*)x(?<miny>\d*)\-(?<maxx>\d*)x(?<maxy>\d*)$/D'; $dimensions = $metadata->dimensions; preg_match_all($regex, $dimensions, $matches, PREG_SET_ORDER); $valid_x = !$width || ($width >= $matches[0]['minx'] && $width <= $matches[0]['maxx']); $valid_y = !$height || ($height >= $matches[0]['miny'] && $height <= $matches[0]['maxy']); if (!($valid_x && $valid_y)) { throw new AvatarFactoryException('Requested dimensions failed validation.'); } } } $class = $this->discovery->getClass($id); $instance = $this->newInstance($class, $configuration); return $instance; }
[ "public", "function", "createService", "(", "string", "$", "id", ",", "AvatarConfigurationInterface", "$", "configuration", ")", ":", "AvatarServiceInterface", "{", "// @todo if plugin is remote, require a destination for avatars.", "$", "metadata", "=", "$", "this", "->", "discovery", "->", "getMetadata", "(", "$", "id", ")", ";", "// Protocol.", "if", "(", "!", "empty", "(", "$", "metadata", "->", "protocols", ")", ")", "{", "$", "protocols", "=", "$", "metadata", "->", "protocols", ";", "$", "protocol", "=", "$", "configuration", "->", "getProtocol", "(", ")", ";", "if", "(", "is_string", "(", "$", "protocol", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "protocol", ",", "$", "protocols", ")", ")", "{", "throw", "new", "AvatarFactoryException", "(", "'Invalid or undefined protocol.'", ")", ";", "}", "}", "}", "// Dimensions.", "$", "width", "=", "$", "configuration", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "configuration", "->", "getHeight", "(", ")", ";", "if", "(", "$", "width", "||", "$", "height", ")", "{", "if", "(", "!", "empty", "(", "$", "metadata", "->", "dimensions", ")", ")", "{", "// Dimensions validator.", "$", "regex", "=", "'/^(?<minx>\\d*)x(?<miny>\\d*)\\-(?<maxx>\\d*)x(?<maxy>\\d*)$/D'", ";", "$", "dimensions", "=", "$", "metadata", "->", "dimensions", ";", "preg_match_all", "(", "$", "regex", ",", "$", "dimensions", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "$", "valid_x", "=", "!", "$", "width", "||", "(", "$", "width", ">=", "$", "matches", "[", "0", "]", "[", "'minx'", "]", "&&", "$", "width", "<=", "$", "matches", "[", "0", "]", "[", "'maxx'", "]", ")", ";", "$", "valid_y", "=", "!", "$", "height", "||", "(", "$", "height", ">=", "$", "matches", "[", "0", "]", "[", "'miny'", "]", "&&", "$", "height", "<=", "$", "matches", "[", "0", "]", "[", "'maxy'", "]", ")", ";", "if", "(", "!", "(", "$", "valid_x", "&&", "$", "valid_y", ")", ")", "{", "throw", "new", "AvatarFactoryException", "(", "'Requested dimensions failed validation.'", ")", ";", "}", "}", "}", "$", "class", "=", "$", "this", "->", "discovery", "->", "getClass", "(", "$", "id", ")", ";", "$", "instance", "=", "$", "this", "->", "newInstance", "(", "$", "class", ",", "$", "configuration", ")", ";", "return", "$", "instance", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/dpi/ak/blob/cc61b172a827498cf6284191d51ce04d0f7c0f97/src/AvatarServiceFactory.php#L35-L72
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.getList
public function getList() { $sql = $this->getSql(); $select = $sql->select() ->columns(array($this->getIdentifierColumn())) ->from($this->getTableName()) ->order(array('id' => 'asc')); $statement = $sql->prepareStatementForSqlObject($select); $results = $statement->execute(); $identifiers = array(); foreach($results as $result) { $identifiers[] = $result[$this->getIdentifierColumn()]; } return $identifiers; }
php
public function getList() { $sql = $this->getSql(); $select = $sql->select() ->columns(array($this->getIdentifierColumn())) ->from($this->getTableName()) ->order(array('id' => 'asc')); $statement = $sql->prepareStatementForSqlObject($select); $results = $statement->execute(); $identifiers = array(); foreach($results as $result) { $identifiers[] = $result[$this->getIdentifierColumn()]; } return $identifiers; }
[ "public", "function", "getList", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "select", "=", "$", "sql", "->", "select", "(", ")", "->", "columns", "(", "array", "(", "$", "this", "->", "getIdentifierColumn", "(", ")", ")", ")", "->", "from", "(", "$", "this", "->", "getTableName", "(", ")", ")", "->", "order", "(", "array", "(", "'id'", "=>", "'asc'", ")", ")", ";", "$", "statement", "=", "$", "sql", "->", "prepareStatementForSqlObject", "(", "$", "select", ")", ";", "$", "results", "=", "$", "statement", "->", "execute", "(", ")", ";", "$", "identifiers", "=", "array", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "result", ")", "{", "$", "identifiers", "[", "]", "=", "$", "result", "[", "$", "this", "->", "getIdentifierColumn", "(", ")", "]", ";", "}", "return", "$", "identifiers", ";", "}" ]
Returns a list of Identifier strings Unfortunately the list() method is reserved @return string[]
[ "Returns", "a", "list", "of", "Identifier", "strings", "Unfortunately", "the", "list", "()", "method", "is", "reserved" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L141-L158
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.getTableStructure
private function getTableStructure() { return array( 'columns' => array( // Unique auto-incrementing primary key new BigInteger('id', false, null, array('auto_increment' => true, 'unsigned' => true)), // Identifier column new Varchar($this->getIdentifierColumn(), 64), // The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length new Blob($this->getDataColumn(), 0) ), 'constraints' => array( // Primary key and index constraints new PrimaryKey('id'), new UniqueKey(array($this->getIdentifierColumn()), $this->getIdentifierColumn()) ), ); }
php
private function getTableStructure() { return array( 'columns' => array( // Unique auto-incrementing primary key new BigInteger('id', false, null, array('auto_increment' => true, 'unsigned' => true)), // Identifier column new Varchar($this->getIdentifierColumn(), 64), // The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length new Blob($this->getDataColumn(), 0) ), 'constraints' => array( // Primary key and index constraints new PrimaryKey('id'), new UniqueKey(array($this->getIdentifierColumn()), $this->getIdentifierColumn()) ), ); }
[ "private", "function", "getTableStructure", "(", ")", "{", "return", "array", "(", "'columns'", "=>", "array", "(", "// Unique auto-incrementing primary key", "new", "BigInteger", "(", "'id'", ",", "false", ",", "null", ",", "array", "(", "'auto_increment'", "=>", "true", ",", "'unsigned'", "=>", "true", ")", ")", ",", "// Identifier column", "new", "Varchar", "(", "$", "this", "->", "getIdentifierColumn", "(", ")", ",", "64", ")", ",", "// The blob column creates a length specification if(length), so length 0 is a nice hack to not specify length", "new", "Blob", "(", "$", "this", "->", "getDataColumn", "(", ")", ",", "0", ")", ")", ",", "'constraints'", "=>", "array", "(", "// Primary key and index constraints", "new", "PrimaryKey", "(", "'id'", ")", ",", "new", "UniqueKey", "(", "array", "(", "$", "this", "->", "getIdentifierColumn", "(", ")", ")", ",", "$", "this", "->", "getIdentifierColumn", "(", ")", ")", ")", ",", ")", ";", "}" ]
Returns the table structure in Zend\Db\Column objects @return array
[ "Returns", "the", "table", "structure", "in", "Zend", "\\", "Db", "\\", "Column", "objects" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L227-L246
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.createTable
public function createTable() { $sql = $this->getSql(); $createTable = new CreateTable($this->getTableName()); $tableStructure = $this->getTableStructure(); foreach($tableStructure['columns'] as $column) { $createTable->addColumn($column); } foreach($tableStructure['constraints'] as $constraint) { $createTable->addConstraint($constraint); } $sql->getAdapter()->query( $sql->getSqlStringForSqlObject($createTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
php
public function createTable() { $sql = $this->getSql(); $createTable = new CreateTable($this->getTableName()); $tableStructure = $this->getTableStructure(); foreach($tableStructure['columns'] as $column) { $createTable->addColumn($column); } foreach($tableStructure['constraints'] as $constraint) { $createTable->addConstraint($constraint); } $sql->getAdapter()->query( $sql->getSqlStringForSqlObject($createTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
[ "public", "function", "createTable", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "createTable", "=", "new", "CreateTable", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "$", "tableStructure", "=", "$", "this", "->", "getTableStructure", "(", ")", ";", "foreach", "(", "$", "tableStructure", "[", "'columns'", "]", "as", "$", "column", ")", "{", "$", "createTable", "->", "addColumn", "(", "$", "column", ")", ";", "}", "foreach", "(", "$", "tableStructure", "[", "'constraints'", "]", "as", "$", "constraint", ")", "{", "$", "createTable", "->", "addConstraint", "(", "$", "constraint", ")", ";", "}", "$", "sql", "->", "getAdapter", "(", ")", "->", "query", "(", "$", "sql", "->", "getSqlStringForSqlObject", "(", "$", "createTable", ")", ",", "Adapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "return", "$", "this", ";", "}" ]
Creates the table structure for you NOTE: This code should fully work when ZendFramework 2.4.0 is released, since then DDL supports auto_increment @see https://github.com/zendframework/zf2/pull/6257 @return PersistenceHandlerInterface
[ "Creates", "the", "table", "structure", "for", "you" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L256-L277
link0/profiler
src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php
ZendDbHandler.dropTable
public function dropTable() { $sql = $this->getSql(); $dropTable = new DropTable($this->getTableName()); $sql->getAdapter()->query($sql->getSqlStringForSqlObject($dropTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
php
public function dropTable() { $sql = $this->getSql(); $dropTable = new DropTable($this->getTableName()); $sql->getAdapter()->query($sql->getSqlStringForSqlObject($dropTable), Adapter::QUERY_MODE_EXECUTE ); return $this; }
[ "public", "function", "dropTable", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getSql", "(", ")", ";", "$", "dropTable", "=", "new", "DropTable", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "$", "sql", "->", "getAdapter", "(", ")", "->", "query", "(", "$", "sql", "->", "getSqlStringForSqlObject", "(", "$", "dropTable", ")", ",", "Adapter", "::", "QUERY_MODE_EXECUTE", ")", ";", "return", "$", "this", ";", "}" ]
Drops the table structure for you @return PersistenceHandlerInterface
[ "Drops", "the", "table", "structure", "for", "you" ]
train
https://github.com/link0/profiler/blob/0573073ff029743734de747619ab65ab2476052d/src/Link0/Profiler/PersistenceHandler/ZendDbHandler.php#L284-L295
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php
SaveHandler.parseWidget
public function parseWidget($widget) { if(is_a($widget, 'Contao\FormTextArea') || is_a($widget, 'Contao\FormTextField')){ if($this->field->getEval('allowHtml')){ $value = strip_tags(\String::decodeEntities($widget->value), \Config::get('allowedTags')); }else{ $value = strip_tags(\String::decodeEntities($widget->value)); } if($this->field->getEval('decodeEntities')){ return $value; }else{ return specialchars($value); } } return $widget->value; }
php
public function parseWidget($widget) { if(is_a($widget, 'Contao\FormTextArea') || is_a($widget, 'Contao\FormTextField')){ if($this->field->getEval('allowHtml')){ $value = strip_tags(\String::decodeEntities($widget->value), \Config::get('allowedTags')); }else{ $value = strip_tags(\String::decodeEntities($widget->value)); } if($this->field->getEval('decodeEntities')){ return $value; }else{ return specialchars($value); } } return $widget->value; }
[ "public", "function", "parseWidget", "(", "$", "widget", ")", "{", "if", "(", "is_a", "(", "$", "widget", ",", "'Contao\\FormTextArea'", ")", "||", "is_a", "(", "$", "widget", ",", "'Contao\\FormTextField'", ")", ")", "{", "if", "(", "$", "this", "->", "field", "->", "getEval", "(", "'allowHtml'", ")", ")", "{", "$", "value", "=", "strip_tags", "(", "\\", "String", "::", "decodeEntities", "(", "$", "widget", "->", "value", ")", ",", "\\", "Config", "::", "get", "(", "'allowedTags'", ")", ")", ";", "}", "else", "{", "$", "value", "=", "strip_tags", "(", "\\", "String", "::", "decodeEntities", "(", "$", "widget", "->", "value", ")", ")", ";", "}", "if", "(", "$", "this", "->", "field", "->", "getEval", "(", "'decodeEntities'", ")", ")", "{", "return", "$", "value", ";", "}", "else", "{", "return", "specialchars", "(", "$", "value", ")", ";", "}", "}", "return", "$", "widget", "->", "value", ";", "}" ]
This function is for the manipulation of the attribute value Must return the value in the format what is needed for MetaModels @param $widget @return mixed
[ "This", "function", "is", "for", "the", "manipulation", "of", "the", "attribute", "value", "Must", "return", "the", "value", "in", "the", "format", "what", "is", "needed", "for", "MetaModels" ]
train
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php#L61-L80
Teamsisu/contao-mm-frontendInput
src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php
SaveHandler.setValue
public function setValue($value) { $this->item->set($this->field->getColName(), $this->field->mmAttribute->widgetToValue($value, null)); }
php
public function setValue($value) { $this->item->set($this->field->getColName(), $this->field->mmAttribute->widgetToValue($value, null)); }
[ "public", "function", "setValue", "(", "$", "value", ")", "{", "$", "this", "->", "item", "->", "set", "(", "$", "this", "->", "field", "->", "getColName", "(", ")", ",", "$", "this", "->", "field", "->", "mmAttribute", "->", "widgetToValue", "(", "$", "value", ",", "null", ")", ")", ";", "}" ]
Set the value of the Attribute from given MetaModels Item
[ "Set", "the", "value", "of", "the", "Attribute", "from", "given", "MetaModels", "Item" ]
train
https://github.com/Teamsisu/contao-mm-frontendInput/blob/ab92e61c24644f1e61265304b6a35e505007d021/src/Teamsisu/MetaModelsFrontendInput/Handler/Save/SaveHandler.php#L85-L88
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.createInstallationClient
public static function createInstallationClient($url, CertificateStorage $certificateStorage) { $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); return self::createBaseClient((string)$url, $handlerStack); }
php
public static function createInstallationClient($url, CertificateStorage $certificateStorage) { $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); return self::createBaseClient((string)$url, $handlerStack); }
[ "public", "static", "function", "createInstallationClient", "(", "$", "url", ",", "CertificateStorage", "$", "certificateStorage", ")", "{", "$", "handlerStack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestIdMiddleware", "(", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestSignatureMiddleware", "(", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "PRIVATE_KEY", "(", ")", ")", ")", ")", ")", ";", "return", "self", "::", "createBaseClient", "(", "(", "string", ")", "$", "url", ",", "$", "handlerStack", ")", ";", "}" ]
Creates an installation client @param string $url @param CertificateStorage $certificateStorage @return ClientInterface
[ "Creates", "an", "installation", "client" ]
train
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L29-L40
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.create
public static function create( $url, TokenService $tokenService, CertificateStorage $certificateStorage, InstallationService $installationService, TokenStorage $tokenStorage ) { $sessionToken = $tokenService->sessionToken(); $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY()); $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken)) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); $handlerStack->push( Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey)) ); $handlerStack->push( Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage)) ); $httpClient = self::createBaseClient($url, $handlerStack); return $httpClient; }
php
public static function create( $url, TokenService $tokenService, CertificateStorage $certificateStorage, InstallationService $installationService, TokenStorage $tokenStorage ) { $sessionToken = $tokenService->sessionToken(); $publicServerKey = $certificateStorage->load(CertificateType::BUNQ_SERVER_KEY()); $handlerStack = HandlerStack::create(); $handlerStack->push( Middleware::mapRequest(new RequestIdMiddleware()) ); $handlerStack->push( Middleware::mapRequest(new RequestAuthenticationMiddleware($sessionToken)) ); $handlerStack->push( Middleware::mapRequest(new RequestSignatureMiddleware($certificateStorage->load(CertificateType::PRIVATE_KEY()))) ); $handlerStack->push( Middleware::mapResponse(new ResponseSignatureMiddleware($publicServerKey)) ); $handlerStack->push( Middleware::mapResponse(new RefreshSessionMiddleware($installationService, $tokenStorage)) ); $httpClient = self::createBaseClient($url, $handlerStack); return $httpClient; }
[ "public", "static", "function", "create", "(", "$", "url", ",", "TokenService", "$", "tokenService", ",", "CertificateStorage", "$", "certificateStorage", ",", "InstallationService", "$", "installationService", ",", "TokenStorage", "$", "tokenStorage", ")", "{", "$", "sessionToken", "=", "$", "tokenService", "->", "sessionToken", "(", ")", ";", "$", "publicServerKey", "=", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "BUNQ_SERVER_KEY", "(", ")", ")", ";", "$", "handlerStack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestIdMiddleware", "(", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestAuthenticationMiddleware", "(", "$", "sessionToken", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapRequest", "(", "new", "RequestSignatureMiddleware", "(", "$", "certificateStorage", "->", "load", "(", "CertificateType", "::", "PRIVATE_KEY", "(", ")", ")", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapResponse", "(", "new", "ResponseSignatureMiddleware", "(", "$", "publicServerKey", ")", ")", ")", ";", "$", "handlerStack", "->", "push", "(", "Middleware", "::", "mapResponse", "(", "new", "RefreshSessionMiddleware", "(", "$", "installationService", ",", "$", "tokenStorage", ")", ")", ")", ";", "$", "httpClient", "=", "self", "::", "createBaseClient", "(", "$", "url", ",", "$", "handlerStack", ")", ";", "return", "$", "httpClient", ";", "}" ]
Creates the HttpClient with all handlers @param string $url @param TokenService $tokenService @param CertificateStorage $certificateStorage @param InstallationService $installationService @param TokenStorage $tokenStorage @return ClientInterface
[ "Creates", "the", "HttpClient", "with", "all", "handlers" ]
train
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L53-L83
verschoof/bunq-api
src/HttpClientFactory.php
HttpClientFactory.createBaseClient
private static function createBaseClient($url, HandlerStack $handlerStack = null) { $httpClient = new \GuzzleHttp\Client( [ 'base_uri' => $url, 'handler' => $handlerStack, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'bunq-api-client:user', ], ] ); return $httpClient; }
php
private static function createBaseClient($url, HandlerStack $handlerStack = null) { $httpClient = new \GuzzleHttp\Client( [ 'base_uri' => $url, 'handler' => $handlerStack, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'bunq-api-client:user', ], ] ); return $httpClient; }
[ "private", "static", "function", "createBaseClient", "(", "$", "url", ",", "HandlerStack", "$", "handlerStack", "=", "null", ")", "{", "$", "httpClient", "=", "new", "\\", "GuzzleHttp", "\\", "Client", "(", "[", "'base_uri'", "=>", "$", "url", ",", "'handler'", "=>", "$", "handlerStack", ",", "'headers'", "=>", "[", "'Content-Type'", "=>", "'application/json'", ",", "'User-Agent'", "=>", "'bunq-api-client:user'", ",", "]", ",", "]", ")", ";", "return", "$", "httpClient", ";", "}" ]
Returns the standard used headers. @param string $url @param HandlerStack|null $handlerStack @return ClientInterface
[ "Returns", "the", "standard", "used", "headers", "." ]
train
https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/HttpClientFactory.php#L93-L107
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
src/App/Resolver/DefinitionRefResolver.php
DefinitionRefResolver.getMethodDefinitionId
public function getMethodDefinitionId(MethodDoc $method, $definitionType) : string { $base = 'UNKNONWN_METHOD-%s'; switch ($definitionType) { case self::METHOD_RESULT_DEFINITION_TYPE: $base = 'Method-%s-Result'; break; case self::METHOD_PARAMS_DEFINITION_TYPE: $base = 'Method-%s-RequestParams'; break; } return sprintf($base, $method->getIdentifier()); }
php
public function getMethodDefinitionId(MethodDoc $method, $definitionType) : string { $base = 'UNKNONWN_METHOD-%s'; switch ($definitionType) { case self::METHOD_RESULT_DEFINITION_TYPE: $base = 'Method-%s-Result'; break; case self::METHOD_PARAMS_DEFINITION_TYPE: $base = 'Method-%s-RequestParams'; break; } return sprintf($base, $method->getIdentifier()); }
[ "public", "function", "getMethodDefinitionId", "(", "MethodDoc", "$", "method", ",", "$", "definitionType", ")", ":", "string", "{", "$", "base", "=", "'UNKNONWN_METHOD-%s'", ";", "switch", "(", "$", "definitionType", ")", "{", "case", "self", "::", "METHOD_RESULT_DEFINITION_TYPE", ":", "$", "base", "=", "'Method-%s-Result'", ";", "break", ";", "case", "self", "::", "METHOD_PARAMS_DEFINITION_TYPE", ":", "$", "base", "=", "'Method-%s-RequestParams'", ";", "break", ";", "}", "return", "sprintf", "(", "$", "base", ",", "$", "method", "->", "getIdentifier", "(", ")", ")", ";", "}" ]
@param MethodDoc $method @param string $definitionType @return string
[ "@param", "MethodDoc", "$method", "@param", "string", "$definitionType" ]
train
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Resolver/DefinitionRefResolver.php#L23-L36
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
src/App/Resolver/DefinitionRefResolver.php
DefinitionRefResolver.getErrorDefinitionId
public function getErrorDefinitionId(ErrorDoc $error, $definitionType) : string { $base = 'UNKNONWN_ERROR-%s'; switch ($definitionType) { case self::CUSTOM_ERROR_DEFINITION_TYPE: $base = 'Error-%s'; break; case self::SERVER_ERROR_DEFINITION_TYPE: $base = 'ServerError-%s'; break; } return sprintf($base, $error->getIdentifier()); }
php
public function getErrorDefinitionId(ErrorDoc $error, $definitionType) : string { $base = 'UNKNONWN_ERROR-%s'; switch ($definitionType) { case self::CUSTOM_ERROR_DEFINITION_TYPE: $base = 'Error-%s'; break; case self::SERVER_ERROR_DEFINITION_TYPE: $base = 'ServerError-%s'; break; } return sprintf($base, $error->getIdentifier()); }
[ "public", "function", "getErrorDefinitionId", "(", "ErrorDoc", "$", "error", ",", "$", "definitionType", ")", ":", "string", "{", "$", "base", "=", "'UNKNONWN_ERROR-%s'", ";", "switch", "(", "$", "definitionType", ")", "{", "case", "self", "::", "CUSTOM_ERROR_DEFINITION_TYPE", ":", "$", "base", "=", "'Error-%s'", ";", "break", ";", "case", "self", "::", "SERVER_ERROR_DEFINITION_TYPE", ":", "$", "base", "=", "'ServerError-%s'", ";", "break", ";", "}", "return", "sprintf", "(", "$", "base", ",", "$", "error", "->", "getIdentifier", "(", ")", ")", ";", "}" ]
@param ErrorDoc $error @param string $definitionType @return string
[ "@param", "ErrorDoc", "$error", "@param", "string", "$definitionType" ]
train
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Resolver/DefinitionRefResolver.php#L44-L57
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.findModel
protected function findModel($id) { $model = $this->module->manager->findGalleryById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $model; }
php
protected function findModel($id) { $model = $this->module->manager->findGalleryById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } return $model; }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist'", ")", ";", "}", "return", "$", "model", ";", "}" ]
Finds the Gallery model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return \wolfguard\gallery\models\Gallery the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "Gallery", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
train
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L128-L137
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionImages
public function actionImages($id) { $gallery = $this->findModel($id); $searchModel = $this->module->manager->createGalleryImageSearch(); $dataProvider = $searchModel->search($_GET, $id); return $this->render('image/index', [ 'gallery' => $gallery, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function actionImages($id) { $gallery = $this->findModel($id); $searchModel = $this->module->manager->createGalleryImageSearch(); $dataProvider = $searchModel->search($_GET, $id); return $this->render('image/index', [ 'gallery' => $gallery, 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "actionImages", "(", "$", "id", ")", "{", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "searchModel", "=", "$", "this", "->", "module", "->", "manager", "->", "createGalleryImageSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "$", "_GET", ",", "$", "id", ")", ";", "return", "$", "this", "->", "render", "(", "'image/index'", ",", "[", "'gallery'", "=>", "$", "gallery", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "'searchModel'", "=>", "$", "searchModel", ",", "]", ")", ";", "}" ]
Lists all Gallery images models. @param $id Gallery id @return mixed
[ "Lists", "all", "Gallery", "images", "models", "." ]
train
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L146-L158
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionCreateImage
public function actionCreateImage($id) { $gallery = $this->findModel($id); $model = $this->module->manager->createGalleryImage(['scenario' => 'create']); $model->loadDefaultValues(); if ($model->load(\Yii::$app->request->post())) { $model->gallery_id = $gallery->id; if($model->create()) { \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been created')); return $this->redirect(['images', 'id' => $id]); } } return $this->render('image/create', [ 'gallery' => $gallery, 'model' => $model ]); }
php
public function actionCreateImage($id) { $gallery = $this->findModel($id); $model = $this->module->manager->createGalleryImage(['scenario' => 'create']); $model->loadDefaultValues(); if ($model->load(\Yii::$app->request->post())) { $model->gallery_id = $gallery->id; if($model->create()) { \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been created')); return $this->redirect(['images', 'id' => $id]); } } return $this->render('image/create', [ 'gallery' => $gallery, 'model' => $model ]); }
[ "public", "function", "actionCreateImage", "(", "$", "id", ")", "{", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "createGalleryImage", "(", "[", "'scenario'", "=>", "'create'", "]", ")", ";", "$", "model", "->", "loadDefaultValues", "(", ")", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ")", "{", "$", "model", "->", "gallery_id", "=", "$", "gallery", "->", "id", ";", "if", "(", "$", "model", "->", "create", "(", ")", ")", "{", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been created'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'images'", ",", "'id'", "=>", "$", "id", "]", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'image/create'", ",", "[", "'gallery'", "=>", "$", "gallery", ",", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
Create gallery image @param $id Gallery id @return string @throws NotFoundHttpException
[ "Create", "gallery", "image" ]
train
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L166-L186
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionUpdateImage
public function actionUpdateImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested image does not exist'); } $model->scenario = 'update'; $gallery = $this->findModel($model->gallery_id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { if(\Yii::$app->request->get('returnUrl')){ $back = urldecode(\Yii::$app->request->get('returnUrl')); return $this->redirect($back); } \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been updated')); return $this->refresh(); } return $this->render('image/update', [ 'model' => $model, 'gallery' => $gallery ]); }
php
public function actionUpdateImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested image does not exist'); } $model->scenario = 'update'; $gallery = $this->findModel($model->gallery_id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { if(\Yii::$app->request->get('returnUrl')){ $back = urldecode(\Yii::$app->request->get('returnUrl')); return $this->redirect($back); } \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been updated')); return $this->refresh(); } return $this->render('image/update', [ 'model' => $model, 'gallery' => $gallery ]); }
[ "public", "function", "actionUpdateImage", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryImageById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested image does not exist'", ")", ";", "}", "$", "model", "->", "scenario", "=", "'update'", ";", "$", "gallery", "=", "$", "this", "->", "findModel", "(", "$", "model", "->", "gallery_id", ")", ";", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "if", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'returnUrl'", ")", ")", "{", "$", "back", "=", "urldecode", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", "'returnUrl'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "back", ")", ";", "}", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been updated'", ")", ")", ";", "return", "$", "this", "->", "refresh", "(", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'image/update'", ",", "[", "'model'", "=>", "$", "model", ",", "'gallery'", "=>", "$", "gallery", "]", ")", ";", "}" ]
Updates an existing GalleryImage model. If update is successful, the browser will be redirected to the 'images' page. @param integer $id @return mixed @throws NotFoundHttpException
[ "Updates", "an", "existing", "GalleryImage", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "images", "page", "." ]
train
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L196-L220
wolfguarder/yii2-gallery
controllers/AdminController.php
AdminController.actionDeleteImage
public function actionDeleteImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } $model->delete(); \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been deleted')); return $this->redirect(['images', 'id' => $model->gallery_id]); }
php
public function actionDeleteImage($id) { $model = $this->module->manager->findGalleryImageById($id); if ($model === null) { throw new NotFoundHttpException('The requested page does not exist'); } $model->delete(); \Yii::$app->getSession()->setFlash('gallery.success', \Yii::t('gallery', 'Image has been deleted')); return $this->redirect(['images', 'id' => $model->gallery_id]); }
[ "public", "function", "actionDeleteImage", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "module", "->", "manager", "->", "findGalleryImageById", "(", "$", "id", ")", ";", "if", "(", "$", "model", "===", "null", ")", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist'", ")", ";", "}", "$", "model", "->", "delete", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "setFlash", "(", "'gallery.success'", ",", "\\", "Yii", "::", "t", "(", "'gallery'", ",", "'Image has been deleted'", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'images'", ",", "'id'", "=>", "$", "model", "->", "gallery_id", "]", ")", ";", "}" ]
Deletes an existing GalleryImage model. If deletion is successful, the browser will be redirected to the 'images' page. @param integer $id @return \yii\web\Response @throws NotFoundHttpException @throws \Exception
[ "Deletes", "an", "existing", "GalleryImage", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "images", "page", "." ]
train
https://github.com/wolfguarder/yii2-gallery/blob/3e79f9e3764bd07322b5fed96e8d8ff1b2b3a48d/controllers/AdminController.php#L231-L243
yosmanyga/resource
src/Yosmanyga/Resource/Util/DocParser.php
DocParser.parse
public function parse($file, $annotationName = null) { $data = []; $class = $this->findClass($file); $ref = new \ReflectionClass($class); $annotations = $this->resolveAnnotations($ref->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'class' => $class, 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } foreach ($ref->getProperties() as $property) { $annotations = $this->resolveAnnotations($property->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'property' => $property->getName(), 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } } foreach ($ref->getMethods() as $method) { $annotations = $this->resolveAnnotations($method->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'method' => $method->getName(), 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } } return $data; }
php
public function parse($file, $annotationName = null) { $data = []; $class = $this->findClass($file); $ref = new \ReflectionClass($class); $annotations = $this->resolveAnnotations($ref->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'class' => $class, 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } foreach ($ref->getProperties() as $property) { $annotations = $this->resolveAnnotations($property->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'property' => $property->getName(), 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } } foreach ($ref->getMethods() as $method) { $annotations = $this->resolveAnnotations($method->getDocComment()); foreach ($annotations as $annotation) { if (!$annotationName || preg_match($annotationName, $annotation['key'])) { $data[] = [ 'method' => $method->getName(), 'key' => $annotation['key'], 'value' => (array) Yaml::parse($annotation['value']), 'metadata' => [ 'class' => $class, ], ]; } } } return $data; }
[ "public", "function", "parse", "(", "$", "file", ",", "$", "annotationName", "=", "null", ")", "{", "$", "data", "=", "[", "]", ";", "$", "class", "=", "$", "this", "->", "findClass", "(", "$", "file", ")", ";", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "annotations", "=", "$", "this", "->", "resolveAnnotations", "(", "$", "ref", "->", "getDocComment", "(", ")", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "if", "(", "!", "$", "annotationName", "||", "preg_match", "(", "$", "annotationName", ",", "$", "annotation", "[", "'key'", "]", ")", ")", "{", "$", "data", "[", "]", "=", "[", "'class'", "=>", "$", "class", ",", "'key'", "=>", "$", "annotation", "[", "'key'", "]", ",", "'value'", "=>", "(", "array", ")", "Yaml", "::", "parse", "(", "$", "annotation", "[", "'value'", "]", ")", ",", "'metadata'", "=>", "[", "'class'", "=>", "$", "class", ",", "]", ",", "]", ";", "}", "}", "foreach", "(", "$", "ref", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "annotations", "=", "$", "this", "->", "resolveAnnotations", "(", "$", "property", "->", "getDocComment", "(", ")", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "if", "(", "!", "$", "annotationName", "||", "preg_match", "(", "$", "annotationName", ",", "$", "annotation", "[", "'key'", "]", ")", ")", "{", "$", "data", "[", "]", "=", "[", "'property'", "=>", "$", "property", "->", "getName", "(", ")", ",", "'key'", "=>", "$", "annotation", "[", "'key'", "]", ",", "'value'", "=>", "(", "array", ")", "Yaml", "::", "parse", "(", "$", "annotation", "[", "'value'", "]", ")", ",", "'metadata'", "=>", "[", "'class'", "=>", "$", "class", ",", "]", ",", "]", ";", "}", "}", "}", "foreach", "(", "$", "ref", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "annotations", "=", "$", "this", "->", "resolveAnnotations", "(", "$", "method", "->", "getDocComment", "(", ")", ")", ";", "foreach", "(", "$", "annotations", "as", "$", "annotation", ")", "{", "if", "(", "!", "$", "annotationName", "||", "preg_match", "(", "$", "annotationName", ",", "$", "annotation", "[", "'key'", "]", ")", ")", "{", "$", "data", "[", "]", "=", "[", "'method'", "=>", "$", "method", "->", "getName", "(", ")", ",", "'key'", "=>", "$", "annotation", "[", "'key'", "]", ",", "'value'", "=>", "(", "array", ")", "Yaml", "::", "parse", "(", "$", "annotation", "[", "'value'", "]", ")", ",", "'metadata'", "=>", "[", "'class'", "=>", "$", "class", ",", "]", ",", "]", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Util/DocParser.php#L12-L64
yosmanyga/resource
src/Yosmanyga/Resource/Util/DocParser.php
DocParser.findClass
private function findClass($file) { $class = false; $namespace = false; $tokens = token_get_all(file_get_contents($file)); for ($i = 0, $count = count($tokens); $i < $count; $i++) { $token = $tokens[$i]; if (!is_array($token)) { continue; } if (true === $class && T_STRING === $token[0]) { return $namespace.'\\'.$token[1]; } if (true === $namespace && T_STRING === $token[0]) { $namespace = ''; do { $namespace .= $token[1]; $token = $tokens[++$i]; } while ($i < $count && is_array($token) && in_array($token[0], [T_NS_SEPARATOR, T_STRING])); } if (T_CLASS === $token[0]) { $class = true; } if (T_NAMESPACE === $token[0]) { $namespace = true; } } return false; }
php
private function findClass($file) { $class = false; $namespace = false; $tokens = token_get_all(file_get_contents($file)); for ($i = 0, $count = count($tokens); $i < $count; $i++) { $token = $tokens[$i]; if (!is_array($token)) { continue; } if (true === $class && T_STRING === $token[0]) { return $namespace.'\\'.$token[1]; } if (true === $namespace && T_STRING === $token[0]) { $namespace = ''; do { $namespace .= $token[1]; $token = $tokens[++$i]; } while ($i < $count && is_array($token) && in_array($token[0], [T_NS_SEPARATOR, T_STRING])); } if (T_CLASS === $token[0]) { $class = true; } if (T_NAMESPACE === $token[0]) { $namespace = true; } } return false; }
[ "private", "function", "findClass", "(", "$", "file", ")", "{", "$", "class", "=", "false", ";", "$", "namespace", "=", "false", ";", "$", "tokens", "=", "token_get_all", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "count", "=", "count", "(", "$", "tokens", ")", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "token", "=", "$", "tokens", "[", "$", "i", "]", ";", "if", "(", "!", "is_array", "(", "$", "token", ")", ")", "{", "continue", ";", "}", "if", "(", "true", "===", "$", "class", "&&", "T_STRING", "===", "$", "token", "[", "0", "]", ")", "{", "return", "$", "namespace", ".", "'\\\\'", ".", "$", "token", "[", "1", "]", ";", "}", "if", "(", "true", "===", "$", "namespace", "&&", "T_STRING", "===", "$", "token", "[", "0", "]", ")", "{", "$", "namespace", "=", "''", ";", "do", "{", "$", "namespace", ".=", "$", "token", "[", "1", "]", ";", "$", "token", "=", "$", "tokens", "[", "++", "$", "i", "]", ";", "}", "while", "(", "$", "i", "<", "$", "count", "&&", "is_array", "(", "$", "token", ")", "&&", "in_array", "(", "$", "token", "[", "0", "]", ",", "[", "T_NS_SEPARATOR", ",", "T_STRING", "]", ")", ")", ";", "}", "if", "(", "T_CLASS", "===", "$", "token", "[", "0", "]", ")", "{", "$", "class", "=", "true", ";", "}", "if", "(", "T_NAMESPACE", "===", "$", "token", "[", "0", "]", ")", "{", "$", "namespace", "=", "true", ";", "}", "}", "return", "false", ";", "}" ]
Copied from Symfony/Component/Routing/Loader/AnnotationFileLoader.php. @author Fabien Potencier <[email protected]> Returns the full class name for the first class in the file. @param string $file A PHP file path @codeCoverageIgnore @return string|false Full class name if found, false otherwise
[ "Copied", "from", "Symfony", "/", "Component", "/", "Routing", "/", "Loader", "/", "AnnotationFileLoader", ".", "php", "." ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Util/DocParser.php#L78-L112
yosmanyga/resource
src/Yosmanyga/Resource/Util/DocParser.php
DocParser.resolveAnnotations
private function resolveAnnotations($comment) { if (!$comment) { return []; } $comment = $this->cleanAnnotations($comment); $annotations = $this->splitAnnotations($comment); $annotations = $this->cleanContents($annotations); $annotations = $this->parseAnnotations($annotations); return $annotations; }
php
private function resolveAnnotations($comment) { if (!$comment) { return []; } $comment = $this->cleanAnnotations($comment); $annotations = $this->splitAnnotations($comment); $annotations = $this->cleanContents($annotations); $annotations = $this->parseAnnotations($annotations); return $annotations; }
[ "private", "function", "resolveAnnotations", "(", "$", "comment", ")", "{", "if", "(", "!", "$", "comment", ")", "{", "return", "[", "]", ";", "}", "$", "comment", "=", "$", "this", "->", "cleanAnnotations", "(", "$", "comment", ")", ";", "$", "annotations", "=", "$", "this", "->", "splitAnnotations", "(", "$", "comment", ")", ";", "$", "annotations", "=", "$", "this", "->", "cleanContents", "(", "$", "annotations", ")", ";", "$", "annotations", "=", "$", "this", "->", "parseAnnotations", "(", "$", "annotations", ")", ";", "return", "$", "annotations", ";", "}" ]
@param string $comment @return array
[ "@param", "string", "$comment" ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Util/DocParser.php#L119-L131
yosmanyga/resource
src/Yosmanyga/Resource/Util/DocParser.php
DocParser.cleanAnnotations
private function cleanAnnotations($comment) { $comment = trim( preg_replace( '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment ) ); // reg ex above is not able to remove */ from a single line docblock if (substr($comment, -2) == '*/') { $comment = trim(substr($comment, 0, -2)); } // normalize strings $comment = str_replace(["\r\n", "\r"], "\n", $comment); return $comment; }
php
private function cleanAnnotations($comment) { $comment = trim( preg_replace( '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u', '$1', $comment ) ); // reg ex above is not able to remove */ from a single line docblock if (substr($comment, -2) == '*/') { $comment = trim(substr($comment, 0, -2)); } // normalize strings $comment = str_replace(["\r\n", "\r"], "\n", $comment); return $comment; }
[ "private", "function", "cleanAnnotations", "(", "$", "comment", ")", "{", "$", "comment", "=", "trim", "(", "preg_replace", "(", "'#[ \\t]*(?:\\/\\*\\*|\\*\\/|\\*)?[ \\t]{0,1}(.*)?#u'", ",", "'$1'", ",", "$", "comment", ")", ")", ";", "// reg ex above is not able to remove */ from a single line docblock", "if", "(", "substr", "(", "$", "comment", ",", "-", "2", ")", "==", "'*/'", ")", "{", "$", "comment", "=", "trim", "(", "substr", "(", "$", "comment", ",", "0", ",", "-", "2", ")", ")", ";", "}", "// normalize strings", "$", "comment", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", "]", ",", "\"\\n\"", ",", "$", "comment", ")", ";", "return", "$", "comment", ";", "}" ]
Copied from phpDocumentor/ReflectionDocBlock/src/phpDocumentor/Reflection/DocBlock.php::cleanInput. @codeCoverageIgnore
[ "Copied", "from", "phpDocumentor", "/", "ReflectionDocBlock", "/", "src", "/", "phpDocumentor", "/", "Reflection", "/", "DocBlock", ".", "php", "::", "cleanInput", "." ]
train
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Util/DocParser.php#L138-L157
gregorybesson/PlaygroundCore
src/Controller/Admin/ElfinderController.php
ElfinderController.access
public function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : null; }
php
public function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : null; }
[ "public", "function", "access", "(", "$", "attr", ",", "$", "path", ",", "$", "data", ",", "$", "volume", ")", "{", "return", "strpos", "(", "basename", "(", "$", "path", ")", ",", "'.'", ")", "===", "0", "?", "!", "(", "$", "attr", "==", "'read'", "||", "$", "attr", "==", "'write'", ")", ":", "null", ";", "}" ]
@param $attr @param $path @param $data @param $volume @return bool|null
[ "@param", "$attr", "@param", "$path", "@param", "$data", "@param", "$volume" ]
train
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Controller/Admin/ElfinderController.php#L91-L96
WellCommerce/OrderBundle
Controller/Front/AddressController.php
AddressController.copyShippingAddress
protected function copyShippingAddress(ParameterBag $parameters) { $billingAddress = $parameters->get('billingAddress'); $shippingAddress = [ 'shippingAddress.copyBillingAddress' => true, ]; foreach ($billingAddress as $key => $value) { list(, $fieldName) = explode('.', $key); $shippingAddress['shippingAddress.' . $fieldName] = $value; } $parameters->set('shippingAddress', $shippingAddress); }
php
protected function copyShippingAddress(ParameterBag $parameters) { $billingAddress = $parameters->get('billingAddress'); $shippingAddress = [ 'shippingAddress.copyBillingAddress' => true, ]; foreach ($billingAddress as $key => $value) { list(, $fieldName) = explode('.', $key); $shippingAddress['shippingAddress.' . $fieldName] = $value; } $parameters->set('shippingAddress', $shippingAddress); }
[ "protected", "function", "copyShippingAddress", "(", "ParameterBag", "$", "parameters", ")", "{", "$", "billingAddress", "=", "$", "parameters", "->", "get", "(", "'billingAddress'", ")", ";", "$", "shippingAddress", "=", "[", "'shippingAddress.copyBillingAddress'", "=>", "true", ",", "]", ";", "foreach", "(", "$", "billingAddress", "as", "$", "key", "=>", "$", "value", ")", "{", "list", "(", ",", "$", "fieldName", ")", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "shippingAddress", "[", "'shippingAddress.'", ".", "$", "fieldName", "]", "=", "$", "value", ";", "}", "$", "parameters", "->", "set", "(", "'shippingAddress'", ",", "$", "shippingAddress", ")", ";", "}" ]
Copies billing address to shipping address @param ParameterBag $parameters
[ "Copies", "billing", "address", "to", "shipping", "address" ]
train
https://github.com/WellCommerce/OrderBundle/blob/d72cfb51eab7a1f66f186900d1e2d533a822c424/Controller/Front/AddressController.php#L97-L111
prooph/link-app-core
src/Service/SystemConfigFactory.php
SystemConfigFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { return \Prooph\Link\Application\Model\ProcessingConfig::asProjectionFrom($serviceLocator->get('prooph.link.app.config_location')); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { return \Prooph\Link\Application\Model\ProcessingConfig::asProjectionFrom($serviceLocator->get('prooph.link.app.config_location')); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "return", "\\", "Prooph", "\\", "Link", "\\", "Application", "\\", "Model", "\\", "ProcessingConfig", "::", "asProjectionFrom", "(", "$", "serviceLocator", "->", "get", "(", "'prooph.link.app.config_location'", ")", ")", ";", "}" ]
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
[ "Create", "service" ]
train
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Service/SystemConfigFactory.php#L32-L35
EcomDev/phpspec-magento-di-adapter
src/Runner/CollaboratorMaintainer.php
CollaboratorMaintainer.prepare
public function prepare( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { if ($example->getSpecification()->getClassReflection()->hasMethod('let')) { $this->parameterValidator->validate($example->getSpecification()->getClassReflection()->getMethod('let')); } $this->parameterValidator->validate($example->getFunctionReflection()); return $this; }
php
public function prepare( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { if ($example->getSpecification()->getClassReflection()->hasMethod('let')) { $this->parameterValidator->validate($example->getSpecification()->getClassReflection()->getMethod('let')); } $this->parameterValidator->validate($example->getFunctionReflection()); return $this; }
[ "public", "function", "prepare", "(", "ExampleNode", "$", "example", ",", "Specification", "$", "context", ",", "MatcherManager", "$", "matchers", ",", "CollaboratorManager", "$", "collaborators", ")", "{", "if", "(", "$", "example", "->", "getSpecification", "(", ")", "->", "getClassReflection", "(", ")", "->", "hasMethod", "(", "'let'", ")", ")", "{", "$", "this", "->", "parameterValidator", "->", "validate", "(", "$", "example", "->", "getSpecification", "(", ")", "->", "getClassReflection", "(", ")", "->", "getMethod", "(", "'let'", ")", ")", ";", "}", "$", "this", "->", "parameterValidator", "->", "validate", "(", "$", "example", "->", "getFunctionReflection", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Generates DI related stuff via parameter validator @param ExampleNode $example @param Specification $context @param MatcherManager $matchers @param CollaboratorManager $collaborators @return $this
[ "Generates", "DI", "related", "stuff", "via", "parameter", "validator" ]
train
https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/Runner/CollaboratorMaintainer.php#L56-L67
EcomDev/phpspec-magento-di-adapter
src/Runner/CollaboratorMaintainer.php
CollaboratorMaintainer.teardown
public function teardown( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { return $this; }
php
public function teardown( ExampleNode $example, Specification $context, MatcherManager $matchers, CollaboratorManager $collaborators ) { return $this; }
[ "public", "function", "teardown", "(", "ExampleNode", "$", "example", ",", "Specification", "$", "context", ",", "MatcherManager", "$", "matchers", ",", "CollaboratorManager", "$", "collaborators", ")", "{", "return", "$", "this", ";", "}" ]
It does nothing on teardown... @param ExampleNode $example @param Specification $context @param MatcherManager $matchers @param CollaboratorManager $collaborators @return $this
[ "It", "does", "nothing", "on", "teardown", "..." ]
train
https://github.com/EcomDev/phpspec-magento-di-adapter/blob/b39f6f0afbb837dbf0eb4c71e6cdb318b8c9de37/src/Runner/CollaboratorMaintainer.php#L79-L87
czim/laravel-pxlcms
src/Generator/Analyzer/AnalyzerContext.php
AnalyzerContext.normalizeCmsDatabaseString
public function normalizeCmsDatabaseString($string, $spaceSubstitute = '_') { $string = html_entity_decode($string); $string = mb_convert_encoding($string, "ISO-8859-1", 'UTF-8'); $string = preg_replace('#\s+#', $spaceSubstitute, $string); $string = $this->normalizeCmsAccents($string); $string = preg_replace('#[^0-9a-z' . preg_quote($spaceSubstitute) . ']#i', '', $string); $string = preg_replace('#[' . preg_quote($spaceSubstitute) . ']+#', $spaceSubstitute, $string); $string = preg_replace('#\s+#', $spaceSubstitute, $string); $string = trim($string, $spaceSubstitute); return $string; }
php
public function normalizeCmsDatabaseString($string, $spaceSubstitute = '_') { $string = html_entity_decode($string); $string = mb_convert_encoding($string, "ISO-8859-1", 'UTF-8'); $string = preg_replace('#\s+#', $spaceSubstitute, $string); $string = $this->normalizeCmsAccents($string); $string = preg_replace('#[^0-9a-z' . preg_quote($spaceSubstitute) . ']#i', '', $string); $string = preg_replace('#[' . preg_quote($spaceSubstitute) . ']+#', $spaceSubstitute, $string); $string = preg_replace('#\s+#', $spaceSubstitute, $string); $string = trim($string, $spaceSubstitute); return $string; }
[ "public", "function", "normalizeCmsDatabaseString", "(", "$", "string", ",", "$", "spaceSubstitute", "=", "'_'", ")", "{", "$", "string", "=", "html_entity_decode", "(", "$", "string", ")", ";", "$", "string", "=", "mb_convert_encoding", "(", "$", "string", ",", "\"ISO-8859-1\"", ",", "'UTF-8'", ")", ";", "$", "string", "=", "preg_replace", "(", "'#\\s+#'", ",", "$", "spaceSubstitute", ",", "$", "string", ")", ";", "$", "string", "=", "$", "this", "->", "normalizeCmsAccents", "(", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'#[^0-9a-z'", ".", "preg_quote", "(", "$", "spaceSubstitute", ")", ".", "']#i'", ",", "''", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'#['", ".", "preg_quote", "(", "$", "spaceSubstitute", ")", ".", "']+#'", ",", "$", "spaceSubstitute", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'#\\s+#'", ",", "$", "spaceSubstitute", ",", "$", "string", ")", ";", "$", "string", "=", "trim", "(", "$", "string", ",", "$", "spaceSubstitute", ")", ";", "return", "$", "string", ";", "}" ]
Normalizes a string (name) to a database field or table name in the same way the PXL CMS does this. @param string $string @param string $spaceSubstitute what to replace spaces with @return string
[ "Normalizes", "a", "string", "(", "name", ")", "to", "a", "database", "field", "or", "table", "name", "in", "the", "same", "way", "the", "PXL", "CMS", "does", "this", "." ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/AnalyzerContext.php#L111-L129
czim/laravel-pxlcms
src/Generator/Analyzer/AnalyzerContext.php
AnalyzerContext.normalizeCmsAccents
public function normalizeCmsAccents($string) { $string = htmlentities($string, ENT_COMPAT | (defined('ENT_HTML401') ? ENT_HTML401 : 0), 'ISO-8859-1'); $string = preg_replace('#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#','$1',$string); $string = preg_replace('#&(ae|AE)lig;#','$1',$string); // æ to ae $string = preg_replace('#&(oe|OE)lig;#','$1',$string); // Œ to OE $string = preg_replace('#&szlig;#','ss',$string); // ß to ss $string = preg_replace('#&(eth|thorn);#','th',$string); // ð and þ to th $string = preg_replace('#&(ETH|THORN);#','Th',$string); // Ð and Þ to Th return html_entity_decode($string); }
php
public function normalizeCmsAccents($string) { $string = htmlentities($string, ENT_COMPAT | (defined('ENT_HTML401') ? ENT_HTML401 : 0), 'ISO-8859-1'); $string = preg_replace('#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#','$1',$string); $string = preg_replace('#&(ae|AE)lig;#','$1',$string); // æ to ae $string = preg_replace('#&(oe|OE)lig;#','$1',$string); // Œ to OE $string = preg_replace('#&szlig;#','ss',$string); // ß to ss $string = preg_replace('#&(eth|thorn);#','th',$string); // ð and þ to th $string = preg_replace('#&(ETH|THORN);#','Th',$string); // Ð and Þ to Th return html_entity_decode($string); }
[ "public", "function", "normalizeCmsAccents", "(", "$", "string", ")", "{", "$", "string", "=", "htmlentities", "(", "$", "string", ",", "ENT_COMPAT", "|", "(", "defined", "(", "'ENT_HTML401'", ")", "?", "ENT_HTML401", ":", "0", ")", ",", "'ISO-8859-1'", ")", ";", "$", "string", "=", "preg_replace", "(", "'#&([a-zA-Z])(uml|acute|grave|circ|tilde|slash|cedil|ring|caron);#'", ",", "'$1'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "'#&(ae|AE)lig;#'", ",", "'$1'", ",", "$", "string", ")", ";", "// æ to ae", "$", "string", "=", "preg_replace", "(", "'#&(oe|OE)lig;#'", ",", "'$1'", ",", "$", "string", ")", ";", "// Œ to OE", "$", "string", "=", "preg_replace", "(", "'#&szlig;#'", ",", "'ss'", ",", "$", "string", ")", ";", "// ß to ss", "$", "string", "=", "preg_replace", "(", "'#&(eth|thorn);#'", ",", "'th'", ",", "$", "string", ")", ";", "// ð and þ to th", "$", "string", "=", "preg_replace", "(", "'#&(ETH|THORN);#'", ",", "'Th'", ",", "$", "string", ")", ";", "// Ð and Þ to Th", "return", "html_entity_decode", "(", "$", "string", ")", ";", "}" ]
Normalize accents just like the CMS does @param string $string @return string
[ "Normalize", "accents", "just", "like", "the", "CMS", "does" ]
train
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/AnalyzerContext.php#L137-L150
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.dump
public function dump(Workout $workout): string { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->setIndent(true); $xmlWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startElement('gpx'); $xmlWriter->writeAttribute('version', '1.1'); $xmlWriter->writeAttribute('creator', 'SportTrackerConnector'); $xmlWriter->writeAttributeNs( 'xsi', 'schemaLocation', null, 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd' ); $xmlWriter->writeAttribute('xmlns', 'http://www.topografix.com/GPX/1/1'); $xmlWriter->writeAttributeNs( 'xmlns', 'gpxtpx', null, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1' ); $xmlWriter->writeAttributeNs('xmlns', 'gpxx', null, 'http://www.garmin.com/xmlschemas/GpxExtensions/v3'); $xmlWriter->writeAttributeNs('xmlns', 'xsi', null, 'http://www.w3.org/2001/XMLSchema-instance'); $this->writeMetaData($xmlWriter, $workout); $this->writeTracks($xmlWriter, $workout); $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(true); }
php
public function dump(Workout $workout): string { $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $xmlWriter->setIndent(true); $xmlWriter->startDocument('1.0', 'UTF-8'); $xmlWriter->startElement('gpx'); $xmlWriter->writeAttribute('version', '1.1'); $xmlWriter->writeAttribute('creator', 'SportTrackerConnector'); $xmlWriter->writeAttributeNs( 'xsi', 'schemaLocation', null, 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd' ); $xmlWriter->writeAttribute('xmlns', 'http://www.topografix.com/GPX/1/1'); $xmlWriter->writeAttributeNs( 'xmlns', 'gpxtpx', null, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1' ); $xmlWriter->writeAttributeNs('xmlns', 'gpxx', null, 'http://www.garmin.com/xmlschemas/GpxExtensions/v3'); $xmlWriter->writeAttributeNs('xmlns', 'xsi', null, 'http://www.w3.org/2001/XMLSchema-instance'); $this->writeMetaData($xmlWriter, $workout); $this->writeTracks($xmlWriter, $workout); $xmlWriter->endElement(); $xmlWriter->endDocument(); return $xmlWriter->outputMemory(true); }
[ "public", "function", "dump", "(", "Workout", "$", "workout", ")", ":", "string", "{", "$", "xmlWriter", "=", "new", "\\", "XMLWriter", "(", ")", ";", "$", "xmlWriter", "->", "openMemory", "(", ")", ";", "$", "xmlWriter", "->", "setIndent", "(", "true", ")", ";", "$", "xmlWriter", "->", "startDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "$", "xmlWriter", "->", "startElement", "(", "'gpx'", ")", ";", "$", "xmlWriter", "->", "writeAttribute", "(", "'version'", ",", "'1.1'", ")", ";", "$", "xmlWriter", "->", "writeAttribute", "(", "'creator'", ",", "'SportTrackerConnector'", ")", ";", "$", "xmlWriter", "->", "writeAttributeNs", "(", "'xsi'", ",", "'schemaLocation'", ",", "null", ",", "'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd'", ")", ";", "$", "xmlWriter", "->", "writeAttribute", "(", "'xmlns'", ",", "'http://www.topografix.com/GPX/1/1'", ")", ";", "$", "xmlWriter", "->", "writeAttributeNs", "(", "'xmlns'", ",", "'gpxtpx'", ",", "null", ",", "'http://www.garmin.com/xmlschemas/TrackPointExtension/v1'", ")", ";", "$", "xmlWriter", "->", "writeAttributeNs", "(", "'xmlns'", ",", "'gpxx'", ",", "null", ",", "'http://www.garmin.com/xmlschemas/GpxExtensions/v3'", ")", ";", "$", "xmlWriter", "->", "writeAttributeNs", "(", "'xmlns'", ",", "'xsi'", ",", "null", ",", "'http://www.w3.org/2001/XMLSchema-instance'", ")", ";", "$", "this", "->", "writeMetaData", "(", "$", "xmlWriter", ",", "$", "workout", ")", ";", "$", "this", "->", "writeTracks", "(", "$", "xmlWriter", ",", "$", "workout", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "$", "xmlWriter", "->", "endDocument", "(", ")", ";", "return", "$", "xmlWriter", "->", "outputMemory", "(", "true", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L20-L53
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeTracks
private function writeTracks(\XMLWriter $xmlWriter, Workout $workout) { foreach ($workout->tracks() as $track) { $xmlWriter->startElement('trk'); $xmlWriter->writeElement('type', $track->sport()); $xmlWriter->startElement('trkseg'); $this->writeTrackPoints($xmlWriter, $track->trackPoints()); $xmlWriter->endElement(); $xmlWriter->endElement(); } }
php
private function writeTracks(\XMLWriter $xmlWriter, Workout $workout) { foreach ($workout->tracks() as $track) { $xmlWriter->startElement('trk'); $xmlWriter->writeElement('type', $track->sport()); $xmlWriter->startElement('trkseg'); $this->writeTrackPoints($xmlWriter, $track->trackPoints()); $xmlWriter->endElement(); $xmlWriter->endElement(); } }
[ "private", "function", "writeTracks", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "Workout", "$", "workout", ")", "{", "foreach", "(", "$", "workout", "->", "tracks", "(", ")", "as", "$", "track", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'trk'", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'type'", ",", "$", "track", "->", "sport", "(", ")", ")", ";", "$", "xmlWriter", "->", "startElement", "(", "'trkseg'", ")", ";", "$", "this", "->", "writeTrackPoints", "(", "$", "xmlWriter", ",", "$", "track", "->", "trackPoints", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "}" ]
Write the tracks to the GPX. @param \XMLWriter $xmlWriter The XML writer. @param Workout $workout The workout.
[ "Write", "the", "tracks", "to", "the", "GPX", "." ]
train
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L61-L71
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeTrackPoints
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints) { foreach ($trackPoints as $trackPoint) { $xmlWriter->startElement('trkpt'); // Location. $xmlWriter->writeAttribute('lat', (string)$trackPoint->latitude()); $xmlWriter->writeAttribute('lon', (string)$trackPoint->longitude()); // Elevation. $xmlWriter->writeElement('ele', (string)$trackPoint->elevation()); // Time of position $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $xmlWriter->writeElement('time', $dateTime->format(\DateTime::W3C)); // Extensions. $this->writeExtensions($xmlWriter, $trackPoint->extensions()); $xmlWriter->endElement(); } }
php
private function writeTrackPoints(\XMLWriter $xmlWriter, array $trackPoints) { foreach ($trackPoints as $trackPoint) { $xmlWriter->startElement('trkpt'); // Location. $xmlWriter->writeAttribute('lat', (string)$trackPoint->latitude()); $xmlWriter->writeAttribute('lon', (string)$trackPoint->longitude()); // Elevation. $xmlWriter->writeElement('ele', (string)$trackPoint->elevation()); // Time of position $dateTime = clone $trackPoint->dateTime(); $dateTime->setTimezone(new \DateTimeZone('UTC')); $xmlWriter->writeElement('time', $dateTime->format(\DateTime::W3C)); // Extensions. $this->writeExtensions($xmlWriter, $trackPoint->extensions()); $xmlWriter->endElement(); } }
[ "private", "function", "writeTrackPoints", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "array", "$", "trackPoints", ")", "{", "foreach", "(", "$", "trackPoints", "as", "$", "trackPoint", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'trkpt'", ")", ";", "// Location.", "$", "xmlWriter", "->", "writeAttribute", "(", "'lat'", ",", "(", "string", ")", "$", "trackPoint", "->", "latitude", "(", ")", ")", ";", "$", "xmlWriter", "->", "writeAttribute", "(", "'lon'", ",", "(", "string", ")", "$", "trackPoint", "->", "longitude", "(", ")", ")", ";", "// Elevation.", "$", "xmlWriter", "->", "writeElement", "(", "'ele'", ",", "(", "string", ")", "$", "trackPoint", "->", "elevation", "(", ")", ")", ";", "// Time of position", "$", "dateTime", "=", "clone", "$", "trackPoint", "->", "dateTime", "(", ")", ";", "$", "dateTime", "->", "setTimezone", "(", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'time'", ",", "$", "dateTime", "->", "format", "(", "\\", "DateTime", "::", "W3C", ")", ")", ";", "// Extensions.", "$", "this", "->", "writeExtensions", "(", "$", "xmlWriter", ",", "$", "trackPoint", "->", "extensions", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "}" ]
Write the track points to the GPX. @param \XMLWriter $xmlWriter The XML writer. @param TrackPoint[] $trackPoints The track points to write.
[ "Write", "the", "track", "points", "to", "the", "GPX", "." ]
train
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L79-L101
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeExtensions
protected function writeExtensions(\XMLWriter $xmlWriter, array $extensions) { $xmlWriter->startElement('extensions'); foreach ($extensions as $extension) { switch ($extension::ID()) { case HR::ID(): $xmlWriter->startElementNs('gpxtpx', 'TrackPointExtension', null); $xmlWriter->writeElementNs('gpxtpx', 'hr', null, (string)$extension->value()); $xmlWriter->endElement(); break; } } $xmlWriter->endElement(); }
php
protected function writeExtensions(\XMLWriter $xmlWriter, array $extensions) { $xmlWriter->startElement('extensions'); foreach ($extensions as $extension) { switch ($extension::ID()) { case HR::ID(): $xmlWriter->startElementNs('gpxtpx', 'TrackPointExtension', null); $xmlWriter->writeElementNs('gpxtpx', 'hr', null, (string)$extension->value()); $xmlWriter->endElement(); break; } } $xmlWriter->endElement(); }
[ "protected", "function", "writeExtensions", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "array", "$", "extensions", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'extensions'", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "switch", "(", "$", "extension", "::", "ID", "(", ")", ")", "{", "case", "HR", "::", "ID", "(", ")", ":", "$", "xmlWriter", "->", "startElementNs", "(", "'gpxtpx'", ",", "'TrackPointExtension'", ",", "null", ")", ";", "$", "xmlWriter", "->", "writeElementNs", "(", "'gpxtpx'", ",", "'hr'", ",", "null", ",", "(", "string", ")", "$", "extension", "->", "value", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "break", ";", "}", "}", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}" ]
Write the extensions into the GPX. @param \XMLWriter $xmlWriter The XMLWriter. @param ExtensionInterface[] $extensions The extensions to write.
[ "Write", "the", "extensions", "into", "the", "GPX", "." ]
train
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L109-L122
dragosprotung/stc-core
src/Workout/Dumper/GPX.php
GPX.writeMetaData
protected function writeMetaData(\XMLWriter $xmlWriter, Workout $workout) { $xmlWriter->startElement('metadata'); if ($workout->author() !== null) { $xmlWriter->startElement('author'); $xmlWriter->writeElement('name', $workout->author()->name()); $xmlWriter->endElement(); } $xmlWriter->endElement(); }
php
protected function writeMetaData(\XMLWriter $xmlWriter, Workout $workout) { $xmlWriter->startElement('metadata'); if ($workout->author() !== null) { $xmlWriter->startElement('author'); $xmlWriter->writeElement('name', $workout->author()->name()); $xmlWriter->endElement(); } $xmlWriter->endElement(); }
[ "protected", "function", "writeMetaData", "(", "\\", "XMLWriter", "$", "xmlWriter", ",", "Workout", "$", "workout", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'metadata'", ")", ";", "if", "(", "$", "workout", "->", "author", "(", ")", "!==", "null", ")", "{", "$", "xmlWriter", "->", "startElement", "(", "'author'", ")", ";", "$", "xmlWriter", "->", "writeElement", "(", "'name'", ",", "$", "workout", "->", "author", "(", ")", "->", "name", "(", ")", ")", ";", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}", "$", "xmlWriter", "->", "endElement", "(", ")", ";", "}" ]
Write the metadata in the GPX. @param \XMLWriter $xmlWriter The XML writer. @param Workout $workout The workout.
[ "Write", "the", "metadata", "in", "the", "GPX", "." ]
train
https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Dumper/GPX.php#L130-L139
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.hydrate
public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { try { $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : LogTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : LogTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; $this->type = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : LogTableMap::translateFieldName('DateTime', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->date_time = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : LogTableMap::translateFieldName('LogText', TableMap::TYPE_PHPNAME, $indexType)]; $this->log_text = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : LogTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)]; $this->user_id = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : LogTableMap::translateFieldName('Username', TableMap::TYPE_PHPNAME, $indexType)]; $this->username = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LogTableMap::translateFieldName('SessionId', TableMap::TYPE_PHPNAME, $indexType)]; $this->session_id = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LogTableMap::translateFieldName('ClientAddress', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_address = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : LogTableMap::translateFieldName('ClientIp', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_ip = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : LogTableMap::translateFieldName('ClientAgent', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_agent = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : LogTableMap::translateFieldName('ClientPlatform', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_platform = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } return $startcol + 11; // 11 = LogTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException(sprintf('Error populating %s object', '\\Alchemy\\Component\\Cerberus\\Model\\Log'), 0, $e); } }
php
public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) { try { $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : LogTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : LogTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; $this->type = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : LogTableMap::translateFieldName('DateTime', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->date_time = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : LogTableMap::translateFieldName('LogText', TableMap::TYPE_PHPNAME, $indexType)]; $this->log_text = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : LogTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)]; $this->user_id = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : LogTableMap::translateFieldName('Username', TableMap::TYPE_PHPNAME, $indexType)]; $this->username = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : LogTableMap::translateFieldName('SessionId', TableMap::TYPE_PHPNAME, $indexType)]; $this->session_id = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : LogTableMap::translateFieldName('ClientAddress', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_address = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : LogTableMap::translateFieldName('ClientIp', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_ip = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : LogTableMap::translateFieldName('ClientAgent', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_agent = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : LogTableMap::translateFieldName('ClientPlatform', TableMap::TYPE_PHPNAME, $indexType)]; $this->client_platform = (null !== $col) ? (string) $col : null; $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } return $startcol + 11; // 11 = LogTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException(sprintf('Error populating %s object', '\\Alchemy\\Component\\Cerberus\\Model\\Log'), 0, $e); } }
[ "public", "function", "hydrate", "(", "$", "row", ",", "$", "startcol", "=", "0", ",", "$", "rehydrate", "=", "false", ",", "$", "indexType", "=", "TableMap", "::", "TYPE_NUM", ")", "{", "try", "{", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "0", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'Id'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "id", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "int", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "1", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'Type'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "type", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "2", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'DateTime'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "if", "(", "$", "col", "===", "'0000-00-00 00:00:00'", ")", "{", "$", "col", "=", "null", ";", "}", "$", "this", "->", "date_time", "=", "(", "null", "!==", "$", "col", ")", "?", "PropelDateTime", "::", "newInstance", "(", "$", "col", ",", "null", ",", "'\\DateTime'", ")", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "3", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'LogText'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "log_text", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "4", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'UserId'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "user_id", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "5", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'Username'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "username", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "6", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'SessionId'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "session_id", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "7", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'ClientAddress'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "client_address", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "8", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'ClientIp'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "client_ip", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "9", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'ClientAgent'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "client_agent", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "col", "=", "$", "row", "[", "TableMap", "::", "TYPE_NUM", "==", "$", "indexType", "?", "10", "+", "$", "startcol", ":", "LogTableMap", "::", "translateFieldName", "(", "'ClientPlatform'", ",", "TableMap", "::", "TYPE_PHPNAME", ",", "$", "indexType", ")", "]", ";", "$", "this", "->", "client_platform", "=", "(", "null", "!==", "$", "col", ")", "?", "(", "string", ")", "$", "col", ":", "null", ";", "$", "this", "->", "resetModified", "(", ")", ";", "$", "this", "->", "setNew", "(", "false", ")", ";", "if", "(", "$", "rehydrate", ")", "{", "$", "this", "->", "ensureConsistency", "(", ")", ";", "}", "return", "$", "startcol", "+", "11", ";", "// 11 = LogTableMap::NUM_HYDRATE_COLUMNS.", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "sprintf", "(", "'Error populating %s object'", ",", "'\\\\Alchemy\\\\Component\\\\Cerberus\\\\Model\\\\Log'", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Hydrates (populates) the object variables with values from the database resultset. An offset (0-based "start column") is specified so that objects can be hydrated with a subset of the columns in the resultset rows. This is needed, for example, for results of JOIN queries where the resultset row includes columns from two or more tables. @param array $row The row returned by DataFetcher->fetch(). @param int $startcol 0-based offset column which indicates which restultset column to start with. @param boolean $rehydrate Whether this object is being re-hydrated from the database. @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. @return int next starting column @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
[ "Hydrates", "(", "populates", ")", "the", "object", "variables", "with", "values", "from", "the", "database", "resultset", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L500-L552
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.setType
public function setType($v) { if ($v !== null) { $v = (string) $v; } if ($this->type !== $v) { $this->type = $v; $this->modifiedColumns[LogTableMap::COL_TYPE] = true; } return $this; }
php
public function setType($v) { if ($v !== null) { $v = (string) $v; } if ($this->type !== $v) { $this->type = $v; $this->modifiedColumns[LogTableMap::COL_TYPE] = true; } return $this; }
[ "public", "function", "setType", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "type", "!==", "$", "v", ")", "{", "$", "this", "->", "type", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "LogTableMap", "::", "COL_TYPE", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [type] column. @param string $v new value @return $this|\Alchemy\Component\Cerberus\Model\Log The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "type", "]", "column", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L597-L609
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.setLogText
public function setLogText($v) { if ($v !== null) { $v = (string) $v; } if ($this->log_text !== $v) { $this->log_text = $v; $this->modifiedColumns[LogTableMap::COL_LOG_TEXT] = true; } return $this; }
php
public function setLogText($v) { if ($v !== null) { $v = (string) $v; } if ($this->log_text !== $v) { $this->log_text = $v; $this->modifiedColumns[LogTableMap::COL_LOG_TEXT] = true; } return $this; }
[ "public", "function", "setLogText", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "log_text", "!==", "$", "v", ")", "{", "$", "this", "->", "log_text", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "LogTableMap", "::", "COL_LOG_TEXT", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [log_text] column. @param string $v new value @return $this|\Alchemy\Component\Cerberus\Model\Log The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "log_text", "]", "column", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L637-L649
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.setClientAddress
public function setClientAddress($v) { if ($v !== null) { $v = (string) $v; } if ($this->client_address !== $v) { $this->client_address = $v; $this->modifiedColumns[LogTableMap::COL_CLIENT_ADDRESS] = true; } return $this; }
php
public function setClientAddress($v) { if ($v !== null) { $v = (string) $v; } if ($this->client_address !== $v) { $this->client_address = $v; $this->modifiedColumns[LogTableMap::COL_CLIENT_ADDRESS] = true; } return $this; }
[ "public", "function", "setClientAddress", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "client_address", "!==", "$", "v", ")", "{", "$", "this", "->", "client_address", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "LogTableMap", "::", "COL_CLIENT_ADDRESS", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [client_address] column. @param string $v new value @return $this|\Alchemy\Component\Cerberus\Model\Log The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "client_address", "]", "column", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L717-L729
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.buildCriteria
public function buildCriteria() { $criteria = new Criteria(LogTableMap::DATABASE_NAME); if ($this->isColumnModified(LogTableMap::COL_ID)) { $criteria->add(LogTableMap::COL_ID, $this->id); } if ($this->isColumnModified(LogTableMap::COL_TYPE)) { $criteria->add(LogTableMap::COL_TYPE, $this->type); } if ($this->isColumnModified(LogTableMap::COL_DATE_TIME)) { $criteria->add(LogTableMap::COL_DATE_TIME, $this->date_time); } if ($this->isColumnModified(LogTableMap::COL_LOG_TEXT)) { $criteria->add(LogTableMap::COL_LOG_TEXT, $this->log_text); } if ($this->isColumnModified(LogTableMap::COL_USER_ID)) { $criteria->add(LogTableMap::COL_USER_ID, $this->user_id); } if ($this->isColumnModified(LogTableMap::COL_USERNAME)) { $criteria->add(LogTableMap::COL_USERNAME, $this->username); } if ($this->isColumnModified(LogTableMap::COL_SESSION_ID)) { $criteria->add(LogTableMap::COL_SESSION_ID, $this->session_id); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_ADDRESS)) { $criteria->add(LogTableMap::COL_CLIENT_ADDRESS, $this->client_address); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_IP)) { $criteria->add(LogTableMap::COL_CLIENT_IP, $this->client_ip); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_AGENT)) { $criteria->add(LogTableMap::COL_CLIENT_AGENT, $this->client_agent); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_PLATFORM)) { $criteria->add(LogTableMap::COL_CLIENT_PLATFORM, $this->client_platform); } return $criteria; }
php
public function buildCriteria() { $criteria = new Criteria(LogTableMap::DATABASE_NAME); if ($this->isColumnModified(LogTableMap::COL_ID)) { $criteria->add(LogTableMap::COL_ID, $this->id); } if ($this->isColumnModified(LogTableMap::COL_TYPE)) { $criteria->add(LogTableMap::COL_TYPE, $this->type); } if ($this->isColumnModified(LogTableMap::COL_DATE_TIME)) { $criteria->add(LogTableMap::COL_DATE_TIME, $this->date_time); } if ($this->isColumnModified(LogTableMap::COL_LOG_TEXT)) { $criteria->add(LogTableMap::COL_LOG_TEXT, $this->log_text); } if ($this->isColumnModified(LogTableMap::COL_USER_ID)) { $criteria->add(LogTableMap::COL_USER_ID, $this->user_id); } if ($this->isColumnModified(LogTableMap::COL_USERNAME)) { $criteria->add(LogTableMap::COL_USERNAME, $this->username); } if ($this->isColumnModified(LogTableMap::COL_SESSION_ID)) { $criteria->add(LogTableMap::COL_SESSION_ID, $this->session_id); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_ADDRESS)) { $criteria->add(LogTableMap::COL_CLIENT_ADDRESS, $this->client_address); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_IP)) { $criteria->add(LogTableMap::COL_CLIENT_IP, $this->client_ip); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_AGENT)) { $criteria->add(LogTableMap::COL_CLIENT_AGENT, $this->client_agent); } if ($this->isColumnModified(LogTableMap::COL_CLIENT_PLATFORM)) { $criteria->add(LogTableMap::COL_CLIENT_PLATFORM, $this->client_platform); } return $criteria; }
[ "public", "function", "buildCriteria", "(", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", "LogTableMap", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_ID", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_ID", ",", "$", "this", "->", "id", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_TYPE", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_TYPE", ",", "$", "this", "->", "type", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_DATE_TIME", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_DATE_TIME", ",", "$", "this", "->", "date_time", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_LOG_TEXT", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_LOG_TEXT", ",", "$", "this", "->", "log_text", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_USER_ID", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_USER_ID", ",", "$", "this", "->", "user_id", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_USERNAME", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_USERNAME", ",", "$", "this", "->", "username", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_SESSION_ID", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_SESSION_ID", ",", "$", "this", "->", "session_id", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_CLIENT_ADDRESS", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_CLIENT_ADDRESS", ",", "$", "this", "->", "client_address", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_CLIENT_IP", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_CLIENT_IP", ",", "$", "this", "->", "client_ip", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_CLIENT_AGENT", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_CLIENT_AGENT", ",", "$", "this", "->", "client_agent", ")", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "LogTableMap", "::", "COL_CLIENT_PLATFORM", ")", ")", "{", "$", "criteria", "->", "add", "(", "LogTableMap", "::", "COL_CLIENT_PLATFORM", ",", "$", "this", "->", "client_platform", ")", ";", "}", "return", "$", "criteria", ";", "}" ]
Build a Criteria object containing the values of all modified columns in this object. @return Criteria The Criteria object containing all modified values.
[ "Build", "a", "Criteria", "object", "containing", "the", "values", "of", "all", "modified", "columns", "in", "this", "object", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L1337-L1376
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/Log.php
Log.copyInto
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setType($this->getType()); $copyObj->setDateTime($this->getDateTime()); $copyObj->setLogText($this->getLogText()); $copyObj->setUserId($this->getUserId()); $copyObj->setUsername($this->getUsername()); $copyObj->setSessionId($this->getSessionId()); $copyObj->setClientAddress($this->getClientAddress()); $copyObj->setClientIp($this->getClientIp()); $copyObj->setClientAgent($this->getClientAgent()); $copyObj->setClientPlatform($this->getClientPlatform()); if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
php
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setType($this->getType()); $copyObj->setDateTime($this->getDateTime()); $copyObj->setLogText($this->getLogText()); $copyObj->setUserId($this->getUserId()); $copyObj->setUsername($this->getUsername()); $copyObj->setSessionId($this->getSessionId()); $copyObj->setClientAddress($this->getClientAddress()); $copyObj->setClientIp($this->getClientIp()); $copyObj->setClientAgent($this->getClientAgent()); $copyObj->setClientPlatform($this->getClientPlatform()); if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
[ "public", "function", "copyInto", "(", "$", "copyObj", ",", "$", "deepCopy", "=", "false", ",", "$", "makeNew", "=", "true", ")", "{", "$", "copyObj", "->", "setType", "(", "$", "this", "->", "getType", "(", ")", ")", ";", "$", "copyObj", "->", "setDateTime", "(", "$", "this", "->", "getDateTime", "(", ")", ")", ";", "$", "copyObj", "->", "setLogText", "(", "$", "this", "->", "getLogText", "(", ")", ")", ";", "$", "copyObj", "->", "setUserId", "(", "$", "this", "->", "getUserId", "(", ")", ")", ";", "$", "copyObj", "->", "setUsername", "(", "$", "this", "->", "getUsername", "(", ")", ")", ";", "$", "copyObj", "->", "setSessionId", "(", "$", "this", "->", "getSessionId", "(", ")", ")", ";", "$", "copyObj", "->", "setClientAddress", "(", "$", "this", "->", "getClientAddress", "(", ")", ")", ";", "$", "copyObj", "->", "setClientIp", "(", "$", "this", "->", "getClientIp", "(", ")", ")", ";", "$", "copyObj", "->", "setClientAgent", "(", "$", "this", "->", "getClientAgent", "(", ")", ")", ";", "$", "copyObj", "->", "setClientPlatform", "(", "$", "this", "->", "getClientPlatform", "(", ")", ")", ";", "if", "(", "$", "makeNew", ")", "{", "$", "copyObj", "->", "setNew", "(", "true", ")", ";", "$", "copyObj", "->", "setId", "(", "NULL", ")", ";", "// this is a auto-increment column, so set to default value", "}", "}" ]
Sets contents of passed object to values from current object. If desired, this method can also make copies of all associated (fkey referrers) objects. @param object $copyObj An object of \Alchemy\Component\Cerberus\Model\Log (or compatible) type. @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. @throws PropelException
[ "Sets", "contents", "of", "passed", "object", "to", "values", "from", "current", "object", "." ]
train
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/Log.php#L1458-L1474
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.usePackage
function usePackage($package, $scopes = []) { foreach((array) $scopes as $scope) { Manager::package($package) ->deferredScope($scope); } $this->require[$package] = $package; return $this; }
php
function usePackage($package, $scopes = []) { foreach((array) $scopes as $scope) { Manager::package($package) ->deferredScope($scope); } $this->require[$package] = $package; return $this; }
[ "function", "usePackage", "(", "$", "package", ",", "$", "scopes", "=", "[", "]", ")", "{", "foreach", "(", "(", "array", ")", "$", "scopes", "as", "$", "scope", ")", "{", "Manager", "::", "package", "(", "$", "package", ")", "->", "deferredScope", "(", "$", "scope", ")", ";", "}", "$", "this", "->", "require", "[", "$", "package", "]", "=", "$", "package", ";", "return", "$", "this", ";", "}" ]
Добавить пакет, от которого есть зависимость @param $package @return $this
[ "Добавить", "пакет", "от", "которого", "есть", "зависимость" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L37-L45
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.js
function js($js, $condition = null, $no_build = false) { $this->js[$js] = compact('condition', 'no_build'); return $this; }
php
function js($js, $condition = null, $no_build = false) { $this->js[$js] = compact('condition', 'no_build'); return $this; }
[ "function", "js", "(", "$", "js", ",", "$", "condition", "=", "null", ",", "$", "no_build", "=", "false", ")", "{", "$", "this", "->", "js", "[", "$", "js", "]", "=", "compact", "(", "'condition'", ",", "'no_build'", ")", ";", "return", "$", "this", ";", "}" ]
Добавить внешний JS @param $js @param null $condition @param bool $no_build @return $this
[ "Добавить", "внешний", "JS" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L60-L64
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.css
function css($css, $media = null, $condition = null, $no_build = false) { $this->css[$css] = compact('media', 'condition', 'no_build'); return $this; }
php
function css($css, $media = null, $condition = null, $no_build = false) { $this->css[$css] = compact('media', 'condition', 'no_build'); return $this; }
[ "function", "css", "(", "$", "css", ",", "$", "media", "=", "null", ",", "$", "condition", "=", "null", ",", "$", "no_build", "=", "false", ")", "{", "$", "this", "->", "css", "[", "$", "css", "]", "=", "compact", "(", "'media'", ",", "'condition'", ",", "'no_build'", ")", ";", "return", "$", "this", ";", "}" ]
Добавить внешний CSS @param $css @param null $media @param null $condition @param bool $no_build @return $this
[ "Добавить", "внешний", "CSS" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L76-L80
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.jsPackage
function jsPackage($js, $condition = null, $no_build = false) { return $this->js('/packages/' . $this->package . '/' . $js, $condition, $no_build); }
php
function jsPackage($js, $condition = null, $no_build = false) { return $this->js('/packages/' . $this->package . '/' . $js, $condition, $no_build); }
[ "function", "jsPackage", "(", "$", "js", ",", "$", "condition", "=", "null", ",", "$", "no_build", "=", "false", ")", "{", "return", "$", "this", "->", "js", "(", "'/packages/'", ".", "$", "this", "->", "package", ".", "'/'", ".", "$", "js", ",", "$", "condition", ",", "$", "no_build", ")", ";", "}" ]
Добавить JS из пакета @param $js @param null $condition @param bool $no_build @return Package
[ "Добавить", "JS", "из", "пакета" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L91-L93
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.cssPackage
function cssPackage($css, $media = null, $condition = null, $no_build = false) { return $this->css('/packages/' . $this->package . '/' . $css, $media, $condition, $no_build); }
php
function cssPackage($css, $media = null, $condition = null, $no_build = false) { return $this->css('/packages/' . $this->package . '/' . $css, $media, $condition, $no_build); }
[ "function", "cssPackage", "(", "$", "css", ",", "$", "media", "=", "null", ",", "$", "condition", "=", "null", ",", "$", "no_build", "=", "false", ")", "{", "return", "$", "this", "->", "css", "(", "'/packages/'", ".", "$", "this", "->", "package", ".", "'/'", ".", "$", "css", ",", "$", "media", ",", "$", "condition", ",", "$", "no_build", ")", ";", "}" ]
Добавить CSS из пакета @param $css @param null $media @param null $condition @param bool $no_build @return Package
[ "Добавить", "CSS", "из", "пакета" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L105-L107
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.scope
function scope($scope) { $styles = (array) Arr::get($this->scopes, $scope . '.css', []); $scripts = (array) Arr::get($this->scopes, $scope . '.js', []); foreach($styles as $style) { $this->css($style); } foreach($scripts as $script) { $this->js($script); } return $this; }
php
function scope($scope) { $styles = (array) Arr::get($this->scopes, $scope . '.css', []); $scripts = (array) Arr::get($this->scopes, $scope . '.js', []); foreach($styles as $style) { $this->css($style); } foreach($scripts as $script) { $this->js($script); } return $this; }
[ "function", "scope", "(", "$", "scope", ")", "{", "$", "styles", "=", "(", "array", ")", "Arr", "::", "get", "(", "$", "this", "->", "scopes", ",", "$", "scope", ".", "'.css'", ",", "[", "]", ")", ";", "$", "scripts", "=", "(", "array", ")", "Arr", "::", "get", "(", "$", "this", "->", "scopes", ",", "$", "scope", ".", "'.js'", ",", "[", "]", ")", ";", "foreach", "(", "$", "styles", "as", "$", "style", ")", "{", "$", "this", "->", "css", "(", "$", "style", ")", ";", "}", "foreach", "(", "$", "scripts", "as", "$", "script", ")", "{", "$", "this", "->", "js", "(", "$", "script", ")", ";", "}", "return", "$", "this", ";", "}" ]
Подключить именованный набор Manager::package('larakit/sf-flot') ->scope('pie'); В итоге вместе с базовыми стилями и скриптами пакета "sf-flot" подключатся скрипты и стили набора pie @param $scope @return Package
[ "Подключить", "именованный", "набор" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L138-L149
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.addExclude
function addExclude($exclude) { $exclude = func_get_args(); foreach($exclude as $v) { $this->exclude = array_merge($this->exclude, (array) $v); } return $this; }
php
function addExclude($exclude) { $exclude = func_get_args(); foreach($exclude as $v) { $this->exclude = array_merge($this->exclude, (array) $v); } return $this; }
[ "function", "addExclude", "(", "$", "exclude", ")", "{", "$", "exclude", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "exclude", "as", "$", "v", ")", "{", "$", "this", "->", "exclude", "=", "array_merge", "(", "$", "this", "->", "exclude", ",", "(", "array", ")", "$", "v", ")", ";", "}", "return", "$", "this", ";", "}" ]
Добавить список роутов, где пакет должен быть выключен @param $exclude string|array @return $this
[ "Добавить", "список", "роутов", "где", "пакет", "должен", "быть", "выключен" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L217-L224
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.on
function on() { if($this->is_used) { return true; } $route = \Route::currentRouteName(); $exclude = self::maxIs($this->exclude, $route); $include = self::maxIs($this->include, $route); if($exclude > $include || true === $exclude) { // исключаем } else { // подключаем //сперва подключим на страницу зависимости foreach((array) $this->require as $require => $scopes) { Manager::package($require) ->on(); } foreach($this->deferred_scopes as $scope) { $this->scope($scope); } //затем подключим CSS foreach($this->css as $url => $item) { $condition = Arr::get($item, 'condition', null); $media = Arr::get($item, 'media', null); $no_build = (bool) Arr::get($item, 'no_build', false); Css::instance() ->add($url, $media, $condition, $no_build); } //затем подключим JS foreach($this->js as $url => $item) { $condition = Arr::get($item, 'condition', null); $no_build = (int) Arr::get($item, 'no_build', false); Js::instance() ->add($url, $condition, $no_build); } } $this->is_used = true; return true; }
php
function on() { if($this->is_used) { return true; } $route = \Route::currentRouteName(); $exclude = self::maxIs($this->exclude, $route); $include = self::maxIs($this->include, $route); if($exclude > $include || true === $exclude) { // исключаем } else { // подключаем //сперва подключим на страницу зависимости foreach((array) $this->require as $require => $scopes) { Manager::package($require) ->on(); } foreach($this->deferred_scopes as $scope) { $this->scope($scope); } //затем подключим CSS foreach($this->css as $url => $item) { $condition = Arr::get($item, 'condition', null); $media = Arr::get($item, 'media', null); $no_build = (bool) Arr::get($item, 'no_build', false); Css::instance() ->add($url, $media, $condition, $no_build); } //затем подключим JS foreach($this->js as $url => $item) { $condition = Arr::get($item, 'condition', null); $no_build = (int) Arr::get($item, 'no_build', false); Js::instance() ->add($url, $condition, $no_build); } } $this->is_used = true; return true; }
[ "function", "on", "(", ")", "{", "if", "(", "$", "this", "->", "is_used", ")", "{", "return", "true", ";", "}", "$", "route", "=", "\\", "Route", "::", "currentRouteName", "(", ")", ";", "$", "exclude", "=", "self", "::", "maxIs", "(", "$", "this", "->", "exclude", ",", "$", "route", ")", ";", "$", "include", "=", "self", "::", "maxIs", "(", "$", "this", "->", "include", ",", "$", "route", ")", ";", "if", "(", "$", "exclude", ">", "$", "include", "||", "true", "===", "$", "exclude", ")", "{", "// исключаем\r", "}", "else", "{", "// подключаем\r", "//сперва подключим на страницу зависимости\r", "foreach", "(", "(", "array", ")", "$", "this", "->", "require", "as", "$", "require", "=>", "$", "scopes", ")", "{", "Manager", "::", "package", "(", "$", "require", ")", "->", "on", "(", ")", ";", "}", "foreach", "(", "$", "this", "->", "deferred_scopes", "as", "$", "scope", ")", "{", "$", "this", "->", "scope", "(", "$", "scope", ")", ";", "}", "//затем подключим CSS\r", "foreach", "(", "$", "this", "->", "css", "as", "$", "url", "=>", "$", "item", ")", "{", "$", "condition", "=", "Arr", "::", "get", "(", "$", "item", ",", "'condition'", ",", "null", ")", ";", "$", "media", "=", "Arr", "::", "get", "(", "$", "item", ",", "'media'", ",", "null", ")", ";", "$", "no_build", "=", "(", "bool", ")", "Arr", "::", "get", "(", "$", "item", ",", "'no_build'", ",", "false", ")", ";", "Css", "::", "instance", "(", ")", "->", "add", "(", "$", "url", ",", "$", "media", ",", "$", "condition", ",", "$", "no_build", ")", ";", "}", "//затем подключим JS\r", "foreach", "(", "$", "this", "->", "js", "as", "$", "url", "=>", "$", "item", ")", "{", "$", "condition", "=", "Arr", "::", "get", "(", "$", "item", ",", "'condition'", ",", "null", ")", ";", "$", "no_build", "=", "(", "int", ")", "Arr", "::", "get", "(", "$", "item", ",", "'no_build'", ",", "false", ")", ";", "Js", "::", "instance", "(", ")", "->", "add", "(", "$", "url", ",", "$", "condition", ",", "$", "no_build", ")", ";", "}", "}", "$", "this", "->", "is_used", "=", "true", ";", "return", "true", ";", "}" ]
Включение пакета с учетом правил использования include/exclude @return bool
[ "Включение", "пакета", "с", "учетом", "правил", "использования", "include", "/", "exclude" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L264-L304
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.maxIs
static protected function maxIs($input_array, $search) { $ret = 0; foreach((array) $input_array as $input) { $is = self::is($input, $search); if(true === $is) { return true; } $ret = max($is, $ret); } return $ret; }
php
static protected function maxIs($input_array, $search) { $ret = 0; foreach((array) $input_array as $input) { $is = self::is($input, $search); if(true === $is) { return true; } $ret = max($is, $ret); } return $ret; }
[ "static", "protected", "function", "maxIs", "(", "$", "input_array", ",", "$", "search", ")", "{", "$", "ret", "=", "0", ";", "foreach", "(", "(", "array", ")", "$", "input_array", "as", "$", "input", ")", "{", "$", "is", "=", "self", "::", "is", "(", "$", "input", ",", "$", "search", ")", ";", "if", "(", "true", "===", "$", "is", ")", "{", "return", "true", ";", "}", "$", "ret", "=", "max", "(", "$", "is", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}" ]
@param $input_array @param $search @return bool|int
[ "@param", "$input_array", "@param", "$search" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L312-L323
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.is
static protected function is($search, $current) { if($search == $current) { return true; } if('*' == $search) { return 1; } $pattern = preg_quote($search, '#'); $pattern = str_replace('\*', '.*', $pattern) . '\z'; $match = (bool) preg_match('#^' . $pattern . '#', $current); if($match) { return mb_strlen($search); } return false; }
php
static protected function is($search, $current) { if($search == $current) { return true; } if('*' == $search) { return 1; } $pattern = preg_quote($search, '#'); $pattern = str_replace('\*', '.*', $pattern) . '\z'; $match = (bool) preg_match('#^' . $pattern . '#', $current); if($match) { return mb_strlen($search); } return false; }
[ "static", "protected", "function", "is", "(", "$", "search", ",", "$", "current", ")", "{", "if", "(", "$", "search", "==", "$", "current", ")", "{", "return", "true", ";", "}", "if", "(", "'*'", "==", "$", "search", ")", "{", "return", "1", ";", "}", "$", "pattern", "=", "preg_quote", "(", "$", "search", ",", "'#'", ")", ";", "$", "pattern", "=", "str_replace", "(", "'\\*'", ",", "'.*'", ",", "$", "pattern", ")", ".", "'\\z'", ";", "$", "match", "=", "(", "bool", ")", "preg_match", "(", "'#^'", ".", "$", "pattern", ".", "'#'", ",", "$", "current", ")", ";", "if", "(", "$", "match", ")", "{", "return", "mb_strlen", "(", "$", "search", ")", ";", "}", "return", "false", ";", "}" ]
@param $search @param $current @return bool|int
[ "@param", "$search", "@param", "$current" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L331-L348
larakit/lk-staticfiles
src/StaticFiles/Package.php
Package.deploy
function deploy($output = null) { if(is_null($this->source_dir)) { return false; } if($output) { $styled = '<comment>Package "' . $this->package . '"</comment> deployed in <error>"/packages/' . $this->package . '"</error>'; $output->writeln($styled); } \File::copyDirectory(base_path('vendor/' . $this->package . '/' . $this->source_dir), public_path('packages/' . $this->package)); return true; }
php
function deploy($output = null) { if(is_null($this->source_dir)) { return false; } if($output) { $styled = '<comment>Package "' . $this->package . '"</comment> deployed in <error>"/packages/' . $this->package . '"</error>'; $output->writeln($styled); } \File::copyDirectory(base_path('vendor/' . $this->package . '/' . $this->source_dir), public_path('packages/' . $this->package)); return true; }
[ "function", "deploy", "(", "$", "output", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "source_dir", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "output", ")", "{", "$", "styled", "=", "'<comment>Package \"'", ".", "$", "this", "->", "package", ".", "'\"</comment> deployed in <error>\"/packages/'", ".", "$", "this", "->", "package", ".", "'\"</error>'", ";", "$", "output", "->", "writeln", "(", "$", "styled", ")", ";", "}", "\\", "File", "::", "copyDirectory", "(", "base_path", "(", "'vendor/'", ".", "$", "this", "->", "package", ".", "'/'", ".", "$", "this", "->", "source_dir", ")", ",", "public_path", "(", "'packages/'", ".", "$", "this", "->", "package", ")", ")", ";", "return", "true", ";", "}" ]
Выкладка пакета @return bool
[ "Выкладка", "пакета" ]
train
https://github.com/larakit/lk-staticfiles/blob/1ee718b1f3a00c29c46b06c2f501413599b0335a/src/StaticFiles/Package.php#L355-L366
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.setIdentifier
public function setIdentifier($identifier) { if (is_string($identifier)) { $this->identifier = $identifier; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($identifier). "' for argument 'identifier' given." ); } }
php
public function setIdentifier($identifier) { if (is_string($identifier)) { $this->identifier = $identifier; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($identifier). "' for argument 'identifier' given." ); } }
[ "public", "function", "setIdentifier", "(", "$", "identifier", ")", "{", "if", "(", "is_string", "(", "$", "identifier", ")", ")", "{", "$", "this", "->", "identifier", "=", "$", "identifier", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "identifier", ")", ".", "\"' for argument 'identifier' given.\"", ")", ";", "}", "}" ]
Sets the keyframes identifier. @param string $identifier
[ "Sets", "the", "keyframes", "identifier", "." ]
train
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L43-L52
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.addRule
public function addRule(RuleAbstract $rule) { // TODO Keyframes with duplicate identifiers do NOT cascade! // Last one overwrites previous ones. // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution if ($rule instanceof KeyframesRuleSet) { $this->rules[] = $rule; } else { throw new \InvalidArgumentException( "Invalid rule instance. Instance of 'KeyframesRuleSet' expected." ); } return $this; }
php
public function addRule(RuleAbstract $rule) { // TODO Keyframes with duplicate identifiers do NOT cascade! // Last one overwrites previous ones. // @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution if ($rule instanceof KeyframesRuleSet) { $this->rules[] = $rule; } else { throw new \InvalidArgumentException( "Invalid rule instance. Instance of 'KeyframesRuleSet' expected." ); } return $this; }
[ "public", "function", "addRule", "(", "RuleAbstract", "$", "rule", ")", "{", "// TODO Keyframes with duplicate identifiers do NOT cascade!", "// Last one overwrites previous ones.", "// @see https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes#Duplicate_resolution", "if", "(", "$", "rule", "instanceof", "KeyframesRuleSet", ")", "{", "$", "this", "->", "rules", "[", "]", "=", "$", "rule", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid rule instance. Instance of 'KeyframesRuleSet' expected.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a keyframes rule set. @param KeyframesRuleSet $rule @return $this
[ "Adds", "a", "keyframes", "rule", "set", "." ]
train
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L70-L85
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php
KeyframesRule.parseRuleString
protected function parseRuleString($ruleString) { if (is_string($ruleString)) { // Check for valid rule format // (with vendor prefix check to match e.g. "@-webkit-keyframes") if (preg_match( '/^[ \r\n\t\f]*@(' . self::getVendorPrefixRegExp("/") . ')?keyframes[ \r\n\t\f]+([^ \r\n\t\f]+)[ \r\n\t\f]*/i', $ruleString, $matches )) { $vendorPrefix = $matches[1]; $identifier = $matches[2]; $this->setIdentifier($identifier, $this->getStyleSheet()); if ($vendorPrefix !== "") { $this->setVendorPrefix($vendorPrefix); } } else { throw new \InvalidArgumentException("Invalid format for @keyframes rule."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given." ); } }
php
protected function parseRuleString($ruleString) { if (is_string($ruleString)) { // Check for valid rule format // (with vendor prefix check to match e.g. "@-webkit-keyframes") if (preg_match( '/^[ \r\n\t\f]*@(' . self::getVendorPrefixRegExp("/") . ')?keyframes[ \r\n\t\f]+([^ \r\n\t\f]+)[ \r\n\t\f]*/i', $ruleString, $matches )) { $vendorPrefix = $matches[1]; $identifier = $matches[2]; $this->setIdentifier($identifier, $this->getStyleSheet()); if ($vendorPrefix !== "") { $this->setVendorPrefix($vendorPrefix); } } else { throw new \InvalidArgumentException("Invalid format for @keyframes rule."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($ruleString). "' for argument 'ruleString' given." ); } }
[ "protected", "function", "parseRuleString", "(", "$", "ruleString", ")", "{", "if", "(", "is_string", "(", "$", "ruleString", ")", ")", "{", "// Check for valid rule format", "// (with vendor prefix check to match e.g. \"@-webkit-keyframes\")", "if", "(", "preg_match", "(", "'/^[ \\r\\n\\t\\f]*@('", ".", "self", "::", "getVendorPrefixRegExp", "(", "\"/\"", ")", ".", "')?keyframes[ \\r\\n\\t\\f]+([^ \\r\\n\\t\\f]+)[ \\r\\n\\t\\f]*/i'", ",", "$", "ruleString", ",", "$", "matches", ")", ")", "{", "$", "vendorPrefix", "=", "$", "matches", "[", "1", "]", ";", "$", "identifier", "=", "$", "matches", "[", "2", "]", ";", "$", "this", "->", "setIdentifier", "(", "$", "identifier", ",", "$", "this", "->", "getStyleSheet", "(", ")", ")", ";", "if", "(", "$", "vendorPrefix", "!==", "\"\"", ")", "{", "$", "this", "->", "setVendorPrefix", "(", "$", "vendorPrefix", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid format for @keyframes rule.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "ruleString", ")", ".", "\"' for argument 'ruleString' given.\"", ")", ";", "}", "}" ]
Parses the keyframes rule. @param string $ruleString
[ "Parses", "the", "keyframes", "rule", "." ]
train
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtKeyframes/KeyframesRule.php#L92-L116
harp-orm/query
src/Compiler/Union.php
Union.render
public static function render(Query\Union $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( Arr::join(' UNION ', Arr::map(function (Query\Select $select) { return Compiler::braced(Select::render($select)); }, $query->getSelects())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
php
public static function render(Query\Union $query) { return Compiler::withDb($query->getDb(), function () use ($query) { return Compiler::expression(array( Arr::join(' UNION ', Arr::map(function (Query\Select $select) { return Compiler::braced(Select::render($select)); }, $query->getSelects())), Compiler::word('ORDER BY', Direction::combine($query->getOrder())), Compiler::word('LIMIT', $query->getLimit()), )); }); }
[ "public", "static", "function", "render", "(", "Query", "\\", "Union", "$", "query", ")", "{", "return", "Compiler", "::", "withDb", "(", "$", "query", "->", "getDb", "(", ")", ",", "function", "(", ")", "use", "(", "$", "query", ")", "{", "return", "Compiler", "::", "expression", "(", "array", "(", "Arr", "::", "join", "(", "' UNION '", ",", "Arr", "::", "map", "(", "function", "(", "Query", "\\", "Select", "$", "select", ")", "{", "return", "Compiler", "::", "braced", "(", "Select", "::", "render", "(", "$", "select", ")", ")", ";", "}", ",", "$", "query", "->", "getSelects", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'ORDER BY'", ",", "Direction", "::", "combine", "(", "$", "query", "->", "getOrder", "(", ")", ")", ")", ",", "Compiler", "::", "word", "(", "'LIMIT'", ",", "$", "query", "->", "getLimit", "(", ")", ")", ",", ")", ")", ";", "}", ")", ";", "}" ]
Render a Union object @param Query\Union $query @return string
[ "Render", "a", "Union", "object" ]
train
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Union.php#L20-L31
comodojo/dispatcher.framework
src/Comodojo/Dispatcher/Response/Preprocessor.php
Preprocessor.get
public function get($status) { $preprocessor = $this->has($status) ? $this->preprocessors[$status] : $this->preprocessors[self::DEFAULT_STATUS]; return ($preprocessor instanceof HttpStatusPreprocessorInterface) ? $preprocessor : new $preprocessor; }
php
public function get($status) { $preprocessor = $this->has($status) ? $this->preprocessors[$status] : $this->preprocessors[self::DEFAULT_STATUS]; return ($preprocessor instanceof HttpStatusPreprocessorInterface) ? $preprocessor : new $preprocessor; }
[ "public", "function", "get", "(", "$", "status", ")", "{", "$", "preprocessor", "=", "$", "this", "->", "has", "(", "$", "status", ")", "?", "$", "this", "->", "preprocessors", "[", "$", "status", "]", ":", "$", "this", "->", "preprocessors", "[", "self", "::", "DEFAULT_STATUS", "]", ";", "return", "(", "$", "preprocessor", "instanceof", "HttpStatusPreprocessorInterface", ")", "?", "$", "preprocessor", ":", "new", "$", "preprocessor", ";", "}" ]
Get an instance of the preprocessor for the current status @param int $status The HTTP status to use @return HttpStatusPreprocessorInterface
[ "Get", "an", "instance", "of", "the", "preprocessor", "for", "the", "current", "status" ]
train
https://github.com/comodojo/dispatcher.framework/blob/5093297dcb7441a8d8f79cbb2429c93232e16d1c/src/Comodojo/Dispatcher/Response/Preprocessor.php#L86-L95
movoin/one-swoole
src/Event/Event.php
Event.getContext
public function getContext(): Context { if ($this->context === null) { $this->context = new Context; } return $this->context; }
php
public function getContext(): Context { if ($this->context === null) { $this->context = new Context; } return $this->context; }
[ "public", "function", "getContext", "(", ")", ":", "Context", "{", "if", "(", "$", "this", "->", "context", "===", "null", ")", "{", "$", "this", "->", "context", "=", "new", "Context", ";", "}", "return", "$", "this", "->", "context", ";", "}" ]
获得事件上下文 @return \One\Event\Context
[ "获得事件上下文" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Event/Event.php#L65-L72
movoin/one-swoole
src/Event/Event.php
Event.setContexts
public function setContexts($contexts) { if ($contexts) { foreach ((array) $contexts as $name => $value) { $this->getContext()->set($name, $value); } } }
php
public function setContexts($contexts) { if ($contexts) { foreach ((array) $contexts as $name => $value) { $this->getContext()->set($name, $value); } } }
[ "public", "function", "setContexts", "(", "$", "contexts", ")", "{", "if", "(", "$", "contexts", ")", "{", "foreach", "(", "(", "array", ")", "$", "contexts", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "getContext", "(", ")", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "}" ]
设置事件上下文 @param array $contexts
[ "设置事件上下文" ]
train
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Event/Event.php#L79-L86
prooph/link-app-core
src/Service/Factory/RiotTagCollectionResolverFactory.php
RiotTagCollectionResolverFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $collections = array(); if (isset($config['asset_manager']['resolver_configs']['riot-tags'])) { $collections = $config['asset_manager']['resolver_configs']['riot-tags']; } return new RiotTagCollectionResolver($collections, $serviceLocator->get('ViewHelperManager')->get('riotTag')); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('Config'); $collections = array(); if (isset($config['asset_manager']['resolver_configs']['riot-tags'])) { $collections = $config['asset_manager']['resolver_configs']['riot-tags']; } return new RiotTagCollectionResolver($collections, $serviceLocator->get('ViewHelperManager')->get('riotTag')); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'Config'", ")", ";", "$", "collections", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'asset_manager'", "]", "[", "'resolver_configs'", "]", "[", "'riot-tags'", "]", ")", ")", "{", "$", "collections", "=", "$", "config", "[", "'asset_manager'", "]", "[", "'resolver_configs'", "]", "[", "'riot-tags'", "]", ";", "}", "return", "new", "RiotTagCollectionResolver", "(", "$", "collections", ",", "$", "serviceLocator", "->", "get", "(", "'ViewHelperManager'", ")", "->", "get", "(", "'riotTag'", ")", ")", ";", "}" ]
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
[ "Create", "service" ]
train
https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Service/Factory/RiotTagCollectionResolverFactory.php#L33-L43
seeren/http
src/Uri/AbstractUri.php
AbstractUri.getAuthority
public final function getAuthority(): string { return ($this->user ? $this->user . static::USER_SEPARATOR : "") . $this->host . ($this->port ? static::HOST_SEPARATOR . $this->port : ""); }
php
public final function getAuthority(): string { return ($this->user ? $this->user . static::USER_SEPARATOR : "") . $this->host . ($this->port ? static::HOST_SEPARATOR . $this->port : ""); }
[ "public", "final", "function", "getAuthority", "(", ")", ":", "string", "{", "return", "(", "$", "this", "->", "user", "?", "$", "this", "->", "user", ".", "static", "::", "USER_SEPARATOR", ":", "\"\"", ")", ".", "$", "this", "->", "host", ".", "(", "$", "this", "->", "port", "?", "static", "::", "HOST_SEPARATOR", ".", "$", "this", "->", "port", ":", "\"\"", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::getAuthority()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L169-L174
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withScheme
public final function withScheme($scheme): UriInterface { if (!is_string($scheme) || !($parsedScheme = $this->parseScheme($scheme)) || $parsedScheme !== strtolower($scheme)) { throw new InvalidArgumentException( "Can't get with scheme: not supported"); } return $this->with("scheme", $parsedScheme); }
php
public final function withScheme($scheme): UriInterface { if (!is_string($scheme) || !($parsedScheme = $this->parseScheme($scheme)) || $parsedScheme !== strtolower($scheme)) { throw new InvalidArgumentException( "Can't get with scheme: not supported"); } return $this->with("scheme", $parsedScheme); }
[ "public", "final", "function", "withScheme", "(", "$", "scheme", ")", ":", "UriInterface", "{", "if", "(", "!", "is_string", "(", "$", "scheme", ")", "||", "!", "(", "$", "parsedScheme", "=", "$", "this", "->", "parseScheme", "(", "$", "scheme", ")", ")", "||", "$", "parsedScheme", "!==", "strtolower", "(", "$", "scheme", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Can't get with scheme: not supported\"", ")", ";", "}", "return", "$", "this", "->", "with", "(", "\"scheme\"", ",", "$", "parsedScheme", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withScheme()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L234-L243
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withUserInfo
public final function withUserInfo($user, $password = null): UriInterface { return $this->with( "user", $user . ($password ? static::HOST_SEPARATOR . $password: "")); }
php
public final function withUserInfo($user, $password = null): UriInterface { return $this->with( "user", $user . ($password ? static::HOST_SEPARATOR . $password: "")); }
[ "public", "final", "function", "withUserInfo", "(", "$", "user", ",", "$", "password", "=", "null", ")", ":", "UriInterface", "{", "return", "$", "this", "->", "with", "(", "\"user\"", ",", "$", "user", ".", "(", "$", "password", "?", "static", "::", "HOST_SEPARATOR", ".", "$", "password", ":", "\"\"", ")", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withUserInfo()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L249-L254
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withHost
public final function withHost($host): UriInterface { if (!is_string($host) || !($parsedHost = $this->parseHost($host))) { throw new InvalidArgumentException( "Can't get with host: invalid host name"); } return $this->with("host", $parsedHost); }
php
public final function withHost($host): UriInterface { if (!is_string($host) || !($parsedHost = $this->parseHost($host))) { throw new InvalidArgumentException( "Can't get with host: invalid host name"); } return $this->with("host", $parsedHost); }
[ "public", "final", "function", "withHost", "(", "$", "host", ")", ":", "UriInterface", "{", "if", "(", "!", "is_string", "(", "$", "host", ")", "||", "!", "(", "$", "parsedHost", "=", "$", "this", "->", "parseHost", "(", "$", "host", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Can't get with host: invalid host name\"", ")", ";", "}", "return", "$", "this", "->", "with", "(", "\"host\"", ",", "$", "parsedHost", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withHost()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L260-L267
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withPort
public final function withPort($port): UriInterface { if (!is_int($port) || !($parsedPort = $this->parsePort($port))) { throw new InvalidArgumentException( "Can't get with port: invalid port range"); } return $this->with("port", $parsedPort); }
php
public final function withPort($port): UriInterface { if (!is_int($port) || !($parsedPort = $this->parsePort($port))) { throw new InvalidArgumentException( "Can't get with port: invalid port range"); } return $this->with("port", $parsedPort); }
[ "public", "final", "function", "withPort", "(", "$", "port", ")", ":", "UriInterface", "{", "if", "(", "!", "is_int", "(", "$", "port", ")", "||", "!", "(", "$", "parsedPort", "=", "$", "this", "->", "parsePort", "(", "$", "port", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Can't get with port: invalid port range\"", ")", ";", "}", "return", "$", "this", "->", "with", "(", "\"port\"", ",", "$", "parsedPort", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withPort()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L273-L281
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withPath
public function withPath($path): UriInterface { if (!is_string($path) || !($parsedPath = $this->parsePath($path))) { throw new InvalidArgumentException( "Can't get with path: invalid expression"); } return $this->with("path", $parsedPath); }
php
public function withPath($path): UriInterface { if (!is_string($path) || !($parsedPath = $this->parsePath($path))) { throw new InvalidArgumentException( "Can't get with path: invalid expression"); } return $this->with("path", $parsedPath); }
[ "public", "function", "withPath", "(", "$", "path", ")", ":", "UriInterface", "{", "if", "(", "!", "is_string", "(", "$", "path", ")", "||", "!", "(", "$", "parsedPath", "=", "$", "this", "->", "parsePath", "(", "$", "path", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Can't get with path: invalid expression\"", ")", ";", "}", "return", "$", "this", "->", "with", "(", "\"path\"", ",", "$", "parsedPath", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withPath()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L287-L295
seeren/http
src/Uri/AbstractUri.php
AbstractUri.withQuery
public final function withQuery($query): UriInterface { if (!is_string($query)) { throw new InvalidArgumentException( "Can't get with query: invalid query string"); } return $this->with("query", $this->parseQuery($query)); }
php
public final function withQuery($query): UriInterface { if (!is_string($query)) { throw new InvalidArgumentException( "Can't get with query: invalid query string"); } return $this->with("query", $this->parseQuery($query)); }
[ "public", "final", "function", "withQuery", "(", "$", "query", ")", ":", "UriInterface", "{", "if", "(", "!", "is_string", "(", "$", "query", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Can't get with query: invalid query string\"", ")", ";", "}", "return", "$", "this", "->", "with", "(", "\"query\"", ",", "$", "this", "->", "parseQuery", "(", "$", "query", ")", ")", ";", "}" ]
{@inheritDoc} @see \Psr\Http\Message\UriInterface::withQuery()
[ "{" ]
train
https://github.com/seeren/http/blob/b5e692e085c41fe25714d17ee90ba78eaf1923c4/src/Uri/AbstractUri.php#L301-L308
alexpts/psr15-middlewares
src/HasRequestAttributeName.php
HasRequestAttributeName.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $request = $this->checkAttributes($request, $this->attributes); return $handler->handle($request); }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $request = $this->checkAttributes($request, $this->attributes); return $handler->handle($request); }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "$", "request", "=", "$", "this", "->", "checkAttributes", "(", "$", "request", ",", "$", "this", "->", "attributes", ")", ";", "return", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "}" ]
@param ServerRequestInterface $request @param RequestHandlerInterface $handler @return ResponseInterface @throws \InvalidArgumentException @throws Exception
[ "@param", "ServerRequestInterface", "$request", "@param", "RequestHandlerInterface", "$handler" ]
train
https://github.com/alexpts/psr15-middlewares/blob/bff2887d5af01c54d9288fd19c20f0f593b69358/src/HasRequestAttributeName.php#L34-L39
alexpts/psr15-middlewares
src/HasRequestAttributeName.php
HasRequestAttributeName.checkAttributes
protected function checkAttributes(ServerRequestInterface $request, array $attributes): ServerRequestInterface { foreach ($attributes as $name) { if (!$request->getAttribute($name)) { throw $this->exception; } } return $request; }
php
protected function checkAttributes(ServerRequestInterface $request, array $attributes): ServerRequestInterface { foreach ($attributes as $name) { if (!$request->getAttribute($name)) { throw $this->exception; } } return $request; }
[ "protected", "function", "checkAttributes", "(", "ServerRequestInterface", "$", "request", ",", "array", "$", "attributes", ")", ":", "ServerRequestInterface", "{", "foreach", "(", "$", "attributes", "as", "$", "name", ")", "{", "if", "(", "!", "$", "request", "->", "getAttribute", "(", "$", "name", ")", ")", "{", "throw", "$", "this", "->", "exception", ";", "}", "}", "return", "$", "request", ";", "}" ]
@param ServerRequestInterface $request @param array $attributes @return ServerRequestInterface @throws Exception
[ "@param", "ServerRequestInterface", "$request", "@param", "array", "$attributes" ]
train
https://github.com/alexpts/psr15-middlewares/blob/bff2887d5af01c54d9288fd19c20f0f593b69358/src/HasRequestAttributeName.php#L48-L57
wpottier/WizadSettingsBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('wizad_settings'); $rootNode ->addDefaultsIfNotSet() ->children() ->scalarNode('config_file_parser')->defaultValue('\Wizad\SettingsBundle\Parser\XmlFileLoader')->end() ->arrayNode('redis') ->info('redis access') ->children() ->scalarNode('dsn')->defaultValue('tcp://127.0.0.1:6379')->isRequired()->end() ->scalarNode('prefix')->defaultValue("symfony.parameters.dynamic")->end() ->end() ->end() ->arrayNode('mysql') ->info('mysql access') ->children() ->scalarNode('host')->defaultValue('localhost')->isRequired()->end() ->scalarNode('user')->defaultValue("")->isRequired()->end() ->scalarNode('password')->defaultValue("")->isRequired()->end() ->scalarNode('dbname')->defaultValue("settings")->isRequired()->end() ->end() ->end() ->arrayNode('bundles') ->defaultValue($this->bundles) ->prototype('scalar') ->validate() ->ifNotInArray($this->bundles) ->thenInvalid('%s is not a valid bundle.') ->end() ->end() ->end(); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('wizad_settings'); $rootNode ->addDefaultsIfNotSet() ->children() ->scalarNode('config_file_parser')->defaultValue('\Wizad\SettingsBundle\Parser\XmlFileLoader')->end() ->arrayNode('redis') ->info('redis access') ->children() ->scalarNode('dsn')->defaultValue('tcp://127.0.0.1:6379')->isRequired()->end() ->scalarNode('prefix')->defaultValue("symfony.parameters.dynamic")->end() ->end() ->end() ->arrayNode('mysql') ->info('mysql access') ->children() ->scalarNode('host')->defaultValue('localhost')->isRequired()->end() ->scalarNode('user')->defaultValue("")->isRequired()->end() ->scalarNode('password')->defaultValue("")->isRequired()->end() ->scalarNode('dbname')->defaultValue("settings")->isRequired()->end() ->end() ->end() ->arrayNode('bundles') ->defaultValue($this->bundles) ->prototype('scalar') ->validate() ->ifNotInArray($this->bundles) ->thenInvalid('%s is not a valid bundle.') ->end() ->end() ->end(); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'wizad_settings'", ")", ";", "$", "rootNode", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'config_file_parser'", ")", "->", "defaultValue", "(", "'\\Wizad\\SettingsBundle\\Parser\\XmlFileLoader'", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'redis'", ")", "->", "info", "(", "'redis access'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'dsn'", ")", "->", "defaultValue", "(", "'tcp://127.0.0.1:6379'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'prefix'", ")", "->", "defaultValue", "(", "\"symfony.parameters.dynamic\"", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'mysql'", ")", "->", "info", "(", "'mysql access'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'host'", ")", "->", "defaultValue", "(", "'localhost'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'user'", ")", "->", "defaultValue", "(", "\"\"", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'password'", ")", "->", "defaultValue", "(", "\"\"", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'dbname'", ")", "->", "defaultValue", "(", "\"settings\"", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'bundles'", ")", "->", "defaultValue", "(", "$", "this", "->", "bundles", ")", "->", "prototype", "(", "'scalar'", ")", "->", "validate", "(", ")", "->", "ifNotInArray", "(", "$", "this", "->", "bundles", ")", "->", "thenInvalid", "(", "'%s is not a valid bundle.'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/DependencyInjection/Configuration.php#L39-L76
hrevert/HtUserRegistration
src/Mapper/UserRegistrationMapper.php
UserRegistrationMapper.findByUser
public function findByUser(UserInterface $user) { $select = $this->getSelect(); $select->where(array('user_id' => $user->getId())); $entity = $this->select($select)->current(); if ($entity instanceof UserRegistrationInterface) { $entity->setUser($user); } return $entity; }
php
public function findByUser(UserInterface $user) { $select = $this->getSelect(); $select->where(array('user_id' => $user->getId())); $entity = $this->select($select)->current(); if ($entity instanceof UserRegistrationInterface) { $entity->setUser($user); } return $entity; }
[ "public", "function", "findByUser", "(", "UserInterface", "$", "user", ")", "{", "$", "select", "=", "$", "this", "->", "getSelect", "(", ")", ";", "$", "select", "->", "where", "(", "array", "(", "'user_id'", "=>", "$", "user", "->", "getId", "(", ")", ")", ")", ";", "$", "entity", "=", "$", "this", "->", "select", "(", "$", "select", ")", "->", "current", "(", ")", ";", "if", "(", "$", "entity", "instanceof", "UserRegistrationInterface", ")", "{", "$", "entity", "->", "setUser", "(", "$", "user", ")", ";", "}", "return", "$", "entity", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/hrevert/HtUserRegistration/blob/6b4a0cc364153757290ab5eed9ffafe1228f3bd6/src/Mapper/UserRegistrationMapper.php#L19-L29
hrevert/HtUserRegistration
src/Mapper/UserRegistrationMapper.php
UserRegistrationMapper.insert
public function insert($entity, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($entity, __METHOD__); return parent::insert($entity); }
php
public function insert($entity, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($entity, __METHOD__); return parent::insert($entity); }
[ "public", "function", "insert", "(", "$", "entity", ",", "$", "tableName", "=", "null", ",", "HydratorInterface", "$", "hydrator", "=", "null", ")", "{", "$", "this", "->", "checkEntity", "(", "$", "entity", ",", "__METHOD__", ")", ";", "return", "parent", "::", "insert", "(", "$", "entity", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/hrevert/HtUserRegistration/blob/6b4a0cc364153757290ab5eed9ffafe1228f3bd6/src/Mapper/UserRegistrationMapper.php#L34-L39
hrevert/HtUserRegistration
src/Mapper/UserRegistrationMapper.php
UserRegistrationMapper.update
public function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($entity, __METHOD__); if (!$where) { $where = array('user_id' => $entity->getUser()->getId()); } return parent::update($entity, $where); }
php
public function update($entity, $where = null, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($entity, __METHOD__); if (!$where) { $where = array('user_id' => $entity->getUser()->getId()); } return parent::update($entity, $where); }
[ "public", "function", "update", "(", "$", "entity", ",", "$", "where", "=", "null", ",", "$", "tableName", "=", "null", ",", "HydratorInterface", "$", "hydrator", "=", "null", ")", "{", "$", "this", "->", "checkEntity", "(", "$", "entity", ",", "__METHOD__", ")", ";", "if", "(", "!", "$", "where", ")", "{", "$", "where", "=", "array", "(", "'user_id'", "=>", "$", "entity", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", ";", "}", "return", "parent", "::", "update", "(", "$", "entity", ",", "$", "where", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/hrevert/HtUserRegistration/blob/6b4a0cc364153757290ab5eed9ffafe1228f3bd6/src/Mapper/UserRegistrationMapper.php#L44-L52
awesomite/chariot
src/Pattern/StdPatterns/ListPattern.php
ListPattern.normalizeToUrl
private function normalizeToUrl($data) { if (\is_object($data)) { if ($data instanceof \Traversable) { return \iterator_to_array($data); } if (\method_exists($data, '__toString')) { return (string) $data; } } if (\is_array($data)) { return $data; } if (\is_scalar($data) && !\is_bool($data)) { return (string) $data; } throw $this->newInvalidToUrl($data); }
php
private function normalizeToUrl($data) { if (\is_object($data)) { if ($data instanceof \Traversable) { return \iterator_to_array($data); } if (\method_exists($data, '__toString')) { return (string) $data; } } if (\is_array($data)) { return $data; } if (\is_scalar($data) && !\is_bool($data)) { return (string) $data; } throw $this->newInvalidToUrl($data); }
[ "private", "function", "normalizeToUrl", "(", "$", "data", ")", "{", "if", "(", "\\", "is_object", "(", "$", "data", ")", ")", "{", "if", "(", "$", "data", "instanceof", "\\", "Traversable", ")", "{", "return", "\\", "iterator_to_array", "(", "$", "data", ")", ";", "}", "if", "(", "\\", "method_exists", "(", "$", "data", ",", "'__toString'", ")", ")", "{", "return", "(", "string", ")", "$", "data", ";", "}", "}", "if", "(", "\\", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "if", "(", "\\", "is_scalar", "(", "$", "data", ")", "&&", "!", "\\", "is_bool", "(", "$", "data", ")", ")", "{", "return", "(", "string", ")", "$", "data", ";", "}", "throw", "$", "this", "->", "newInvalidToUrl", "(", "$", "data", ")", ";", "}" ]
@param $data @return array|string
[ "@param", "$data" ]
train
https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/StdPatterns/ListPattern.php#L51-L72
gdbots/pbjx-bundle-php
src/Twig/PbjxExtension.php
PbjxExtension.pbjUrl
public function pbjUrl(Message $pbj, string $template): ?string { return UriTemplateService::expand("{$pbj::schema()->getQName()}.{$template}", $pbj->getUriTemplateVars()); }
php
public function pbjUrl(Message $pbj, string $template): ?string { return UriTemplateService::expand("{$pbj::schema()->getQName()}.{$template}", $pbj->getUriTemplateVars()); }
[ "public", "function", "pbjUrl", "(", "Message", "$", "pbj", ",", "string", "$", "template", ")", ":", "?", "string", "{", "return", "UriTemplateService", "::", "expand", "(", "\"{$pbj::schema()->getQName()}.{$template}\"", ",", "$", "pbj", "->", "getUriTemplateVars", "(", ")", ")", ";", "}" ]
Returns a named URL to a pbj instance. Example: {{ pbj_url(pbj, 'canonical') }} @param Message $pbj @param string $template @return string
[ "Returns", "a", "named", "URL", "to", "a", "pbj", "instance", "." ]
train
https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Twig/PbjxExtension.php#L109-L112
gdbots/pbjx-bundle-php
src/Twig/PbjxExtension.php
PbjxExtension.pbjxRequest
public function pbjxRequest(string $curie, array $data = []): ?Response { try { /** @var Request $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($curie)); $request = $class::fromArray($data); if (!$request instanceof Request) { throw new InvalidArgumentException(sprintf('The provided curie [%s] is not a request.', $curie)); } // ensures permission check is bypassed $request->set('ctx_causator_ref', $request->generateMessageRef()); $response = $this->pbjx->request($request); if (!$response->has('ctx_request')) { $response->set('ctx_request', $request); } return $response; } catch (\Throwable $e) { if ($this->debug) { throw $e; } $this->logger->warning( 'Unable to process twig "pbjx_request" function for [{curie}].', ['exception' => $e, 'curie' => $curie, 'data' => $data] ); } return null; }
php
public function pbjxRequest(string $curie, array $data = []): ?Response { try { /** @var Request $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($curie)); $request = $class::fromArray($data); if (!$request instanceof Request) { throw new InvalidArgumentException(sprintf('The provided curie [%s] is not a request.', $curie)); } // ensures permission check is bypassed $request->set('ctx_causator_ref', $request->generateMessageRef()); $response = $this->pbjx->request($request); if (!$response->has('ctx_request')) { $response->set('ctx_request', $request); } return $response; } catch (\Throwable $e) { if ($this->debug) { throw $e; } $this->logger->warning( 'Unable to process twig "pbjx_request" function for [{curie}].', ['exception' => $e, 'curie' => $curie, 'data' => $data] ); } return null; }
[ "public", "function", "pbjxRequest", "(", "string", "$", "curie", ",", "array", "$", "data", "=", "[", "]", ")", ":", "?", "Response", "{", "try", "{", "/** @var Request $class */", "$", "class", "=", "MessageResolver", "::", "resolveCurie", "(", "SchemaCurie", "::", "fromString", "(", "$", "curie", ")", ")", ";", "$", "request", "=", "$", "class", "::", "fromArray", "(", "$", "data", ")", ";", "if", "(", "!", "$", "request", "instanceof", "Request", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The provided curie [%s] is not a request.'", ",", "$", "curie", ")", ")", ";", "}", "// ensures permission check is bypassed", "$", "request", "->", "set", "(", "'ctx_causator_ref'", ",", "$", "request", "->", "generateMessageRef", "(", ")", ")", ";", "$", "response", "=", "$", "this", "->", "pbjx", "->", "request", "(", "$", "request", ")", ";", "if", "(", "!", "$", "response", "->", "has", "(", "'ctx_request'", ")", ")", "{", "$", "response", "->", "set", "(", "'ctx_request'", ",", "$", "request", ")", ";", "}", "return", "$", "response", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "if", "(", "$", "this", "->", "debug", ")", "{", "throw", "$", "e", ";", "}", "$", "this", "->", "logger", "->", "warning", "(", "'Unable to process twig \"pbjx_request\" function for [{curie}].'", ",", "[", "'exception'", "=>", "$", "e", ",", "'curie'", "=>", "$", "curie", ",", "'data'", "=>", "$", "data", "]", ")", ";", "}", "return", "null", ";", "}" ]
Performs a pbjx->request and returns the response. If debugging is enabled an exception will be thrown (generally in dev), otherwise it will be logged and null will be returned. Example: {% set pbjx_response = pbjx_request('acme:blog:request:get-comments-request', {'article_id':id}) %} {% if pbjx_response %} {% include pbj_template(pbjx_response, 'list', device_view) with {'pbj': pbjx_response} %} {% endif %} @param string $curie @param array $data @return Response|null @throws \Throwable
[ "Performs", "a", "pbjx", "-", ">", "request", "and", "returns", "the", "response", ".", "If", "debugging", "is", "enabled", "an", "exception", "will", "be", "thrown", "(", "generally", "in", "dev", ")", "otherwise", "it", "will", "be", "logged", "and", "null", "will", "be", "returned", "." ]
train
https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Twig/PbjxExtension.php#L147-L178
whatthejeff/fab-phpunit-resultprinter
src/Fab/PHPUnit/ResultPrinter.php
ResultPrinter.writeProgress
protected function writeProgress($progress) { if ($progress == '.') { $progress = $this->fab->paintChar('*'); } parent::writeProgress($progress); }
php
protected function writeProgress($progress) { if ($progress == '.') { $progress = $this->fab->paintChar('*'); } parent::writeProgress($progress); }
[ "protected", "function", "writeProgress", "(", "$", "progress", ")", "{", "if", "(", "$", "progress", "==", "'.'", ")", "{", "$", "progress", "=", "$", "this", "->", "fab", "->", "paintChar", "(", "'*'", ")", ";", "}", "parent", "::", "writeProgress", "(", "$", "progress", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/whatthejeff/fab-phpunit-resultprinter/blob/0b30213e552ce2f02757e64865692faf9d5a8987/src/Fab/PHPUnit/ResultPrinter.php#L42-L49
huasituo/hstcms
src/Http/Controllers/Manage/MenuController.php
MenuController.role
public function role(Request $request) { if($request->get('_ajax')) { $ename = $request->input('ename'); $parent = $request->input('parent'); $uri = $request->input('uri'); $query = CommonRoleUriModel::where('id', '>', 0); if($ename) { $query->where('ename', $ename); } if($uri) { $query->where('uri', $uri); } if($parent) { $query->where('parent', $parent); } $list = $query->orderby('id', 'desc')->paginate($this->paginate); $this->addMessage($list, 'list'); return $this->showMessage('Hstcms::public.successful'); } $view = [ 'navs'=>$this->getNavs('operation') ]; $this->navs = [ 'nav'=>['name'=>hst_lang('hstcms::public.menu'), 'url'=>'manageMenuNav'], 'role'=>['name'=>hst_lang('hstcms::manage.role.uri'), 'url'=>'manageMenuRole'], 'add'=>['name'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri'), 'url'=>'manageMenuRoleAdd', 'class'=>'J_dialogs', 'title'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri')] ]; $view = [ 'navs'=>$this->getNavs('role') ]; return $this->loadTemplate('menu.role', $view); }
php
public function role(Request $request) { if($request->get('_ajax')) { $ename = $request->input('ename'); $parent = $request->input('parent'); $uri = $request->input('uri'); $query = CommonRoleUriModel::where('id', '>', 0); if($ename) { $query->where('ename', $ename); } if($uri) { $query->where('uri', $uri); } if($parent) { $query->where('parent', $parent); } $list = $query->orderby('id', 'desc')->paginate($this->paginate); $this->addMessage($list, 'list'); return $this->showMessage('Hstcms::public.successful'); } $view = [ 'navs'=>$this->getNavs('operation') ]; $this->navs = [ 'nav'=>['name'=>hst_lang('hstcms::public.menu'), 'url'=>'manageMenuNav'], 'role'=>['name'=>hst_lang('hstcms::manage.role.uri'), 'url'=>'manageMenuRole'], 'add'=>['name'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri'), 'url'=>'manageMenuRoleAdd', 'class'=>'J_dialogs', 'title'=>hst_lang('hstcms::public.add', 'hstcms::manage.role.uri')] ]; $view = [ 'navs'=>$this->getNavs('role') ]; return $this->loadTemplate('menu.role', $view); }
[ "public", "function", "role", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "get", "(", "'_ajax'", ")", ")", "{", "$", "ename", "=", "$", "request", "->", "input", "(", "'ename'", ")", ";", "$", "parent", "=", "$", "request", "->", "input", "(", "'parent'", ")", ";", "$", "uri", "=", "$", "request", "->", "input", "(", "'uri'", ")", ";", "$", "query", "=", "CommonRoleUriModel", "::", "where", "(", "'id'", ",", "'>'", ",", "0", ")", ";", "if", "(", "$", "ename", ")", "{", "$", "query", "->", "where", "(", "'ename'", ",", "$", "ename", ")", ";", "}", "if", "(", "$", "uri", ")", "{", "$", "query", "->", "where", "(", "'uri'", ",", "$", "uri", ")", ";", "}", "if", "(", "$", "parent", ")", "{", "$", "query", "->", "where", "(", "'parent'", ",", "$", "parent", ")", ";", "}", "$", "list", "=", "$", "query", "->", "orderby", "(", "'id'", ",", "'desc'", ")", "->", "paginate", "(", "$", "this", "->", "paginate", ")", ";", "$", "this", "->", "addMessage", "(", "$", "list", ",", "'list'", ")", ";", "return", "$", "this", "->", "showMessage", "(", "'Hstcms::public.successful'", ")", ";", "}", "$", "view", "=", "[", "'navs'", "=>", "$", "this", "->", "getNavs", "(", "'operation'", ")", "]", ";", "$", "this", "->", "navs", "=", "[", "'nav'", "=>", "[", "'name'", "=>", "hst_lang", "(", "'hstcms::public.menu'", ")", ",", "'url'", "=>", "'manageMenuNav'", "]", ",", "'role'", "=>", "[", "'name'", "=>", "hst_lang", "(", "'hstcms::manage.role.uri'", ")", ",", "'url'", "=>", "'manageMenuRole'", "]", ",", "'add'", "=>", "[", "'name'", "=>", "hst_lang", "(", "'hstcms::public.add'", ",", "'hstcms::manage.role.uri'", ")", ",", "'url'", "=>", "'manageMenuRoleAdd'", ",", "'class'", "=>", "'J_dialogs'", ",", "'title'", "=>", "hst_lang", "(", "'hstcms::public.add'", ",", "'hstcms::manage.role.uri'", ")", "]", "]", ";", "$", "view", "=", "[", "'navs'", "=>", "$", "this", "->", "getNavs", "(", "'role'", ")", "]", ";", "return", "$", "this", "->", "loadTemplate", "(", "'menu.role'", ",", "$", "view", ")", ";", "}" ]
====================================
[ "====================================" ]
train
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Http/Controllers/Manage/MenuController.php#L144-L176
FrenchFrogs/framework
src/Modal/Modal/Modal.php
Modal.appendAction
public function appendAction(FrenchFrogs\Form\Element\Button $action) { $this->actions[] = $action; return $this; }
php
public function appendAction(FrenchFrogs\Form\Element\Button $action) { $this->actions[] = $action; return $this; }
[ "public", "function", "appendAction", "(", "FrenchFrogs", "\\", "Form", "\\", "Element", "\\", "Button", "$", "action", ")", "{", "$", "this", "->", "actions", "[", "]", "=", "$", "action", ";", "return", "$", "this", ";", "}" ]
Push one element to the end of the $actions container @param \FrenchFrogs\Form\Element\Button $action @return $this
[ "Push", "one", "element", "to", "the", "end", "of", "the", "$actions", "container" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Modal/Modal/Modal.php#L485-L489
FrenchFrogs/framework
src/Modal/Modal/Modal.php
Modal.prependAction
public function prependAction(FrenchFrogs\Form\Element\Button $action) { array_unshift($this->actions, $action); return $this; }
php
public function prependAction(FrenchFrogs\Form\Element\Button $action) { array_unshift($this->actions, $action); return $this; }
[ "public", "function", "prependAction", "(", "FrenchFrogs", "\\", "Form", "\\", "Element", "\\", "Button", "$", "action", ")", "{", "array_unshift", "(", "$", "this", "->", "actions", ",", "$", "action", ")", ";", "return", "$", "this", ";", "}" ]
Prepend one elements to the beginning of the $actions container @param \FrenchFrogs\Form\Element\Button $action @return $this
[ "Prepend", "one", "elements", "to", "the", "beginning", "of", "the", "$actions", "container" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Modal/Modal/Modal.php#L497-L501
FrenchFrogs/framework
src/Modal/Modal/Modal.php
Modal.renderRemoteEmptyModal
static function renderRemoteEmptyModal($remoteId = null) { $modal = modal(); if (!is_null($remoteId)) { $modal->setRemoteId($remoteId); } return $modal->getRenderer()->render('modal_remote', $modal); }
php
static function renderRemoteEmptyModal($remoteId = null) { $modal = modal(); if (!is_null($remoteId)) { $modal->setRemoteId($remoteId); } return $modal->getRenderer()->render('modal_remote', $modal); }
[ "static", "function", "renderRemoteEmptyModal", "(", "$", "remoteId", "=", "null", ")", "{", "$", "modal", "=", "modal", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "remoteId", ")", ")", "{", "$", "modal", "->", "setRemoteId", "(", "$", "remoteId", ")", ";", "}", "return", "$", "modal", "->", "getRenderer", "(", ")", "->", "render", "(", "'modal_remote'", ",", "$", "modal", ")", ";", "}" ]
Render an emptyl @param null $remoteId @return mixed @throws \Exception
[ "Render", "an", "emptyl" ]
train
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Modal/Modal/Modal.php#L540-L548
stubbles/stubbles-webapp-core
src/main/php/response/mimetypes/Image.php
Image.serialize
public function serialize($resource, OutputStream $out): OutputStream { if (null === $resource) { return $out; } if ($resource instanceof Error) { $image = $this->loadImage($this->errorImgResource); } elseif (!($resource instanceof ImageSource)) { $image = $this->loadImage($resource); } else { $image = $resource; } if (!empty($image)) { // must use output buffering // PHP's image*() functions write directly to stdout ob_start(); $image->display(); $result = ob_get_contents(); // end output buffering first before writing to output stream // because it might be captured by output buffering as well ob_end_clean(); $out->write($result); } return $out; }
php
public function serialize($resource, OutputStream $out): OutputStream { if (null === $resource) { return $out; } if ($resource instanceof Error) { $image = $this->loadImage($this->errorImgResource); } elseif (!($resource instanceof ImageSource)) { $image = $this->loadImage($resource); } else { $image = $resource; } if (!empty($image)) { // must use output buffering // PHP's image*() functions write directly to stdout ob_start(); $image->display(); $result = ob_get_contents(); // end output buffering first before writing to output stream // because it might be captured by output buffering as well ob_end_clean(); $out->write($result); } return $out; }
[ "public", "function", "serialize", "(", "$", "resource", ",", "OutputStream", "$", "out", ")", ":", "OutputStream", "{", "if", "(", "null", "===", "$", "resource", ")", "{", "return", "$", "out", ";", "}", "if", "(", "$", "resource", "instanceof", "Error", ")", "{", "$", "image", "=", "$", "this", "->", "loadImage", "(", "$", "this", "->", "errorImgResource", ")", ";", "}", "elseif", "(", "!", "(", "$", "resource", "instanceof", "ImageSource", ")", ")", "{", "$", "image", "=", "$", "this", "->", "loadImage", "(", "$", "resource", ")", ";", "}", "else", "{", "$", "image", "=", "$", "resource", ";", "}", "if", "(", "!", "empty", "(", "$", "image", ")", ")", "{", "// must use output buffering", "// PHP's image*() functions write directly to stdout", "ob_start", "(", ")", ";", "$", "image", "->", "display", "(", ")", ";", "$", "result", "=", "ob_get_contents", "(", ")", ";", "// end output buffering first before writing to output stream", "// because it might be captured by output buffering as well", "ob_end_clean", "(", ")", ";", "$", "out", "->", "write", "(", "$", "result", ")", ";", "}", "return", "$", "out", ";", "}" ]
serializes resource to output stream @param mixed $resource @param \stubbles\streams\OutputStream $out @return \stubbles\streams\OutputStream
[ "serializes", "resource", "to", "output", "stream" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/mimetypes/Image.php#L66-L93
stubbles/stubbles-webapp-core
src/main/php/response/mimetypes/Image.php
Image.loadImage
private function loadImage(string $resource) { try { return $this->resourceLoader->load( $resource, function($fileName) { return ImageSource::load($fileName); } ); } catch (\Throwable $t) { // not allowed to throw exceptions, as we are outside any catching // mechanism trigger_error( 'Can not load image "' . $resource . '": ' . $t->getMessage(), E_USER_ERROR ); return null; } }
php
private function loadImage(string $resource) { try { return $this->resourceLoader->load( $resource, function($fileName) { return ImageSource::load($fileName); } ); } catch (\Throwable $t) { // not allowed to throw exceptions, as we are outside any catching // mechanism trigger_error( 'Can not load image "' . $resource . '": ' . $t->getMessage(), E_USER_ERROR ); return null; } }
[ "private", "function", "loadImage", "(", "string", "$", "resource", ")", "{", "try", "{", "return", "$", "this", "->", "resourceLoader", "->", "load", "(", "$", "resource", ",", "function", "(", "$", "fileName", ")", "{", "return", "ImageSource", "::", "load", "(", "$", "fileName", ")", ";", "}", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "t", ")", "{", "// not allowed to throw exceptions, as we are outside any catching", "// mechanism", "trigger_error", "(", "'Can not load image \"'", ".", "$", "resource", ".", "'\": '", ".", "$", "t", "->", "getMessage", "(", ")", ",", "E_USER_ERROR", ")", ";", "return", "null", ";", "}", "}" ]
loads image from resource pathes @param string $resource @return \stubbles\img\Image|null
[ "loads", "image", "from", "resource", "pathes" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/mimetypes/Image.php#L101-L117
stubbles/stubbles-webapp-core
src/main/php/routing/api/Resource.php
Resource.addLink
public function addLink(string $rel, $uri): Link { return $this->links->add($rel, $uri); }
php
public function addLink(string $rel, $uri): Link { return $this->links->add($rel, $uri); }
[ "public", "function", "addLink", "(", "string", "$", "rel", ",", "$", "uri", ")", ":", "Link", "{", "return", "$", "this", "->", "links", "->", "add", "(", "$", "rel", ",", "$", "uri", ")", ";", "}" ]
adds a link for this resource @param string $rel relation of this link to the resource @param string $uri actual uri @return \stubbles\webapp\routing\api\Link
[ "adds", "a", "link", "for", "this", "resource" ]
train
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Resource.php#L132-L135