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
ufocoder/yii2-SyncSocial
src/actions/ActionSynchronize.php
ActionSynchronize.redirectWithMessages
protected function redirectWithMessages( $flag, $successMessage, $failedMessage ) { if ( $flag ) { Yii::$app->session->setFlash( 'success', $successMessage ); return $this->controller->redirect( $this->successUrl ); } else { Yii::$app->session->setFlash( 'warning', $failedMessage ); return $this->controller->redirect( $this->failedUrl ); } }
php
protected function redirectWithMessages( $flag, $successMessage, $failedMessage ) { if ( $flag ) { Yii::$app->session->setFlash( 'success', $successMessage ); return $this->controller->redirect( $this->successUrl ); } else { Yii::$app->session->setFlash( 'warning', $failedMessage ); return $this->controller->redirect( $this->failedUrl ); } }
[ "protected", "function", "redirectWithMessages", "(", "$", "flag", ",", "$", "successMessage", ",", "$", "failedMessage", ")", "{", "if", "(", "$", "flag", ")", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'success'", ",", "$", "successMessage", ")", ";", "return", "$", "this", "->", "controller", "->", "redirect", "(", "$", "this", "->", "successUrl", ")", ";", "}", "else", "{", "Yii", "::", "$", "app", "->", "session", "->", "setFlash", "(", "'warning'", ",", "$", "failedMessage", ")", ";", "return", "$", "this", "->", "controller", "->", "redirect", "(", "$", "this", "->", "failedUrl", ")", ";", "}", "}" ]
@param $flag @param $successMessage @param $failedMessage @return \yii\web\Response
[ "@param", "$flag", "@param", "$successMessage", "@param", "$failedMessage" ]
train
https://github.com/ufocoder/yii2-SyncSocial/blob/2dbaaec2dad782c52fdd5b648a31ba7fe2a75e1b/src/actions/ActionSynchronize.php#L62-L70
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsConfig.php
OptionsConfig.validate_config
private function validate_config( $config ) { $this->section_names = array(); foreach( $config['sections'] as $section ) { if( in_array( $section->title, $this->section_names ) ) { throw new DuplicateSectionException( $section->title ); } // Component name uniqueness is validated by the from object, not here foreach( $section->get_fields() as $field ) { $this->fields[] = $field; } $this->section_names[] = $section->title; } return $config; }
php
private function validate_config( $config ) { $this->section_names = array(); foreach( $config['sections'] as $section ) { if( in_array( $section->title, $this->section_names ) ) { throw new DuplicateSectionException( $section->title ); } // Component name uniqueness is validated by the from object, not here foreach( $section->get_fields() as $field ) { $this->fields[] = $field; } $this->section_names[] = $section->title; } return $config; }
[ "private", "function", "validate_config", "(", "$", "config", ")", "{", "$", "this", "->", "section_names", "=", "array", "(", ")", ";", "foreach", "(", "$", "config", "[", "'sections'", "]", "as", "$", "section", ")", "{", "if", "(", "in_array", "(", "$", "section", "->", "title", ",", "$", "this", "->", "section_names", ")", ")", "{", "throw", "new", "DuplicateSectionException", "(", "$", "section", "->", "title", ")", ";", "}", "// Component name uniqueness is validated by the from object, not here", "foreach", "(", "$", "section", "->", "get_fields", "(", ")", "as", "$", "field", ")", "{", "$", "this", "->", "fields", "[", "]", "=", "$", "field", ";", "}", "$", "this", "->", "section_names", "[", "]", "=", "$", "section", "->", "title", ";", "}", "return", "$", "config", ";", "}" ]
Validate the integrity of the provided configuration array @param array $config @throws DuplicateNameException On duplicate field name
[ "Validate", "the", "integrity", "of", "the", "provided", "configuration", "array" ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsConfig.php#L40-L61
askupasoftware/amarkal
Extensions/WordPress/Options/OptionsConfig.php
OptionsConfig.set_section_slugs
private function set_section_slugs() { // For more than 1 sections, set section specific slugs if( count( $this->sections ) > 1 ) { foreach( $this->sections as $section ) { $section->set_slug( \Amarkal\Common\Tools::strtoslug( $section->title ) ); } } // For a single section, use the page's title as the slug else { $this->sections[0]->set_slug( \Amarkal\Common\Tools::strtoslug( $this->title ) ); } }
php
private function set_section_slugs() { // For more than 1 sections, set section specific slugs if( count( $this->sections ) > 1 ) { foreach( $this->sections as $section ) { $section->set_slug( \Amarkal\Common\Tools::strtoslug( $section->title ) ); } } // For a single section, use the page's title as the slug else { $this->sections[0]->set_slug( \Amarkal\Common\Tools::strtoslug( $this->title ) ); } }
[ "private", "function", "set_section_slugs", "(", ")", "{", "// For more than 1 sections, set section specific slugs", "if", "(", "count", "(", "$", "this", "->", "sections", ")", ">", "1", ")", "{", "foreach", "(", "$", "this", "->", "sections", "as", "$", "section", ")", "{", "$", "section", "->", "set_slug", "(", "\\", "Amarkal", "\\", "Common", "\\", "Tools", "::", "strtoslug", "(", "$", "section", "->", "title", ")", ")", ";", "}", "}", "// For a single section, use the page's title as the slug", "else", "{", "$", "this", "->", "sections", "[", "0", "]", "->", "set_slug", "(", "\\", "Amarkal", "\\", "Common", "\\", "Tools", "::", "strtoslug", "(", "$", "this", "->", "title", ")", ")", ";", "}", "}" ]
Set slugs to each section, according the number of sections.
[ "Set", "slugs", "to", "each", "section", "according", "the", "number", "of", "sections", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/OptionsConfig.php#L66-L82
smajohusic/laravel-mail-logger
src/Commands/DeleteLogs.php
DeleteLogs.handle
public function handle() { $timeLimit = (new Carbon)->now()->subDays(config('mailLogger.keepLogsForDays')); app(MailLog::class) ->where('created_at', '<=', $timeLimit) ->get() ->each ->delete(); }
php
public function handle() { $timeLimit = (new Carbon)->now()->subDays(config('mailLogger.keepLogsForDays')); app(MailLog::class) ->where('created_at', '<=', $timeLimit) ->get() ->each ->delete(); }
[ "public", "function", "handle", "(", ")", "{", "$", "timeLimit", "=", "(", "new", "Carbon", ")", "->", "now", "(", ")", "->", "subDays", "(", "config", "(", "'mailLogger.keepLogsForDays'", ")", ")", ";", "app", "(", "MailLog", "::", "class", ")", "->", "where", "(", "'created_at'", ",", "'<='", ",", "$", "timeLimit", ")", "->", "get", "(", ")", "->", "each", "->", "delete", "(", ")", ";", "}" ]
Execute the console command. @return mixed
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/smajohusic/laravel-mail-logger/blob/c7b506bd276d703267d13dd8290f58d64e60d999/src/Commands/DeleteLogs.php#L30-L38
yuncms/framework
src/web/Application.php
Application.catchOffline
public function catchOffline() { if (Yii::$app->settings->get('close', 'system')) { $this->catchAll = [ 'site/offline', 'reason' => Yii::$app->settings->get('closeReason', 'system') ]; } }
php
public function catchOffline() { if (Yii::$app->settings->get('close', 'system')) { $this->catchAll = [ 'site/offline', 'reason' => Yii::$app->settings->get('closeReason', 'system') ]; } }
[ "public", "function", "catchOffline", "(", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "settings", "->", "get", "(", "'close'", ",", "'system'", ")", ")", "{", "$", "this", "->", "catchAll", "=", "[", "'site/offline'", ",", "'reason'", "=>", "Yii", "::", "$", "app", "->", "settings", "->", "get", "(", "'closeReason'", ",", "'system'", ")", "]", ";", "}", "}" ]
检查离线
[ "检查离线" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/web/Application.php#L42-L50
yuncms/framework
src/web/Application.php
Application.setLanguage
public function setLanguage($language = null) { if (is_null($language)) { if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) { $this->language = $language; Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language])); } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) { $this->language = $cookie->value; } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) { $this->language = $language; } } else { $this->language = $language; } }
php
public function setLanguage($language = null) { if (is_null($language)) { if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) { $this->language = $language; Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language])); } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) { $this->language = $cookie->value; } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) { $this->language = $language; } } else { $this->language = $language; } }
[ "public", "function", "setLanguage", "(", "$", "language", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "language", ")", ")", "{", "if", "(", "(", "$", "language", "=", "Yii", "::", "$", "app", "->", "request", "->", "getQueryParam", "(", "'_lang'", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "language", "=", "$", "language", ";", "Yii", "::", "$", "app", "->", "response", "->", "cookies", "->", "add", "(", "new", "Cookie", "(", "[", "'name'", "=>", "'_lang'", ",", "'value'", "=>", "$", "language", "]", ")", ")", ";", "}", "else", "if", "(", "(", "$", "cookie", "=", "Yii", "::", "$", "app", "->", "request", "->", "cookies", "->", "get", "(", "'_lang'", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "language", "=", "$", "cookie", "->", "value", ";", "}", "else", "if", "(", "(", "$", "language", "=", "Yii", "::", "$", "app", "->", "request", "->", "getPreferredLanguage", "(", ")", ")", "!==", "null", ")", "{", "$", "this", "->", "language", "=", "$", "language", ";", "}", "}", "else", "{", "$", "this", "->", "language", "=", "$", "language", ";", "}", "}" ]
set language @param null $language @return void
[ "set", "language" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/web/Application.php#L57-L71
egeloen/IvorySerializerBundle
FOS/Serializer.php
Serializer.serialize
public function serialize($data, $format, FOSContext $context) { return $this->serializer->serialize($data, $format, $this->convertContext($context)); }
php
public function serialize($data, $format, FOSContext $context) { return $this->serializer->serialize($data, $format, $this->convertContext($context)); }
[ "public", "function", "serialize", "(", "$", "data", ",", "$", "format", ",", "FOSContext", "$", "context", ")", "{", "return", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "data", ",", "$", "format", ",", "$", "this", "->", "convertContext", "(", "$", "context", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/FOS/Serializer.php#L45-L48
egeloen/IvorySerializerBundle
FOS/Serializer.php
Serializer.deserialize
public function deserialize($data, $type, $format, FOSContext $context) { return $this->serializer->deserialize($data, $type, $format, $this->convertContext($context)); }
php
public function deserialize($data, $type, $format, FOSContext $context) { return $this->serializer->deserialize($data, $type, $format, $this->convertContext($context)); }
[ "public", "function", "deserialize", "(", "$", "data", ",", "$", "type", ",", "$", "format", ",", "FOSContext", "$", "context", ")", "{", "return", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "data", ",", "$", "type", ",", "$", "format", ",", "$", "this", "->", "convertContext", "(", "$", "context", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/FOS/Serializer.php#L53-L56
egeloen/IvorySerializerBundle
FOS/Serializer.php
Serializer.convertContext
private function convertContext(FOSContext $fosContext) { $context = new Context(); $context->addOptions($fosContext->getAttributes()); if ($fosContext->getSerializeNull() !== null) { $context->setIgnoreNull(!$fosContext->getSerializeNull()); } $exclusionStrategies = $this->createExclusionStrategies($fosContext); if (!empty($exclusionStrategies)) { $exclusionStrategy = count($exclusionStrategies) > 1 ? new ChainExclusionStrategy($exclusionStrategies) : array_shift($exclusionStrategies); $context->setExclusionStrategy($exclusionStrategy); } return $context; }
php
private function convertContext(FOSContext $fosContext) { $context = new Context(); $context->addOptions($fosContext->getAttributes()); if ($fosContext->getSerializeNull() !== null) { $context->setIgnoreNull(!$fosContext->getSerializeNull()); } $exclusionStrategies = $this->createExclusionStrategies($fosContext); if (!empty($exclusionStrategies)) { $exclusionStrategy = count($exclusionStrategies) > 1 ? new ChainExclusionStrategy($exclusionStrategies) : array_shift($exclusionStrategies); $context->setExclusionStrategy($exclusionStrategy); } return $context; }
[ "private", "function", "convertContext", "(", "FOSContext", "$", "fosContext", ")", "{", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "addOptions", "(", "$", "fosContext", "->", "getAttributes", "(", ")", ")", ";", "if", "(", "$", "fosContext", "->", "getSerializeNull", "(", ")", "!==", "null", ")", "{", "$", "context", "->", "setIgnoreNull", "(", "!", "$", "fosContext", "->", "getSerializeNull", "(", ")", ")", ";", "}", "$", "exclusionStrategies", "=", "$", "this", "->", "createExclusionStrategies", "(", "$", "fosContext", ")", ";", "if", "(", "!", "empty", "(", "$", "exclusionStrategies", ")", ")", "{", "$", "exclusionStrategy", "=", "count", "(", "$", "exclusionStrategies", ")", ">", "1", "?", "new", "ChainExclusionStrategy", "(", "$", "exclusionStrategies", ")", ":", "array_shift", "(", "$", "exclusionStrategies", ")", ";", "$", "context", "->", "setExclusionStrategy", "(", "$", "exclusionStrategy", ")", ";", "}", "return", "$", "context", ";", "}" ]
@param FOSContext $fosContext @return Context
[ "@param", "FOSContext", "$fosContext" ]
train
https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/FOS/Serializer.php#L63-L83
egeloen/IvorySerializerBundle
FOS/Serializer.php
Serializer.createExclusionStrategies
private function createExclusionStrategies(FOSContext $context) { $exclusionStrategies = []; $groups = $context->getGroups(); $version = $context->getVersion(); if (!empty($groups)) { $exclusionStrategies[] = new GroupsExclusionStrategy($groups); } if (!empty($version)) { $exclusionStrategies[] = new VersionExclusionStrategy($version); } if (method_exists($context, 'isMaxDepthEnabled')) { if ($context->isMaxDepthEnabled()) { $exclusionStrategies[] = new MaxDepthExclusionStrategy(); } } else { $maxDepth = $context->getMaxDepth(); if (!empty($maxDepth)) { $exclusionStrategies[] = new MaxDepthExclusionStrategy($maxDepth); } } $customExclusionStrategies = $context->getAttribute($attribute = 'ivory_exclusion_strategies') ?: []; if (!is_array($customExclusionStrategies) && !$customExclusionStrategies instanceof \Traversable) { throw new \RuntimeException(sprintf( 'The "%s" context attribute must be an array or implement "%s".', $attribute, \Traversable::class )); } foreach ($customExclusionStrategies as $customExclusionStrategy) { if (!$customExclusionStrategy instanceof ExclusionStrategyInterface) { throw new \RuntimeException(sprintf( 'The "%s" context attribute must be an array of "%s", got "%s".', $attribute, ExclusionStrategyInterface::class, is_object($customExclusionStrategy) ? get_class($customExclusionStrategy) : gettype($customExclusionStrategy) )); } $exclusionStrategies[] = $customExclusionStrategy; } return $exclusionStrategies; }
php
private function createExclusionStrategies(FOSContext $context) { $exclusionStrategies = []; $groups = $context->getGroups(); $version = $context->getVersion(); if (!empty($groups)) { $exclusionStrategies[] = new GroupsExclusionStrategy($groups); } if (!empty($version)) { $exclusionStrategies[] = new VersionExclusionStrategy($version); } if (method_exists($context, 'isMaxDepthEnabled')) { if ($context->isMaxDepthEnabled()) { $exclusionStrategies[] = new MaxDepthExclusionStrategy(); } } else { $maxDepth = $context->getMaxDepth(); if (!empty($maxDepth)) { $exclusionStrategies[] = new MaxDepthExclusionStrategy($maxDepth); } } $customExclusionStrategies = $context->getAttribute($attribute = 'ivory_exclusion_strategies') ?: []; if (!is_array($customExclusionStrategies) && !$customExclusionStrategies instanceof \Traversable) { throw new \RuntimeException(sprintf( 'The "%s" context attribute must be an array or implement "%s".', $attribute, \Traversable::class )); } foreach ($customExclusionStrategies as $customExclusionStrategy) { if (!$customExclusionStrategy instanceof ExclusionStrategyInterface) { throw new \RuntimeException(sprintf( 'The "%s" context attribute must be an array of "%s", got "%s".', $attribute, ExclusionStrategyInterface::class, is_object($customExclusionStrategy) ? get_class($customExclusionStrategy) : gettype($customExclusionStrategy) )); } $exclusionStrategies[] = $customExclusionStrategy; } return $exclusionStrategies; }
[ "private", "function", "createExclusionStrategies", "(", "FOSContext", "$", "context", ")", "{", "$", "exclusionStrategies", "=", "[", "]", ";", "$", "groups", "=", "$", "context", "->", "getGroups", "(", ")", ";", "$", "version", "=", "$", "context", "->", "getVersion", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "groups", ")", ")", "{", "$", "exclusionStrategies", "[", "]", "=", "new", "GroupsExclusionStrategy", "(", "$", "groups", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "version", ")", ")", "{", "$", "exclusionStrategies", "[", "]", "=", "new", "VersionExclusionStrategy", "(", "$", "version", ")", ";", "}", "if", "(", "method_exists", "(", "$", "context", ",", "'isMaxDepthEnabled'", ")", ")", "{", "if", "(", "$", "context", "->", "isMaxDepthEnabled", "(", ")", ")", "{", "$", "exclusionStrategies", "[", "]", "=", "new", "MaxDepthExclusionStrategy", "(", ")", ";", "}", "}", "else", "{", "$", "maxDepth", "=", "$", "context", "->", "getMaxDepth", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "maxDepth", ")", ")", "{", "$", "exclusionStrategies", "[", "]", "=", "new", "MaxDepthExclusionStrategy", "(", "$", "maxDepth", ")", ";", "}", "}", "$", "customExclusionStrategies", "=", "$", "context", "->", "getAttribute", "(", "$", "attribute", "=", "'ivory_exclusion_strategies'", ")", "?", ":", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "customExclusionStrategies", ")", "&&", "!", "$", "customExclusionStrategies", "instanceof", "\\", "Traversable", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The \"%s\" context attribute must be an array or implement \"%s\".'", ",", "$", "attribute", ",", "\\", "Traversable", "::", "class", ")", ")", ";", "}", "foreach", "(", "$", "customExclusionStrategies", "as", "$", "customExclusionStrategy", ")", "{", "if", "(", "!", "$", "customExclusionStrategy", "instanceof", "ExclusionStrategyInterface", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'The \"%s\" context attribute must be an array of \"%s\", got \"%s\".'", ",", "$", "attribute", ",", "ExclusionStrategyInterface", "::", "class", ",", "is_object", "(", "$", "customExclusionStrategy", ")", "?", "get_class", "(", "$", "customExclusionStrategy", ")", ":", "gettype", "(", "$", "customExclusionStrategy", ")", ")", ")", ";", "}", "$", "exclusionStrategies", "[", "]", "=", "$", "customExclusionStrategy", ";", "}", "return", "$", "exclusionStrategies", ";", "}" ]
@param FOSContext $context @return ExclusionStrategyInterface[]
[ "@param", "FOSContext", "$context" ]
train
https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/FOS/Serializer.php#L90-L143
Double-Opt-in/php-client-api
src/Client/Commands/Responses/Models/Status.php
Status.createFromStdClass
public static function createFromStdClass(stdClass $class) { $site = isset($class->site) ? $class->site : null; $type = isset($class->type) ? $class->type : null; $storage_time = isset($class->storage_time) ? $class->storage_time : 0; $credits = isset($class->credits) ? $class->credits : 0; $soft_quota = isset($class->soft_quota) ? $class->soft_quota : 0; $hard_quota = isset($class->hard_quota) ? $class->hard_quota : 0; $daily_credits_usage = isset($class->daily_credits_usage) ? $class->daily_credits_usage : 0; $unique_hashes = isset($class->unique_hashes) ? $class->unique_hashes : 0; return new Status($site, $type, $storage_time, $credits, $soft_quota, $hard_quota, $daily_credits_usage, $unique_hashes); }
php
public static function createFromStdClass(stdClass $class) { $site = isset($class->site) ? $class->site : null; $type = isset($class->type) ? $class->type : null; $storage_time = isset($class->storage_time) ? $class->storage_time : 0; $credits = isset($class->credits) ? $class->credits : 0; $soft_quota = isset($class->soft_quota) ? $class->soft_quota : 0; $hard_quota = isset($class->hard_quota) ? $class->hard_quota : 0; $daily_credits_usage = isset($class->daily_credits_usage) ? $class->daily_credits_usage : 0; $unique_hashes = isset($class->unique_hashes) ? $class->unique_hashes : 0; return new Status($site, $type, $storage_time, $credits, $soft_quota, $hard_quota, $daily_credits_usage, $unique_hashes); }
[ "public", "static", "function", "createFromStdClass", "(", "stdClass", "$", "class", ")", "{", "$", "site", "=", "isset", "(", "$", "class", "->", "site", ")", "?", "$", "class", "->", "site", ":", "null", ";", "$", "type", "=", "isset", "(", "$", "class", "->", "type", ")", "?", "$", "class", "->", "type", ":", "null", ";", "$", "storage_time", "=", "isset", "(", "$", "class", "->", "storage_time", ")", "?", "$", "class", "->", "storage_time", ":", "0", ";", "$", "credits", "=", "isset", "(", "$", "class", "->", "credits", ")", "?", "$", "class", "->", "credits", ":", "0", ";", "$", "soft_quota", "=", "isset", "(", "$", "class", "->", "soft_quota", ")", "?", "$", "class", "->", "soft_quota", ":", "0", ";", "$", "hard_quota", "=", "isset", "(", "$", "class", "->", "hard_quota", ")", "?", "$", "class", "->", "hard_quota", ":", "0", ";", "$", "daily_credits_usage", "=", "isset", "(", "$", "class", "->", "daily_credits_usage", ")", "?", "$", "class", "->", "daily_credits_usage", ":", "0", ";", "$", "unique_hashes", "=", "isset", "(", "$", "class", "->", "unique_hashes", ")", "?", "$", "class", "->", "unique_hashes", ":", "0", ";", "return", "new", "Status", "(", "$", "site", ",", "$", "type", ",", "$", "storage_time", ",", "$", "credits", ",", "$", "soft_quota", ",", "$", "hard_quota", ",", "$", "daily_credits_usage", ",", "$", "unique_hashes", ")", ";", "}" ]
creates from a stdClass @param stdClass $class @return Status
[ "creates", "from", "a", "stdClass" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Models/Status.php#L97-L109
Double-Opt-in/php-client-api
src/Client/Commands/Responses/Models/Status.php
Status.toArray
public function toArray() { return array( 'site' => $this->site, 'type' => $this->type, 'storage_time' => $this->storage_time, 'credits' => $this->credits, 'soft_quota' => $this->soft_quota, 'hard_quota' => $this->hard_quota, 'daily_credits_usage' => $this->daily_credits_usage, 'unique_hashes' => $this->unique_hashes, ); }
php
public function toArray() { return array( 'site' => $this->site, 'type' => $this->type, 'storage_time' => $this->storage_time, 'credits' => $this->credits, 'soft_quota' => $this->soft_quota, 'hard_quota' => $this->hard_quota, 'daily_credits_usage' => $this->daily_credits_usage, 'unique_hashes' => $this->unique_hashes, ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'site'", "=>", "$", "this", "->", "site", ",", "'type'", "=>", "$", "this", "->", "type", ",", "'storage_time'", "=>", "$", "this", "->", "storage_time", ",", "'credits'", "=>", "$", "this", "->", "credits", ",", "'soft_quota'", "=>", "$", "this", "->", "soft_quota", ",", "'hard_quota'", "=>", "$", "this", "->", "hard_quota", ",", "'daily_credits_usage'", "=>", "$", "this", "->", "daily_credits_usage", ",", "'unique_hashes'", "=>", "$", "this", "->", "unique_hashes", ",", ")", ";", "}" ]
returns status as array @return array
[ "returns", "status", "as", "array" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/Models/Status.php#L196-L208
webforge-labs/psc-cms
lib/PHPWord/PHPWord/DocumentProperties.php
PHPWord_DocumentProperties.setCreated
public function setCreated($pValue = null) { if (is_null($pValue)) { $pValue = time(); } $this->_created = $pValue; return $this; }
php
public function setCreated($pValue = null) { if (is_null($pValue)) { $pValue = time(); } $this->_created = $pValue; return $this; }
[ "public", "function", "setCreated", "(", "$", "pValue", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "pValue", ")", ")", "{", "$", "pValue", "=", "time", "(", ")", ";", "}", "$", "this", "->", "_created", "=", "$", "pValue", ";", "return", "$", "this", ";", "}" ]
Set Created @param datetime $pValue @return PHPWord_DocumentProperties
[ "Set", "Created" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/DocumentProperties.php#L179-L185
webforge-labs/psc-cms
lib/PHPWord/PHPWord/DocumentProperties.php
PHPWord_DocumentProperties.setModified
public function setModified($pValue = null) { if (is_null($pValue)) { $pValue = time(); } $this->_modified = $pValue; return $this; }
php
public function setModified($pValue = null) { if (is_null($pValue)) { $pValue = time(); } $this->_modified = $pValue; return $this; }
[ "public", "function", "setModified", "(", "$", "pValue", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "pValue", ")", ")", "{", "$", "pValue", "=", "time", "(", ")", ";", "}", "$", "this", "->", "_modified", "=", "$", "pValue", ";", "return", "$", "this", ";", "}" ]
Set Modified @param datetime $pValue @return PHPWord_DocumentProperties
[ "Set", "Modified" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/DocumentProperties.php#L202-L208
nguyenanhung/td-send-sms
src/Database/SmsDatabase.php
SmsDatabase.getConfigData
public function getConfigData() { $configData = DataRepository::getData('config_database'); $this->logger->debug(__FUNCTION__, 'Config Database => ' . json_encode($configData)); return $configData; }
php
public function getConfigData() { $configData = DataRepository::getData('config_database'); $this->logger->debug(__FUNCTION__, 'Config Database => ' . json_encode($configData)); return $configData; }
[ "public", "function", "getConfigData", "(", ")", "{", "$", "configData", "=", "DataRepository", "::", "getData", "(", "'config_database'", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "__FUNCTION__", ",", "'Config Database => '", ".", "json_encode", "(", "$", "configData", ")", ")", ";", "return", "$", "configData", ";", "}" ]
Function getConfigData @author: 713uk13m <[email protected]> @time : 11/21/18 22:22 @return array|mixed
[ "Function", "getConfigData" ]
train
https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/Database/SmsDatabase.php#L158-L164
nguyenanhung/td-send-sms
src/Database/SmsDatabase.php
SmsDatabase.connectDatabase
public function connectDatabase($database = array()) { $model = new BaseModel(); if (isset($this->options['debugStatus']) && $this->options['debugStatus'] === TRUE) { $model->debugStatus = $this->options['debugStatus']; if (isset($this->options['debugLevel']) && !empty($this->options['debugLevel'])) { $model->debugLevel = $this->options['debugLevel']; } if (isset($this->options['loggerPath']) && !empty($this->options['loggerPath'])) { $model->debugLoggerPath = $this->options['loggerPath']; } $model->debugLoggerFilename = 'Log-' . date('Y-m-d') . '.log'; $model->__construct(); } $model->setDatabase($database); return $model; }
php
public function connectDatabase($database = array()) { $model = new BaseModel(); if (isset($this->options['debugStatus']) && $this->options['debugStatus'] === TRUE) { $model->debugStatus = $this->options['debugStatus']; if (isset($this->options['debugLevel']) && !empty($this->options['debugLevel'])) { $model->debugLevel = $this->options['debugLevel']; } if (isset($this->options['loggerPath']) && !empty($this->options['loggerPath'])) { $model->debugLoggerPath = $this->options['loggerPath']; } $model->debugLoggerFilename = 'Log-' . date('Y-m-d') . '.log'; $model->__construct(); } $model->setDatabase($database); return $model; }
[ "public", "function", "connectDatabase", "(", "$", "database", "=", "array", "(", ")", ")", "{", "$", "model", "=", "new", "BaseModel", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'debugStatus'", "]", ")", "&&", "$", "this", "->", "options", "[", "'debugStatus'", "]", "===", "TRUE", ")", "{", "$", "model", "->", "debugStatus", "=", "$", "this", "->", "options", "[", "'debugStatus'", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'debugLevel'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "options", "[", "'debugLevel'", "]", ")", ")", "{", "$", "model", "->", "debugLevel", "=", "$", "this", "->", "options", "[", "'debugLevel'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'loggerPath'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "options", "[", "'loggerPath'", "]", ")", ")", "{", "$", "model", "->", "debugLoggerPath", "=", "$", "this", "->", "options", "[", "'loggerPath'", "]", ";", "}", "$", "model", "->", "debugLoggerFilename", "=", "'Log-'", ".", "date", "(", "'Y-m-d'", ")", ".", "'.log'", ";", "$", "model", "->", "__construct", "(", ")", ";", "}", "$", "model", "->", "setDatabase", "(", "$", "database", ")", ";", "return", "$", "model", ";", "}" ]
Function connectDatabase @author: 713uk13m <[email protected]> @time : 11/21/18 22:23 @param array $database @return \nguyenanhung\MyDatabase\Model\BaseModel
[ "Function", "connectDatabase" ]
train
https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/Database/SmsDatabase.php#L177-L194
nguyenanhung/td-send-sms
src/Database/SmsDatabase.php
SmsDatabase.getDataShortCode
public function getDataShortCode($whereValue = '', $whereField = 'shortcode') { $inputParams = array('whereValue' => $whereValue, 'whereField' => $whereField); $this->logger->debug(__FUNCTION__, 'Input Params => ' . json_encode($inputParams)); $cacheKey = self::PROJECT_CACHE_KEY . self::CLASS_CACHE_KEY . __FUNCTION__ . hash('md5', json_encode($whereValue) . json_encode($whereField)); if ($this->cache->has($cacheKey)) { $result = $this->cache->get($cacheKey); } else { $database = $this->connectDatabase($this->sdkConfig[self::_DATABASE_CONFIG_KEY_]); $result = $database->setTable(self::TABLE_SHORT_CODE)->getInfo($whereValue, $whereField); $this->cache->save($cacheKey, $result); $database->disconnect(); } $this->logger->debug(__FUNCTION__, 'Result Data => ' . json_encode($result)); return $result; }
php
public function getDataShortCode($whereValue = '', $whereField = 'shortcode') { $inputParams = array('whereValue' => $whereValue, 'whereField' => $whereField); $this->logger->debug(__FUNCTION__, 'Input Params => ' . json_encode($inputParams)); $cacheKey = self::PROJECT_CACHE_KEY . self::CLASS_CACHE_KEY . __FUNCTION__ . hash('md5', json_encode($whereValue) . json_encode($whereField)); if ($this->cache->has($cacheKey)) { $result = $this->cache->get($cacheKey); } else { $database = $this->connectDatabase($this->sdkConfig[self::_DATABASE_CONFIG_KEY_]); $result = $database->setTable(self::TABLE_SHORT_CODE)->getInfo($whereValue, $whereField); $this->cache->save($cacheKey, $result); $database->disconnect(); } $this->logger->debug(__FUNCTION__, 'Result Data => ' . json_encode($result)); return $result; }
[ "public", "function", "getDataShortCode", "(", "$", "whereValue", "=", "''", ",", "$", "whereField", "=", "'shortcode'", ")", "{", "$", "inputParams", "=", "array", "(", "'whereValue'", "=>", "$", "whereValue", ",", "'whereField'", "=>", "$", "whereField", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "__FUNCTION__", ",", "'Input Params => '", ".", "json_encode", "(", "$", "inputParams", ")", ")", ";", "$", "cacheKey", "=", "self", "::", "PROJECT_CACHE_KEY", ".", "self", "::", "CLASS_CACHE_KEY", ".", "__FUNCTION__", ".", "hash", "(", "'md5'", ",", "json_encode", "(", "$", "whereValue", ")", ".", "json_encode", "(", "$", "whereField", ")", ")", ";", "if", "(", "$", "this", "->", "cache", "->", "has", "(", "$", "cacheKey", ")", ")", "{", "$", "result", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "cacheKey", ")", ";", "}", "else", "{", "$", "database", "=", "$", "this", "->", "connectDatabase", "(", "$", "this", "->", "sdkConfig", "[", "self", "::", "_DATABASE_CONFIG_KEY_", "]", ")", ";", "$", "result", "=", "$", "database", "->", "setTable", "(", "self", "::", "TABLE_SHORT_CODE", ")", "->", "getInfo", "(", "$", "whereValue", ",", "$", "whereField", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "cacheKey", ",", "$", "result", ")", ";", "$", "database", "->", "disconnect", "(", ")", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "__FUNCTION__", ",", "'Result Data => '", ".", "json_encode", "(", "$", "result", ")", ")", ";", "return", "$", "result", ";", "}" ]
Function getDataShortCode @author: 713uk13m <[email protected]> @time : 11/21/18 22:40 @param string $whereValue @param string $whereField @return array|bool|\Illuminate\Support\Collection|mixed|null|string
[ "Function", "getDataShortCode" ]
train
https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/Database/SmsDatabase.php#L208-L224
geekwright/Po
src/PoEntry.php
PoEntry.add
public function add(string $type, string $value): void { if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
php
public function add(string $type, string $value): void { if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
[ "public", "function", "add", "(", "string", "$", "type", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "(", "array", ")", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a value to an array 'type' in the entry @param string $type PoToken constant @param string $value value to store @return void
[ "add", "a", "value", "to", "an", "array", "type", "in", "the", "entry" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L48-L55
geekwright/Po
src/PoEntry.php
PoEntry.addQuoted
public function addQuoted(string $type, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
php
public function addQuoted(string $type, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } $this->entry[$type] = (array) $this->entry[$type]; $this->entry[$type][] = $value; }
[ "public", "function", "addQuoted", "(", "string", "$", "type", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "value", "[", "0", "]", "==", "'\"'", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "-", "1", ")", ";", "}", "$", "value", "=", "stripcslashes", "(", "$", "value", ")", ";", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "(", "array", ")", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a quoted value to the array 'type' in the entry @param string $type PoToken constant @param string $value value to store @return void
[ "add", "a", "quoted", "value", "to", "the", "array", "type", "in", "the", "entry" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L64-L76
geekwright/Po
src/PoEntry.php
PoEntry.addQuotedAtPosition
public function addQuotedAtPosition(string $type, int $position, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } if (isset($this->entry[$type][$position]) && is_scalar($this->entry[$type][$position]) ) { $this->entry[$type][$position] = array($this->entry[$type][$position]); } $this->entry[$type][$position][] = $value; }
php
public function addQuotedAtPosition(string $type, int $position, string $value): void { if ($value[0]=='"') { $value = substr($value, 1, -1); } $value = stripcslashes($value); if ($this->entry[$type] === null) { $this->entry[$type] = array(); } if (isset($this->entry[$type][$position]) && is_scalar($this->entry[$type][$position]) ) { $this->entry[$type][$position] = array($this->entry[$type][$position]); } $this->entry[$type][$position][] = $value; }
[ "public", "function", "addQuotedAtPosition", "(", "string", "$", "type", ",", "int", "$", "position", ",", "string", "$", "value", ")", ":", "void", "{", "if", "(", "$", "value", "[", "0", "]", "==", "'\"'", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "-", "1", ")", ";", "}", "$", "value", "=", "stripcslashes", "(", "$", "value", ")", ";", "if", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "===", "null", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "=", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", "&&", "is_scalar", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", ")", "{", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", "=", "array", "(", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", ")", ";", "}", "$", "this", "->", "entry", "[", "$", "type", "]", "[", "$", "position", "]", "[", "]", "=", "$", "value", ";", "}" ]
add a quoted value to the nested array 'type' in the entry This is mainly useful for translated plurals. Since any plural msgstr can have continuation lines, the message is stored as an array of arrays. @param string $type PoToken constant @param integer $position array position to store @param string $value value to store @return void
[ "add", "a", "quoted", "value", "to", "the", "nested", "array", "type", "in", "the", "entry" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L89-L105
geekwright/Po
src/PoEntry.php
PoEntry.getAsString
public function getAsString(string $type): ?string { $ret = $this->entry[$type]; if (is_array($ret)) { $ret = implode('', $ret); } return $ret; }
php
public function getAsString(string $type): ?string { $ret = $this->entry[$type]; if (is_array($ret)) { $ret = implode('', $ret); } return $ret; }
[ "public", "function", "getAsString", "(", "string", "$", "type", ")", ":", "?", "string", "{", "$", "ret", "=", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "if", "(", "is_array", "(", "$", "ret", ")", ")", "{", "$", "ret", "=", "implode", "(", "''", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}" ]
get the value of a specified type as a string @param string $type PoToken constant @return string|null
[ "get", "the", "value", "of", "a", "specified", "type", "as", "a", "string" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L125-L132
geekwright/Po
src/PoEntry.php
PoEntry.getAsStringArray
public function getAsStringArray(string $type): ?array { $plurals = $this->entry[$type]; $plurals = is_array($plurals) ? $plurals : array('', ''); $ret = array(); foreach ($plurals as $i => $value) { if (is_array($value)) { $value = implode('', $value); } $ret[$i] = $value; } return $ret; }
php
public function getAsStringArray(string $type): ?array { $plurals = $this->entry[$type]; $plurals = is_array($plurals) ? $plurals : array('', ''); $ret = array(); foreach ($plurals as $i => $value) { if (is_array($value)) { $value = implode('', $value); } $ret[$i] = $value; } return $ret; }
[ "public", "function", "getAsStringArray", "(", "string", "$", "type", ")", ":", "?", "array", "{", "$", "plurals", "=", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "$", "plurals", "=", "is_array", "(", "$", "plurals", ")", "?", "$", "plurals", ":", "array", "(", "''", ",", "''", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "plurals", "as", "$", "i", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "''", ",", "$", "value", ")", ";", "}", "$", "ret", "[", "$", "i", "]", "=", "$", "value", ";", "}", "return", "$", "ret", ";", "}" ]
Get the value of a specified type as an array of strings. This is mainly for plural TRANSLATED messages. @param string $type PoToken constant @return string[]|null
[ "Get", "the", "value", "of", "a", "specified", "type", "as", "an", "array", "of", "strings", ".", "This", "is", "mainly", "for", "plural", "TRANSLATED", "messages", "." ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L142-L154
geekwright/Po
src/PoEntry.php
PoEntry.dumpEntry
public function dumpEntry(): string { $output = $this->dumpEntryComments(); $key = PoTokens::CONTEXT; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); } $key = PoTokens::MESSAGE; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); $key = PoTokens::PLURAL; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); $key = PoTokens::TRANSLATED; $plurals = $this->entry[$key]; $plurals = is_array($plurals) ? $plurals : array('', ''); foreach ($plurals as $i => $value) { $output .= "{$key}[{$i}]" . $this->formatQuotedString($value); } } else { $key = PoTokens::TRANSLATED; $output .= $key . $this->formatQuotedString($this->entry[$key]); } } $output .= "\n"; return $output; }
php
public function dumpEntry(): string { $output = $this->dumpEntryComments(); $key = PoTokens::CONTEXT; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); } $key = PoTokens::MESSAGE; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); $key = PoTokens::PLURAL; if (!($this->entry[$key] === null)) { $output .= $key . $this->formatQuotedString($this->entry[$key]); $key = PoTokens::TRANSLATED; $plurals = $this->entry[$key]; $plurals = is_array($plurals) ? $plurals : array('', ''); foreach ($plurals as $i => $value) { $output .= "{$key}[{$i}]" . $this->formatQuotedString($value); } } else { $key = PoTokens::TRANSLATED; $output .= $key . $this->formatQuotedString($this->entry[$key]); } } $output .= "\n"; return $output; }
[ "public", "function", "dumpEntry", "(", ")", ":", "string", "{", "$", "output", "=", "$", "this", "->", "dumpEntryComments", "(", ")", ";", "$", "key", "=", "PoTokens", "::", "CONTEXT", ";", "if", "(", "!", "(", "$", "this", "->", "entry", "[", "$", "key", "]", "===", "null", ")", ")", "{", "$", "output", ".=", "$", "key", ".", "$", "this", "->", "formatQuotedString", "(", "$", "this", "->", "entry", "[", "$", "key", "]", ")", ";", "}", "$", "key", "=", "PoTokens", "::", "MESSAGE", ";", "if", "(", "!", "(", "$", "this", "->", "entry", "[", "$", "key", "]", "===", "null", ")", ")", "{", "$", "output", ".=", "$", "key", ".", "$", "this", "->", "formatQuotedString", "(", "$", "this", "->", "entry", "[", "$", "key", "]", ")", ";", "$", "key", "=", "PoTokens", "::", "PLURAL", ";", "if", "(", "!", "(", "$", "this", "->", "entry", "[", "$", "key", "]", "===", "null", ")", ")", "{", "$", "output", ".=", "$", "key", ".", "$", "this", "->", "formatQuotedString", "(", "$", "this", "->", "entry", "[", "$", "key", "]", ")", ";", "$", "key", "=", "PoTokens", "::", "TRANSLATED", ";", "$", "plurals", "=", "$", "this", "->", "entry", "[", "$", "key", "]", ";", "$", "plurals", "=", "is_array", "(", "$", "plurals", ")", "?", "$", "plurals", ":", "array", "(", "''", ",", "''", ")", ";", "foreach", "(", "$", "plurals", "as", "$", "i", "=>", "$", "value", ")", "{", "$", "output", ".=", "\"{$key}[{$i}]\"", ".", "$", "this", "->", "formatQuotedString", "(", "$", "value", ")", ";", "}", "}", "else", "{", "$", "key", "=", "PoTokens", "::", "TRANSLATED", ";", "$", "output", ".=", "$", "key", ".", "$", "this", "->", "formatQuotedString", "(", "$", "this", "->", "entry", "[", "$", "key", "]", ")", ";", "}", "}", "$", "output", ".=", "\"\\n\"", ";", "return", "$", "output", ";", "}" ]
Dump this entry as a po/pot file fragment @return string
[ "Dump", "this", "entry", "as", "a", "po", "/", "pot", "file", "fragment" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L173-L201
geekwright/Po
src/PoEntry.php
PoEntry.dumpEntryComments
protected function dumpEntryComments(): string { $commentKeys = array( PoTokens::TRANSLATOR_COMMENTS, PoTokens::EXTRACTED_COMMENTS, PoTokens::REFERENCE, PoTokens::FLAG, PoTokens::PREVIOUS, PoTokens::OBSOLETE, ); $output = ''; foreach ($commentKeys as $type) { $section = $this->entry[$type]; if (is_array($section)) { foreach ($section as $comment) { $output .= $type . ' ' . $comment . "\n"; } } elseif (!($section === null)) { $output .= $type . ' ' . $section . "\n"; } } return $output; }
php
protected function dumpEntryComments(): string { $commentKeys = array( PoTokens::TRANSLATOR_COMMENTS, PoTokens::EXTRACTED_COMMENTS, PoTokens::REFERENCE, PoTokens::FLAG, PoTokens::PREVIOUS, PoTokens::OBSOLETE, ); $output = ''; foreach ($commentKeys as $type) { $section = $this->entry[$type]; if (is_array($section)) { foreach ($section as $comment) { $output .= $type . ' ' . $comment . "\n"; } } elseif (!($section === null)) { $output .= $type . ' ' . $section . "\n"; } } return $output; }
[ "protected", "function", "dumpEntryComments", "(", ")", ":", "string", "{", "$", "commentKeys", "=", "array", "(", "PoTokens", "::", "TRANSLATOR_COMMENTS", ",", "PoTokens", "::", "EXTRACTED_COMMENTS", ",", "PoTokens", "::", "REFERENCE", ",", "PoTokens", "::", "FLAG", ",", "PoTokens", "::", "PREVIOUS", ",", "PoTokens", "::", "OBSOLETE", ",", ")", ";", "$", "output", "=", "''", ";", "foreach", "(", "$", "commentKeys", "as", "$", "type", ")", "{", "$", "section", "=", "$", "this", "->", "entry", "[", "$", "type", "]", ";", "if", "(", "is_array", "(", "$", "section", ")", ")", "{", "foreach", "(", "$", "section", "as", "$", "comment", ")", "{", "$", "output", ".=", "$", "type", ".", "' '", ".", "$", "comment", ".", "\"\\n\"", ";", "}", "}", "elseif", "(", "!", "(", "$", "section", "===", "null", ")", ")", "{", "$", "output", ".=", "$", "type", ".", "' '", ".", "$", "section", ".", "\"\\n\"", ";", "}", "}", "return", "$", "output", ";", "}" ]
Dump the comments for this entry as a po/pot file fragment @return string
[ "Dump", "the", "comments", "for", "this", "entry", "as", "a", "po", "/", "pot", "file", "fragment" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L208-L233
geekwright/Po
src/PoEntry.php
PoEntry.formatQuotedString
protected function formatQuotedString($value, bool $bare = false): string { if (is_array($value)) { $string = ''; foreach ($value as $partial) { $string .= $this->formatQuotedString($partial, true) . "\n"; } return $bare ? $string : ' ' . $string; } else { $string = ($value === null) ? '' : $value; $string = stripcslashes($string); $string = addcslashes($string, "\0..\37\""); $string = '"' . $string . '"'; return $bare ? $string : ' ' . $string . "\n"; } }
php
protected function formatQuotedString($value, bool $bare = false): string { if (is_array($value)) { $string = ''; foreach ($value as $partial) { $string .= $this->formatQuotedString($partial, true) . "\n"; } return $bare ? $string : ' ' . $string; } else { $string = ($value === null) ? '' : $value; $string = stripcslashes($string); $string = addcslashes($string, "\0..\37\""); $string = '"' . $string . '"'; return $bare ? $string : ' ' . $string . "\n"; } }
[ "protected", "function", "formatQuotedString", "(", "$", "value", ",", "bool", "$", "bare", "=", "false", ")", ":", "string", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "string", "=", "''", ";", "foreach", "(", "$", "value", "as", "$", "partial", ")", "{", "$", "string", ".=", "$", "this", "->", "formatQuotedString", "(", "$", "partial", ",", "true", ")", ".", "\"\\n\"", ";", "}", "return", "$", "bare", "?", "$", "string", ":", "' '", ".", "$", "string", ";", "}", "else", "{", "$", "string", "=", "(", "$", "value", "===", "null", ")", "?", "''", ":", "$", "value", ";", "$", "string", "=", "stripcslashes", "(", "$", "string", ")", ";", "$", "string", "=", "addcslashes", "(", "$", "string", ",", "\"\\0..\\37\\\"\"", ")", ";", "$", "string", "=", "'\"'", ".", "$", "string", ".", "'\"'", ";", "return", "$", "bare", "?", "$", "string", ":", "' '", ".", "$", "string", ".", "\"\\n\"", ";", "}", "}" ]
format a string for output by escaping control and double quote characters, then surrounding with double quotes @param string|string[]|null $value string to prepare @param boolean $bare true for bare output, default false adds leading space and trailing newline @return string
[ "format", "a", "string", "for", "output", "by", "escaping", "control", "and", "double", "quote", "characters", "then", "surrounding", "with", "double", "quotes" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L245-L260
geekwright/Po
src/PoEntry.php
PoEntry.hasFlag
public function hasFlag(string $name): bool { $flags = array(); $flagEntry = $this->entry[PoTokens::FLAG]; if (!empty($flagEntry)) { foreach ((array) $flagEntry as $csv) { $temp = str_getcsv($csv, ','); foreach ($temp as $flag) { $flag = strtolower(trim($flag)); $flags[$flag] = $flag; } } return isset($flags[strtolower(trim($name))]); } return false; }
php
public function hasFlag(string $name): bool { $flags = array(); $flagEntry = $this->entry[PoTokens::FLAG]; if (!empty($flagEntry)) { foreach ((array) $flagEntry as $csv) { $temp = str_getcsv($csv, ','); foreach ($temp as $flag) { $flag = strtolower(trim($flag)); $flags[$flag] = $flag; } } return isset($flags[strtolower(trim($name))]); } return false; }
[ "public", "function", "hasFlag", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "flags", "=", "array", "(", ")", ";", "$", "flagEntry", "=", "$", "this", "->", "entry", "[", "PoTokens", "::", "FLAG", "]", ";", "if", "(", "!", "empty", "(", "$", "flagEntry", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "flagEntry", "as", "$", "csv", ")", "{", "$", "temp", "=", "str_getcsv", "(", "$", "csv", ",", "','", ")", ";", "foreach", "(", "$", "temp", "as", "$", "flag", ")", "{", "$", "flag", "=", "strtolower", "(", "trim", "(", "$", "flag", ")", ")", ";", "$", "flags", "[", "$", "flag", "]", "=", "$", "flag", ";", "}", "}", "return", "isset", "(", "$", "flags", "[", "strtolower", "(", "trim", "(", "$", "name", ")", ")", "]", ")", ";", "}", "return", "false", ";", "}" ]
check for presence of a flag @param string $name flag to check @return boolean true if flag is set, otherwise false
[ "check", "for", "presence", "of", "a", "flag" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L269-L284
geekwright/Po
src/PoEntry.php
PoEntry.addFlag
public function addFlag(string $name): void { if (!$this->hasFlag($name)) { $flagEntry = $this->entry[PoTokens::FLAG]; if ($flagEntry === null) { $this->set(PoTokens::FLAG, $name); } elseif (is_array($flagEntry)) { $flagEntry[] = $name; $this->set(PoTokens::FLAG, implode(',', $flagEntry)); } else { $this->set(PoTokens::FLAG, $flagEntry . ',' . $name); } } }
php
public function addFlag(string $name): void { if (!$this->hasFlag($name)) { $flagEntry = $this->entry[PoTokens::FLAG]; if ($flagEntry === null) { $this->set(PoTokens::FLAG, $name); } elseif (is_array($flagEntry)) { $flagEntry[] = $name; $this->set(PoTokens::FLAG, implode(',', $flagEntry)); } else { $this->set(PoTokens::FLAG, $flagEntry . ',' . $name); } } }
[ "public", "function", "addFlag", "(", "string", "$", "name", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "hasFlag", "(", "$", "name", ")", ")", "{", "$", "flagEntry", "=", "$", "this", "->", "entry", "[", "PoTokens", "::", "FLAG", "]", ";", "if", "(", "$", "flagEntry", "===", "null", ")", "{", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "$", "name", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "flagEntry", ")", ")", "{", "$", "flagEntry", "[", "]", "=", "$", "name", ";", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "implode", "(", "','", ",", "$", "flagEntry", ")", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "PoTokens", "::", "FLAG", ",", "$", "flagEntry", ".", "','", ".", "$", "name", ")", ";", "}", "}", "}" ]
add a flag to the entry @param string $name flag to check @return void
[ "add", "a", "flag", "to", "the", "entry" ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoEntry.php#L293-L306
teneleven/GeolocatorBundle
Provider/LocationProviderRegistry.php
LocationProviderRegistry.registerProvider
public function registerProvider($key, LocationProviderInterface $provider) { if (!$this->hasProvider($key)) { $this->providers[$key] = $provider; } }
php
public function registerProvider($key, LocationProviderInterface $provider) { if (!$this->hasProvider($key)) { $this->providers[$key] = $provider; } }
[ "public", "function", "registerProvider", "(", "$", "key", ",", "LocationProviderInterface", "$", "provider", ")", "{", "if", "(", "!", "$", "this", "->", "hasProvider", "(", "$", "key", ")", ")", "{", "$", "this", "->", "providers", "[", "$", "key", "]", "=", "$", "provider", ";", "}", "}" ]
Register a provider @param $key @param LocationProviderInterface $provider
[ "Register", "a", "provider" ]
train
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Provider/LocationProviderRegistry.php#L48-L53
teneleven/GeolocatorBundle
Provider/LocationProviderRegistry.php
LocationProviderRegistry.getProvider
public function getProvider($key) { if (!$this->hasProvider($key)) { throw new \InvalidArgumentException(sprintf('Location Provider with key "%s" does not exist', $key)); } return $this->providers[$key]; }
php
public function getProvider($key) { if (!$this->hasProvider($key)) { throw new \InvalidArgumentException(sprintf('Location Provider with key "%s" does not exist', $key)); } return $this->providers[$key]; }
[ "public", "function", "getProvider", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "hasProvider", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Location Provider with key \"%s\" does not exist'", ",", "$", "key", ")", ")", ";", "}", "return", "$", "this", "->", "providers", "[", "$", "key", "]", ";", "}" ]
Get specified provider @param $key @return LocationProviderInterface @throws \InvalidArgumentException
[ "Get", "specified", "provider" ]
train
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Provider/LocationProviderRegistry.php#L73-L80
rayrutjes/domain-foundation
src/Serializer/JsonSerializer.php
JsonSerializer.serialize
public function serialize(Serializable $object) { $reflectionClass = new \ReflectionClass($object); $data = []; foreach ($reflectionClass->getProperties() as $reflectionProperty) { if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($object); } return json_encode($data); }
php
public function serialize(Serializable $object) { $reflectionClass = new \ReflectionClass($object); $data = []; foreach ($reflectionClass->getProperties() as $reflectionProperty) { if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } $data[$reflectionProperty->getName()] = $reflectionProperty->getValue($object); } return json_encode($data); }
[ "public", "function", "serialize", "(", "Serializable", "$", "object", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "reflectionClass", "->", "getProperties", "(", ")", "as", "$", "reflectionProperty", ")", "{", "if", "(", "!", "$", "reflectionProperty", "->", "isPublic", "(", ")", ")", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "}", "$", "data", "[", "$", "reflectionProperty", "->", "getName", "(", ")", "]", "=", "$", "reflectionProperty", "->", "getValue", "(", "$", "object", ")", ";", "}", "return", "json_encode", "(", "$", "data", ")", ";", "}" ]
@param $object @return mixed
[ "@param", "$object" ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Serializer/JsonSerializer.php#L14-L26
rayrutjes/domain-foundation
src/Serializer/JsonSerializer.php
JsonSerializer.deserialize
public function deserialize($object, Contract $type) { $reflectionClass = new \ReflectionClass($type->className()); $data = json_decode($object, true); $instance = $reflectionClass->newInstanceWithoutConstructor(); foreach ($data as $propertyName => $propertyValue) { if (!$reflectionClass->hasProperty($propertyName)) { continue; } $reflectionProperty = $reflectionClass->getProperty($propertyName); if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } $reflectionProperty->setValue($instance, $propertyValue); } return $instance; }
php
public function deserialize($object, Contract $type) { $reflectionClass = new \ReflectionClass($type->className()); $data = json_decode($object, true); $instance = $reflectionClass->newInstanceWithoutConstructor(); foreach ($data as $propertyName => $propertyValue) { if (!$reflectionClass->hasProperty($propertyName)) { continue; } $reflectionProperty = $reflectionClass->getProperty($propertyName); if (!$reflectionProperty->isPublic()) { $reflectionProperty->setAccessible(true); } $reflectionProperty->setValue($instance, $propertyValue); } return $instance; }
[ "public", "function", "deserialize", "(", "$", "object", ",", "Contract", "$", "type", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "type", "->", "className", "(", ")", ")", ";", "$", "data", "=", "json_decode", "(", "$", "object", ",", "true", ")", ";", "$", "instance", "=", "$", "reflectionClass", "->", "newInstanceWithoutConstructor", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "propertyName", "=>", "$", "propertyValue", ")", "{", "if", "(", "!", "$", "reflectionClass", "->", "hasProperty", "(", "$", "propertyName", ")", ")", "{", "continue", ";", "}", "$", "reflectionProperty", "=", "$", "reflectionClass", "->", "getProperty", "(", "$", "propertyName", ")", ";", "if", "(", "!", "$", "reflectionProperty", "->", "isPublic", "(", ")", ")", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "}", "$", "reflectionProperty", "->", "setValue", "(", "$", "instance", ",", "$", "propertyValue", ")", ";", "}", "return", "$", "instance", ";", "}" ]
@param $object @param Contract $type @return Serializable
[ "@param", "$object", "@param", "Contract", "$type" ]
train
https://github.com/rayrutjes/domain-foundation/blob/2bce7cd6a6612f718e70e3176589c1abf39d1a3e/src/Serializer/JsonSerializer.php#L34-L51
periaptio/empress-generator
src/Commands/PublishCommand.php
PublishCommand.handle
public function handle() { if ($this->option('all')) { $this->publishCommonViews(); $this->publishTemplates(); $this->publishBaseRepository(); } elseif ($this->option('templates')) { $this->publishTemplates(); } elseif ($this->option('baseRepository')) { $this->publishBaseRepository(); } else { $this->publishCommonViews(); } }
php
public function handle() { if ($this->option('all')) { $this->publishCommonViews(); $this->publishTemplates(); $this->publishBaseRepository(); } elseif ($this->option('templates')) { $this->publishTemplates(); } elseif ($this->option('baseRepository')) { $this->publishBaseRepository(); } else { $this->publishCommonViews(); } }
[ "public", "function", "handle", "(", ")", "{", "if", "(", "$", "this", "->", "option", "(", "'all'", ")", ")", "{", "$", "this", "->", "publishCommonViews", "(", ")", ";", "$", "this", "->", "publishTemplates", "(", ")", ";", "$", "this", "->", "publishBaseRepository", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "option", "(", "'templates'", ")", ")", "{", "$", "this", "->", "publishTemplates", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "option", "(", "'baseRepository'", ")", ")", "{", "$", "this", "->", "publishBaseRepository", "(", ")", ";", "}", "else", "{", "$", "this", "->", "publishCommonViews", "(", ")", ";", "}", "}" ]
Execute the command. @return void
[ "Execute", "the", "command", "." ]
train
https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Commands/PublishCommand.php#L30-L43
yuncms/framework
src/admin/Bootstrap.php
Bootstrap.bootstrap
public function bootstrap($app) { //附加权限验证行为 $app->attachBehavior('access', Yii::createObject(BackendAccessControl::class)); //设置前台URL $app->frontUrlManager->baseUrl = Yii::$app->settings->get('url', 'system'); $manifestFile = Yii::getAlias('@vendor/yuncms/backend.php'); if (is_file($manifestFile)) { $manifests = require($manifestFile); $app->setModules($manifests); } }
php
public function bootstrap($app) { //附加权限验证行为 $app->attachBehavior('access', Yii::createObject(BackendAccessControl::class)); //设置前台URL $app->frontUrlManager->baseUrl = Yii::$app->settings->get('url', 'system'); $manifestFile = Yii::getAlias('@vendor/yuncms/backend.php'); if (is_file($manifestFile)) { $manifests = require($manifestFile); $app->setModules($manifests); } }
[ "public", "function", "bootstrap", "(", "$", "app", ")", "{", "//附加权限验证行为", "$", "app", "->", "attachBehavior", "(", "'access'", ",", "Yii", "::", "createObject", "(", "BackendAccessControl", "::", "class", ")", ")", ";", "//设置前台URL", "$", "app", "->", "frontUrlManager", "->", "baseUrl", "=", "Yii", "::", "$", "app", "->", "settings", "->", "get", "(", "'url'", ",", "'system'", ")", ";", "$", "manifestFile", "=", "Yii", "::", "getAlias", "(", "'@vendor/yuncms/backend.php'", ")", ";", "if", "(", "is_file", "(", "$", "manifestFile", ")", ")", "{", "$", "manifests", "=", "require", "(", "$", "manifestFile", ")", ";", "$", "app", "->", "setModules", "(", "$", "manifests", ")", ";", "}", "}" ]
初始化 @param \yuncms\web\Application $app @throws \yii\base\InvalidConfigException
[ "初始化" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/Bootstrap.php#L27-L40
forxer/tao
src/Tao/Templating/Templating.php
Templating.getPaginationHtml
public function getPaginationHtml($pager, $routeName, array $routeAttributes = []) { return (new TwitterBootstrap3View())->render($pager, function($page) use ($routeName, $routeAttributes) { return $this->app['router']->generate($routeName, array_merge(['page' => $page], $routeAttributes)); }, [ 'proximity' => 2, 'prev_message' => 'Précédente', 'next_message' => 'Suivante' ] ); }
php
public function getPaginationHtml($pager, $routeName, array $routeAttributes = []) { return (new TwitterBootstrap3View())->render($pager, function($page) use ($routeName, $routeAttributes) { return $this->app['router']->generate($routeName, array_merge(['page' => $page], $routeAttributes)); }, [ 'proximity' => 2, 'prev_message' => 'Précédente', 'next_message' => 'Suivante' ] ); }
[ "public", "function", "getPaginationHtml", "(", "$", "pager", ",", "$", "routeName", ",", "array", "$", "routeAttributes", "=", "[", "]", ")", "{", "return", "(", "new", "TwitterBootstrap3View", "(", ")", ")", "->", "render", "(", "$", "pager", ",", "function", "(", "$", "page", ")", "use", "(", "$", "routeName", ",", "$", "routeAttributes", ")", "{", "return", "$", "this", "->", "app", "[", "'router'", "]", "->", "generate", "(", "$", "routeName", ",", "array_merge", "(", "[", "'page'", "=>", "$", "page", "]", ",", "$", "routeAttributes", ")", ")", ";", "}", ",", "[", "'proximity'", "=>", "2", ",", "'prev_message'", "=>", "'Précédente',", "", "'next_message'", "=>", "'Suivante'", "]", ")", ";", "}" ]
Retourne le HTML de la pagination. Note : Ne devrait pas se trouver ici, ou au moins devrait être découplé de TwitterBootstrap3View, mais en attendant ça fait le job... @param Pagerfanta\Pagerfanta $pager @param string $routeName @return string
[ "Retourne", "le", "HTML", "de", "la", "pagination", "." ]
train
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Templating.php#L60-L72
uthando-cms/uthando-dompdf
src/UthandoDomPdf/Form/PdfTextLineFontFieldSet.php
PdfTextLineFontFieldSet.init
public function init() { $this->add([ 'name' => 'family', 'type' => Text::class, 'options' => [ 'label' => 'Font Family', 'column-size' => 'md-8', 'label_attributes' => [ 'class' => 'col-md-4', ], ], ]); $this->add([ 'name' => 'weight', 'type' => Select::class, 'options' => [ 'label' => 'Font Weight', 'label_attributes' => [ 'class' => 'col-md-4', ], 'value_options' => [ 'normal' => 'Normal', 'bold' => 'Bold', 'italic' => 'Italic', 'bold_italic' => 'Bold Italic', ], 'column-size' => 'md-8', ], ]); $this->add([ 'name' => 'size', 'type' => Number::class, 'options' => [ 'label' => 'Font Size', 'column-size' => 'md-8', 'label_attributes' => [ 'class' => 'col-md-4', ], ], ]); }
php
public function init() { $this->add([ 'name' => 'family', 'type' => Text::class, 'options' => [ 'label' => 'Font Family', 'column-size' => 'md-8', 'label_attributes' => [ 'class' => 'col-md-4', ], ], ]); $this->add([ 'name' => 'weight', 'type' => Select::class, 'options' => [ 'label' => 'Font Weight', 'label_attributes' => [ 'class' => 'col-md-4', ], 'value_options' => [ 'normal' => 'Normal', 'bold' => 'Bold', 'italic' => 'Italic', 'bold_italic' => 'Bold Italic', ], 'column-size' => 'md-8', ], ]); $this->add([ 'name' => 'size', 'type' => Number::class, 'options' => [ 'label' => 'Font Size', 'column-size' => 'md-8', 'label_attributes' => [ 'class' => 'col-md-4', ], ], ]); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "add", "(", "[", "'name'", "=>", "'family'", ",", "'type'", "=>", "Text", "::", "class", ",", "'options'", "=>", "[", "'label'", "=>", "'Font Family'", ",", "'column-size'", "=>", "'md-8'", ",", "'label_attributes'", "=>", "[", "'class'", "=>", "'col-md-4'", ",", "]", ",", "]", ",", "]", ")", ";", "$", "this", "->", "add", "(", "[", "'name'", "=>", "'weight'", ",", "'type'", "=>", "Select", "::", "class", ",", "'options'", "=>", "[", "'label'", "=>", "'Font Weight'", ",", "'label_attributes'", "=>", "[", "'class'", "=>", "'col-md-4'", ",", "]", ",", "'value_options'", "=>", "[", "'normal'", "=>", "'Normal'", ",", "'bold'", "=>", "'Bold'", ",", "'italic'", "=>", "'Italic'", ",", "'bold_italic'", "=>", "'Bold Italic'", ",", "]", ",", "'column-size'", "=>", "'md-8'", ",", "]", ",", "]", ")", ";", "$", "this", "->", "add", "(", "[", "'name'", "=>", "'size'", ",", "'type'", "=>", "Number", "::", "class", ",", "'options'", "=>", "[", "'label'", "=>", "'Font Size'", ",", "'column-size'", "=>", "'md-8'", ",", "'label_attributes'", "=>", "[", "'class'", "=>", "'col-md-4'", ",", "]", ",", "]", ",", "]", ")", ";", "}" ]
Set up elements
[ "Set", "up", "elements" ]
train
https://github.com/uthando-cms/uthando-dompdf/blob/60a750058c2db9ed167476192b20c7f544c32007/src/UthandoDomPdf/Form/PdfTextLineFontFieldSet.php#L46-L89
PeekAndPoke/psi
src/Operation/Terminal/JoinOperation.php
JoinOperation.apply
public function apply(\Iterator $set) { $data = iterator_to_array($set); return implode($this->delimiter, $data); }
php
public function apply(\Iterator $set) { $data = iterator_to_array($set); return implode($this->delimiter, $data); }
[ "public", "function", "apply", "(", "\\", "Iterator", "$", "set", ")", "{", "$", "data", "=", "iterator_to_array", "(", "$", "set", ")", ";", "return", "implode", "(", "$", "this", "->", "delimiter", ",", "$", "data", ")", ";", "}" ]
{@inheritdoc} @return string
[ "{", "@inheritdoc", "}" ]
train
https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Operation/Terminal/JoinOperation.php#L35-L40
koriym/Koriym.Psr4List
src/SortingIterator.php
SortingIterator.sort
public function sort(\SplFileInfo $a, \SplFileInfo $b) { $pathA = $a->getPathname(); $pathB = $b->getPathname(); $cntA = count(explode('/', $pathA)); $cntB = count(explode('/', $pathB)); if ($cntA !== $cntB) { return $cntA > $cntB; } return $a->getPathname() > $b->getPathname(); }
php
public function sort(\SplFileInfo $a, \SplFileInfo $b) { $pathA = $a->getPathname(); $pathB = $b->getPathname(); $cntA = count(explode('/', $pathA)); $cntB = count(explode('/', $pathB)); if ($cntA !== $cntB) { return $cntA > $cntB; } return $a->getPathname() > $b->getPathname(); }
[ "public", "function", "sort", "(", "\\", "SplFileInfo", "$", "a", ",", "\\", "SplFileInfo", "$", "b", ")", "{", "$", "pathA", "=", "$", "a", "->", "getPathname", "(", ")", ";", "$", "pathB", "=", "$", "b", "->", "getPathname", "(", ")", ";", "$", "cntA", "=", "count", "(", "explode", "(", "'/'", ",", "$", "pathA", ")", ")", ";", "$", "cntB", "=", "count", "(", "explode", "(", "'/'", ",", "$", "pathB", ")", ")", ";", "if", "(", "$", "cntA", "!==", "$", "cntB", ")", "{", "return", "$", "cntA", ">", "$", "cntB", ";", "}", "return", "$", "a", "->", "getPathname", "(", ")", ">", "$", "b", "->", "getPathname", "(", ")", ";", "}" ]
@param \SplFileInfo $a @param \SplFileInfo $b @return bool
[ "@param", "\\", "SplFileInfo", "$a", "@param", "\\", "SplFileInfo", "$b" ]
train
https://github.com/koriym/Koriym.Psr4List/blob/4f267aa6de4e37cfa84f4d9447f2936e8c79870a/src/SortingIterator.php#L40-L50
JoshuaEstes/FeatureToggle
src/JoshuaEstes/Component/FeatureToggle/Toggle/FeatureToggle.php
FeatureToggle.setOption
public function setOption($option, $value) { $this->options[$option] = $value; $this->resolve($this->options); }
php
public function setOption($option, $value) { $this->options[$option] = $value; $this->resolve($this->options); }
[ "public", "function", "setOption", "(", "$", "option", ",", "$", "value", ")", "{", "$", "this", "->", "options", "[", "$", "option", "]", "=", "$", "value", ";", "$", "this", "->", "resolve", "(", "$", "this", "->", "options", ")", ";", "}" ]
Set or modify an option after the object has been initialized @param string $option @param string $value
[ "Set", "or", "modify", "an", "option", "after", "the", "object", "has", "been", "initialized" ]
train
https://github.com/JoshuaEstes/FeatureToggle/blob/d93b95b649acce80a6395d97cd165ba733971d84/src/JoshuaEstes/Component/FeatureToggle/Toggle/FeatureToggle.php#L42-L46
dashifen/wordpress-php7-plugin-boilerplate
src/Component/AbstractComponent.php
AbstractComponent.hasExpectedArgCount
protected function hasExpectedArgCount(string $handler, int $actualArgCount): bool { $expectedArgCount = $this->attachments[$handler]->getArgCount(); // as you might imagine, if we have our expected argument count, // then it's equal to the actual argument count expected by this // handler. return $expectedArgCount === $actualArgCount; }
php
protected function hasExpectedArgCount(string $handler, int $actualArgCount): bool { $expectedArgCount = $this->attachments[$handler]->getArgCount(); // as you might imagine, if we have our expected argument count, // then it's equal to the actual argument count expected by this // handler. return $expectedArgCount === $actualArgCount; }
[ "protected", "function", "hasExpectedArgCount", "(", "string", "$", "handler", ",", "int", "$", "actualArgCount", ")", ":", "bool", "{", "$", "expectedArgCount", "=", "$", "this", "->", "attachments", "[", "$", "handler", "]", "->", "getArgCount", "(", ")", ";", "// as you might imagine, if we have our expected argument count,", "// then it's equal to the actual argument count expected by this", "// handler.", "return", "$", "expectedArgCount", "===", "$", "actualArgCount", ";", "}" ]
@param string $handler @param int $actualArgCount @return bool
[ "@param", "string", "$handler", "@param", "int", "$actualArgCount" ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Component/AbstractComponent.php#L100-L108
dashifen/wordpress-php7-plugin-boilerplate
src/Component/AbstractComponent.php
AbstractComponent.getExpectedArgCountMessage
protected function getExpectedArgCountMessage(string $handler, int $actualArgCount): string { $expectedArgCount = $this->attachments[$handler]->getArgCount(); // the spaceship operator, added in PHP 7.0, compares the operands // and results in -1, 0, or 1 based on whether the left-hand one // is less than, equal to, or greater than the right-hand one. we // know they're not equal (or we wouldn't be here), so we only have // to worry about -1 and 1 as follows: $message = ($actualArgCount <=> $expectedArgCount) === -1 ? "Not enough arguments for %s. Received %d; expected %d" : "Too many arguments for %s. Received %d; expected %d"; $message = sprintf($message, $handler, $actualArgCount, $expectedArgCount); return $message; }
php
protected function getExpectedArgCountMessage(string $handler, int $actualArgCount): string { $expectedArgCount = $this->attachments[$handler]->getArgCount(); // the spaceship operator, added in PHP 7.0, compares the operands // and results in -1, 0, or 1 based on whether the left-hand one // is less than, equal to, or greater than the right-hand one. we // know they're not equal (or we wouldn't be here), so we only have // to worry about -1 and 1 as follows: $message = ($actualArgCount <=> $expectedArgCount) === -1 ? "Not enough arguments for %s. Received %d; expected %d" : "Too many arguments for %s. Received %d; expected %d"; $message = sprintf($message, $handler, $actualArgCount, $expectedArgCount); return $message; }
[ "protected", "function", "getExpectedArgCountMessage", "(", "string", "$", "handler", ",", "int", "$", "actualArgCount", ")", ":", "string", "{", "$", "expectedArgCount", "=", "$", "this", "->", "attachments", "[", "$", "handler", "]", "->", "getArgCount", "(", ")", ";", "// the spaceship operator, added in PHP 7.0, compares the operands", "// and results in -1, 0, or 1 based on whether the left-hand one", "// is less than, equal to, or greater than the right-hand one. we", "// know they're not equal (or we wouldn't be here), so we only have", "// to worry about -1 and 1 as follows:", "$", "message", "=", "(", "$", "actualArgCount", "<=>", "$", "expectedArgCount", ")", "===", "-", "1", "?", "\"Not enough arguments for %s. Received %d; expected %d\"", ":", "\"Too many arguments for %s. Received %d; expected %d\"", ";", "$", "message", "=", "sprintf", "(", "$", "message", ",", "$", "handler", ",", "$", "actualArgCount", ",", "$", "expectedArgCount", ")", ";", "return", "$", "message", ";", "}" ]
@param string $handler @param int $actualArgCount @return string
[ "@param", "string", "$handler", "@param", "int", "$actualArgCount" ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Component/AbstractComponent.php#L116-L133
dashifen/wordpress-php7-plugin-boilerplate
src/Component/AbstractComponent.php
AbstractComponent.attachHook
public function attachHook(HookInterface $hook): void { // to attach a hook to our component, we want to index our // $attachments property using the handler within $hook. if // a handler already has a hook, we have a problem -- each // handler must be unique and it had better exist, too. $handler = $hook->getHandler(); if (!$this->hasHookHandler($handler)) { throw new ComponentException("Unknown handler: $handler", ComponentException::UNKNOWN_HANDLER); } if (isset($this->attachments[$handler])) { throw new ComponentException("Duplicated handler: $handler", ComponentException::DUPLICATED_HANDLER); } $this->attachments[$handler] = $hook; }
php
public function attachHook(HookInterface $hook): void { // to attach a hook to our component, we want to index our // $attachments property using the handler within $hook. if // a handler already has a hook, we have a problem -- each // handler must be unique and it had better exist, too. $handler = $hook->getHandler(); if (!$this->hasHookHandler($handler)) { throw new ComponentException("Unknown handler: $handler", ComponentException::UNKNOWN_HANDLER); } if (isset($this->attachments[$handler])) { throw new ComponentException("Duplicated handler: $handler", ComponentException::DUPLICATED_HANDLER); } $this->attachments[$handler] = $hook; }
[ "public", "function", "attachHook", "(", "HookInterface", "$", "hook", ")", ":", "void", "{", "// to attach a hook to our component, we want to index our", "// $attachments property using the handler within $hook. if", "// a handler already has a hook, we have a problem -- each", "// handler must be unique and it had better exist, too.", "$", "handler", "=", "$", "hook", "->", "getHandler", "(", ")", ";", "if", "(", "!", "$", "this", "->", "hasHookHandler", "(", "$", "handler", ")", ")", "{", "throw", "new", "ComponentException", "(", "\"Unknown handler: $handler\"", ",", "ComponentException", "::", "UNKNOWN_HANDLER", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "attachments", "[", "$", "handler", "]", ")", ")", "{", "throw", "new", "ComponentException", "(", "\"Duplicated handler: $handler\"", ",", "ComponentException", "::", "DUPLICATED_HANDLER", ")", ";", "}", "$", "this", "->", "attachments", "[", "$", "handler", "]", "=", "$", "hook", ";", "}" ]
@param HookInterface $hook @return void @throws ComponentException
[ "@param", "HookInterface", "$hook" ]
train
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Component/AbstractComponent.php#L141-L161
lootils/archiver
src/Lootils/Archiver/PharArchive.php
PharArchive.add
public function add($file, $entry_name = null) { // Make sure to adapt the entry name as the original filename. if (isset($entry_name)) { $this->phar->addFile($file, $entry_name); } else { $this->phar->addFile($file); } return $this; }
php
public function add($file, $entry_name = null) { // Make sure to adapt the entry name as the original filename. if (isset($entry_name)) { $this->phar->addFile($file, $entry_name); } else { $this->phar->addFile($file); } return $this; }
[ "public", "function", "add", "(", "$", "file", ",", "$", "entry_name", "=", "null", ")", "{", "// Make sure to adapt the entry name as the original filename.", "if", "(", "isset", "(", "$", "entry_name", ")", ")", "{", "$", "this", "->", "phar", "->", "addFile", "(", "$", "file", ",", "$", "entry_name", ")", ";", "}", "else", "{", "$", "this", "->", "phar", "->", "addFile", "(", "$", "file", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add the given file to the file archive.
[ "Add", "the", "given", "file", "to", "the", "file", "archive", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/PharArchive.php#L35-L46
lootils/archiver
src/Lootils/Archiver/PharArchive.php
PharArchive.remove
public function remove($entry) { $result = $this->phar->delete($entry); if ($result === false) { throw new ArchiveException('Error removing entry ' . $entry); } return $this; }
php
public function remove($entry) { $result = $this->phar->delete($entry); if ($result === false) { throw new ArchiveException('Error removing entry ' . $entry); } return $this; }
[ "public", "function", "remove", "(", "$", "entry", ")", "{", "$", "result", "=", "$", "this", "->", "phar", "->", "delete", "(", "$", "entry", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "ArchiveException", "(", "'Error removing entry '", ".", "$", "entry", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove the specified file from the archive.
[ "Remove", "the", "specified", "file", "from", "the", "archive", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/PharArchive.php#L51-L59
lootils/archiver
src/Lootils/Archiver/PharArchive.php
PharArchive.extractTo
public function extractTo($destination, $entries = array()) { $result = false; if (!empty($entries)) { $result = $this->phar->extractTo($destination, $entries); } else { $result = $this->phar->extractTo($destination); } if ($result === false) { throw new ArchiveException('Error extracting archive.'); } return $this; }
php
public function extractTo($destination, $entries = array()) { $result = false; if (!empty($entries)) { $result = $this->phar->extractTo($destination, $entries); } else { $result = $this->phar->extractTo($destination); } if ($result === false) { throw new ArchiveException('Error extracting archive.'); } return $this; }
[ "public", "function", "extractTo", "(", "$", "destination", ",", "$", "entries", "=", "array", "(", ")", ")", "{", "$", "result", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "entries", ")", ")", "{", "$", "result", "=", "$", "this", "->", "phar", "->", "extractTo", "(", "$", "destination", ",", "$", "entries", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "phar", "->", "extractTo", "(", "$", "destination", ")", ";", "}", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "ArchiveException", "(", "'Error extracting archive.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Extract the given files to the destination.
[ "Extract", "the", "given", "files", "to", "the", "destination", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/PharArchive.php#L64-L77
lootils/archiver
src/Lootils/Archiver/PharArchive.php
PharArchive.contents
public function contents() { $files = array(); // Phar files must be reloaded to have updated contents. $this->phar = new Phar($this->path); foreach ($this->phar as $file) { $name = basename($file); $files[$name] = $this->phar[$name]; } return $files; }
php
public function contents() { $files = array(); // Phar files must be reloaded to have updated contents. $this->phar = new Phar($this->path); foreach ($this->phar as $file) { $name = basename($file); $files[$name] = $this->phar[$name]; } return $files; }
[ "public", "function", "contents", "(", ")", "{", "$", "files", "=", "array", "(", ")", ";", "// Phar files must be reloaded to have updated contents.", "$", "this", "->", "phar", "=", "new", "Phar", "(", "$", "this", "->", "path", ")", ";", "foreach", "(", "$", "this", "->", "phar", "as", "$", "file", ")", "{", "$", "name", "=", "basename", "(", "$", "file", ")", ";", "$", "files", "[", "$", "name", "]", "=", "$", "this", "->", "phar", "[", "$", "name", "]", ";", "}", "return", "$", "files", ";", "}" ]
Retrieve an array of the archive contents.
[ "Retrieve", "an", "array", "of", "the", "archive", "contents", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/PharArchive.php#L82-L95
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/LicenseController.php
LicenseController.editAction
public function editAction() { /** @var License $oLicense */ $oLicense = LicenseQuery::create()->findOne(); if ($oLicense === null) { throw $this->createNotFoundException('Unable to find License entity.'); } $oLicense->setValidUntil(date("d.m.Y", $oLicense->getValidUntil())); $editForm = $this->createEditForm($oLicense); return $this->render('SlashworksAppBundle:License:edit_license.html.twig', array( 'entity' => $oLicense, 'edit_form' => $editForm->createView(), )); }
php
public function editAction() { /** @var License $oLicense */ $oLicense = LicenseQuery::create()->findOne(); if ($oLicense === null) { throw $this->createNotFoundException('Unable to find License entity.'); } $oLicense->setValidUntil(date("d.m.Y", $oLicense->getValidUntil())); $editForm = $this->createEditForm($oLicense); return $this->render('SlashworksAppBundle:License:edit_license.html.twig', array( 'entity' => $oLicense, 'edit_form' => $editForm->createView(), )); }
[ "public", "function", "editAction", "(", ")", "{", "/** @var License $oLicense */", "$", "oLicense", "=", "LicenseQuery", "::", "create", "(", ")", "->", "findOne", "(", ")", ";", "if", "(", "$", "oLicense", "===", "null", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find License entity.'", ")", ";", "}", "$", "oLicense", "->", "setValidUntil", "(", "date", "(", "\"d.m.Y\"", ",", "$", "oLicense", "->", "getValidUntil", "(", ")", ")", ")", ";", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "oLicense", ")", ";", "return", "$", "this", "->", "render", "(", "'SlashworksAppBundle:License:edit_license.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "oLicense", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to edit an existing RemoteApp entity. @return \Symfony\Component\HttpFoundation\Response
[ "Displays", "a", "form", "to", "edit", "an", "existing", "RemoteApp", "entity", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/LicenseController.php#L60-L77
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/LicenseController.php
LicenseController.updateAction
public function updateAction(Request $request) { /** @var License $oLicense */ $oLicense = LicenseQuery::create()->findOne(); if ($oLicense === null) { throw $this->createNotFoundException('Unable to find License entity.'); } $editForm = $this->createEditForm($oLicense); $editForm->handleRequest($request); $aResult = array( "success" => false, "message" => "" ); $sLico = SystemSettings::get("lico"); $aHeaders = array( 'Content-Type: application/json' ); $sDomain = $this->_getSiteURL(); $aRequest = array( 'lico' => array( 'domain' => $sDomain, 'license' => $oLicense->getSerial() ), ); $sRequest = json_encode($aRequest); /* * Check license against license-server */ $oRequest = curl_init($sLico . "/api/check/license"); curl_setopt($oRequest, CURLOPT_HTTPHEADER, $aHeaders); curl_setopt($oRequest, CURLOPT_TIMEOUT, 120); curl_setopt($oRequest, CURLOPT_POST, 1); curl_setopt($oRequest, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($oRequest, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest); curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($oRequest); $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE); $error = curl_error($oRequest); curl_close($oRequest); if ($iHttpStatus == 200) { $oResponse = json_decode($response); if ($editForm->isValid() && $oResponse->valid == true) { $aResult['max_clients'] = $oResponse->max_clients; $aResult['valid_until'] = $oResponse->valid_until; $aResult['domain'] = $sDomain; $aResult['success'] = true; $aResult['message'] = $this->get("translator")->trans("license.update.successful"); // license valid, save new license-data $oLicense->setValidUntil($aResult['valid_until']); $oLicense->setMaxClients($aResult['max_clients']); $oLicense->setDomain($sDomain); $oLicense->save(); } else { $aResult['success'] = false; $aResult['message'] = $this->get("translator")->trans("license.update.failed"); $aResult['valid_until'] = strtotime("1970-01-01"); $aResult['max_clients'] = 0; $aResult['domain'] = "-"; } } else { $aResult['max_clients'] = $oLicense->getMaxClients(); $aResult['valid_until'] = strtotime($oLicense->getValidUntil()); $aResult['domain'] = $sDomain; $aResult['success'] = false; $aResult['message'] = $this->get("translator")->trans("license.update.failed_lico"); } $sResult = json_encode($aResult); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
php
public function updateAction(Request $request) { /** @var License $oLicense */ $oLicense = LicenseQuery::create()->findOne(); if ($oLicense === null) { throw $this->createNotFoundException('Unable to find License entity.'); } $editForm = $this->createEditForm($oLicense); $editForm->handleRequest($request); $aResult = array( "success" => false, "message" => "" ); $sLico = SystemSettings::get("lico"); $aHeaders = array( 'Content-Type: application/json' ); $sDomain = $this->_getSiteURL(); $aRequest = array( 'lico' => array( 'domain' => $sDomain, 'license' => $oLicense->getSerial() ), ); $sRequest = json_encode($aRequest); /* * Check license against license-server */ $oRequest = curl_init($sLico . "/api/check/license"); curl_setopt($oRequest, CURLOPT_HTTPHEADER, $aHeaders); curl_setopt($oRequest, CURLOPT_TIMEOUT, 120); curl_setopt($oRequest, CURLOPT_POST, 1); curl_setopt($oRequest, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($oRequest, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($oRequest, CURLOPT_POSTFIELDS, $sRequest); curl_setopt($oRequest, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($oRequest); $iHttpStatus = curl_getinfo($oRequest, CURLINFO_HTTP_CODE); $error = curl_error($oRequest); curl_close($oRequest); if ($iHttpStatus == 200) { $oResponse = json_decode($response); if ($editForm->isValid() && $oResponse->valid == true) { $aResult['max_clients'] = $oResponse->max_clients; $aResult['valid_until'] = $oResponse->valid_until; $aResult['domain'] = $sDomain; $aResult['success'] = true; $aResult['message'] = $this->get("translator")->trans("license.update.successful"); // license valid, save new license-data $oLicense->setValidUntil($aResult['valid_until']); $oLicense->setMaxClients($aResult['max_clients']); $oLicense->setDomain($sDomain); $oLicense->save(); } else { $aResult['success'] = false; $aResult['message'] = $this->get("translator")->trans("license.update.failed"); $aResult['valid_until'] = strtotime("1970-01-01"); $aResult['max_clients'] = 0; $aResult['domain'] = "-"; } } else { $aResult['max_clients'] = $oLicense->getMaxClients(); $aResult['valid_until'] = strtotime($oLicense->getValidUntil()); $aResult['domain'] = $sDomain; $aResult['success'] = false; $aResult['message'] = $this->get("translator")->trans("license.update.failed_lico"); } $sResult = json_encode($aResult); $response = new Response($sResult); $response->headers->set('Content-Type', 'application/json'); return $response; }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ")", "{", "/** @var License $oLicense */", "$", "oLicense", "=", "LicenseQuery", "::", "create", "(", ")", "->", "findOne", "(", ")", ";", "if", "(", "$", "oLicense", "===", "null", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find License entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "oLicense", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "aResult", "=", "array", "(", "\"success\"", "=>", "false", ",", "\"message\"", "=>", "\"\"", ")", ";", "$", "sLico", "=", "SystemSettings", "::", "get", "(", "\"lico\"", ")", ";", "$", "aHeaders", "=", "array", "(", "'Content-Type: application/json'", ")", ";", "$", "sDomain", "=", "$", "this", "->", "_getSiteURL", "(", ")", ";", "$", "aRequest", "=", "array", "(", "'lico'", "=>", "array", "(", "'domain'", "=>", "$", "sDomain", ",", "'license'", "=>", "$", "oLicense", "->", "getSerial", "(", ")", ")", ",", ")", ";", "$", "sRequest", "=", "json_encode", "(", "$", "aRequest", ")", ";", "/*\n * Check license against license-server\n */", "$", "oRequest", "=", "curl_init", "(", "$", "sLico", ".", "\"/api/check/license\"", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_HTTPHEADER", ",", "$", "aHeaders", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_TIMEOUT", ",", "120", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_POST", ",", "1", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_SSL_VERIFYHOST", ",", "false", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_POSTFIELDS", ",", "$", "sRequest", ")", ";", "curl_setopt", "(", "$", "oRequest", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "response", "=", "curl_exec", "(", "$", "oRequest", ")", ";", "$", "iHttpStatus", "=", "curl_getinfo", "(", "$", "oRequest", ",", "CURLINFO_HTTP_CODE", ")", ";", "$", "error", "=", "curl_error", "(", "$", "oRequest", ")", ";", "curl_close", "(", "$", "oRequest", ")", ";", "if", "(", "$", "iHttpStatus", "==", "200", ")", "{", "$", "oResponse", "=", "json_decode", "(", "$", "response", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", "&&", "$", "oResponse", "->", "valid", "==", "true", ")", "{", "$", "aResult", "[", "'max_clients'", "]", "=", "$", "oResponse", "->", "max_clients", ";", "$", "aResult", "[", "'valid_until'", "]", "=", "$", "oResponse", "->", "valid_until", ";", "$", "aResult", "[", "'domain'", "]", "=", "$", "sDomain", ";", "$", "aResult", "[", "'success'", "]", "=", "true", ";", "$", "aResult", "[", "'message'", "]", "=", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"license.update.successful\"", ")", ";", "// license valid, save new license-data", "$", "oLicense", "->", "setValidUntil", "(", "$", "aResult", "[", "'valid_until'", "]", ")", ";", "$", "oLicense", "->", "setMaxClients", "(", "$", "aResult", "[", "'max_clients'", "]", ")", ";", "$", "oLicense", "->", "setDomain", "(", "$", "sDomain", ")", ";", "$", "oLicense", "->", "save", "(", ")", ";", "}", "else", "{", "$", "aResult", "[", "'success'", "]", "=", "false", ";", "$", "aResult", "[", "'message'", "]", "=", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"license.update.failed\"", ")", ";", "$", "aResult", "[", "'valid_until'", "]", "=", "strtotime", "(", "\"1970-01-01\"", ")", ";", "$", "aResult", "[", "'max_clients'", "]", "=", "0", ";", "$", "aResult", "[", "'domain'", "]", "=", "\"-\"", ";", "}", "}", "else", "{", "$", "aResult", "[", "'max_clients'", "]", "=", "$", "oLicense", "->", "getMaxClients", "(", ")", ";", "$", "aResult", "[", "'valid_until'", "]", "=", "strtotime", "(", "$", "oLicense", "->", "getValidUntil", "(", ")", ")", ";", "$", "aResult", "[", "'domain'", "]", "=", "$", "sDomain", ";", "$", "aResult", "[", "'success'", "]", "=", "false", ";", "$", "aResult", "[", "'message'", "]", "=", "$", "this", "->", "get", "(", "\"translator\"", ")", "->", "trans", "(", "\"license.update.failed_lico\"", ")", ";", "}", "$", "sResult", "=", "json_encode", "(", "$", "aResult", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "sResult", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "return", "$", "response", ";", "}" ]
Update license @param \Symfony\Component\HttpFoundation\Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response @throws \Exception @throws \PropelException
[ "Update", "license" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/LicenseController.php#L89-L182
slashworks/control-bundle
src/Slashworks/AppBundle/Controller/LicenseController.php
LicenseController.createEditForm
private function createEditForm(License $oLicense) { $oForm = $this->createForm(new LicenseType(), $oLicense, array( 'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())), 'method' => 'PUT', )); $oForm->add('submit', 'submit', array('label' => 'Update')); return $oForm; }
php
private function createEditForm(License $oLicense) { $oForm = $this->createForm(new LicenseType(), $oLicense, array( 'action' => $this->generateUrl('license_update', array('id' => $oLicense->getId())), 'method' => 'PUT', )); $oForm->add('submit', 'submit', array('label' => 'Update')); return $oForm; }
[ "private", "function", "createEditForm", "(", "License", "$", "oLicense", ")", "{", "$", "oForm", "=", "$", "this", "->", "createForm", "(", "new", "LicenseType", "(", ")", ",", "$", "oLicense", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'license_update'", ",", "array", "(", "'id'", "=>", "$", "oLicense", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "oForm", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "oForm", ";", "}" ]
Create edit form for lucense @param \Slashworks\AppBundle\Model\License $oLicense @return \Symfony\Component\Form\Form
[ "Create", "edit", "form", "for", "lucense" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/LicenseController.php#L192-L203
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php
ContentTreeService.createOrUpdate
public function createOrUpdate($object) { if (!$object instanceof TreeObject) { throw new UnsupportedObjectOperationException(TreeObject::class, get_class($object)); } $this->publishContentObjects($object); }
php
public function createOrUpdate($object) { if (!$object instanceof TreeObject) { throw new UnsupportedObjectOperationException(TreeObject::class, get_class($object)); } $this->publishContentObjects($object); }
[ "public", "function", "createOrUpdate", "(", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "TreeObject", ")", "{", "throw", "new", "UnsupportedObjectOperationException", "(", "TreeObject", "::", "class", ",", "get_class", "(", "$", "object", ")", ")", ";", "}", "$", "this", "->", "publishContentObjects", "(", "$", "object", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php#L45-L52
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php
ContentTreeService.publishContentObjects
private function publishContentObjects(TreeObject $object) { $last = $this->objectService->createOrUpdate($object->data); foreach ($object->getNodes() as $subObject) { if ($subObject instanceof TreeObject) { $this->publishContentObjects($subObject); } else { /* @var ContentObject $subObject */ $subObject->addParentLocation($last->getProperty('content_info')->mainLocationId); $this->objectService->createOrUpdate($subObject); } } }
php
private function publishContentObjects(TreeObject $object) { $last = $this->objectService->createOrUpdate($object->data); foreach ($object->getNodes() as $subObject) { if ($subObject instanceof TreeObject) { $this->publishContentObjects($subObject); } else { /* @var ContentObject $subObject */ $subObject->addParentLocation($last->getProperty('content_info')->mainLocationId); $this->objectService->createOrUpdate($subObject); } } }
[ "private", "function", "publishContentObjects", "(", "TreeObject", "$", "object", ")", "{", "$", "last", "=", "$", "this", "->", "objectService", "->", "createOrUpdate", "(", "$", "object", "->", "data", ")", ";", "foreach", "(", "$", "object", "->", "getNodes", "(", ")", "as", "$", "subObject", ")", "{", "if", "(", "$", "subObject", "instanceof", "TreeObject", ")", "{", "$", "this", "->", "publishContentObjects", "(", "$", "subObject", ")", ";", "}", "else", "{", "/* @var ContentObject $subObject */", "$", "subObject", "->", "addParentLocation", "(", "$", "last", "->", "getProperty", "(", "'content_info'", ")", "->", "mainLocationId", ")", ";", "$", "this", "->", "objectService", "->", "createOrUpdate", "(", "$", "subObject", ")", ";", "}", "}", "}" ]
Publishes content objects. @param TreeObject $object @throws \InvalidArgumentException
[ "Publishes", "content", "objects", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php#L61-L74
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php
ContentTreeService.remove
public function remove($object) { if ($this->logger) { $this->logger->warning(sprintf( 'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.', __CLASS__, EzPlatformObject::class )); } return; }
php
public function remove($object) { if ($this->logger) { $this->logger->warning(sprintf( 'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.', __CLASS__, EzPlatformObject::class )); } return; }
[ "public", "function", "remove", "(", "$", "object", ")", "{", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "sprintf", "(", "'Attempted to delete using %s, which is not supported. Use the implementations of %s instead.'", ",", "__CLASS__", ",", "EzPlatformObject", "::", "class", ")", ")", ";", "}", "return", ";", "}" ]
Bulk-deletions is not supported. @param ObjectInterface $object
[ "Bulk", "-", "deletions", "is", "not", "supported", "." ]
train
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/Core/ContentTreeService.php#L81-L92
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.attach
public function attach(Threaded $object, $data = null) { $this->data[] = $object; $this->info[] = $data; }
php
public function attach(Threaded $object, $data = null) { $this->data[] = $object; $this->info[] = $data; }
[ "public", "function", "attach", "(", "Threaded", "$", "object", ",", "$", "data", "=", "null", ")", "{", "$", "this", "->", "data", "[", "]", "=", "$", "object", ";", "$", "this", "->", "info", "[", "]", "=", "$", "data", ";", "}" ]
Adds an object in the storage @param Threaded $object @param mixed $data [optional] @return void
[ "Adds", "an", "object", "in", "the", "storage" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L35-L39
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.contains
public function contains(Threaded $object) { foreach ($this->data as $value) { if ($value === $object) { return true; } } return false; }
php
public function contains(Threaded $object) { foreach ($this->data as $value) { if ($value === $object) { return true; } } return false; }
[ "public", "function", "contains", "(", "Threaded", "$", "object", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "value", ")", "{", "if", "(", "$", "value", "===", "$", "object", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks if the storage contains a specific object @param Threaded $object @return bool true if the object is in the storage, false otherwise.
[ "Checks", "if", "the", "storage", "contains", "a", "specific", "object" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L63-L71
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.addAll
public function addAll(self $storage) { foreach ($storage->data as $object) { $this->attach($object); } }
php
public function addAll(self $storage) { foreach ($storage->data as $object) { $this->attach($object); } }
[ "public", "function", "addAll", "(", "self", "$", "storage", ")", "{", "foreach", "(", "$", "storage", "->", "data", "as", "$", "object", ")", "{", "$", "this", "->", "attach", "(", "$", "object", ")", ";", "}", "}" ]
Adds all objects from another storage @param ObjectStorage $storage @return void
[ "Adds", "all", "objects", "from", "another", "storage" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L79-L84
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.removeAll
public function removeAll(self $storage) { foreach ($this->data as $key => $value) { foreach ($storage->data as $object) { if ($object === $value) { unset($this->data[$key]); unset($this->info[$key]); } } } }
php
public function removeAll(self $storage) { foreach ($this->data as $key => $value) { foreach ($storage->data as $object) { if ($object === $value) { unset($this->data[$key]); unset($this->info[$key]); } } } }
[ "public", "function", "removeAll", "(", "self", "$", "storage", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "foreach", "(", "$", "storage", "->", "data", "as", "$", "object", ")", "{", "if", "(", "$", "object", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "unset", "(", "$", "this", "->", "info", "[", "$", "key", "]", ")", ";", "}", "}", "}", "}" ]
Removes objects contained in another storage from the current storage @param ObjectStorage $storage @return void
[ "Removes", "objects", "contained", "in", "another", "storage", "from", "the", "current", "storage" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L92-L102
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.getInfo
public function getInfo(Threaded $object) { foreach ($this->data as $key => $value) { if ($object === $value) { return $this->info[$key]; } } }
php
public function getInfo(Threaded $object) { foreach ($this->data as $key => $value) { if ($object === $value) { return $this->info[$key]; } } }
[ "public", "function", "getInfo", "(", "Threaded", "$", "object", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "object", "===", "$", "value", ")", "{", "return", "$", "this", "->", "info", "[", "$", "key", "]", ";", "}", "}", "}" ]
Returns the data associated with the current iterator entry @param Threaded $object @return mixed The data associated with the current iterator position.
[ "Returns", "the", "data", "associated", "with", "the", "current", "iterator", "entry" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L128-L135
prolic/Concurrent-PHP-Utils
src/ConcurrentPhpUtils/ObjectStorage.php
ObjectStorage.setInfo
public function setInfo(Threaded $object, $data) { foreach ($this->data as $key => $value) { if ($object->equals($value)) { $this->info[$key] = $data; break; } } }
php
public function setInfo(Threaded $object, $data) { foreach ($this->data as $key => $value) { if ($object->equals($value)) { $this->info[$key] = $data; break; } } }
[ "public", "function", "setInfo", "(", "Threaded", "$", "object", ",", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "object", "->", "equals", "(", "$", "value", ")", ")", "{", "$", "this", "->", "info", "[", "$", "key", "]", "=", "$", "data", ";", "break", ";", "}", "}", "}" ]
Sets the data associated with the current iterator entry @param Threaded $object @param mixed $data @return void
[ "Sets", "the", "data", "associated", "with", "the", "current", "iterator", "entry" ]
train
https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/ObjectStorage.php#L144-L152
tableau-mkt/eggs-n-cereal
src/Utils/Converter.php
Converter.toXLIFF
public function toXLIFF($pretty_print = FALSE) { $this->doc->formatOutput = $pretty_print; // Do not use getElementById to comply with older versions of libxml. // getElementById doesn't work properly on libxml 2.7.6 (CentOS) $xpath = new \DOMXPath($this->doc); $wrapper_div = $xpath->query("//*[@id='eggs-n-cereal-dont-ever-use-this-id']")->item(0); $out = $this->doc->createDocumentFragment(); $domNodeList = array(); for ($i = 0; $i < $wrapper_div->childNodes->length; ++$i) { $domNodeList[] = $wrapper_div->childNodes->item($i); } $this->sanitizeMixedDomNodeList($this->doc, $domNodeList); foreach($domNodeList as $domNode){ if ($output = $this->convert($domNode)) { $out->appendChild($output); } } return $this->doc->saveXML($out); }
php
public function toXLIFF($pretty_print = FALSE) { $this->doc->formatOutput = $pretty_print; // Do not use getElementById to comply with older versions of libxml. // getElementById doesn't work properly on libxml 2.7.6 (CentOS) $xpath = new \DOMXPath($this->doc); $wrapper_div = $xpath->query("//*[@id='eggs-n-cereal-dont-ever-use-this-id']")->item(0); $out = $this->doc->createDocumentFragment(); $domNodeList = array(); for ($i = 0; $i < $wrapper_div->childNodes->length; ++$i) { $domNodeList[] = $wrapper_div->childNodes->item($i); } $this->sanitizeMixedDomNodeList($this->doc, $domNodeList); foreach($domNodeList as $domNode){ if ($output = $this->convert($domNode)) { $out->appendChild($output); } } return $this->doc->saveXML($out); }
[ "public", "function", "toXLIFF", "(", "$", "pretty_print", "=", "FALSE", ")", "{", "$", "this", "->", "doc", "->", "formatOutput", "=", "$", "pretty_print", ";", "// Do not use getElementById to comply with older versions of libxml.", "// getElementById doesn't work properly on libxml 2.7.6 (CentOS)", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "this", "->", "doc", ")", ";", "$", "wrapper_div", "=", "$", "xpath", "->", "query", "(", "\"//*[@id='eggs-n-cereal-dont-ever-use-this-id']\"", ")", "->", "item", "(", "0", ")", ";", "$", "out", "=", "$", "this", "->", "doc", "->", "createDocumentFragment", "(", ")", ";", "$", "domNodeList", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "wrapper_div", "->", "childNodes", "->", "length", ";", "++", "$", "i", ")", "{", "$", "domNodeList", "[", "]", "=", "$", "wrapper_div", "->", "childNodes", "->", "item", "(", "$", "i", ")", ";", "}", "$", "this", "->", "sanitizeMixedDomNodeList", "(", "$", "this", "->", "doc", ",", "$", "domNodeList", ")", ";", "foreach", "(", "$", "domNodeList", "as", "$", "domNode", ")", "{", "if", "(", "$", "output", "=", "$", "this", "->", "convert", "(", "$", "domNode", ")", ")", "{", "$", "out", "->", "appendChild", "(", "$", "output", ")", ";", "}", "}", "return", "$", "this", "->", "doc", "->", "saveXML", "(", "$", "out", ")", ";", "}" ]
Converts HTML to the corresponding XLIFF representation. @return string The source HTML converted to XLIFF.
[ "Converts", "HTML", "to", "the", "corresponding", "XLIFF", "representation", "." ]
train
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Converter.php#L189-L213
tableau-mkt/eggs-n-cereal
src/Utils/Converter.php
Converter.sanitizeMixedDomNodeList
protected function sanitizeMixedDomNodeList(\DOMDocument $doc, &$list){ $NewElement = $doc->createElement('text'); $test = array(XML_ELEMENT_NODE=> FALSE, XML_TEXT_NODE=>FALSE); foreach($list as $node){ $test[$node->nodeType] = TRUE; } //text only so exit if($test[XML_TEXT_NODE] == TRUE && $test[XML_ELEMENT_NODE] == FALSE){ return; } //mixed group logic $newList = array(); foreach($list as $k => $node){ if (array_key_exists($node->nodeName, $this->inlineTags)|| array_key_exists($node->nodeName, array('#text' => true))){ unset($list[$k]); $NewElement->appendChild($node->cloneNode(true)); if (!isset($node->nextSibling->nodeName)){ $newList[$k] = $NewElement; }else if(array_key_exists($node->nextSibling->nodeName, $this->inlineTags)|| array_key_exists($node->nextSibling->nodeName, array('#text' => true))){ //do nothing }else{ $newList[$k] = $NewElement; } }else{ $newList[$k] = $node; $NewElement = $doc->createElement('text'); } } $list = $newList; }
php
protected function sanitizeMixedDomNodeList(\DOMDocument $doc, &$list){ $NewElement = $doc->createElement('text'); $test = array(XML_ELEMENT_NODE=> FALSE, XML_TEXT_NODE=>FALSE); foreach($list as $node){ $test[$node->nodeType] = TRUE; } //text only so exit if($test[XML_TEXT_NODE] == TRUE && $test[XML_ELEMENT_NODE] == FALSE){ return; } //mixed group logic $newList = array(); foreach($list as $k => $node){ if (array_key_exists($node->nodeName, $this->inlineTags)|| array_key_exists($node->nodeName, array('#text' => true))){ unset($list[$k]); $NewElement->appendChild($node->cloneNode(true)); if (!isset($node->nextSibling->nodeName)){ $newList[$k] = $NewElement; }else if(array_key_exists($node->nextSibling->nodeName, $this->inlineTags)|| array_key_exists($node->nextSibling->nodeName, array('#text' => true))){ //do nothing }else{ $newList[$k] = $NewElement; } }else{ $newList[$k] = $node; $NewElement = $doc->createElement('text'); } } $list = $newList; }
[ "protected", "function", "sanitizeMixedDomNodeList", "(", "\\", "DOMDocument", "$", "doc", ",", "&", "$", "list", ")", "{", "$", "NewElement", "=", "$", "doc", "->", "createElement", "(", "'text'", ")", ";", "$", "test", "=", "array", "(", "XML_ELEMENT_NODE", "=>", "FALSE", ",", "XML_TEXT_NODE", "=>", "FALSE", ")", ";", "foreach", "(", "$", "list", "as", "$", "node", ")", "{", "$", "test", "[", "$", "node", "->", "nodeType", "]", "=", "TRUE", ";", "}", "//text only so exit", "if", "(", "$", "test", "[", "XML_TEXT_NODE", "]", "==", "TRUE", "&&", "$", "test", "[", "XML_ELEMENT_NODE", "]", "==", "FALSE", ")", "{", "return", ";", "}", "//mixed group logic", "$", "newList", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "k", "=>", "$", "node", ")", "{", "if", "(", "array_key_exists", "(", "$", "node", "->", "nodeName", ",", "$", "this", "->", "inlineTags", ")", "||", "array_key_exists", "(", "$", "node", "->", "nodeName", ",", "array", "(", "'#text'", "=>", "true", ")", ")", ")", "{", "unset", "(", "$", "list", "[", "$", "k", "]", ")", ";", "$", "NewElement", "->", "appendChild", "(", "$", "node", "->", "cloneNode", "(", "true", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "node", "->", "nextSibling", "->", "nodeName", ")", ")", "{", "$", "newList", "[", "$", "k", "]", "=", "$", "NewElement", ";", "}", "else", "if", "(", "array_key_exists", "(", "$", "node", "->", "nextSibling", "->", "nodeName", ",", "$", "this", "->", "inlineTags", ")", "||", "array_key_exists", "(", "$", "node", "->", "nextSibling", "->", "nodeName", ",", "array", "(", "'#text'", "=>", "true", ")", ")", ")", "{", "//do nothing", "}", "else", "{", "$", "newList", "[", "$", "k", "]", "=", "$", "NewElement", ";", "}", "}", "else", "{", "$", "newList", "[", "$", "k", "]", "=", "$", "node", ";", "$", "NewElement", "=", "$", "doc", "->", "createElement", "(", "'text'", ")", ";", "}", "}", "$", "list", "=", "$", "newList", ";", "}" ]
Test for mixed dom node types (DOMText and DOMElement) Wraps sibling DOMText and DOMElement inline tags into single DOMElement with a text attribute @return string The source HTML converted to XLIFF.
[ "Test", "for", "mixed", "dom", "node", "types", "(", "DOMText", "and", "DOMElement", ")", "Wraps", "sibling", "DOMText", "and", "DOMElement", "inline", "tags", "into", "single", "DOMElement", "with", "a", "text", "attribute" ]
train
https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Utils/Converter.php#L222-L257
ARCANEDEV/Sanitizer
src/Http/FormRequest.php
FormRequest.sanitize
protected function sanitize() { $sanitized = sanitizer()->make( $this->all(), $this->sanitizerRules() ); $this->replace($sanitized); }
php
protected function sanitize() { $sanitized = sanitizer()->make( $this->all(), $this->sanitizerRules() ); $this->replace($sanitized); }
[ "protected", "function", "sanitize", "(", ")", "{", "$", "sanitized", "=", "sanitizer", "(", ")", "->", "make", "(", "$", "this", "->", "all", "(", ")", ",", "$", "this", "->", "sanitizerRules", "(", ")", ")", ";", "$", "this", "->", "replace", "(", "$", "sanitized", ")", ";", "}" ]
Sanitize this request's input.
[ "Sanitize", "this", "request", "s", "input", "." ]
train
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Http/FormRequest.php#L30-L38
fubhy/graphql-php
src/Type/Definition/Types/InterfaceType.php
InterfaceType.addPossibleType
public function addPossibleType(ObjectType $type) { $this->types = array_unique(array_merge($this->types, [$type])); }
php
public function addPossibleType(ObjectType $type) { $this->types = array_unique(array_merge($this->types, [$type])); }
[ "public", "function", "addPossibleType", "(", "ObjectType", "$", "type", ")", "{", "$", "this", "->", "types", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "types", ",", "[", "$", "type", "]", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/InterfaceType.php#L109-L112
fubhy/graphql-php
src/Type/Definition/Types/InterfaceType.php
InterfaceType.resolveType
public function resolveType($value) { if (isset($this->typeResolver)) { return call_user_func($this->typeResolver, $value); } return $this->getTypeOf($value); }
php
public function resolveType($value) { if (isset($this->typeResolver)) { return call_user_func($this->typeResolver, $value); } return $this->getTypeOf($value); }
[ "public", "function", "resolveType", "(", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "typeResolver", ")", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "typeResolver", ",", "$", "value", ")", ";", "}", "return", "$", "this", "->", "getTypeOf", "(", "$", "value", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Type/Definition/Types/InterfaceType.php#L125-L132
netgen/ngopengraph
classes/ngopengraphobjectrelation.php
ngOpenGraphObjectRelation.getData
public function getData() { $relationObject = $this->ContentObjectAttribute->attribute( 'content' ); if ( $relationObject instanceof eZContentObject ) { return trim( $relationObject->attribute( 'name' ) ); } return ""; }
php
public function getData() { $relationObject = $this->ContentObjectAttribute->attribute( 'content' ); if ( $relationObject instanceof eZContentObject ) { return trim( $relationObject->attribute( 'name' ) ); } return ""; }
[ "public", "function", "getData", "(", ")", "{", "$", "relationObject", "=", "$", "this", "->", "ContentObjectAttribute", "->", "attribute", "(", "'content'", ")", ";", "if", "(", "$", "relationObject", "instanceof", "eZContentObject", ")", "{", "return", "trim", "(", "$", "relationObject", "->", "attribute", "(", "'name'", ")", ")", ";", "}", "return", "\"\"", ";", "}" ]
Returns data for the attribute @return string
[ "Returns", "data", "for", "the", "attribute" ]
train
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/classes/ngopengraphobjectrelation.php#L10-L20
netgen/ngopengraph
classes/ngopengraphobjectrelation.php
ngOpenGraphObjectRelation.getDataMember
public function getDataMember( $dataMember ) { if ( $dataMember === 'related_images' ) { $images = array(); $relationObject = $this->ContentObjectAttribute->attribute( 'content' ); if ( $relationObject instanceof eZContentObject ) { $dataMap = $relationObject->attribute( 'data_map' ); foreach ( $dataMap as $attribute ) { /** @var eZContentObjectAttribute $attribute */ if ( $attribute->attribute( 'data_type_string' ) !== eZImageType::DATA_TYPE_STRING ) { continue; } if ( $attribute->hasContent() ) { $imageAliasHandler = $attribute->attribute( 'content' ); $imageAlias = $imageAliasHandler->imageAlias( 'opengraph' ); if ( $imageAlias['is_valid'] == 1 ) { $images[] = eZSys::serverURL() . '/' . $imageAlias['full_path']; } } } } if ( empty( $images ) ) { $images[] = eZSys::serverURL() . eZURLOperator::eZImage( null, 'opengraph_default_image.png', '' ); } return $images; } return ""; }
php
public function getDataMember( $dataMember ) { if ( $dataMember === 'related_images' ) { $images = array(); $relationObject = $this->ContentObjectAttribute->attribute( 'content' ); if ( $relationObject instanceof eZContentObject ) { $dataMap = $relationObject->attribute( 'data_map' ); foreach ( $dataMap as $attribute ) { /** @var eZContentObjectAttribute $attribute */ if ( $attribute->attribute( 'data_type_string' ) !== eZImageType::DATA_TYPE_STRING ) { continue; } if ( $attribute->hasContent() ) { $imageAliasHandler = $attribute->attribute( 'content' ); $imageAlias = $imageAliasHandler->imageAlias( 'opengraph' ); if ( $imageAlias['is_valid'] == 1 ) { $images[] = eZSys::serverURL() . '/' . $imageAlias['full_path']; } } } } if ( empty( $images ) ) { $images[] = eZSys::serverURL() . eZURLOperator::eZImage( null, 'opengraph_default_image.png', '' ); } return $images; } return ""; }
[ "public", "function", "getDataMember", "(", "$", "dataMember", ")", "{", "if", "(", "$", "dataMember", "===", "'related_images'", ")", "{", "$", "images", "=", "array", "(", ")", ";", "$", "relationObject", "=", "$", "this", "->", "ContentObjectAttribute", "->", "attribute", "(", "'content'", ")", ";", "if", "(", "$", "relationObject", "instanceof", "eZContentObject", ")", "{", "$", "dataMap", "=", "$", "relationObject", "->", "attribute", "(", "'data_map'", ")", ";", "foreach", "(", "$", "dataMap", "as", "$", "attribute", ")", "{", "/** @var eZContentObjectAttribute $attribute */", "if", "(", "$", "attribute", "->", "attribute", "(", "'data_type_string'", ")", "!==", "eZImageType", "::", "DATA_TYPE_STRING", ")", "{", "continue", ";", "}", "if", "(", "$", "attribute", "->", "hasContent", "(", ")", ")", "{", "$", "imageAliasHandler", "=", "$", "attribute", "->", "attribute", "(", "'content'", ")", ";", "$", "imageAlias", "=", "$", "imageAliasHandler", "->", "imageAlias", "(", "'opengraph'", ")", ";", "if", "(", "$", "imageAlias", "[", "'is_valid'", "]", "==", "1", ")", "{", "$", "images", "[", "]", "=", "eZSys", "::", "serverURL", "(", ")", ".", "'/'", ".", "$", "imageAlias", "[", "'full_path'", "]", ";", "}", "}", "}", "}", "if", "(", "empty", "(", "$", "images", ")", ")", "{", "$", "images", "[", "]", "=", "eZSys", "::", "serverURL", "(", ")", ".", "eZURLOperator", "::", "eZImage", "(", "null", ",", "'opengraph_default_image.png'", ",", "''", ")", ";", "}", "return", "$", "images", ";", "}", "return", "\"\"", ";", "}" ]
Returns part of the data for the attribute @param string $dataMember @return string
[ "Returns", "part", "of", "the", "data", "for", "the", "attribute" ]
train
https://github.com/netgen/ngopengraph/blob/68a99862f240ee74174ea9b888a9a33743142e27/classes/ngopengraphobjectrelation.php#L29-L68
qcubed/orm
src/Database/Mysqli5/MysqliDatabase.php
MysqliDatabase.parseNameFromKeyDefinition
private function parseNameFromKeyDefinition($strKeyDefinition) { $strKeyDefinition = trim($strKeyDefinition); $intPosition = strpos($strKeyDefinition, '('); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } else { if ($intPosition == 0) // No Key Name Defined { return null; } } // If we're here, then we have a key name defined $strName = trim(substr($strKeyDefinition, 0, $intPosition)); // Rip Out leading and trailing "`" character (if applicable) if (substr($strName, 0, 1) == '`') { return substr($strName, 1, strlen($strName) - 2); } else { return $strName; } }
php
private function parseNameFromKeyDefinition($strKeyDefinition) { $strKeyDefinition = trim($strKeyDefinition); $intPosition = strpos($strKeyDefinition, '('); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } else { if ($intPosition == 0) // No Key Name Defined { return null; } } // If we're here, then we have a key name defined $strName = trim(substr($strKeyDefinition, 0, $intPosition)); // Rip Out leading and trailing "`" character (if applicable) if (substr($strName, 0, 1) == '`') { return substr($strName, 1, strlen($strName) - 2); } else { return $strName; } }
[ "private", "function", "parseNameFromKeyDefinition", "(", "$", "strKeyDefinition", ")", "{", "$", "strKeyDefinition", "=", "trim", "(", "$", "strKeyDefinition", ")", ";", "$", "intPosition", "=", "strpos", "(", "$", "strKeyDefinition", ",", "'('", ")", ";", "if", "(", "$", "intPosition", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid Key Definition: $strKeyDefinition\"", ")", ";", "}", "else", "{", "if", "(", "$", "intPosition", "==", "0", ")", "// No Key Name Defined", "{", "return", "null", ";", "}", "}", "// If we're here, then we have a key name defined", "$", "strName", "=", "trim", "(", "substr", "(", "$", "strKeyDefinition", ",", "0", ",", "$", "intPosition", ")", ")", ";", "// Rip Out leading and trailing \"`\" character (if applicable)", "if", "(", "substr", "(", "$", "strName", ",", "0", ",", "1", ")", "==", "'`'", ")", "{", "return", "substr", "(", "$", "strName", ",", "1", ",", "strlen", "(", "$", "strName", ")", "-", "2", ")", ";", "}", "else", "{", "return", "$", "strName", ";", "}", "}" ]
If the key name exists, this will parse it out and return it
[ "If", "the", "key", "name", "exists", "this", "will", "parse", "it", "out", "and", "return", "it" ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/Mysqli5/MysqliDatabase.php#L281-L305
qcubed/orm
src/Database/Mysqli5/MysqliDatabase.php
MysqliDatabase.parseColumnNameArrayFromKeyDefinition
private function parseColumnNameArrayFromKeyDefinition($strKeyDefinition) { $strKeyDefinition = trim($strKeyDefinition); // Get rid of the opening "(" and the closing ")" $intPosition = strpos($strKeyDefinition, '('); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } $strKeyDefinition = trim(substr($strKeyDefinition, $intPosition + 1)); $intPosition = strpos($strKeyDefinition, ')'); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } $strKeyDefinition = trim(substr($strKeyDefinition, 0, $intPosition)); // Create the Array // TODO: Current method doesn't support key names with commas or parenthesis in them! $strToReturn = explode(',', $strKeyDefinition); // Take out trailing and leading "`" character in each name (if applicable) for ($intIndex = 0; $intIndex < count($strToReturn); $intIndex++) { $strColumn = $strToReturn[$intIndex]; if (substr($strColumn, 0, 1) == '`') { $strColumn = substr($strColumn, 1, strpos($strColumn, '`', 1) - 1); } $strToReturn[$intIndex] = $strColumn; } return $strToReturn; }
php
private function parseColumnNameArrayFromKeyDefinition($strKeyDefinition) { $strKeyDefinition = trim($strKeyDefinition); // Get rid of the opening "(" and the closing ")" $intPosition = strpos($strKeyDefinition, '('); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } $strKeyDefinition = trim(substr($strKeyDefinition, $intPosition + 1)); $intPosition = strpos($strKeyDefinition, ')'); if ($intPosition === false) { throw new \Exception("Invalid Key Definition: $strKeyDefinition"); } $strKeyDefinition = trim(substr($strKeyDefinition, 0, $intPosition)); // Create the Array // TODO: Current method doesn't support key names with commas or parenthesis in them! $strToReturn = explode(',', $strKeyDefinition); // Take out trailing and leading "`" character in each name (if applicable) for ($intIndex = 0; $intIndex < count($strToReturn); $intIndex++) { $strColumn = $strToReturn[$intIndex]; if (substr($strColumn, 0, 1) == '`') { $strColumn = substr($strColumn, 1, strpos($strColumn, '`', 1) - 1); } $strToReturn[$intIndex] = $strColumn; } return $strToReturn; }
[ "private", "function", "parseColumnNameArrayFromKeyDefinition", "(", "$", "strKeyDefinition", ")", "{", "$", "strKeyDefinition", "=", "trim", "(", "$", "strKeyDefinition", ")", ";", "// Get rid of the opening \"(\" and the closing \")\"", "$", "intPosition", "=", "strpos", "(", "$", "strKeyDefinition", ",", "'('", ")", ";", "if", "(", "$", "intPosition", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid Key Definition: $strKeyDefinition\"", ")", ";", "}", "$", "strKeyDefinition", "=", "trim", "(", "substr", "(", "$", "strKeyDefinition", ",", "$", "intPosition", "+", "1", ")", ")", ";", "$", "intPosition", "=", "strpos", "(", "$", "strKeyDefinition", ",", "')'", ")", ";", "if", "(", "$", "intPosition", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid Key Definition: $strKeyDefinition\"", ")", ";", "}", "$", "strKeyDefinition", "=", "trim", "(", "substr", "(", "$", "strKeyDefinition", ",", "0", ",", "$", "intPosition", ")", ")", ";", "// Create the Array", "// TODO: Current method doesn't support key names with commas or parenthesis in them!", "$", "strToReturn", "=", "explode", "(", "','", ",", "$", "strKeyDefinition", ")", ";", "// Take out trailing and leading \"`\" character in each name (if applicable)", "for", "(", "$", "intIndex", "=", "0", ";", "$", "intIndex", "<", "count", "(", "$", "strToReturn", ")", ";", "$", "intIndex", "++", ")", "{", "$", "strColumn", "=", "$", "strToReturn", "[", "$", "intIndex", "]", ";", "if", "(", "substr", "(", "$", "strColumn", ",", "0", ",", "1", ")", "==", "'`'", ")", "{", "$", "strColumn", "=", "substr", "(", "$", "strColumn", ",", "1", ",", "strpos", "(", "$", "strColumn", ",", "'`'", ",", "1", ")", "-", "1", ")", ";", "}", "$", "strToReturn", "[", "$", "intIndex", "]", "=", "$", "strColumn", ";", "}", "return", "$", "strToReturn", ";", "}" ]
This will return an array of strings that are the names [COL], etc.
[ "This", "will", "return", "an", "array", "of", "strings", "that", "are", "the", "names", "[", "COL", "]", "etc", "." ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Database/Mysqli5/MysqliDatabase.php#L309-L342
webforge-labs/psc-cms
lib/Psc/CMS/Controller/FileUploadController.php
FileUploadController.getFiles
public function getFiles(Array $criteria = array(), Array $orderBy = NULL) { $files = new \Psc\Data\ArrayCollection( $this->manager->getRepository()->findBy($criteria, $orderBy) ); foreach ($files as $file) { $this->manager->attach($file); } return $files; }
php
public function getFiles(Array $criteria = array(), Array $orderBy = NULL) { $files = new \Psc\Data\ArrayCollection( $this->manager->getRepository()->findBy($criteria, $orderBy) ); foreach ($files as $file) { $this->manager->attach($file); } return $files; }
[ "public", "function", "getFiles", "(", "Array", "$", "criteria", "=", "array", "(", ")", ",", "Array", "$", "orderBy", "=", "NULL", ")", "{", "$", "files", "=", "new", "\\", "Psc", "\\", "Data", "\\", "ArrayCollection", "(", "$", "this", "->", "manager", "->", "getRepository", "(", ")", "->", "findBy", "(", "$", "criteria", ",", "$", "orderBy", ")", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "this", "->", "manager", "->", "attach", "(", "$", "file", ")", ";", "}", "return", "$", "files", ";", "}" ]
Returns a list of all uploaded files @return array
[ "Returns", "a", "list", "of", "all", "uploaded", "files" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/FileUploadController.php#L64-L74
CakeCMS/Core
src/View/AppView.php
AppView.getViewFile
public function getViewFile($name) { list($plugin, $name) = $this->pluginSplit($name); $return = null; foreach ($this->_paths($plugin) as $path) { $viewFile = FS::clean($path . $name . $this->_ext); if (FS::isFile($viewFile)) { $return = $this->_checkFilePath($viewFile, $path); break; } } return $return; }
php
public function getViewFile($name) { list($plugin, $name) = $this->pluginSplit($name); $return = null; foreach ($this->_paths($plugin) as $path) { $viewFile = FS::clean($path . $name . $this->_ext); if (FS::isFile($viewFile)) { $return = $this->_checkFilePath($viewFile, $path); break; } } return $return; }
[ "public", "function", "getViewFile", "(", "$", "name", ")", "{", "list", "(", "$", "plugin", ",", "$", "name", ")", "=", "$", "this", "->", "pluginSplit", "(", "$", "name", ")", ";", "$", "return", "=", "null", ";", "foreach", "(", "$", "this", "->", "_paths", "(", "$", "plugin", ")", "as", "$", "path", ")", "{", "$", "viewFile", "=", "FS", "::", "clean", "(", "$", "path", ".", "$", "name", ".", "$", "this", "->", "_ext", ")", ";", "if", "(", "FS", "::", "isFile", "(", "$", "viewFile", ")", ")", "{", "$", "return", "=", "$", "this", "->", "_checkFilePath", "(", "$", "viewFile", ",", "$", "path", ")", ";", "break", ";", "}", "}", "return", "$", "return", ";", "}" ]
Get view file path. @param string $name @return null|string
[ "Get", "view", "file", "path", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L64-L77
CakeCMS/Core
src/View/AppView.php
AppView.partial
public function partial($name, array $data = []) { $file = $this->_getLayoutPartialPath($name); if (FS::isFile($file)) { return $this->_render($file, $data); } return null; }
php
public function partial($name, array $data = []) { $file = $this->_getLayoutPartialPath($name); if (FS::isFile($file)) { return $this->_render($file, $data); } return null; }
[ "public", "function", "partial", "(", "$", "name", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "file", "=", "$", "this", "->", "_getLayoutPartialPath", "(", "$", "name", ")", ";", "if", "(", "FS", "::", "isFile", "(", "$", "file", ")", ")", "{", "return", "$", "this", "->", "_render", "(", "$", "file", ",", "$", "data", ")", ";", "}", "return", "null", ";", "}" ]
Render layout partial. @param string $name @param array $data @return null|string
[ "Render", "layout", "partial", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L109-L118
CakeCMS/Core
src/View/AppView.php
AppView.render
public function render($view = null, $layout = null) { $view = $this->_getFormView($view); return parent::render($view, $layout); }
php
public function render($view = null, $layout = null) { $view = $this->_getFormView($view); return parent::render($view, $layout); }
[ "public", "function", "render", "(", "$", "view", "=", "null", ",", "$", "layout", "=", "null", ")", "{", "$", "view", "=", "$", "this", "->", "_getFormView", "(", "$", "view", ")", ";", "return", "parent", "::", "render", "(", "$", "view", ",", "$", "layout", ")", ";", "}" ]
Renders view for given template file and layout. @param null|string $view @param null|string $layout @return null|string
[ "Renders", "view", "for", "given", "template", "file", "and", "layout", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L127-L131
CakeCMS/Core
src/View/AppView.php
AppView._findViewByRequest
protected function _findViewByRequest() { $paths = App::path('Template', $this->plugin); $action = (string) $this->request->getParam('action'); $controller = $this->request->getParam('controller'); $viewFile = $action . $this->_ext; $viewSubPath = $this->_getSubPaths($controller); foreach ($paths as $path) { foreach ($viewSubPath as $subPath) { $full = $path . $subPath . DS . $viewFile; if (FS::isFile($full)) { return $action; } $formView = $path . $subPath . DS . self::VIEW_FORM . $this->_ext; if (FS::isFile($formView)) { return self::VIEW_FORM; } } } return null; }
php
protected function _findViewByRequest() { $paths = App::path('Template', $this->plugin); $action = (string) $this->request->getParam('action'); $controller = $this->request->getParam('controller'); $viewFile = $action . $this->_ext; $viewSubPath = $this->_getSubPaths($controller); foreach ($paths as $path) { foreach ($viewSubPath as $subPath) { $full = $path . $subPath . DS . $viewFile; if (FS::isFile($full)) { return $action; } $formView = $path . $subPath . DS . self::VIEW_FORM . $this->_ext; if (FS::isFile($formView)) { return self::VIEW_FORM; } } } return null; }
[ "protected", "function", "_findViewByRequest", "(", ")", "{", "$", "paths", "=", "App", "::", "path", "(", "'Template'", ",", "$", "this", "->", "plugin", ")", ";", "$", "action", "=", "(", "string", ")", "$", "this", "->", "request", "->", "getParam", "(", "'action'", ")", ";", "$", "controller", "=", "$", "this", "->", "request", "->", "getParam", "(", "'controller'", ")", ";", "$", "viewFile", "=", "$", "action", ".", "$", "this", "->", "_ext", ";", "$", "viewSubPath", "=", "$", "this", "->", "_getSubPaths", "(", "$", "controller", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "foreach", "(", "$", "viewSubPath", "as", "$", "subPath", ")", "{", "$", "full", "=", "$", "path", ".", "$", "subPath", ".", "DS", ".", "$", "viewFile", ";", "if", "(", "FS", "::", "isFile", "(", "$", "full", ")", ")", "{", "return", "$", "action", ";", "}", "$", "formView", "=", "$", "path", ".", "$", "subPath", ".", "DS", ".", "self", "::", "VIEW_FORM", ".", "$", "this", "->", "_ext", ";", "if", "(", "FS", "::", "isFile", "(", "$", "formView", ")", ")", "{", "return", "self", "::", "VIEW_FORM", ";", "}", "}", "}", "return", "null", ";", "}" ]
Find form view by request. @return string|null
[ "Find", "form", "view", "by", "request", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L138-L162
CakeCMS/Core
src/View/AppView.php
AppView._getFormView
protected function _getFormView($view = null) { if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) { $view = $this->_findViewByRequest(); } return $view; }
php
protected function _getFormView($view = null) { if (empty($view) && Arr::in($this->request->getParam('action'), $this->_formActions)) { $view = $this->_findViewByRequest(); } return $view; }
[ "protected", "function", "_getFormView", "(", "$", "view", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "view", ")", "&&", "Arr", "::", "in", "(", "$", "this", "->", "request", "->", "getParam", "(", "'action'", ")", ",", "$", "this", "->", "_formActions", ")", ")", "{", "$", "view", "=", "$", "this", "->", "_findViewByRequest", "(", ")", ";", "}", "return", "$", "view", ";", "}" ]
Get current form view. @param null|string $view @return null
[ "Get", "current", "form", "view", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L170-L177
CakeCMS/Core
src/View/AppView.php
AppView._getLayoutPartialPath
protected function _getLayoutPartialPath($name) { list($plugin, $name) = $this->pluginSplit($name); $paths = $this->_paths($plugin); $layoutPaths = $this->_getSubPaths('Layout' . DS . 'Partial'); foreach ($paths as $path) { foreach ($layoutPaths as $layoutPath) { $partial = $path . $layoutPath . DS . $name . $this->_ext; if (FS::isFile($partial)) { return $partial; } } } return false; }
php
protected function _getLayoutPartialPath($name) { list($plugin, $name) = $this->pluginSplit($name); $paths = $this->_paths($plugin); $layoutPaths = $this->_getSubPaths('Layout' . DS . 'Partial'); foreach ($paths as $path) { foreach ($layoutPaths as $layoutPath) { $partial = $path . $layoutPath . DS . $name . $this->_ext; if (FS::isFile($partial)) { return $partial; } } } return false; }
[ "protected", "function", "_getLayoutPartialPath", "(", "$", "name", ")", "{", "list", "(", "$", "plugin", ",", "$", "name", ")", "=", "$", "this", "->", "pluginSplit", "(", "$", "name", ")", ";", "$", "paths", "=", "$", "this", "->", "_paths", "(", "$", "plugin", ")", ";", "$", "layoutPaths", "=", "$", "this", "->", "_getSubPaths", "(", "'Layout'", ".", "DS", ".", "'Partial'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "foreach", "(", "$", "layoutPaths", "as", "$", "layoutPath", ")", "{", "$", "partial", "=", "$", "path", ".", "$", "layoutPath", ".", "DS", ".", "$", "name", ".", "$", "this", "->", "_ext", ";", "if", "(", "FS", "::", "isFile", "(", "$", "partial", ")", ")", "{", "return", "$", "partial", ";", "}", "}", "}", "return", "false", ";", "}" ]
Finds an partial filename, returns false on failure. @param string $name @return bool|string
[ "Finds", "an", "partial", "filename", "returns", "false", "on", "failure", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/View/AppView.php#L185-L202
pointybeard/omnipay-nabtransact
src/Message/AbstractRequest.php
AbstractRequest.generateMessageTimestamp
protected static function generateMessageTimestamp() { list($micro, $sec) = explode(' ', microtime()); $ss = substr($micro, 2, 3); return date("YdmHis{$ss}000+600"); }
php
protected static function generateMessageTimestamp() { list($micro, $sec) = explode(' ', microtime()); $ss = substr($micro, 2, 3); return date("YdmHis{$ss}000+600"); }
[ "protected", "static", "function", "generateMessageTimestamp", "(", ")", "{", "list", "(", "$", "micro", ",", "$", "sec", ")", "=", "explode", "(", "' '", ",", "microtime", "(", ")", ")", ";", "$", "ss", "=", "substr", "(", "$", "micro", ",", "2", ",", "3", ")", ";", "return", "date", "(", "\"YdmHis{$ss}000+600\"", ")", ";", "}" ]
The format of the Timestamp or Log Time strings returned by NAB Transact XML API is: YYYYDDMMHHnnssKKK000sOOO where: YYYY = 4-digit year DD = 2-digit zero-padded day of month MM = 2-digit zero-padded month of year (January = 01) HH = 2-digit zero-padded hour of day in 24-hour clock format (midnight =0) is a 2-digit zero-padded minute of hour NN = 2-digit zero-padded second of minute SS = 3-digit zero-padded millisecond of second KKK = Static 0 characters, as NAB Transact does not store nanoseconds 000 = Time zone offset, where s is “+” or “-“, and OOO = minutes, from GMT. sOOO = 4-digit year. E.g. June 24, 2010 5:12:16.789 PM, Australian EST is: 20102406171216789000+600
[ "The", "format", "of", "the", "Timestamp", "or", "Log", "Time", "strings", "returned", "by", "NAB", "Transact", "XML", "API", "is", ":", "YYYYDDMMHHnnssKKK000sOOO", "where", ":", "YYYY", "=", "4", "-", "digit", "year", "DD", "=", "2", "-", "digit", "zero", "-", "padded", "day", "of", "month", "MM", "=", "2", "-", "digit", "zero", "-", "padded", "month", "of", "year", "(", "January", "=", "01", ")", "HH", "=", "2", "-", "digit", "zero", "-", "padded", "hour", "of", "day", "in", "24", "-", "hour", "clock", "format", "(", "midnight", "=", "0", ")", "is", "a", "2", "-", "digit", "zero", "-", "padded", "minute", "of", "hour", "NN", "=", "2", "-", "digit", "zero", "-", "padded", "second", "of", "minute", "SS", "=", "3", "-", "digit", "zero", "-", "padded", "millisecond", "of", "second", "KKK", "=", "Static", "0", "characters", "as", "NAB", "Transact", "does", "not", "store", "nanoseconds", "000", "=", "Time", "zone", "offset", "where", "s", "is", "“", "+", "”", "or", "“", "-", "“", "and", "OOO", "=", "minutes", "from", "GMT", ".", "sOOO", "=", "4", "-", "digit", "year", "." ]
train
https://github.com/pointybeard/omnipay-nabtransact/blob/72321a3a0cf4c359436f1dad3bb1141f47dd92f8/src/Message/AbstractRequest.php#L101-L107
traderinteractive/util-file-php
src/File.php
File.deleteDirectoryContents
public static function deleteDirectoryContents(string $directoryPath) { $paths = scandir($directoryPath); if ($paths === false) { throw new \Exception("cannot list directory '{$directoryPath}'"); } foreach ($paths as $path) { if ($path === '.' || $path === '..') { continue; } $fullPath = "{$directoryPath}/{$path}"; if (is_dir($fullPath)) { self::deleteDirectoryContents($fullPath);//RECURSIVE CALL self::throwIfFalse(rmdir($fullPath), "cannot delete '{$fullPath}'", 1); continue; } self::throwIfFalse(unlink($fullPath), "cannot delete '{$fullPath}'", 2); } }
php
public static function deleteDirectoryContents(string $directoryPath) { $paths = scandir($directoryPath); if ($paths === false) { throw new \Exception("cannot list directory '{$directoryPath}'"); } foreach ($paths as $path) { if ($path === '.' || $path === '..') { continue; } $fullPath = "{$directoryPath}/{$path}"; if (is_dir($fullPath)) { self::deleteDirectoryContents($fullPath);//RECURSIVE CALL self::throwIfFalse(rmdir($fullPath), "cannot delete '{$fullPath}'", 1); continue; } self::throwIfFalse(unlink($fullPath), "cannot delete '{$fullPath}'", 2); } }
[ "public", "static", "function", "deleteDirectoryContents", "(", "string", "$", "directoryPath", ")", "{", "$", "paths", "=", "scandir", "(", "$", "directoryPath", ")", ";", "if", "(", "$", "paths", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "\"cannot list directory '{$directoryPath}'\"", ")", ";", "}", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "$", "path", "===", "'.'", "||", "$", "path", "===", "'..'", ")", "{", "continue", ";", "}", "$", "fullPath", "=", "\"{$directoryPath}/{$path}\"", ";", "if", "(", "is_dir", "(", "$", "fullPath", ")", ")", "{", "self", "::", "deleteDirectoryContents", "(", "$", "fullPath", ")", ";", "//RECURSIVE CALL", "self", "::", "throwIfFalse", "(", "rmdir", "(", "$", "fullPath", ")", ",", "\"cannot delete '{$fullPath}'\"", ",", "1", ")", ";", "continue", ";", "}", "self", "::", "throwIfFalse", "(", "unlink", "(", "$", "fullPath", ")", ",", "\"cannot delete '{$fullPath}'\"", ",", "2", ")", ";", "}", "}" ]
Recursively deletes directory contents @param string $directoryPath absolute path of directory @return void @throws \Exception if file cannot be deleted @throws \Exception if directory cannot be deleted @throws \Exception if $directoryPath cannot be listed
[ "Recursively", "deletes", "directory", "contents" ]
train
https://github.com/traderinteractive/util-file-php/blob/07711b5f91232c39264c706c30dab07356dc823f/src/File.php#L24-L46
traderinteractive/util-file-php
src/File.php
File.delete
public static function delete(string $path) { if (trim($path) === '') { throw new \InvalidArgumentException('$path is not a string or is whitespace'); } if (!file_exists($path)) { return; } try { self::throwIfFalse(unlink($path), "unlink returned false for '{$path}'"); } catch (\Exception $e) { if (file_exists($path)) { throw $e; } } }
php
public static function delete(string $path) { if (trim($path) === '') { throw new \InvalidArgumentException('$path is not a string or is whitespace'); } if (!file_exists($path)) { return; } try { self::throwIfFalse(unlink($path), "unlink returned false for '{$path}'"); } catch (\Exception $e) { if (file_exists($path)) { throw $e; } } }
[ "public", "static", "function", "delete", "(", "string", "$", "path", ")", "{", "if", "(", "trim", "(", "$", "path", ")", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$path is not a string or is whitespace'", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "return", ";", "}", "try", "{", "self", "::", "throwIfFalse", "(", "unlink", "(", "$", "path", ")", ",", "\"unlink returned false for '{$path}'\"", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "$", "e", ";", "}", "}", "}" ]
Deletes the given file specified by $path @param string $path path to the file to be deleted @return void @throws \InvalidArgumentException if $path is whitespace @throws \Exception if unlink returns false
[ "Deletes", "the", "given", "file", "specified", "by", "$path" ]
train
https://github.com/traderinteractive/util-file-php/blob/07711b5f91232c39264c706c30dab07356dc823f/src/File.php#L58-L75
traderinteractive/util-file-php
src/File.php
File.deletePathIfEmpty
public static function deletePathIfEmpty(string $deletePath, string $stopAtPath = '/') { if (!file_exists($deletePath)) { return; } if (realpath($deletePath) === realpath($stopAtPath)) { return; } $handle = dir($deletePath); for ($entry = $handle->read(); $entry !== false; $entry = $handle->read()) { if ($entry == '.' || $entry == '..') { continue; } //dir not empty $handle->close(); return; } rmdir($deletePath); $handle->close(); //RECURSION!!! self::deletePathIfEmpty(dirname($deletePath), $stopAtPath); }
php
public static function deletePathIfEmpty(string $deletePath, string $stopAtPath = '/') { if (!file_exists($deletePath)) { return; } if (realpath($deletePath) === realpath($stopAtPath)) { return; } $handle = dir($deletePath); for ($entry = $handle->read(); $entry !== false; $entry = $handle->read()) { if ($entry == '.' || $entry == '..') { continue; } //dir not empty $handle->close(); return; } rmdir($deletePath); $handle->close(); //RECURSION!!! self::deletePathIfEmpty(dirname($deletePath), $stopAtPath); }
[ "public", "static", "function", "deletePathIfEmpty", "(", "string", "$", "deletePath", ",", "string", "$", "stopAtPath", "=", "'/'", ")", "{", "if", "(", "!", "file_exists", "(", "$", "deletePath", ")", ")", "{", "return", ";", "}", "if", "(", "realpath", "(", "$", "deletePath", ")", "===", "realpath", "(", "$", "stopAtPath", ")", ")", "{", "return", ";", "}", "$", "handle", "=", "dir", "(", "$", "deletePath", ")", ";", "for", "(", "$", "entry", "=", "$", "handle", "->", "read", "(", ")", ";", "$", "entry", "!==", "false", ";", "$", "entry", "=", "$", "handle", "->", "read", "(", ")", ")", "{", "if", "(", "$", "entry", "==", "'.'", "||", "$", "entry", "==", "'..'", ")", "{", "continue", ";", "}", "//dir not empty", "$", "handle", "->", "close", "(", ")", ";", "return", ";", "}", "rmdir", "(", "$", "deletePath", ")", ";", "$", "handle", "->", "close", "(", ")", ";", "//RECURSION!!!", "self", "::", "deletePathIfEmpty", "(", "dirname", "(", "$", "deletePath", ")", ",", "$", "stopAtPath", ")", ";", "}" ]
Recursively deletes the given directory path until a non-empty directory is found or the $stopAtPath is reached. @param string $deletePath The empty directory path to delete. @param string $stopAtPath The point at which the deletion should stop. Defaults to /. @return void
[ "Recursively", "deletes", "the", "given", "directory", "path", "until", "a", "non", "-", "empty", "directory", "is", "found", "or", "the", "$stopAtPath", "is", "reached", "." ]
train
https://github.com/traderinteractive/util-file-php/blob/07711b5f91232c39264c706c30dab07356dc823f/src/File.php#L85-L111
simplisti/jasper-starter
src/OptionFileTrait.php
OptionFileTrait.getCsvfile
public function getCsvfile ($key) { if (array_key_exists($key, $this->csv)) { return $this->csv[$key]; } return false; }
php
public function getCsvfile ($key) { if (array_key_exists($key, $this->csv)) { return $this->csv[$key]; } return false; }
[ "public", "function", "getCsvfile", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "csv", ")", ")", "{", "return", "$", "this", "->", "csv", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}" ]
Get the CSV file details for data source or false on failure @return string
[ "Get", "the", "CSV", "file", "details", "for", "data", "source", "or", "false", "on", "failure" ]
train
https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/OptionFileTrait.php#L46-L53
simplisti/jasper-starter
src/OptionFileTrait.php
OptionFileTrait.setCsvOptions
public function setCsvOptions ($charSet = 'utf-8', $delimField = ",", $delimNewLine = "\n", array $columnHeaderNames = []) { $this->csv['charSet'] = $charSet; $this->csv['delimField'] = $delimField; $this->csv['delimNewLine'] = $delimNewLine; $this->csv['columnHeaderNames'] = $columnHeaderNames; return $this; }
php
public function setCsvOptions ($charSet = 'utf-8', $delimField = ",", $delimNewLine = "\n", array $columnHeaderNames = []) { $this->csv['charSet'] = $charSet; $this->csv['delimField'] = $delimField; $this->csv['delimNewLine'] = $delimNewLine; $this->csv['columnHeaderNames'] = $columnHeaderNames; return $this; }
[ "public", "function", "setCsvOptions", "(", "$", "charSet", "=", "'utf-8'", ",", "$", "delimField", "=", "\",\"", ",", "$", "delimNewLine", "=", "\"\\n\"", ",", "array", "$", "columnHeaderNames", "=", "[", "]", ")", "{", "$", "this", "->", "csv", "[", "'charSet'", "]", "=", "$", "charSet", ";", "$", "this", "->", "csv", "[", "'delimField'", "]", "=", "$", "delimField", ";", "$", "this", "->", "csv", "[", "'delimNewLine'", "]", "=", "$", "delimNewLine", ";", "$", "this", "->", "csv", "[", "'columnHeaderNames'", "]", "=", "$", "columnHeaderNames", ";", "return", "$", "this", ";", "}" ]
Set the CSV file details for data source @return $this
[ "Set", "the", "CSV", "file", "details", "for", "data", "source" ]
train
https://github.com/simplisti/jasper-starter/blob/e03e24663e983710fb4f1afad6c85bde8553de65/src/OptionFileTrait.php#L60-L69
catacgc/juice-di-container
src/Container.php
JuiceContainer.offsetSet
public function offsetSet($id, $value) { if ($this->locked) { throw new BadMethodCallException('Setting values into a locked container is not allowed'); } if ($value instanceof JuiceParam) { $this->values[$id] = $value->value; return; } if (is_callable($value) || $value instanceof JuiceDefinition) { $this->definitions[$id] = $value; return; } if (is_string($value) && '@' == $value[0]) { $this->aliases[$id] = substr($value, 1); return; } $this->values[$id] = $value; }
php
public function offsetSet($id, $value) { if ($this->locked) { throw new BadMethodCallException('Setting values into a locked container is not allowed'); } if ($value instanceof JuiceParam) { $this->values[$id] = $value->value; return; } if (is_callable($value) || $value instanceof JuiceDefinition) { $this->definitions[$id] = $value; return; } if (is_string($value) && '@' == $value[0]) { $this->aliases[$id] = substr($value, 1); return; } $this->values[$id] = $value; }
[ "public", "function", "offsetSet", "(", "$", "id", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "locked", ")", "{", "throw", "new", "BadMethodCallException", "(", "'Setting values into a locked container is not allowed'", ")", ";", "}", "if", "(", "$", "value", "instanceof", "JuiceParam", ")", "{", "$", "this", "->", "values", "[", "$", "id", "]", "=", "$", "value", "->", "value", ";", "return", ";", "}", "if", "(", "is_callable", "(", "$", "value", ")", "||", "$", "value", "instanceof", "JuiceDefinition", ")", "{", "$", "this", "->", "definitions", "[", "$", "id", "]", "=", "$", "value", ";", "return", ";", "}", "if", "(", "is_string", "(", "$", "value", ")", "&&", "'@'", "==", "$", "value", "[", "0", "]", ")", "{", "$", "this", "->", "aliases", "[", "$", "id", "]", "=", "substr", "(", "$", "value", ",", "1", ")", ";", "return", ";", "}", "$", "this", "->", "values", "[", "$", "id", "]", "=", "$", "value", ";", "}" ]
Sets a parameter or a definition
[ "Sets", "a", "parameter", "or", "a", "definition" ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L46-L68
catacgc/juice-di-container
src/Container.php
JuiceContainer.offsetGet
public function offsetGet($id) { $this->lock(); if (!empty($this->resolving[$id])) { $chain = implode(' -> ', array_keys($this->resolving)); throw new InvalidArgumentException("Circular dependency found: $chain -> $id"); } $this->resolving[$id] = true; $return = $this->getServiceOrParameter($id); unset($this->resolving[$id]); return $return; }
php
public function offsetGet($id) { $this->lock(); if (!empty($this->resolving[$id])) { $chain = implode(' -> ', array_keys($this->resolving)); throw new InvalidArgumentException("Circular dependency found: $chain -> $id"); } $this->resolving[$id] = true; $return = $this->getServiceOrParameter($id); unset($this->resolving[$id]); return $return; }
[ "public", "function", "offsetGet", "(", "$", "id", ")", "{", "$", "this", "->", "lock", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "resolving", "[", "$", "id", "]", ")", ")", "{", "$", "chain", "=", "implode", "(", "' -> '", ",", "array_keys", "(", "$", "this", "->", "resolving", ")", ")", ";", "throw", "new", "InvalidArgumentException", "(", "\"Circular dependency found: $chain -> $id\"", ")", ";", "}", "$", "this", "->", "resolving", "[", "$", "id", "]", "=", "true", ";", "$", "return", "=", "$", "this", "->", "getServiceOrParameter", "(", "$", "id", ")", ";", "unset", "(", "$", "this", "->", "resolving", "[", "$", "id", "]", ")", ";", "return", "$", "return", ";", "}" ]
Gets a parameter or an object. @param string $id The unique identifier for the parameter or definition @return mixed The value of the parameter or an object @throws InvalidArgumentException if the identifier is not defined
[ "Gets", "a", "parameter", "or", "an", "object", "." ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L79-L93
catacgc/juice-di-container
src/Container.php
JuiceContainer.getServiceOrParameter
private function getServiceOrParameter($id) { if (array_key_exists($id, $this->aliases)) { return $this->offsetGet($this->aliases[$id]); } if (array_key_exists($id, $this->values)) { return $this->values[$id]; } if (array_key_exists($id, $this->definitions)) { return $this->values[$id] = $this->build($this->definitions[$id]); } throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); }
php
private function getServiceOrParameter($id) { if (array_key_exists($id, $this->aliases)) { return $this->offsetGet($this->aliases[$id]); } if (array_key_exists($id, $this->values)) { return $this->values[$id]; } if (array_key_exists($id, $this->definitions)) { return $this->values[$id] = $this->build($this->definitions[$id]); } throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); }
[ "private", "function", "getServiceOrParameter", "(", "$", "id", ")", "{", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "aliases", ")", ")", "{", "return", "$", "this", "->", "offsetGet", "(", "$", "this", "->", "aliases", "[", "$", "id", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "values", ")", ")", "{", "return", "$", "this", "->", "values", "[", "$", "id", "]", ";", "}", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "definitions", ")", ")", "{", "return", "$", "this", "->", "values", "[", "$", "id", "]", "=", "$", "this", "->", "build", "(", "$", "this", "->", "definitions", "[", "$", "id", "]", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Identifier \"%s\" is not defined.'", ",", "$", "id", ")", ")", ";", "}" ]
Return the service associated with this unique identifier @param string $id The unique identifier @return mixed @throws InvalidArgumentException
[ "Return", "the", "service", "associated", "with", "this", "unique", "identifier" ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L102-L117
catacgc/juice-di-container
src/Container.php
JuiceContainer.offsetExists
public function offsetExists($id) { return isset($this->values[$id]) || isset($this->definitions[$id]) || isset($this->aliases[$id]); }
php
public function offsetExists($id) { return isset($this->values[$id]) || isset($this->definitions[$id]) || isset($this->aliases[$id]); }
[ "public", "function", "offsetExists", "(", "$", "id", ")", "{", "return", "isset", "(", "$", "this", "->", "values", "[", "$", "id", "]", ")", "||", "isset", "(", "$", "this", "->", "definitions", "[", "$", "id", "]", ")", "||", "isset", "(", "$", "this", "->", "aliases", "[", "$", "id", "]", ")", ";", "}" ]
Checks if a parameter or an object is set. @param string $id The unique identifier for the parameter or service @return Boolean
[ "Checks", "if", "a", "parameter", "or", "an", "object", "is", "set", "." ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L126-L129
catacgc/juice-di-container
src/Container.php
JuiceContainer.offsetUnset
public function offsetUnset($id) { unset($this->values[$id]); unset($this->definitions[$id]); unset($this->aliases[$id]); }
php
public function offsetUnset($id) { unset($this->values[$id]); unset($this->definitions[$id]); unset($this->aliases[$id]); }
[ "public", "function", "offsetUnset", "(", "$", "id", ")", "{", "unset", "(", "$", "this", "->", "values", "[", "$", "id", "]", ")", ";", "unset", "(", "$", "this", "->", "definitions", "[", "$", "id", "]", ")", ";", "unset", "(", "$", "this", "->", "aliases", "[", "$", "id", "]", ")", ";", "}" ]
Unsets a parameter or an object. @param string $id The unique identifier for the parameter or object
[ "Unsets", "a", "parameter", "or", "an", "object", "." ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L136-L141
catacgc/juice-di-container
src/Container.php
JuiceContainer.raw
public function raw($id) { if (array_key_exists($id, $this->values)) { return $this->values[$id]; } if (array_key_exists($id, $this->definitions)) { return $this->definitions[$id]; } if (array_key_exists($id, $this->aliases)) { return $this->aliases[$id]; } throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); }
php
public function raw($id) { if (array_key_exists($id, $this->values)) { return $this->values[$id]; } if (array_key_exists($id, $this->definitions)) { return $this->definitions[$id]; } if (array_key_exists($id, $this->aliases)) { return $this->aliases[$id]; } throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); }
[ "public", "function", "raw", "(", "$", "id", ")", "{", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "values", ")", ")", "{", "return", "$", "this", "->", "values", "[", "$", "id", "]", ";", "}", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "definitions", ")", ")", "{", "return", "$", "this", "->", "definitions", "[", "$", "id", "]", ";", "}", "if", "(", "array_key_exists", "(", "$", "id", ",", "$", "this", "->", "aliases", ")", ")", "{", "return", "$", "this", "->", "aliases", "[", "$", "id", "]", ";", "}", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Identifier \"%s\" is not defined.'", ",", "$", "id", ")", ")", ";", "}" ]
Gets a parameter or the closure defining an object. @param string $id The unique identifier for the parameter or object @return mixed The value of the parameter or the closure defining an object @throws InvalidArgumentException if the identifier is not defined
[ "Gets", "a", "parameter", "or", "the", "closure", "defining", "an", "object", "." ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L152-L167
catacgc/juice-di-container
src/Container.php
JuiceContainer.build
public function build($definition) { if (is_callable($definition)) { return call_user_func($definition, $this); } return $this->buildFromDefinition($definition); }
php
public function build($definition) { if (is_callable($definition)) { return call_user_func($definition, $this); } return $this->buildFromDefinition($definition); }
[ "public", "function", "build", "(", "$", "definition", ")", "{", "if", "(", "is_callable", "(", "$", "definition", ")", ")", "{", "return", "call_user_func", "(", "$", "definition", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "buildFromDefinition", "(", "$", "definition", ")", ";", "}" ]
Build a definition and return the instantiated object @param $definition @return mixed
[ "Build", "a", "definition", "and", "return", "the", "instantiated", "object" ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L175-L182
catacgc/juice-di-container
src/Container.php
JuiceContainer.resolveValue
protected function resolveValue($value) { if (is_array($value)) { foreach ($value as $index => $val) { $value[$index] = $this->resolveValue($val); } return $value; } if (is_string($value) && '@' == $value[0]) { return $this->offsetGet(substr($value, 1)); } return $value; }
php
protected function resolveValue($value) { if (is_array($value)) { foreach ($value as $index => $val) { $value[$index] = $this->resolveValue($val); } return $value; } if (is_string($value) && '@' == $value[0]) { return $this->offsetGet(substr($value, 1)); } return $value; }
[ "protected", "function", "resolveValue", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "index", "=>", "$", "val", ")", "{", "$", "value", "[", "$", "index", "]", "=", "$", "this", "->", "resolveValue", "(", "$", "val", ")", ";", "}", "return", "$", "value", ";", "}", "if", "(", "is_string", "(", "$", "value", ")", "&&", "'@'", "==", "$", "value", "[", "0", "]", ")", "{", "return", "$", "this", "->", "offsetGet", "(", "substr", "(", "$", "value", ",", "1", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Finds and marks references (strings beginning with an @) to other services or parameters
[ "Finds", "and", "marks", "references", "(", "strings", "beginning", "with", "an" ]
train
https://github.com/catacgc/juice-di-container/blob/773bb155b9d2fd8b8bed7754d88edc3b06d6d12d/src/Container.php#L202-L217
geekwright/Po
src/PoInitSmarty.php
PoInitSmarty.msginitString
public function msginitString(string $source, string $refname): PoFile { if (!($this->poFile instanceof PoFile)) { $this->poFile = new PoFile; } $tpl = $this->smarty->createTemplate('eval:'.$source); $tags = $this->smarty->getTags($tpl); $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); foreach ($tags as $tag) { if (in_array($tag[0], $translateTags)) { $entry = new PoEntry; $haveEntry = false; $entry->add(PoTokens::REFERENCE, $refname); foreach ($tag[1] as $temp) { foreach ($temp as $key => $value) { if ($value[0]=="'" || $value[0]=='"') { if (in_array($key, $this->msgidArgNames)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($value)); $haveEntry = true; } elseif (in_array($key, $this->msgidPluralArgNames)) { $entry->set(PoTokens::PLURAL, $this->escapeForPo($value)); } elseif (in_array($key, $this->msgctxtArgNames)) { $entry->set(PoTokens::CONTEXT, $this->escapeForPo($value)); } } } } if ($haveEntry) { $this->checkPhpFormatFlag($entry); $this->poFile->mergeEntry($entry); } } } return $this->poFile; }
php
public function msginitString(string $source, string $refname): PoFile { if (!($this->poFile instanceof PoFile)) { $this->poFile = new PoFile; } $tpl = $this->smarty->createTemplate('eval:'.$source); $tags = $this->smarty->getTags($tpl); $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); foreach ($tags as $tag) { if (in_array($tag[0], $translateTags)) { $entry = new PoEntry; $haveEntry = false; $entry->add(PoTokens::REFERENCE, $refname); foreach ($tag[1] as $temp) { foreach ($temp as $key => $value) { if ($value[0]=="'" || $value[0]=='"') { if (in_array($key, $this->msgidArgNames)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($value)); $haveEntry = true; } elseif (in_array($key, $this->msgidPluralArgNames)) { $entry->set(PoTokens::PLURAL, $this->escapeForPo($value)); } elseif (in_array($key, $this->msgctxtArgNames)) { $entry->set(PoTokens::CONTEXT, $this->escapeForPo($value)); } } } } if ($haveEntry) { $this->checkPhpFormatFlag($entry); $this->poFile->mergeEntry($entry); } } } return $this->poFile; }
[ "public", "function", "msginitString", "(", "string", "$", "source", ",", "string", "$", "refname", ")", ":", "PoFile", "{", "if", "(", "!", "(", "$", "this", "->", "poFile", "instanceof", "PoFile", ")", ")", "{", "$", "this", "->", "poFile", "=", "new", "PoFile", ";", "}", "$", "tpl", "=", "$", "this", "->", "smarty", "->", "createTemplate", "(", "'eval:'", ".", "$", "source", ")", ";", "$", "tags", "=", "$", "this", "->", "smarty", "->", "getTags", "(", "$", "tpl", ")", ";", "$", "translateTags", "=", "array_merge", "(", "$", "this", "->", "gettextTags", ",", "$", "this", "->", "pgettextTags", ",", "$", "this", "->", "ngettextTags", ")", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "if", "(", "in_array", "(", "$", "tag", "[", "0", "]", ",", "$", "translateTags", ")", ")", "{", "$", "entry", "=", "new", "PoEntry", ";", "$", "haveEntry", "=", "false", ";", "$", "entry", "->", "add", "(", "PoTokens", "::", "REFERENCE", ",", "$", "refname", ")", ";", "foreach", "(", "$", "tag", "[", "1", "]", "as", "$", "temp", ")", "{", "foreach", "(", "$", "temp", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "[", "0", "]", "==", "\"'\"", "||", "$", "value", "[", "0", "]", "==", "'\"'", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "msgidArgNames", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "MESSAGE", ",", "$", "this", "->", "escapeForPo", "(", "$", "value", ")", ")", ";", "$", "haveEntry", "=", "true", ";", "}", "elseif", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "msgidPluralArgNames", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "PLURAL", ",", "$", "this", "->", "escapeForPo", "(", "$", "value", ")", ")", ";", "}", "elseif", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "msgctxtArgNames", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "CONTEXT", ",", "$", "this", "->", "escapeForPo", "(", "$", "value", ")", ")", ";", "}", "}", "}", "}", "if", "(", "$", "haveEntry", ")", "{", "$", "this", "->", "checkPhpFormatFlag", "(", "$", "entry", ")", ";", "$", "this", "->", "poFile", "->", "mergeEntry", "(", "$", "entry", ")", ";", "}", "}", "}", "return", "$", "this", "->", "poFile", ";", "}" ]
Inspect the supplied source, capture gettext references as a PoFile object. @param string $source php source code @param string $refname source identification used for PO reference comments @return PoFile
[ "Inspect", "the", "supplied", "source", "capture", "gettext", "references", "as", "a", "PoFile", "object", "." ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoInitSmarty.php#L183-L219
struzik-vladislav/php-error-handler
src/Processor/LoggerProcessor.php
LoggerProcessor.handle
public function handle($errno, $errstr, $errfile, $errline) { $level = $this->getAssociatedLogLevel($errno); $this->logger->log( $level, sprintf('%s in %s:%s', $errstr, $errfile, $errline), [ 'backtrace' => (new \Exception(''))->getTraceAsString(), ] ); return null; }
php
public function handle($errno, $errstr, $errfile, $errline) { $level = $this->getAssociatedLogLevel($errno); $this->logger->log( $level, sprintf('%s in %s:%s', $errstr, $errfile, $errline), [ 'backtrace' => (new \Exception(''))->getTraceAsString(), ] ); return null; }
[ "public", "function", "handle", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "$", "level", "=", "$", "this", "->", "getAssociatedLogLevel", "(", "$", "errno", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "$", "level", ",", "sprintf", "(", "'%s in %s:%s'", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", ",", "[", "'backtrace'", "=>", "(", "new", "\\", "Exception", "(", "''", ")", ")", "->", "getTraceAsString", "(", ")", ",", "]", ")", ";", "return", "null", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/Processor/LoggerProcessor.php#L59-L72
struzik-vladislav/php-error-handler
src/Processor/LoggerProcessor.php
LoggerProcessor.getAssociatedLogLevel
private function getAssociatedLogLevel($errno) { $associations = [ E_WARNING => LogLevel::WARNING, E_NOTICE => LogLevel::NOTICE, E_USER_ERROR => LogLevel::ERROR, E_USER_WARNING => LogLevel::WARNING, E_USER_NOTICE => LogLevel::NOTICE, E_STRICT => LogLevel::NOTICE, E_RECOVERABLE_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::NOTICE, E_USER_DEPRECATED => LogLevel::NOTICE, ]; if (isset($associations[$errno])) { return $associations[$errno]; } return LogLevel::CRITICAL; }
php
private function getAssociatedLogLevel($errno) { $associations = [ E_WARNING => LogLevel::WARNING, E_NOTICE => LogLevel::NOTICE, E_USER_ERROR => LogLevel::ERROR, E_USER_WARNING => LogLevel::WARNING, E_USER_NOTICE => LogLevel::NOTICE, E_STRICT => LogLevel::NOTICE, E_RECOVERABLE_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::NOTICE, E_USER_DEPRECATED => LogLevel::NOTICE, ]; if (isset($associations[$errno])) { return $associations[$errno]; } return LogLevel::CRITICAL; }
[ "private", "function", "getAssociatedLogLevel", "(", "$", "errno", ")", "{", "$", "associations", "=", "[", "E_WARNING", "=>", "LogLevel", "::", "WARNING", ",", "E_NOTICE", "=>", "LogLevel", "::", "NOTICE", ",", "E_USER_ERROR", "=>", "LogLevel", "::", "ERROR", ",", "E_USER_WARNING", "=>", "LogLevel", "::", "WARNING", ",", "E_USER_NOTICE", "=>", "LogLevel", "::", "NOTICE", ",", "E_STRICT", "=>", "LogLevel", "::", "NOTICE", ",", "E_RECOVERABLE_ERROR", "=>", "LogLevel", "::", "ERROR", ",", "E_DEPRECATED", "=>", "LogLevel", "::", "NOTICE", ",", "E_USER_DEPRECATED", "=>", "LogLevel", "::", "NOTICE", ",", "]", ";", "if", "(", "isset", "(", "$", "associations", "[", "$", "errno", "]", ")", ")", "{", "return", "$", "associations", "[", "$", "errno", "]", ";", "}", "return", "LogLevel", "::", "CRITICAL", ";", "}" ]
Getting the log level constant associated with error code. @param int $errno level of the error raised @return string
[ "Getting", "the", "log", "level", "constant", "associated", "with", "error", "code", "." ]
train
https://github.com/struzik-vladislav/php-error-handler/blob/87fa9f56edca7011f78e00659bb094b4fe713ebe/src/Processor/LoggerProcessor.php#L81-L100
inc2734/wp-share-buttons
src/App/Shortcode/Copy.php
Copy._shortcode
public function _shortcode( $attributes ) { if ( ! isset( $attributes['post_id'] ) ) { return; } $title = wp_strip_all_tags( get_the_title( $attributes['post_id'] ) . ' - ' . get_bloginfo( 'name' ) ); $attributes = shortcode_atts( [ 'type' => 'balloon', 'title' => apply_filters( 'inc2734_wp_share_buttons_shared_title', $title, 'copy' ), 'post_id' => '', 'hashtags' => apply_filters( 'inc2734_wp_share_buttons_shared_hashtags', '', 'copy' ), ], $attributes ); return $this->render( 'copy/copy', [ 'type' => $attributes['type'], 'title' => $attributes['title'], 'post_id' => $attributes['post_id'], 'hashtags' => $attributes['hashtags'], ] ); }
php
public function _shortcode( $attributes ) { if ( ! isset( $attributes['post_id'] ) ) { return; } $title = wp_strip_all_tags( get_the_title( $attributes['post_id'] ) . ' - ' . get_bloginfo( 'name' ) ); $attributes = shortcode_atts( [ 'type' => 'balloon', 'title' => apply_filters( 'inc2734_wp_share_buttons_shared_title', $title, 'copy' ), 'post_id' => '', 'hashtags' => apply_filters( 'inc2734_wp_share_buttons_shared_hashtags', '', 'copy' ), ], $attributes ); return $this->render( 'copy/copy', [ 'type' => $attributes['type'], 'title' => $attributes['title'], 'post_id' => $attributes['post_id'], 'hashtags' => $attributes['hashtags'], ] ); }
[ "public", "function", "_shortcode", "(", "$", "attributes", ")", "{", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'post_id'", "]", ")", ")", "{", "return", ";", "}", "$", "title", "=", "wp_strip_all_tags", "(", "get_the_title", "(", "$", "attributes", "[", "'post_id'", "]", ")", ".", "' - '", ".", "get_bloginfo", "(", "'name'", ")", ")", ";", "$", "attributes", "=", "shortcode_atts", "(", "[", "'type'", "=>", "'balloon'", ",", "'title'", "=>", "apply_filters", "(", "'inc2734_wp_share_buttons_shared_title'", ",", "$", "title", ",", "'copy'", ")", ",", "'post_id'", "=>", "''", ",", "'hashtags'", "=>", "apply_filters", "(", "'inc2734_wp_share_buttons_shared_hashtags'", ",", "''", ",", "'copy'", ")", ",", "]", ",", "$", "attributes", ")", ";", "return", "$", "this", "->", "render", "(", "'copy/copy'", ",", "[", "'type'", "=>", "$", "attributes", "[", "'type'", "]", ",", "'title'", "=>", "$", "attributes", "[", "'title'", "]", ",", "'post_id'", "=>", "$", "attributes", "[", "'post_id'", "]", ",", "'hashtags'", "=>", "$", "attributes", "[", "'hashtags'", "]", ",", "]", ")", ";", "}" ]
Register shortcode @param array $attributes @return void
[ "Register", "shortcode" ]
train
https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Shortcode/Copy.php#L23-L49
anime-db/world-art-filler-bundle
src/Service/Refiller.php
Refiller.refill
public function refill(Item $item, $field) { if (!($url = $this->getSourceForFill($item))) { return $item; } if ($field == self::FIELD_IMAGES) { if (preg_match('/id=(?<id>\d+)/', $url, $mat)) { foreach ($this->filler->getFrames($mat['id']) as $frame) { // check of the existence of the image /* @var $image \AnimeDb\Bundle\CatalogBundle\Entity\Image */ foreach ($item->getImages() as $image) { if ($frame == $image->getSource()) { continue 2; } } $item->addImage((new Image())->setSource($frame)); } } } elseif ($new_item = $this->filler->fill(['url' => $url, 'frames' => false])) { $item = $this->fillItem($item, $new_item, $field); } return $item; }
php
public function refill(Item $item, $field) { if (!($url = $this->getSourceForFill($item))) { return $item; } if ($field == self::FIELD_IMAGES) { if (preg_match('/id=(?<id>\d+)/', $url, $mat)) { foreach ($this->filler->getFrames($mat['id']) as $frame) { // check of the existence of the image /* @var $image \AnimeDb\Bundle\CatalogBundle\Entity\Image */ foreach ($item->getImages() as $image) { if ($frame == $image->getSource()) { continue 2; } } $item->addImage((new Image())->setSource($frame)); } } } elseif ($new_item = $this->filler->fill(['url' => $url, 'frames' => false])) { $item = $this->fillItem($item, $new_item, $field); } return $item; }
[ "public", "function", "refill", "(", "Item", "$", "item", ",", "$", "field", ")", "{", "if", "(", "!", "(", "$", "url", "=", "$", "this", "->", "getSourceForFill", "(", "$", "item", ")", ")", ")", "{", "return", "$", "item", ";", "}", "if", "(", "$", "field", "==", "self", "::", "FIELD_IMAGES", ")", "{", "if", "(", "preg_match", "(", "'/id=(?<id>\\d+)/'", ",", "$", "url", ",", "$", "mat", ")", ")", "{", "foreach", "(", "$", "this", "->", "filler", "->", "getFrames", "(", "$", "mat", "[", "'id'", "]", ")", "as", "$", "frame", ")", "{", "// check of the existence of the image", "/* @var $image \\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Image */", "foreach", "(", "$", "item", "->", "getImages", "(", ")", "as", "$", "image", ")", "{", "if", "(", "$", "frame", "==", "$", "image", "->", "getSource", "(", ")", ")", "{", "continue", "2", ";", "}", "}", "$", "item", "->", "addImage", "(", "(", "new", "Image", "(", ")", ")", "->", "setSource", "(", "$", "frame", ")", ")", ";", "}", "}", "}", "elseif", "(", "$", "new_item", "=", "$", "this", "->", "filler", "->", "fill", "(", "[", "'url'", "=>", "$", "url", ",", "'frames'", "=>", "false", "]", ")", ")", "{", "$", "item", "=", "$", "this", "->", "fillItem", "(", "$", "item", ",", "$", "new_item", ",", "$", "field", ")", ";", "}", "return", "$", "item", ";", "}" ]
Refill item field from source. @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item @param string $field @return \AnimeDb\Bundle\CatalogBundle\Entity\Item
[ "Refill", "item", "field", "from", "source", "." ]
train
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L131-L155
anime-db/world-art-filler-bundle
src/Service/Refiller.php
Refiller.isCanSearch
public function isCanSearch(Item $item, $field) { if (!in_array($field, $this->supported_fields)) { return false; } if ($this->isCanRefill($item, $field) || $item->getName()) { return true; } /* @var $name \AnimeDb\Bundle\CatalogBundle\Entity\Name */ foreach ($item->getNames() as $name) { if ($name->getName()) { return true; } } return false; }
php
public function isCanSearch(Item $item, $field) { if (!in_array($field, $this->supported_fields)) { return false; } if ($this->isCanRefill($item, $field) || $item->getName()) { return true; } /* @var $name \AnimeDb\Bundle\CatalogBundle\Entity\Name */ foreach ($item->getNames() as $name) { if ($name->getName()) { return true; } } return false; }
[ "public", "function", "isCanSearch", "(", "Item", "$", "item", ",", "$", "field", ")", "{", "if", "(", "!", "in_array", "(", "$", "field", ",", "$", "this", "->", "supported_fields", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "isCanRefill", "(", "$", "item", ",", "$", "field", ")", "||", "$", "item", "->", "getName", "(", ")", ")", "{", "return", "true", ";", "}", "/* @var $name \\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Name */", "foreach", "(", "$", "item", "->", "getNames", "(", ")", "as", "$", "name", ")", "{", "if", "(", "$", "name", "->", "getName", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Is can search. @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item @param string $field @return bool
[ "Is", "can", "search", "." ]
train
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L165-L181
anime-db/world-art-filler-bundle
src/Service/Refiller.php
Refiller.search
public function search(Item $item, $field) { // can refill from source. not need search if ($url = $this->getSourceForFill($item)) { return [ new ItemRefiller( $item->getName(), ['url' => $url], $url, $item->getCover(), $item->getSummary() ), ]; } // get name for search if (!($name = $item->getName())) { foreach ($item->getNames() as $name) { if ($name) { break; } } } $result = []; // do search if ($name) { $result = $this->search->search(['name' => $name]); /* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */ foreach ($result as $key => $item) { parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query); $link = array_values($query)[0]['url']; $result[$key] = new ItemRefiller( $item->getName(), ['url' => $link], $link, $item->getImage(), $item->getDescription() ); } } return $result; }
php
public function search(Item $item, $field) { // can refill from source. not need search if ($url = $this->getSourceForFill($item)) { return [ new ItemRefiller( $item->getName(), ['url' => $url], $url, $item->getCover(), $item->getSummary() ), ]; } // get name for search if (!($name = $item->getName())) { foreach ($item->getNames() as $name) { if ($name) { break; } } } $result = []; // do search if ($name) { $result = $this->search->search(['name' => $name]); /* @var $item \AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Search\Item */ foreach ($result as $key => $item) { parse_str(parse_url($item->getLink(), PHP_URL_QUERY), $query); $link = array_values($query)[0]['url']; $result[$key] = new ItemRefiller( $item->getName(), ['url' => $link], $link, $item->getImage(), $item->getDescription() ); } } return $result; }
[ "public", "function", "search", "(", "Item", "$", "item", ",", "$", "field", ")", "{", "// can refill from source. not need search", "if", "(", "$", "url", "=", "$", "this", "->", "getSourceForFill", "(", "$", "item", ")", ")", "{", "return", "[", "new", "ItemRefiller", "(", "$", "item", "->", "getName", "(", ")", ",", "[", "'url'", "=>", "$", "url", "]", ",", "$", "url", ",", "$", "item", "->", "getCover", "(", ")", ",", "$", "item", "->", "getSummary", "(", ")", ")", ",", "]", ";", "}", "// get name for search", "if", "(", "!", "(", "$", "name", "=", "$", "item", "->", "getName", "(", ")", ")", ")", "{", "foreach", "(", "$", "item", "->", "getNames", "(", ")", "as", "$", "name", ")", "{", "if", "(", "$", "name", ")", "{", "break", ";", "}", "}", "}", "$", "result", "=", "[", "]", ";", "// do search", "if", "(", "$", "name", ")", "{", "$", "result", "=", "$", "this", "->", "search", "->", "search", "(", "[", "'name'", "=>", "$", "name", "]", ")", ";", "/* @var $item \\AnimeDb\\Bundle\\CatalogBundle\\Plugin\\Fill\\Search\\Item */", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "item", ")", "{", "parse_str", "(", "parse_url", "(", "$", "item", "->", "getLink", "(", ")", ",", "PHP_URL_QUERY", ")", ",", "$", "query", ")", ";", "$", "link", "=", "array_values", "(", "$", "query", ")", "[", "0", "]", "[", "'url'", "]", ";", "$", "result", "[", "$", "key", "]", "=", "new", "ItemRefiller", "(", "$", "item", "->", "getName", "(", ")", ",", "[", "'url'", "=>", "$", "link", "]", ",", "$", "link", ",", "$", "item", "->", "getImage", "(", ")", ",", "$", "item", "->", "getDescription", "(", ")", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Search items for refill. @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item @param string $field @return array [\AnimeDb\Bundle\CatalogBundle\Plugin\Fill\Refiller\Item]
[ "Search", "items", "for", "refill", "." ]
train
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L191-L234
anime-db/world-art-filler-bundle
src/Service/Refiller.php
Refiller.fillItem
protected function fillItem(Item $item, Item $new_item, $field) { switch ($field) { case self::FIELD_COUNTRY: $item->setCountry($new_item->getCountry()); break; case self::FIELD_DATE_END: $item->setDateEnd($new_item->getDateEnd()); break; case self::FIELD_DATE_PREMIERE: $item->setDatePremiere($new_item->getDatePremiere()); break; case self::FIELD_DURATION: $item->setDuration($new_item->getDuration()); break; case self::FIELD_EPISODES: $item->setEpisodes($new_item->getEpisodes()); break; case self::FIELD_EPISODES_NUMBER: $item->setEpisodesNumber($new_item->getEpisodesNumber()); break; case self::FIELD_FILE_INFO: $item->setFileInfo($new_item->getFileInfo()); break; case self::FIELD_GENRES: /* @var $new_genre \AnimeDb\Bundle\CatalogBundle\Entity\Genre */ foreach ($new_item->getGenres() as $new_genre) { $item->addGenre($new_genre); } break; case self::FIELD_NAMES: // set main name in top of names list $new_names = $new_item->getNames()->toArray(); array_unshift($new_names, (new Name())->setName($new_item->getName())); foreach ($new_names as $new_name) { $item->addName($new_name); } break; case self::FIELD_SOURCES: foreach ($new_item->getSources() as $new_source) { $item->addSource($new_source); } break; case self::FIELD_STUDIO: $item->setStudio($new_item->getStudio()); break; case self::FIELD_SUMMARY: $item->setSummary($new_item->getSummary()); break; } return $item; }
php
protected function fillItem(Item $item, Item $new_item, $field) { switch ($field) { case self::FIELD_COUNTRY: $item->setCountry($new_item->getCountry()); break; case self::FIELD_DATE_END: $item->setDateEnd($new_item->getDateEnd()); break; case self::FIELD_DATE_PREMIERE: $item->setDatePremiere($new_item->getDatePremiere()); break; case self::FIELD_DURATION: $item->setDuration($new_item->getDuration()); break; case self::FIELD_EPISODES: $item->setEpisodes($new_item->getEpisodes()); break; case self::FIELD_EPISODES_NUMBER: $item->setEpisodesNumber($new_item->getEpisodesNumber()); break; case self::FIELD_FILE_INFO: $item->setFileInfo($new_item->getFileInfo()); break; case self::FIELD_GENRES: /* @var $new_genre \AnimeDb\Bundle\CatalogBundle\Entity\Genre */ foreach ($new_item->getGenres() as $new_genre) { $item->addGenre($new_genre); } break; case self::FIELD_NAMES: // set main name in top of names list $new_names = $new_item->getNames()->toArray(); array_unshift($new_names, (new Name())->setName($new_item->getName())); foreach ($new_names as $new_name) { $item->addName($new_name); } break; case self::FIELD_SOURCES: foreach ($new_item->getSources() as $new_source) { $item->addSource($new_source); } break; case self::FIELD_STUDIO: $item->setStudio($new_item->getStudio()); break; case self::FIELD_SUMMARY: $item->setSummary($new_item->getSummary()); break; } return $item; }
[ "protected", "function", "fillItem", "(", "Item", "$", "item", ",", "Item", "$", "new_item", ",", "$", "field", ")", "{", "switch", "(", "$", "field", ")", "{", "case", "self", "::", "FIELD_COUNTRY", ":", "$", "item", "->", "setCountry", "(", "$", "new_item", "->", "getCountry", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_DATE_END", ":", "$", "item", "->", "setDateEnd", "(", "$", "new_item", "->", "getDateEnd", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_DATE_PREMIERE", ":", "$", "item", "->", "setDatePremiere", "(", "$", "new_item", "->", "getDatePremiere", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_DURATION", ":", "$", "item", "->", "setDuration", "(", "$", "new_item", "->", "getDuration", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_EPISODES", ":", "$", "item", "->", "setEpisodes", "(", "$", "new_item", "->", "getEpisodes", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_EPISODES_NUMBER", ":", "$", "item", "->", "setEpisodesNumber", "(", "$", "new_item", "->", "getEpisodesNumber", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_FILE_INFO", ":", "$", "item", "->", "setFileInfo", "(", "$", "new_item", "->", "getFileInfo", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_GENRES", ":", "/* @var $new_genre \\AnimeDb\\Bundle\\CatalogBundle\\Entity\\Genre */", "foreach", "(", "$", "new_item", "->", "getGenres", "(", ")", "as", "$", "new_genre", ")", "{", "$", "item", "->", "addGenre", "(", "$", "new_genre", ")", ";", "}", "break", ";", "case", "self", "::", "FIELD_NAMES", ":", "// set main name in top of names list", "$", "new_names", "=", "$", "new_item", "->", "getNames", "(", ")", "->", "toArray", "(", ")", ";", "array_unshift", "(", "$", "new_names", ",", "(", "new", "Name", "(", ")", ")", "->", "setName", "(", "$", "new_item", "->", "getName", "(", ")", ")", ")", ";", "foreach", "(", "$", "new_names", "as", "$", "new_name", ")", "{", "$", "item", "->", "addName", "(", "$", "new_name", ")", ";", "}", "break", ";", "case", "self", "::", "FIELD_SOURCES", ":", "foreach", "(", "$", "new_item", "->", "getSources", "(", ")", "as", "$", "new_source", ")", "{", "$", "item", "->", "addSource", "(", "$", "new_source", ")", ";", "}", "break", ";", "case", "self", "::", "FIELD_STUDIO", ":", "$", "item", "->", "setStudio", "(", "$", "new_item", "->", "getStudio", "(", ")", ")", ";", "break", ";", "case", "self", "::", "FIELD_SUMMARY", ":", "$", "item", "->", "setSummary", "(", "$", "new_item", "->", "getSummary", "(", ")", ")", ";", "break", ";", "}", "return", "$", "item", ";", "}" ]
Fill item. @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $item @param \AnimeDb\Bundle\CatalogBundle\Entity\Item $new_item @param string $field @return \AnimeDb\Bundle\CatalogBundle\Entity\Item
[ "Fill", "item", "." ]
train
https://github.com/anime-db/world-art-filler-bundle/blob/f2ef4dbd12fe39c18183d1628b5049b8d381e42c/src/Service/Refiller.php#L266-L318
yuncms/framework
src/admin/models/AdminRoute.php
AdminRoute.getRoutes
public function getRoutes() { $manager = RBACHelper::getAuthManager(); $routes = $this->getAppRoutes(); $exists = []; foreach (array_keys($manager->getPermissions()) as $name) { if ($name[0] !== '/') { continue; } $exists[] = $name; unset($routes[$name]); } return [ 'avaliable' => array_keys($routes), 'assigned' => $exists ]; }
php
public function getRoutes() { $manager = RBACHelper::getAuthManager(); $routes = $this->getAppRoutes(); $exists = []; foreach (array_keys($manager->getPermissions()) as $name) { if ($name[0] !== '/') { continue; } $exists[] = $name; unset($routes[$name]); } return [ 'avaliable' => array_keys($routes), 'assigned' => $exists ]; }
[ "public", "function", "getRoutes", "(", ")", "{", "$", "manager", "=", "RBACHelper", "::", "getAuthManager", "(", ")", ";", "$", "routes", "=", "$", "this", "->", "getAppRoutes", "(", ")", ";", "$", "exists", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "manager", "->", "getPermissions", "(", ")", ")", "as", "$", "name", ")", "{", "if", "(", "$", "name", "[", "0", "]", "!==", "'/'", ")", "{", "continue", ";", "}", "$", "exists", "[", "]", "=", "$", "name", ";", "unset", "(", "$", "routes", "[", "$", "name", "]", ")", ";", "}", "return", "[", "'avaliable'", "=>", "array_keys", "(", "$", "routes", ")", ",", "'assigned'", "=>", "$", "exists", "]", ";", "}" ]
Get avaliable and assigned routes @return array
[ "Get", "avaliable", "and", "assigned", "routes" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/AdminRoute.php#L87-L103
yuncms/framework
src/admin/models/AdminRoute.php
AdminRoute.setDefaultRule
protected function setDefaultRule() { if (RBACHelper::getAuthManager()->getRule(RouteRule::RULE_NAME) === null) { RBACHelper::getAuthManager()->add(new RouteRule()); } }
php
protected function setDefaultRule() { if (RBACHelper::getAuthManager()->getRule(RouteRule::RULE_NAME) === null) { RBACHelper::getAuthManager()->add(new RouteRule()); } }
[ "protected", "function", "setDefaultRule", "(", ")", "{", "if", "(", "RBACHelper", "::", "getAuthManager", "(", ")", "->", "getRule", "(", "RouteRule", "::", "RULE_NAME", ")", "===", "null", ")", "{", "RBACHelper", "::", "getAuthManager", "(", ")", "->", "add", "(", "new", "RouteRule", "(", ")", ")", ";", "}", "}" ]
Set default rule of parametrize route. @throws Exception
[ "Set", "default", "rule", "of", "parametrize", "route", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/models/AdminRoute.php#L264-L269
VincentChalnot/SidusAdminBundle
Event/AdminControllerResolver.php
AdminControllerResolver.getController
protected function getController(Request $request, Admin $admin, Action $action, array $controllerPatterns) { foreach ($controllerPatterns as $controllerPattern) { $controller = strtr( $controllerPattern, [ '{{admin}}' => lcfirst($admin->getCode()), '{{Admin}}' => ucfirst($admin->getCode()), '{{action}}' => lcfirst($action->getCode()), '{{Action}}' => ucfirst($action->getCode()), ] ); $testRequest = clone $request; $testRequest->attributes->set('_controller', $controller); try { $resolvedController = $this->controllerResolver->getController($testRequest); } catch (\LogicException $e) { continue; } if (false !== $resolvedController) { return $resolvedController; } } $flattened = implode(', ', $controllerPatterns); $m = "Unable to resolve any valid controller for the admin '{$admin->getCode()}' and action "; $m .= "'{$action->getCode()}' and for the controller_pattern configuration: {$flattened}"; throw new \RuntimeException($m); }
php
protected function getController(Request $request, Admin $admin, Action $action, array $controllerPatterns) { foreach ($controllerPatterns as $controllerPattern) { $controller = strtr( $controllerPattern, [ '{{admin}}' => lcfirst($admin->getCode()), '{{Admin}}' => ucfirst($admin->getCode()), '{{action}}' => lcfirst($action->getCode()), '{{Action}}' => ucfirst($action->getCode()), ] ); $testRequest = clone $request; $testRequest->attributes->set('_controller', $controller); try { $resolvedController = $this->controllerResolver->getController($testRequest); } catch (\LogicException $e) { continue; } if (false !== $resolvedController) { return $resolvedController; } } $flattened = implode(', ', $controllerPatterns); $m = "Unable to resolve any valid controller for the admin '{$admin->getCode()}' and action "; $m .= "'{$action->getCode()}' and for the controller_pattern configuration: {$flattened}"; throw new \RuntimeException($m); }
[ "protected", "function", "getController", "(", "Request", "$", "request", ",", "Admin", "$", "admin", ",", "Action", "$", "action", ",", "array", "$", "controllerPatterns", ")", "{", "foreach", "(", "$", "controllerPatterns", "as", "$", "controllerPattern", ")", "{", "$", "controller", "=", "strtr", "(", "$", "controllerPattern", ",", "[", "'{{admin}}'", "=>", "lcfirst", "(", "$", "admin", "->", "getCode", "(", ")", ")", ",", "'{{Admin}}'", "=>", "ucfirst", "(", "$", "admin", "->", "getCode", "(", ")", ")", ",", "'{{action}}'", "=>", "lcfirst", "(", "$", "action", "->", "getCode", "(", ")", ")", ",", "'{{Action}}'", "=>", "ucfirst", "(", "$", "action", "->", "getCode", "(", ")", ")", ",", "]", ")", ";", "$", "testRequest", "=", "clone", "$", "request", ";", "$", "testRequest", "->", "attributes", "->", "set", "(", "'_controller'", ",", "$", "controller", ")", ";", "try", "{", "$", "resolvedController", "=", "$", "this", "->", "controllerResolver", "->", "getController", "(", "$", "testRequest", ")", ";", "}", "catch", "(", "\\", "LogicException", "$", "e", ")", "{", "continue", ";", "}", "if", "(", "false", "!==", "$", "resolvedController", ")", "{", "return", "$", "resolvedController", ";", "}", "}", "$", "flattened", "=", "implode", "(", "', '", ",", "$", "controllerPatterns", ")", ";", "$", "m", "=", "\"Unable to resolve any valid controller for the admin '{$admin->getCode()}' and action \"", ";", "$", "m", ".=", "\"'{$action->getCode()}' and for the controller_pattern configuration: {$flattened}\"", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "m", ")", ";", "}" ]
@param Request $request @param Admin $admin @param Action $action @param array $controllerPatterns @return callable|false
[ "@param", "Request", "$request", "@param", "Admin", "$admin", "@param", "Action", "$action", "@param", "array", "$controllerPatterns" ]
train
https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/Event/AdminControllerResolver.php#L72-L101
fyuze/framework
src/Fyuze/Error/ErrorHandler.php
ErrorHandler.handle
public function handle(Exception $exception) { try { $handlers = array_filter($this->handlers, function ($handler) use ($exception) { return $exception instanceof $handler[0]; }); foreach ($handlers as $handler) { $error = $handler[1]($exception); if ($error !== null) { break; } } } catch (Exception $e) { echo sprintf('[%d] %s in %s', $e->getLine(), $e->getMessage(), $e->getFile()); } }
php
public function handle(Exception $exception) { try { $handlers = array_filter($this->handlers, function ($handler) use ($exception) { return $exception instanceof $handler[0]; }); foreach ($handlers as $handler) { $error = $handler[1]($exception); if ($error !== null) { break; } } } catch (Exception $e) { echo sprintf('[%d] %s in %s', $e->getLine(), $e->getMessage(), $e->getFile()); } }
[ "public", "function", "handle", "(", "Exception", "$", "exception", ")", "{", "try", "{", "$", "handlers", "=", "array_filter", "(", "$", "this", "->", "handlers", ",", "function", "(", "$", "handler", ")", "use", "(", "$", "exception", ")", "{", "return", "$", "exception", "instanceof", "$", "handler", "[", "0", "]", ";", "}", ")", ";", "foreach", "(", "$", "handlers", "as", "$", "handler", ")", "{", "$", "error", "=", "$", "handler", "[", "1", "]", "(", "$", "exception", ")", ";", "if", "(", "$", "error", "!==", "null", ")", "{", "break", ";", "}", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "echo", "sprintf", "(", "'[%d] %s in %s'", ",", "$", "e", "->", "getLine", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getFile", "(", ")", ")", ";", "}", "}" ]
@param Exception $exception @return void
[ "@param", "Exception", "$exception" ]
train
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Error/ErrorHandler.php#L49-L69
nyeholt/silverstripe-external-content
code/transform/QueuedExternalContentImporter.php
QueuedExternalContentImporter.getJobType
public function getJobType() { $sourceObject = ExternalContent::getDataObjectFor($this->sourceObjectID); if (!$sourceObject) { $this->addMessage("ERROR: Source object $this->sourceObjectID cannot be found"); return QueuedJob::QUEUED; } // go a couple levels deep and see how many items we're looking at if (!$this->includeChildren) { return QueuedJob::QUEUED; } $children = $sourceObject->stageChildren(); if (!$children) { return QueuedJob::QUEUED; } $count = 1; foreach ($children as $child) { $count++; if ($count > 20) { $this->totalSteps = $count; return QueuedJob::QUEUED; } $subChildren = $child->stageChildren(); if ($subChildren) { foreach ($subChildren as $sub) { $count++; if ($count > 20) { $this->totalSteps = $count; return QueuedJob::QUEUED; } } } } $this->totalSteps = $count; return QueuedJob::QUEUED; }
php
public function getJobType() { $sourceObject = ExternalContent::getDataObjectFor($this->sourceObjectID); if (!$sourceObject) { $this->addMessage("ERROR: Source object $this->sourceObjectID cannot be found"); return QueuedJob::QUEUED; } // go a couple levels deep and see how many items we're looking at if (!$this->includeChildren) { return QueuedJob::QUEUED; } $children = $sourceObject->stageChildren(); if (!$children) { return QueuedJob::QUEUED; } $count = 1; foreach ($children as $child) { $count++; if ($count > 20) { $this->totalSteps = $count; return QueuedJob::QUEUED; } $subChildren = $child->stageChildren(); if ($subChildren) { foreach ($subChildren as $sub) { $count++; if ($count > 20) { $this->totalSteps = $count; return QueuedJob::QUEUED; } } } } $this->totalSteps = $count; return QueuedJob::QUEUED; }
[ "public", "function", "getJobType", "(", ")", "{", "$", "sourceObject", "=", "ExternalContent", "::", "getDataObjectFor", "(", "$", "this", "->", "sourceObjectID", ")", ";", "if", "(", "!", "$", "sourceObject", ")", "{", "$", "this", "->", "addMessage", "(", "\"ERROR: Source object $this->sourceObjectID cannot be found\"", ")", ";", "return", "QueuedJob", "::", "QUEUED", ";", "}", "// go a couple levels deep and see how many items we're looking at", "if", "(", "!", "$", "this", "->", "includeChildren", ")", "{", "return", "QueuedJob", "::", "QUEUED", ";", "}", "$", "children", "=", "$", "sourceObject", "->", "stageChildren", "(", ")", ";", "if", "(", "!", "$", "children", ")", "{", "return", "QueuedJob", "::", "QUEUED", ";", "}", "$", "count", "=", "1", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "count", "++", ";", "if", "(", "$", "count", ">", "20", ")", "{", "$", "this", "->", "totalSteps", "=", "$", "count", ";", "return", "QueuedJob", "::", "QUEUED", ";", "}", "$", "subChildren", "=", "$", "child", "->", "stageChildren", "(", ")", ";", "if", "(", "$", "subChildren", ")", "{", "foreach", "(", "$", "subChildren", "as", "$", "sub", ")", "{", "$", "count", "++", ";", "if", "(", "$", "count", ">", "20", ")", "{", "$", "this", "->", "totalSteps", "=", "$", "count", ";", "return", "QueuedJob", "::", "QUEUED", ";", "}", "}", "}", "}", "$", "this", "->", "totalSteps", "=", "$", "count", ";", "return", "QueuedJob", "::", "QUEUED", ";", "}" ]
By default jobs should just go into the default processing queue @return String
[ "By", "default", "jobs", "should", "just", "go", "into", "the", "default", "processing", "queue" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/transform/QueuedExternalContentImporter.php#L43-L81