id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
231,200
cygnite/framework
src/Cygnite/Translation/Translator.php
Translator.get
public function get($key, $locale = null) { if (!$locale) { // Use the global target language $locale = $this->locale(); } if (string_has($key, ':')) { $exp = string_split($key, ':'); // Load the translation table for this language $translator = $this->load($locale.'-'.$exp[0]); unset($exp[0]); $string = ArrayAccessor::make($translator, function ($a) use ($exp) { return $a->toString(implode('.', $exp)); }); // Return the translated string if it exists return !is_null($string) ? $string : $key; } // Load the Translator array for this language $translator = $this->load($locale); // Return the translated string if it exists return isset($translator[$key]) ? $translator[$key] : $key; }
php
public function get($key, $locale = null) { if (!$locale) { // Use the global target language $locale = $this->locale(); } if (string_has($key, ':')) { $exp = string_split($key, ':'); // Load the translation table for this language $translator = $this->load($locale.'-'.$exp[0]); unset($exp[0]); $string = ArrayAccessor::make($translator, function ($a) use ($exp) { return $a->toString(implode('.', $exp)); }); // Return the translated string if it exists return !is_null($string) ? $string : $key; } // Load the Translator array for this language $translator = $this->load($locale); // Return the translated string if it exists return isset($translator[$key]) ? $translator[$key] : $key; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "!", "$", "locale", ")", "{", "// Use the global target language", "$", "locale", "=", "$", "this", "->", "locale", "(", ")", ";", "}", "if", "(", "string_has", "(", "$", "key", ",", "':'", ")", ")", "{", "$", "exp", "=", "string_split", "(", "$", "key", ",", "':'", ")", ";", "// Load the translation table for this language", "$", "translator", "=", "$", "this", "->", "load", "(", "$", "locale", ".", "'-'", ".", "$", "exp", "[", "0", "]", ")", ";", "unset", "(", "$", "exp", "[", "0", "]", ")", ";", "$", "string", "=", "ArrayAccessor", "::", "make", "(", "$", "translator", ",", "function", "(", "$", "a", ")", "use", "(", "$", "exp", ")", "{", "return", "$", "a", "->", "toString", "(", "implode", "(", "'.'", ",", "$", "exp", ")", ")", ";", "}", ")", ";", "// Return the translated string if it exists", "return", "!", "is_null", "(", "$", "string", ")", "?", "$", "string", ":", "$", "key", ";", "}", "// Load the Translator array for this language", "$", "translator", "=", "$", "this", "->", "load", "(", "$", "locale", ")", ";", "// Return the translated string if it exists", "return", "isset", "(", "$", "translator", "[", "$", "key", "]", ")", "?", "$", "translator", "[", "$", "key", "]", ":", "$", "key", ";", "}" ]
Returns Translator of a string. If no Translator exists, the original string will be returned. trans('Hello, :user', array(':user' => $username)); $hello = $trans->get('welcome.Hello friends, my name is :name'); @param $key to translate @param null $locale target language @return string
[ "Returns", "Translator", "of", "a", "string", ".", "If", "no", "Translator", "exists", "the", "original", "string", "will", "be", "returned", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Translation/Translator.php#L121-L146
231,201
cygnite/framework
src/Cygnite/Translation/Translator.php
Translator.findLanguageFile
public function findLanguageFile($file) { // Create a partial path of the filename $path = DS.$file.$this->getFileExtension(); // Include paths must be searched in reverse $paths = array_reverse([$this->getRootDirectory().$this->getLangDir()]); // Array of files that have been found $locale = []; foreach ($paths as $dir) { if (is_file($dir.$path)) { // This path has a file, add it to the list $locale[] = $dir.$path; } else { //Fallback Locale $fallbackFile = str_replace($this->locale(), $this->getFallback(), $path); /* | We will search for fallback locale if | found we will load it into the list */ if (is_file($dir.$fallbackFile)) { $locale[] = $dir.$fallbackFile; } } } return $locale; }
php
public function findLanguageFile($file) { // Create a partial path of the filename $path = DS.$file.$this->getFileExtension(); // Include paths must be searched in reverse $paths = array_reverse([$this->getRootDirectory().$this->getLangDir()]); // Array of files that have been found $locale = []; foreach ($paths as $dir) { if (is_file($dir.$path)) { // This path has a file, add it to the list $locale[] = $dir.$path; } else { //Fallback Locale $fallbackFile = str_replace($this->locale(), $this->getFallback(), $path); /* | We will search for fallback locale if | found we will load it into the list */ if (is_file($dir.$fallbackFile)) { $locale[] = $dir.$fallbackFile; } } } return $locale; }
[ "public", "function", "findLanguageFile", "(", "$", "file", ")", "{", "// Create a partial path of the filename", "$", "path", "=", "DS", ".", "$", "file", ".", "$", "this", "->", "getFileExtension", "(", ")", ";", "// Include paths must be searched in reverse", "$", "paths", "=", "array_reverse", "(", "[", "$", "this", "->", "getRootDirectory", "(", ")", ".", "$", "this", "->", "getLangDir", "(", ")", "]", ")", ";", "// Array of files that have been found", "$", "locale", "=", "[", "]", ";", "foreach", "(", "$", "paths", "as", "$", "dir", ")", "{", "if", "(", "is_file", "(", "$", "dir", ".", "$", "path", ")", ")", "{", "// This path has a file, add it to the list", "$", "locale", "[", "]", "=", "$", "dir", ".", "$", "path", ";", "}", "else", "{", "//Fallback Locale", "$", "fallbackFile", "=", "str_replace", "(", "$", "this", "->", "locale", "(", ")", ",", "$", "this", "->", "getFallback", "(", ")", ",", "$", "path", ")", ";", "/*\n | We will search for fallback locale if\n | found we will load it into the list\n */", "if", "(", "is_file", "(", "$", "dir", ".", "$", "fallbackFile", ")", ")", "{", "$", "locale", "[", "]", "=", "$", "dir", ".", "$", "fallbackFile", ";", "}", "}", "}", "return", "$", "locale", ";", "}" ]
Find the language file if exists load it into list else search for fallback locale and load. @param $file @return array
[ "Find", "the", "language", "file", "if", "exists", "load", "it", "into", "list", "else", "search", "for", "fallback", "locale", "and", "load", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Translation/Translator.php#L243-L271
231,202
cygnite/framework
src/Cygnite/Translation/Translator.php
Translator.load
public function load($locale) { if (isset($this->cache[$locale])) { return $this->cache[$locale]; } // New Translator array $trans = []; // Split the language: language, region, locale, etc $parts = string_split($locale, '-'); do { // Create a path for this set of parts $path = implode(DS, $parts); // Remove the last part if ($files = $this->findLanguageFile($path)) { $trans = $this->loadMessages($files, $trans); } array_pop($parts); } while ($parts); // Cache the Translator table locally return $this->cache[$locale] = $trans; }
php
public function load($locale) { if (isset($this->cache[$locale])) { return $this->cache[$locale]; } // New Translator array $trans = []; // Split the language: language, region, locale, etc $parts = string_split($locale, '-'); do { // Create a path for this set of parts $path = implode(DS, $parts); // Remove the last part if ($files = $this->findLanguageFile($path)) { $trans = $this->loadMessages($files, $trans); } array_pop($parts); } while ($parts); // Cache the Translator table locally return $this->cache[$locale] = $trans; }
[ "public", "function", "load", "(", "$", "locale", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "locale", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "locale", "]", ";", "}", "// New Translator array", "$", "trans", "=", "[", "]", ";", "// Split the language: language, region, locale, etc", "$", "parts", "=", "string_split", "(", "$", "locale", ",", "'-'", ")", ";", "do", "{", "// Create a path for this set of parts", "$", "path", "=", "implode", "(", "DS", ",", "$", "parts", ")", ";", "// Remove the last part", "if", "(", "$", "files", "=", "$", "this", "->", "findLanguageFile", "(", "$", "path", ")", ")", "{", "$", "trans", "=", "$", "this", "->", "loadMessages", "(", "$", "files", ",", "$", "trans", ")", ";", "}", "array_pop", "(", "$", "parts", ")", ";", "}", "while", "(", "$", "parts", ")", ";", "// Cache the Translator table locally", "return", "$", "this", "->", "cache", "[", "$", "locale", "]", "=", "$", "trans", ";", "}" ]
Returns the Translator array for a given language. // Get all defined Spanish messages $messages = $trans->load('es'); @param string $locale language to load @return array
[ "Returns", "the", "Translator", "array", "for", "a", "given", "language", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Translation/Translator.php#L283-L308
231,203
cygnite/framework
src/Cygnite/Translation/Translator.php
Translator.loadMessages
private function loadMessages($files, $trans) { $message = []; foreach ($files as $file) { // Merge the language strings into the sub message array if (is_readable($file)) { $message = array_merge($message, include $file); } } // Append to the sub message array, preventing overloading files $trans += $message; return $trans; }
php
private function loadMessages($files, $trans) { $message = []; foreach ($files as $file) { // Merge the language strings into the sub message array if (is_readable($file)) { $message = array_merge($message, include $file); } } // Append to the sub message array, preventing overloading files $trans += $message; return $trans; }
[ "private", "function", "loadMessages", "(", "$", "files", ",", "$", "trans", ")", "{", "$", "message", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "// Merge the language strings into the sub message array", "if", "(", "is_readable", "(", "$", "file", ")", ")", "{", "$", "message", "=", "array_merge", "(", "$", "message", ",", "include", "$", "file", ")", ";", "}", "}", "// Append to the sub message array, preventing overloading files", "$", "trans", "+=", "$", "message", ";", "return", "$", "trans", ";", "}" ]
We will load all messages into array. @param $files @param $trans @return array
[ "We", "will", "load", "all", "messages", "into", "array", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Translation/Translator.php#L318-L331
231,204
tapestry-cloud/tapestry
src/Entities/CachedFile.php
CachedFile.check
public function check(File $file) { if ($file->getUid() !== $this->uid) { throw new \Exception('This CachedFile is not for uid ['.$file->getUid().']'); } return $this->hash === $this->hashFile($file); }
php
public function check(File $file) { if ($file->getUid() !== $this->uid) { throw new \Exception('This CachedFile is not for uid ['.$file->getUid().']'); } return $this->hash === $this->hashFile($file); }
[ "public", "function", "check", "(", "File", "$", "file", ")", "{", "if", "(", "$", "file", "->", "getUid", "(", ")", "!==", "$", "this", "->", "uid", ")", "{", "throw", "new", "\\", "Exception", "(", "'This CachedFile is not for uid ['", ".", "$", "file", "->", "getUid", "(", ")", ".", "']'", ")", ";", "}", "return", "$", "this", "->", "hash", "===", "$", "this", "->", "hashFile", "(", "$", "file", ")", ";", "}" ]
Check to see if the current cache entry is still valid. @param File $file @return bool @throws \Exception
[ "Check", "to", "see", "if", "the", "current", "cache", "entry", "is", "still", "valid", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/CachedFile.php#L53-L60
231,205
tapestry-cloud/tapestry
src/Entities/CachedFile.php
CachedFile.hashFile
private function hashFile(File $file) { $arr = []; foreach ($this->layouts as $layout) { if (strpos($layout, '_templates') === false) { $layout = '_templates'.DIRECTORY_SEPARATOR.$layout; } $layoutPathName = $this->sourceDirectory.DIRECTORY_SEPARATOR.$layout.'.phtml'; if (file_exists($layoutPathName)) { array_push($arr, sha1_file($layoutPathName)); } } array_push($arr, $file->getLastModified()); return sha1(implode('.', $arr)); }
php
private function hashFile(File $file) { $arr = []; foreach ($this->layouts as $layout) { if (strpos($layout, '_templates') === false) { $layout = '_templates'.DIRECTORY_SEPARATOR.$layout; } $layoutPathName = $this->sourceDirectory.DIRECTORY_SEPARATOR.$layout.'.phtml'; if (file_exists($layoutPathName)) { array_push($arr, sha1_file($layoutPathName)); } } array_push($arr, $file->getLastModified()); return sha1(implode('.', $arr)); }
[ "private", "function", "hashFile", "(", "File", "$", "file", ")", "{", "$", "arr", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "layouts", "as", "$", "layout", ")", "{", "if", "(", "strpos", "(", "$", "layout", ",", "'_templates'", ")", "===", "false", ")", "{", "$", "layout", "=", "'_templates'", ".", "DIRECTORY_SEPARATOR", ".", "$", "layout", ";", "}", "$", "layoutPathName", "=", "$", "this", "->", "sourceDirectory", ".", "DIRECTORY_SEPARATOR", ".", "$", "layout", ".", "'.phtml'", ";", "if", "(", "file_exists", "(", "$", "layoutPathName", ")", ")", "{", "array_push", "(", "$", "arr", ",", "sha1_file", "(", "$", "layoutPathName", ")", ")", ";", "}", "}", "array_push", "(", "$", "arr", ",", "$", "file", "->", "getLastModified", "(", ")", ")", ";", "return", "sha1", "(", "implode", "(", "'.'", ",", "$", "arr", ")", ")", ";", "}" ]
Calculates the invalidation hash for the given File. @param File $file @return string
[ "Calculates", "the", "invalidation", "hash", "for", "the", "given", "File", "." ]
f3fc980b2484ccbe609a7f811c65b91254e8720e
https://github.com/tapestry-cloud/tapestry/blob/f3fc980b2484ccbe609a7f811c65b91254e8720e/src/Entities/CachedFile.php#L68-L86
231,206
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_config_file_compiler.php
Smarty_Internal_Config_File_Compiler.compileTemplate
public function compileTemplate(Smarty_Internal_Template $template) { $this->template = $template; $this->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->getTimeStamp(), $this->template->source->type); if ($this->smarty->debugging) { $this->smarty->_debug->start_compile($this->template); } // init the lexer/parser to compile the config file /* @var Smarty_Internal_ConfigFileLexer $lex */ $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n", $this); /* @var Smarty_Internal_ConfigFileParser $parser */ $parser = new $this->parser_class($lex, $this); if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } else { $mbEncoding = null; } if ($this->smarty->_parserdebug) { $parser->PrintTrace(); } // get tokens from lexer and parse them while ($lex->yylex()) { if ($this->smarty->_parserdebug) { echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; } $parser->doParse($lex->token, $lex->value); } // finish parsing process $parser->doParse(0, 0); if ($mbEncoding) { mb_internal_encoding($mbEncoding); } if ($this->smarty->debugging) { $this->smarty->_debug->end_compile($this->template); } // template header code $template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n"; $template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n"; $code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>'; return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code); }
php
public function compileTemplate(Smarty_Internal_Template $template) { $this->template = $template; $this->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->getTimeStamp(), $this->template->source->type); if ($this->smarty->debugging) { $this->smarty->_debug->start_compile($this->template); } // init the lexer/parser to compile the config file /* @var Smarty_Internal_ConfigFileLexer $lex */ $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n", $this); /* @var Smarty_Internal_ConfigFileParser $parser */ $parser = new $this->parser_class($lex, $this); if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('ASCII'); } else { $mbEncoding = null; } if ($this->smarty->_parserdebug) { $parser->PrintTrace(); } // get tokens from lexer and parse them while ($lex->yylex()) { if ($this->smarty->_parserdebug) { echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n"; } $parser->doParse($lex->token, $lex->value); } // finish parsing process $parser->doParse(0, 0); if ($mbEncoding) { mb_internal_encoding($mbEncoding); } if ($this->smarty->debugging) { $this->smarty->_debug->end_compile($this->template); } // template header code $template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n"; $template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n"; $code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>'; return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code); }
[ "public", "function", "compileTemplate", "(", "Smarty_Internal_Template", "$", "template", ")", "{", "$", "this", "->", "template", "=", "$", "template", ";", "$", "this", "->", "template", "->", "compiled", "->", "file_dependency", "[", "$", "this", "->", "template", "->", "source", "->", "uid", "]", "=", "array", "(", "$", "this", "->", "template", "->", "source", "->", "filepath", ",", "$", "this", "->", "template", "->", "source", "->", "getTimeStamp", "(", ")", ",", "$", "this", "->", "template", "->", "source", "->", "type", ")", ";", "if", "(", "$", "this", "->", "smarty", "->", "debugging", ")", "{", "$", "this", "->", "smarty", "->", "_debug", "->", "start_compile", "(", "$", "this", "->", "template", ")", ";", "}", "// init the lexer/parser to compile the config file", "/* @var Smarty_Internal_ConfigFileLexer $lex */", "$", "lex", "=", "new", "$", "this", "->", "lexer_class", "(", "str_replace", "(", "array", "(", "\"\\r\\n\"", ",", "\"\\r\"", ")", ",", "\"\\n\"", ",", "$", "template", "->", "source", "->", "getContent", "(", ")", ")", ".", "\"\\n\"", ",", "$", "this", ")", ";", "/* @var Smarty_Internal_ConfigFileParser $parser */", "$", "parser", "=", "new", "$", "this", "->", "parser_class", "(", "$", "lex", ",", "$", "this", ")", ";", "if", "(", "function_exists", "(", "'mb_internal_encoding'", ")", "&&", "(", "(", "int", ")", "ini_get", "(", "'mbstring.func_overload'", ")", ")", "&", "2", ")", "{", "$", "mbEncoding", "=", "mb_internal_encoding", "(", ")", ";", "mb_internal_encoding", "(", "'ASCII'", ")", ";", "}", "else", "{", "$", "mbEncoding", "=", "null", ";", "}", "if", "(", "$", "this", "->", "smarty", "->", "_parserdebug", ")", "{", "$", "parser", "->", "PrintTrace", "(", ")", ";", "}", "// get tokens from lexer and parse them", "while", "(", "$", "lex", "->", "yylex", "(", ")", ")", "{", "if", "(", "$", "this", "->", "smarty", "->", "_parserdebug", ")", "{", "echo", "\"<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \\n\"", ";", "}", "$", "parser", "->", "doParse", "(", "$", "lex", "->", "token", ",", "$", "lex", "->", "value", ")", ";", "}", "// finish parsing process", "$", "parser", "->", "doParse", "(", "0", ",", "0", ")", ";", "if", "(", "$", "mbEncoding", ")", "{", "mb_internal_encoding", "(", "$", "mbEncoding", ")", ";", "}", "if", "(", "$", "this", "->", "smarty", "->", "debugging", ")", "{", "$", "this", "->", "smarty", "->", "_debug", "->", "end_compile", "(", "$", "this", "->", "template", ")", ";", "}", "// template header code", "$", "template_header", "=", "\"<?php /* Smarty version \"", ".", "Smarty", "::", "SMARTY_VERSION", ".", "\", created on \"", ".", "strftime", "(", "\"%Y-%m-%d %H:%M:%S\"", ")", ".", "\"\\n\"", ";", "$", "template_header", ".=", "\" compiled from \\\"\"", ".", "$", "this", "->", "template", "->", "source", "->", "filepath", ".", "\"\\\" */ ?>\\n\"", ";", "$", "code", "=", "'<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, '", ".", "var_export", "(", "$", "this", "->", "config_data", ",", "true", ")", ".", "'); ?>'", ";", "return", "$", "template_header", ".", "$", "this", "->", "template", "->", "smarty", "->", "ext", "->", "_codeFrame", "->", "create", "(", "$", "this", "->", "template", ",", "$", "code", ")", ";", "}" ]
Method to compile Smarty config source. @param Smarty_Internal_Template $template @return bool true if compiling succeeded, false if it failed
[ "Method", "to", "compile", "Smarty", "config", "source", "." ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_config_file_compiler.php#L101-L151
231,207
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_template.php
Smarty_Internal_Template._getTemplateId
public function _getTemplateId() { return isset($this->templateId) ? $this->templateId : $this->templateId = $this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id); }
php
public function _getTemplateId() { return isset($this->templateId) ? $this->templateId : $this->templateId = $this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id); }
[ "public", "function", "_getTemplateId", "(", ")", "{", "return", "isset", "(", "$", "this", "->", "templateId", ")", "?", "$", "this", "->", "templateId", ":", "$", "this", "->", "templateId", "=", "$", "this", "->", "smarty", "->", "_getTemplateId", "(", "$", "this", "->", "template_resource", ",", "$", "this", "->", "cache_id", ",", "$", "this", "->", "compile_id", ")", ";", "}" ]
Get unique template id @return string
[ "Get", "unique", "template", "id" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_template.php#L240-L244
231,208
ctbsea/phalapi-smarty
src/Smarty/sysplugins/smarty_internal_template.php
Smarty_Internal_Template.loadCompiler
public function loadCompiler() { if (!class_exists($this->source->handler->compiler_class)) { $this->smarty->loadPlugin($this->source->handler->compiler_class); } $this->compiler = new $this->source->handler->compiler_class($this->source->handler->template_lexer_class, $this->source->handler->template_parser_class, $this->smarty); }
php
public function loadCompiler() { if (!class_exists($this->source->handler->compiler_class)) { $this->smarty->loadPlugin($this->source->handler->compiler_class); } $this->compiler = new $this->source->handler->compiler_class($this->source->handler->template_lexer_class, $this->source->handler->template_parser_class, $this->smarty); }
[ "public", "function", "loadCompiler", "(", ")", "{", "if", "(", "!", "class_exists", "(", "$", "this", "->", "source", "->", "handler", "->", "compiler_class", ")", ")", "{", "$", "this", "->", "smarty", "->", "loadPlugin", "(", "$", "this", "->", "source", "->", "handler", "->", "compiler_class", ")", ";", "}", "$", "this", "->", "compiler", "=", "new", "$", "this", "->", "source", "->", "handler", "->", "compiler_class", "(", "$", "this", "->", "source", "->", "handler", "->", "template_lexer_class", ",", "$", "this", "->", "source", "->", "handler", "->", "template_parser_class", ",", "$", "this", "->", "smarty", ")", ";", "}" ]
Load compiler object @throws \SmartyException
[ "Load", "compiler", "object" ]
4d40da3e4482c0749f3cfd1605265a109a1c495f
https://github.com/ctbsea/phalapi-smarty/blob/4d40da3e4482c0749f3cfd1605265a109a1c495f/src/Smarty/sysplugins/smarty_internal_template.php#L281-L289
231,209
cygnite/framework
src/Cygnite/Console/Generator/Form.php
Form.generate
public function generate() { $filePath = ''; $formName = Inflector::classify($this->formCommand->tableName); if (file_exists($this->getFormTemplatePath().'Form'.EXT)) { //We will generate Form Component $formContent = file_get_contents($this->getFormTemplatePath().'Form'.EXT); } else { die("Form template doesn't exists in ".$this->getFormTemplatePath().'Form'.EXT.' directory.'); } $this->controllerInstance->isFormGenerator = true; $this->controllerInstance->updateTemplate(); $this->controllerInstance->setControllerName($formName); $this->controllerInstance->setApplicationDirectory(realpath(CYGNITE_BASE.DS.APPPATH)); $formContent = str_replace('%controllerName%', $formName, $formContent); $formContent = str_replace('{%formElements%}', $this->controllerInstance->getForm().PHP_EOL, $formContent); $this->controllerInstance->generateFormComponent($formContent); }
php
public function generate() { $filePath = ''; $formName = Inflector::classify($this->formCommand->tableName); if (file_exists($this->getFormTemplatePath().'Form'.EXT)) { //We will generate Form Component $formContent = file_get_contents($this->getFormTemplatePath().'Form'.EXT); } else { die("Form template doesn't exists in ".$this->getFormTemplatePath().'Form'.EXT.' directory.'); } $this->controllerInstance->isFormGenerator = true; $this->controllerInstance->updateTemplate(); $this->controllerInstance->setControllerName($formName); $this->controllerInstance->setApplicationDirectory(realpath(CYGNITE_BASE.DS.APPPATH)); $formContent = str_replace('%controllerName%', $formName, $formContent); $formContent = str_replace('{%formElements%}', $this->controllerInstance->getForm().PHP_EOL, $formContent); $this->controllerInstance->generateFormComponent($formContent); }
[ "public", "function", "generate", "(", ")", "{", "$", "filePath", "=", "''", ";", "$", "formName", "=", "Inflector", "::", "classify", "(", "$", "this", "->", "formCommand", "->", "tableName", ")", ";", "if", "(", "file_exists", "(", "$", "this", "->", "getFormTemplatePath", "(", ")", ".", "'Form'", ".", "EXT", ")", ")", "{", "//We will generate Form Component", "$", "formContent", "=", "file_get_contents", "(", "$", "this", "->", "getFormTemplatePath", "(", ")", ".", "'Form'", ".", "EXT", ")", ";", "}", "else", "{", "die", "(", "\"Form template doesn't exists in \"", ".", "$", "this", "->", "getFormTemplatePath", "(", ")", ".", "'Form'", ".", "EXT", ".", "' directory.'", ")", ";", "}", "$", "this", "->", "controllerInstance", "->", "isFormGenerator", "=", "true", ";", "$", "this", "->", "controllerInstance", "->", "updateTemplate", "(", ")", ";", "$", "this", "->", "controllerInstance", "->", "setControllerName", "(", "$", "formName", ")", ";", "$", "this", "->", "controllerInstance", "->", "setApplicationDirectory", "(", "realpath", "(", "CYGNITE_BASE", ".", "DS", ".", "APPPATH", ")", ")", ";", "$", "formContent", "=", "str_replace", "(", "'%controllerName%'", ",", "$", "formName", ",", "$", "formContent", ")", ";", "$", "formContent", "=", "str_replace", "(", "'{%formElements%}'", ",", "$", "this", "->", "controllerInstance", "->", "getForm", "(", ")", ".", "PHP_EOL", ",", "$", "formContent", ")", ";", "$", "this", "->", "controllerInstance", "->", "generateFormComponent", "(", "$", "formContent", ")", ";", "}" ]
Generate Form.
[ "Generate", "Form", "." ]
58d0cc1c946415eb0867d76218bd35166e999093
https://github.com/cygnite/framework/blob/58d0cc1c946415eb0867d76218bd35166e999093/src/Cygnite/Console/Generator/Form.php#L77-L97
231,210
php-task/TaskBundle
src/DependencyInjection/TaskExtension.php
TaskExtension.loadDoctrineAdapter
private function loadDoctrineAdapter(array $config, ContainerBuilder $container) { if ($config['clear']) { $definition = new Definition( DoctrineTaskExecutionListener::class, [new Reference('doctrine.orm.entity_manager', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)] ); $definition->addTag( 'kernel.event_listener', ['event' => Events::TASK_AFTER, 'method' => 'clearEntityManagerAfterTask'] ); $container->setDefinition('task.adapter.doctrine.execution_listener', $definition); } }
php
private function loadDoctrineAdapter(array $config, ContainerBuilder $container) { if ($config['clear']) { $definition = new Definition( DoctrineTaskExecutionListener::class, [new Reference('doctrine.orm.entity_manager', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)] ); $definition->addTag( 'kernel.event_listener', ['event' => Events::TASK_AFTER, 'method' => 'clearEntityManagerAfterTask'] ); $container->setDefinition('task.adapter.doctrine.execution_listener', $definition); } }
[ "private", "function", "loadDoctrineAdapter", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "$", "config", "[", "'clear'", "]", ")", "{", "$", "definition", "=", "new", "Definition", "(", "DoctrineTaskExecutionListener", "::", "class", ",", "[", "new", "Reference", "(", "'doctrine.orm.entity_manager'", ",", "ContainerInterface", "::", "IGNORE_ON_INVALID_REFERENCE", ")", "]", ")", ";", "$", "definition", "->", "addTag", "(", "'kernel.event_listener'", ",", "[", "'event'", "=>", "Events", "::", "TASK_AFTER", ",", "'method'", "=>", "'clearEntityManagerAfterTask'", "]", ")", ";", "$", "container", "->", "setDefinition", "(", "'task.adapter.doctrine.execution_listener'", ",", "$", "definition", ")", ";", "}", "}" ]
Load doctrine adapter. @param array $config @param ContainerBuilder $container
[ "Load", "doctrine", "adapter", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/DependencyInjection/TaskExtension.php#L68-L81
231,211
php-task/TaskBundle
src/DependencyInjection/TaskExtension.php
TaskExtension.loadLockingComponent
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader) { if (!$config['enabled']) { return $loader->load('locking/null.xml'); } $loader->load('locking/services.xml'); $container->setParameter('task.lock.ttl', $config['ttl']); }
php
private function loadLockingComponent(array $config, ContainerBuilder $container, LoaderInterface $loader) { if (!$config['enabled']) { return $loader->load('locking/null.xml'); } $loader->load('locking/services.xml'); $container->setParameter('task.lock.ttl', $config['ttl']); }
[ "private", "function", "loadLockingComponent", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ",", "LoaderInterface", "$", "loader", ")", "{", "if", "(", "!", "$", "config", "[", "'enabled'", "]", ")", "{", "return", "$", "loader", "->", "load", "(", "'locking/null.xml'", ")", ";", "}", "$", "loader", "->", "load", "(", "'locking/services.xml'", ")", ";", "$", "container", "->", "setParameter", "(", "'task.lock.ttl'", ",", "$", "config", "[", "'ttl'", "]", ")", ";", "}" ]
Load services for locking component. @param array $config @param LoaderInterface $loader @param ContainerBuilder $container
[ "Load", "services", "for", "locking", "component", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/DependencyInjection/TaskExtension.php#L90-L98
231,212
php-task/TaskBundle
src/DependencyInjection/TaskExtension.php
TaskExtension.loadExecutorComponent
private function loadExecutorComponent(array $config, ContainerBuilder $container, LoaderInterface $loader) { $loader->load('executor/' . $config['type'] . '.xml'); $container->setAlias('task.executor', 'task.executor.' . $config['type']); if (!array_key_exists($config['type'], $config)) { return; } foreach ($config[$config['type']] as $key => $value) { $container->setParameter('task.executor.' . $key, $value); } if (!file_exists($container->getParameter('task.executor.console_path'))) { throw new InvalidConfigurationException( 'Console file does not exists! Given in "task.executor.seperate.console".' ); } }
php
private function loadExecutorComponent(array $config, ContainerBuilder $container, LoaderInterface $loader) { $loader->load('executor/' . $config['type'] . '.xml'); $container->setAlias('task.executor', 'task.executor.' . $config['type']); if (!array_key_exists($config['type'], $config)) { return; } foreach ($config[$config['type']] as $key => $value) { $container->setParameter('task.executor.' . $key, $value); } if (!file_exists($container->getParameter('task.executor.console_path'))) { throw new InvalidConfigurationException( 'Console file does not exists! Given in "task.executor.seperate.console".' ); } }
[ "private", "function", "loadExecutorComponent", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ",", "LoaderInterface", "$", "loader", ")", "{", "$", "loader", "->", "load", "(", "'executor/'", ".", "$", "config", "[", "'type'", "]", ".", "'.xml'", ")", ";", "$", "container", "->", "setAlias", "(", "'task.executor'", ",", "'task.executor.'", ".", "$", "config", "[", "'type'", "]", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "config", "[", "'type'", "]", ",", "$", "config", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "config", "[", "$", "config", "[", "'type'", "]", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "container", "->", "setParameter", "(", "'task.executor.'", ".", "$", "key", ",", "$", "value", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "container", "->", "getParameter", "(", "'task.executor.console_path'", ")", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "'Console file does not exists! Given in \"task.executor.seperate.console\".'", ")", ";", "}", "}" ]
Load services for executor component. @param array $config @param LoaderInterface $loader @param ContainerBuilder $container
[ "Load", "services", "for", "executor", "component", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/DependencyInjection/TaskExtension.php#L107-L125
231,213
php-task/TaskBundle
src/DependencyInjection/TaskExtension.php
TaskExtension.getLockingStorageAliases
private function getLockingStorageAliases(ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds('task.lock.storage'); $result = []; foreach ($taggedServices as $id => $tags) { foreach ($tags as $tag) { $result[$tag['alias']] = $id; } } return $result; }
php
private function getLockingStorageAliases(ContainerBuilder $container) { $taggedServices = $container->findTaggedServiceIds('task.lock.storage'); $result = []; foreach ($taggedServices as $id => $tags) { foreach ($tags as $tag) { $result[$tag['alias']] = $id; } } return $result; }
[ "private", "function", "getLockingStorageAliases", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "taggedServices", "=", "$", "container", "->", "findTaggedServiceIds", "(", "'task.lock.storage'", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "taggedServices", "as", "$", "id", "=>", "$", "tags", ")", "{", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "result", "[", "$", "tag", "[", "'alias'", "]", "]", "=", "$", "id", ";", "}", "}", "return", "$", "result", ";", "}" ]
Find storage aliases and related ids. @param ContainerBuilder $container @return array
[ "Find", "storage", "aliases", "and", "related", "ids", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/DependencyInjection/TaskExtension.php#L134-L146
231,214
php-task/TaskBundle
src/Command/ScheduleSystemTasksCommand.php
ScheduleSystemTasksCommand.processSystemTask
private function processSystemTask($systemKey, array $systemTask, OutputInterface $output) { if (!$systemTask['enabled']) { if ($this->disableSystemTask($systemKey)) { $output->writeln(sprintf(' * System-task "%s" was <comment>disabled</comment>', $systemKey)); } return; } if ($task = $this->taskRepository->findBySystemKey($systemKey)) { $this->updateTask($systemKey, $systemTask, $task); $output->writeln(sprintf(' * System-task "%s" was <info>updated</info>', $systemKey)); return; } /** @var TaskBuilder $builder */ $builder = $this->scheduler->createTask($systemTask['handler_class'], $systemTask['workload']); $builder->setSystemKey($systemKey); if ($systemTask['cron_expression']) { $builder->cron($systemTask['cron_expression']); } $builder->schedule(); $output->writeln(sprintf(' * System-task "%s" was <info>created</info>', $systemKey)); }
php
private function processSystemTask($systemKey, array $systemTask, OutputInterface $output) { if (!$systemTask['enabled']) { if ($this->disableSystemTask($systemKey)) { $output->writeln(sprintf(' * System-task "%s" was <comment>disabled</comment>', $systemKey)); } return; } if ($task = $this->taskRepository->findBySystemKey($systemKey)) { $this->updateTask($systemKey, $systemTask, $task); $output->writeln(sprintf(' * System-task "%s" was <info>updated</info>', $systemKey)); return; } /** @var TaskBuilder $builder */ $builder = $this->scheduler->createTask($systemTask['handler_class'], $systemTask['workload']); $builder->setSystemKey($systemKey); if ($systemTask['cron_expression']) { $builder->cron($systemTask['cron_expression']); } $builder->schedule(); $output->writeln(sprintf(' * System-task "%s" was <info>created</info>', $systemKey)); }
[ "private", "function", "processSystemTask", "(", "$", "systemKey", ",", "array", "$", "systemTask", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "!", "$", "systemTask", "[", "'enabled'", "]", ")", "{", "if", "(", "$", "this", "->", "disableSystemTask", "(", "$", "systemKey", ")", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "' * System-task \"%s\" was <comment>disabled</comment>'", ",", "$", "systemKey", ")", ")", ";", "}", "return", ";", "}", "if", "(", "$", "task", "=", "$", "this", "->", "taskRepository", "->", "findBySystemKey", "(", "$", "systemKey", ")", ")", "{", "$", "this", "->", "updateTask", "(", "$", "systemKey", ",", "$", "systemTask", ",", "$", "task", ")", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "' * System-task \"%s\" was <info>updated</info>'", ",", "$", "systemKey", ")", ")", ";", "return", ";", "}", "/** @var TaskBuilder $builder */", "$", "builder", "=", "$", "this", "->", "scheduler", "->", "createTask", "(", "$", "systemTask", "[", "'handler_class'", "]", ",", "$", "systemTask", "[", "'workload'", "]", ")", ";", "$", "builder", "->", "setSystemKey", "(", "$", "systemKey", ")", ";", "if", "(", "$", "systemTask", "[", "'cron_expression'", "]", ")", "{", "$", "builder", "->", "cron", "(", "$", "systemTask", "[", "'cron_expression'", "]", ")", ";", "}", "$", "builder", "->", "schedule", "(", ")", ";", "$", "output", "->", "writeln", "(", "sprintf", "(", "' * System-task \"%s\" was <info>created</info>'", ",", "$", "systemKey", ")", ")", ";", "}" ]
Process single system task. @param string $systemKey @param array $systemTask @param OutputInterface $output
[ "Process", "single", "system", "task", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Command/ScheduleSystemTasksCommand.php#L120-L148
231,215
php-task/TaskBundle
src/Command/ScheduleSystemTasksCommand.php
ScheduleSystemTasksCommand.disableSystemTask
private function disableSystemTask($systemKey) { if (!$task = $this->taskRepository->findBySystemKey($systemKey)) { return false; } $this->disableTask($task); return true; }
php
private function disableSystemTask($systemKey) { if (!$task = $this->taskRepository->findBySystemKey($systemKey)) { return false; } $this->disableTask($task); return true; }
[ "private", "function", "disableSystemTask", "(", "$", "systemKey", ")", "{", "if", "(", "!", "$", "task", "=", "$", "this", "->", "taskRepository", "->", "findBySystemKey", "(", "$", "systemKey", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "disableTask", "(", "$", "task", ")", ";", "return", "true", ";", "}" ]
Disable task identified by system-key. @param string $systemKey @return bool
[ "Disable", "task", "identified", "by", "system", "-", "key", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Command/ScheduleSystemTasksCommand.php#L157-L166
231,216
php-task/TaskBundle
src/Command/ScheduleSystemTasksCommand.php
ScheduleSystemTasksCommand.disableTask
public function disableTask(TaskInterface $task) { $task->setInterval($task->getInterval(), $task->getFirstExecution(), new \DateTime()); return $this->abortPending($task); }
php
public function disableTask(TaskInterface $task) { $task->setInterval($task->getInterval(), $task->getFirstExecution(), new \DateTime()); return $this->abortPending($task); }
[ "public", "function", "disableTask", "(", "TaskInterface", "$", "task", ")", "{", "$", "task", "->", "setInterval", "(", "$", "task", "->", "getInterval", "(", ")", ",", "$", "task", "->", "getFirstExecution", "(", ")", ",", "new", "\\", "DateTime", "(", ")", ")", ";", "return", "$", "this", "->", "abortPending", "(", "$", "task", ")", ";", "}" ]
Disable given task identified. @param TaskInterface $task @return bool
[ "Disable", "given", "task", "identified", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Command/ScheduleSystemTasksCommand.php#L175-L180
231,217
php-task/TaskBundle
src/Command/ScheduleSystemTasksCommand.php
ScheduleSystemTasksCommand.updateTask
private function updateTask($systemKey, array $systemTask, TaskInterface $task) { if ($task->getHandlerClass() !== $systemTask['handler_class'] || $task->getWorkload() !== $systemTask['workload'] ) { throw new \InvalidArgumentException( sprintf('No update of handle-class or workload is supported for system-task "%s".', $systemKey) ); } if ($task->getInterval() === $systemTask['cron_expression']) { return; } $task->setInterval(CronExpression::factory($systemTask['cron_expression']), $task->getFirstExecution()); $this->abortPending($task); $this->scheduler->scheduleTasks(); }
php
private function updateTask($systemKey, array $systemTask, TaskInterface $task) { if ($task->getHandlerClass() !== $systemTask['handler_class'] || $task->getWorkload() !== $systemTask['workload'] ) { throw new \InvalidArgumentException( sprintf('No update of handle-class or workload is supported for system-task "%s".', $systemKey) ); } if ($task->getInterval() === $systemTask['cron_expression']) { return; } $task->setInterval(CronExpression::factory($systemTask['cron_expression']), $task->getFirstExecution()); $this->abortPending($task); $this->scheduler->scheduleTasks(); }
[ "private", "function", "updateTask", "(", "$", "systemKey", ",", "array", "$", "systemTask", ",", "TaskInterface", "$", "task", ")", "{", "if", "(", "$", "task", "->", "getHandlerClass", "(", ")", "!==", "$", "systemTask", "[", "'handler_class'", "]", "||", "$", "task", "->", "getWorkload", "(", ")", "!==", "$", "systemTask", "[", "'workload'", "]", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No update of handle-class or workload is supported for system-task \"%s\".'", ",", "$", "systemKey", ")", ")", ";", "}", "if", "(", "$", "task", "->", "getInterval", "(", ")", "===", "$", "systemTask", "[", "'cron_expression'", "]", ")", "{", "return", ";", "}", "$", "task", "->", "setInterval", "(", "CronExpression", "::", "factory", "(", "$", "systemTask", "[", "'cron_expression'", "]", ")", ",", "$", "task", "->", "getFirstExecution", "(", ")", ")", ";", "$", "this", "->", "abortPending", "(", "$", "task", ")", ";", "$", "this", "->", "scheduler", "->", "scheduleTasks", "(", ")", ";", "}" ]
Update given task. @param string $systemKey @param array $systemTask @param TaskInterface $task
[ "Update", "given", "task", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Command/ScheduleSystemTasksCommand.php#L189-L207
231,218
php-task/TaskBundle
src/Command/ScheduleSystemTasksCommand.php
ScheduleSystemTasksCommand.abortPending
private function abortPending(TaskInterface $task) { if (!$execution = $this->taskExecutionRepository->findPending($task)) { return false; } $execution->setStatus(TaskStatus::ABORTED); $this->taskExecutionRepository->save($execution); return true; }
php
private function abortPending(TaskInterface $task) { if (!$execution = $this->taskExecutionRepository->findPending($task)) { return false; } $execution->setStatus(TaskStatus::ABORTED); $this->taskExecutionRepository->save($execution); return true; }
[ "private", "function", "abortPending", "(", "TaskInterface", "$", "task", ")", "{", "if", "(", "!", "$", "execution", "=", "$", "this", "->", "taskExecutionRepository", "->", "findPending", "(", "$", "task", ")", ")", "{", "return", "false", ";", "}", "$", "execution", "->", "setStatus", "(", "TaskStatus", "::", "ABORTED", ")", ";", "$", "this", "->", "taskExecutionRepository", "->", "save", "(", "$", "execution", ")", ";", "return", "true", ";", "}" ]
Abort pending execution for given task. @param TaskInterface $task @return bool
[ "Abort", "pending", "execution", "for", "given", "task", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Command/ScheduleSystemTasksCommand.php#L216-L226
231,219
PaymentSuite/paymentsuite
src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteConfiguration.php
AbstractPaymentSuiteConfiguration.addRouteConfiguration
protected function addRouteConfiguration($routeName) { $builder = new TreeBuilder(); $node = $builder->root($routeName); $node ->isRequired() ->children() ->scalarNode('route') ->isRequired() ->cannotBeEmpty() ->end() ->booleanNode('order_append') ->defaultTrue() ->end() ->scalarNode('order_append_field') ->defaultValue('order_id') ->end() ->end(); return $node; }
php
protected function addRouteConfiguration($routeName) { $builder = new TreeBuilder(); $node = $builder->root($routeName); $node ->isRequired() ->children() ->scalarNode('route') ->isRequired() ->cannotBeEmpty() ->end() ->booleanNode('order_append') ->defaultTrue() ->end() ->scalarNode('order_append_field') ->defaultValue('order_id') ->end() ->end(); return $node; }
[ "protected", "function", "addRouteConfiguration", "(", "$", "routeName", ")", "{", "$", "builder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "node", "=", "$", "builder", "->", "root", "(", "$", "routeName", ")", ";", "$", "node", "->", "isRequired", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'route'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'order_append'", ")", "->", "defaultTrue", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'order_append_field'", ")", "->", "defaultValue", "(", "'order_id'", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "node", ";", "}" ]
Add a new success route in configuration. @param string $routeName Route name @return NodeDefinition Node
[ "Add", "a", "new", "success", "route", "in", "configuration", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteConfiguration.php#L34-L54
231,220
php-task/TaskBundle
src/Entity/TaskRepository.php
TaskRepository.findEndBefore
public function findEndBefore(\DateTime $dateTime) { return $this->createQueryBuilder('t') ->where('t.lastExecution IS NULL OR t.lastExecution > :dateTime') ->setParameter('dateTime', $dateTime) ->getQuery() ->getResult(); }
php
public function findEndBefore(\DateTime $dateTime) { return $this->createQueryBuilder('t') ->where('t.lastExecution IS NULL OR t.lastExecution > :dateTime') ->setParameter('dateTime', $dateTime) ->getQuery() ->getResult(); }
[ "public", "function", "findEndBefore", "(", "\\", "DateTime", "$", "dateTime", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'t'", ")", "->", "where", "(", "'t.lastExecution IS NULL OR t.lastExecution > :dateTime'", ")", "->", "setParameter", "(", "'dateTime'", ",", "$", "dateTime", ")", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Returns task where last-execution is before given date-time. @param \DateTime $dateTime @return TaskInterface[]
[ "Returns", "task", "where", "last", "-", "execution", "is", "before", "given", "date", "-", "time", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Entity/TaskRepository.php#L93-L100
231,221
php-task/TaskBundle
src/Entity/TaskRepository.php
TaskRepository.findBySystemKey
public function findBySystemKey($systemKey) { try { return $this->createQueryBuilder('t') ->where('t.systemKey = :systemKey') ->setParameter('systemKey', $systemKey) ->getQuery() ->getSingleResult(); } catch (NoResultException $exception) { return; } }
php
public function findBySystemKey($systemKey) { try { return $this->createQueryBuilder('t') ->where('t.systemKey = :systemKey') ->setParameter('systemKey', $systemKey) ->getQuery() ->getSingleResult(); } catch (NoResultException $exception) { return; } }
[ "public", "function", "findBySystemKey", "(", "$", "systemKey", ")", "{", "try", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'t'", ")", "->", "where", "(", "'t.systemKey = :systemKey'", ")", "->", "setParameter", "(", "'systemKey'", ",", "$", "systemKey", ")", "->", "getQuery", "(", ")", "->", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NoResultException", "$", "exception", ")", "{", "return", ";", "}", "}" ]
Returns task identified by system-key. @param string $systemKey @return TaskInterface
[ "Returns", "task", "identified", "by", "system", "-", "key", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Entity/TaskRepository.php#L109-L120
231,222
dnadesign/silverstripe-elemental-subsites
src/Extensions/ElementalSubsiteExtension.php
ElementalSubsiteExtension.augmentSQL
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) { if (!class_exists(Subsite::class)) { return; } if (Subsite::$disable_subsite_filter) { return; } if ($dataQuery && $dataQuery->getQueryParam('Subsite.filter') === false) { return; } if ($query->filtersOnID()) { return; } if (Subsite::$force_subsite) { $subsiteID = Subsite::$force_subsite; } else { $subsiteID = (int) SubsiteState::singleton()->getSubsiteId(); } // Get the base table name $elementTableName = DataObject::getSchema()->baseDataTable(BaseElement::class); // The foreach is an ugly way of getting the first key :-) foreach ($query->getFrom() as $tableName => $info) { // The tableName should be Element or Element_Live... if (substr($tableName, 0, strlen($elementTableName)) === $elementTableName) { $query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)"); break; } } }
php
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null) { if (!class_exists(Subsite::class)) { return; } if (Subsite::$disable_subsite_filter) { return; } if ($dataQuery && $dataQuery->getQueryParam('Subsite.filter') === false) { return; } if ($query->filtersOnID()) { return; } if (Subsite::$force_subsite) { $subsiteID = Subsite::$force_subsite; } else { $subsiteID = (int) SubsiteState::singleton()->getSubsiteId(); } // Get the base table name $elementTableName = DataObject::getSchema()->baseDataTable(BaseElement::class); // The foreach is an ugly way of getting the first key :-) foreach ($query->getFrom() as $tableName => $info) { // The tableName should be Element or Element_Live... if (substr($tableName, 0, strlen($elementTableName)) === $elementTableName) { $query->addWhere("\"$tableName\".\"SubsiteID\" IN ($subsiteID)"); break; } } }
[ "public", "function", "augmentSQL", "(", "SQLSelect", "$", "query", ",", "DataQuery", "$", "dataQuery", "=", "null", ")", "{", "if", "(", "!", "class_exists", "(", "Subsite", "::", "class", ")", ")", "{", "return", ";", "}", "if", "(", "Subsite", "::", "$", "disable_subsite_filter", ")", "{", "return", ";", "}", "if", "(", "$", "dataQuery", "&&", "$", "dataQuery", "->", "getQueryParam", "(", "'Subsite.filter'", ")", "===", "false", ")", "{", "return", ";", "}", "if", "(", "$", "query", "->", "filtersOnID", "(", ")", ")", "{", "return", ";", "}", "if", "(", "Subsite", "::", "$", "force_subsite", ")", "{", "$", "subsiteID", "=", "Subsite", "::", "$", "force_subsite", ";", "}", "else", "{", "$", "subsiteID", "=", "(", "int", ")", "SubsiteState", "::", "singleton", "(", ")", "->", "getSubsiteId", "(", ")", ";", "}", "// Get the base table name", "$", "elementTableName", "=", "DataObject", "::", "getSchema", "(", ")", "->", "baseDataTable", "(", "BaseElement", "::", "class", ")", ";", "// The foreach is an ugly way of getting the first key :-)", "foreach", "(", "$", "query", "->", "getFrom", "(", ")", "as", "$", "tableName", "=>", "$", "info", ")", "{", "// The tableName should be Element or Element_Live...", "if", "(", "substr", "(", "$", "tableName", ",", "0", ",", "strlen", "(", "$", "elementTableName", ")", ")", "===", "$", "elementTableName", ")", "{", "$", "query", "->", "addWhere", "(", "\"\\\"$tableName\\\".\\\"SubsiteID\\\" IN ($subsiteID)\"", ")", ";", "break", ";", "}", "}", "}" ]
Update any requests for elements to limit the results to the current site @param SQLSelect $query @param DataQuery|null $dataQuery
[ "Update", "any", "requests", "for", "elements", "to", "limit", "the", "results", "to", "the", "current", "site" ]
c6b0581779e39ffecf033ec72ab455ace2cf6951
https://github.com/dnadesign/silverstripe-elemental-subsites/blob/c6b0581779e39ffecf033ec72ab455ace2cf6951/src/Extensions/ElementalSubsiteExtension.php#L42-L77
231,223
benmag/laravel-rancher
src/Factories/Entity/AbstractEntity.php
AbstractEntity.setProperty
public function setProperty($property, $value) { $this->$property = $value; // Parse $value. Is it an entity or an array containing entities? // We've got an array, lets see if we can instantiate an entity if(is_array($value) && !empty($value) && is_object(head($value))) { $array = $value; // for clarity, call it what it is // We can only guess at what the entity might be if we have the `type` if(property_exists(head($array), 'type')) { // Get the class of the new entity we want to instantiate $class = (new \ReflectionClass($this))->getNamespaceName() . "\\" . ucfirst(head($array)->type); // Update each element of the array to have the instantiated entity if(class_exists($class)) foreach($array as $key => $value) { // Update the array with the entity $array[$key] = new $class($value); } // Update the property with the array of entities $this->$property = $array; } } // We've got an object, see if we can instantiate that into an entity else if(gettype($value) == "object") { if(property_exists($value, 'type')) { // Get the class of the new entity we want to instantiate $class = (new \ReflectionClass($this))->getNamespaceName() . "\\" . ucfirst($value->type); // Update the property with the instantiated entity if(class_exists($class)) { $this->$property = new $class($value); } } } }
php
public function setProperty($property, $value) { $this->$property = $value; // Parse $value. Is it an entity or an array containing entities? // We've got an array, lets see if we can instantiate an entity if(is_array($value) && !empty($value) && is_object(head($value))) { $array = $value; // for clarity, call it what it is // We can only guess at what the entity might be if we have the `type` if(property_exists(head($array), 'type')) { // Get the class of the new entity we want to instantiate $class = (new \ReflectionClass($this))->getNamespaceName() . "\\" . ucfirst(head($array)->type); // Update each element of the array to have the instantiated entity if(class_exists($class)) foreach($array as $key => $value) { // Update the array with the entity $array[$key] = new $class($value); } // Update the property with the array of entities $this->$property = $array; } } // We've got an object, see if we can instantiate that into an entity else if(gettype($value) == "object") { if(property_exists($value, 'type')) { // Get the class of the new entity we want to instantiate $class = (new \ReflectionClass($this))->getNamespaceName() . "\\" . ucfirst($value->type); // Update the property with the instantiated entity if(class_exists($class)) { $this->$property = new $class($value); } } } }
[ "public", "function", "setProperty", "(", "$", "property", ",", "$", "value", ")", "{", "$", "this", "->", "$", "property", "=", "$", "value", ";", "// Parse $value. Is it an entity or an array containing entities?", "// We've got an array, lets see if we can instantiate an entity", "if", "(", "is_array", "(", "$", "value", ")", "&&", "!", "empty", "(", "$", "value", ")", "&&", "is_object", "(", "head", "(", "$", "value", ")", ")", ")", "{", "$", "array", "=", "$", "value", ";", "// for clarity, call it what it is", "// We can only guess at what the entity might be if we have the `type`", "if", "(", "property_exists", "(", "head", "(", "$", "array", ")", ",", "'type'", ")", ")", "{", "// Get the class of the new entity we want to instantiate", "$", "class", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ")", "->", "getNamespaceName", "(", ")", ".", "\"\\\\\"", ".", "ucfirst", "(", "head", "(", "$", "array", ")", "->", "type", ")", ";", "// Update each element of the array to have the instantiated entity", "if", "(", "class_exists", "(", "$", "class", ")", ")", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "// Update the array with the entity", "$", "array", "[", "$", "key", "]", "=", "new", "$", "class", "(", "$", "value", ")", ";", "}", "// Update the property with the array of entities", "$", "this", "->", "$", "property", "=", "$", "array", ";", "}", "}", "// We've got an object, see if we can instantiate that into an entity", "else", "if", "(", "gettype", "(", "$", "value", ")", "==", "\"object\"", ")", "{", "if", "(", "property_exists", "(", "$", "value", ",", "'type'", ")", ")", "{", "// Get the class of the new entity we want to instantiate", "$", "class", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ")", "->", "getNamespaceName", "(", ")", ".", "\"\\\\\"", ".", "ucfirst", "(", "$", "value", "->", "type", ")", ";", "// Update the property with the instantiated entity", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "this", "->", "$", "property", "=", "new", "$", "class", "(", "$", "value", ")", ";", "}", "}", "}", "}" ]
By default, simply set the property to the specified value When the value is an array of objects with a `type` parameter, check if instantiation is possible. The value of `type` is used to decide which class to attempt to instantiate @param $property @param $value
[ "By", "default", "simply", "set", "the", "property", "to", "the", "specified", "value" ]
8cd933757c206588215c72b6691f72515eaa0f38
https://github.com/benmag/laravel-rancher/blob/8cd933757c206588215c72b6691f72515eaa0f38/src/Factories/Entity/AbstractEntity.php#L80-L130
231,224
niklongstone/regex-reverse
src/RegRev/Configuration.php
Configuration.setUp
public function setUp($parameters) { $expressions = new ExpressionContainer(); foreach ($parameters as $param) { $charType = $this->buildCharType($param); $expressions->set($charType); } return $expressions; }
php
public function setUp($parameters) { $expressions = new ExpressionContainer(); foreach ($parameters as $param) { $charType = $this->buildCharType($param); $expressions->set($charType); } return $expressions; }
[ "public", "function", "setUp", "(", "$", "parameters", ")", "{", "$", "expressions", "=", "new", "ExpressionContainer", "(", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "param", ")", "{", "$", "charType", "=", "$", "this", "->", "buildCharType", "(", "$", "param", ")", ";", "$", "expressions", "->", "set", "(", "$", "charType", ")", ";", "}", "return", "$", "expressions", ";", "}" ]
Setup the configuration. @param array $parameters @return ExpressionContainer
[ "Setup", "the", "configuration", "." ]
a93bb266fbc0621094a5d1ad2583b8a54999ea25
https://github.com/niklongstone/regex-reverse/blob/a93bb266fbc0621094a5d1ad2583b8a54999ea25/src/RegRev/Configuration.php#L230-L239
231,225
lukasdev/DRouter
src/Router.php
Router.validatePath
private function validatePath($path) { $last = strlen($path)-1; if ($path[$last] == '/') { $path = substr($path, 0, -1); } return $path; }
php
private function validatePath($path) { $last = strlen($path)-1; if ($path[$last] == '/') { $path = substr($path, 0, -1); } return $path; }
[ "private", "function", "validatePath", "(", "$", "path", ")", "{", "$", "last", "=", "strlen", "(", "$", "path", ")", "-", "1", ";", "if", "(", "$", "path", "[", "$", "last", "]", "==", "'/'", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "0", ",", "-", "1", ")", ";", "}", "return", "$", "path", ";", "}" ]
Valida os paths das rotas, retirando a ultima barra caso exista para evitar conflitos no dispatch @param $path string
[ "Valida", "os", "paths", "das", "rotas", "retirando", "a", "ultima", "barra", "caso", "exista", "para", "evitar", "conflitos", "no", "dispatch" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L96-L103
231,226
lukasdev/DRouter
src/Router.php
Router.group
public function group($prefix, $fnc) { $this->routePrefix = $prefix; if ($fnc instanceof \Closure) { $fnc(); } else { throw new \InvalidArgumentException('Callable do metodo group DEVE ser um Closure'); } $this->routePrefix = null; $this->groupMiddlewares[$prefix] = []; $this->currentGroup = $prefix; return $this; }
php
public function group($prefix, $fnc) { $this->routePrefix = $prefix; if ($fnc instanceof \Closure) { $fnc(); } else { throw new \InvalidArgumentException('Callable do metodo group DEVE ser um Closure'); } $this->routePrefix = null; $this->groupMiddlewares[$prefix] = []; $this->currentGroup = $prefix; return $this; }
[ "public", "function", "group", "(", "$", "prefix", ",", "$", "fnc", ")", "{", "$", "this", "->", "routePrefix", "=", "$", "prefix", ";", "if", "(", "$", "fnc", "instanceof", "\\", "Closure", ")", "{", "$", "fnc", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Callable do metodo group DEVE ser um Closure'", ")", ";", "}", "$", "this", "->", "routePrefix", "=", "null", ";", "$", "this", "->", "groupMiddlewares", "[", "$", "prefix", "]", "=", "[", "]", ";", "$", "this", "->", "currentGroup", "=", "$", "prefix", ";", "return", "$", "this", ";", "}" ]
Define o prefixo para agrupamento das rotas @param $prefix string @param $fnc callable Closure
[ "Define", "o", "prefixo", "para", "agrupamento", "das", "rotas" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L143-L156
231,227
lukasdev/DRouter
src/Router.php
Router.setName
public function setName($routeName) { $lastMethod = $this->lastRouteMethod; $lastIndex = count($this->routes[$lastMethod])-1; $indexName = $lastMethod.':'.$lastIndex; $this->routeNames[$indexName] = $routeName; $rota = $this->routes[$lastMethod][$lastIndex]; $rota->setName($routeName); $this->routes[$lastMethod][$lastIndex] = $rota; return $this; }
php
public function setName($routeName) { $lastMethod = $this->lastRouteMethod; $lastIndex = count($this->routes[$lastMethod])-1; $indexName = $lastMethod.':'.$lastIndex; $this->routeNames[$indexName] = $routeName; $rota = $this->routes[$lastMethod][$lastIndex]; $rota->setName($routeName); $this->routes[$lastMethod][$lastIndex] = $rota; return $this; }
[ "public", "function", "setName", "(", "$", "routeName", ")", "{", "$", "lastMethod", "=", "$", "this", "->", "lastRouteMethod", ";", "$", "lastIndex", "=", "count", "(", "$", "this", "->", "routes", "[", "$", "lastMethod", "]", ")", "-", "1", ";", "$", "indexName", "=", "$", "lastMethod", ".", "':'", ".", "$", "lastIndex", ";", "$", "this", "->", "routeNames", "[", "$", "indexName", "]", "=", "$", "routeName", ";", "$", "rota", "=", "$", "this", "->", "routes", "[", "$", "lastMethod", "]", "[", "$", "lastIndex", "]", ";", "$", "rota", "->", "setName", "(", "$", "routeName", ")", ";", "$", "this", "->", "routes", "[", "$", "lastMethod", "]", "[", "$", "lastIndex", "]", "=", "$", "rota", ";", "return", "$", "this", ";", "}" ]
Define o nome de uma rota recem criada @param $routeName string
[ "Define", "o", "nome", "de", "uma", "rota", "recem", "criada" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L162-L174
231,228
lukasdev/DRouter
src/Router.php
Router.findRouteByName
public function findRouteByName($routeName) { $routePath = array_search($routeName, $this->routeNames); list($method, $index) = explode(':', $routePath); return $this->routes[$method][$index]; }
php
public function findRouteByName($routeName) { $routePath = array_search($routeName, $this->routeNames); list($method, $index) = explode(':', $routePath); return $this->routes[$method][$index]; }
[ "public", "function", "findRouteByName", "(", "$", "routeName", ")", "{", "$", "routePath", "=", "array_search", "(", "$", "routeName", ",", "$", "this", "->", "routeNames", ")", ";", "list", "(", "$", "method", ",", "$", "index", ")", "=", "explode", "(", "':'", ",", "$", "routePath", ")", ";", "return", "$", "this", "->", "routes", "[", "$", "method", "]", "[", "$", "index", "]", ";", "}" ]
Encontra um objeto de uma rota por seu nome
[ "Encontra", "um", "objeto", "de", "uma", "rota", "por", "seu", "nome" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L179-L184
231,229
lukasdev/DRouter
src/Router.php
Router.findLastRoute
private function findLastRoute() { $method = $this->lastRouteMethod; $index = count($this->routes[$method])-1; return $this->routes[$method][$index]; }
php
private function findLastRoute() { $method = $this->lastRouteMethod; $index = count($this->routes[$method])-1; return $this->routes[$method][$index]; }
[ "private", "function", "findLastRoute", "(", ")", "{", "$", "method", "=", "$", "this", "->", "lastRouteMethod", ";", "$", "index", "=", "count", "(", "$", "this", "->", "routes", "[", "$", "method", "]", ")", "-", "1", ";", "return", "$", "this", "->", "routes", "[", "$", "method", "]", "[", "$", "index", "]", ";", "}" ]
Encontra o ultimo objeto de rota declarada idependente de seu name
[ "Encontra", "o", "ultimo", "objeto", "de", "rota", "declarada", "idependente", "de", "seu", "name" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L189-L195
231,230
lukasdev/DRouter
src/Router.php
Router.redirectTo
public function redirectTo($routeName, $query = array(), $params = array()) { $path = $this->pathFor($routeName, $params); if (!is_array($query)) { throw new \UnexpectedValueException('Router::redirectTo A query deve ser um array!'); } if (count($query) > 0) { $path = $path.'?'.http_build_query($query); } $path = ($path == '') ? '/' : $path; header("Location: ".$path); die; }
php
public function redirectTo($routeName, $query = array(), $params = array()) { $path = $this->pathFor($routeName, $params); if (!is_array($query)) { throw new \UnexpectedValueException('Router::redirectTo A query deve ser um array!'); } if (count($query) > 0) { $path = $path.'?'.http_build_query($query); } $path = ($path == '') ? '/' : $path; header("Location: ".$path); die; }
[ "public", "function", "redirectTo", "(", "$", "routeName", ",", "$", "query", "=", "array", "(", ")", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "pathFor", "(", "$", "routeName", ",", "$", "params", ")", ";", "if", "(", "!", "is_array", "(", "$", "query", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Router::redirectTo A query deve ser um array!'", ")", ";", "}", "if", "(", "count", "(", "$", "query", ")", ">", "0", ")", "{", "$", "path", "=", "$", "path", ".", "'?'", ".", "http_build_query", "(", "$", "query", ")", ";", "}", "$", "path", "=", "(", "$", "path", "==", "''", ")", "?", "'/'", ":", "$", "path", ";", "header", "(", "\"Location: \"", ".", "$", "path", ")", ";", "die", ";", "}" ]
Efetua um redirecionamento para um path, passando gets opcionais convertidos de array, como parametros @param string $routeName @param array $query @param array $params
[ "Efetua", "um", "redirecionamento", "para", "um", "path", "passando", "gets", "opcionais", "convertidos", "de", "array", "como", "parametros" ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L304-L318
231,231
lukasdev/DRouter
src/Router.php
Router.dispatchCandidateRoutes
public function dispatchCandidateRoutes($requestUri) { $expUri = explode('/',$requestUri); $similaridades = []; if (count($this->candidateRoutes) > 1) { foreach ($this->candidateRoutes as $n => $rota) { $padrao = $rota->getPattern(); if (preg_match('/\[:options\]/', $padrao)) { unset($this->candidateRoutes[$n]); } } } foreach ($this->candidateRoutes as $n => $rota) { $padrao = $rota->getPattern(); if (preg_match('/\[:options\]/', $padrao)) { $this->matchedRoute = $rota; $this->candidateRoutes = []; return; } $naoVariaveis = $this->getNonVariables($padrao); foreach ($naoVariaveis as $i => $valor) { if(!isset($similaridades[$n])) $similaridades[$n] = 0; if (isset($expUri[$i]) && $expUri[$i] == $valor) { $similaridades[$n] += 1; } } } $bigger = max(array_values($similaridades)); $mostSimilar = array_search($bigger, $similaridades); $this->matchedRoute = $this->candidateRoutes[$mostSimilar]; $this->candidateRoutes = []; }
php
public function dispatchCandidateRoutes($requestUri) { $expUri = explode('/',$requestUri); $similaridades = []; if (count($this->candidateRoutes) > 1) { foreach ($this->candidateRoutes as $n => $rota) { $padrao = $rota->getPattern(); if (preg_match('/\[:options\]/', $padrao)) { unset($this->candidateRoutes[$n]); } } } foreach ($this->candidateRoutes as $n => $rota) { $padrao = $rota->getPattern(); if (preg_match('/\[:options\]/', $padrao)) { $this->matchedRoute = $rota; $this->candidateRoutes = []; return; } $naoVariaveis = $this->getNonVariables($padrao); foreach ($naoVariaveis as $i => $valor) { if(!isset($similaridades[$n])) $similaridades[$n] = 0; if (isset($expUri[$i]) && $expUri[$i] == $valor) { $similaridades[$n] += 1; } } } $bigger = max(array_values($similaridades)); $mostSimilar = array_search($bigger, $similaridades); $this->matchedRoute = $this->candidateRoutes[$mostSimilar]; $this->candidateRoutes = []; }
[ "public", "function", "dispatchCandidateRoutes", "(", "$", "requestUri", ")", "{", "$", "expUri", "=", "explode", "(", "'/'", ",", "$", "requestUri", ")", ";", "$", "similaridades", "=", "[", "]", ";", "if", "(", "count", "(", "$", "this", "->", "candidateRoutes", ")", ">", "1", ")", "{", "foreach", "(", "$", "this", "->", "candidateRoutes", "as", "$", "n", "=>", "$", "rota", ")", "{", "$", "padrao", "=", "$", "rota", "->", "getPattern", "(", ")", ";", "if", "(", "preg_match", "(", "'/\\[:options\\]/'", ",", "$", "padrao", ")", ")", "{", "unset", "(", "$", "this", "->", "candidateRoutes", "[", "$", "n", "]", ")", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "candidateRoutes", "as", "$", "n", "=>", "$", "rota", ")", "{", "$", "padrao", "=", "$", "rota", "->", "getPattern", "(", ")", ";", "if", "(", "preg_match", "(", "'/\\[:options\\]/'", ",", "$", "padrao", ")", ")", "{", "$", "this", "->", "matchedRoute", "=", "$", "rota", ";", "$", "this", "->", "candidateRoutes", "=", "[", "]", ";", "return", ";", "}", "$", "naoVariaveis", "=", "$", "this", "->", "getNonVariables", "(", "$", "padrao", ")", ";", "foreach", "(", "$", "naoVariaveis", "as", "$", "i", "=>", "$", "valor", ")", "{", "if", "(", "!", "isset", "(", "$", "similaridades", "[", "$", "n", "]", ")", ")", "$", "similaridades", "[", "$", "n", "]", "=", "0", ";", "if", "(", "isset", "(", "$", "expUri", "[", "$", "i", "]", ")", "&&", "$", "expUri", "[", "$", "i", "]", "==", "$", "valor", ")", "{", "$", "similaridades", "[", "$", "n", "]", "+=", "1", ";", "}", "}", "}", "$", "bigger", "=", "max", "(", "array_values", "(", "$", "similaridades", ")", ")", ";", "$", "mostSimilar", "=", "array_search", "(", "$", "bigger", ",", "$", "similaridades", ")", ";", "$", "this", "->", "matchedRoute", "=", "$", "this", "->", "candidateRoutes", "[", "$", "mostSimilar", "]", ";", "$", "this", "->", "candidateRoutes", "=", "[", "]", ";", "}" ]
Determina qual rota deve ser despachada, com base em sua similaridade com a request URI,para evitar conflitos entre rotas parecidas. @param $requestUri string
[ "Determina", "qual", "rota", "deve", "ser", "despachada", "com", "base", "em", "sua", "similaridade", "com", "a", "request", "URI", "para", "evitar", "conflitos", "entre", "rotas", "parecidas", "." ]
b02e9fb595f00b89122886ccb77f623bae09141a
https://github.com/lukasdev/DRouter/blob/b02e9fb595f00b89122886ccb77f623bae09141a/src/Router.php#L375-L412
231,232
schemaio/schema-php-client
lib/Connection.php
Connection.request_write
private function request_write($args) { $request = json_encode($args)."\n"; $this->last_request = $request; if (!$this->stream) { $desc = $this->request_description(); throw new NetworkException("Unable to execute request ({$desc}): Connection closed"); } // Must block while writing stream_set_blocking($this->stream, true); for ($written = 0; $written < strlen($request); $written += $fwrite) { $fwrite = fwrite($this->stream, substr($request, $written)); if ($fwrite === false) { break; } } $this->request_count++; }
php
private function request_write($args) { $request = json_encode($args)."\n"; $this->last_request = $request; if (!$this->stream) { $desc = $this->request_description(); throw new NetworkException("Unable to execute request ({$desc}): Connection closed"); } // Must block while writing stream_set_blocking($this->stream, true); for ($written = 0; $written < strlen($request); $written += $fwrite) { $fwrite = fwrite($this->stream, substr($request, $written)); if ($fwrite === false) { break; } } $this->request_count++; }
[ "private", "function", "request_write", "(", "$", "args", ")", "{", "$", "request", "=", "json_encode", "(", "$", "args", ")", ".", "\"\\n\"", ";", "$", "this", "->", "last_request", "=", "$", "request", ";", "if", "(", "!", "$", "this", "->", "stream", ")", "{", "$", "desc", "=", "$", "this", "->", "request_description", "(", ")", ";", "throw", "new", "NetworkException", "(", "\"Unable to execute request ({$desc}): Connection closed\"", ")", ";", "}", "// Must block while writing", "stream_set_blocking", "(", "$", "this", "->", "stream", ",", "true", ")", ";", "for", "(", "$", "written", "=", "0", ";", "$", "written", "<", "strlen", "(", "$", "request", ")", ";", "$", "written", "+=", "$", "fwrite", ")", "{", "$", "fwrite", "=", "fwrite", "(", "$", "this", "->", "stream", ",", "substr", "(", "$", "request", ",", "$", "written", ")", ")", ";", "if", "(", "$", "fwrite", "===", "false", ")", "{", "break", ";", "}", "}", "$", "this", "->", "request_count", "++", ";", "}" ]
Write request to stream @param array $args
[ "Write", "request", "to", "stream" ]
20759434a6dd7fcc38910eca5ad228287472751b
https://github.com/schemaio/schema-php-client/blob/20759434a6dd7fcc38910eca5ad228287472751b/lib/Connection.php#L120-L140
231,233
schemaio/schema-php-client
lib/Connection.php
Connection.request_response
private function request_response() { // Must not block while reading stream_set_blocking($this->stream, false); $response = ''; while (true) { $buffer = fgets($this->stream); $response .= $buffer; if (strstr($buffer, "\n")) { break; } else { usleep(1000); } } $data = ''; if (!$response) { $this->close(); $desc = $this->request_description(); throw new ProtocolException("Unable to read response from server ({$desc})"); } else if (null === ($data = json_decode(trim($response), true))) { $desc = $this->request_description(); throw new ProtocolException("Unable to parse response from server ({$desc}): {$response}"); } else if (!is_array($data)) { $desc = $this->request_description(); throw new ProtocolException("Invalid response from server ({$desc}): ".json_encode($data)); } if (isset($data['$error'])) { throw new ServerException((string)$data['$error']); } if (isset($data['$end'])) { $this->close(); } return $data; }
php
private function request_response() { // Must not block while reading stream_set_blocking($this->stream, false); $response = ''; while (true) { $buffer = fgets($this->stream); $response .= $buffer; if (strstr($buffer, "\n")) { break; } else { usleep(1000); } } $data = ''; if (!$response) { $this->close(); $desc = $this->request_description(); throw new ProtocolException("Unable to read response from server ({$desc})"); } else if (null === ($data = json_decode(trim($response), true))) { $desc = $this->request_description(); throw new ProtocolException("Unable to parse response from server ({$desc}): {$response}"); } else if (!is_array($data)) { $desc = $this->request_description(); throw new ProtocolException("Invalid response from server ({$desc}): ".json_encode($data)); } if (isset($data['$error'])) { throw new ServerException((string)$data['$error']); } if (isset($data['$end'])) { $this->close(); } return $data; }
[ "private", "function", "request_response", "(", ")", "{", "// Must not block while reading", "stream_set_blocking", "(", "$", "this", "->", "stream", ",", "false", ")", ";", "$", "response", "=", "''", ";", "while", "(", "true", ")", "{", "$", "buffer", "=", "fgets", "(", "$", "this", "->", "stream", ")", ";", "$", "response", ".=", "$", "buffer", ";", "if", "(", "strstr", "(", "$", "buffer", ",", "\"\\n\"", ")", ")", "{", "break", ";", "}", "else", "{", "usleep", "(", "1000", ")", ";", "}", "}", "$", "data", "=", "''", ";", "if", "(", "!", "$", "response", ")", "{", "$", "this", "->", "close", "(", ")", ";", "$", "desc", "=", "$", "this", "->", "request_description", "(", ")", ";", "throw", "new", "ProtocolException", "(", "\"Unable to read response from server ({$desc})\"", ")", ";", "}", "else", "if", "(", "null", "===", "(", "$", "data", "=", "json_decode", "(", "trim", "(", "$", "response", ")", ",", "true", ")", ")", ")", "{", "$", "desc", "=", "$", "this", "->", "request_description", "(", ")", ";", "throw", "new", "ProtocolException", "(", "\"Unable to parse response from server ({$desc}): {$response}\"", ")", ";", "}", "else", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "$", "desc", "=", "$", "this", "->", "request_description", "(", ")", ";", "throw", "new", "ProtocolException", "(", "\"Invalid response from server ({$desc}): \"", ".", "json_encode", "(", "$", "data", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'$error'", "]", ")", ")", "{", "throw", "new", "ServerException", "(", "(", "string", ")", "$", "data", "[", "'$error'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'$end'", "]", ")", ")", "{", "$", "this", "->", "close", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Get server response @return mixed
[ "Get", "server", "response" ]
20759434a6dd7fcc38910eca5ad228287472751b
https://github.com/schemaio/schema-php-client/blob/20759434a6dd7fcc38910eca5ad228287472751b/lib/Connection.php#L147-L184
231,234
schemaio/schema-php-client
lib/Connection.php
Connection.request_description
private function request_description() { $request = json_decode(trim($this->last_request), true); $desc = strtoupper($request[0]); if (isset($request[1])) { $desc .= ' '.json_encode($request[1]); } return $desc; }
php
private function request_description() { $request = json_decode(trim($this->last_request), true); $desc = strtoupper($request[0]); if (isset($request[1])) { $desc .= ' '.json_encode($request[1]); } return $desc; }
[ "private", "function", "request_description", "(", ")", "{", "$", "request", "=", "json_decode", "(", "trim", "(", "$", "this", "->", "last_request", ")", ",", "true", ")", ";", "$", "desc", "=", "strtoupper", "(", "$", "request", "[", "0", "]", ")", ";", "if", "(", "isset", "(", "$", "request", "[", "1", "]", ")", ")", "{", "$", "desc", ".=", "' '", ".", "json_encode", "(", "$", "request", "[", "1", "]", ")", ";", "}", "return", "$", "desc", ";", "}" ]
Get description of last request @return string
[ "Get", "description", "of", "last", "request" ]
20759434a6dd7fcc38910eca5ad228287472751b
https://github.com/schemaio/schema-php-client/blob/20759434a6dd7fcc38910eca5ad228287472751b/lib/Connection.php#L191-L199
231,235
schemaio/schema-php-client
lib/Connection.php
Connection.close
public function close() { fclose($this->stream); $this->stream = null; $this->connected = false; }
php
public function close() { fclose($this->stream); $this->stream = null; $this->connected = false; }
[ "public", "function", "close", "(", ")", "{", "fclose", "(", "$", "this", "->", "stream", ")", ";", "$", "this", "->", "stream", "=", "null", ";", "$", "this", "->", "connected", "=", "false", ";", "}" ]
Close connection stream @return void
[ "Close", "connection", "stream" ]
20759434a6dd7fcc38910eca5ad228287472751b
https://github.com/schemaio/schema-php-client/blob/20759434a6dd7fcc38910eca5ad228287472751b/lib/Connection.php#L206-L211
231,236
juliushaertl/phpdoc-to-rst
src/ApiDocBuilder.php
ApiDocBuilder.createDirectoryStructure
private function createDirectoryStructure() { foreach ($this->project->getNamespaces() as $namespace) { $namespaceDir = $this->dstDir . str_replace('\\', '/', $namespace->getFqsen()); if (is_dir($namespaceDir)) { continue; } if (!mkdir($namespaceDir, 0755, true)) { throw new WriteException('Could not create directory ' . $namespaceDir); } } }
php
private function createDirectoryStructure() { foreach ($this->project->getNamespaces() as $namespace) { $namespaceDir = $this->dstDir . str_replace('\\', '/', $namespace->getFqsen()); if (is_dir($namespaceDir)) { continue; } if (!mkdir($namespaceDir, 0755, true)) { throw new WriteException('Could not create directory ' . $namespaceDir); } } }
[ "private", "function", "createDirectoryStructure", "(", ")", "{", "foreach", "(", "$", "this", "->", "project", "->", "getNamespaces", "(", ")", "as", "$", "namespace", ")", "{", "$", "namespaceDir", "=", "$", "this", "->", "dstDir", ".", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "namespace", "->", "getFqsen", "(", ")", ")", ";", "if", "(", "is_dir", "(", "$", "namespaceDir", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "mkdir", "(", "$", "namespaceDir", ",", "0755", ",", "true", ")", ")", "{", "throw", "new", "WriteException", "(", "'Could not create directory '", ".", "$", "namespaceDir", ")", ";", "}", "}", "}" ]
Create directory structure for the rst output @throws WriteException
[ "Create", "directory", "structure", "for", "the", "rst", "output" ]
9a695417d1f3bb709f60cd5c519e46f1ad08c843
https://github.com/juliushaertl/phpdoc-to-rst/blob/9a695417d1f3bb709f60cd5c519e46f1ad08c843/src/ApiDocBuilder.php#L215-L225
231,237
PaymentSuite/paymentsuite
src/PaymentSuite/PaypalWebCheckoutBundle/Services/PaypalWebCheckoutMethodFactory.php
PaypalWebCheckoutMethodFactory.create
public function create( $mcGross = null, $paymentStatus = null, $notifyVersion = null, $payerStatus = null, $business = null, $quantity = null, $verifySign = null, $payerEmail = null, $txnId = null, $paymentType = null, $receiverEmail = null, $pendingReason = null, $txnType = null, $itemName = null, $mcCurrency = null, $itemNumber = null, $testIpn = null, $ipnTrackId = null ) { return new PaypalWebCheckoutMethod( $mcGross, $paymentStatus, $notifyVersion, $payerStatus, $business, $quantity, $verifySign, $payerEmail, $txnId, $paymentType, $receiverEmail, $pendingReason, $txnType, $itemName, $mcCurrency, $itemNumber, $testIpn, $ipnTrackId ); }
php
public function create( $mcGross = null, $paymentStatus = null, $notifyVersion = null, $payerStatus = null, $business = null, $quantity = null, $verifySign = null, $payerEmail = null, $txnId = null, $paymentType = null, $receiverEmail = null, $pendingReason = null, $txnType = null, $itemName = null, $mcCurrency = null, $itemNumber = null, $testIpn = null, $ipnTrackId = null ) { return new PaypalWebCheckoutMethod( $mcGross, $paymentStatus, $notifyVersion, $payerStatus, $business, $quantity, $verifySign, $payerEmail, $txnId, $paymentType, $receiverEmail, $pendingReason, $txnType, $itemName, $mcCurrency, $itemNumber, $testIpn, $ipnTrackId ); }
[ "public", "function", "create", "(", "$", "mcGross", "=", "null", ",", "$", "paymentStatus", "=", "null", ",", "$", "notifyVersion", "=", "null", ",", "$", "payerStatus", "=", "null", ",", "$", "business", "=", "null", ",", "$", "quantity", "=", "null", ",", "$", "verifySign", "=", "null", ",", "$", "payerEmail", "=", "null", ",", "$", "txnId", "=", "null", ",", "$", "paymentType", "=", "null", ",", "$", "receiverEmail", "=", "null", ",", "$", "pendingReason", "=", "null", ",", "$", "txnType", "=", "null", ",", "$", "itemName", "=", "null", ",", "$", "mcCurrency", "=", "null", ",", "$", "itemNumber", "=", "null", ",", "$", "testIpn", "=", "null", ",", "$", "ipnTrackId", "=", "null", ")", "{", "return", "new", "PaypalWebCheckoutMethod", "(", "$", "mcGross", ",", "$", "paymentStatus", ",", "$", "notifyVersion", ",", "$", "payerStatus", ",", "$", "business", ",", "$", "quantity", ",", "$", "verifySign", ",", "$", "payerEmail", ",", "$", "txnId", ",", "$", "paymentType", ",", "$", "receiverEmail", ",", "$", "pendingReason", ",", "$", "txnType", ",", "$", "itemName", ",", "$", "mcCurrency", ",", "$", "itemNumber", ",", "$", "testIpn", ",", "$", "ipnTrackId", ")", ";", "}" ]
Initialize Paypal Method using an array which represents the parameters coming from the IPN message as shown in. https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/#id091EAB0105Z @param float $mcGross Mc gross @param string $paymentStatus Payment status @param string $notifyVersion Notify version @param string $payerStatus Payer status @param string $business Business @param string $quantity Quantity @param string $verifySign Verify sign @param string $payerEmail Payer email @param string $txnId Txn id @param string $paymentType Payment type @param string $receiverEmail Reciever email @param string $pendingReason Pending reason @param string $txnType Txn type @param string $itemName Item name @param string $mcCurrency Mc currency @param string $itemNumber Item number @param string $testIpn Test ipn @param string $ipnTrackId Ipn track id @return PaypalWebCheckoutMethod Method instance
[ "Initialize", "Paypal", "Method", "using", "an", "array", "which", "represents", "the", "parameters", "coming", "from", "the", "IPN", "message", "as", "shown", "in", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaypalWebCheckoutBundle/Services/PaypalWebCheckoutMethodFactory.php#L63-L103
231,238
jupeter/DoctrineDumpFixturesBundle
Command/DoctrineDumpCommand.php
DoctrineDumpCommand.loadCollaction
protected function loadCollaction($name, $entityName, $fields) { $em = $this->getContainer()->get('doctrine')->getManager(); $entityRepository = $em->getRepository($entityName); $meta = $em->getClassMetadata($entityName); $identifier = $meta->getSingleIdentifierFieldName(); $identifierMethodName = 'get'.ucfirst($identifier); $collection = $entityRepository->findAll(); $result = array(); foreach ($collection as $item) { $element = array(); foreach ($fields as $fieldName => $attributes) { $methodName = 'get'.ucfirst($fieldName); $fieldValue = $item->$methodName(); $value = null; if (is_object($fieldValue)) { if (get_class($fieldValue) === 'DateTime') { $value = array('type' => 'DateTime', 'name' => $fieldValue->format('r')); } elseif (array_key_exists('targetEntity', $attributes)) { $targetClassName = $meta->associationMappings[$fieldName]['targetEntity']; $targetEntityProvider = new EntityProvider($targetClassName); $targetMethodName = 'get'.ucfirst($em->getClassMetadata($targetClassName)->identifier[0]); $value = array( 'type' => 'reference', 'name' => $targetEntityProvider->getName().'_'.$fieldValue->$targetMethodName(), ); } else { throw new \Exception('aaa'); } } else { $value = $fieldValue; } $element[$fieldName] = $value; } $result[$name.'_'.$item->$identifierMethodName()] = $element; } return $result; }
php
protected function loadCollaction($name, $entityName, $fields) { $em = $this->getContainer()->get('doctrine')->getManager(); $entityRepository = $em->getRepository($entityName); $meta = $em->getClassMetadata($entityName); $identifier = $meta->getSingleIdentifierFieldName(); $identifierMethodName = 'get'.ucfirst($identifier); $collection = $entityRepository->findAll(); $result = array(); foreach ($collection as $item) { $element = array(); foreach ($fields as $fieldName => $attributes) { $methodName = 'get'.ucfirst($fieldName); $fieldValue = $item->$methodName(); $value = null; if (is_object($fieldValue)) { if (get_class($fieldValue) === 'DateTime') { $value = array('type' => 'DateTime', 'name' => $fieldValue->format('r')); } elseif (array_key_exists('targetEntity', $attributes)) { $targetClassName = $meta->associationMappings[$fieldName]['targetEntity']; $targetEntityProvider = new EntityProvider($targetClassName); $targetMethodName = 'get'.ucfirst($em->getClassMetadata($targetClassName)->identifier[0]); $value = array( 'type' => 'reference', 'name' => $targetEntityProvider->getName().'_'.$fieldValue->$targetMethodName(), ); } else { throw new \Exception('aaa'); } } else { $value = $fieldValue; } $element[$fieldName] = $value; } $result[$name.'_'.$item->$identifierMethodName()] = $element; } return $result; }
[ "protected", "function", "loadCollaction", "(", "$", "name", ",", "$", "entityName", ",", "$", "fields", ")", "{", "$", "em", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "$", "entityRepository", "=", "$", "em", "->", "getRepository", "(", "$", "entityName", ")", ";", "$", "meta", "=", "$", "em", "->", "getClassMetadata", "(", "$", "entityName", ")", ";", "$", "identifier", "=", "$", "meta", "->", "getSingleIdentifierFieldName", "(", ")", ";", "$", "identifierMethodName", "=", "'get'", ".", "ucfirst", "(", "$", "identifier", ")", ";", "$", "collection", "=", "$", "entityRepository", "->", "findAll", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "item", ")", "{", "$", "element", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "attributes", ")", "{", "$", "methodName", "=", "'get'", ".", "ucfirst", "(", "$", "fieldName", ")", ";", "$", "fieldValue", "=", "$", "item", "->", "$", "methodName", "(", ")", ";", "$", "value", "=", "null", ";", "if", "(", "is_object", "(", "$", "fieldValue", ")", ")", "{", "if", "(", "get_class", "(", "$", "fieldValue", ")", "===", "'DateTime'", ")", "{", "$", "value", "=", "array", "(", "'type'", "=>", "'DateTime'", ",", "'name'", "=>", "$", "fieldValue", "->", "format", "(", "'r'", ")", ")", ";", "}", "elseif", "(", "array_key_exists", "(", "'targetEntity'", ",", "$", "attributes", ")", ")", "{", "$", "targetClassName", "=", "$", "meta", "->", "associationMappings", "[", "$", "fieldName", "]", "[", "'targetEntity'", "]", ";", "$", "targetEntityProvider", "=", "new", "EntityProvider", "(", "$", "targetClassName", ")", ";", "$", "targetMethodName", "=", "'get'", ".", "ucfirst", "(", "$", "em", "->", "getClassMetadata", "(", "$", "targetClassName", ")", "->", "identifier", "[", "0", "]", ")", ";", "$", "value", "=", "array", "(", "'type'", "=>", "'reference'", ",", "'name'", "=>", "$", "targetEntityProvider", "->", "getName", "(", ")", ".", "'_'", ".", "$", "fieldValue", "->", "$", "targetMethodName", "(", ")", ",", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'aaa'", ")", ";", "}", "}", "else", "{", "$", "value", "=", "$", "fieldValue", ";", "}", "$", "element", "[", "$", "fieldName", "]", "=", "$", "value", ";", "}", "$", "result", "[", "$", "name", ".", "'_'", ".", "$", "item", "->", "$", "identifierMethodName", "(", ")", "]", "=", "$", "element", ";", "}", "return", "$", "result", ";", "}" ]
Load Collection of Doctrine entities. @param $name @param $entityName @param $fields @return array @throws \Exception
[ "Load", "Collection", "of", "Doctrine", "entities", "." ]
7207417ae847fb1aaa6bd2014217976c5b121cb3
https://github.com/jupeter/DoctrineDumpFixturesBundle/blob/7207417ae847fb1aaa6bd2014217976c5b121cb3/Command/DoctrineDumpCommand.php#L121-L169
231,239
jupeter/DoctrineDumpFixturesBundle
Command/DoctrineDumpCommand.php
DoctrineDumpCommand.loadItem
protected function loadItem($em, $data, $attributes, $association) { if (is_object($data)) { if (get_class($data) === 'DateTime') { return array('type' => 'DateTime', 'name' => $data->format('r')); } if (array_key_exists('targetEntity', $attributes)) { $targetClass = $em->getClassMetadata($attributes['targetEntity']); // var_dump($association);die(); $className = get_class($data); // die($className); $entityProvider = new EntityProvider($className); // $meta = $em->getClassMetadata($className); $identifier = $targetClass->getSingleIdentifierFieldName(); $identifierMethodName = 'get'.ucfirst($identifier); return array( 'type' => 'reference', 'name' => $entityProvider->getName().'_'.$data->$identifierMethodName(), ); } throw new \Exception('Unknown data class: '.get_class($data)); } if (!is_array($data)) { return str_replace(array("\r\n", "\r", "\n"), '\n', htmlspecialchars($data, ENT_QUOTES)); } return $data; }
php
protected function loadItem($em, $data, $attributes, $association) { if (is_object($data)) { if (get_class($data) === 'DateTime') { return array('type' => 'DateTime', 'name' => $data->format('r')); } if (array_key_exists('targetEntity', $attributes)) { $targetClass = $em->getClassMetadata($attributes['targetEntity']); // var_dump($association);die(); $className = get_class($data); // die($className); $entityProvider = new EntityProvider($className); // $meta = $em->getClassMetadata($className); $identifier = $targetClass->getSingleIdentifierFieldName(); $identifierMethodName = 'get'.ucfirst($identifier); return array( 'type' => 'reference', 'name' => $entityProvider->getName().'_'.$data->$identifierMethodName(), ); } throw new \Exception('Unknown data class: '.get_class($data)); } if (!is_array($data)) { return str_replace(array("\r\n", "\r", "\n"), '\n', htmlspecialchars($data, ENT_QUOTES)); } return $data; }
[ "protected", "function", "loadItem", "(", "$", "em", ",", "$", "data", ",", "$", "attributes", ",", "$", "association", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "if", "(", "get_class", "(", "$", "data", ")", "===", "'DateTime'", ")", "{", "return", "array", "(", "'type'", "=>", "'DateTime'", ",", "'name'", "=>", "$", "data", "->", "format", "(", "'r'", ")", ")", ";", "}", "if", "(", "array_key_exists", "(", "'targetEntity'", ",", "$", "attributes", ")", ")", "{", "$", "targetClass", "=", "$", "em", "->", "getClassMetadata", "(", "$", "attributes", "[", "'targetEntity'", "]", ")", ";", "// var_dump($association);die();", "$", "className", "=", "get_class", "(", "$", "data", ")", ";", "// die($className);", "$", "entityProvider", "=", "new", "EntityProvider", "(", "$", "className", ")", ";", "// $meta = $em->getClassMetadata($className);", "$", "identifier", "=", "$", "targetClass", "->", "getSingleIdentifierFieldName", "(", ")", ";", "$", "identifierMethodName", "=", "'get'", ".", "ucfirst", "(", "$", "identifier", ")", ";", "return", "array", "(", "'type'", "=>", "'reference'", ",", "'name'", "=>", "$", "entityProvider", "->", "getName", "(", ")", ".", "'_'", ".", "$", "data", "->", "$", "identifierMethodName", "(", ")", ",", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Unknown data class: '", ".", "get_class", "(", "$", "data", ")", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "str_replace", "(", "array", "(", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", ")", ",", "'\\n'", ",", "htmlspecialchars", "(", "$", "data", ",", "ENT_QUOTES", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Render one Entity item. @param $em @param $data @param $attributes @param $association @return array|mixed @throws \Exception
[ "Render", "one", "Entity", "item", "." ]
7207417ae847fb1aaa6bd2014217976c5b121cb3
https://github.com/jupeter/DoctrineDumpFixturesBundle/blob/7207417ae847fb1aaa6bd2014217976c5b121cb3/Command/DoctrineDumpCommand.php#L183-L217
231,240
leomarquine/eloquent-uuid
src/Uuid.php
Uuid.bootUuid
protected static function bootUuid() { static::creating(function ($model) { if (! Generator::isValid($model->{$model->getKeyName()})) { $model->{$model->getKeyName()} = Generator::uuid4()->toString(); } }); }
php
protected static function bootUuid() { static::creating(function ($model) { if (! Generator::isValid($model->{$model->getKeyName()})) { $model->{$model->getKeyName()} = Generator::uuid4()->toString(); } }); }
[ "protected", "static", "function", "bootUuid", "(", ")", "{", "static", "::", "creating", "(", "function", "(", "$", "model", ")", "{", "if", "(", "!", "Generator", "::", "isValid", "(", "$", "model", "->", "{", "$", "model", "->", "getKeyName", "(", ")", "}", ")", ")", "{", "$", "model", "->", "{", "$", "model", "->", "getKeyName", "(", ")", "}", "=", "Generator", "::", "uuid4", "(", ")", "->", "toString", "(", ")", ";", "}", "}", ")", ";", "}" ]
Boot uuid trait. @return void
[ "Boot", "uuid", "trait", "." ]
6f3d8384e332cf0be07b5800ca38a8cf12ae120d
https://github.com/leomarquine/eloquent-uuid/blob/6f3d8384e332cf0be07b5800ca38a8cf12ae120d/src/Uuid.php#L14-L21
231,241
codescheme/postcodes
src/Classes/Postcode.php
Postcode.validate
public function validate($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/validate'; $request = new Request('GET', $url); $response = $this->httpTransport($request); return ($response && (200 === $response->status) && $response->result); }
php
public function validate($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/validate'; $request = new Request('GET', $url); $response = $this->httpTransport($request); return ($response && (200 === $response->status) && $response->result); }
[ "public", "function", "validate", "(", "$", "postcode", ")", "{", "$", "url", "=", "'/postcodes/'", ".", "rawurlencode", "(", "$", "postcode", ")", ".", "'/validate'", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "$", "response", "=", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "return", "(", "$", "response", "&&", "(", "200", "===", "$", "response", "->", "status", ")", "&&", "$", "response", "->", "result", ")", ";", "}" ]
Validates a postcode @param string $postcode to be validated @return boolean
[ "Validates", "a", "postcode" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L54-L61
231,242
codescheme/postcodes
src/Classes/Postcode.php
Postcode.nearest
public function nearest($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/nearest'; $request = new Request('GET', $url); return $this->httpTransport($request); }
php
public function nearest($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/nearest'; $request = new Request('GET', $url); return $this->httpTransport($request); }
[ "public", "function", "nearest", "(", "$", "postcode", ")", "{", "$", "url", "=", "'/postcodes/'", ".", "rawurlencode", "(", "$", "postcode", ")", ".", "'/nearest'", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Find nearest postcodes to given @param string $postcode @return object | null on Exception
[ "Find", "nearest", "postcodes", "to", "given" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L69-L75
231,243
codescheme/postcodes
src/Classes/Postcode.php
Postcode.reverseGeocode
public function reverseGeocode($lon, $lat) { $url = '/postcodes?lon=' . (float) $lon . '&lat=' . (float) $lat; $request = new Request('GET', $url); return $this->httpTransport($request); }
php
public function reverseGeocode($lon, $lat) { $url = '/postcodes?lon=' . (float) $lon . '&lat=' . (float) $lat; $request = new Request('GET', $url); return $this->httpTransport($request); }
[ "public", "function", "reverseGeocode", "(", "$", "lon", ",", "$", "lat", ")", "{", "$", "url", "=", "'/postcodes?lon='", ".", "(", "float", ")", "$", "lon", ".", "'&lat='", ".", "(", "float", ")", "$", "lat", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Get postcode from coordinates @params string $lon, $lat the coordinates @return object | null on Exception
[ "Get", "postcode", "from", "coordinates" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L83-L89
231,244
codescheme/postcodes
src/Classes/Postcode.php
Postcode.autocomplete
public function autocomplete($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/autocomplete'; $request = new Request('GET', $url); return $this->httpTransport($request); }
php
public function autocomplete($postcode) { $url = '/postcodes/' . rawurlencode($postcode) . '/autocomplete'; $request = new Request('GET', $url); return $this->httpTransport($request); }
[ "public", "function", "autocomplete", "(", "$", "postcode", ")", "{", "$", "url", "=", "'/postcodes/'", ".", "rawurlencode", "(", "$", "postcode", ")", ".", "'/autocomplete'", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Autocomplete a postcode, @param string $postcode, partial, especially outcode @return object | null on Exception
[ "Autocomplete", "a", "postcode" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L97-L103
231,245
codescheme/postcodes
src/Classes/Postcode.php
Postcode.postcodeLookup
public function postcodeLookup($postcode) { $url = '/postcodes/' . rawurlencode($postcode); $request = new Request('GET', $url); return $this->httpTransport($request); }
php
public function postcodeLookup($postcode) { $url = '/postcodes/' . rawurlencode($postcode); $request = new Request('GET', $url); return $this->httpTransport($request); }
[ "public", "function", "postcodeLookup", "(", "$", "postcode", ")", "{", "$", "url", "=", "'/postcodes/'", ".", "rawurlencode", "(", "$", "postcode", ")", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Look up a postcode, @param string $postcode, @return object | null on Exception
[ "Look", "up", "a", "postcode" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L111-L117
231,246
codescheme/postcodes
src/Classes/Postcode.php
Postcode.outcodeLookup
public function outcodeLookup($outcode) { $url = '/outcodes/' . rawurlencode($outcode); $request = new Request('GET', $url); return $this->httpTransport($request); }
php
public function outcodeLookup($outcode) { $url = '/outcodes/' . rawurlencode($outcode); $request = new Request('GET', $url); return $this->httpTransport($request); }
[ "public", "function", "outcodeLookup", "(", "$", "outcode", ")", "{", "$", "url", "=", "'/outcodes/'", ".", "rawurlencode", "(", "$", "outcode", ")", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "url", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Look up a outcode, @param string $outcode, @return object | null on Exception
[ "Look", "up", "a", "outcode" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L125-L131
231,247
codescheme/postcodes
src/Classes/Postcode.php
Postcode.postcodeLookupBulk
public function postcodeLookupBulk($postcodes) { $headers = ['Content-Type' => 'application/json']; $body = ['postcodes' => $postcodes]; $request = new Request('POST', '/postcodes', $headers, json_encode($body)); return $this->httpTransport($request); }
php
public function postcodeLookupBulk($postcodes) { $headers = ['Content-Type' => 'application/json']; $body = ['postcodes' => $postcodes]; $request = new Request('POST', '/postcodes', $headers, json_encode($body)); return $this->httpTransport($request); }
[ "public", "function", "postcodeLookupBulk", "(", "$", "postcodes", ")", "{", "$", "headers", "=", "[", "'Content-Type'", "=>", "'application/json'", "]", ";", "$", "body", "=", "[", "'postcodes'", "=>", "$", "postcodes", "]", ";", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "'/postcodes'", ",", "$", "headers", ",", "json_encode", "(", "$", "body", ")", ")", ";", "return", "$", "this", "->", "httpTransport", "(", "$", "request", ")", ";", "}" ]
Bulk information lookup for multiple postcodes @param array $postcodes @return object | null on RequestException
[ "Bulk", "information", "lookup", "for", "multiple", "postcodes" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L139-L147
231,248
codescheme/postcodes
src/Classes/Postcode.php
Postcode.httpTransport
protected function httpTransport($request) { try { $response = $this->client->send($request); $results = json_decode($response->getBody()); return $results; } catch (RequestException $e) { Log::error(Psr7\str($e->getRequest())); if ($e->hasResponse()) { Log::error(Psr7\str($e->getResponse())); } } }
php
protected function httpTransport($request) { try { $response = $this->client->send($request); $results = json_decode($response->getBody()); return $results; } catch (RequestException $e) { Log::error(Psr7\str($e->getRequest())); if ($e->hasResponse()) { Log::error(Psr7\str($e->getResponse())); } } }
[ "protected", "function", "httpTransport", "(", "$", "request", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "$", "results", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "return", "$", "results", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "Log", "::", "error", "(", "Psr7", "\\", "str", "(", "$", "e", "->", "getRequest", "(", ")", ")", ")", ";", "if", "(", "$", "e", "->", "hasResponse", "(", ")", ")", "{", "Log", "::", "error", "(", "Psr7", "\\", "str", "(", "$", "e", "->", "getResponse", "(", ")", ")", ")", ";", "}", "}", "}" ]
Does the http @param GuzzleHttp\Psr7\Request $request @throws RequestException @return object | null on RequestException
[ "Does", "the", "http" ]
51d948f3350507dbafcc693d10fc426b02143ec3
https://github.com/codescheme/postcodes/blob/51d948f3350507dbafcc693d10fc426b02143ec3/src/Classes/Postcode.php#L172-L185
231,249
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Controller/OwsProxyController.php
OwsProxyController.entryPointAction
public function entryPointAction() { $this->container->get('session')->save(); $this->logger = $this->container->get('logger'); /** @var Request $request */ $request = $this->get('request'); /** @var Signer $signer */ $signer = $this->get('signer'); $proxy_query = ProxyQuery::createFromRequest($request); try { $signer->checkSignedUrl($proxy_query->getGetUrl()); } catch (HttpException $e) { // let http exceptions run through unmodified throw $e; } catch (BadSignatureException $e) { throw new HTTPStatus403Exception('Invalid URL signature: ' . $e->getMessage()); } $service = strtoupper($proxy_query->getServiceType()); $errorMessagePrefix = "OwsProxyController->entryPointAction {$service}"; $this->logger->debug("OwsProxyController->entryPointAction"); /** @var EventDispatcherInterface $dispatcher */ $dispatcher = $this->container->get('event_dispatcher'); $proxy_config = $this->container->getParameter("owsproxy.proxy"); switch ($service) { case 'WMS': $proxy = new WmsProxy($dispatcher, $proxy_config, $proxy_query, $this->logger); break; case 'WFS': $proxy = new WfsProxy($dispatcher, $proxy_config, $proxy_query, 'OWSProxy3', $this->logger); break; default: //@TODO ? return $this->exceptionHtml(new \Exception('Unknown Service Type', 404)); } try { $browserResponse = $proxy->handle(); $cookies_req = $request->cookies; $response = new Response(); Utils::setHeadersFromBrowserResponse($response, $browserResponse); foreach ($cookies_req as $key => $value) { $response->headers->removeCookie($key); $response->headers->setCookie(new Cookie($key, $value)); } $content = $browserResponse->getContent(); $response->setContent($content); return $response; } catch (\Exception $e) { $this->logger->error("{$errorMessagePrefix}: {$e->getCode()} " . $e->getMessage()); return $this->exceptionHtml($e); } }
php
public function entryPointAction() { $this->container->get('session')->save(); $this->logger = $this->container->get('logger'); /** @var Request $request */ $request = $this->get('request'); /** @var Signer $signer */ $signer = $this->get('signer'); $proxy_query = ProxyQuery::createFromRequest($request); try { $signer->checkSignedUrl($proxy_query->getGetUrl()); } catch (HttpException $e) { // let http exceptions run through unmodified throw $e; } catch (BadSignatureException $e) { throw new HTTPStatus403Exception('Invalid URL signature: ' . $e->getMessage()); } $service = strtoupper($proxy_query->getServiceType()); $errorMessagePrefix = "OwsProxyController->entryPointAction {$service}"; $this->logger->debug("OwsProxyController->entryPointAction"); /** @var EventDispatcherInterface $dispatcher */ $dispatcher = $this->container->get('event_dispatcher'); $proxy_config = $this->container->getParameter("owsproxy.proxy"); switch ($service) { case 'WMS': $proxy = new WmsProxy($dispatcher, $proxy_config, $proxy_query, $this->logger); break; case 'WFS': $proxy = new WfsProxy($dispatcher, $proxy_config, $proxy_query, 'OWSProxy3', $this->logger); break; default: //@TODO ? return $this->exceptionHtml(new \Exception('Unknown Service Type', 404)); } try { $browserResponse = $proxy->handle(); $cookies_req = $request->cookies; $response = new Response(); Utils::setHeadersFromBrowserResponse($response, $browserResponse); foreach ($cookies_req as $key => $value) { $response->headers->removeCookie($key); $response->headers->setCookie(new Cookie($key, $value)); } $content = $browserResponse->getContent(); $response->setContent($content); return $response; } catch (\Exception $e) { $this->logger->error("{$errorMessagePrefix}: {$e->getCode()} " . $e->getMessage()); return $this->exceptionHtml($e); } }
[ "public", "function", "entryPointAction", "(", ")", "{", "$", "this", "->", "container", "->", "get", "(", "'session'", ")", "->", "save", "(", ")", ";", "$", "this", "->", "logger", "=", "$", "this", "->", "container", "->", "get", "(", "'logger'", ")", ";", "/** @var Request $request */", "$", "request", "=", "$", "this", "->", "get", "(", "'request'", ")", ";", "/** @var Signer $signer */", "$", "signer", "=", "$", "this", "->", "get", "(", "'signer'", ")", ";", "$", "proxy_query", "=", "ProxyQuery", "::", "createFromRequest", "(", "$", "request", ")", ";", "try", "{", "$", "signer", "->", "checkSignedUrl", "(", "$", "proxy_query", "->", "getGetUrl", "(", ")", ")", ";", "}", "catch", "(", "HttpException", "$", "e", ")", "{", "// let http exceptions run through unmodified", "throw", "$", "e", ";", "}", "catch", "(", "BadSignatureException", "$", "e", ")", "{", "throw", "new", "HTTPStatus403Exception", "(", "'Invalid URL signature: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "service", "=", "strtoupper", "(", "$", "proxy_query", "->", "getServiceType", "(", ")", ")", ";", "$", "errorMessagePrefix", "=", "\"OwsProxyController->entryPointAction {$service}\"", ";", "$", "this", "->", "logger", "->", "debug", "(", "\"OwsProxyController->entryPointAction\"", ")", ";", "/** @var EventDispatcherInterface $dispatcher */", "$", "dispatcher", "=", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", ";", "$", "proxy_config", "=", "$", "this", "->", "container", "->", "getParameter", "(", "\"owsproxy.proxy\"", ")", ";", "switch", "(", "$", "service", ")", "{", "case", "'WMS'", ":", "$", "proxy", "=", "new", "WmsProxy", "(", "$", "dispatcher", ",", "$", "proxy_config", ",", "$", "proxy_query", ",", "$", "this", "->", "logger", ")", ";", "break", ";", "case", "'WFS'", ":", "$", "proxy", "=", "new", "WfsProxy", "(", "$", "dispatcher", ",", "$", "proxy_config", ",", "$", "proxy_query", ",", "'OWSProxy3'", ",", "$", "this", "->", "logger", ")", ";", "break", ";", "default", ":", "//@TODO ?", "return", "$", "this", "->", "exceptionHtml", "(", "new", "\\", "Exception", "(", "'Unknown Service Type'", ",", "404", ")", ")", ";", "}", "try", "{", "$", "browserResponse", "=", "$", "proxy", "->", "handle", "(", ")", ";", "$", "cookies_req", "=", "$", "request", "->", "cookies", ";", "$", "response", "=", "new", "Response", "(", ")", ";", "Utils", "::", "setHeadersFromBrowserResponse", "(", "$", "response", ",", "$", "browserResponse", ")", ";", "foreach", "(", "$", "cookies_req", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "response", "->", "headers", "->", "removeCookie", "(", "$", "key", ")", ";", "$", "response", "->", "headers", "->", "setCookie", "(", "new", "Cookie", "(", "$", "key", ",", "$", "value", ")", ")", ";", "}", "$", "content", "=", "$", "browserResponse", "->", "getContent", "(", ")", ";", "$", "response", "->", "setContent", "(", "$", "content", ")", ";", "return", "$", "response", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "\"{$errorMessagePrefix}: {$e->getCode()} \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "return", "$", "this", "->", "exceptionHtml", "(", "$", "e", ")", ";", "}", "}" ]
Handles the client's request @Route("/") @return \Symfony\Component\HttpFoundation\Response the response
[ "Handles", "the", "client", "s", "request" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Controller/OwsProxyController.php#L90-L144
231,250
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Controller/OwsProxyController.php
OwsProxyController.exceptionHtml
private function exceptionHtml(\Exception $e) { $response = new Response(); $html = $this->render("OwsProxy3CoreBundle::exception.html.twig", array("exception" => $e)); $response->headers->set('Content-Type', 'text/html'); $response->setStatusCode($e->getCode() ?: 500); $response->setContent($html->getContent()); return $response; }
php
private function exceptionHtml(\Exception $e) { $response = new Response(); $html = $this->render("OwsProxy3CoreBundle::exception.html.twig", array("exception" => $e)); $response->headers->set('Content-Type', 'text/html'); $response->setStatusCode($e->getCode() ?: 500); $response->setContent($html->getContent()); return $response; }
[ "private", "function", "exceptionHtml", "(", "\\", "Exception", "$", "e", ")", "{", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "html", "=", "$", "this", "->", "render", "(", "\"OwsProxy3CoreBundle::exception.html.twig\"", ",", "array", "(", "\"exception\"", "=>", "$", "e", ")", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'text/html'", ")", ";", "$", "response", "->", "setStatusCode", "(", "$", "e", "->", "getCode", "(", ")", "?", ":", "500", ")", ";", "$", "response", "->", "setContent", "(", "$", "html", "->", "getContent", "(", ")", ")", ";", "return", "$", "response", ";", "}" ]
Creates a response with an exception as HTML @param \Exception $e the exception @return \Symfony\Component\HttpFoundation\Response the response
[ "Creates", "a", "response", "with", "an", "exception", "as", "HTML" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Controller/OwsProxyController.php#L152-L160
231,251
PaymentSuite/paymentsuite
src/PaymentSuite/StripeBundle/Services/StripeTemplateRender.php
StripeTemplateRender.renderStripeForm
public function renderStripeForm(Twig_Environment $environment, $viewTemplate = null) { $formType = $this->formFactory->create('stripe_view'); $environment->display($viewTemplate ?: $this->viewTemplate, [ 'stripe_form' => $formType->createView(), 'stripe_execute_route' => 'paymentsuite_stripe_execute', ]); }
php
public function renderStripeForm(Twig_Environment $environment, $viewTemplate = null) { $formType = $this->formFactory->create('stripe_view'); $environment->display($viewTemplate ?: $this->viewTemplate, [ 'stripe_form' => $formType->createView(), 'stripe_execute_route' => 'paymentsuite_stripe_execute', ]); }
[ "public", "function", "renderStripeForm", "(", "Twig_Environment", "$", "environment", ",", "$", "viewTemplate", "=", "null", ")", "{", "$", "formType", "=", "$", "this", "->", "formFactory", "->", "create", "(", "'stripe_view'", ")", ";", "$", "environment", "->", "display", "(", "$", "viewTemplate", "?", ":", "$", "this", "->", "viewTemplate", ",", "[", "'stripe_form'", "=>", "$", "formType", "->", "createView", "(", ")", ",", "'stripe_execute_route'", "=>", "'paymentsuite_stripe_execute'", ",", "]", ")", ";", "}" ]
Render stripe form. @param Twig_Environment $environment Environment @param bool $viewTemplate View template
[ "Render", "stripe", "form", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/StripeBundle/Services/StripeTemplateRender.php#L92-L100
231,252
PaymentSuite/paymentsuite
src/PaymentSuite/StripeBundle/Services/StripeTemplateRender.php
StripeTemplateRender.renderStripeScripts
public function renderStripeScripts(Twig_Environment $environment) { $environment->display($this->scriptsTemplate, [ 'public_key' => $this->publicKey, 'currency' => $this->paymentBridgeInterface->getCurrency(), ]); }
php
public function renderStripeScripts(Twig_Environment $environment) { $environment->display($this->scriptsTemplate, [ 'public_key' => $this->publicKey, 'currency' => $this->paymentBridgeInterface->getCurrency(), ]); }
[ "public", "function", "renderStripeScripts", "(", "Twig_Environment", "$", "environment", ")", "{", "$", "environment", "->", "display", "(", "$", "this", "->", "scriptsTemplate", ",", "[", "'public_key'", "=>", "$", "this", "->", "publicKey", ",", "'currency'", "=>", "$", "this", "->", "paymentBridgeInterface", "->", "getCurrency", "(", ")", ",", "]", ")", ";", "}" ]
Render stripe scripts. @param Twig_Environment $environment Environment
[ "Render", "stripe", "scripts", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/StripeBundle/Services/StripeTemplateRender.php#L107-L113
231,253
swoft-cloud/swoft-http-client
src/Client.php
Client.request
public function request(string $method, $uri, array $options = []): HttpResultInterface { $options = $this->prepareDefaults($options); $headers = $options['headers'] ?? []; $body = $options['body'] ?? null; $version = $options['version'] ?? '1.1'; // Merge the URI into the base URI. $uri = $this->buildUri($uri, $options); $profileKey = 'http.' . (string)$uri; App::profileStart($profileKey); $request = new Request($method, $uri, $headers, $body, $version); $adapter = $this->getAdapter(); $this->setDefaultUserAgent(); $result = $adapter->request($request, $options); App::profileEnd($profileKey); return $result; }
php
public function request(string $method, $uri, array $options = []): HttpResultInterface { $options = $this->prepareDefaults($options); $headers = $options['headers'] ?? []; $body = $options['body'] ?? null; $version = $options['version'] ?? '1.1'; // Merge the URI into the base URI. $uri = $this->buildUri($uri, $options); $profileKey = 'http.' . (string)$uri; App::profileStart($profileKey); $request = new Request($method, $uri, $headers, $body, $version); $adapter = $this->getAdapter(); $this->setDefaultUserAgent(); $result = $adapter->request($request, $options); App::profileEnd($profileKey); return $result; }
[ "public", "function", "request", "(", "string", "$", "method", ",", "$", "uri", ",", "array", "$", "options", "=", "[", "]", ")", ":", "HttpResultInterface", "{", "$", "options", "=", "$", "this", "->", "prepareDefaults", "(", "$", "options", ")", ";", "$", "headers", "=", "$", "options", "[", "'headers'", "]", "??", "[", "]", ";", "$", "body", "=", "$", "options", "[", "'body'", "]", "??", "null", ";", "$", "version", "=", "$", "options", "[", "'version'", "]", "??", "'1.1'", ";", "// Merge the URI into the base URI.", "$", "uri", "=", "$", "this", "->", "buildUri", "(", "$", "uri", ",", "$", "options", ")", ";", "$", "profileKey", "=", "'http.'", ".", "(", "string", ")", "$", "uri", ";", "App", "::", "profileStart", "(", "$", "profileKey", ")", ";", "$", "request", "=", "new", "Request", "(", "$", "method", ",", "$", "uri", ",", "$", "headers", ",", "$", "body", ",", "$", "version", ")", ";", "$", "adapter", "=", "$", "this", "->", "getAdapter", "(", ")", ";", "$", "this", "->", "setDefaultUserAgent", "(", ")", ";", "$", "result", "=", "$", "adapter", "->", "request", "(", "$", "request", ",", "$", "options", ")", ";", "App", "::", "profileEnd", "(", "$", "profileKey", ")", ";", "return", "$", "result", ";", "}" ]
Send a Http request @param string $method @param string|UriInterface $uri @param array $options @return HttpResultInterface @throws \InvalidArgumentException
[ "Send", "a", "Http", "request" ]
980ac3701cc100ec605ccb5f7e974861f900d0e9
https://github.com/swoft-cloud/swoft-http-client/blob/980ac3701cc100ec605ccb5f7e974861f900d0e9/src/Client.php#L84-L100
231,254
swoft-cloud/swoft-http-client
src/Client.php
Client.prepareDefaults
protected function prepareDefaults($options): array { $defaults = $this->configs; if (! empty($defaults['headers'])) { // Default headers are only added if they are not present. $defaults['_headers'] = $defaults['headers']; unset($defaults['headers']); } // Special handling for headers is required as they are added as if (array_key_exists('headers', $options)) { // Allows default headers to be unset. if ($options['headers'] === null) { $defaults['_headers'] = null; unset($options['headers']); } elseif (! \is_array($options['headers'])) { throw new \InvalidArgumentException('headers must be an array'); } } // Shallow merge defaults underneath options. $result = array_replace($defaults, $options); // Remove null values. foreach ($result as $k => $v) { if ($v === null) { unset($result[$k]); } } return $result; }
php
protected function prepareDefaults($options): array { $defaults = $this->configs; if (! empty($defaults['headers'])) { // Default headers are only added if they are not present. $defaults['_headers'] = $defaults['headers']; unset($defaults['headers']); } // Special handling for headers is required as they are added as if (array_key_exists('headers', $options)) { // Allows default headers to be unset. if ($options['headers'] === null) { $defaults['_headers'] = null; unset($options['headers']); } elseif (! \is_array($options['headers'])) { throw new \InvalidArgumentException('headers must be an array'); } } // Shallow merge defaults underneath options. $result = array_replace($defaults, $options); // Remove null values. foreach ($result as $k => $v) { if ($v === null) { unset($result[$k]); } } return $result; }
[ "protected", "function", "prepareDefaults", "(", "$", "options", ")", ":", "array", "{", "$", "defaults", "=", "$", "this", "->", "configs", ";", "if", "(", "!", "empty", "(", "$", "defaults", "[", "'headers'", "]", ")", ")", "{", "// Default headers are only added if they are not present.", "$", "defaults", "[", "'_headers'", "]", "=", "$", "defaults", "[", "'headers'", "]", ";", "unset", "(", "$", "defaults", "[", "'headers'", "]", ")", ";", "}", "// Special handling for headers is required as they are added as", "if", "(", "array_key_exists", "(", "'headers'", ",", "$", "options", ")", ")", "{", "// Allows default headers to be unset.", "if", "(", "$", "options", "[", "'headers'", "]", "===", "null", ")", "{", "$", "defaults", "[", "'_headers'", "]", "=", "null", ";", "unset", "(", "$", "options", "[", "'headers'", "]", ")", ";", "}", "elseif", "(", "!", "\\", "is_array", "(", "$", "options", "[", "'headers'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'headers must be an array'", ")", ";", "}", "}", "// Shallow merge defaults underneath options.", "$", "result", "=", "array_replace", "(", "$", "defaults", ",", "$", "options", ")", ";", "// Remove null values.", "foreach", "(", "$", "result", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "unset", "(", "$", "result", "[", "$", "k", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Merges default options into the array. @param array $options Options to modify by reference @return array @throws \InvalidArgumentException
[ "Merges", "default", "options", "into", "the", "array", "." ]
980ac3701cc100ec605ccb5f7e974861f900d0e9
https://github.com/swoft-cloud/swoft-http-client/blob/980ac3701cc100ec605ccb5f7e974861f900d0e9/src/Client.php#L298-L330
231,255
swoft-cloud/swoft-http-client
src/Client.php
Client.getDefaultUserAgent
public function getDefaultUserAgent(): string { if (! $this->defaultUserAgent) { $currentMethodName = __FUNCTION__; $isAdapterUserAgent = method_exists($this->getAdapter(), $currentMethodName); if ($isAdapterUserAgent) { $this->defaultUserAgent = $this->getAdapter()->$currentMethodName(); } else { $defaultAgent = 'Swoft/' . App::version(); if (! Coroutine::isSupportCoroutine() && \extension_loaded('curl') && \function_exists('curl_version')) { $defaultAgent .= ' curl/' . \curl_version()['version']; } $defaultAgent .= ' PHP/' . PHP_VERSION; $this->defaultUserAgent = $defaultAgent; } } return $this->defaultUserAgent; }
php
public function getDefaultUserAgent(): string { if (! $this->defaultUserAgent) { $currentMethodName = __FUNCTION__; $isAdapterUserAgent = method_exists($this->getAdapter(), $currentMethodName); if ($isAdapterUserAgent) { $this->defaultUserAgent = $this->getAdapter()->$currentMethodName(); } else { $defaultAgent = 'Swoft/' . App::version(); if (! Coroutine::isSupportCoroutine() && \extension_loaded('curl') && \function_exists('curl_version')) { $defaultAgent .= ' curl/' . \curl_version()['version']; } $defaultAgent .= ' PHP/' . PHP_VERSION; $this->defaultUserAgent = $defaultAgent; } } return $this->defaultUserAgent; }
[ "public", "function", "getDefaultUserAgent", "(", ")", ":", "string", "{", "if", "(", "!", "$", "this", "->", "defaultUserAgent", ")", "{", "$", "currentMethodName", "=", "__FUNCTION__", ";", "$", "isAdapterUserAgent", "=", "method_exists", "(", "$", "this", "->", "getAdapter", "(", ")", ",", "$", "currentMethodName", ")", ";", "if", "(", "$", "isAdapterUserAgent", ")", "{", "$", "this", "->", "defaultUserAgent", "=", "$", "this", "->", "getAdapter", "(", ")", "->", "$", "currentMethodName", "(", ")", ";", "}", "else", "{", "$", "defaultAgent", "=", "'Swoft/'", ".", "App", "::", "version", "(", ")", ";", "if", "(", "!", "Coroutine", "::", "isSupportCoroutine", "(", ")", "&&", "\\", "extension_loaded", "(", "'curl'", ")", "&&", "\\", "function_exists", "(", "'curl_version'", ")", ")", "{", "$", "defaultAgent", ".=", "' curl/'", ".", "\\", "curl_version", "(", ")", "[", "'version'", "]", ";", "}", "$", "defaultAgent", ".=", "' PHP/'", ".", "PHP_VERSION", ";", "$", "this", "->", "defaultUserAgent", "=", "$", "defaultAgent", ";", "}", "}", "return", "$", "this", "->", "defaultUserAgent", ";", "}" ]
Get the default User-Agent string @return string @throws \InvalidArgumentException
[ "Get", "the", "default", "User", "-", "Agent", "string" ]
980ac3701cc100ec605ccb5f7e974861f900d0e9
https://github.com/swoft-cloud/swoft-http-client/blob/980ac3701cc100ec605ccb5f7e974861f900d0e9/src/Client.php#L338-L356
231,256
swoft-cloud/swoft-http-client
src/Client.php
Client.setDefaultUserAgent
private function setDefaultUserAgent() { // Add the default user-agent header. if (! isset($this->configs['headers'])) { $this->configs['headers'] = ['User-Agent' => $this->getDefaultUserAgent()]; } else { // Add the User-Agent header if one was not already set. foreach (array_keys($this->configs['headers']) as $name) { if (strtolower($name) === 'user-agent') { return; } } $this->configs['headers']['User-Agent'] = $this->getDefaultUserAgent(); } }
php
private function setDefaultUserAgent() { // Add the default user-agent header. if (! isset($this->configs['headers'])) { $this->configs['headers'] = ['User-Agent' => $this->getDefaultUserAgent()]; } else { // Add the User-Agent header if one was not already set. foreach (array_keys($this->configs['headers']) as $name) { if (strtolower($name) === 'user-agent') { return; } } $this->configs['headers']['User-Agent'] = $this->getDefaultUserAgent(); } }
[ "private", "function", "setDefaultUserAgent", "(", ")", "{", "// Add the default user-agent header.", "if", "(", "!", "isset", "(", "$", "this", "->", "configs", "[", "'headers'", "]", ")", ")", "{", "$", "this", "->", "configs", "[", "'headers'", "]", "=", "[", "'User-Agent'", "=>", "$", "this", "->", "getDefaultUserAgent", "(", ")", "]", ";", "}", "else", "{", "// Add the User-Agent header if one was not already set.", "foreach", "(", "array_keys", "(", "$", "this", "->", "configs", "[", "'headers'", "]", ")", "as", "$", "name", ")", "{", "if", "(", "strtolower", "(", "$", "name", ")", "===", "'user-agent'", ")", "{", "return", ";", "}", "}", "$", "this", "->", "configs", "[", "'headers'", "]", "[", "'User-Agent'", "]", "=", "$", "this", "->", "getDefaultUserAgent", "(", ")", ";", "}", "}" ]
Set default User-Agent to Client. @important Notice that this method should always use after setAdapter() method, or else getDefaultUserAgent() and getAdapter() methods will automated get an Adapter, probably is not the adapter you wanted. @return void @throws \InvalidArgumentException
[ "Set", "default", "User", "-", "Agent", "to", "Client", "." ]
980ac3701cc100ec605ccb5f7e974861f900d0e9
https://github.com/swoft-cloud/swoft-http-client/blob/980ac3701cc100ec605ccb5f7e974861f900d0e9/src/Client.php#L368-L382
231,257
PaymentSuite/paymentsuite
src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php
PaylandsExtension.registerEndpointServices
protected function registerEndpointServices(ContainerBuilder $containerBuilder, array $config) { $resolverDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.currency_service_resolver'); foreach ($config as $option) { $resolverDefinition->addMethodCall('addService', [ $option['currency'], $option['service'], ]); } }
php
protected function registerEndpointServices(ContainerBuilder $containerBuilder, array $config) { $resolverDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.currency_service_resolver'); foreach ($config as $option) { $resolverDefinition->addMethodCall('addService', [ $option['currency'], $option['service'], ]); } }
[ "protected", "function", "registerEndpointServices", "(", "ContainerBuilder", "$", "containerBuilder", ",", "array", "$", "config", ")", "{", "$", "resolverDefinition", "=", "$", "containerBuilder", "->", "getDefinition", "(", "'paymentsuite.paylands.currency_service_resolver'", ")", ";", "foreach", "(", "$", "config", "as", "$", "option", ")", "{", "$", "resolverDefinition", "->", "addMethodCall", "(", "'addService'", ",", "[", "$", "option", "[", "'currency'", "]", ",", "$", "option", "[", "'service'", "]", ",", "]", ")", ";", "}", "}" ]
Registers the list of available currency dependant Paylands' services to use. @param ContainerBuilder $containerBuilder @param array $config
[ "Registers", "the", "list", "of", "available", "currency", "dependant", "Paylands", "services", "to", "use", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php#L70-L80
231,258
PaymentSuite/paymentsuite
src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php
PaylandsExtension.resolveApiClientInterfaces
protected function resolveApiClientInterfaces(ContainerBuilder $containerBuilder, array $config) { $requestFactoryDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.api.request_factory'); $requestFactoryDefinition->addMethodCall('setRequestFactory', [ $config['request_factory'] ? $containerBuilder->getDefinition($config['request_factory']) : null, ]); $clientFactoryDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.api.client_factory'); $clientFactoryDefinition->addMethodCall('setHttpClient', [ $config['http_client'] ? $containerBuilder->getDefinition($config['http_client']) : null, ]); $clientFactoryDefinition->addMethodCall('setUriFactory', [ $config['uri_factory'] ? $containerBuilder->getDefinition($config['uri_factory']) : null, ]); }
php
protected function resolveApiClientInterfaces(ContainerBuilder $containerBuilder, array $config) { $requestFactoryDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.api.request_factory'); $requestFactoryDefinition->addMethodCall('setRequestFactory', [ $config['request_factory'] ? $containerBuilder->getDefinition($config['request_factory']) : null, ]); $clientFactoryDefinition = $containerBuilder->getDefinition('paymentsuite.paylands.api.client_factory'); $clientFactoryDefinition->addMethodCall('setHttpClient', [ $config['http_client'] ? $containerBuilder->getDefinition($config['http_client']) : null, ]); $clientFactoryDefinition->addMethodCall('setUriFactory', [ $config['uri_factory'] ? $containerBuilder->getDefinition($config['uri_factory']) : null, ]); }
[ "protected", "function", "resolveApiClientInterfaces", "(", "ContainerBuilder", "$", "containerBuilder", ",", "array", "$", "config", ")", "{", "$", "requestFactoryDefinition", "=", "$", "containerBuilder", "->", "getDefinition", "(", "'paymentsuite.paylands.api.request_factory'", ")", ";", "$", "requestFactoryDefinition", "->", "addMethodCall", "(", "'setRequestFactory'", ",", "[", "$", "config", "[", "'request_factory'", "]", "?", "$", "containerBuilder", "->", "getDefinition", "(", "$", "config", "[", "'request_factory'", "]", ")", ":", "null", ",", "]", ")", ";", "$", "clientFactoryDefinition", "=", "$", "containerBuilder", "->", "getDefinition", "(", "'paymentsuite.paylands.api.client_factory'", ")", ";", "$", "clientFactoryDefinition", "->", "addMethodCall", "(", "'setHttpClient'", ",", "[", "$", "config", "[", "'http_client'", "]", "?", "$", "containerBuilder", "->", "getDefinition", "(", "$", "config", "[", "'http_client'", "]", ")", ":", "null", ",", "]", ")", ";", "$", "clientFactoryDefinition", "->", "addMethodCall", "(", "'setUriFactory'", ",", "[", "$", "config", "[", "'uri_factory'", "]", "?", "$", "containerBuilder", "->", "getDefinition", "(", "$", "config", "[", "'uri_factory'", "]", ")", ":", "null", ",", "]", ")", ";", "}" ]
Resolves configuration of needed psr-7 interfaces. When null is provided, auto-discovery is used. When a service key is provided, that service is injected into related services instead. @param ContainerBuilder $containerBuilder @param array $config
[ "Resolves", "configuration", "of", "needed", "psr", "-", "7", "interfaces", ".", "When", "null", "is", "provided", "auto", "-", "discovery", "is", "used", ".", "When", "a", "service", "key", "is", "provided", "that", "service", "is", "injected", "into", "related", "services", "instead", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php#L89-L106
231,259
PaymentSuite/paymentsuite
src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php
PaylandsExtension.registerApiClient
protected function registerApiClient(ContainerBuilder $containerBuilder, $config) { $containerBuilder->setAlias('paymentsuite.paylands.api.client', $config['api_client']); if (Configuration::API_CLIENT_DEFAULT == $config['api_client']) { $this->resolveApiClientInterfaces($containerBuilder, $config['interfaces']); $this->registerEndpointServices($containerBuilder, $config['services']); } }
php
protected function registerApiClient(ContainerBuilder $containerBuilder, $config) { $containerBuilder->setAlias('paymentsuite.paylands.api.client', $config['api_client']); if (Configuration::API_CLIENT_DEFAULT == $config['api_client']) { $this->resolveApiClientInterfaces($containerBuilder, $config['interfaces']); $this->registerEndpointServices($containerBuilder, $config['services']); } }
[ "protected", "function", "registerApiClient", "(", "ContainerBuilder", "$", "containerBuilder", ",", "$", "config", ")", "{", "$", "containerBuilder", "->", "setAlias", "(", "'paymentsuite.paylands.api.client'", ",", "$", "config", "[", "'api_client'", "]", ")", ";", "if", "(", "Configuration", "::", "API_CLIENT_DEFAULT", "==", "$", "config", "[", "'api_client'", "]", ")", "{", "$", "this", "->", "resolveApiClientInterfaces", "(", "$", "containerBuilder", ",", "$", "config", "[", "'interfaces'", "]", ")", ";", "$", "this", "->", "registerEndpointServices", "(", "$", "containerBuilder", ",", "$", "config", "[", "'services'", "]", ")", ";", "}", "}" ]
Registers final API client to use, default or custom. @param ContainerBuilder $containerBuilder @param array $config
[ "Registers", "final", "API", "client", "to", "use", "default", "or", "custom", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaylandsBundle/DependencyInjection/PaylandsExtension.php#L114-L123
231,260
PaymentSuite/paymentsuite
src/PaymentSuite/StripeBundle/Services/StripeManager.php
StripeManager.processPayment
public function processPayment(StripeMethod $paymentMethod, $amount) { /** * check and set payment data. */ $chargeParams = $this->prepareData( $paymentMethod, $amount ); /** * make payment. */ $transaction = $this ->transactionFactory ->create($chargeParams); /** * Payment paid done. * * Paid process has ended ( No matters result ) */ $this ->paymentEventDispatcher ->notifyPaymentOrderDone( $this->paymentBridge, $paymentMethod ); /** * when a transaction is successful, it is marked as 'closed'. */ if ($transaction['paid'] != 1) { /** * Payment paid failed. * * Paid process has ended failed */ $this ->paymentEventDispatcher ->notifyPaymentOrderFail( $this->paymentBridge, $paymentMethod ); throw new PaymentException(); } $paymentMethod ->setTransactionId($transaction['id']) ->setTransactionStatus('paid') ->setTransactionResponse($transaction); /** * Payment paid successfully. * * Paid process has ended successfully */ $this ->paymentEventDispatcher ->notifyPaymentOrderSuccess( $this->paymentBridge, $paymentMethod ); return $this; }
php
public function processPayment(StripeMethod $paymentMethod, $amount) { /** * check and set payment data. */ $chargeParams = $this->prepareData( $paymentMethod, $amount ); /** * make payment. */ $transaction = $this ->transactionFactory ->create($chargeParams); /** * Payment paid done. * * Paid process has ended ( No matters result ) */ $this ->paymentEventDispatcher ->notifyPaymentOrderDone( $this->paymentBridge, $paymentMethod ); /** * when a transaction is successful, it is marked as 'closed'. */ if ($transaction['paid'] != 1) { /** * Payment paid failed. * * Paid process has ended failed */ $this ->paymentEventDispatcher ->notifyPaymentOrderFail( $this->paymentBridge, $paymentMethod ); throw new PaymentException(); } $paymentMethod ->setTransactionId($transaction['id']) ->setTransactionStatus('paid') ->setTransactionResponse($transaction); /** * Payment paid successfully. * * Paid process has ended successfully */ $this ->paymentEventDispatcher ->notifyPaymentOrderSuccess( $this->paymentBridge, $paymentMethod ); return $this; }
[ "public", "function", "processPayment", "(", "StripeMethod", "$", "paymentMethod", ",", "$", "amount", ")", "{", "/**\n * check and set payment data.\n */", "$", "chargeParams", "=", "$", "this", "->", "prepareData", "(", "$", "paymentMethod", ",", "$", "amount", ")", ";", "/**\n * make payment.\n */", "$", "transaction", "=", "$", "this", "->", "transactionFactory", "->", "create", "(", "$", "chargeParams", ")", ";", "/**\n * Payment paid done.\n *\n * Paid process has ended ( No matters result )\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderDone", "(", "$", "this", "->", "paymentBridge", ",", "$", "paymentMethod", ")", ";", "/**\n * when a transaction is successful, it is marked as 'closed'.\n */", "if", "(", "$", "transaction", "[", "'paid'", "]", "!=", "1", ")", "{", "/**\n * Payment paid failed.\n *\n * Paid process has ended failed\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderFail", "(", "$", "this", "->", "paymentBridge", ",", "$", "paymentMethod", ")", ";", "throw", "new", "PaymentException", "(", ")", ";", "}", "$", "paymentMethod", "->", "setTransactionId", "(", "$", "transaction", "[", "'id'", "]", ")", "->", "setTransactionStatus", "(", "'paid'", ")", "->", "setTransactionResponse", "(", "$", "transaction", ")", ";", "/**\n * Payment paid successfully.\n *\n * Paid process has ended successfully\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderSuccess", "(", "$", "this", "->", "paymentBridge", ",", "$", "paymentMethod", ")", ";", "return", "$", "this", ";", "}" ]
Tries to process a payment through Stripe. @param StripeMethod $paymentMethod Payment method @param float $amount Amount @throws PaymentAmountsNotMatchException @throws PaymentException @return StripeManager Self object
[ "Tries", "to", "process", "a", "payment", "through", "Stripe", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/StripeBundle/Services/StripeManager.php#L80-L147
231,261
PaymentSuite/paymentsuite
src/PaymentSuite/StripeBundle/Services/StripeManager.php
StripeManager.prepareData
private function prepareData(StripeMethod $paymentMethod, $amount) { /// first check that amounts are the same $cartAmount = intval($this->paymentBridge->getAmount()); /** * If both amounts are different, execute Exception. */ if (abs($amount - $cartAmount) > 0.00001) { throw new PaymentAmountsNotMatchException(); } /** * At this point, order must be created given a cart, and placed in PaymentBridge. * * So, $this->paymentBridge->getOrder() must return an object */ $this ->paymentEventDispatcher ->notifyPaymentOrderLoad( $this->paymentBridge, $paymentMethod ); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Order exists right here. */ $this ->paymentEventDispatcher ->notifyPaymentOrderCreated( $this->paymentBridge, $paymentMethod ); return new StripeTransaction( $paymentMethod->getApiToken(), $cartAmount, $this->paymentBridge->getCurrency() ); }
php
private function prepareData(StripeMethod $paymentMethod, $amount) { /// first check that amounts are the same $cartAmount = intval($this->paymentBridge->getAmount()); /** * If both amounts are different, execute Exception. */ if (abs($amount - $cartAmount) > 0.00001) { throw new PaymentAmountsNotMatchException(); } /** * At this point, order must be created given a cart, and placed in PaymentBridge. * * So, $this->paymentBridge->getOrder() must return an object */ $this ->paymentEventDispatcher ->notifyPaymentOrderLoad( $this->paymentBridge, $paymentMethod ); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Order exists right here. */ $this ->paymentEventDispatcher ->notifyPaymentOrderCreated( $this->paymentBridge, $paymentMethod ); return new StripeTransaction( $paymentMethod->getApiToken(), $cartAmount, $this->paymentBridge->getCurrency() ); }
[ "private", "function", "prepareData", "(", "StripeMethod", "$", "paymentMethod", ",", "$", "amount", ")", "{", "/// first check that amounts are the same", "$", "cartAmount", "=", "intval", "(", "$", "this", "->", "paymentBridge", "->", "getAmount", "(", ")", ")", ";", "/**\n * If both amounts are different, execute Exception.\n */", "if", "(", "abs", "(", "$", "amount", "-", "$", "cartAmount", ")", ">", "0.00001", ")", "{", "throw", "new", "PaymentAmountsNotMatchException", "(", ")", ";", "}", "/**\n * At this point, order must be created given a cart, and placed in PaymentBridge.\n *\n * So, $this->paymentBridge->getOrder() must return an object\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderLoad", "(", "$", "this", "->", "paymentBridge", ",", "$", "paymentMethod", ")", ";", "/**\n * Order Not found Exception must be thrown just here.\n */", "if", "(", "!", "$", "this", "->", "paymentBridge", "->", "getOrder", "(", ")", ")", "{", "throw", "new", "PaymentOrderNotFoundException", "(", ")", ";", "}", "/**\n * Order exists right here.\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderCreated", "(", "$", "this", "->", "paymentBridge", ",", "$", "paymentMethod", ")", ";", "return", "new", "StripeTransaction", "(", "$", "paymentMethod", "->", "getApiToken", "(", ")", ",", "$", "cartAmount", ",", "$", "this", "->", "paymentBridge", "->", "getCurrency", "(", ")", ")", ";", "}" ]
Check and set param for payment. @param StripeMethod $paymentMethod Payment method @param float $amount Amount @return StripeTransaction Charge params @throws PaymentAmountsNotMatchException @throws PaymentOrderNotFoundException
[ "Check", "and", "set", "param", "for", "payment", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/StripeBundle/Services/StripeManager.php#L160-L206
231,262
PaymentSuite/paymentsuite
src/PaymentSuite/RedsysBundle/Services/RedsysFormTypeBuilder.php
RedsysFormTypeBuilder.shopSignature
private function shopSignature( $amount, $order, $merchantCode, $currency, $transactionType, $merchantURL, $secret ) { return strtoupper(sha1(implode('', [ $amount, $order, $merchantCode, $currency, $transactionType, $merchantURL, $secret, ]))); }
php
private function shopSignature( $amount, $order, $merchantCode, $currency, $transactionType, $merchantURL, $secret ) { return strtoupper(sha1(implode('', [ $amount, $order, $merchantCode, $currency, $transactionType, $merchantURL, $secret, ]))); }
[ "private", "function", "shopSignature", "(", "$", "amount", ",", "$", "order", ",", "$", "merchantCode", ",", "$", "currency", ",", "$", "transactionType", ",", "$", "merchantURL", ",", "$", "secret", ")", "{", "return", "strtoupper", "(", "sha1", "(", "implode", "(", "''", ",", "[", "$", "amount", ",", "$", "order", ",", "$", "merchantCode", ",", "$", "currency", ",", "$", "transactionType", ",", "$", "merchantURL", ",", "$", "secret", ",", "]", ")", ")", ")", ";", "}" ]
Creates signature to be sent to Redsys. @param string $amount Amount @param string $order Order number @param string $merchantCode Merchant code @param string $currency Currency @param string $transactionType Transaction type @param string $merchantURL Merchant url @param string $secret Secret key @return string Signature
[ "Creates", "signature", "to", "be", "sent", "to", "Redsys", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/RedsysBundle/Services/RedsysFormTypeBuilder.php#L247-L265
231,263
PaymentSuite/paymentsuite
src/PaymentSuite/RedsysBundle/Services/RedsysFormTypeBuilder.php
RedsysFormTypeBuilder.formatOrderNumber
private function formatOrderNumber($orderNumber) { $length = strlen($orderNumber); $minLength = 4; if ($length < $minLength) { $orderNumber = str_pad($orderNumber, $minLength, '0', STR_PAD_LEFT); } return $orderNumber; }
php
private function formatOrderNumber($orderNumber) { $length = strlen($orderNumber); $minLength = 4; if ($length < $minLength) { $orderNumber = str_pad($orderNumber, $minLength, '0', STR_PAD_LEFT); } return $orderNumber; }
[ "private", "function", "formatOrderNumber", "(", "$", "orderNumber", ")", "{", "$", "length", "=", "strlen", "(", "$", "orderNumber", ")", ";", "$", "minLength", "=", "4", ";", "if", "(", "$", "length", "<", "$", "minLength", ")", "{", "$", "orderNumber", "=", "str_pad", "(", "$", "orderNumber", ",", "$", "minLength", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}", "return", "$", "orderNumber", ";", "}" ]
Formats order number to be Redsys compliant. @param string $orderNumber Order number @return string $orderNumber @todo Check that start with 4 numbers and that at least is 12 chars long
[ "Formats", "order", "number", "to", "be", "Redsys", "compliant", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/RedsysBundle/Services/RedsysFormTypeBuilder.php#L323-L333
231,264
davin-bao/workflow
src/DavinBao/Workflow/MigrationCommand.php
MigrationCommand.createMigration
protected function createMigration() { // migrations目录应该是根目录 app->path => base_pash $migration_file = base_path()."/database/migrations/".date('Y_m_d_His')."_workflow_setup_tables.php"; $app = app(); $resource_type = ''; if(is_array($app['config']->get('resource_type'))){ $resource_type = implode(",", app()['config']->get('workflow::resource_type')); } $output = $app['view']->make('workflow::generators.migration')->with('res_type',$resource_type)->render(); if( ! file_exists( $migration_file ) ) { $fs = fopen($migration_file, 'x'); if ( $fs ) { fwrite($fs, $output); fclose($fs); return true; } else { return false; } } else { return false; } }
php
protected function createMigration() { // migrations目录应该是根目录 app->path => base_pash $migration_file = base_path()."/database/migrations/".date('Y_m_d_His')."_workflow_setup_tables.php"; $app = app(); $resource_type = ''; if(is_array($app['config']->get('resource_type'))){ $resource_type = implode(",", app()['config']->get('workflow::resource_type')); } $output = $app['view']->make('workflow::generators.migration')->with('res_type',$resource_type)->render(); if( ! file_exists( $migration_file ) ) { $fs = fopen($migration_file, 'x'); if ( $fs ) { fwrite($fs, $output); fclose($fs); return true; } else { return false; } } else { return false; } }
[ "protected", "function", "createMigration", "(", ")", "{", "// migrations目录应该是根目录 app->path => base_pash", "$", "migration_file", "=", "base_path", "(", ")", ".", "\"/database/migrations/\"", ".", "date", "(", "'Y_m_d_His'", ")", ".", "\"_workflow_setup_tables.php\"", ";", "$", "app", "=", "app", "(", ")", ";", "$", "resource_type", "=", "''", ";", "if", "(", "is_array", "(", "$", "app", "[", "'config'", "]", "->", "get", "(", "'resource_type'", ")", ")", ")", "{", "$", "resource_type", "=", "implode", "(", "\",\"", ",", "app", "(", ")", "[", "'config'", "]", "->", "get", "(", "'workflow::resource_type'", ")", ")", ";", "}", "$", "output", "=", "$", "app", "[", "'view'", "]", "->", "make", "(", "'workflow::generators.migration'", ")", "->", "with", "(", "'res_type'", ",", "$", "resource_type", ")", "->", "render", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "migration_file", ")", ")", "{", "$", "fs", "=", "fopen", "(", "$", "migration_file", ",", "'x'", ")", ";", "if", "(", "$", "fs", ")", "{", "fwrite", "(", "$", "fs", ",", "$", "output", ")", ";", "fclose", "(", "$", "fs", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Create the migration @param string $name @return bool
[ "Create", "the", "migration" ]
8af8b33ef63e455a2a5a1cdf6ac7bc154d590488
https://github.com/davin-bao/workflow/blob/8af8b33ef63e455a2a5a1cdf6ac7bc154d590488/src/DavinBao/Workflow/MigrationCommand.php#L79-L109
231,265
php-task/TaskBundle
src/Builder/TaskBuilder.php
TaskBuilder.setSystemKey
public function setSystemKey($systemKey) { if (!$this->task instanceof Task) { throw new NotSupportedMethodException('systemKey', $this->task); } $this->task->setSystemKey($systemKey); return $this; }
php
public function setSystemKey($systemKey) { if (!$this->task instanceof Task) { throw new NotSupportedMethodException('systemKey', $this->task); } $this->task->setSystemKey($systemKey); return $this; }
[ "public", "function", "setSystemKey", "(", "$", "systemKey", ")", "{", "if", "(", "!", "$", "this", "->", "task", "instanceof", "Task", ")", "{", "throw", "new", "NotSupportedMethodException", "(", "'systemKey'", ",", "$", "this", "->", "task", ")", ";", "}", "$", "this", "->", "task", "->", "setSystemKey", "(", "$", "systemKey", ")", ";", "return", "$", "this", ";", "}" ]
Set system-key. @param string $systemKey @return TaskBuilderInterface @throws NotSupportedMethodException
[ "Set", "system", "-", "key", "." ]
be8f0bbdfa3dc9dcaf0e01814166730a336eea07
https://github.com/php-task/TaskBundle/blob/be8f0bbdfa3dc9dcaf0e01814166730a336eea07/src/Builder/TaskBuilder.php#L32-L41
231,266
PaymentSuite/paymentsuite
src/PaymentSuite/PaymentCoreBundle/Services/PaymentLogger.php
PaymentLogger.log
public function log( $level, $message, $paymentMethod, array $context = [] ) { if (!$this->active) { return $this; } $this ->logger ->log( $level, "[$paymentMethod] - $message", $context ); return $this; }
php
public function log( $level, $message, $paymentMethod, array $context = [] ) { if (!$this->active) { return $this; } $this ->logger ->log( $level, "[$paymentMethod] - $message", $context ); return $this; }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "$", "paymentMethod", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "active", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "logger", "->", "log", "(", "$", "level", ",", "\"[$paymentMethod] - $message\"", ",", "$", "context", ")", ";", "return", "$", "this", ";", "}" ]
Log payment message, prepending payment bundle name if set. @param string $level Level @param string $message Message to log @param string $paymentMethod Payment method @param array $context Context @return PaymentLogger Self object
[ "Log", "payment", "message", "prepending", "payment", "bundle", "name", "if", "set", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaymentCoreBundle/Services/PaymentLogger.php#L63-L82
231,267
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.createFromUrl
public static function createFromUrl($url, $user = null, $password = null, $headers = array(), $getParams = array(), $postParams = array(), $content = null) { $rowUrl = parse_url($url); if (empty($rowUrl["host"])) { throw new HTTPStatus502Exception("The host is not defined", 502); } if ($user !== null) { $rowUrl["user"] = $user; $rowUrl["pass"] = $password === null ? "" : $password; } $getParamsHelp = array(); if (isset($rowUrl["query"])) { parse_str($rowUrl["query"], $getParamsHelp); unset($rowUrl["query"]); } $getParams = array_merge($getParamsHelp, $getParams); $method = Utils::$METHOD_GET; if ($content !== null || count($postParams) > 0) { $method = Utils::$METHOD_POST; } $headers['Host'] = $rowUrl['host']; return new ProxyQuery($rowUrl, $method, $content, $getParams, $postParams, $headers); }
php
public static function createFromUrl($url, $user = null, $password = null, $headers = array(), $getParams = array(), $postParams = array(), $content = null) { $rowUrl = parse_url($url); if (empty($rowUrl["host"])) { throw new HTTPStatus502Exception("The host is not defined", 502); } if ($user !== null) { $rowUrl["user"] = $user; $rowUrl["pass"] = $password === null ? "" : $password; } $getParamsHelp = array(); if (isset($rowUrl["query"])) { parse_str($rowUrl["query"], $getParamsHelp); unset($rowUrl["query"]); } $getParams = array_merge($getParamsHelp, $getParams); $method = Utils::$METHOD_GET; if ($content !== null || count($postParams) > 0) { $method = Utils::$METHOD_POST; } $headers['Host'] = $rowUrl['host']; return new ProxyQuery($rowUrl, $method, $content, $getParams, $postParams, $headers); }
[ "public", "static", "function", "createFromUrl", "(", "$", "url", ",", "$", "user", "=", "null", ",", "$", "password", "=", "null", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "getParams", "=", "array", "(", ")", ",", "$", "postParams", "=", "array", "(", ")", ",", "$", "content", "=", "null", ")", "{", "$", "rowUrl", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "empty", "(", "$", "rowUrl", "[", "\"host\"", "]", ")", ")", "{", "throw", "new", "HTTPStatus502Exception", "(", "\"The host is not defined\"", ",", "502", ")", ";", "}", "if", "(", "$", "user", "!==", "null", ")", "{", "$", "rowUrl", "[", "\"user\"", "]", "=", "$", "user", ";", "$", "rowUrl", "[", "\"pass\"", "]", "=", "$", "password", "===", "null", "?", "\"\"", ":", "$", "password", ";", "}", "$", "getParamsHelp", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "rowUrl", "[", "\"query\"", "]", ")", ")", "{", "parse_str", "(", "$", "rowUrl", "[", "\"query\"", "]", ",", "$", "getParamsHelp", ")", ";", "unset", "(", "$", "rowUrl", "[", "\"query\"", "]", ")", ";", "}", "$", "getParams", "=", "array_merge", "(", "$", "getParamsHelp", ",", "$", "getParams", ")", ";", "$", "method", "=", "Utils", "::", "$", "METHOD_GET", ";", "if", "(", "$", "content", "!==", "null", "||", "count", "(", "$", "postParams", ")", ">", "0", ")", "{", "$", "method", "=", "Utils", "::", "$", "METHOD_POST", ";", "}", "$", "headers", "[", "'Host'", "]", "=", "$", "rowUrl", "[", "'host'", "]", ";", "return", "new", "ProxyQuery", "(", "$", "rowUrl", ",", "$", "method", ",", "$", "content", ",", "$", "getParams", ",", "$", "postParams", ",", "$", "headers", ")", ";", "}" ]
Creates an instance from parameters @param string $url the url @param string $user the user name for basic authentication @param string $password the user password for basic authentication @param array $headers the HTTP headers @param array $getParams the GET parameters @param array $postParams the POST parameters @param string $content the POST content @return ProxyQuery a new instance @throws HTTPStatus502Exception if the host is not defined at $url
[ "Creates", "an", "instance", "from", "parameters" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L67-L98
231,268
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.createFromRequest
public static function createFromRequest(Request $request) { $rowUrl = urldecode(Utils::getParamValue($request, Utils::$PARAMETER_URL, Utils::$METHOD_GET, false)); $rowUrl = parse_url($rowUrl); if (empty($rowUrl["host"])) { throw new HTTPStatus502Exception("The host is not defined", 502); } $getParams = array(); if (isset($rowUrl["query"])) { parse_str($rowUrl["query"], $getParams); unset($rowUrl["query"]); } $allParams = Utils::getAllParams($request); if (isset($allParams[Utils::$METHOD_GET]) && isset($allParams[Utils::$METHOD_GET][Utils::$PARAMETER_URL])) { unset($allParams[Utils::$METHOD_GET][Utils::$PARAMETER_URL]); } $content = null; $postParams = array(); if (isset($allParams[Utils::$CONTENT]) || isset($allParams[Utils::$METHOD_POST])) { $method = Utils::$METHOD_POST; $content = isset($allParams[Utils::$CONTENT]) ? $allParams[Utils::$CONTENT] : $request->getContent(); $postParams = isset($allParams[Utils::$METHOD_POST]) ? $allParams[Utils::$METHOD_POST] : array(); // if url containts more get parameters if (!empty($allParams[Utils::$METHOD_GET])) { $postParams = array_merge($postParams, $allParams[Utils::$METHOD_GET]); } } else { $method = Utils::$METHOD_GET; $getParamshelp = isset($allParams[Utils::$METHOD_GET]) ? $allParams[Utils::$METHOD_GET] : array(); $getParams = array_merge($getParams, $getParamshelp); } $headers = Utils::getHeadersFromRequest($request); $headers['Host'] = $rowUrl['host']; return new ProxyQuery($rowUrl, $method, $content, $getParams, $postParams, $headers); }
php
public static function createFromRequest(Request $request) { $rowUrl = urldecode(Utils::getParamValue($request, Utils::$PARAMETER_URL, Utils::$METHOD_GET, false)); $rowUrl = parse_url($rowUrl); if (empty($rowUrl["host"])) { throw new HTTPStatus502Exception("The host is not defined", 502); } $getParams = array(); if (isset($rowUrl["query"])) { parse_str($rowUrl["query"], $getParams); unset($rowUrl["query"]); } $allParams = Utils::getAllParams($request); if (isset($allParams[Utils::$METHOD_GET]) && isset($allParams[Utils::$METHOD_GET][Utils::$PARAMETER_URL])) { unset($allParams[Utils::$METHOD_GET][Utils::$PARAMETER_URL]); } $content = null; $postParams = array(); if (isset($allParams[Utils::$CONTENT]) || isset($allParams[Utils::$METHOD_POST])) { $method = Utils::$METHOD_POST; $content = isset($allParams[Utils::$CONTENT]) ? $allParams[Utils::$CONTENT] : $request->getContent(); $postParams = isset($allParams[Utils::$METHOD_POST]) ? $allParams[Utils::$METHOD_POST] : array(); // if url containts more get parameters if (!empty($allParams[Utils::$METHOD_GET])) { $postParams = array_merge($postParams, $allParams[Utils::$METHOD_GET]); } } else { $method = Utils::$METHOD_GET; $getParamshelp = isset($allParams[Utils::$METHOD_GET]) ? $allParams[Utils::$METHOD_GET] : array(); $getParams = array_merge($getParams, $getParamshelp); } $headers = Utils::getHeadersFromRequest($request); $headers['Host'] = $rowUrl['host']; return new ProxyQuery($rowUrl, $method, $content, $getParams, $postParams, $headers); }
[ "public", "static", "function", "createFromRequest", "(", "Request", "$", "request", ")", "{", "$", "rowUrl", "=", "urldecode", "(", "Utils", "::", "getParamValue", "(", "$", "request", ",", "Utils", "::", "$", "PARAMETER_URL", ",", "Utils", "::", "$", "METHOD_GET", ",", "false", ")", ")", ";", "$", "rowUrl", "=", "parse_url", "(", "$", "rowUrl", ")", ";", "if", "(", "empty", "(", "$", "rowUrl", "[", "\"host\"", "]", ")", ")", "{", "throw", "new", "HTTPStatus502Exception", "(", "\"The host is not defined\"", ",", "502", ")", ";", "}", "$", "getParams", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "rowUrl", "[", "\"query\"", "]", ")", ")", "{", "parse_str", "(", "$", "rowUrl", "[", "\"query\"", "]", ",", "$", "getParams", ")", ";", "unset", "(", "$", "rowUrl", "[", "\"query\"", "]", ")", ";", "}", "$", "allParams", "=", "Utils", "::", "getAllParams", "(", "$", "request", ")", ";", "if", "(", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", ")", "&&", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", "[", "Utils", "::", "$", "PARAMETER_URL", "]", ")", ")", "{", "unset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", "[", "Utils", "::", "$", "PARAMETER_URL", "]", ")", ";", "}", "$", "content", "=", "null", ";", "$", "postParams", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "CONTENT", "]", ")", "||", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_POST", "]", ")", ")", "{", "$", "method", "=", "Utils", "::", "$", "METHOD_POST", ";", "$", "content", "=", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "CONTENT", "]", ")", "?", "$", "allParams", "[", "Utils", "::", "$", "CONTENT", "]", ":", "$", "request", "->", "getContent", "(", ")", ";", "$", "postParams", "=", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_POST", "]", ")", "?", "$", "allParams", "[", "Utils", "::", "$", "METHOD_POST", "]", ":", "array", "(", ")", ";", "// if url containts more get parameters", "if", "(", "!", "empty", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", ")", ")", "{", "$", "postParams", "=", "array_merge", "(", "$", "postParams", ",", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", ")", ";", "}", "}", "else", "{", "$", "method", "=", "Utils", "::", "$", "METHOD_GET", ";", "$", "getParamshelp", "=", "isset", "(", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", ")", "?", "$", "allParams", "[", "Utils", "::", "$", "METHOD_GET", "]", ":", "array", "(", ")", ";", "$", "getParams", "=", "array_merge", "(", "$", "getParams", ",", "$", "getParamshelp", ")", ";", "}", "$", "headers", "=", "Utils", "::", "getHeadersFromRequest", "(", "$", "request", ")", ";", "$", "headers", "[", "'Host'", "]", "=", "$", "rowUrl", "[", "'host'", "]", ";", "return", "new", "ProxyQuery", "(", "$", "rowUrl", ",", "$", "method", ",", "$", "content", ",", "$", "getParams", ",", "$", "postParams", ",", "$", "headers", ")", ";", "}" ]
Creates an instance @param Request $request @return ProxyQuery a new instance @throws HTTPStatus502Exception if the host is not defined
[ "Creates", "an", "instance" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L107-L158
231,269
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.addPostParameter
public function addPostParameter($name, $value) { if (!$this->hasGetPostParamValue($name, true)) { $this->postParams[$name] = $value; return true; } else { return false; } }
php
public function addPostParameter($name, $value) { if (!$this->hasGetPostParamValue($name, true)) { $this->postParams[$name] = $value; return true; } else { return false; } }
[ "public", "function", "addPostParameter", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "hasGetPostParamValue", "(", "$", "name", ",", "true", ")", ")", "{", "$", "this", "->", "postParams", "[", "$", "name", "]", "=", "$", "value", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Adds a POST parameter if not already present @param string $name @param string $value @return boolean true if added false if not
[ "Adds", "a", "POST", "parameter", "if", "not", "already", "present" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L202-L213
231,270
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.addGetParameter
public function addGetParameter($name, $value) { if (!$this->hasGetPostParamValue($name, true)) { $this->getParams[$name] = $value; return true; } else { return false; } }
php
public function addGetParameter($name, $value) { if (!$this->hasGetPostParamValue($name, true)) { $this->getParams[$name] = $value; return true; } else { return false; } }
[ "public", "function", "addGetParameter", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "hasGetPostParamValue", "(", "$", "name", ",", "true", ")", ")", "{", "$", "this", "->", "getParams", "[", "$", "name", "]", "=", "$", "value", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Adds a GET parameter if not already present @param string $name @param string $value @return boolean true if added false if not
[ "Adds", "a", "GET", "parameter", "if", "not", "already", "present" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L222-L233
231,271
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.getGetUrl
public function getGetUrl() { $scheme = empty($this->rowUrl["scheme"]) ? "http://" : $this->rowUrl["scheme"] . "://"; $user = empty($this->rowUrl["user"]) ? "" : $this->rowUrl["user"]; $pass = empty($this->rowUrl["pass"]) ? "" : $this->rowUrl["pass"]; // if pass is there, put a : between user and pass (user:pass) if (!empty($pass)) { $user = rawurlencode($user) . ":"; } // if user and password are there, put a @ after pass, so that user:pass@host will be constructed if (!empty($user) || !empty($pass)) { $pass = rawurlencode($pass) . "@"; } $host = $this->rowUrl["host"]; $port = empty($this->rowUrl["port"]) ? "" : ":" . $this->rowUrl["port"]; $path = empty($this->rowUrl["path"]) ? "" : $this->rowUrl["path"]; $urlquery = ""; if (count($this->getParams) > 0) { $urlquery = "?" . http_build_query($this->getParams); } return $scheme . $user . $pass . $host . $port . $path . $urlquery; }
php
public function getGetUrl() { $scheme = empty($this->rowUrl["scheme"]) ? "http://" : $this->rowUrl["scheme"] . "://"; $user = empty($this->rowUrl["user"]) ? "" : $this->rowUrl["user"]; $pass = empty($this->rowUrl["pass"]) ? "" : $this->rowUrl["pass"]; // if pass is there, put a : between user and pass (user:pass) if (!empty($pass)) { $user = rawurlencode($user) . ":"; } // if user and password are there, put a @ after pass, so that user:pass@host will be constructed if (!empty($user) || !empty($pass)) { $pass = rawurlencode($pass) . "@"; } $host = $this->rowUrl["host"]; $port = empty($this->rowUrl["port"]) ? "" : ":" . $this->rowUrl["port"]; $path = empty($this->rowUrl["path"]) ? "" : $this->rowUrl["path"]; $urlquery = ""; if (count($this->getParams) > 0) { $urlquery = "?" . http_build_query($this->getParams); } return $scheme . $user . $pass . $host . $port . $path . $urlquery; }
[ "public", "function", "getGetUrl", "(", ")", "{", "$", "scheme", "=", "empty", "(", "$", "this", "->", "rowUrl", "[", "\"scheme\"", "]", ")", "?", "\"http://\"", ":", "$", "this", "->", "rowUrl", "[", "\"scheme\"", "]", ".", "\"://\"", ";", "$", "user", "=", "empty", "(", "$", "this", "->", "rowUrl", "[", "\"user\"", "]", ")", "?", "\"\"", ":", "$", "this", "->", "rowUrl", "[", "\"user\"", "]", ";", "$", "pass", "=", "empty", "(", "$", "this", "->", "rowUrl", "[", "\"pass\"", "]", ")", "?", "\"\"", ":", "$", "this", "->", "rowUrl", "[", "\"pass\"", "]", ";", "// if pass is there, put a : between user and pass (user:pass)", "if", "(", "!", "empty", "(", "$", "pass", ")", ")", "{", "$", "user", "=", "rawurlencode", "(", "$", "user", ")", ".", "\":\"", ";", "}", "// if user and password are there, put a @ after pass, so that user:pass@host will be constructed", "if", "(", "!", "empty", "(", "$", "user", ")", "||", "!", "empty", "(", "$", "pass", ")", ")", "{", "$", "pass", "=", "rawurlencode", "(", "$", "pass", ")", ".", "\"@\"", ";", "}", "$", "host", "=", "$", "this", "->", "rowUrl", "[", "\"host\"", "]", ";", "$", "port", "=", "empty", "(", "$", "this", "->", "rowUrl", "[", "\"port\"", "]", ")", "?", "\"\"", ":", "\":\"", ".", "$", "this", "->", "rowUrl", "[", "\"port\"", "]", ";", "$", "path", "=", "empty", "(", "$", "this", "->", "rowUrl", "[", "\"path\"", "]", ")", "?", "\"\"", ":", "$", "this", "->", "rowUrl", "[", "\"path\"", "]", ";", "$", "urlquery", "=", "\"\"", ";", "if", "(", "count", "(", "$", "this", "->", "getParams", ")", ">", "0", ")", "{", "$", "urlquery", "=", "\"?\"", ".", "http_build_query", "(", "$", "this", "->", "getParams", ")", ";", "}", "return", "$", "scheme", ".", "$", "user", ".", "$", "pass", ".", "$", "host", ".", "$", "port", ".", "$", "path", ".", "$", "urlquery", ";", "}" ]
Generats the url for HTTP GET @return string the HTTP GET url
[ "Generats", "the", "url", "for", "HTTP", "GET" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L346-L373
231,272
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.getGetParamValue
public function getGetParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->getParams as $key => $value) { if (strtolower($key) === $name) { return $value; } } } else { foreach ($this->getParams as $key => $value) { if ($key === $name) { return $value; } } } return null; }
php
public function getGetParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->getParams as $key => $value) { if (strtolower($key) === $name) { return $value; } } } else { foreach ($this->getParams as $key => $value) { if ($key === $name) { return $value; } } } return null; }
[ "public", "function", "getGetParamValue", "(", "$", "name", ",", "$", "ignoreCase", "=", "false", ")", "{", "if", "(", "$", "ignoreCase", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "getParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "key", ")", "===", "$", "name", ")", "{", "return", "$", "value", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "getParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "$", "name", ")", "{", "return", "$", "value", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the parameter value from GET parameters @param string $name the parameter name @param boolean $ignoreCase to ignore the parameter name case sensitivity @return string|null the parameter value or null
[ "Returns", "the", "parameter", "value", "from", "GET", "parameters" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L402-L426
231,273
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.getPostParamValue
public function getPostParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->postParams as $key => $value) { if (strtolower($key) === $name) { return $value; } } } else { foreach ($this->postParams as $key => $value) { if ($key === $name) { return $value; } } } return null; }
php
public function getPostParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->postParams as $key => $value) { if (strtolower($key) === $name) { return $value; } } } else { foreach ($this->postParams as $key => $value) { if ($key === $name) { return $value; } } } return null; }
[ "public", "function", "getPostParamValue", "(", "$", "name", ",", "$", "ignoreCase", "=", "false", ")", "{", "if", "(", "$", "ignoreCase", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "postParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "key", ")", "===", "$", "name", ")", "{", "return", "$", "value", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "postParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "$", "name", ")", "{", "return", "$", "value", ";", "}", "}", "}", "return", "null", ";", "}" ]
Returns the parameter value from POST parameters @param string $name the parameter name @param boolean $ignoreCase to ignore the parameter name case sensitivity @return string|null the parameter value or null
[ "Returns", "the", "parameter", "value", "from", "POST", "parameters" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L435-L459
231,274
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.removeGetParameter
public function removeGetParameter($name) { if (isset($this->getParams[$name])) { unset($this->getParams[$name]); return true; } else return false; }
php
public function removeGetParameter($name) { if (isset($this->getParams[$name])) { unset($this->getParams[$name]); return true; } else return false; }
[ "public", "function", "removeGetParameter", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "getParams", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "getParams", "[", "$", "name", "]", ")", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}" ]
Removes a GET parameter. @param string $name parameter name @return boolean true if parameter removed
[ "Removes", "a", "GET", "parameter", "." ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L466-L474
231,275
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.removePostParameter
public function removePostParameter($name) { if (isset($this->postParams[$name])) { unset($this->postParams[$name]); return true; } else return false; }
php
public function removePostParameter($name) { if (isset($this->postParams[$name])) { unset($this->postParams[$name]); return true; } else return false; }
[ "public", "function", "removePostParameter", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "postParams", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "postParams", "[", "$", "name", "]", ")", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}" ]
Removes a POST parameter. @param string $name parameter name @return boolean true if parameter removed
[ "Removes", "a", "POST", "parameter", "." ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L481-L489
231,276
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.hasGetParamValue
public function hasGetParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->getParams as $key => $value) { if (strtolower($key) === $name) { return true; } } } else { foreach ($this->getParams as $key => $value) { if ($key === $name) { return true; } } } return false; }
php
public function hasGetParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->getParams as $key => $value) { if (strtolower($key) === $name) { return true; } } } else { foreach ($this->getParams as $key => $value) { if ($key === $name) { return true; } } } return false; }
[ "public", "function", "hasGetParamValue", "(", "$", "name", ",", "$", "ignoreCase", "=", "false", ")", "{", "if", "(", "$", "ignoreCase", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "getParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "key", ")", "===", "$", "name", ")", "{", "return", "true", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "getParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "$", "name", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if a GET parameter exists @param string $name the parameter name @param boolean $ignoreCase to ignore the parameter name case sensitivity @return boolean true if a parameter exists
[ "Checks", "if", "a", "GET", "parameter", "exists" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L518-L542
231,277
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/ProxyQuery.php
ProxyQuery.hasPostParamValue
public function hasPostParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->postParams as $key => $value) { if (strtolower($key) === $name) { return true; } } } else { foreach ($this->postParams as $key => $value) { if ($key === $name) { return true; } } } return false; }
php
public function hasPostParamValue($name, $ignoreCase = false) { if ($ignoreCase) { $name = strtolower($name); foreach ($this->postParams as $key => $value) { if (strtolower($key) === $name) { return true; } } } else { foreach ($this->postParams as $key => $value) { if ($key === $name) { return true; } } } return false; }
[ "public", "function", "hasPostParamValue", "(", "$", "name", ",", "$", "ignoreCase", "=", "false", ")", "{", "if", "(", "$", "ignoreCase", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "foreach", "(", "$", "this", "->", "postParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strtolower", "(", "$", "key", ")", "===", "$", "name", ")", "{", "return", "true", ";", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "postParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "key", "===", "$", "name", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if a POST parameter exists @param string $name the parameter name @param boolean $ignoreCase to ignore the parameter name case sensitivity @return boolean true if a parameter exists
[ "Checks", "if", "a", "POST", "parameter", "exists" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/ProxyQuery.php#L551-L575
231,278
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.append
public function append($string) { ArgumentValidator::validateScalar($string); $this->string .= (string)$string; return $this; }
php
public function append($string) { ArgumentValidator::validateScalar($string); $this->string .= (string)$string; return $this; }
[ "public", "function", "append", "(", "$", "string", ")", "{", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "$", "this", "->", "string", ".=", "(", "string", ")", "$", "string", ";", "return", "$", "this", ";", "}" ]
Appends the given string @param string $string @return $this @throws \InvalidArgumentException
[ "Appends", "the", "given", "string" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L43-L48
231,279
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.prepend
public function prepend($string) { ArgumentValidator::validateScalar($string); $this->string = (string)$string . $this->string; return $this; }
php
public function prepend($string) { ArgumentValidator::validateScalar($string); $this->string = (string)$string . $this->string; return $this; }
[ "public", "function", "prepend", "(", "$", "string", ")", "{", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "$", "this", "->", "string", "=", "(", "string", ")", "$", "string", ".", "$", "this", "->", "string", ";", "return", "$", "this", ";", "}" ]
Prepends the given string @param string $string @return $this @throws \InvalidArgumentException
[ "Prepends", "the", "given", "string" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L57-L62
231,280
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.insert
public function insert($position, $string) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateScalar($string); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } $this->string = mb_substr($this->string, 0, $position) . (string)$string . mb_substr($this->string, $position); return $this; }
php
public function insert($position, $string) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateScalar($string); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } $this->string = mb_substr($this->string, 0, $position) . (string)$string . mb_substr($this->string, $position); return $this; }
[ "public", "function", "insert", "(", "$", "position", ",", "$", "string", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ".", "(", "string", ")", "$", "string", ".", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", ")", ";", "return", "$", "this", ";", "}" ]
Inserts the given string at the given position @param int $position @param string $string @return $this @throws \InvalidArgumentException
[ "Inserts", "the", "given", "string", "at", "the", "given", "position" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L72-L81
231,281
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.replace
public function replace($position, $length, $string) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateUnsignedInteger($length); ArgumentValidator::validateScalar($string); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if ($position + $length > $this->length()) { throw new \InvalidArgumentException('Length invalid'); } $this->string = mb_substr($this->string, 0, $position) . (string)$string . mb_substr($this->string, $position + $length); return $this; }
php
public function replace($position, $length, $string) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateUnsignedInteger($length); ArgumentValidator::validateScalar($string); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if ($position + $length > $this->length()) { throw new \InvalidArgumentException('Length invalid'); } $this->string = mb_substr($this->string, 0, $position) . (string)$string . mb_substr($this->string, $position + $length); return $this; }
[ "public", "function", "replace", "(", "$", "position", ",", "$", "length", ",", "$", "string", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "length", ")", ";", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "if", "(", "$", "position", "+", "$", "length", ">", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Length invalid'", ")", ";", "}", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ".", "(", "string", ")", "$", "string", ".", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", "+", "$", "length", ")", ";", "return", "$", "this", ";", "}" ]
Replaces the characters defined by the given position and length with the given string @param int $position @param int $length @param string $string @return $this @throws \InvalidArgumentException
[ "Replaces", "the", "characters", "defined", "by", "the", "given", "position", "and", "length", "with", "the", "given", "string" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L92-L105
231,282
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.setCharAt
public function setCharAt($position, $character) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateScalar($character); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if (mb_strlen((string)$character) !== 1) { throw new \InvalidArgumentException('Expected a scalar value of length 1'); } $this->string = mb_substr($this->string, 0, $position) . (string)$character . mb_substr($this->string, $position + 1); return $this; }
php
public function setCharAt($position, $character) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateScalar($character); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if (mb_strlen((string)$character) !== 1) { throw new \InvalidArgumentException('Expected a scalar value of length 1'); } $this->string = mb_substr($this->string, 0, $position) . (string)$character . mb_substr($this->string, $position + 1); return $this; }
[ "public", "function", "setCharAt", "(", "$", "position", ",", "$", "character", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "ArgumentValidator", "::", "validateScalar", "(", "$", "character", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "if", "(", "mb_strlen", "(", "(", "string", ")", "$", "character", ")", "!==", "1", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expected a scalar value of length 1'", ")", ";", "}", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ".", "(", "string", ")", "$", "character", ".", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", "+", "1", ")", ";", "return", "$", "this", ";", "}" ]
Sets the character at the given position @param int $position @param string $character @return $this @throws \InvalidArgumentException
[ "Sets", "the", "character", "at", "the", "given", "position" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L115-L127
231,283
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.reverse
public function reverse() { $length = $this->length(); $reversed = ''; while ($length-- > 0) { $reversed .= mb_substr($this->string, $length, 1, mb_detect_encoding($this->string)); } $this->string = $reversed; return $this; }
php
public function reverse() { $length = $this->length(); $reversed = ''; while ($length-- > 0) { $reversed .= mb_substr($this->string, $length, 1, mb_detect_encoding($this->string)); } $this->string = $reversed; return $this; }
[ "public", "function", "reverse", "(", ")", "{", "$", "length", "=", "$", "this", "->", "length", "(", ")", ";", "$", "reversed", "=", "''", ";", "while", "(", "$", "length", "--", ">", "0", ")", "{", "$", "reversed", ".=", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "length", ",", "1", ",", "mb_detect_encoding", "(", "$", "this", "->", "string", ")", ")", ";", "}", "$", "this", "->", "string", "=", "$", "reversed", ";", "return", "$", "this", ";", "}" ]
Reverts the string to build @return $this
[ "Reverts", "the", "string", "to", "build" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L134-L143
231,284
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.delete
public function delete($position, $length = null) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateUnsignedIntegerOrNull($length); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if ($length === null) { $this->string = mb_substr($this->string, 0, $position); } else { $this->string = mb_substr($this->string, 0, $position) . mb_substr($this->string, $position + $length); } return $this; }
php
public function delete($position, $length = null) { ArgumentValidator::validateUnsignedInteger($position); ArgumentValidator::validateUnsignedIntegerOrNull($length); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } if ($length === null) { $this->string = mb_substr($this->string, 0, $position); } else { $this->string = mb_substr($this->string, 0, $position) . mb_substr($this->string, $position + $length); } return $this; }
[ "public", "function", "delete", "(", "$", "position", ",", "$", "length", "=", "null", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "ArgumentValidator", "::", "validateUnsignedIntegerOrNull", "(", "$", "length", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "if", "(", "$", "length", "===", "null", ")", "{", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ";", "}", "else", "{", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ".", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", "+", "$", "length", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes the portion defined by the given position and length @param int $position @param int $length @return $this @throws \InvalidArgumentException
[ "Removes", "the", "portion", "defined", "by", "the", "given", "position", "and", "length" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L153-L166
231,285
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.deleteCharAt
public function deleteCharAt($position) { ArgumentValidator::validateUnsignedInteger($position); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } $this->string = mb_substr($this->string, 0, $position) . mb_substr($this->string, $position + 1); return $this; }
php
public function deleteCharAt($position) { ArgumentValidator::validateUnsignedInteger($position); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } $this->string = mb_substr($this->string, 0, $position) . mb_substr($this->string, $position + 1); return $this; }
[ "public", "function", "deleteCharAt", "(", "$", "position", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "$", "this", "->", "string", "=", "mb_substr", "(", "$", "this", "->", "string", ",", "0", ",", "$", "position", ")", ".", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", "+", "1", ")", ";", "return", "$", "this", ";", "}" ]
Removes the character at the given position @param int $position @return $this @throws \InvalidArgumentException
[ "Removes", "the", "character", "at", "the", "given", "position" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L175-L183
231,286
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.contains
public function contains($substring) { ArgumentValidator::validateScalar($substring); return strpos($this->string, (string)$substring) !== false; }
php
public function contains($substring) { ArgumentValidator::validateScalar($substring); return strpos($this->string, (string)$substring) !== false; }
[ "public", "function", "contains", "(", "$", "substring", ")", "{", "ArgumentValidator", "::", "validateScalar", "(", "$", "substring", ")", ";", "return", "strpos", "(", "$", "this", "->", "string", ",", "(", "string", ")", "$", "substring", ")", "!==", "false", ";", "}" ]
Whether the string to build contains the given substring @param string $substring @return bool @throws \InvalidArgumentException
[ "Whether", "the", "string", "to", "build", "contains", "the", "given", "substring" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L192-L196
231,287
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.indexOf
public function indexOf($string, $offset = 0) { ArgumentValidator::validateScalar($string); ArgumentValidator::validateEmpty($string); ArgumentValidator::validateUnsignedInteger($offset); $index = mb_strpos($this->string, (string)$string, $offset); return $index === false ? null : $index; }
php
public function indexOf($string, $offset = 0) { ArgumentValidator::validateScalar($string); ArgumentValidator::validateEmpty($string); ArgumentValidator::validateUnsignedInteger($offset); $index = mb_strpos($this->string, (string)$string, $offset); return $index === false ? null : $index; }
[ "public", "function", "indexOf", "(", "$", "string", ",", "$", "offset", "=", "0", ")", "{", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "ArgumentValidator", "::", "validateEmpty", "(", "$", "string", ")", ";", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "offset", ")", ";", "$", "index", "=", "mb_strpos", "(", "$", "this", "->", "string", ",", "(", "string", ")", "$", "string", ",", "$", "offset", ")", ";", "return", "$", "index", "===", "false", "?", "null", ":", "$", "index", ";", "}" ]
Returns the index of the first occurence of the given substring or null Takes an optional parameter to begin searching after the given offset @param string $string @param int $offset @return int @throws \InvalidArgumentException
[ "Returns", "the", "index", "of", "the", "first", "occurence", "of", "the", "given", "substring", "or", "null" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L208-L215
231,288
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.lastIndexOf
public function lastIndexOf($string, $offset = 0) { ArgumentValidator::validateScalar($string); ArgumentValidator::validateEmpty($string); ArgumentValidator::validateUnsignedInteger($offset); $index = mb_strrpos($this->string, (string)$string, -1 * $offset); return $index === false ? null : $index; }
php
public function lastIndexOf($string, $offset = 0) { ArgumentValidator::validateScalar($string); ArgumentValidator::validateEmpty($string); ArgumentValidator::validateUnsignedInteger($offset); $index = mb_strrpos($this->string, (string)$string, -1 * $offset); return $index === false ? null : $index; }
[ "public", "function", "lastIndexOf", "(", "$", "string", ",", "$", "offset", "=", "0", ")", "{", "ArgumentValidator", "::", "validateScalar", "(", "$", "string", ")", ";", "ArgumentValidator", "::", "validateEmpty", "(", "$", "string", ")", ";", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "offset", ")", ";", "$", "index", "=", "mb_strrpos", "(", "$", "this", "->", "string", ",", "(", "string", ")", "$", "string", ",", "-", "1", "*", "$", "offset", ")", ";", "return", "$", "index", "===", "false", "?", "null", ":", "$", "index", ";", "}" ]
Returns the index of the last occurence of the given substring or null Takes an optional parameter to end searching before the given offset @param string $string @param int $offset @return int @throws \InvalidArgumentException
[ "Returns", "the", "index", "of", "the", "last", "occurence", "of", "the", "given", "substring", "or", "null" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L227-L234
231,289
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.charAt
public function charAt($position) { ArgumentValidator::validateUnsignedInteger($position); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } return mb_substr($this->string, $position, 1); }
php
public function charAt($position) { ArgumentValidator::validateUnsignedInteger($position); if ($position >= $this->length()) { throw new \InvalidArgumentException('Position invalid'); } return mb_substr($this->string, $position, 1); }
[ "public", "function", "charAt", "(", "$", "position", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "position", ")", ";", "if", "(", "$", "position", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Position invalid'", ")", ";", "}", "return", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "position", ",", "1", ")", ";", "}" ]
Returns the character at the given position @param int $position @return string @throws \InvalidArgumentException
[ "Returns", "the", "character", "at", "the", "given", "position" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L263-L270
231,290
markenwerk/php-string-builder
src/StringBuilder.php
StringBuilder.buildSubstring
public function buildSubstring($startPosition, $length = null) { ArgumentValidator::validateUnsignedInteger($startPosition); ArgumentValidator::validateUnsignedIntegerOrNull($length); if ($startPosition >= $this->length()) { throw new \InvalidArgumentException('Start position ' . (string)$startPosition . ' invalid'); } if ($length === null) { return mb_substr($this->string, $startPosition); } return mb_substr($this->string, $startPosition, $length); }
php
public function buildSubstring($startPosition, $length = null) { ArgumentValidator::validateUnsignedInteger($startPosition); ArgumentValidator::validateUnsignedIntegerOrNull($length); if ($startPosition >= $this->length()) { throw new \InvalidArgumentException('Start position ' . (string)$startPosition . ' invalid'); } if ($length === null) { return mb_substr($this->string, $startPosition); } return mb_substr($this->string, $startPosition, $length); }
[ "public", "function", "buildSubstring", "(", "$", "startPosition", ",", "$", "length", "=", "null", ")", "{", "ArgumentValidator", "::", "validateUnsignedInteger", "(", "$", "startPosition", ")", ";", "ArgumentValidator", "::", "validateUnsignedIntegerOrNull", "(", "$", "length", ")", ";", "if", "(", "$", "startPosition", ">=", "$", "this", "->", "length", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Start position '", ".", "(", "string", ")", "$", "startPosition", ".", "' invalid'", ")", ";", "}", "if", "(", "$", "length", "===", "null", ")", "{", "return", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "startPosition", ")", ";", "}", "return", "mb_substr", "(", "$", "this", "->", "string", ",", "$", "startPosition", ",", "$", "length", ")", ";", "}" ]
Returns an substring defined by startPosition and length @param int $startPosition @param int $length @return string @throws \InvalidArgumentException
[ "Returns", "an", "substring", "defined", "by", "startPosition", "and", "length" ]
ce02ea5c81d24102075bd7d3b0fcb20209dab865
https://github.com/markenwerk/php-string-builder/blob/ce02ea5c81d24102075bd7d3b0fcb20209dab865/src/StringBuilder.php#L300-L311
231,291
mapbender/owsproxy3
src/OwsProxy3/CoreBundle/Component/CommonProxy.php
CommonProxy.createBrowser
protected function createBrowser() { $this->logger->debug("CommonProxy->createBrowser rowUrl:" . print_r($this->proxy_query->getRowUrl(), true)); $rowUrl = $this->proxy_query->getRowUrl(); $proxy_config = $this->proxy_config; $curl = new Curl(); $curl->setOption(CURLOPT_TIMEOUT, 60); $curl->setOption(CURLOPT_CONNECTTIMEOUT, 30); if ($proxy_config !== null && $proxy_config['checkssl'] !== null && $proxy_config['checkssl'] === false) { $curl->setOption(CURLOPT_SSL_VERIFYPEER, false); } if ($proxy_config !== null && $proxy_config['timeout'] !== null) { $curl->setOption(CURLOPT_TIMEOUT, $proxy_config['timeout']); } if ($proxy_config !== null && $proxy_config['connecttimeout'] !== null) { $curl->setOption(CURLOPT_CONNECTTIMEOUT, $proxy_config['connecttimeout']); } if ($proxy_config !== null && $proxy_config['host'] !== null && !in_array($rowUrl['host'], $proxy_config['noproxy'])) { $curl->setOption(CURLOPT_PROXY, $proxy_config['host']); $curl->setOption(CURLOPT_PROXYPORT, $proxy_config['port']); if ($proxy_config['user'] !== null && $proxy_config['password'] !== null) { $curl->setOption(CURLOPT_PROXYUSERPWD, $proxy_config['user'] . ':' . $proxy_config['password']); } } $browser = new Browser($curl); if(array_key_exists('user', $rowUrl) && $rowUrl['user'] != '' && array_key_exists('pass', $rowUrl) && $rowUrl['pass'] != '') { $browser->addListener(new BasicAuthListener($rowUrl['user'], $rowUrl['pass'])); } return $browser; }
php
protected function createBrowser() { $this->logger->debug("CommonProxy->createBrowser rowUrl:" . print_r($this->proxy_query->getRowUrl(), true)); $rowUrl = $this->proxy_query->getRowUrl(); $proxy_config = $this->proxy_config; $curl = new Curl(); $curl->setOption(CURLOPT_TIMEOUT, 60); $curl->setOption(CURLOPT_CONNECTTIMEOUT, 30); if ($proxy_config !== null && $proxy_config['checkssl'] !== null && $proxy_config['checkssl'] === false) { $curl->setOption(CURLOPT_SSL_VERIFYPEER, false); } if ($proxy_config !== null && $proxy_config['timeout'] !== null) { $curl->setOption(CURLOPT_TIMEOUT, $proxy_config['timeout']); } if ($proxy_config !== null && $proxy_config['connecttimeout'] !== null) { $curl->setOption(CURLOPT_CONNECTTIMEOUT, $proxy_config['connecttimeout']); } if ($proxy_config !== null && $proxy_config['host'] !== null && !in_array($rowUrl['host'], $proxy_config['noproxy'])) { $curl->setOption(CURLOPT_PROXY, $proxy_config['host']); $curl->setOption(CURLOPT_PROXYPORT, $proxy_config['port']); if ($proxy_config['user'] !== null && $proxy_config['password'] !== null) { $curl->setOption(CURLOPT_PROXYUSERPWD, $proxy_config['user'] . ':' . $proxy_config['password']); } } $browser = new Browser($curl); if(array_key_exists('user', $rowUrl) && $rowUrl['user'] != '' && array_key_exists('pass', $rowUrl) && $rowUrl['pass'] != '') { $browser->addListener(new BasicAuthListener($rowUrl['user'], $rowUrl['pass'])); } return $browser; }
[ "protected", "function", "createBrowser", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"CommonProxy->createBrowser rowUrl:\"", ".", "print_r", "(", "$", "this", "->", "proxy_query", "->", "getRowUrl", "(", ")", ",", "true", ")", ")", ";", "$", "rowUrl", "=", "$", "this", "->", "proxy_query", "->", "getRowUrl", "(", ")", ";", "$", "proxy_config", "=", "$", "this", "->", "proxy_config", ";", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_TIMEOUT", ",", "60", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_CONNECTTIMEOUT", ",", "30", ")", ";", "if", "(", "$", "proxy_config", "!==", "null", "&&", "$", "proxy_config", "[", "'checkssl'", "]", "!==", "null", "&&", "$", "proxy_config", "[", "'checkssl'", "]", "===", "false", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "}", "if", "(", "$", "proxy_config", "!==", "null", "&&", "$", "proxy_config", "[", "'timeout'", "]", "!==", "null", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_TIMEOUT", ",", "$", "proxy_config", "[", "'timeout'", "]", ")", ";", "}", "if", "(", "$", "proxy_config", "!==", "null", "&&", "$", "proxy_config", "[", "'connecttimeout'", "]", "!==", "null", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_CONNECTTIMEOUT", ",", "$", "proxy_config", "[", "'connecttimeout'", "]", ")", ";", "}", "if", "(", "$", "proxy_config", "!==", "null", "&&", "$", "proxy_config", "[", "'host'", "]", "!==", "null", "&&", "!", "in_array", "(", "$", "rowUrl", "[", "'host'", "]", ",", "$", "proxy_config", "[", "'noproxy'", "]", ")", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXY", ",", "$", "proxy_config", "[", "'host'", "]", ")", ";", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXYPORT", ",", "$", "proxy_config", "[", "'port'", "]", ")", ";", "if", "(", "$", "proxy_config", "[", "'user'", "]", "!==", "null", "&&", "$", "proxy_config", "[", "'password'", "]", "!==", "null", ")", "{", "$", "curl", "->", "setOption", "(", "CURLOPT_PROXYUSERPWD", ",", "$", "proxy_config", "[", "'user'", "]", ".", "':'", ".", "$", "proxy_config", "[", "'password'", "]", ")", ";", "}", "}", "$", "browser", "=", "new", "Browser", "(", "$", "curl", ")", ";", "if", "(", "array_key_exists", "(", "'user'", ",", "$", "rowUrl", ")", "&&", "$", "rowUrl", "[", "'user'", "]", "!=", "''", "&&", "array_key_exists", "(", "'pass'", ",", "$", "rowUrl", ")", "&&", "$", "rowUrl", "[", "'pass'", "]", "!=", "''", ")", "{", "$", "browser", "->", "addListener", "(", "new", "BasicAuthListener", "(", "$", "rowUrl", "[", "'user'", "]", ",", "$", "rowUrl", "[", "'pass'", "]", ")", ")", ";", "}", "return", "$", "browser", ";", "}" ]
Creates the browser @return \Buzz\Browser
[ "Creates", "the", "browser" ]
7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3
https://github.com/mapbender/owsproxy3/blob/7aa0d22d489489bde3df6722ac3f9cfb2a5b7ce3/src/OwsProxy3/CoreBundle/Component/CommonProxy.php#L93-L127
231,292
oanhnn/laravel-presets
src/PresetCommand.php
PresetCommand.bootstrap
protected function bootstrap() { (new Presets\Bootstrap($this->filesystem))->install(); $this->info('Bootstrap scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
php
protected function bootstrap() { (new Presets\Bootstrap($this->filesystem))->install(); $this->info('Bootstrap scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
[ "protected", "function", "bootstrap", "(", ")", "{", "(", "new", "Presets", "\\", "Bootstrap", "(", "$", "this", "->", "filesystem", ")", ")", "->", "install", "(", ")", ";", "$", "this", "->", "info", "(", "'Bootstrap scaffolding installed successfully.'", ")", ";", "$", "this", "->", "comment", "(", "'Please run \"npm install && npm run dev\" to compile your fresh scaffolding.'", ")", ";", "}" ]
Install the "fresh" preset. @return void
[ "Install", "the", "fresh", "preset", "." ]
b30d731bb23b764e0767715ae243876faf13408e
https://github.com/oanhnn/laravel-presets/blob/b30d731bb23b764e0767715ae243876faf13408e/src/PresetCommand.php#L68-L73
231,293
oanhnn/laravel-presets
src/PresetCommand.php
PresetCommand.vue
public function vue() { (new Presets\Vue($this->filesystem))->install(); $this->info('Vue scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
php
public function vue() { (new Presets\Vue($this->filesystem))->install(); $this->info('Vue scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
[ "public", "function", "vue", "(", ")", "{", "(", "new", "Presets", "\\", "Vue", "(", "$", "this", "->", "filesystem", ")", ")", "->", "install", "(", ")", ";", "$", "this", "->", "info", "(", "'Vue scaffolding installed successfully.'", ")", ";", "$", "this", "->", "comment", "(", "'Please run \"npm install && npm run dev\" to compile your fresh scaffolding.'", ")", ";", "}" ]
Install the "vue" preset. @return void
[ "Install", "the", "vue", "preset", "." ]
b30d731bb23b764e0767715ae243876faf13408e
https://github.com/oanhnn/laravel-presets/blob/b30d731bb23b764e0767715ae243876faf13408e/src/PresetCommand.php#L79-L84
231,294
oanhnn/laravel-presets
src/PresetCommand.php
PresetCommand.react
public function react() { (new Presets\React($this->filesystem))->install(); $this->info('React scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
php
public function react() { (new Presets\React($this->filesystem))->install(); $this->info('React scaffolding installed successfully.'); $this->comment('Please run "npm install && npm run dev" to compile your fresh scaffolding.'); }
[ "public", "function", "react", "(", ")", "{", "(", "new", "Presets", "\\", "React", "(", "$", "this", "->", "filesystem", ")", ")", "->", "install", "(", ")", ";", "$", "this", "->", "info", "(", "'React scaffolding installed successfully.'", ")", ";", "$", "this", "->", "comment", "(", "'Please run \"npm install && npm run dev\" to compile your fresh scaffolding.'", ")", ";", "}" ]
Install the "react" preset. @return void
[ "Install", "the", "react", "preset", "." ]
b30d731bb23b764e0767715ae243876faf13408e
https://github.com/oanhnn/laravel-presets/blob/b30d731bb23b764e0767715ae243876faf13408e/src/PresetCommand.php#L90-L95
231,295
PaymentSuite/paymentsuite
src/PaymentSuite/StripeBundle/Services/StripeTransactionFactory.php
StripeTransactionFactory.create
public function create(StripeTransaction $transaction) { try { Stripe::setApiKey($this->privateKey); $this->dispatcher->notifyCustomerPreCreate($transaction); $customer = Customer::create($transaction->getCustomerData()); $transaction->setCustomerId($customer->id); $chargeData = Charge::create($transaction->getChargeData()); } catch (Exception $e) { // The way to get to 'notifyPaymentOrderFail' return [ 'paid' => 0, ]; } return $chargeData; }
php
public function create(StripeTransaction $transaction) { try { Stripe::setApiKey($this->privateKey); $this->dispatcher->notifyCustomerPreCreate($transaction); $customer = Customer::create($transaction->getCustomerData()); $transaction->setCustomerId($customer->id); $chargeData = Charge::create($transaction->getChargeData()); } catch (Exception $e) { // The way to get to 'notifyPaymentOrderFail' return [ 'paid' => 0, ]; } return $chargeData; }
[ "public", "function", "create", "(", "StripeTransaction", "$", "transaction", ")", "{", "try", "{", "Stripe", "::", "setApiKey", "(", "$", "this", "->", "privateKey", ")", ";", "$", "this", "->", "dispatcher", "->", "notifyCustomerPreCreate", "(", "$", "transaction", ")", ";", "$", "customer", "=", "Customer", "::", "create", "(", "$", "transaction", "->", "getCustomerData", "(", ")", ")", ";", "$", "transaction", "->", "setCustomerId", "(", "$", "customer", "->", "id", ")", ";", "$", "chargeData", "=", "Charge", "::", "create", "(", "$", "transaction", "->", "getChargeData", "(", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "// The way to get to 'notifyPaymentOrderFail'", "return", "[", "'paid'", "=>", "0", ",", "]", ";", "}", "return", "$", "chargeData", ";", "}" ]
Create new Transaction with a set of params. @param array $transaction Set of params [source, amount, currency] @return \ArrayAccess|array Result of transaction
[ "Create", "new", "Transaction", "with", "a", "set", "of", "params", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/StripeBundle/Services/StripeTransactionFactory.php#L58-L78
231,296
PaymentSuite/paymentsuite
src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteExtension.php
AbstractPaymentSuiteExtension.registerRedirectRoutesDefinition
protected function registerRedirectRoutesDefinition( ContainerBuilder $containerBuilder, $paymentName, array $redirectionRoutesConfiguration ) { $collectionDefinition = $containerBuilder->register( "paymentsuite.{$paymentName}.routes", 'PaymentSuite\PaymentCoreBundle\ValueObject\RedirectionRouteCollection' ); foreach ($redirectionRoutesConfiguration as $redirectRouteName => $redirectRouteConfiguration) { $serviceName = "paymentsuite.$paymentName.route_$redirectRouteName"; $routeDefinition = $containerBuilder->register( $serviceName, 'PaymentSuite\PaymentCoreBundle\ValueObject\RedirectionRoute' ); $routeDefinition ->addArgument($redirectRouteConfiguration['route']) ->addArgument($redirectRouteConfiguration['order_append']) ->addArgument($redirectRouteConfiguration['order_append_field']); $collectionDefinition->addMethodCall( 'addRedirectionRoute', [ new Reference($serviceName), $redirectRouteName, ] ); } }
php
protected function registerRedirectRoutesDefinition( ContainerBuilder $containerBuilder, $paymentName, array $redirectionRoutesConfiguration ) { $collectionDefinition = $containerBuilder->register( "paymentsuite.{$paymentName}.routes", 'PaymentSuite\PaymentCoreBundle\ValueObject\RedirectionRouteCollection' ); foreach ($redirectionRoutesConfiguration as $redirectRouteName => $redirectRouteConfiguration) { $serviceName = "paymentsuite.$paymentName.route_$redirectRouteName"; $routeDefinition = $containerBuilder->register( $serviceName, 'PaymentSuite\PaymentCoreBundle\ValueObject\RedirectionRoute' ); $routeDefinition ->addArgument($redirectRouteConfiguration['route']) ->addArgument($redirectRouteConfiguration['order_append']) ->addArgument($redirectRouteConfiguration['order_append_field']); $collectionDefinition->addMethodCall( 'addRedirectionRoute', [ new Reference($serviceName), $redirectRouteName, ] ); } }
[ "protected", "function", "registerRedirectRoutesDefinition", "(", "ContainerBuilder", "$", "containerBuilder", ",", "$", "paymentName", ",", "array", "$", "redirectionRoutesConfiguration", ")", "{", "$", "collectionDefinition", "=", "$", "containerBuilder", "->", "register", "(", "\"paymentsuite.{$paymentName}.routes\"", ",", "'PaymentSuite\\PaymentCoreBundle\\ValueObject\\RedirectionRouteCollection'", ")", ";", "foreach", "(", "$", "redirectionRoutesConfiguration", "as", "$", "redirectRouteName", "=>", "$", "redirectRouteConfiguration", ")", "{", "$", "serviceName", "=", "\"paymentsuite.$paymentName.route_$redirectRouteName\"", ";", "$", "routeDefinition", "=", "$", "containerBuilder", "->", "register", "(", "$", "serviceName", ",", "'PaymentSuite\\PaymentCoreBundle\\ValueObject\\RedirectionRoute'", ")", ";", "$", "routeDefinition", "->", "addArgument", "(", "$", "redirectRouteConfiguration", "[", "'route'", "]", ")", "->", "addArgument", "(", "$", "redirectRouteConfiguration", "[", "'order_append'", "]", ")", "->", "addArgument", "(", "$", "redirectRouteConfiguration", "[", "'order_append_field'", "]", ")", ";", "$", "collectionDefinition", "->", "addMethodCall", "(", "'addRedirectionRoute'", ",", "[", "new", "Reference", "(", "$", "serviceName", ")", ",", "$", "redirectRouteName", ",", "]", ")", ";", "}", "}" ]
Create a new service for the RedirectRoutes collection given a configuration array. This method will register each redirection route in a separated service and will create a new service for the collection The value entered must have this format [ 'name' => [ 'route' => 'xxx', 'order_append' => 'xxx', 'order_append_field' => 'xxx', ], [ 'name2' => [ 'route' => 'xxx', 'order_append' => 'xxx', 'order_append_field' => 'xxx', ] Definitions will have this format paymentsuite.{paymentName}.routes paymentsuite.{paymentName}.route_success paymentsuite.{paymentName}.route_failure @param ContainerBuilder $containerBuilder Container builder @param string $paymentName Payment name @param array $redirectionRoutesConfiguration Redirection routes configuration
[ "Create", "a", "new", "service", "for", "the", "RedirectRoutes", "collection", "given", "a", "configuration", "array", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteExtension.php#L57-L87
231,297
PaymentSuite/paymentsuite
src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteExtension.php
AbstractPaymentSuiteExtension.addParameters
protected function addParameters( ContainerBuilder $containerBuilder, $paymentName, array $configuration ) { foreach ($configuration as $key => $value) { $parameterName = '' === $paymentName ? "paymentsuite.$key" : "paymentsuite.$paymentName.$key"; $containerBuilder->setParameter( $parameterName, $value ); } }
php
protected function addParameters( ContainerBuilder $containerBuilder, $paymentName, array $configuration ) { foreach ($configuration as $key => $value) { $parameterName = '' === $paymentName ? "paymentsuite.$key" : "paymentsuite.$paymentName.$key"; $containerBuilder->setParameter( $parameterName, $value ); } }
[ "protected", "function", "addParameters", "(", "ContainerBuilder", "$", "containerBuilder", ",", "$", "paymentName", ",", "array", "$", "configuration", ")", "{", "foreach", "(", "$", "configuration", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "parameterName", "=", "''", "===", "$", "paymentName", "?", "\"paymentsuite.$key\"", ":", "\"paymentsuite.$paymentName.$key\"", ";", "$", "containerBuilder", "->", "setParameter", "(", "$", "parameterName", ",", "$", "value", ")", ";", "}", "}" ]
Add parameters and values in a bulk way. @param ContainerBuilder $containerBuilder Container builder @param string $paymentName Payment name @param array $configuration Configuration
[ "Add", "parameters", "and", "values", "in", "a", "bulk", "way", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/PaymentCoreBundle/DependencyInjection/Abstracts/AbstractPaymentSuiteExtension.php#L96-L111
231,298
PaymentSuite/paymentsuite
src/PaymentSuite/BankwireBundle/Services/BankwireManager.php
BankwireManager.processPayment
public function processPayment() { $bankwireMethod = $this ->methodFactory ->create(); /** * At this point, order must be created given a cart, and placed in PaymentBridge. * * So, $this->paymentBridge->getOrder() must return an object */ $this ->paymentEventDispatcher ->notifyPaymentOrderLoad( $this->paymentBridge, $bankwireMethod ); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Order exists right here. */ $this ->paymentEventDispatcher ->notifyPaymentOrderCreated( $this->paymentBridge, $bankwireMethod ); /** * Payment paid done. * * Paid process has ended ( No matters result ) */ $this ->paymentEventDispatcher ->notifyPaymentOrderDone( $this->paymentBridge, $bankwireMethod ); return $this; }
php
public function processPayment() { $bankwireMethod = $this ->methodFactory ->create(); /** * At this point, order must be created given a cart, and placed in PaymentBridge. * * So, $this->paymentBridge->getOrder() must return an object */ $this ->paymentEventDispatcher ->notifyPaymentOrderLoad( $this->paymentBridge, $bankwireMethod ); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Order exists right here. */ $this ->paymentEventDispatcher ->notifyPaymentOrderCreated( $this->paymentBridge, $bankwireMethod ); /** * Payment paid done. * * Paid process has ended ( No matters result ) */ $this ->paymentEventDispatcher ->notifyPaymentOrderDone( $this->paymentBridge, $bankwireMethod ); return $this; }
[ "public", "function", "processPayment", "(", ")", "{", "$", "bankwireMethod", "=", "$", "this", "->", "methodFactory", "->", "create", "(", ")", ";", "/**\n * At this point, order must be created given a cart, and placed in PaymentBridge.\n *\n * So, $this->paymentBridge->getOrder() must return an object\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderLoad", "(", "$", "this", "->", "paymentBridge", ",", "$", "bankwireMethod", ")", ";", "/**\n * Order Not found Exception must be thrown just here.\n */", "if", "(", "!", "$", "this", "->", "paymentBridge", "->", "getOrder", "(", ")", ")", "{", "throw", "new", "PaymentOrderNotFoundException", "(", ")", ";", "}", "/**\n * Order exists right here.\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderCreated", "(", "$", "this", "->", "paymentBridge", ",", "$", "bankwireMethod", ")", ";", "/**\n * Payment paid done.\n *\n * Paid process has ended ( No matters result )\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderDone", "(", "$", "this", "->", "paymentBridge", ",", "$", "bankwireMethod", ")", ";", "return", "$", "this", ";", "}" ]
Tries to process a payment through Bankwire. @return BankwireManager Self object @throws PaymentOrderNotFoundException
[ "Tries", "to", "process", "a", "payment", "through", "Bankwire", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/BankwireBundle/Services/BankwireManager.php#L72-L120
231,299
PaymentSuite/paymentsuite
src/PaymentSuite/BankwireBundle/Services/BankwireManager.php
BankwireManager.validatePayment
public function validatePayment($orderId) { /** * Loads order to validate. */ $this ->paymentBridge ->findOrder($orderId); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Payment paid successfully. * * Paid process has ended successfully */ $this ->paymentEventDispatcher ->notifyPaymentOrderSuccess( $this->paymentBridge, $this ->methodFactory ->create() ); return $this; }
php
public function validatePayment($orderId) { /** * Loads order to validate. */ $this ->paymentBridge ->findOrder($orderId); /** * Order Not found Exception must be thrown just here. */ if (!$this->paymentBridge->getOrder()) { throw new PaymentOrderNotFoundException(); } /** * Payment paid successfully. * * Paid process has ended successfully */ $this ->paymentEventDispatcher ->notifyPaymentOrderSuccess( $this->paymentBridge, $this ->methodFactory ->create() ); return $this; }
[ "public", "function", "validatePayment", "(", "$", "orderId", ")", "{", "/**\n * Loads order to validate.\n */", "$", "this", "->", "paymentBridge", "->", "findOrder", "(", "$", "orderId", ")", ";", "/**\n * Order Not found Exception must be thrown just here.\n */", "if", "(", "!", "$", "this", "->", "paymentBridge", "->", "getOrder", "(", ")", ")", "{", "throw", "new", "PaymentOrderNotFoundException", "(", ")", ";", "}", "/**\n * Payment paid successfully.\n *\n * Paid process has ended successfully\n */", "$", "this", "->", "paymentEventDispatcher", "->", "notifyPaymentOrderSuccess", "(", "$", "this", "->", "paymentBridge", ",", "$", "this", "->", "methodFactory", "->", "create", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Validates payment, given an Id of an existing order. @param int $orderId Id from order to validate @return BankwireManager self Object @throws PaymentOrderNotFoundException
[ "Validates", "payment", "given", "an", "Id", "of", "an", "existing", "order", "." ]
8ae57df57fa07aff7e59701a0b3c83c504095b92
https://github.com/PaymentSuite/paymentsuite/blob/8ae57df57fa07aff7e59701a0b3c83c504095b92/src/PaymentSuite/BankwireBundle/Services/BankwireManager.php#L131-L162