repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
colorium/web
src/Colorium/Web/App.php
App.render
protected function render(Context $context) { $this->logger->debug('kernel.process.render: render Response'); // resolve output format if($context->response->raw) { // template if($template = $context->logic->html) { // render template $vars = $context->response->content; $vars = is_array($vars) ? $vars : (array)$vars; $content = $this->templater->render($template, $vars); // set html response $context->response = new Response\Html($content, $context->response->code, $context->response->headers); $this->logger->debug('kernel.process.render: template "' . $template . '" compiled'); } // json elseif($context->logic->render = 'json') { $context->response = new Response\Json($context->response->content, $context->response->code, $context->response->headers); $this->logger->debug('kernel.process.render: json response generated'); } // remove auto-generated flag $context->response->raw = false; } // render template elseif($context->response instanceof Response\Template) { $context->response->content = $this->templater->render($context->response->template, $context->response->vars); } // render redirect elseif($context->response instanceof Response\Redirect and $context->response->uri[0] == '/') { $context->response->uri = $context->request->uri->make($context->response->uri); } return $context; }
php
protected function render(Context $context) { $this->logger->debug('kernel.process.render: render Response'); // resolve output format if($context->response->raw) { // template if($template = $context->logic->html) { // render template $vars = $context->response->content; $vars = is_array($vars) ? $vars : (array)$vars; $content = $this->templater->render($template, $vars); // set html response $context->response = new Response\Html($content, $context->response->code, $context->response->headers); $this->logger->debug('kernel.process.render: template "' . $template . '" compiled'); } // json elseif($context->logic->render = 'json') { $context->response = new Response\Json($context->response->content, $context->response->code, $context->response->headers); $this->logger->debug('kernel.process.render: json response generated'); } // remove auto-generated flag $context->response->raw = false; } // render template elseif($context->response instanceof Response\Template) { $context->response->content = $this->templater->render($context->response->template, $context->response->vars); } // render redirect elseif($context->response instanceof Response\Redirect and $context->response->uri[0] == '/') { $context->response->uri = $context->request->uri->make($context->response->uri); } return $context; }
[ "protected", "function", "render", "(", "Context", "$", "context", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'kernel.process.render: render Response'", ")", ";", "// resolve output format", "if", "(", "$", "context", "->", "response", "->", "raw", ")", "{", "// template", "if", "(", "$", "template", "=", "$", "context", "->", "logic", "->", "html", ")", "{", "// render template", "$", "vars", "=", "$", "context", "->", "response", "->", "content", ";", "$", "vars", "=", "is_array", "(", "$", "vars", ")", "?", "$", "vars", ":", "(", "array", ")", "$", "vars", ";", "$", "content", "=", "$", "this", "->", "templater", "->", "render", "(", "$", "template", ",", "$", "vars", ")", ";", "// set html response", "$", "context", "->", "response", "=", "new", "Response", "\\", "Html", "(", "$", "content", ",", "$", "context", "->", "response", "->", "code", ",", "$", "context", "->", "response", "->", "headers", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'kernel.process.render: template \"'", ".", "$", "template", ".", "'\" compiled'", ")", ";", "}", "// json", "elseif", "(", "$", "context", "->", "logic", "->", "render", "=", "'json'", ")", "{", "$", "context", "->", "response", "=", "new", "Response", "\\", "Json", "(", "$", "context", "->", "response", "->", "content", ",", "$", "context", "->", "response", "->", "code", ",", "$", "context", "->", "response", "->", "headers", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'kernel.process.render: json response generated'", ")", ";", "}", "// remove auto-generated flag", "$", "context", "->", "response", "->", "raw", "=", "false", ";", "}", "// render template", "elseif", "(", "$", "context", "->", "response", "instanceof", "Response", "\\", "Template", ")", "{", "$", "context", "->", "response", "->", "content", "=", "$", "this", "->", "templater", "->", "render", "(", "$", "context", "->", "response", "->", "template", ",", "$", "context", "->", "response", "->", "vars", ")", ";", "}", "// render redirect", "elseif", "(", "$", "context", "->", "response", "instanceof", "Response", "\\", "Redirect", "and", "$", "context", "->", "response", "->", "uri", "[", "0", "]", "==", "'/'", ")", "{", "$", "context", "->", "response", "->", "uri", "=", "$", "context", "->", "request", "->", "uri", "->", "make", "(", "$", "context", "->", "response", "->", "uri", ")", ";", "}", "return", "$", "context", ";", "}" ]
Render response @param Context $context @return Context
[ "Render", "response" ]
train
https://github.com/colorium/web/blob/2a767658b8737022939b0cc4505b5f652c1683d2/src/Colorium/Web/App.php#L58-L96
mslib/resource-proxy
Msl/ResourceProxy/Source/Imap.php
Imap.setConfig
public function setConfig(SourceConfig $sourceConfig) { // FILTERS // 1. Setting message status filter $filters = $sourceConfig->getFilter(); if (isset($filters[self::MESSAGES_STATUS_FILTER])) { $messageStatus = $filters[self::MESSAGES_STATUS_FILTER]; if ($messageStatus === self::UNREAD_ONLY_MESSAGES_FILTER) { $this->unreadOnly = true; } } // 2. Setting folder filter if (isset($filters[self::FOLDER_FILTER])) { $this->folder = $filters[self::FOLDER_FILTER]; } // Calling parent method to set the rest of the required configuration parent::setConfig($sourceConfig); }
php
public function setConfig(SourceConfig $sourceConfig) { // FILTERS // 1. Setting message status filter $filters = $sourceConfig->getFilter(); if (isset($filters[self::MESSAGES_STATUS_FILTER])) { $messageStatus = $filters[self::MESSAGES_STATUS_FILTER]; if ($messageStatus === self::UNREAD_ONLY_MESSAGES_FILTER) { $this->unreadOnly = true; } } // 2. Setting folder filter if (isset($filters[self::FOLDER_FILTER])) { $this->folder = $filters[self::FOLDER_FILTER]; } // Calling parent method to set the rest of the required configuration parent::setConfig($sourceConfig); }
[ "public", "function", "setConfig", "(", "SourceConfig", "$", "sourceConfig", ")", "{", "// FILTERS", "// 1. Setting message status filter", "$", "filters", "=", "$", "sourceConfig", "->", "getFilter", "(", ")", ";", "if", "(", "isset", "(", "$", "filters", "[", "self", "::", "MESSAGES_STATUS_FILTER", "]", ")", ")", "{", "$", "messageStatus", "=", "$", "filters", "[", "self", "::", "MESSAGES_STATUS_FILTER", "]", ";", "if", "(", "$", "messageStatus", "===", "self", "::", "UNREAD_ONLY_MESSAGES_FILTER", ")", "{", "$", "this", "->", "unreadOnly", "=", "true", ";", "}", "}", "// 2. Setting folder filter", "if", "(", "isset", "(", "$", "filters", "[", "self", "::", "FOLDER_FILTER", "]", ")", ")", "{", "$", "this", "->", "folder", "=", "$", "filters", "[", "self", "::", "FOLDER_FILTER", "]", ";", "}", "// Calling parent method to set the rest of the required configuration", "parent", "::", "setConfig", "(", "$", "sourceConfig", ")", ";", "}" ]
Sets all the required parameters to configure a given Source instance. @param SourceConfig $sourceConfig @throws \Msl\ResourceProxy\Exception\BadSourceConfigurationException @return void
[ "Sets", "all", "the", "required", "parameters", "to", "configure", "a", "given", "Source", "instance", "." ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Imap.php#L43-L61
mslib/resource-proxy
Msl/ResourceProxy/Source/Imap.php
Imap.getContentIterator
public function getContentIterator() { // Initializing output array $output = new \ArrayIterator(); // Getting total number of messages $maxMessage = $this->storage->countMessages(); for($i=1; $i<=$maxMessage; $i++) { // Getting the message object $message = $this->storage->getMessage($i); if ($message instanceof \Zend\Mail\Storage\Message) { // Adding only unread messages to result iterator if ($this->unreadOnly && $message->hasFlag(ZendStorage::FLAG_SEEN)) { continue; } // Wrapping the result object into an appropriate ResourceInterface instance try { $imapMessage = new ImapMessage(); $imapMessage->init($this->getName(), $i, $message); } catch (\Exception $e) { throw new Exception\SourceGetContentException( sprintf( 'Error while getting the content for the resource unique id \'%s\'. Exception is: \'%s\'.', $i, $e->getMessage() ) ); } // Adding the wrapping object to the result iterator $output->append($imapMessage); } } // Returning the result iterator return $output; }
php
public function getContentIterator() { // Initializing output array $output = new \ArrayIterator(); // Getting total number of messages $maxMessage = $this->storage->countMessages(); for($i=1; $i<=$maxMessage; $i++) { // Getting the message object $message = $this->storage->getMessage($i); if ($message instanceof \Zend\Mail\Storage\Message) { // Adding only unread messages to result iterator if ($this->unreadOnly && $message->hasFlag(ZendStorage::FLAG_SEEN)) { continue; } // Wrapping the result object into an appropriate ResourceInterface instance try { $imapMessage = new ImapMessage(); $imapMessage->init($this->getName(), $i, $message); } catch (\Exception $e) { throw new Exception\SourceGetContentException( sprintf( 'Error while getting the content for the resource unique id \'%s\'. Exception is: \'%s\'.', $i, $e->getMessage() ) ); } // Adding the wrapping object to the result iterator $output->append($imapMessage); } } // Returning the result iterator return $output; }
[ "public", "function", "getContentIterator", "(", ")", "{", "// Initializing output array", "$", "output", "=", "new", "\\", "ArrayIterator", "(", ")", ";", "// Getting total number of messages", "$", "maxMessage", "=", "$", "this", "->", "storage", "->", "countMessages", "(", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "$", "maxMessage", ";", "$", "i", "++", ")", "{", "// Getting the message object", "$", "message", "=", "$", "this", "->", "storage", "->", "getMessage", "(", "$", "i", ")", ";", "if", "(", "$", "message", "instanceof", "\\", "Zend", "\\", "Mail", "\\", "Storage", "\\", "Message", ")", "{", "// Adding only unread messages to result iterator", "if", "(", "$", "this", "->", "unreadOnly", "&&", "$", "message", "->", "hasFlag", "(", "ZendStorage", "::", "FLAG_SEEN", ")", ")", "{", "continue", ";", "}", "// Wrapping the result object into an appropriate ResourceInterface instance", "try", "{", "$", "imapMessage", "=", "new", "ImapMessage", "(", ")", ";", "$", "imapMessage", "->", "init", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "i", ",", "$", "message", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "\\", "SourceGetContentException", "(", "sprintf", "(", "'Error while getting the content for the resource unique id \\'%s\\'. Exception is: \\'%s\\'.'", ",", "$", "i", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "// Adding the wrapping object to the result iterator", "$", "output", "->", "append", "(", "$", "imapMessage", ")", ";", "}", "}", "// Returning the result iterator", "return", "$", "output", ";", "}" ]
Returns an Iterator instance for a list of Resource instances. (in this case, list of emails to be parsed) @throws \Exception @return mixed
[ "Returns", "an", "Iterator", "instance", "for", "a", "list", "of", "Resource", "instances", ".", "(", "in", "this", "case", "list", "of", "emails", "to", "be", "parsed", ")" ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Imap.php#L71-L110
mslib/resource-proxy
Msl/ResourceProxy/Source/Imap.php
Imap.postParseUnitAction
public function postParseUnitAction($uniqueId, $success = true) { // Setting parsed message flag to SEEN $result = new ParseResult(); try { if ($success) { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_SEEN)); } else { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_RECENT)); } } catch (\Exception $e) { $result->setResult(false); $result->setMessage($e->getMessage()); $result->setCode($e->getCode()); } // Returning the result object return $result; }
php
public function postParseUnitAction($uniqueId, $success = true) { // Setting parsed message flag to SEEN $result = new ParseResult(); try { if ($success) { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_SEEN)); } else { $this->storage->setFlags($uniqueId, array(ZendStorage::FLAG_RECENT)); } } catch (\Exception $e) { $result->setResult(false); $result->setMessage($e->getMessage()); $result->setCode($e->getCode()); } // Returning the result object return $result; }
[ "public", "function", "postParseUnitAction", "(", "$", "uniqueId", ",", "$", "success", "=", "true", ")", "{", "// Setting parsed message flag to SEEN", "$", "result", "=", "new", "ParseResult", "(", ")", ";", "try", "{", "if", "(", "$", "success", ")", "{", "$", "this", "->", "storage", "->", "setFlags", "(", "$", "uniqueId", ",", "array", "(", "ZendStorage", "::", "FLAG_SEEN", ")", ")", ";", "}", "else", "{", "$", "this", "->", "storage", "->", "setFlags", "(", "$", "uniqueId", ",", "array", "(", "ZendStorage", "::", "FLAG_RECENT", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "result", "->", "setResult", "(", "false", ")", ";", "$", "result", "->", "setMessage", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "result", "->", "setCode", "(", "$", "e", "->", "getCode", "(", ")", ")", ";", "}", "// Returning the result object", "return", "$", "result", ";", "}" ]
Action to be run after a single set of data retrieved from the remote source has been parsed. @param string $uniqueId Unique id of the single set to be treated (e.g. unique id of a message in a mail box) @param bool $success True if the data of a given resource have been downloaded and used correctly; false otherwise. @return \Msl\ResourceProxy\Source\Parse\ParseResult|void
[ "Action", "to", "be", "run", "after", "a", "single", "set", "of", "data", "retrieved", "from", "the", "remote", "source", "has", "been", "parsed", "." ]
train
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Source/Imap.php#L120-L138
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.render
public function render($slug, $data = []) { $this->current_view = $this->get_template_name($slug); $data = $this->add_default_data($data); echo $this->blade->run($this->current_view, $data); // Now a view has been rendered, reset the current_view context. $this->current_view = null; }
php
public function render($slug, $data = []) { $this->current_view = $this->get_template_name($slug); $data = $this->add_default_data($data); echo $this->blade->run($this->current_view, $data); // Now a view has been rendered, reset the current_view context. $this->current_view = null; }
[ "public", "function", "render", "(", "$", "slug", ",", "$", "data", "=", "[", "]", ")", "{", "$", "this", "->", "current_view", "=", "$", "this", "->", "get_template_name", "(", "$", "slug", ")", ";", "$", "data", "=", "$", "this", "->", "add_default_data", "(", "$", "data", ")", ";", "echo", "$", "this", "->", "blade", "->", "run", "(", "$", "this", "->", "current_view", ",", "$", "data", ")", ";", "// Now a view has been rendered, reset the current_view context.", "$", "this", "->", "current_view", "=", "null", ";", "}" ]
Renders a view. @since 1.0.0 @param string $slug The slug for the generic template. @param array $data Optional. Additional data to pass to a partial. Available in the partial as $data. @throws \Exception
[ "Renders", "a", "view", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L45-L55
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.partial
public function partial($slug, $data = []) { $data = $this->add_default_data($data); // Check if this is being run outside of a view context. if ($this->current_view === null) { echo $this->blade->run('partials.' . $this->bladeify($slug), $data); return; } echo $this->blade->runChild('partials.' . $this->bladeify($slug), $data); }
php
public function partial($slug, $data = []) { $data = $this->add_default_data($data); // Check if this is being run outside of a view context. if ($this->current_view === null) { echo $this->blade->run('partials.' . $this->bladeify($slug), $data); return; } echo $this->blade->runChild('partials.' . $this->bladeify($slug), $data); }
[ "public", "function", "partial", "(", "$", "slug", ",", "$", "data", "=", "[", "]", ")", "{", "$", "data", "=", "$", "this", "->", "add_default_data", "(", "$", "data", ")", ";", "// Check if this is being run outside of a view context.", "if", "(", "$", "this", "->", "current_view", "===", "null", ")", "{", "echo", "$", "this", "->", "blade", "->", "run", "(", "'partials.'", ".", "$", "this", "->", "bladeify", "(", "$", "slug", ")", ",", "$", "data", ")", ";", "return", ";", "}", "echo", "$", "this", "->", "blade", "->", "runChild", "(", "'partials.'", ".", "$", "this", "->", "bladeify", "(", "$", "slug", ")", ",", "$", "data", ")", ";", "}" ]
Fetch and display a template partial. @since 1.0.0 @param string $slug The slug for the generic template. @param array $data Optional. Additional data to pass to a partial. Available in the partial as $data. @throws \Exception
[ "Fetch", "and", "display", "a", "template", "partial", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L66-L77
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.get_template_name
public function get_template_name($slug) { $slug = \str_replace( [ Config::get('theme.templates_directory') . '/', $this->blade->getFileExtension(), ], '', $slug ); if (\strpos($slug, 'views/') !== 0) { $slug = 'views.' . $slug; } return $this->bladeify($slug); }
php
public function get_template_name($slug) { $slug = \str_replace( [ Config::get('theme.templates_directory') . '/', $this->blade->getFileExtension(), ], '', $slug ); if (\strpos($slug, 'views/') !== 0) { $slug = 'views.' . $slug; } return $this->bladeify($slug); }
[ "public", "function", "get_template_name", "(", "$", "slug", ")", "{", "$", "slug", "=", "\\", "str_replace", "(", "[", "Config", "::", "get", "(", "'theme.templates_directory'", ")", ".", "'/'", ",", "$", "this", "->", "blade", "->", "getFileExtension", "(", ")", ",", "]", ",", "''", ",", "$", "slug", ")", ";", "if", "(", "\\", "strpos", "(", "$", "slug", ",", "'views/'", ")", "!==", "0", ")", "{", "$", "slug", "=", "'views.'", ".", "$", "slug", ";", "}", "return", "$", "this", "->", "bladeify", "(", "$", "slug", ")", ";", "}" ]
Generate the template file name from the slug. @since 1.0.0 @param string $slug The slug for the generic template. @return string
[ "Generate", "the", "template", "file", "name", "from", "the", "slug", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L87-L103
snapwp/snap-blade
src/Blade_Strategy.php
Blade_Strategy.add_default_data
private function add_default_data($data = []) { global $wp_query, $post; $data['wp_query'] = $wp_query; $data['post'] = &$post; $data['current_view'] = $this->current_view; $data['request'] = Request::get_root_instance(); $data['errors'] = Validation::$errors; return $data; }
php
private function add_default_data($data = []) { global $wp_query, $post; $data['wp_query'] = $wp_query; $data['post'] = &$post; $data['current_view'] = $this->current_view; $data['request'] = Request::get_root_instance(); $data['errors'] = Validation::$errors; return $data; }
[ "private", "function", "add_default_data", "(", "$", "data", "=", "[", "]", ")", "{", "global", "$", "wp_query", ",", "$", "post", ";", "$", "data", "[", "'wp_query'", "]", "=", "$", "wp_query", ";", "$", "data", "[", "'post'", "]", "=", "&", "$", "post", ";", "$", "data", "[", "'current_view'", "]", "=", "$", "this", "->", "current_view", ";", "$", "data", "[", "'request'", "]", "=", "Request", "::", "get_root_instance", "(", ")", ";", "$", "data", "[", "'errors'", "]", "=", "Validation", "::", "$", "errors", ";", "return", "$", "data", ";", "}" ]
Add default data to template. @since 1.0.0 @param array $data Data array. @return array
[ "Add", "default", "data", "to", "template", "." ]
train
https://github.com/snapwp/snap-blade/blob/41e004e93440f6b58638b64dc8d20cca4a0546fa/src/Blade_Strategy.php#L125-L136
DataDo/data
src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php
DefaultMethodNameParser.parse
public function parse($methodName) { return new MethodNameToken( $methodName, $this->getQueryMode($methodName), $this->getTokens($methodName) ); }
php
public function parse($methodName) { return new MethodNameToken( $methodName, $this->getQueryMode($methodName), $this->getTokens($methodName) ); }
[ "public", "function", "parse", "(", "$", "methodName", ")", "{", "return", "new", "MethodNameToken", "(", "$", "methodName", ",", "$", "this", "->", "getQueryMode", "(", "$", "methodName", ")", ",", "$", "this", "->", "getTokens", "(", "$", "methodName", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php#L25-L32
DataDo/data
src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php
DefaultMethodNameParser.getTokens
private function getTokens($methodName) { preg_match_all('([A-Z_-][^A-Z_-]*)', $methodName, $rawTokens); $result = array(); $lastToken = null; $seenBy = false; foreach ($rawTokens[0] as $token) { $newToken = $this->getToken($token, $seenBy); if ($newToken instanceof ValueToken) { $lastToken = $lastToken !== null && $lastToken instanceof ValueToken ? new ValueToken($lastToken->getSource() . $newToken->getSource()) : $newToken; } else { if ($lastToken instanceof ValueToken) { // Add the last token too $result[] = $lastToken; $lastToken = null; } $result[] = $newToken; } } if ($lastToken !== null) { $result[] = $lastToken; } return $result; }
php
private function getTokens($methodName) { preg_match_all('([A-Z_-][^A-Z_-]*)', $methodName, $rawTokens); $result = array(); $lastToken = null; $seenBy = false; foreach ($rawTokens[0] as $token) { $newToken = $this->getToken($token, $seenBy); if ($newToken instanceof ValueToken) { $lastToken = $lastToken !== null && $lastToken instanceof ValueToken ? new ValueToken($lastToken->getSource() . $newToken->getSource()) : $newToken; } else { if ($lastToken instanceof ValueToken) { // Add the last token too $result[] = $lastToken; $lastToken = null; } $result[] = $newToken; } } if ($lastToken !== null) { $result[] = $lastToken; } return $result; }
[ "private", "function", "getTokens", "(", "$", "methodName", ")", "{", "preg_match_all", "(", "'([A-Z_-][^A-Z_-]*)'", ",", "$", "methodName", ",", "$", "rawTokens", ")", ";", "$", "result", "=", "array", "(", ")", ";", "$", "lastToken", "=", "null", ";", "$", "seenBy", "=", "false", ";", "foreach", "(", "$", "rawTokens", "[", "0", "]", "as", "$", "token", ")", "{", "$", "newToken", "=", "$", "this", "->", "getToken", "(", "$", "token", ",", "$", "seenBy", ")", ";", "if", "(", "$", "newToken", "instanceof", "ValueToken", ")", "{", "$", "lastToken", "=", "$", "lastToken", "!==", "null", "&&", "$", "lastToken", "instanceof", "ValueToken", "?", "new", "ValueToken", "(", "$", "lastToken", "->", "getSource", "(", ")", ".", "$", "newToken", "->", "getSource", "(", ")", ")", ":", "$", "newToken", ";", "}", "else", "{", "if", "(", "$", "lastToken", "instanceof", "ValueToken", ")", "{", "// Add the last token too", "$", "result", "[", "]", "=", "$", "lastToken", ";", "$", "lastToken", "=", "null", ";", "}", "$", "result", "[", "]", "=", "$", "newToken", ";", "}", "}", "if", "(", "$", "lastToken", "!==", "null", ")", "{", "$", "result", "[", "]", "=", "$", "lastToken", ";", "}", "return", "$", "result", ";", "}" ]
Split the method name into tokens and parse them. @param $methodName string the method name @return Token[]
[ "Split", "the", "method", "name", "into", "tokens", "and", "parse", "them", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php#L50-L79
DataDo/data
src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php
DefaultMethodNameParser.getToken
private function getToken($token, &$hasSeenBy) { switch ($token) { case 'And': return new AndToken(); case 'Or': return new OrToken(); case 'By': case 'Where': $hasSeenBy = true; return new ByToken(); case 'All': return new AllToken(); case 'Distinct': if ($hasSeenBy) { return new ValueToken($token); } else { return new DistinctToken(); } case 'Like': if ($hasSeenBy) { return new LikeToken(); } else { return new ValueToken($token); } default: return new ValueToken($token); } }
php
private function getToken($token, &$hasSeenBy) { switch ($token) { case 'And': return new AndToken(); case 'Or': return new OrToken(); case 'By': case 'Where': $hasSeenBy = true; return new ByToken(); case 'All': return new AllToken(); case 'Distinct': if ($hasSeenBy) { return new ValueToken($token); } else { return new DistinctToken(); } case 'Like': if ($hasSeenBy) { return new LikeToken(); } else { return new ValueToken($token); } default: return new ValueToken($token); } }
[ "private", "function", "getToken", "(", "$", "token", ",", "&", "$", "hasSeenBy", ")", "{", "switch", "(", "$", "token", ")", "{", "case", "'And'", ":", "return", "new", "AndToken", "(", ")", ";", "case", "'Or'", ":", "return", "new", "OrToken", "(", ")", ";", "case", "'By'", ":", "case", "'Where'", ":", "$", "hasSeenBy", "=", "true", ";", "return", "new", "ByToken", "(", ")", ";", "case", "'All'", ":", "return", "new", "AllToken", "(", ")", ";", "case", "'Distinct'", ":", "if", "(", "$", "hasSeenBy", ")", "{", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "else", "{", "return", "new", "DistinctToken", "(", ")", ";", "}", "case", "'Like'", ":", "if", "(", "$", "hasSeenBy", ")", "{", "return", "new", "LikeToken", "(", ")", ";", "}", "else", "{", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "default", ":", "return", "new", "ValueToken", "(", "$", "token", ")", ";", "}", "}" ]
Translate a token source to a token object. @param $token string the token source @return Token the token object
[ "Translate", "a", "token", "source", "to", "a", "token", "object", "." ]
train
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Parser/DefaultMethodNameParser.php#L87-L115
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php
Parser.parse
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { $this->currentLineNb = -1; $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { throw new ParseException('The YAML value does not appear to be valid UTF-8.'); } if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('UTF-8'); } $data = array(); $context = null; while ($this->moveToNextLine()) { if ($this->isCurrentLineEmpty()) { continue; } // tab? if ("\t" === $this->currentLine[0]) { throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } $isRef = $isInPlace = $isProcessed = false; if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'mapping' == $context) { throw new ParseException('You cannot define a sequence item when in a mapping'); } $context = 'sequence'; if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } // array if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches) ) { // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); $parser = new Parser($c); $parser->refs =& $this->refs; $block = $values['value']; if ($this->isNextLineIndented()) { $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport); } else { $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } $context = 'mapping'; // force correct settings Inline::parse(null, $exceptionOnInvalidType, $objectSupport); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } if ('<<' === $key) { if (isset($values['value']) && 0 === strpos($values['value'], '*')) { $isInPlace = substr($values['value'], 1); if (!array_key_exists($isInPlace, $this->refs)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); } } else { if (isset($values['value']) && $values['value'] !== '') { $value = $values['value']; } else { $value = $this->getNextEmbedBlock(); } $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); $merged = array(); if (!is_array($parsed)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } elseif (isset($parsed[0])) { // Numeric array, merge individual elements foreach (array_reverse($parsed) as $parsedItem) { if (!is_array($parsedItem)) { throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); } $merged = array_merge($parsedItem, $merged); } } else { // Associative array, merge $merged = array_merge($merged, $parsed); } $isProcessed = $merged; } } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } if ($isProcessed) { // Merge keys $data = $isProcessed; // hash } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { $data[$key] = null; } else { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } } else { if ($isInPlace) { $data = $this->refs[$isInPlace]; } else { $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } else { // 1-liner optionally followed by newline $lineCount = count($this->lines); if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } if (is_array($value)) { $first = reset($value); if (is_string($first) && 0 === strpos($first, '*')) { $data = array(); foreach ($value as $alias) { $data[] = $this->refs[substr($alias, 1)]; } $value = $data; } } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $value; } switch (preg_last_error()) { case PREG_INTERNAL_ERROR: $error = 'Internal PCRE error.'; break; case PREG_BACKTRACK_LIMIT_ERROR: $error = 'pcre.backtrack_limit reached.'; break; case PREG_RECURSION_LIMIT_ERROR: $error = 'pcre.recursion_limit reached.'; break; case PREG_BAD_UTF8_ERROR: $error = 'Malformed UTF-8 data.'; break; case PREG_BAD_UTF8_OFFSET_ERROR: $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.'; break; default: $error = 'Unable to parse.'; } throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine); } if ($isRef) { $this->refs[$isRef] = end($data); } } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return empty($data) ? null : $data; }
php
public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false) { $this->currentLineNb = -1; $this->currentLine = ''; $this->lines = explode("\n", $this->cleanup($value)); if (function_exists('mb_detect_encoding') && false === mb_detect_encoding($value, 'UTF-8', true)) { throw new ParseException('The YAML value does not appear to be valid UTF-8.'); } if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) { $mbEncoding = mb_internal_encoding(); mb_internal_encoding('UTF-8'); } $data = array(); $context = null; while ($this->moveToNextLine()) { if ($this->isCurrentLineEmpty()) { continue; } // tab? if ("\t" === $this->currentLine[0]) { throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } $isRef = $isInPlace = $isProcessed = false; if (preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'mapping' == $context) { throw new ParseException('You cannot define a sequence item when in a mapping'); } $context = 'sequence'; if (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } // array if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $data[] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) && ' ' == $values['leadspaces'] && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches) ) { // this is a compact notation element, add to next block and parse $c = $this->getRealCurrentLineNb(); $parser = new Parser($c); $parser->refs =& $this->refs; $block = $values['value']; if ($this->isNextLineIndented()) { $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); } $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport); } else { $data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } elseif (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) { if ($context && 'sequence' == $context) { throw new ParseException('You cannot define a mapping item when in a sequence'); } $context = 'mapping'; // force correct settings Inline::parse(null, $exceptionOnInvalidType, $objectSupport); try { $key = Inline::parseScalar($values['key']); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } if ('<<' === $key) { if (isset($values['value']) && 0 === strpos($values['value'], '*')) { $isInPlace = substr($values['value'], 1); if (!array_key_exists($isInPlace, $this->refs)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $isInPlace), $this->getRealCurrentLineNb() + 1, $this->currentLine); } } else { if (isset($values['value']) && $values['value'] !== '') { $value = $values['value']; } else { $value = $this->getNextEmbedBlock(); } $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport); $merged = array(); if (!is_array($parsed)) { throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } elseif (isset($parsed[0])) { // Numeric array, merge individual elements foreach (array_reverse($parsed) as $parsedItem) { if (!is_array($parsedItem)) { throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem); } $merged = array_merge($parsedItem, $merged); } } else { // Associative array, merge $merged = array_merge($merged, $parsed); } $isProcessed = $merged; } } elseif (isset($values['value']) && preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) { $isRef = $matches['ref']; $values['value'] = $matches['value']; } if ($isProcessed) { // Merge keys $data = $isProcessed; // hash } elseif (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) { // if next line is less indented or equal, then it means that the current value is null if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) { $data[$key] = null; } else { $c = $this->getRealCurrentLineNb() + 1; $parser = new Parser($c); $parser->refs =& $this->refs; $data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport); } } else { if ($isInPlace) { $data = $this->refs[$isInPlace]; } else { $data[$key] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport); } } } else { // 1-liner optionally followed by newline $lineCount = count($this->lines); if (1 === $lineCount || (2 === $lineCount && empty($this->lines[1]))) { try { $value = Inline::parse($this->lines[0], $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } if (is_array($value)) { $first = reset($value); if (is_string($first) && 0 === strpos($first, '*')) { $data = array(); foreach ($value as $alias) { $data[] = $this->refs[substr($alias, 1)]; } $value = $data; } } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return $value; } switch (preg_last_error()) { case PREG_INTERNAL_ERROR: $error = 'Internal PCRE error.'; break; case PREG_BACKTRACK_LIMIT_ERROR: $error = 'pcre.backtrack_limit reached.'; break; case PREG_RECURSION_LIMIT_ERROR: $error = 'pcre.recursion_limit reached.'; break; case PREG_BAD_UTF8_ERROR: $error = 'Malformed UTF-8 data.'; break; case PREG_BAD_UTF8_OFFSET_ERROR: $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.'; break; default: $error = 'Unable to parse.'; } throw new ParseException($error, $this->getRealCurrentLineNb() + 1, $this->currentLine); } if ($isRef) { $this->refs[$isRef] = end($data); } } if (isset($mbEncoding)) { mb_internal_encoding($mbEncoding); } return empty($data) ? null : $data; }
[ "public", "function", "parse", "(", "$", "value", ",", "$", "exceptionOnInvalidType", "=", "false", ",", "$", "objectSupport", "=", "false", ")", "{", "$", "this", "->", "currentLineNb", "=", "-", "1", ";", "$", "this", "->", "currentLine", "=", "''", ";", "$", "this", "->", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "cleanup", "(", "$", "value", ")", ")", ";", "if", "(", "function_exists", "(", "'mb_detect_encoding'", ")", "&&", "false", "===", "mb_detect_encoding", "(", "$", "value", ",", "'UTF-8'", ",", "true", ")", ")", "{", "throw", "new", "ParseException", "(", "'The YAML value does not appear to be valid UTF-8.'", ")", ";", "}", "if", "(", "function_exists", "(", "'mb_internal_encoding'", ")", "&&", "(", "(", "int", ")", "ini_get", "(", "'mbstring.func_overload'", ")", ")", "&", "2", ")", "{", "$", "mbEncoding", "=", "mb_internal_encoding", "(", ")", ";", "mb_internal_encoding", "(", "'UTF-8'", ")", ";", "}", "$", "data", "=", "array", "(", ")", ";", "$", "context", "=", "null", ";", "while", "(", "$", "this", "->", "moveToNextLine", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isCurrentLineEmpty", "(", ")", ")", "{", "continue", ";", "}", "// tab?", "if", "(", "\"\\t\"", "===", "$", "this", "->", "currentLine", "[", "0", "]", ")", "{", "throw", "new", "ParseException", "(", "'A YAML file cannot contain tabs as indentation.'", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "$", "isRef", "=", "$", "isInPlace", "=", "$", "isProcessed", "=", "false", ";", "if", "(", "preg_match", "(", "'#^\\-((?P<leadspaces>\\s+)(?P<value>.+?))?\\s*$#u'", ",", "$", "this", "->", "currentLine", ",", "$", "values", ")", ")", "{", "if", "(", "$", "context", "&&", "'mapping'", "==", "$", "context", ")", "{", "throw", "new", "ParseException", "(", "'You cannot define a sequence item when in a mapping'", ")", ";", "}", "$", "context", "=", "'sequence'", ";", "if", "(", "isset", "(", "$", "values", "[", "'value'", "]", ")", "&&", "preg_match", "(", "'#^&(?P<ref>[^ ]+) *(?P<value>.*)#u'", ",", "$", "values", "[", "'value'", "]", ",", "$", "matches", ")", ")", "{", "$", "isRef", "=", "$", "matches", "[", "'ref'", "]", ";", "$", "values", "[", "'value'", "]", "=", "$", "matches", "[", "'value'", "]", ";", "}", "// array", "if", "(", "!", "isset", "(", "$", "values", "[", "'value'", "]", ")", "||", "''", "==", "trim", "(", "$", "values", "[", "'value'", "]", ",", "' '", ")", "||", "0", "===", "strpos", "(", "ltrim", "(", "$", "values", "[", "'value'", "]", ",", "' '", ")", ",", "'#'", ")", ")", "{", "$", "c", "=", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ";", "$", "parser", "=", "new", "Parser", "(", "$", "c", ")", ";", "$", "parser", "->", "refs", "=", "&", "$", "this", "->", "refs", ";", "$", "data", "[", "]", "=", "$", "parser", "->", "parse", "(", "$", "this", "->", "getNextEmbedBlock", "(", ")", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "values", "[", "'leadspaces'", "]", ")", "&&", "' '", "==", "$", "values", "[", "'leadspaces'", "]", "&&", "preg_match", "(", "'#^(?P<key>'", ".", "Inline", "::", "REGEX_QUOTED_STRING", ".", "'|[^ \\'\"\\{\\[].*?) *\\:(\\s+(?P<value>.+?))?\\s*$#u'", ",", "$", "values", "[", "'value'", "]", ",", "$", "matches", ")", ")", "{", "// this is a compact notation element, add to next block and parse", "$", "c", "=", "$", "this", "->", "getRealCurrentLineNb", "(", ")", ";", "$", "parser", "=", "new", "Parser", "(", "$", "c", ")", ";", "$", "parser", "->", "refs", "=", "&", "$", "this", "->", "refs", ";", "$", "block", "=", "$", "values", "[", "'value'", "]", ";", "if", "(", "$", "this", "->", "isNextLineIndented", "(", ")", ")", "{", "$", "block", ".=", "\"\\n\"", ".", "$", "this", "->", "getNextEmbedBlock", "(", "$", "this", "->", "getCurrentLineIndentation", "(", ")", "+", "2", ")", ";", "}", "$", "data", "[", "]", "=", "$", "parser", "->", "parse", "(", "$", "block", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "else", "{", "$", "data", "[", "]", "=", "$", "this", "->", "parseValue", "(", "$", "values", "[", "'value'", "]", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "}", "}", "elseif", "(", "preg_match", "(", "'#^(?P<key>'", ".", "Inline", "::", "REGEX_QUOTED_STRING", ".", "'|[^ \\'\"\\[\\{].*?) *\\:(\\s+(?P<value>.+?))?\\s*$#u'", ",", "$", "this", "->", "currentLine", ",", "$", "values", ")", ")", "{", "if", "(", "$", "context", "&&", "'sequence'", "==", "$", "context", ")", "{", "throw", "new", "ParseException", "(", "'You cannot define a mapping item when in a sequence'", ")", ";", "}", "$", "context", "=", "'mapping'", ";", "// force correct settings", "Inline", "::", "parse", "(", "null", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "try", "{", "$", "key", "=", "Inline", "::", "parseScalar", "(", "$", "values", "[", "'key'", "]", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "$", "e", "->", "setParsedLine", "(", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ")", ";", "$", "e", "->", "setSnippet", "(", "$", "this", "->", "currentLine", ")", ";", "throw", "$", "e", ";", "}", "if", "(", "'<<'", "===", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "values", "[", "'value'", "]", ")", "&&", "0", "===", "strpos", "(", "$", "values", "[", "'value'", "]", ",", "'*'", ")", ")", "{", "$", "isInPlace", "=", "substr", "(", "$", "values", "[", "'value'", "]", ",", "1", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "isInPlace", ",", "$", "this", "->", "refs", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Reference \"%s\" does not exist.'", ",", "$", "isInPlace", ")", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "}", "else", "{", "if", "(", "isset", "(", "$", "values", "[", "'value'", "]", ")", "&&", "$", "values", "[", "'value'", "]", "!==", "''", ")", "{", "$", "value", "=", "$", "values", "[", "'value'", "]", ";", "}", "else", "{", "$", "value", "=", "$", "this", "->", "getNextEmbedBlock", "(", ")", ";", "}", "$", "c", "=", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ";", "$", "parser", "=", "new", "Parser", "(", "$", "c", ")", ";", "$", "parser", "->", "refs", "=", "&", "$", "this", "->", "refs", ";", "$", "parsed", "=", "$", "parser", "->", "parse", "(", "$", "value", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "$", "merged", "=", "array", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "parsed", ")", ")", "{", "throw", "new", "ParseException", "(", "'YAML merge keys used with a scalar value instead of an array.'", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "elseif", "(", "isset", "(", "$", "parsed", "[", "0", "]", ")", ")", "{", "// Numeric array, merge individual elements", "foreach", "(", "array_reverse", "(", "$", "parsed", ")", "as", "$", "parsedItem", ")", "{", "if", "(", "!", "is_array", "(", "$", "parsedItem", ")", ")", "{", "throw", "new", "ParseException", "(", "'Merge items must be arrays.'", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "parsedItem", ")", ";", "}", "$", "merged", "=", "array_merge", "(", "$", "parsedItem", ",", "$", "merged", ")", ";", "}", "}", "else", "{", "// Associative array, merge", "$", "merged", "=", "array_merge", "(", "$", "merged", ",", "$", "parsed", ")", ";", "}", "$", "isProcessed", "=", "$", "merged", ";", "}", "}", "elseif", "(", "isset", "(", "$", "values", "[", "'value'", "]", ")", "&&", "preg_match", "(", "'#^&(?P<ref>[^ ]+) *(?P<value>.*)#u'", ",", "$", "values", "[", "'value'", "]", ",", "$", "matches", ")", ")", "{", "$", "isRef", "=", "$", "matches", "[", "'ref'", "]", ";", "$", "values", "[", "'value'", "]", "=", "$", "matches", "[", "'value'", "]", ";", "}", "if", "(", "$", "isProcessed", ")", "{", "// Merge keys", "$", "data", "=", "$", "isProcessed", ";", "// hash", "}", "elseif", "(", "!", "isset", "(", "$", "values", "[", "'value'", "]", ")", "||", "''", "==", "trim", "(", "$", "values", "[", "'value'", "]", ",", "' '", ")", "||", "0", "===", "strpos", "(", "ltrim", "(", "$", "values", "[", "'value'", "]", ",", "' '", ")", ",", "'#'", ")", ")", "{", "// if next line is less indented or equal, then it means that the current value is null", "if", "(", "!", "$", "this", "->", "isNextLineIndented", "(", ")", "&&", "!", "$", "this", "->", "isNextLineUnIndentedCollection", "(", ")", ")", "{", "$", "data", "[", "$", "key", "]", "=", "null", ";", "}", "else", "{", "$", "c", "=", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ";", "$", "parser", "=", "new", "Parser", "(", "$", "c", ")", ";", "$", "parser", "->", "refs", "=", "&", "$", "this", "->", "refs", ";", "$", "data", "[", "$", "key", "]", "=", "$", "parser", "->", "parse", "(", "$", "this", "->", "getNextEmbedBlock", "(", ")", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "}", "else", "{", "if", "(", "$", "isInPlace", ")", "{", "$", "data", "=", "$", "this", "->", "refs", "[", "$", "isInPlace", "]", ";", "}", "else", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "parseValue", "(", "$", "values", "[", "'value'", "]", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "}", "}", "else", "{", "// 1-liner optionally followed by newline", "$", "lineCount", "=", "count", "(", "$", "this", "->", "lines", ")", ";", "if", "(", "1", "===", "$", "lineCount", "||", "(", "2", "===", "$", "lineCount", "&&", "empty", "(", "$", "this", "->", "lines", "[", "1", "]", ")", ")", ")", "{", "try", "{", "$", "value", "=", "Inline", "::", "parse", "(", "$", "this", "->", "lines", "[", "0", "]", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "$", "e", "->", "setParsedLine", "(", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ")", ";", "$", "e", "->", "setSnippet", "(", "$", "this", "->", "currentLine", ")", ";", "throw", "$", "e", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "first", "=", "reset", "(", "$", "value", ")", ";", "if", "(", "is_string", "(", "$", "first", ")", "&&", "0", "===", "strpos", "(", "$", "first", ",", "'*'", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "alias", ")", "{", "$", "data", "[", "]", "=", "$", "this", "->", "refs", "[", "substr", "(", "$", "alias", ",", "1", ")", "]", ";", "}", "$", "value", "=", "$", "data", ";", "}", "}", "if", "(", "isset", "(", "$", "mbEncoding", ")", ")", "{", "mb_internal_encoding", "(", "$", "mbEncoding", ")", ";", "}", "return", "$", "value", ";", "}", "switch", "(", "preg_last_error", "(", ")", ")", "{", "case", "PREG_INTERNAL_ERROR", ":", "$", "error", "=", "'Internal PCRE error.'", ";", "break", ";", "case", "PREG_BACKTRACK_LIMIT_ERROR", ":", "$", "error", "=", "'pcre.backtrack_limit reached.'", ";", "break", ";", "case", "PREG_RECURSION_LIMIT_ERROR", ":", "$", "error", "=", "'pcre.recursion_limit reached.'", ";", "break", ";", "case", "PREG_BAD_UTF8_ERROR", ":", "$", "error", "=", "'Malformed UTF-8 data.'", ";", "break", ";", "case", "PREG_BAD_UTF8_OFFSET_ERROR", ":", "$", "error", "=", "'Offset doesn\\'t correspond to the begin of a valid UTF-8 code point.'", ";", "break", ";", "default", ":", "$", "error", "=", "'Unable to parse.'", ";", "}", "throw", "new", "ParseException", "(", "$", "error", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "if", "(", "$", "isRef", ")", "{", "$", "this", "->", "refs", "[", "$", "isRef", "]", "=", "end", "(", "$", "data", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "mbEncoding", ")", ")", "{", "mb_internal_encoding", "(", "$", "mbEncoding", ")", ";", "}", "return", "empty", "(", "$", "data", ")", "?", "null", ":", "$", "data", ";", "}" ]
Parses a YAML string to a PHP value. @param string $value A YAML string @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise @param Boolean $objectSupport true if object support is enabled, false otherwise @return mixed A PHP value @throws ParseException If the YAML is not valid
[ "Parses", "a", "YAML", "string", "to", "a", "PHP", "value", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php#L49-L256
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php
Parser.getNextEmbedBlock
private function getNextEmbedBlock($indentation = null) { $this->moveToNextLine(); if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine); if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } } else { $newIndent = $indentation; } $data = array(substr($this->currentLine, $newIndent)); $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); while ($this->moveToNextLine()) { if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { $this->moveToPreviousLine(); break; } if ($this->isCurrentLineEmpty()) { if ($this->isCurrentLineBlank()) { $data[] = substr($this->currentLine, $newIndent); } continue; } $indent = $this->getCurrentLineIndentation(); if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) { // empty line $data[] = $match['text']; } elseif ($indent >= $newIndent) { $data[] = substr($this->currentLine, $newIndent); } elseif (0 == $indent) { $this->moveToPreviousLine(); break; } else { throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } } return implode("\n", $data); }
php
private function getNextEmbedBlock($indentation = null) { $this->moveToNextLine(); if (null === $indentation) { $newIndent = $this->getCurrentLineIndentation(); $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine); if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) { throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } } else { $newIndent = $indentation; } $data = array(substr($this->currentLine, $newIndent)); $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine); while ($this->moveToNextLine()) { if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { $this->moveToPreviousLine(); break; } if ($this->isCurrentLineEmpty()) { if ($this->isCurrentLineBlank()) { $data[] = substr($this->currentLine, $newIndent); } continue; } $indent = $this->getCurrentLineIndentation(); if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) { // empty line $data[] = $match['text']; } elseif ($indent >= $newIndent) { $data[] = substr($this->currentLine, $newIndent); } elseif (0 == $indent) { $this->moveToPreviousLine(); break; } else { throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine); } } return implode("\n", $data); }
[ "private", "function", "getNextEmbedBlock", "(", "$", "indentation", "=", "null", ")", "{", "$", "this", "->", "moveToNextLine", "(", ")", ";", "if", "(", "null", "===", "$", "indentation", ")", "{", "$", "newIndent", "=", "$", "this", "->", "getCurrentLineIndentation", "(", ")", ";", "$", "unindentedEmbedBlock", "=", "$", "this", "->", "isStringUnIndentedCollectionItem", "(", "$", "this", "->", "currentLine", ")", ";", "if", "(", "!", "$", "this", "->", "isCurrentLineEmpty", "(", ")", "&&", "0", "===", "$", "newIndent", "&&", "!", "$", "unindentedEmbedBlock", ")", "{", "throw", "new", "ParseException", "(", "'Indentation problem.'", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "}", "else", "{", "$", "newIndent", "=", "$", "indentation", ";", "}", "$", "data", "=", "array", "(", "substr", "(", "$", "this", "->", "currentLine", ",", "$", "newIndent", ")", ")", ";", "$", "isItUnindentedCollection", "=", "$", "this", "->", "isStringUnIndentedCollectionItem", "(", "$", "this", "->", "currentLine", ")", ";", "while", "(", "$", "this", "->", "moveToNextLine", "(", ")", ")", "{", "if", "(", "$", "isItUnindentedCollection", "&&", "!", "$", "this", "->", "isStringUnIndentedCollectionItem", "(", "$", "this", "->", "currentLine", ")", ")", "{", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "break", ";", "}", "if", "(", "$", "this", "->", "isCurrentLineEmpty", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isCurrentLineBlank", "(", ")", ")", "{", "$", "data", "[", "]", "=", "substr", "(", "$", "this", "->", "currentLine", ",", "$", "newIndent", ")", ";", "}", "continue", ";", "}", "$", "indent", "=", "$", "this", "->", "getCurrentLineIndentation", "(", ")", ";", "if", "(", "preg_match", "(", "'#^(?P<text> *)$#'", ",", "$", "this", "->", "currentLine", ",", "$", "match", ")", ")", "{", "// empty line", "$", "data", "[", "]", "=", "$", "match", "[", "'text'", "]", ";", "}", "elseif", "(", "$", "indent", ">=", "$", "newIndent", ")", "{", "$", "data", "[", "]", "=", "substr", "(", "$", "this", "->", "currentLine", ",", "$", "newIndent", ")", ";", "}", "elseif", "(", "0", "==", "$", "indent", ")", "{", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "break", ";", "}", "else", "{", "throw", "new", "ParseException", "(", "'Indentation problem.'", ",", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ",", "$", "this", "->", "currentLine", ")", ";", "}", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "data", ")", ";", "}" ]
Returns the next embed block of YAML. @param integer $indentation The indent level at which the block is to be read, or null for default @return string A YAML string @throws ParseException When indentation problem are detected
[ "Returns", "the", "next", "embed", "block", "of", "YAML", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php#L287-L339
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php
Parser.parseValue
private function parseValue($value, $exceptionOnInvalidType, $objectSupport) { if (0 === strpos($value, '*')) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { $value = substr($value, 1); } if (!array_key_exists($value, $this->refs)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine); } return $this->refs[$value]; } if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); } try { return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } }
php
private function parseValue($value, $exceptionOnInvalidType, $objectSupport) { if (0 === strpos($value, '*')) { if (false !== $pos = strpos($value, '#')) { $value = substr($value, 1, $pos - 2); } else { $value = substr($value, 1); } if (!array_key_exists($value, $this->refs)) { throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine); } return $this->refs[$value]; } if (preg_match('/^(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?$/', $value, $matches)) { $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : ''; return $this->parseFoldedScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), intval(abs($modifiers))); } try { return Inline::parse($value, $exceptionOnInvalidType, $objectSupport); } catch (ParseException $e) { $e->setParsedLine($this->getRealCurrentLineNb() + 1); $e->setSnippet($this->currentLine); throw $e; } }
[ "private", "function", "parseValue", "(", "$", "value", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "value", ",", "'*'", ")", ")", "{", "if", "(", "false", "!==", "$", "pos", "=", "strpos", "(", "$", "value", ",", "'#'", ")", ")", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ",", "$", "pos", "-", "2", ")", ";", "}", "else", "{", "$", "value", "=", "substr", "(", "$", "value", ",", "1", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "value", ",", "$", "this", "->", "refs", ")", ")", "{", "throw", "new", "ParseException", "(", "sprintf", "(", "'Reference \"%s\" does not exist.'", ",", "$", "value", ")", ",", "$", "this", "->", "currentLine", ")", ";", "}", "return", "$", "this", "->", "refs", "[", "$", "value", "]", ";", "}", "if", "(", "preg_match", "(", "'/^(?P<separator>\\||>)(?P<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?P<comments> +#.*)?$/'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "modifiers", "=", "isset", "(", "$", "matches", "[", "'modifiers'", "]", ")", "?", "$", "matches", "[", "'modifiers'", "]", ":", "''", ";", "return", "$", "this", "->", "parseFoldedScalar", "(", "$", "matches", "[", "'separator'", "]", ",", "preg_replace", "(", "'#\\d+#'", ",", "''", ",", "$", "modifiers", ")", ",", "intval", "(", "abs", "(", "$", "modifiers", ")", ")", ")", ";", "}", "try", "{", "return", "Inline", "::", "parse", "(", "$", "value", ",", "$", "exceptionOnInvalidType", ",", "$", "objectSupport", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "$", "e", "->", "setParsedLine", "(", "$", "this", "->", "getRealCurrentLineNb", "(", ")", "+", "1", ")", ";", "$", "e", "->", "setSnippet", "(", "$", "this", "->", "currentLine", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Parses a YAML value. @param string $value A YAML value @param Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise @param Boolean $objectSupport True if object support is enabled, false otherwise @return mixed A PHP value @throws ParseException When reference does not exist
[ "Parses", "a", "YAML", "value", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php#L376-L406
xiewulong/yii2-fileupload
oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php
Parser.parseFoldedScalar
private function parseFoldedScalar($separator, $indicator = '', $indentation = 0) { $notEOF = $this->moveToNextLine(); if (!$notEOF) { return ''; } $isCurrentLineBlank = $this->isCurrentLineBlank(); $text = ''; // leading blank lines are consumed before determining indentation while ($notEOF && $isCurrentLineBlank) { // newline only if not EOF if ($notEOF = $this->moveToNextLine()) { $text .= "\n"; $isCurrentLineBlank = $this->isCurrentLineBlank(); } } // determine indentation if not specified if (0 === $indentation) { if (preg_match('/^ +/', $this->currentLine, $matches)) { $indentation = strlen($matches[0]); } } if ($indentation > 0) { $pattern = sprintf('/^ {%d}(.*)$/', $indentation); while ( $notEOF && ( $isCurrentLineBlank || preg_match($pattern, $this->currentLine, $matches) ) ) { if ($isCurrentLineBlank) { $text .= substr($this->currentLine, $indentation); } else { $text .= $matches[1]; } // newline only if not EOF if ($notEOF = $this->moveToNextLine()) { $text .= "\n"; $isCurrentLineBlank = $this->isCurrentLineBlank(); } } } elseif ($notEOF) { $text .= "\n"; } if ($notEOF) { $this->moveToPreviousLine(); } // replace all non-trailing single newlines with spaces in folded blocks if ('>' === $separator) { preg_match('/(\n*)$/', $text, $matches); $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n")); $text .= $matches[1]; } // deal with trailing newlines as indicated if ('' === $indicator) { $text = preg_replace('/\n+$/s', "\n", $text); } elseif ('-' === $indicator) { $text = preg_replace('/\n+$/s', '', $text); } return $text; }
php
private function parseFoldedScalar($separator, $indicator = '', $indentation = 0) { $notEOF = $this->moveToNextLine(); if (!$notEOF) { return ''; } $isCurrentLineBlank = $this->isCurrentLineBlank(); $text = ''; // leading blank lines are consumed before determining indentation while ($notEOF && $isCurrentLineBlank) { // newline only if not EOF if ($notEOF = $this->moveToNextLine()) { $text .= "\n"; $isCurrentLineBlank = $this->isCurrentLineBlank(); } } // determine indentation if not specified if (0 === $indentation) { if (preg_match('/^ +/', $this->currentLine, $matches)) { $indentation = strlen($matches[0]); } } if ($indentation > 0) { $pattern = sprintf('/^ {%d}(.*)$/', $indentation); while ( $notEOF && ( $isCurrentLineBlank || preg_match($pattern, $this->currentLine, $matches) ) ) { if ($isCurrentLineBlank) { $text .= substr($this->currentLine, $indentation); } else { $text .= $matches[1]; } // newline only if not EOF if ($notEOF = $this->moveToNextLine()) { $text .= "\n"; $isCurrentLineBlank = $this->isCurrentLineBlank(); } } } elseif ($notEOF) { $text .= "\n"; } if ($notEOF) { $this->moveToPreviousLine(); } // replace all non-trailing single newlines with spaces in folded blocks if ('>' === $separator) { preg_match('/(\n*)$/', $text, $matches); $text = preg_replace('/(?<!\n)\n(?!\n)/', ' ', rtrim($text, "\n")); $text .= $matches[1]; } // deal with trailing newlines as indicated if ('' === $indicator) { $text = preg_replace('/\n+$/s', "\n", $text); } elseif ('-' === $indicator) { $text = preg_replace('/\n+$/s', '', $text); } return $text; }
[ "private", "function", "parseFoldedScalar", "(", "$", "separator", ",", "$", "indicator", "=", "''", ",", "$", "indentation", "=", "0", ")", "{", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ";", "if", "(", "!", "$", "notEOF", ")", "{", "return", "''", ";", "}", "$", "isCurrentLineBlank", "=", "$", "this", "->", "isCurrentLineBlank", "(", ")", ";", "$", "text", "=", "''", ";", "// leading blank lines are consumed before determining indentation", "while", "(", "$", "notEOF", "&&", "$", "isCurrentLineBlank", ")", "{", "// newline only if not EOF", "if", "(", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ")", "{", "$", "text", ".=", "\"\\n\"", ";", "$", "isCurrentLineBlank", "=", "$", "this", "->", "isCurrentLineBlank", "(", ")", ";", "}", "}", "// determine indentation if not specified", "if", "(", "0", "===", "$", "indentation", ")", "{", "if", "(", "preg_match", "(", "'/^ +/'", ",", "$", "this", "->", "currentLine", ",", "$", "matches", ")", ")", "{", "$", "indentation", "=", "strlen", "(", "$", "matches", "[", "0", "]", ")", ";", "}", "}", "if", "(", "$", "indentation", ">", "0", ")", "{", "$", "pattern", "=", "sprintf", "(", "'/^ {%d}(.*)$/'", ",", "$", "indentation", ")", ";", "while", "(", "$", "notEOF", "&&", "(", "$", "isCurrentLineBlank", "||", "preg_match", "(", "$", "pattern", ",", "$", "this", "->", "currentLine", ",", "$", "matches", ")", ")", ")", "{", "if", "(", "$", "isCurrentLineBlank", ")", "{", "$", "text", ".=", "substr", "(", "$", "this", "->", "currentLine", ",", "$", "indentation", ")", ";", "}", "else", "{", "$", "text", ".=", "$", "matches", "[", "1", "]", ";", "}", "// newline only if not EOF", "if", "(", "$", "notEOF", "=", "$", "this", "->", "moveToNextLine", "(", ")", ")", "{", "$", "text", ".=", "\"\\n\"", ";", "$", "isCurrentLineBlank", "=", "$", "this", "->", "isCurrentLineBlank", "(", ")", ";", "}", "}", "}", "elseif", "(", "$", "notEOF", ")", "{", "$", "text", ".=", "\"\\n\"", ";", "}", "if", "(", "$", "notEOF", ")", "{", "$", "this", "->", "moveToPreviousLine", "(", ")", ";", "}", "// replace all non-trailing single newlines with spaces in folded blocks", "if", "(", "'>'", "===", "$", "separator", ")", "{", "preg_match", "(", "'/(\\n*)$/'", ",", "$", "text", ",", "$", "matches", ")", ";", "$", "text", "=", "preg_replace", "(", "'/(?<!\\n)\\n(?!\\n)/'", ",", "' '", ",", "rtrim", "(", "$", "text", ",", "\"\\n\"", ")", ")", ";", "$", "text", ".=", "$", "matches", "[", "1", "]", ";", "}", "// deal with trailing newlines as indicated", "if", "(", "''", "===", "$", "indicator", ")", "{", "$", "text", "=", "preg_replace", "(", "'/\\n+$/s'", ",", "\"\\n\"", ",", "$", "text", ")", ";", "}", "elseif", "(", "'-'", "===", "$", "indicator", ")", "{", "$", "text", "=", "preg_replace", "(", "'/\\n+$/s'", ",", "''", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}" ]
Parses a folded scalar. @param string $separator The separator that was used to begin this folded scalar (| or >) @param string $indicator The indicator that was used to begin this folded scalar (+ or -) @param integer $indentation The indentation that was used to begin this folded scalar @return string The text value
[ "Parses", "a", "folded", "scalar", "." ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/yaml/Symfony/Component/Yaml/Parser.php#L417-L487
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getWellKnown
public function getWellKnown() { $cached = $this->getCache('wellKnown'); if (!empty($cached)) { return $cached; } try { $response = $this->client->get($this->wellKnownUrl); } catch (RequestException $e) { $this->lastException = $e; return null; } $output = json_decode($response->getBody()); if (json_last_error() !== JSON_ERROR_NONE) { return null; } $this->setCache('wellKnown', $output); return $output; }
php
public function getWellKnown() { $cached = $this->getCache('wellKnown'); if (!empty($cached)) { return $cached; } try { $response = $this->client->get($this->wellKnownUrl); } catch (RequestException $e) { $this->lastException = $e; return null; } $output = json_decode($response->getBody()); if (json_last_error() !== JSON_ERROR_NONE) { return null; } $this->setCache('wellKnown', $output); return $output; }
[ "public", "function", "getWellKnown", "(", ")", "{", "$", "cached", "=", "$", "this", "->", "getCache", "(", "'wellKnown'", ")", ";", "if", "(", "!", "empty", "(", "$", "cached", ")", ")", "{", "return", "$", "cached", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "wellKnownUrl", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "null", ";", "}", "$", "output", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "return", "null", ";", "}", "$", "this", "->", "setCache", "(", "'wellKnown'", ",", "$", "output", ")", ";", "return", "$", "output", ";", "}" ]
Get the response of the specified .well-known URL. @return object Parsed JSON response from the well known URL
[ "Get", "the", "response", "of", "the", "specified", ".", "well", "-", "known", "URL", "." ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L63-L85
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getPublicKey
public function getPublicKey() { $cached = $this->getCache('publicKey'); if (!empty($cached)) { return $cached; } $wellKnown = $this->getWellKnown(); if (empty($wellKnown->jwks_uri)) { return null; } try { $response = $this->client->get($wellKnown->jwks_uri); } catch (RequestException $e) { $this->lastException = $e; return null; } $jwks = json_decode($response->getBody()); if (empty($jwks->keys[0]->x5c[0])) { return null; } $X509 = new X509(); if (!$X509->loadX509($jwks->keys[0]->x5c[0])) { return null; } $key = (string)$X509->getPublicKey(); $this->setCache('publicKey', $key); return $key; }
php
public function getPublicKey() { $cached = $this->getCache('publicKey'); if (!empty($cached)) { return $cached; } $wellKnown = $this->getWellKnown(); if (empty($wellKnown->jwks_uri)) { return null; } try { $response = $this->client->get($wellKnown->jwks_uri); } catch (RequestException $e) { $this->lastException = $e; return null; } $jwks = json_decode($response->getBody()); if (empty($jwks->keys[0]->x5c[0])) { return null; } $X509 = new X509(); if (!$X509->loadX509($jwks->keys[0]->x5c[0])) { return null; } $key = (string)$X509->getPublicKey(); $this->setCache('publicKey', $key); return $key; }
[ "public", "function", "getPublicKey", "(", ")", "{", "$", "cached", "=", "$", "this", "->", "getCache", "(", "'publicKey'", ")", ";", "if", "(", "!", "empty", "(", "$", "cached", ")", ")", "{", "return", "$", "cached", ";", "}", "$", "wellKnown", "=", "$", "this", "->", "getWellKnown", "(", ")", ";", "if", "(", "empty", "(", "$", "wellKnown", "->", "jwks_uri", ")", ")", "{", "return", "null", ";", "}", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "wellKnown", "->", "jwks_uri", ")", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "null", ";", "}", "$", "jwks", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "jwks", "->", "keys", "[", "0", "]", "->", "x5c", "[", "0", "]", ")", ")", "{", "return", "null", ";", "}", "$", "X509", "=", "new", "X509", "(", ")", ";", "if", "(", "!", "$", "X509", "->", "loadX509", "(", "$", "jwks", "->", "keys", "[", "0", "]", "->", "x5c", "[", "0", "]", ")", ")", "{", "return", "null", ";", "}", "$", "key", "=", "(", "string", ")", "$", "X509", "->", "getPublicKey", "(", ")", ";", "$", "this", "->", "setCache", "(", "'publicKey'", ",", "$", "key", ")", ";", "return", "$", "key", ";", "}" ]
Get the public key of the current well-known URL @return string
[ "Get", "the", "public", "key", "of", "the", "current", "well", "-", "known", "URL" ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L92-L126
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.validateJWT
public function validateJWT($jwt) { try { $decoded = $this->decode($jwt); return !empty($decoded); } catch (Exception $e) { //For simple true/false validation we don't throw exceptions; //just return false but store exception in case further //details are wanted $this->lastException = $e; return false; } }
php
public function validateJWT($jwt) { try { $decoded = $this->decode($jwt); return !empty($decoded); } catch (Exception $e) { //For simple true/false validation we don't throw exceptions; //just return false but store exception in case further //details are wanted $this->lastException = $e; return false; } }
[ "public", "function", "validateJWT", "(", "$", "jwt", ")", "{", "try", "{", "$", "decoded", "=", "$", "this", "->", "decode", "(", "$", "jwt", ")", ";", "return", "!", "empty", "(", "$", "decoded", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "//For simple true/false validation we don't throw exceptions;", "//just return false but store exception in case further", "//details are wanted", "$", "this", "->", "lastException", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Check if a JWT is valid @param string $jwt JWT @return bool true if $jwt is a valid JWT, false if not
[ "Check", "if", "a", "JWT", "is", "valid" ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L135-L147
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.decode
public function decode($jwt) { $wellKnown = $this->getWellKnown(); $key = $this->getPublicKey(); $decodedObject = JWT::decode( $jwt, $key, $wellKnown->id_token_signing_alg_values_supported ); //Firebase\JWT\JWT::decode does not verify that some required //fields actually exist if (empty($decodedObject->iss)) { throw new NoIssuerException('No issuer in JWT'); } if ($decodedObject->iss != $wellKnown->issuer) { throw new BadIssuerException('JWT issuer does not match well-known'); } if (empty($decodedObject->exp)) { //Firebase\JWT\JWT does throw an exception if 'exp' field is in //the past, but not if it's completely missing throw new NoExpirationException('No expiration in JWT'); } //JWT::decode returns at stdClass object, but iterating through keys is much //simpler with an array. So here's a quick Object-to-Array conversion $decoded = json_decode(json_encode($decodedObject), true); return $this->parseClaims($decoded); }
php
public function decode($jwt) { $wellKnown = $this->getWellKnown(); $key = $this->getPublicKey(); $decodedObject = JWT::decode( $jwt, $key, $wellKnown->id_token_signing_alg_values_supported ); //Firebase\JWT\JWT::decode does not verify that some required //fields actually exist if (empty($decodedObject->iss)) { throw new NoIssuerException('No issuer in JWT'); } if ($decodedObject->iss != $wellKnown->issuer) { throw new BadIssuerException('JWT issuer does not match well-known'); } if (empty($decodedObject->exp)) { //Firebase\JWT\JWT does throw an exception if 'exp' field is in //the past, but not if it's completely missing throw new NoExpirationException('No expiration in JWT'); } //JWT::decode returns at stdClass object, but iterating through keys is much //simpler with an array. So here's a quick Object-to-Array conversion $decoded = json_decode(json_encode($decodedObject), true); return $this->parseClaims($decoded); }
[ "public", "function", "decode", "(", "$", "jwt", ")", "{", "$", "wellKnown", "=", "$", "this", "->", "getWellKnown", "(", ")", ";", "$", "key", "=", "$", "this", "->", "getPublicKey", "(", ")", ";", "$", "decodedObject", "=", "JWT", "::", "decode", "(", "$", "jwt", ",", "$", "key", ",", "$", "wellKnown", "->", "id_token_signing_alg_values_supported", ")", ";", "//Firebase\\JWT\\JWT::decode does not verify that some required", "//fields actually exist", "if", "(", "empty", "(", "$", "decodedObject", "->", "iss", ")", ")", "{", "throw", "new", "NoIssuerException", "(", "'No issuer in JWT'", ")", ";", "}", "if", "(", "$", "decodedObject", "->", "iss", "!=", "$", "wellKnown", "->", "issuer", ")", "{", "throw", "new", "BadIssuerException", "(", "'JWT issuer does not match well-known'", ")", ";", "}", "if", "(", "empty", "(", "$", "decodedObject", "->", "exp", ")", ")", "{", "//Firebase\\JWT\\JWT does throw an exception if 'exp' field is in", "//the past, but not if it's completely missing", "throw", "new", "NoExpirationException", "(", "'No expiration in JWT'", ")", ";", "}", "//JWT::decode returns at stdClass object, but iterating through keys is much", "//simpler with an array. So here's a quick Object-to-Array conversion", "$", "decoded", "=", "json_decode", "(", "json_encode", "(", "$", "decodedObject", ")", ",", "true", ")", ";", "return", "$", "this", "->", "parseClaims", "(", "$", "decoded", ")", ";", "}" ]
Decode a JWT @param string $jwt JWT @return object decoded JWT @throws Exception Various exceptions for various problems with JWT (see Firebase\JWT\JWT::decode for details)
[ "Decode", "a", "JWT" ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L159-L188
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.parseClaims
public function parseClaims($jwt) { //PHP 7 has convenient "??" operator, but we're making this //5.4+ compatible. So this is a simple "safe array access" that //won't cause warnings or errors if we try to get a non-existent key $get = function ($arr, $key) { return array_key_exists($key, $arr) ? $arr[$key] : null; }; $hasResourceOwner = array_key_exists('http://byu.edu/claims/resourceowner_byu_id', $jwt); $jwt['byu']['client'] = [ 'byuId' => $get($jwt, 'http://byu.edu/claims/client_byu_id'), 'claimSource' => $get($jwt, 'http://byu.edu/claims/client_claim_source'), 'netId' => $get($jwt, 'http://byu.edu/claims/client_net_id'), 'personId' => $get($jwt, 'http://byu.edu/claims/client_person_id'), 'preferredFirstName' => $get($jwt, 'http://byu.edu/claims/client_preferred_first_name'), 'prefix' => $get($jwt, 'http://byu.edu/claims/client_name_prefix'), 'restOfName' => $get($jwt, 'http://byu.edu/claims/client_rest_of_name'), 'sortName' => $get($jwt, 'http://byu.edu/claims/client_sort_name'), 'subscriberNetId' => $get($jwt, 'http://byu.edu/claims/client_subscriber_net_id'), 'suffix' => $get($jwt, 'http://byu.edu/claims/client_name_prefix'), 'surname' => $get($jwt, 'http://byu.edu/claims/client_surname'), 'surnamePosition' => $get($jwt, 'http://byu.edu/claims/client_surname_position') ]; if ($hasResourceOwner) { $jwt['byu']['resourceOwner'] = [ 'byuId' => $get($jwt, 'http://byu.edu/claims/resourceowner_byu_id'), 'netId' => $get($jwt, 'http://byu.edu/claims/resourceowner_net_id'), 'personId' => $get($jwt, 'http://byu.edu/claims/resourceowner_person_id'), 'preferredFirstName' => $get($jwt, 'http://byu.edu/claims/resourceowner_preferred_first_name'), 'prefix' => $get($jwt, 'http://byu.edu/claims/resourceowner_prefix'), 'restOfName' => $get($jwt, 'http://byu.edu/claims/resourceowner_rest_of_name'), 'sortName' => $get($jwt, 'http://byu.edu/claims/resourceowner_sort_name'), 'suffix' => $get($jwt, 'http://byu.edu/claims/resourceowner_suffix'), 'surname' => $get($jwt, 'http://byu.edu/claims/resourceowner_surname'), 'surnamePosition' => $get($jwt, 'http://byu.edu/claims/resourceowner_surname_position') ]; } $webresCheckKey = $hasResourceOwner ? 'resourceOwner' : 'client'; $jwt['byu']['webresCheck'] = [ 'byuId' => $jwt['byu'][$webresCheckKey]['byuId'], 'netId' => $jwt['byu'][$webresCheckKey]['netId'], 'personId' => $jwt['byu'][$webresCheckKey]['personId'] ]; $jwt['wso2'] = [ 'apiContext' => $get($jwt, 'http://wso2.org/claims/apicontext'), 'application' => [ 'id' => $get($jwt, 'http://wso2.org/claims/applicationid'), 'name' => $get($jwt, 'http://wso2.org/claims/applicationname'), 'tier' => $get($jwt, 'http://wso2.org/claims/applicationtier') ], 'clientId' => $get($jwt, 'http://wso2.org/claims/client_id'), 'endUser' => $get($jwt, 'http://wso2.org/claims/enduser'), 'endUserTenantId' => $get($jwt, 'http://wso2.org/claims/enduserTenantId'), 'keyType' => $get($jwt, 'http://wso2.org/claims/keytype'), 'subscriber' => $get($jwt, 'http://wso2.org/claims/subscriber'), 'tier' => $get($jwt, 'http://wso2.org/claims/tier'), 'userType' => $get($jwt, 'http://wso2.org/claims/usertype'), 'version' => $get($jwt, 'http://wso2.org/claims/version') ]; return $jwt; }
php
public function parseClaims($jwt) { //PHP 7 has convenient "??" operator, but we're making this //5.4+ compatible. So this is a simple "safe array access" that //won't cause warnings or errors if we try to get a non-existent key $get = function ($arr, $key) { return array_key_exists($key, $arr) ? $arr[$key] : null; }; $hasResourceOwner = array_key_exists('http://byu.edu/claims/resourceowner_byu_id', $jwt); $jwt['byu']['client'] = [ 'byuId' => $get($jwt, 'http://byu.edu/claims/client_byu_id'), 'claimSource' => $get($jwt, 'http://byu.edu/claims/client_claim_source'), 'netId' => $get($jwt, 'http://byu.edu/claims/client_net_id'), 'personId' => $get($jwt, 'http://byu.edu/claims/client_person_id'), 'preferredFirstName' => $get($jwt, 'http://byu.edu/claims/client_preferred_first_name'), 'prefix' => $get($jwt, 'http://byu.edu/claims/client_name_prefix'), 'restOfName' => $get($jwt, 'http://byu.edu/claims/client_rest_of_name'), 'sortName' => $get($jwt, 'http://byu.edu/claims/client_sort_name'), 'subscriberNetId' => $get($jwt, 'http://byu.edu/claims/client_subscriber_net_id'), 'suffix' => $get($jwt, 'http://byu.edu/claims/client_name_prefix'), 'surname' => $get($jwt, 'http://byu.edu/claims/client_surname'), 'surnamePosition' => $get($jwt, 'http://byu.edu/claims/client_surname_position') ]; if ($hasResourceOwner) { $jwt['byu']['resourceOwner'] = [ 'byuId' => $get($jwt, 'http://byu.edu/claims/resourceowner_byu_id'), 'netId' => $get($jwt, 'http://byu.edu/claims/resourceowner_net_id'), 'personId' => $get($jwt, 'http://byu.edu/claims/resourceowner_person_id'), 'preferredFirstName' => $get($jwt, 'http://byu.edu/claims/resourceowner_preferred_first_name'), 'prefix' => $get($jwt, 'http://byu.edu/claims/resourceowner_prefix'), 'restOfName' => $get($jwt, 'http://byu.edu/claims/resourceowner_rest_of_name'), 'sortName' => $get($jwt, 'http://byu.edu/claims/resourceowner_sort_name'), 'suffix' => $get($jwt, 'http://byu.edu/claims/resourceowner_suffix'), 'surname' => $get($jwt, 'http://byu.edu/claims/resourceowner_surname'), 'surnamePosition' => $get($jwt, 'http://byu.edu/claims/resourceowner_surname_position') ]; } $webresCheckKey = $hasResourceOwner ? 'resourceOwner' : 'client'; $jwt['byu']['webresCheck'] = [ 'byuId' => $jwt['byu'][$webresCheckKey]['byuId'], 'netId' => $jwt['byu'][$webresCheckKey]['netId'], 'personId' => $jwt['byu'][$webresCheckKey]['personId'] ]; $jwt['wso2'] = [ 'apiContext' => $get($jwt, 'http://wso2.org/claims/apicontext'), 'application' => [ 'id' => $get($jwt, 'http://wso2.org/claims/applicationid'), 'name' => $get($jwt, 'http://wso2.org/claims/applicationname'), 'tier' => $get($jwt, 'http://wso2.org/claims/applicationtier') ], 'clientId' => $get($jwt, 'http://wso2.org/claims/client_id'), 'endUser' => $get($jwt, 'http://wso2.org/claims/enduser'), 'endUserTenantId' => $get($jwt, 'http://wso2.org/claims/enduserTenantId'), 'keyType' => $get($jwt, 'http://wso2.org/claims/keytype'), 'subscriber' => $get($jwt, 'http://wso2.org/claims/subscriber'), 'tier' => $get($jwt, 'http://wso2.org/claims/tier'), 'userType' => $get($jwt, 'http://wso2.org/claims/usertype'), 'version' => $get($jwt, 'http://wso2.org/claims/version') ]; return $jwt; }
[ "public", "function", "parseClaims", "(", "$", "jwt", ")", "{", "//PHP 7 has convenient \"??\" operator, but we're making this", "//5.4+ compatible. So this is a simple \"safe array access\" that", "//won't cause warnings or errors if we try to get a non-existent key", "$", "get", "=", "function", "(", "$", "arr", ",", "$", "key", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "arr", ")", "?", "$", "arr", "[", "$", "key", "]", ":", "null", ";", "}", ";", "$", "hasResourceOwner", "=", "array_key_exists", "(", "'http://byu.edu/claims/resourceowner_byu_id'", ",", "$", "jwt", ")", ";", "$", "jwt", "[", "'byu'", "]", "[", "'client'", "]", "=", "[", "'byuId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_byu_id'", ")", ",", "'claimSource'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_claim_source'", ")", ",", "'netId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_net_id'", ")", ",", "'personId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_person_id'", ")", ",", "'preferredFirstName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_preferred_first_name'", ")", ",", "'prefix'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_name_prefix'", ")", ",", "'restOfName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_rest_of_name'", ")", ",", "'sortName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_sort_name'", ")", ",", "'subscriberNetId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_subscriber_net_id'", ")", ",", "'suffix'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_name_prefix'", ")", ",", "'surname'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_surname'", ")", ",", "'surnamePosition'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/client_surname_position'", ")", "]", ";", "if", "(", "$", "hasResourceOwner", ")", "{", "$", "jwt", "[", "'byu'", "]", "[", "'resourceOwner'", "]", "=", "[", "'byuId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_byu_id'", ")", ",", "'netId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_net_id'", ")", ",", "'personId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_person_id'", ")", ",", "'preferredFirstName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_preferred_first_name'", ")", ",", "'prefix'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_prefix'", ")", ",", "'restOfName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_rest_of_name'", ")", ",", "'sortName'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_sort_name'", ")", ",", "'suffix'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_suffix'", ")", ",", "'surname'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_surname'", ")", ",", "'surnamePosition'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://byu.edu/claims/resourceowner_surname_position'", ")", "]", ";", "}", "$", "webresCheckKey", "=", "$", "hasResourceOwner", "?", "'resourceOwner'", ":", "'client'", ";", "$", "jwt", "[", "'byu'", "]", "[", "'webresCheck'", "]", "=", "[", "'byuId'", "=>", "$", "jwt", "[", "'byu'", "]", "[", "$", "webresCheckKey", "]", "[", "'byuId'", "]", ",", "'netId'", "=>", "$", "jwt", "[", "'byu'", "]", "[", "$", "webresCheckKey", "]", "[", "'netId'", "]", ",", "'personId'", "=>", "$", "jwt", "[", "'byu'", "]", "[", "$", "webresCheckKey", "]", "[", "'personId'", "]", "]", ";", "$", "jwt", "[", "'wso2'", "]", "=", "[", "'apiContext'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/apicontext'", ")", ",", "'application'", "=>", "[", "'id'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/applicationid'", ")", ",", "'name'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/applicationname'", ")", ",", "'tier'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/applicationtier'", ")", "]", ",", "'clientId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/client_id'", ")", ",", "'endUser'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/enduser'", ")", ",", "'endUserTenantId'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/enduserTenantId'", ")", ",", "'keyType'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/keytype'", ")", ",", "'subscriber'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/subscriber'", ")", ",", "'tier'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/tier'", ")", ",", "'userType'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/usertype'", ")", ",", "'version'", "=>", "$", "get", "(", "$", "jwt", ",", "'http://wso2.org/claims/version'", ")", "]", ";", "return", "$", "jwt", ";", "}" ]
Parse standard set of 'http://XXXX/claims/YYYY' claims and save as hierarchal array data @param array $jwt @return array
[ "Parse", "standard", "set", "of", "http", ":", "//", "XXXX", "/", "claims", "/", "YYYY", "claims", "and", "save", "as", "hierarchal", "array", "data" ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L198-L264
byu-oit/byu-jwt-php
src/BYUJWT.php
BYUJWT.getCache
protected function getCache($key) { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; } return false; }
php
protected function getCache($key) { if (array_key_exists($key, $this->cache)) { return $this->cache[$key]; } return false; }
[ "protected", "function", "getCache", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "cache", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}" ]
Simple cache reader. Implemented as a function so that if you don't want caching, you can make a subclass that overrides this function and always returns false @param string $key Cache key @return various
[ "Simple", "cache", "reader", ".", "Implemented", "as", "a", "function", "so", "that", "if", "you", "don", "t", "want", "caching", "you", "can", "make", "a", "subclass", "that", "overrides", "this", "function", "and", "always", "returns", "false" ]
train
https://github.com/byu-oit/byu-jwt-php/blob/9e55be8928a2c4925176303c100caf293d6a2cf9/src/BYUJWT.php#L275-L281
WellCommerce/StandardEditionBundle
DataFixtures/ORM/LoadTaxData.php
LoadTaxData.load
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } foreach (self::$samples as $val) { $name = sprintf('%s%s', $val, '%'); $tax = new Tax(); $tax->setValue($val); foreach ($this->getLocales() as $locale) { $tax->translate($locale->getCode())->setName($name . ' VAT'); } $tax->mergeNewTranslations(); $manager->persist($tax); $this->setReference('tax_' . $val, $tax); } $manager->flush(); }
php
public function load(ObjectManager $manager) { if (!$this->isEnabled()) { return; } foreach (self::$samples as $val) { $name = sprintf('%s%s', $val, '%'); $tax = new Tax(); $tax->setValue($val); foreach ($this->getLocales() as $locale) { $tax->translate($locale->getCode())->setName($name . ' VAT'); } $tax->mergeNewTranslations(); $manager->persist($tax); $this->setReference('tax_' . $val, $tax); } $manager->flush(); }
[ "public", "function", "load", "(", "ObjectManager", "$", "manager", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "foreach", "(", "self", "::", "$", "samples", "as", "$", "val", ")", "{", "$", "name", "=", "sprintf", "(", "'%s%s'", ",", "$", "val", ",", "'%'", ")", ";", "$", "tax", "=", "new", "Tax", "(", ")", ";", "$", "tax", "->", "setValue", "(", "$", "val", ")", ";", "foreach", "(", "$", "this", "->", "getLocales", "(", ")", "as", "$", "locale", ")", "{", "$", "tax", "->", "translate", "(", "$", "locale", "->", "getCode", "(", ")", ")", "->", "setName", "(", "$", "name", ".", "' VAT'", ")", ";", "}", "$", "tax", "->", "mergeNewTranslations", "(", ")", ";", "$", "manager", "->", "persist", "(", "$", "tax", ")", ";", "$", "this", "->", "setReference", "(", "'tax_'", ".", "$", "val", ",", "$", "tax", ")", ";", "}", "$", "manager", "->", "flush", "(", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/WellCommerce/StandardEditionBundle/blob/6367bd20bbb6bde37c710a6ba87ae72b5f05f61e/DataFixtures/ORM/LoadTaxData.php#L31-L51
gdbots/iam-php
src/CreateAppHandler.php
CreateAppHandler.beforePutEvents
protected function beforePutEvents(NodeCreated $event, CreateNode $command, Pbjx $pbjx): void { parent::beforePutEvents($event, $command, $pbjx); /** @var App $node */ $node = $event->get('node'); $node->set('status', NodeStatus::PUBLISHED()); }
php
protected function beforePutEvents(NodeCreated $event, CreateNode $command, Pbjx $pbjx): void { parent::beforePutEvents($event, $command, $pbjx); /** @var App $node */ $node = $event->get('node'); $node->set('status', NodeStatus::PUBLISHED()); }
[ "protected", "function", "beforePutEvents", "(", "NodeCreated", "$", "event", ",", "CreateNode", "$", "command", ",", "Pbjx", "$", "pbjx", ")", ":", "void", "{", "parent", "::", "beforePutEvents", "(", "$", "event", ",", "$", "command", ",", "$", "pbjx", ")", ";", "/** @var App $node */", "$", "node", "=", "$", "event", "->", "get", "(", "'node'", ")", ";", "$", "node", "->", "set", "(", "'status'", ",", "NodeStatus", "::", "PUBLISHED", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/CreateAppHandler.php#L24-L31
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setDivider
public function setDivider($divider = '/'): Breadcrumbs { if (!is_string($divider) && !is_null($divider)) { throw new InvalidArgumentException('Breadcrumbs::setDivider() only accepts strings or NULL'); } $this->setOption('divider', $divider); return $this; }
php
public function setDivider($divider = '/'): Breadcrumbs { if (!is_string($divider) && !is_null($divider)) { throw new InvalidArgumentException('Breadcrumbs::setDivider() only accepts strings or NULL'); } $this->setOption('divider', $divider); return $this; }
[ "public", "function", "setDivider", "(", "$", "divider", "=", "'/'", ")", ":", "Breadcrumbs", "{", "if", "(", "!", "is_string", "(", "$", "divider", ")", "&&", "!", "is_null", "(", "$", "divider", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Breadcrumbs::setDivider() only accepts strings or NULL'", ")", ";", "}", "$", "this", "->", "setOption", "(", "'divider'", ",", "$", "divider", ")", ";", "return", "$", "this", ";", "}" ]
Sets the divider which will be printed between the breadcrumbs. If set to `null`, the divider won't be printed at all. @param string|null $divider The divider used to separe the breadcrumbs. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Sets", "the", "divider", "which", "will", "be", "printed", "between", "the", "breadcrumbs", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L53-L61
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setDividerElement
public function setDividerElement(string $element): Breadcrumbs { $this->validateElement('allowedDividerElement', $element); $this->setOption('dividerElement', $element); return $this; }
php
public function setDividerElement(string $element): Breadcrumbs { $this->validateElement('allowedDividerElement', $element); $this->setOption('dividerElement', $element); return $this; }
[ "public", "function", "setDividerElement", "(", "string", "$", "element", ")", ":", "Breadcrumbs", "{", "$", "this", "->", "validateElement", "(", "'allowedDividerElement'", ",", "$", "element", ")", ";", "$", "this", "->", "setOption", "(", "'dividerElement'", ",", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Set the divider list DOM Element. @param string $element The Element to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "divider", "list", "DOM", "Element", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L80-L87
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setListElement
public function setListElement(string $element): Breadcrumbs { $this->validateElement('allowedListElement', $element); $this->setOption('listElement', $element); return $this; }
php
public function setListElement(string $element): Breadcrumbs { $this->validateElement('allowedListElement', $element); $this->setOption('listElement', $element); return $this; }
[ "public", "function", "setListElement", "(", "string", "$", "element", ")", ":", "Breadcrumbs", "{", "$", "this", "->", "validateElement", "(", "'allowedListElement'", ",", "$", "element", ")", ";", "$", "this", "->", "setOption", "(", "'listElement'", ",", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Set the container list DOM Element. @param string $element The Element to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "container", "list", "DOM", "Element", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L152-L159
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setListItemElement
public function setListItemElement(string $element): Breadcrumbs { $this->validateElement('allowedListItemElement', $element); $this->setOption('listItemElement', $element); return $this; }
php
public function setListItemElement(string $element): Breadcrumbs { $this->validateElement('allowedListItemElement', $element); $this->setOption('listItemElement', $element); return $this; }
[ "public", "function", "setListItemElement", "(", "string", "$", "element", ")", ":", "Breadcrumbs", "{", "$", "this", "->", "validateElement", "(", "'allowedListItemElement'", ",", "$", "element", ")", ";", "$", "this", "->", "setOption", "(", "'listItemElement'", ",", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Set the item DOM Element. @param string $element The Element to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "item", "DOM", "Element", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L224-L231
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setListActiveElement
public function setListActiveElement(string $element): Breadcrumbs { $this->validateElement('allowedListActiveElement', $element); $this->setOption('listActiveElement', $element); return $this; }
php
public function setListActiveElement(string $element): Breadcrumbs { $this->validateElement('allowedListActiveElement', $element); $this->setOption('listActiveElement', $element); return $this; }
[ "public", "function", "setListActiveElement", "(", "string", "$", "element", ")", ":", "Breadcrumbs", "{", "$", "this", "->", "validateElement", "(", "'allowedListActiveElement'", ",", "$", "element", ")", ";", "$", "this", "->", "setOption", "(", "'listActiveElement'", ",", "$", "element", ")", ";", "return", "$", "this", ";", "}" ]
Set the active DOM Element. @param string $element The Element to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "active", "DOM", "Element", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L296-L303
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.setElementClasses
protected function setElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $this->setOption($option, array_unique($classes)); return $this; }
php
protected function setElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $this->setOption($option, array_unique($classes)); return $this; }
[ "protected", "function", "setElementClasses", "(", "string", "$", "option", ",", "$", "classes", ")", ":", "Breadcrumbs", "{", "if", "(", "is_string", "(", "$", "classes", ")", ")", "{", "$", "classes", "=", "explode", "(", "' '", ",", "$", "classes", ")", ";", "}", "$", "this", "->", "validateClasses", "(", "$", "classes", ")", ";", "$", "this", "->", "setOption", "(", "$", "option", ",", "array_unique", "(", "$", "classes", ")", ")", ";", "return", "$", "this", ";", "}" ]
Set the classes to the given option type. @param string $option The option from where we must set the classes. @param string|array $classes The classes to set. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Set", "the", "classes", "to", "the", "given", "option", "type", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L369-L379
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.addElementClasses
protected function addElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $classes = array_merge( $this->getOption($option), $classes ); $this->setOption($option, array_unique($classes)); return $this; }
php
protected function addElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $classes = array_merge( $this->getOption($option), $classes ); $this->setOption($option, array_unique($classes)); return $this; }
[ "protected", "function", "addElementClasses", "(", "string", "$", "option", ",", "$", "classes", ")", ":", "Breadcrumbs", "{", "if", "(", "is_string", "(", "$", "classes", ")", ")", "{", "$", "classes", "=", "explode", "(", "' '", ",", "$", "classes", ")", ";", "}", "$", "this", "->", "validateClasses", "(", "$", "classes", ")", ";", "$", "classes", "=", "array_merge", "(", "$", "this", "->", "getOption", "(", "$", "option", ")", ",", "$", "classes", ")", ";", "$", "this", "->", "setOption", "(", "$", "option", ",", "array_unique", "(", "$", "classes", ")", ")", ";", "return", "$", "this", ";", "}" ]
Add one or more CSS classes related to the option type. @param string $option The option from where we must add the classes. @param string|array $classes The classes to add. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Add", "one", "or", "more", "CSS", "classes", "related", "to", "the", "option", "type", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L405-L419
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.removeElementClasses
protected function removeElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $classes = array_diff( $this->getOption($option), $classes ); $this->setOption($option, array_unique($classes)); return $this; }
php
protected function removeElementClasses(string $option, $classes): Breadcrumbs { if (is_string($classes)) { $classes = explode(' ', $classes); } $this->validateClasses($classes); $classes = array_diff( $this->getOption($option), $classes ); $this->setOption($option, array_unique($classes)); return $this; }
[ "protected", "function", "removeElementClasses", "(", "string", "$", "option", ",", "$", "classes", ")", ":", "Breadcrumbs", "{", "if", "(", "is_string", "(", "$", "classes", ")", ")", "{", "$", "classes", "=", "explode", "(", "' '", ",", "$", "classes", ")", ";", "}", "$", "this", "->", "validateClasses", "(", "$", "classes", ")", ";", "$", "classes", "=", "array_diff", "(", "$", "this", "->", "getOption", "(", "$", "option", ")", ",", "$", "classes", ")", ";", "$", "this", "->", "setOption", "(", "$", "option", ",", "array_unique", "(", "$", "classes", ")", ")", ";", "return", "$", "this", ";", "}" ]
Remove one or more CSS classes related to the option type. @param string $option The option from where we must remove the classes. @param string|array $classes The classes to remove. @return \Xety\Breadcrumbs\Breadcrumbs
[ "Remove", "one", "or", "more", "CSS", "classes", "related", "to", "the", "option", "type", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L429-L443
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.validateElement
protected function validateElement(string $type, string $element) { if (!in_array($element, $this->{$type})) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; throw new InvalidArgumentException("Breadcrumbs::{$trace} was passed \"$element\", but " . "this is not a valid element. Allowed list : " . implode(' ', $this->{$type})); } }
php
protected function validateElement(string $type, string $element) { if (!in_array($element, $this->{$type})) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function']; throw new InvalidArgumentException("Breadcrumbs::{$trace} was passed \"$element\", but " . "this is not a valid element. Allowed list : " . implode(' ', $this->{$type})); } }
[ "protected", "function", "validateElement", "(", "string", "$", "type", ",", "string", "$", "element", ")", "{", "if", "(", "!", "in_array", "(", "$", "element", ",", "$", "this", "->", "{", "$", "type", "}", ")", ")", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ",", "2", ")", "[", "1", "]", "[", "'function'", "]", ";", "throw", "new", "InvalidArgumentException", "(", "\"Breadcrumbs::{$trace} was passed \\\"$element\\\", but \"", ".", "\"this is not a valid element. Allowed list : \"", ".", "implode", "(", "' '", ",", "$", "this", "->", "{", "$", "type", "}", ")", ")", ";", "}", "}" ]
Validate an Element before saving it. @param string $type The type from where we must validate the Element. @param string $element The Element to validate. @throws \InvalidArgumentException When the validation fail. @return void
[ "Validate", "an", "Element", "before", "saving", "it", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L455-L463
Xety/Breadcrumbs
src/BreadcrumbsTrait.php
BreadcrumbsTrait.validateClasses
protected function validateClasses($classes) { if (!is_array($classes)) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function']; throw new InvalidArgumentException("Breadcrumbs::{$trace}() only accepts strings or arrays."); } foreach ($classes as $key => $class) { if (!is_string($class)) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function']; throw new InvalidArgumentException( "Breadcrumbs::{$trace}() was passed an array, but at least one of the values " . "was not a string: \$classes['{$key}'] = " . print_r($class, true) ); } } }
php
protected function validateClasses($classes) { if (!is_array($classes)) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function']; throw new InvalidArgumentException("Breadcrumbs::{$trace}() only accepts strings or arrays."); } foreach ($classes as $key => $class) { if (!is_string($class)) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function']; throw new InvalidArgumentException( "Breadcrumbs::{$trace}() was passed an array, but at least one of the values " . "was not a string: \$classes['{$key}'] = " . print_r($class, true) ); } } }
[ "protected", "function", "validateClasses", "(", "$", "classes", ")", "{", "if", "(", "!", "is_array", "(", "$", "classes", ")", ")", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ",", "3", ")", "[", "2", "]", "[", "'function'", "]", ";", "throw", "new", "InvalidArgumentException", "(", "\"Breadcrumbs::{$trace}() only accepts strings or arrays.\"", ")", ";", "}", "foreach", "(", "$", "classes", "as", "$", "key", "=>", "$", "class", ")", "{", "if", "(", "!", "is_string", "(", "$", "class", ")", ")", "{", "$", "trace", "=", "debug_backtrace", "(", "DEBUG_BACKTRACE_IGNORE_ARGS", ",", "3", ")", "[", "2", "]", "[", "'function'", "]", ";", "throw", "new", "InvalidArgumentException", "(", "\"Breadcrumbs::{$trace}() was passed an array, but at least one of the values \"", ".", "\"was not a string: \\$classes['{$key}'] = \"", ".", "print_r", "(", "$", "class", ",", "true", ")", ")", ";", "}", "}", "}" ]
Validate the classes to ensure they have the right format. @param array $classes The classes to validate. @throws \InvalidArgumentException When the classes is not an array or a string. Or when the class name is not a string. @return void
[ "Validate", "the", "classes", "to", "ensure", "they", "have", "the", "right", "format", "." ]
train
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L475-L493
i-lateral/silverstripe-users
code/forms/Users_EditAccountForm.php
Users_EditAccountForm.doUpdate
public function doUpdate($data) { $filter = array(); $member = Member::get()->byID($data["ID"]); $this->extend("onBeforeUpdate", $data); // Check that a member isn't trying to mess up another users profile if (Member::currentUserID() && $member->canEdit(Member::currentUser())) { try { // Save member $this->saveInto($member); $member->write(); $this->sessionMessage( _t("Users.DETAILSUPDATED", "Account details updated"), "success" ); } catch (Exception $e) { $this->sessionMessage( $e->getMessage(), "warning" ); } } else { $this->sessionMessage( _t("Users.CANNOTEDIT", "You cannot edit this account"), "warning" ); } $this->extend("onAfterUpdate", $data); return $this->controller->redirectBack(); }
php
public function doUpdate($data) { $filter = array(); $member = Member::get()->byID($data["ID"]); $this->extend("onBeforeUpdate", $data); // Check that a member isn't trying to mess up another users profile if (Member::currentUserID() && $member->canEdit(Member::currentUser())) { try { // Save member $this->saveInto($member); $member->write(); $this->sessionMessage( _t("Users.DETAILSUPDATED", "Account details updated"), "success" ); } catch (Exception $e) { $this->sessionMessage( $e->getMessage(), "warning" ); } } else { $this->sessionMessage( _t("Users.CANNOTEDIT", "You cannot edit this account"), "warning" ); } $this->extend("onAfterUpdate", $data); return $this->controller->redirectBack(); }
[ "public", "function", "doUpdate", "(", "$", "data", ")", "{", "$", "filter", "=", "array", "(", ")", ";", "$", "member", "=", "Member", "::", "get", "(", ")", "->", "byID", "(", "$", "data", "[", "\"ID\"", "]", ")", ";", "$", "this", "->", "extend", "(", "\"onBeforeUpdate\"", ",", "$", "data", ")", ";", "// Check that a member isn't trying to mess up another users profile", "if", "(", "Member", "::", "currentUserID", "(", ")", "&&", "$", "member", "->", "canEdit", "(", "Member", "::", "currentUser", "(", ")", ")", ")", "{", "try", "{", "// Save member", "$", "this", "->", "saveInto", "(", "$", "member", ")", ";", "$", "member", "->", "write", "(", ")", ";", "$", "this", "->", "sessionMessage", "(", "_t", "(", "\"Users.DETAILSUPDATED\"", ",", "\"Account details updated\"", ")", ",", "\"success\"", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "sessionMessage", "(", "$", "e", "->", "getMessage", "(", ")", ",", "\"warning\"", ")", ";", "}", "}", "else", "{", "$", "this", "->", "sessionMessage", "(", "_t", "(", "\"Users.CANNOTEDIT\"", ",", "\"You cannot edit this account\"", ")", ",", "\"warning\"", ")", ";", "}", "$", "this", "->", "extend", "(", "\"onAfterUpdate\"", ",", "$", "data", ")", ";", "return", "$", "this", "->", "controller", "->", "redirectBack", "(", ")", ";", "}" ]
Register a new member @param array $data User submitted data @return SS_HTTPResponse
[ "Register", "a", "new", "member" ]
train
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/forms/Users_EditAccountForm.php#L107-L141
titledk/silverstripe-uploaddirrules
code/rules/SubsiteUploadDirRules.php
SubsiteUploadDirRules.calc_directory_for_subsite
public static function calc_directory_for_subsite($subsite) { //$subsite = Subsite::currentSubsite(); if ($subsite) { $title = $subsite->Title; $url = strtolower(singleton('SiteTree')->generateURLSegment($title)); return $url; } else { return false; } }
php
public static function calc_directory_for_subsite($subsite) { //$subsite = Subsite::currentSubsite(); if ($subsite) { $title = $subsite->Title; $url = strtolower(singleton('SiteTree')->generateURLSegment($title)); return $url; } else { return false; } }
[ "public", "static", "function", "calc_directory_for_subsite", "(", "$", "subsite", ")", "{", "//$subsite = Subsite::currentSubsite();", "if", "(", "$", "subsite", ")", "{", "$", "title", "=", "$", "subsite", "->", "Title", ";", "$", "url", "=", "strtolower", "(", "singleton", "(", "'SiteTree'", ")", "->", "generateURLSegment", "(", "$", "title", ")", ")", ";", "return", "$", "url", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Base rules for subsite directory TODO make it configurable, allowing for subsite dirs to be either in the root, or inside of a "subsites" directory. @return bool|string
[ "Base", "rules", "for", "subsite", "directory", "TODO", "make", "it", "configurable", "allowing", "for", "subsite", "dirs", "to", "be", "either", "in", "the", "root", "or", "inside", "of", "a", "subsites", "directory", "." ]
train
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/SubsiteUploadDirRules.php#L16-L27
titledk/silverstripe-uploaddirrules
code/rules/SubsiteUploadDirRules.php
SubsiteUploadDirRules.get_directory_for_current_subsite
public static function get_directory_for_current_subsite() { $subsite = Subsite::currentSubsite(); if ($subsite) { if ((int) $subsite->AssetsFolderID > 0) { $dirObj = $subsite->AssetsFolder(); $dirName = str_replace('assets/', '', $dirObj->Filename); //make sure we've got no trailing slashes $dirName = str_replace('/', '', $dirName); return $dirName; } } else { return false; } }
php
public static function get_directory_for_current_subsite() { $subsite = Subsite::currentSubsite(); if ($subsite) { if ((int) $subsite->AssetsFolderID > 0) { $dirObj = $subsite->AssetsFolder(); $dirName = str_replace('assets/', '', $dirObj->Filename); //make sure we've got no trailing slashes $dirName = str_replace('/', '', $dirName); return $dirName; } } else { return false; } }
[ "public", "static", "function", "get_directory_for_current_subsite", "(", ")", "{", "$", "subsite", "=", "Subsite", "::", "currentSubsite", "(", ")", ";", "if", "(", "$", "subsite", ")", "{", "if", "(", "(", "int", ")", "$", "subsite", "->", "AssetsFolderID", ">", "0", ")", "{", "$", "dirObj", "=", "$", "subsite", "->", "AssetsFolder", "(", ")", ";", "$", "dirName", "=", "str_replace", "(", "'assets/'", ",", "''", ",", "$", "dirObj", "->", "Filename", ")", ";", "//make sure we've got no trailing slashes", "$", "dirName", "=", "str_replace", "(", "'/'", ",", "''", ",", "$", "dirName", ")", ";", "return", "$", "dirName", ";", "}", "}", "else", "{", "return", "false", ";", "}", "}" ]
Getting subsite directory based on it's assets folder. @return bool|mixed
[ "Getting", "subsite", "directory", "based", "on", "it", "s", "assets", "folder", "." ]
train
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/SubsiteUploadDirRules.php#L34-L51
titledk/silverstripe-uploaddirrules
code/rules/SubsiteUploadDirRules.php
SubsiteUploadDirRules.calc_full_directory_for_object
public static function calc_full_directory_for_object(DataObject $do) { if ($do->ClassName == 'Subsite') { //This is the subsite creation //we only want the subsite part return self::calc_directory_for_subsite($do); } else { //If we're dealing with a path inside of a subsites, //we need at least be sure that the subsite is having an asset directory //NOTE: this only works when on the actual subsite $subsite_dir = self::get_directory_for_current_subsite(); if ($subsite_dir) { $str = parent::calc_full_directory_for_object($do); $str = "$subsite_dir/$str"; return $str; } else { return false; } } }
php
public static function calc_full_directory_for_object(DataObject $do) { if ($do->ClassName == 'Subsite') { //This is the subsite creation //we only want the subsite part return self::calc_directory_for_subsite($do); } else { //If we're dealing with a path inside of a subsites, //we need at least be sure that the subsite is having an asset directory //NOTE: this only works when on the actual subsite $subsite_dir = self::get_directory_for_current_subsite(); if ($subsite_dir) { $str = parent::calc_full_directory_for_object($do); $str = "$subsite_dir/$str"; return $str; } else { return false; } } }
[ "public", "static", "function", "calc_full_directory_for_object", "(", "DataObject", "$", "do", ")", "{", "if", "(", "$", "do", "->", "ClassName", "==", "'Subsite'", ")", "{", "//This is the subsite creation", "//we only want the subsite part", "return", "self", "::", "calc_directory_for_subsite", "(", "$", "do", ")", ";", "}", "else", "{", "//If we're dealing with a path inside of a subsites,", "//we need at least be sure that the subsite is having an asset directory", "//NOTE: this only works when on the actual subsite", "$", "subsite_dir", "=", "self", "::", "get_directory_for_current_subsite", "(", ")", ";", "if", "(", "$", "subsite_dir", ")", "{", "$", "str", "=", "parent", "::", "calc_full_directory_for_object", "(", "$", "do", ")", ";", "$", "str", "=", "\"$subsite_dir/$str\"", ";", "return", "$", "str", ";", "}", "else", "{", "return", "false", ";", "}", "}", "}" ]
Full subsite directory. @param DataObject $do @return bool|string
[ "Full", "subsite", "directory", "." ]
train
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/SubsiteUploadDirRules.php#L69-L90
DevGroup-ru/yii2-measure
src/models/Measure.php
Measure.validateConverterClass
public function validateConverterClass($attribute, $params) { $className = $this->$attribute; if (class_exists($className) === true) { if (new $className instanceof MeasureConverterInterface === false) { $this->addError($attribute, MeasureHelper::t('Class does not implement `DevGroup\Measure\converters\MeasureConverterInterface` interface')); } } else { $this->addError($attribute, MeasureHelper::t('Class not found')); } }
php
public function validateConverterClass($attribute, $params) { $className = $this->$attribute; if (class_exists($className) === true) { if (new $className instanceof MeasureConverterInterface === false) { $this->addError($attribute, MeasureHelper::t('Class does not implement `DevGroup\Measure\converters\MeasureConverterInterface` interface')); } } else { $this->addError($attribute, MeasureHelper::t('Class not found')); } }
[ "public", "function", "validateConverterClass", "(", "$", "attribute", ",", "$", "params", ")", "{", "$", "className", "=", "$", "this", "->", "$", "attribute", ";", "if", "(", "class_exists", "(", "$", "className", ")", "===", "true", ")", "{", "if", "(", "new", "$", "className", "instanceof", "MeasureConverterInterface", "===", "false", ")", "{", "$", "this", "->", "addError", "(", "$", "attribute", ",", "MeasureHelper", "::", "t", "(", "'Class does not implement `DevGroup\\Measure\\converters\\MeasureConverterInterface` interface'", ")", ")", ";", "}", "}", "else", "{", "$", "this", "->", "addError", "(", "$", "attribute", ",", "MeasureHelper", "::", "t", "(", "'Class not found'", ")", ")", ";", "}", "}" ]
Validate the converter class name @param string $attribute @param array $params
[ "Validate", "the", "converter", "class", "name" ]
train
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L44-L54
DevGroup-ru/yii2-measure
src/models/Measure.php
Measure.getTypes
public static function getTypes() { $typesList = []; foreach (Yii::$app->db->getTableSchema(static::tableName())->columns['type']->enumValues as $type) { $typesList[$type] = MeasureHelper::t($type); } return $typesList; }
php
public static function getTypes() { $typesList = []; foreach (Yii::$app->db->getTableSchema(static::tableName())->columns['type']->enumValues as $type) { $typesList[$type] = MeasureHelper::t($type); } return $typesList; }
[ "public", "static", "function", "getTypes", "(", ")", "{", "$", "typesList", "=", "[", "]", ";", "foreach", "(", "Yii", "::", "$", "app", "->", "db", "->", "getTableSchema", "(", "static", "::", "tableName", "(", ")", ")", "->", "columns", "[", "'type'", "]", "->", "enumValues", "as", "$", "type", ")", "{", "$", "typesList", "[", "$", "type", "]", "=", "MeasureHelper", "::", "t", "(", "$", "type", ")", ";", "}", "return", "$", "typesList", ";", "}" ]
Get list of measure types. @return array of types in the next format `'TypeName' => 'Translated type name'`
[ "Get", "list", "of", "measure", "types", "." ]
train
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L60-L67
DevGroup-ru/yii2-measure
src/models/Measure.php
Measure.getFormatter
public function getFormatter() { if ($this->formatterInstance === null) { $this->formatterInstance = Yii::createObject( [ 'class' => '\yii\i18n\Formatter', 'decimalSeparator' => $this->decimal_separator, 'thousandSeparator' => $this->thousand_separator, 'numberFormatterOptions' => [ \NumberFormatter::MIN_FRACTION_DIGITS => $this->min_fraction_digits, \NumberFormatter::MAX_FRACTION_DIGITS => $this->max_fraction_digits, ] ] ); } return $this->formatterInstance; }
php
public function getFormatter() { if ($this->formatterInstance === null) { $this->formatterInstance = Yii::createObject( [ 'class' => '\yii\i18n\Formatter', 'decimalSeparator' => $this->decimal_separator, 'thousandSeparator' => $this->thousand_separator, 'numberFormatterOptions' => [ \NumberFormatter::MIN_FRACTION_DIGITS => $this->min_fraction_digits, \NumberFormatter::MAX_FRACTION_DIGITS => $this->max_fraction_digits, ] ] ); } return $this->formatterInstance; }
[ "public", "function", "getFormatter", "(", ")", "{", "if", "(", "$", "this", "->", "formatterInstance", "===", "null", ")", "{", "$", "this", "->", "formatterInstance", "=", "Yii", "::", "createObject", "(", "[", "'class'", "=>", "'\\yii\\i18n\\Formatter'", ",", "'decimalSeparator'", "=>", "$", "this", "->", "decimal_separator", ",", "'thousandSeparator'", "=>", "$", "this", "->", "thousand_separator", ",", "'numberFormatterOptions'", "=>", "[", "\\", "NumberFormatter", "::", "MIN_FRACTION_DIGITS", "=>", "$", "this", "->", "min_fraction_digits", ",", "\\", "NumberFormatter", "::", "MAX_FRACTION_DIGITS", "=>", "$", "this", "->", "max_fraction_digits", ",", "]", "]", ")", ";", "}", "return", "$", "this", "->", "formatterInstance", ";", "}" ]
Returns \yii\i18n\Formatter instance for current Currency instance @return \yii\i18n\Formatter @throws InvalidConfigException
[ "Returns", "\\", "yii", "\\", "i18n", "\\", "Formatter", "instance", "for", "current", "Currency", "instance" ]
train
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L119-L135
DevGroup-ru/yii2-measure
src/models/Measure.php
Measure.getMeasures
public static function getMeasures($type) { /** @var ActiveQuery $query */ $query = static::find()->select(['name', 'id'])->indexBy('id'); if (empty($type) === false) { $query->where(['type' => $type]); } return $query->column(); }
php
public static function getMeasures($type) { /** @var ActiveQuery $query */ $query = static::find()->select(['name', 'id'])->indexBy('id'); if (empty($type) === false) { $query->where(['type' => $type]); } return $query->column(); }
[ "public", "static", "function", "getMeasures", "(", "$", "type", ")", "{", "/** @var ActiveQuery $query */", "$", "query", "=", "static", "::", "find", "(", ")", "->", "select", "(", "[", "'name'", ",", "'id'", "]", ")", "->", "indexBy", "(", "'id'", ")", ";", "if", "(", "empty", "(", "$", "type", ")", "===", "false", ")", "{", "$", "query", "->", "where", "(", "[", "'type'", "=>", "$", "type", "]", ")", ";", "}", "return", "$", "query", "->", "column", "(", ")", ";", "}" ]
Get measures by type name. @param string $type @return array of measures in the next format `measure_id => 'Measure name'`
[ "Get", "measures", "by", "type", "name", "." ]
train
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L152-L160
skmetaly/laravel-twitch-restful-api
src/API/Authentication.php
Authentication.authenticationURL
public function authenticationURL() { $clientId = config('twitch-api.client_id'); $scopes = implode('+', config('twitch-api.scopes')); $redirectURL = config('twitch-api.redirect_url'); return config('twitch-api.api_url') . '/kraken/oauth2/authorize?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectURL . '&scope=' . $scopes; }
php
public function authenticationURL() { $clientId = config('twitch-api.client_id'); $scopes = implode('+', config('twitch-api.scopes')); $redirectURL = config('twitch-api.redirect_url'); return config('twitch-api.api_url') . '/kraken/oauth2/authorize?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectURL . '&scope=' . $scopes; }
[ "public", "function", "authenticationURL", "(", ")", "{", "$", "clientId", "=", "config", "(", "'twitch-api.client_id'", ")", ";", "$", "scopes", "=", "implode", "(", "'+'", ",", "config", "(", "'twitch-api.scopes'", ")", ")", ";", "$", "redirectURL", "=", "config", "(", "'twitch-api.redirect_url'", ")", ";", "return", "config", "(", "'twitch-api.api_url'", ")", ".", "'/kraken/oauth2/authorize?response_type=code&client_id='", ".", "$", "clientId", ".", "'&redirect_uri='", ".", "$", "redirectURL", ".", "'&scope='", ".", "$", "scopes", ";", "}" ]
Returns the authentication URL where the user needs to be redirected to @return string
[ "Returns", "the", "authentication", "URL", "where", "the", "user", "needs", "to", "be", "redirected", "to" ]
train
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Authentication.php#L22-L29
skmetaly/laravel-twitch-restful-api
src/API/Authentication.php
Authentication.requestToken
public function requestToken($code) { $parameters = [ 'client_id' => config('twitch-api.client_id'), 'client_secret' => config('twitch-api.client_secret'), 'redirect_uri' => config('twitch-api.redirect_url'), 'code' => $code, 'grant_type' => 'authorization_code' ]; try { $client = new Client(); $response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]); $response = $response->json(); if (isset($response[ 'access_token' ])) { return $response[ 'access_token' ]; } } catch (\Exception $e) { throw $e; } }
php
public function requestToken($code) { $parameters = [ 'client_id' => config('twitch-api.client_id'), 'client_secret' => config('twitch-api.client_secret'), 'redirect_uri' => config('twitch-api.redirect_url'), 'code' => $code, 'grant_type' => 'authorization_code' ]; try { $client = new Client(); $response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]); $response = $response->json(); if (isset($response[ 'access_token' ])) { return $response[ 'access_token' ]; } } catch (\Exception $e) { throw $e; } }
[ "public", "function", "requestToken", "(", "$", "code", ")", "{", "$", "parameters", "=", "[", "'client_id'", "=>", "config", "(", "'twitch-api.client_id'", ")", ",", "'client_secret'", "=>", "config", "(", "'twitch-api.client_secret'", ")", ",", "'redirect_uri'", "=>", "config", "(", "'twitch-api.redirect_url'", ")", ",", "'code'", "=>", "$", "code", ",", "'grant_type'", "=>", "'authorization_code'", "]", ";", "try", "{", "$", "client", "=", "new", "Client", "(", ")", ";", "$", "response", "=", "$", "client", "->", "post", "(", "config", "(", "'twitch-api.api_url'", ")", ".", "'/kraken/oauth2/token'", ",", "[", "'body'", "=>", "$", "parameters", "]", ")", ";", "$", "response", "=", "$", "response", "->", "json", "(", ")", ";", "if", "(", "isset", "(", "$", "response", "[", "'access_token'", "]", ")", ")", "{", "return", "$", "response", "[", "'access_token'", "]", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Requests a token for a given code @param $code @return mixed @throws \Exception
[ "Requests", "a", "token", "for", "a", "given", "code" ]
train
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Authentication.php#L39-L65
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Html.php
Html.getCorpusIcon
protected function getCorpusIcon() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) return; return $this->getImage($this->currObj->getIcon() . ".png"); }
php
protected function getCorpusIcon() { if($this->currObj instanceof Channel && $this->currObj->isSpacer()) return; return $this->getImage($this->currObj->getIcon() . ".png"); }
[ "protected", "function", "getCorpusIcon", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Channel", "&&", "$", "this", "->", "currObj", "->", "isSpacer", "(", ")", ")", "return", ";", "return", "$", "this", "->", "getImage", "(", "$", "this", "->", "currObj", "->", "getIcon", "(", ")", ".", "\".png\"", ")", ";", "}" ]
Returns a HTML img tag which can be used to display the status icon for a TeamSpeak_Node_Abstract object. @return string
[ "Returns", "a", "HTML", "img", "tag", "which", "can", "be", "used", "to", "display", "the", "status", "icon", "for", "a", "TeamSpeak_Node_Abstract", "object", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Html.php#L329-L334
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3/Viewer/Html.php
Html.getSuffixIcon
protected function getSuffixIcon() { if($this->currObj instanceof Server) { return $this->getSuffixIconServer(); } elseif($this->currObj instanceof Channel) { return $this->getSuffixIconChannel(); } elseif($this->currObj instanceof Client) { return $this->getSuffixIconClient(); } }
php
protected function getSuffixIcon() { if($this->currObj instanceof Server) { return $this->getSuffixIconServer(); } elseif($this->currObj instanceof Channel) { return $this->getSuffixIconChannel(); } elseif($this->currObj instanceof Client) { return $this->getSuffixIconClient(); } }
[ "protected", "function", "getSuffixIcon", "(", ")", "{", "if", "(", "$", "this", "->", "currObj", "instanceof", "Server", ")", "{", "return", "$", "this", "->", "getSuffixIconServer", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Channel", ")", "{", "return", "$", "this", "->", "getSuffixIconChannel", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "currObj", "instanceof", "Client", ")", "{", "return", "$", "this", "->", "getSuffixIconClient", "(", ")", ";", "}", "}" ]
Returns the HTML img tags which can be used to display the various icons for a TeamSpeak_Node_Abstract object. @return string
[ "Returns", "the", "HTML", "img", "tags", "which", "can", "be", "used", "to", "display", "the", "various", "icons", "for", "a", "TeamSpeak_Node_Abstract", "object", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Viewer/Html.php#L406-L420
wenbinye/PhalconX
src/Db/Schema/Index.php
Index.fromIndex
public static function fromIndex(Db\Index $index) { return new self([ 'name' => $index->getName(), 'columns' => $index->getColumns(), 'type' => $index->getType() ]); }
php
public static function fromIndex(Db\Index $index) { return new self([ 'name' => $index->getName(), 'columns' => $index->getColumns(), 'type' => $index->getType() ]); }
[ "public", "static", "function", "fromIndex", "(", "Db", "\\", "Index", "$", "index", ")", "{", "return", "new", "self", "(", "[", "'name'", "=>", "$", "index", "->", "getName", "(", ")", ",", "'columns'", "=>", "$", "index", "->", "getColumns", "(", ")", ",", "'type'", "=>", "$", "index", "->", "getType", "(", ")", "]", ")", ";", "}" ]
convert from Phalcon\Db\Index object
[ "convert", "from", "Phalcon", "\\", "Db", "\\", "Index", "object" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Index.php#L34-L41
wenbinye/PhalconX
src/Db/Schema/Index.php
Index.create
public static function create($name, $definition) { if (preg_match('/^(.*?)KEY\s*\((.*?)\)/', $definition, $matches)) { return new self([ 'name' => $name, 'columns' => preg_split('/\s*,\s*/', $matches[2]), 'type' => trim($matches[1]) ]); } else { throw new \InvalidArgumentException("Invalid index definition '$definition'"); } }
php
public static function create($name, $definition) { if (preg_match('/^(.*?)KEY\s*\((.*?)\)/', $definition, $matches)) { return new self([ 'name' => $name, 'columns' => preg_split('/\s*,\s*/', $matches[2]), 'type' => trim($matches[1]) ]); } else { throw new \InvalidArgumentException("Invalid index definition '$definition'"); } }
[ "public", "static", "function", "create", "(", "$", "name", ",", "$", "definition", ")", "{", "if", "(", "preg_match", "(", "'/^(.*?)KEY\\s*\\((.*?)\\)/'", ",", "$", "definition", ",", "$", "matches", ")", ")", "{", "return", "new", "self", "(", "[", "'name'", "=>", "$", "name", ",", "'columns'", "=>", "preg_split", "(", "'/\\s*,\\s*/'", ",", "$", "matches", "[", "2", "]", ")", ",", "'type'", "=>", "trim", "(", "$", "matches", "[", "1", "]", ")", "]", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid index definition '$definition'\"", ")", ";", "}", "}" ]
create from definition PRIMARY KEY(col1, ...) UNIQUE KEY(col1, ...) KEY(col1, ...)
[ "create", "from", "definition", "PRIMARY", "KEY", "(", "col1", "...", ")", "UNIQUE", "KEY", "(", "col1", "...", ")", "KEY", "(", "col1", "...", ")" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Index.php#L49-L60
wenbinye/PhalconX
src/Db/Schema/Index.php
Index.isSame
public function isSame(Index $other, $renamedColumns = null) { if ($renamedColumns) { $columns = []; foreach ($this->columns as $col) { $columns[] = isset($renamedColumns[$col]) ? $renamedColumns[$col]->name : $col; } } else { $columns = $this->columns; } if ($columns != $other->columns) { return false; } if ($this->name == self::PRIMARY || $other->name == self::PRIMARY) { return $this->name == $other->name; } else { return $this->type == $other->type; } }
php
public function isSame(Index $other, $renamedColumns = null) { if ($renamedColumns) { $columns = []; foreach ($this->columns as $col) { $columns[] = isset($renamedColumns[$col]) ? $renamedColumns[$col]->name : $col; } } else { $columns = $this->columns; } if ($columns != $other->columns) { return false; } if ($this->name == self::PRIMARY || $other->name == self::PRIMARY) { return $this->name == $other->name; } else { return $this->type == $other->type; } }
[ "public", "function", "isSame", "(", "Index", "$", "other", ",", "$", "renamedColumns", "=", "null", ")", "{", "if", "(", "$", "renamedColumns", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "col", ")", "{", "$", "columns", "[", "]", "=", "isset", "(", "$", "renamedColumns", "[", "$", "col", "]", ")", "?", "$", "renamedColumns", "[", "$", "col", "]", "->", "name", ":", "$", "col", ";", "}", "}", "else", "{", "$", "columns", "=", "$", "this", "->", "columns", ";", "}", "if", "(", "$", "columns", "!=", "$", "other", "->", "columns", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "name", "==", "self", "::", "PRIMARY", "||", "$", "other", "->", "name", "==", "self", "::", "PRIMARY", ")", "{", "return", "$", "this", "->", "name", "==", "$", "other", "->", "name", ";", "}", "else", "{", "return", "$", "this", "->", "type", "==", "$", "other", "->", "type", ";", "}", "}" ]
compare with index @param Index $other @param array $renamedColumns @return boolean
[ "compare", "with", "index" ]
train
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Index.php#L100-L118
DesignPond/newsletter
src/Http/Controllers/Backend/ListController.php
ListController.show
public function show($id) { $lists = $this->list->getAll(); $list = $this->list->find($id); return view('newsletter::Backend.lists.emails')->with(['lists' => $lists, 'list' => $list]); }
php
public function show($id) { $lists = $this->list->getAll(); $list = $this->list->find($id); return view('newsletter::Backend.lists.emails')->with(['lists' => $lists, 'list' => $list]); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "lists", "=", "$", "this", "->", "list", "->", "getAll", "(", ")", ";", "$", "list", "=", "$", "this", "->", "list", "->", "find", "(", "$", "id", ")", ";", "return", "view", "(", "'newsletter::Backend.lists.emails'", ")", "->", "with", "(", "[", "'lists'", "=>", "$", "lists", ",", "'list'", "=>", "$", "list", "]", ")", ";", "}" ]
Display a listing of the resource. @return \Illuminate\Http\Response
[ "Display", "a", "listing", "of", "the", "resource", "." ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/ListController.php#L52-L58
DesignPond/newsletter
src/Http/Controllers/Backend/ListController.php
ListController.send
public function send(SendListRequest $request) { $list = $this->list->find($request->input('list_id')); $this->import->send($request->input('campagne_id'),$list); alert()->success('Campagne envoyé à la liste!'); return redirect('build/newsletter'); }
php
public function send(SendListRequest $request) { $list = $this->list->find($request->input('list_id')); $this->import->send($request->input('campagne_id'),$list); alert()->success('Campagne envoyé à la liste!'); return redirect('build/newsletter'); }
[ "public", "function", "send", "(", "SendListRequest", "$", "request", ")", "{", "$", "list", "=", "$", "this", "->", "list", "->", "find", "(", "$", "request", "->", "input", "(", "'list_id'", ")", ")", ";", "$", "this", "->", "import", "->", "send", "(", "$", "request", "->", "input", "(", "'campagne_id'", ")", ",", "$", "list", ")", ";", "alert", "(", ")", "->", "success", "(", "'Campagne envoyé à la liste!');", "", "", "return", "redirect", "(", "'build/newsletter'", ")", ";", "}" ]
Send test campagne @return \Illuminate\Http\Response
[ "Send", "test", "campagne" ]
train
https://github.com/DesignPond/newsletter/blob/0bf0e7a8a42fa4b90a5e937771bb80058e0a91c3/src/Http/Controllers/Backend/ListController.php#L65-L74
Avatar4eg/flarum-ext-geotags
src/Api/Serializer/GeotagBasicSerializer.php
GeotagBasicSerializer.getDefaultAttributes
protected function getDefaultAttributes($geotag) { if (! ($geotag instanceof Geotag)) { throw new InvalidArgumentException(get_class($this) . ' can only serialize instances of ' . Geotag::class); } return [ 'title' => $geotag->title, 'country' => $geotag->country, 'lat' => (float) $geotag->lat, 'lng' => (float) $geotag->lng ]; }
php
protected function getDefaultAttributes($geotag) { if (! ($geotag instanceof Geotag)) { throw new InvalidArgumentException(get_class($this) . ' can only serialize instances of ' . Geotag::class); } return [ 'title' => $geotag->title, 'country' => $geotag->country, 'lat' => (float) $geotag->lat, 'lng' => (float) $geotag->lng ]; }
[ "protected", "function", "getDefaultAttributes", "(", "$", "geotag", ")", "{", "if", "(", "!", "(", "$", "geotag", "instanceof", "Geotag", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "get_class", "(", "$", "this", ")", ".", "' can only serialize instances of '", ".", "Geotag", "::", "class", ")", ";", "}", "return", "[", "'title'", "=>", "$", "geotag", "->", "title", ",", "'country'", "=>", "$", "geotag", "->", "country", ",", "'lat'", "=>", "(", "float", ")", "$", "geotag", "->", "lat", ",", "'lng'", "=>", "(", "float", ")", "$", "geotag", "->", "lng", "]", ";", "}" ]
{@inheritdoc} @param Geotag $geotag @throws InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/Avatar4eg/flarum-ext-geotags/blob/a54216a02a3e0abc908f9ba3aec69431f906fb92/src/Api/Serializer/GeotagBasicSerializer.php#L35-L48
surebert/surebert-framework
src/sb/Email/Writer.php
Writer.send
public function send($email = 0) { if ($email instanceof Email) { $this->addEmailToOutbox($email); } $sent_emails = 0; foreach ($this->emails as &$email) { //all email goes to DEBUG_EMAIL if specified if (defined("DEBUG_EMAIL")) { $email->debug_info = "\n\nDEBUG MODE: Should be sent to: " . $email->to . " when not in debug mode!"; $email->debug_info .= "\nDEBUG MODE: Should be sent from: " . $email->from . " when not in debug mode!"; $email->to = \DEBUG_EMAIL; $email->from = \DEBUG_EMAIL; if (!empty($email->cc)) { $email->debug_info .= "\nDEBUG MODE: Should be be CCed to: " . implode(", ", $email->cc) . " when not in debug mode!"; $email->cc = Array(); } if (!empty($email->bcc)) { $email->debug_info .= "\nDEBUG MODE: Should be be BCCed to: " . implode(", ", $email->bcc) . " when not in debug mode!"; $email->bcc = Array(); } $email->body .= $email->debug_info; if (!empty($email->body_HTML)) { $email->body_HTML .= nl2br($email->debug_info); } } $email->to = $email->to ? $email->to : null; $email->constructMultipartMessage(); //sanitize sender params if(preg_match("~<(.*?)>~", $email->from, $match)){ $sender = $match[1]; } else { $sender = $email->from; } $sender = filter_var($sender, FILTER_SANITIZE_EMAIL); $params = sprintf('-f%s', escapeshellcmd($sender)); if (mail($email->to, $email->subject, $email->body, $email->_header_text, $params)) { $email->sent = 1; $sent_emails++; $this->logEmail($email, true); } else { $this->logEmail($email, false); } } $emails_cnt = count($this->emails); $this->emails = Array(); if ($sent_emails == $emails_cnt) { return true; } else { return false; } }
php
public function send($email = 0) { if ($email instanceof Email) { $this->addEmailToOutbox($email); } $sent_emails = 0; foreach ($this->emails as &$email) { //all email goes to DEBUG_EMAIL if specified if (defined("DEBUG_EMAIL")) { $email->debug_info = "\n\nDEBUG MODE: Should be sent to: " . $email->to . " when not in debug mode!"; $email->debug_info .= "\nDEBUG MODE: Should be sent from: " . $email->from . " when not in debug mode!"; $email->to = \DEBUG_EMAIL; $email->from = \DEBUG_EMAIL; if (!empty($email->cc)) { $email->debug_info .= "\nDEBUG MODE: Should be be CCed to: " . implode(", ", $email->cc) . " when not in debug mode!"; $email->cc = Array(); } if (!empty($email->bcc)) { $email->debug_info .= "\nDEBUG MODE: Should be be BCCed to: " . implode(", ", $email->bcc) . " when not in debug mode!"; $email->bcc = Array(); } $email->body .= $email->debug_info; if (!empty($email->body_HTML)) { $email->body_HTML .= nl2br($email->debug_info); } } $email->to = $email->to ? $email->to : null; $email->constructMultipartMessage(); //sanitize sender params if(preg_match("~<(.*?)>~", $email->from, $match)){ $sender = $match[1]; } else { $sender = $email->from; } $sender = filter_var($sender, FILTER_SANITIZE_EMAIL); $params = sprintf('-f%s', escapeshellcmd($sender)); if (mail($email->to, $email->subject, $email->body, $email->_header_text, $params)) { $email->sent = 1; $sent_emails++; $this->logEmail($email, true); } else { $this->logEmail($email, false); } } $emails_cnt = count($this->emails); $this->emails = Array(); if ($sent_emails == $emails_cnt) { return true; } else { return false; } }
[ "public", "function", "send", "(", "$", "email", "=", "0", ")", "{", "if", "(", "$", "email", "instanceof", "Email", ")", "{", "$", "this", "->", "addEmailToOutbox", "(", "$", "email", ")", ";", "}", "$", "sent_emails", "=", "0", ";", "foreach", "(", "$", "this", "->", "emails", "as", "&", "$", "email", ")", "{", "//all email goes to DEBUG_EMAIL if specified", "if", "(", "defined", "(", "\"DEBUG_EMAIL\"", ")", ")", "{", "$", "email", "->", "debug_info", "=", "\"\\n\\nDEBUG MODE: Should be sent to: \"", ".", "$", "email", "->", "to", ".", "\" when not in debug mode!\"", ";", "$", "email", "->", "debug_info", ".=", "\"\\nDEBUG MODE: Should be sent from: \"", ".", "$", "email", "->", "from", ".", "\" when not in debug mode!\"", ";", "$", "email", "->", "to", "=", "\\", "DEBUG_EMAIL", ";", "$", "email", "->", "from", "=", "\\", "DEBUG_EMAIL", ";", "if", "(", "!", "empty", "(", "$", "email", "->", "cc", ")", ")", "{", "$", "email", "->", "debug_info", ".=", "\"\\nDEBUG MODE: Should be be CCed to: \"", ".", "implode", "(", "\", \"", ",", "$", "email", "->", "cc", ")", ".", "\" when not in debug mode!\"", ";", "$", "email", "->", "cc", "=", "Array", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "email", "->", "bcc", ")", ")", "{", "$", "email", "->", "debug_info", ".=", "\"\\nDEBUG MODE: Should be be BCCed to: \"", ".", "implode", "(", "\", \"", ",", "$", "email", "->", "bcc", ")", ".", "\" when not in debug mode!\"", ";", "$", "email", "->", "bcc", "=", "Array", "(", ")", ";", "}", "$", "email", "->", "body", ".=", "$", "email", "->", "debug_info", ";", "if", "(", "!", "empty", "(", "$", "email", "->", "body_HTML", ")", ")", "{", "$", "email", "->", "body_HTML", ".=", "nl2br", "(", "$", "email", "->", "debug_info", ")", ";", "}", "}", "$", "email", "->", "to", "=", "$", "email", "->", "to", "?", "$", "email", "->", "to", ":", "null", ";", "$", "email", "->", "constructMultipartMessage", "(", ")", ";", "//sanitize sender params", "if", "(", "preg_match", "(", "\"~<(.*?)>~\"", ",", "$", "email", "->", "from", ",", "$", "match", ")", ")", "{", "$", "sender", "=", "$", "match", "[", "1", "]", ";", "}", "else", "{", "$", "sender", "=", "$", "email", "->", "from", ";", "}", "$", "sender", "=", "filter_var", "(", "$", "sender", ",", "FILTER_SANITIZE_EMAIL", ")", ";", "$", "params", "=", "sprintf", "(", "'-f%s'", ",", "escapeshellcmd", "(", "$", "sender", ")", ")", ";", "if", "(", "mail", "(", "$", "email", "->", "to", ",", "$", "email", "->", "subject", ",", "$", "email", "->", "body", ",", "$", "email", "->", "_header_text", ",", "$", "params", ")", ")", "{", "$", "email", "->", "sent", "=", "1", ";", "$", "sent_emails", "++", ";", "$", "this", "->", "logEmail", "(", "$", "email", ",", "true", ")", ";", "}", "else", "{", "$", "this", "->", "logEmail", "(", "$", "email", ",", "false", ")", ";", "}", "}", "$", "emails_cnt", "=", "count", "(", "$", "this", "->", "emails", ")", ";", "$", "this", "->", "emails", "=", "Array", "(", ")", ";", "if", "(", "$", "sent_emails", "==", "$", "emails_cnt", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Sends the emails in the $emails array that were attached using addEmailToOutbox, logs progress if log file is specified
[ "Sends", "the", "emails", "in", "the", "$emails", "array", "that", "were", "attached", "using", "addEmailToOutbox", "logs", "progress", "if", "log", "file", "is", "specified" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L90-L159
surebert/surebert-framework
src/sb/Email/Writer.php
Writer.addEmailToOutbox
public function addEmailToOutbox(\sb\Email $email) { if ($this->checkHeadersForInjection($email)) { return 0; } else { $this->emails[] = $email; return true; } }
php
public function addEmailToOutbox(\sb\Email $email) { if ($this->checkHeadersForInjection($email)) { return 0; } else { $this->emails[] = $email; return true; } }
[ "public", "function", "addEmailToOutbox", "(", "\\", "sb", "\\", "Email", "$", "email", ")", "{", "if", "(", "$", "this", "->", "checkHeadersForInjection", "(", "$", "email", ")", ")", "{", "return", "0", ";", "}", "else", "{", "$", "this", "->", "emails", "[", "]", "=", "$", "email", ";", "return", "true", ";", "}", "}" ]
Adds an email to the outbox which is sent with the send method @param \sb\Email $email @return boolean false if it has injectors, true if added to outbox
[ "Adds", "an", "email", "to", "the", "outbox", "which", "is", "sent", "with", "the", "send", "method" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L167-L178
surebert/surebert-framework
src/sb/Email/Writer.php
Writer.logEmail
private function logEmail($email, $sent) { $message = "\nEmail sent at " . date('m/d/y h:i:s'); $message .= "\nFrom:" . $email->from . '@' . $this->remote_addr; $message .= "\nTo: " . $email->to; foreach ($email->cc as $cc) { $message .="\nCc:" . $cc; } foreach ($email->bcc as $bcc) { $message .="\nBcc:" . $bcc; } $message .= "\nSubject: " . $email->subject; $message .= "\nAttachments: " . count($email->attachments) . ' '; if ($this->log_body) { $message .= "\nBody: " . $email->body; $message .= "\nBody_HTML: " . $email->body_HTML; } $names = Array(); foreach ($email->attachments as $attachment) { $names[] = $attachment->name; } $message .= "(" . \implode(",", $names) . ")"; if ($sent) { return $this->logger->sbEmailWriterSent($message); } else { return $this->logger->sbEmailWriterError($message); } }
php
private function logEmail($email, $sent) { $message = "\nEmail sent at " . date('m/d/y h:i:s'); $message .= "\nFrom:" . $email->from . '@' . $this->remote_addr; $message .= "\nTo: " . $email->to; foreach ($email->cc as $cc) { $message .="\nCc:" . $cc; } foreach ($email->bcc as $bcc) { $message .="\nBcc:" . $bcc; } $message .= "\nSubject: " . $email->subject; $message .= "\nAttachments: " . count($email->attachments) . ' '; if ($this->log_body) { $message .= "\nBody: " . $email->body; $message .= "\nBody_HTML: " . $email->body_HTML; } $names = Array(); foreach ($email->attachments as $attachment) { $names[] = $attachment->name; } $message .= "(" . \implode(",", $names) . ")"; if ($sent) { return $this->logger->sbEmailWriterSent($message); } else { return $this->logger->sbEmailWriterError($message); } }
[ "private", "function", "logEmail", "(", "$", "email", ",", "$", "sent", ")", "{", "$", "message", "=", "\"\\nEmail sent at \"", ".", "date", "(", "'m/d/y h:i:s'", ")", ";", "$", "message", ".=", "\"\\nFrom:\"", ".", "$", "email", "->", "from", ".", "'@'", ".", "$", "this", "->", "remote_addr", ";", "$", "message", ".=", "\"\\nTo: \"", ".", "$", "email", "->", "to", ";", "foreach", "(", "$", "email", "->", "cc", "as", "$", "cc", ")", "{", "$", "message", ".=", "\"\\nCc:\"", ".", "$", "cc", ";", "}", "foreach", "(", "$", "email", "->", "bcc", "as", "$", "bcc", ")", "{", "$", "message", ".=", "\"\\nBcc:\"", ".", "$", "bcc", ";", "}", "$", "message", ".=", "\"\\nSubject: \"", ".", "$", "email", "->", "subject", ";", "$", "message", ".=", "\"\\nAttachments: \"", ".", "count", "(", "$", "email", "->", "attachments", ")", ".", "' '", ";", "if", "(", "$", "this", "->", "log_body", ")", "{", "$", "message", ".=", "\"\\nBody: \"", ".", "$", "email", "->", "body", ";", "$", "message", ".=", "\"\\nBody_HTML: \"", ".", "$", "email", "->", "body_HTML", ";", "}", "$", "names", "=", "Array", "(", ")", ";", "foreach", "(", "$", "email", "->", "attachments", "as", "$", "attachment", ")", "{", "$", "names", "[", "]", "=", "$", "attachment", "->", "name", ";", "}", "$", "message", ".=", "\"(\"", ".", "\\", "implode", "(", "\",\"", ",", "$", "names", ")", ".", "\")\"", ";", "if", "(", "$", "sent", ")", "{", "return", "$", "this", "->", "logger", "->", "sbEmailWriterSent", "(", "$", "message", ")", ";", "}", "else", "{", "return", "$", "this", "->", "logger", "->", "sbEmailWriterError", "(", "$", "message", ")", ";", "}", "}" ]
Logs the sending of emails if logging is enable by specifying the log_file property @param $email \sb\Email @param $sent Boolean, was the email sent or not
[ "Logs", "the", "sending", "of", "emails", "if", "logging", "is", "enable", "by", "specifying", "the", "log_file", "property" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L186-L217
surebert/surebert-framework
src/sb/Email/Writer.php
Writer.checkHeadersForInjection
private function checkHeadersForInjection(\sb\Email $email) { if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) { return true; } return false; }
php
private function checkHeadersForInjection(\sb\Email $email) { if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) { return true; } return false; }
[ "private", "function", "checkHeadersForInjection", "(", "\\", "sb", "\\", "Email", "$", "email", ")", "{", "if", "(", "\\", "preg_match", "(", "\"~\\r|:~i\"", ",", "$", "email", "->", "to", ")", "||", "preg_match", "(", "\"~\\r|:~i\"", ",", "$", "email", "->", "from", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks email for injections in from and to addr @param \sb\Email $email @return boolean
[ "Checks", "email", "for", "injections", "in", "from", "and", "to", "addr" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L225-L233
ArrowSphere/Client
src/xAC/Cursor.php
Cursor.get
public function get() { $uri = null; if ($this->context) { $uri = $this->context->getBaseUri() . '/'; } $uri .= $this->params['endpoint']; $uri .= sprintf("?page=%d&perpage=%d" , $this->page , $this->perpage ); // add filter if value is not empty foreach ($this->filters as $filter) { if (! empty($filter['value'])) { $uri .= sprintf("&%s=%s" , $filter['field'] , rawurlencode($filter['value']) ); } } $res = $this->client->call($uri); // get and preserve pagination $lr = Client::getLastResponse(); $this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : []; // convert array to Entities collection $this->data = []; foreach ($res as $data) { $this->data[] = (new Entity([], $this->client))->setData($data); } $this->current = 0; return $this->data; }
php
public function get() { $uri = null; if ($this->context) { $uri = $this->context->getBaseUri() . '/'; } $uri .= $this->params['endpoint']; $uri .= sprintf("?page=%d&perpage=%d" , $this->page , $this->perpage ); // add filter if value is not empty foreach ($this->filters as $filter) { if (! empty($filter['value'])) { $uri .= sprintf("&%s=%s" , $filter['field'] , rawurlencode($filter['value']) ); } } $res = $this->client->call($uri); // get and preserve pagination $lr = Client::getLastResponse(); $this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : []; // convert array to Entities collection $this->data = []; foreach ($res as $data) { $this->data[] = (new Entity([], $this->client))->setData($data); } $this->current = 0; return $this->data; }
[ "public", "function", "get", "(", ")", "{", "$", "uri", "=", "null", ";", "if", "(", "$", "this", "->", "context", ")", "{", "$", "uri", "=", "$", "this", "->", "context", "->", "getBaseUri", "(", ")", ".", "'/'", ";", "}", "$", "uri", ".=", "$", "this", "->", "params", "[", "'endpoint'", "]", ";", "$", "uri", ".=", "sprintf", "(", "\"?page=%d&perpage=%d\"", ",", "$", "this", "->", "page", ",", "$", "this", "->", "perpage", ")", ";", "// add filter if value is not empty", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "empty", "(", "$", "filter", "[", "'value'", "]", ")", ")", "{", "$", "uri", ".=", "sprintf", "(", "\"&%s=%s\"", ",", "$", "filter", "[", "'field'", "]", ",", "rawurlencode", "(", "$", "filter", "[", "'value'", "]", ")", ")", ";", "}", "}", "$", "res", "=", "$", "this", "->", "client", "->", "call", "(", "$", "uri", ")", ";", "// get and preserve pagination", "$", "lr", "=", "Client", "::", "getLastResponse", "(", ")", ";", "$", "this", "->", "pagination", "=", "isset", "(", "$", "lr", "[", "'body'", "]", ")", "&&", "isset", "(", "$", "lr", "[", "'body'", "]", "[", "'pagination'", "]", ")", "?", "$", "lr", "[", "'body'", "]", "[", "'pagination'", "]", ":", "[", "]", ";", "// convert array to Entities collection", "$", "this", "->", "data", "=", "[", "]", ";", "foreach", "(", "$", "res", "as", "$", "data", ")", "{", "$", "this", "->", "data", "[", "]", "=", "(", "new", "Entity", "(", "[", "]", ",", "$", "this", "->", "client", ")", ")", "->", "setData", "(", "$", "data", ")", ";", "}", "$", "this", "->", "current", "=", "0", ";", "return", "$", "this", "->", "data", ";", "}" ]
Get current data @return array
[ "Get", "current", "data" ]
train
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L86-L123
ArrowSphere/Client
src/xAC/Cursor.php
Cursor.getNext
public function getNext() { if (count($this->pagination) == 0) { $this->get(); } if ($this->page < $this->pagination['total_pages']) { $this->page++; return $this->get(); } return false; }
php
public function getNext() { if (count($this->pagination) == 0) { $this->get(); } if ($this->page < $this->pagination['total_pages']) { $this->page++; return $this->get(); } return false; }
[ "public", "function", "getNext", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "pagination", ")", "==", "0", ")", "{", "$", "this", "->", "get", "(", ")", ";", "}", "if", "(", "$", "this", "->", "page", "<", "$", "this", "->", "pagination", "[", "'total_pages'", "]", ")", "{", "$", "this", "->", "page", "++", ";", "return", "$", "this", "->", "get", "(", ")", ";", "}", "return", "false", ";", "}" ]
Increase page number and get next results batch return array
[ "Increase", "page", "number", "and", "get", "next", "results", "batch", "return", "array" ]
train
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L129-L141
ArrowSphere/Client
src/xAC/Cursor.php
Cursor.setPerPage
public function setPerPage($perpage) { if ($perpage > 0) { $this->perpage = (int) $perpage; $this->page = 1; } return $this; }
php
public function setPerPage($perpage) { if ($perpage > 0) { $this->perpage = (int) $perpage; $this->page = 1; } return $this; }
[ "public", "function", "setPerPage", "(", "$", "perpage", ")", "{", "if", "(", "$", "perpage", ">", "0", ")", "{", "$", "this", "->", "perpage", "=", "(", "int", ")", "$", "perpage", ";", "$", "this", "->", "page", "=", "1", ";", "}", "return", "$", "this", ";", "}" ]
Set per page value, reset page value to 1 @param integer $perpage @return \Arrowsphere\Client\xAC\Cursor
[ "Set", "per", "page", "value", "reset", "page", "value", "to", "1" ]
train
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L173-L181
ArrowSphere/Client
src/xAC/Cursor.php
Cursor.addFilter
public function addFilter($field, $value, $operator= '=') { $this->filter[] = [ 'field' => $field, 'value' => $value, 'operator' => $operator, ]; return $this; }
php
public function addFilter($field, $value, $operator= '=') { $this->filter[] = [ 'field' => $field, 'value' => $value, 'operator' => $operator, ]; return $this; }
[ "public", "function", "addFilter", "(", "$", "field", ",", "$", "value", ",", "$", "operator", "=", "'='", ")", "{", "$", "this", "->", "filter", "[", "]", "=", "[", "'field'", "=>", "$", "field", ",", "'value'", "=>", "$", "value", ",", "'operator'", "=>", "$", "operator", ",", "]", ";", "return", "$", "this", ";", "}" ]
Add a filter that will be passed to the API query @param string $field @param string $value @param string $operator @return \Arrowsphere\Client\xAC\Cursor
[ "Add", "a", "filter", "that", "will", "be", "passed", "to", "the", "API", "query" ]
train
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L200-L209
ArrowSphere/Client
src/xAC/Cursor.php
Cursor.resetFilters
public function resetFilters($field = null) { if (is_null($field)) { $this->filters = []; } else { if (isset($this->filters[$field])) { unset($this->filters[$field]); } } return $this; }
php
public function resetFilters($field = null) { if (is_null($field)) { $this->filters = []; } else { if (isset($this->filters[$field])) { unset($this->filters[$field]); } } return $this; }
[ "public", "function", "resetFilters", "(", "$", "field", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "field", ")", ")", "{", "$", "this", "->", "filters", "=", "[", "]", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "this", "->", "filters", "[", "$", "field", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "filters", "[", "$", "field", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove filter matching given identifier or all filters if empty @param string $field @return \Arrowsphere\Client\xAC\Cursor
[ "Remove", "filter", "matching", "given", "identifier", "or", "all", "filters", "if", "empty" ]
train
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L216-L227
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php
ezcCacheStorageFilePlain.prepareData
protected function prepareData( $data ) { if ( is_scalar( $data ) === false ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple' ) ); } return ( string ) $data; }
php
protected function prepareData( $data ) { if ( is_scalar( $data ) === false ) { throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple' ) ); } return ( string ) $data; }
[ "protected", "function", "prepareData", "(", "$", "data", ")", "{", "if", "(", "is_scalar", "(", "$", "data", ")", "===", "false", ")", "{", "throw", "new", "ezcCacheInvalidDataException", "(", "gettype", "(", "$", "data", ")", ",", "array", "(", "'simple'", ")", ")", ";", "}", "return", "(", "string", ")", "$", "data", ";", "}" ]
Serialize the data for storing. Serializes a PHP variable (except type resource and object) to a executable PHP code representation string. @param mixed $data Simple type or array @return string The serialized data @throws ezcCacheInvalidDataException If the data submitted is an array,object or a resource, since this implementation of {@link ezcCacheStorageFile} can only deal with scalar values.
[ "Serialize", "the", "data", "for", "storing", ".", "Serializes", "a", "PHP", "variable", "(", "except", "type", "resource", "and", "object", ")", "to", "a", "executable", "PHP", "code", "representation", "string", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php#L71-L78
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php
ezcCacheStorageFilePlain.restoreMetaData
public function restoreMetaData() { // Silence require warnings. It's ok that meta data does not exist. $dataStr = @$this->fetchData( $this->properties['location'] . $this->properties['options']->metaDataFile ); $dataArr = unserialize( $dataStr ); $result = null; if ( $dataArr !== false ) { $result = new $dataArr['class'](); $result->setState( $dataArr['data'] ); } return $result; }
php
public function restoreMetaData() { // Silence require warnings. It's ok that meta data does not exist. $dataStr = @$this->fetchData( $this->properties['location'] . $this->properties['options']->metaDataFile ); $dataArr = unserialize( $dataStr ); $result = null; if ( $dataArr !== false ) { $result = new $dataArr['class'](); $result->setState( $dataArr['data'] ); } return $result; }
[ "public", "function", "restoreMetaData", "(", ")", "{", "// Silence require warnings. It's ok that meta data does not exist.", "$", "dataStr", "=", "@", "$", "this", "->", "fetchData", "(", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "properties", "[", "'options'", "]", "->", "metaDataFile", ")", ";", "$", "dataArr", "=", "unserialize", "(", "$", "dataStr", ")", ";", "$", "result", "=", "null", ";", "if", "(", "$", "dataArr", "!==", "false", ")", "{", "$", "result", "=", "new", "$", "dataArr", "[", "'class'", "]", "(", ")", ";", "$", "result", "->", "setState", "(", "$", "dataArr", "[", "'data'", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Restores and returns the meta data struct. This method fetches the meta data stored in the storage and returns the according struct of type {@link ezcCacheStackMetaData}. The meta data must be stored inside the storage, but should not be visible as normal cache items to the user. @return ezcCacheStackMetaData
[ "Restores", "and", "returns", "the", "meta", "data", "struct", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php#L90-L106
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php
ezcCacheStorageFilePlain.storeMetaData
public function storeMetaData( ezcCacheStackMetaData $metaData ) { $dataArr = array( 'class' => get_class( $metaData ), 'data' => $metaData->getState(), ); // This storage only handles scalar values, so we serialize here. $dataStr = serialize( $dataArr ); $this->storeRawData( $this->properties['location'] . $this->properties['options']->metaDataFile, $this->prepareData( $dataStr ) ); }
php
public function storeMetaData( ezcCacheStackMetaData $metaData ) { $dataArr = array( 'class' => get_class( $metaData ), 'data' => $metaData->getState(), ); // This storage only handles scalar values, so we serialize here. $dataStr = serialize( $dataArr ); $this->storeRawData( $this->properties['location'] . $this->properties['options']->metaDataFile, $this->prepareData( $dataStr ) ); }
[ "public", "function", "storeMetaData", "(", "ezcCacheStackMetaData", "$", "metaData", ")", "{", "$", "dataArr", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "metaData", ")", ",", "'data'", "=>", "$", "metaData", "->", "getState", "(", ")", ",", ")", ";", "// This storage only handles scalar values, so we serialize here.", "$", "dataStr", "=", "serialize", "(", "$", "dataArr", ")", ";", "$", "this", "->", "storeRawData", "(", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "properties", "[", "'options'", "]", "->", "metaDataFile", ",", "$", "this", "->", "prepareData", "(", "$", "dataStr", ")", ")", ";", "}" ]
Stores the given meta data struct. This method stores the given $metaData inside the storage. The data must be stored with the same mechanism that the storage itself uses. However, it should not be stored as a normal cache item, if possible, to avoid accedental user manipulation. @param ezcCacheStackMetaData $metaData @return void
[ "Stores", "the", "given", "meta", "data", "struct", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file/plain.php#L119-L131
znck/countries
src/FileLoader.php
FileLoader.load
public function load(string $locale):array { $filename = "{$this->path}/{$locale}.php"; try { $loaded = $this->files->getRequire($filename); if (!is_array($loaded)) { throw new InvalidResourceException(); } return $loaded; } catch (FileNotFoundException $e) { throw new NotFoundResourceException("$filename not found.", 0, $e); } catch (\Throwable $e) { throw new InvalidResourceException("$filename has invalid resources.", 0, $e); } }
php
public function load(string $locale):array { $filename = "{$this->path}/{$locale}.php"; try { $loaded = $this->files->getRequire($filename); if (!is_array($loaded)) { throw new InvalidResourceException(); } return $loaded; } catch (FileNotFoundException $e) { throw new NotFoundResourceException("$filename not found.", 0, $e); } catch (\Throwable $e) { throw new InvalidResourceException("$filename has invalid resources.", 0, $e); } }
[ "public", "function", "load", "(", "string", "$", "locale", ")", ":", "array", "{", "$", "filename", "=", "\"{$this->path}/{$locale}.php\"", ";", "try", "{", "$", "loaded", "=", "$", "this", "->", "files", "->", "getRequire", "(", "$", "filename", ")", ";", "if", "(", "!", "is_array", "(", "$", "loaded", ")", ")", "{", "throw", "new", "InvalidResourceException", "(", ")", ";", "}", "return", "$", "loaded", ";", "}", "catch", "(", "FileNotFoundException", "$", "e", ")", "{", "throw", "new", "NotFoundResourceException", "(", "\"$filename not found.\"", ",", "0", ",", "$", "e", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "throw", "new", "InvalidResourceException", "(", "\"$filename has invalid resources.\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Loads a locale. @param string $locale A locale @throws NotFoundResourceException when the resource cannot be found @throws InvalidResourceException when the resource cannot be loaded @return array
[ "Loads", "a", "locale", "." ]
train
https://github.com/znck/countries/blob/a78a2b302dfa8eacab8fe0c06127dbb37fa98fd3/src/FileLoader.php#L43-L58
impensavel/essence
src/AbstractEssence.php
AbstractEssence.register
public function register(array $element, $key = 'default') { if (! is_array($element['map'])) { throw new EssenceException('['.$key.'] Element property map must be an array'); } if (! isset($element['handler'])) { throw new EssenceException('['.$key.'] Element data handler is not set'); } if (! $element['handler'] instanceof Closure) { throw new EssenceException('['.$key.'] Element data handler must be a Closure'); } $this->maps[$key] = $element['map']; $this->handlers[$key] = $element['handler']; }
php
public function register(array $element, $key = 'default') { if (! is_array($element['map'])) { throw new EssenceException('['.$key.'] Element property map must be an array'); } if (! isset($element['handler'])) { throw new EssenceException('['.$key.'] Element data handler is not set'); } if (! $element['handler'] instanceof Closure) { throw new EssenceException('['.$key.'] Element data handler must be a Closure'); } $this->maps[$key] = $element['map']; $this->handlers[$key] = $element['handler']; }
[ "public", "function", "register", "(", "array", "$", "element", ",", "$", "key", "=", "'default'", ")", "{", "if", "(", "!", "is_array", "(", "$", "element", "[", "'map'", "]", ")", ")", "{", "throw", "new", "EssenceException", "(", "'['", ".", "$", "key", ".", "'] Element property map must be an array'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "element", "[", "'handler'", "]", ")", ")", "{", "throw", "new", "EssenceException", "(", "'['", ".", "$", "key", ".", "'] Element data handler is not set'", ")", ";", "}", "if", "(", "!", "$", "element", "[", "'handler'", "]", "instanceof", "Closure", ")", "{", "throw", "new", "EssenceException", "(", "'['", ".", "$", "key", ".", "'] Element data handler must be a Closure'", ")", ";", "}", "$", "this", "->", "maps", "[", "$", "key", "]", "=", "$", "element", "[", "'map'", "]", ";", "$", "this", "->", "handlers", "[", "$", "key", "]", "=", "$", "element", "[", "'handler'", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/impensavel/essence/blob/e74969e55ac889e8c2cab9a915f82e93a72e629e/src/AbstractEssence.php#L36-L52
odiaseo/pagebuilder
src/PageBuilder/Controller/TemplateController.php
TemplateController.get
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getTemplateLayout($id) ); }
php
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getTemplateLayout($id) ); }
[ "public", "function", "get", "(", "$", "id", ")", "{", "return", "$", "this", "->", "_sendPayload", "(", "$", "this", "->", "_getService", "(", "$", "this", "->", "_pageServiceKey", ")", "->", "getTemplateLayout", "(", "$", "id", ")", ")", ";", "}" ]
Get template details @param mixed $id @return mixed|\Zend\View\Model\ModelInterface
[ "Get", "template", "details" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/TemplateController.php#L18-L23
odiaseo/pagebuilder
src/PageBuilder/Controller/TemplateController.php
TemplateController.update
public function update($id, $data) { $layout = isset($data['layout']) ? $data['layout'] : null; return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->updateTemplateLayout($id, $layout) ); }
php
public function update($id, $data) { $layout = isset($data['layout']) ? $data['layout'] : null; return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->updateTemplateLayout($id, $layout) ); }
[ "public", "function", "update", "(", "$", "id", ",", "$", "data", ")", "{", "$", "layout", "=", "isset", "(", "$", "data", "[", "'layout'", "]", ")", "?", "$", "data", "[", "'layout'", "]", ":", "null", ";", "return", "$", "this", "->", "_sendPayload", "(", "$", "this", "->", "_getService", "(", "$", "this", "->", "_pageServiceKey", ")", "->", "updateTemplateLayout", "(", "$", "id", ",", "$", "layout", ")", ")", ";", "}" ]
Update template @param mixed $id @param mixed $data @return mixed|\Zend\View\Model\ModelInterface
[ "Update", "template" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/TemplateController.php#L33-L40
GrupaZero/api
src/Gzero/Api/Transformer/WidgetTransformer.php
WidgetTransformer.transform
public function transform($widget) { $widget = $this->entityToArray(Widget::class, $widget); return [ 'id' => (int) $widget['id'], 'name' => $widget['name'], 'args' => array_camel_case_keys($widget['args']), 'isActive' => (bool) $widget['is_active'], 'isCacheable' => (bool) $widget['is_cacheable'], 'createdAt' => $widget['created_at'], 'updatedAt' => $widget['updated_at'], ]; }
php
public function transform($widget) { $widget = $this->entityToArray(Widget::class, $widget); return [ 'id' => (int) $widget['id'], 'name' => $widget['name'], 'args' => array_camel_case_keys($widget['args']), 'isActive' => (bool) $widget['is_active'], 'isCacheable' => (bool) $widget['is_cacheable'], 'createdAt' => $widget['created_at'], 'updatedAt' => $widget['updated_at'], ]; }
[ "public", "function", "transform", "(", "$", "widget", ")", "{", "$", "widget", "=", "$", "this", "->", "entityToArray", "(", "Widget", "::", "class", ",", "$", "widget", ")", ";", "return", "[", "'id'", "=>", "(", "int", ")", "$", "widget", "[", "'id'", "]", ",", "'name'", "=>", "$", "widget", "[", "'name'", "]", ",", "'args'", "=>", "array_camel_case_keys", "(", "$", "widget", "[", "'args'", "]", ")", ",", "'isActive'", "=>", "(", "bool", ")", "$", "widget", "[", "'is_active'", "]", ",", "'isCacheable'", "=>", "(", "bool", ")", "$", "widget", "[", "'is_cacheable'", "]", ",", "'createdAt'", "=>", "$", "widget", "[", "'created_at'", "]", ",", "'updatedAt'", "=>", "$", "widget", "[", "'updated_at'", "]", ",", "]", ";", "}" ]
Transforms widget entity @param Widget|array $widget Widget entity @return array
[ "Transforms", "widget", "entity" ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/WidgetTransformer.php#L26-L38
SergioMadness/query-builder
src/traits/Conditional.php
Conditional.setConditionBuilder
public function setConditionBuilder(\pwf\components\querybuilder\interfaces\ConditionBuilder $builder) { $this->conditionBuilder = $builder; return $this; }
php
public function setConditionBuilder(\pwf\components\querybuilder\interfaces\ConditionBuilder $builder) { $this->conditionBuilder = $builder; return $this; }
[ "public", "function", "setConditionBuilder", "(", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "interfaces", "\\", "ConditionBuilder", "$", "builder", ")", "{", "$", "this", "->", "conditionBuilder", "=", "$", "builder", ";", "return", "$", "this", ";", "}" ]
Set condition builder @param \pwf\components\querybuilder\interfaces\ConditionBuilder $builder @return $this
[ "Set", "condition", "builder" ]
train
https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/traits/Conditional.php#L27-L31
comodojo/daemon
src/Comodojo/Daemon/Console/LogHandler.php
LogHandler.write
protected function write(array $record) { $level = $record['level']; $message = $record['formatted']; $context = empty($record['context']) ? null : $record['context']; $time = $record['datetime']->format('c'); $this->toConsole($time, $level, $message, $context); }
php
protected function write(array $record) { $level = $record['level']; $message = $record['formatted']; $context = empty($record['context']) ? null : $record['context']; $time = $record['datetime']->format('c'); $this->toConsole($time, $level, $message, $context); }
[ "protected", "function", "write", "(", "array", "$", "record", ")", "{", "$", "level", "=", "$", "record", "[", "'level'", "]", ";", "$", "message", "=", "$", "record", "[", "'formatted'", "]", ";", "$", "context", "=", "empty", "(", "$", "record", "[", "'context'", "]", ")", "?", "null", ":", "$", "record", "[", "'context'", "]", ";", "$", "time", "=", "$", "record", "[", "'datetime'", "]", "->", "format", "(", "'c'", ")", ";", "$", "this", "->", "toConsole", "(", "$", "time", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}" ]
Record's writer
[ "Record", "s", "writer" ]
train
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Console/LogHandler.php#L91-L103
comodojo/daemon
src/Comodojo/Daemon/Console/LogHandler.php
LogHandler.toConsole
private function toConsole($time, $level, $message, $context) { $color = static::$colors[$level]; $pattern = "<%s>%s</%s>"; $message = sprintf($pattern, $color, $message, $color); $this->outputcontroller->out($message); if ( !empty($context) && $this->include_context ) { $this->outputcontroller->out(sprintf($pattern, $color, var_export($context, true), $color)); } }
php
private function toConsole($time, $level, $message, $context) { $color = static::$colors[$level]; $pattern = "<%s>%s</%s>"; $message = sprintf($pattern, $color, $message, $color); $this->outputcontroller->out($message); if ( !empty($context) && $this->include_context ) { $this->outputcontroller->out(sprintf($pattern, $color, var_export($context, true), $color)); } }
[ "private", "function", "toConsole", "(", "$", "time", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", "{", "$", "color", "=", "static", "::", "$", "colors", "[", "$", "level", "]", ";", "$", "pattern", "=", "\"<%s>%s</%s>\"", ";", "$", "message", "=", "sprintf", "(", "$", "pattern", ",", "$", "color", ",", "$", "message", ",", "$", "color", ")", ";", "$", "this", "->", "outputcontroller", "->", "out", "(", "$", "message", ")", ";", "if", "(", "!", "empty", "(", "$", "context", ")", "&&", "$", "this", "->", "include_context", ")", "{", "$", "this", "->", "outputcontroller", "->", "out", "(", "sprintf", "(", "$", "pattern", ",", "$", "color", ",", "var_export", "(", "$", "context", ",", "true", ")", ",", "$", "color", ")", ")", ";", "}", "}" ]
Send record to console formatting it
[ "Send", "record", "to", "console", "formatting", "it" ]
train
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Console/LogHandler.php#L108-L124
surebert/surebert-framework
src/sb/Controller/REST.php
REST.render
public function render() { if ($this->onBeforeRender() === false) { return $this->notFound(); } $method = \sb\Gateway::$request->method; if (method_exists($this, $method)) { $reflection = new \ReflectionMethod($this, $method); //check for phpdocs $docs = $reflection->getDocComment(); $servable = false; if (!empty($docs)) { if (preg_match("~@servable (true|false)~", $docs, $match)) { $servable = $match[1] == 'true' ? true : false; } } if ($servable) { return $this->filterOutput($this->$method()); } else { return $this->filterOutput($this->notFound($method)); } } else { return $this->filterOutput($this->notFound($method)); } }
php
public function render() { if ($this->onBeforeRender() === false) { return $this->notFound(); } $method = \sb\Gateway::$request->method; if (method_exists($this, $method)) { $reflection = new \ReflectionMethod($this, $method); //check for phpdocs $docs = $reflection->getDocComment(); $servable = false; if (!empty($docs)) { if (preg_match("~@servable (true|false)~", $docs, $match)) { $servable = $match[1] == 'true' ? true : false; } } if ($servable) { return $this->filterOutput($this->$method()); } else { return $this->filterOutput($this->notFound($method)); } } else { return $this->filterOutput($this->notFound($method)); } }
[ "public", "function", "render", "(", ")", "{", "if", "(", "$", "this", "->", "onBeforeRender", "(", ")", "===", "false", ")", "{", "return", "$", "this", "->", "notFound", "(", ")", ";", "}", "$", "method", "=", "\\", "sb", "\\", "Gateway", "::", "$", "request", "->", "method", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "$", "this", ",", "$", "method", ")", ";", "//check for phpdocs", "$", "docs", "=", "$", "reflection", "->", "getDocComment", "(", ")", ";", "$", "servable", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "docs", ")", ")", "{", "if", "(", "preg_match", "(", "\"~@servable (true|false)~\"", ",", "$", "docs", ",", "$", "match", ")", ")", "{", "$", "servable", "=", "$", "match", "[", "1", "]", "==", "'true'", "?", "true", ":", "false", ";", "}", "}", "if", "(", "$", "servable", ")", "{", "return", "$", "this", "->", "filterOutput", "(", "$", "this", "->", "$", "method", "(", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "filterOutput", "(", "$", "this", "->", "notFound", "(", "$", "method", ")", ")", ";", "}", "}", "else", "{", "return", "$", "this", "->", "filterOutput", "(", "$", "this", "->", "notFound", "(", "$", "method", ")", ")", ";", "}", "}" ]
Used to render the output through the filterOutput method by calling the handler appropriate to the HTTP request @return string
[ "Used", "to", "render", "the", "output", "through", "the", "filterOutput", "method", "by", "calling", "the", "handler", "appropriate", "to", "the", "HTTP", "request" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/REST.php#L66-L93
surebert/surebert-framework
src/sb/Gitlab/User.php
User.getByEmail
protected function getByEmail($email) { $users = $this->_client->get('/users?search='.urlencode($email)); return isset($users[0]) ? $users[0] : false; }
php
protected function getByEmail($email) { $users = $this->_client->get('/users?search='.urlencode($email)); return isset($users[0]) ? $users[0] : false; }
[ "protected", "function", "getByEmail", "(", "$", "email", ")", "{", "$", "users", "=", "$", "this", "->", "_client", "->", "get", "(", "'/users?search='", ".", "urlencode", "(", "$", "email", ")", ")", ";", "return", "isset", "(", "$", "users", "[", "0", "]", ")", "?", "$", "users", "[", "0", "]", ":", "false", ";", "}" ]
Loads a user by email @param string $email @return \stdClass
[ "Loads", "a", "user", "by", "email" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/User.php#L88-L91
DevGroup-ru/yii2-users-module
src/models/SocialMappings.php
SocialMappings.mapForSocialService
public static function mapForSocialService($id) { /** @var LazyCache $cache */ $cache = Yii::$app->cache; $map = $cache->lazy( function () use ($id) { return static::find() ->where(['social_service_id' => $id]) ->indexBy('model_attribute') ->select(['model_attribute', 'social_attributes']) ->asArray() ->all(); }, "MappingsForSocial:$id", 86400, new TagDependency([ 'tags' => [ static::commonTag(), ] ]) ); foreach ($map as &$values) { $values = explode(',', $values['social_attributes']); } return $map; }
php
public static function mapForSocialService($id) { /** @var LazyCache $cache */ $cache = Yii::$app->cache; $map = $cache->lazy( function () use ($id) { return static::find() ->where(['social_service_id' => $id]) ->indexBy('model_attribute') ->select(['model_attribute', 'social_attributes']) ->asArray() ->all(); }, "MappingsForSocial:$id", 86400, new TagDependency([ 'tags' => [ static::commonTag(), ] ]) ); foreach ($map as &$values) { $values = explode(',', $values['social_attributes']); } return $map; }
[ "public", "static", "function", "mapForSocialService", "(", "$", "id", ")", "{", "/** @var LazyCache $cache */", "$", "cache", "=", "Yii", "::", "$", "app", "->", "cache", ";", "$", "map", "=", "$", "cache", "->", "lazy", "(", "function", "(", ")", "use", "(", "$", "id", ")", "{", "return", "static", "::", "find", "(", ")", "->", "where", "(", "[", "'social_service_id'", "=>", "$", "id", "]", ")", "->", "indexBy", "(", "'model_attribute'", ")", "->", "select", "(", "[", "'model_attribute'", ",", "'social_attributes'", "]", ")", "->", "asArray", "(", ")", "->", "all", "(", ")", ";", "}", ",", "\"MappingsForSocial:$id\"", ",", "86400", ",", "new", "TagDependency", "(", "[", "'tags'", "=>", "[", "static", "::", "commonTag", "(", ")", ",", "]", "]", ")", ")", ";", "foreach", "(", "$", "map", "as", "&", "$", "values", ")", "{", "$", "values", "=", "explode", "(", "','", ",", "$", "values", "[", "'social_attributes'", "]", ")", ";", "}", "return", "$", "map", ";", "}" ]
@param integer $id @return array
[ "@param", "integer", "$id" ]
train
https://github.com/DevGroup-ru/yii2-users-module/blob/ff0103dc55c3462627ccc704c33e70c96053f750/src/models/SocialMappings.php#L71-L96
f3ath/lazypdo
src/PDODecorator.php
PDODecorator.quote
public function quote($string, $type = PDO::PARAM_STR) { return $this->getPDO()->quote($string, $type); }
php
public function quote($string, $type = PDO::PARAM_STR) { return $this->getPDO()->quote($string, $type); }
[ "public", "function", "quote", "(", "$", "string", ",", "$", "type", "=", "PDO", "::", "PARAM_STR", ")", "{", "return", "$", "this", "->", "getPDO", "(", ")", "->", "quote", "(", "$", "string", ",", "$", "type", ")", ";", "}" ]
Quotes a string for use in a query. @param string $string @param int $type @return string
[ "Quotes", "a", "string", "for", "use", "in", "a", "query", "." ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/PDODecorator.php#L144-L147
f3ath/lazypdo
src/PDODecorator.php
PDODecorator.query
public function query($statement) { if (1 == func_num_args()) { return $this->getPDO()->query($statement); } // this way is much slower but supports overloading // http://php.net/manual/en/pdo.query.php return call_user_func_array(array($this->getPDO(), __FUNCTION__), func_get_args()); }
php
public function query($statement) { if (1 == func_num_args()) { return $this->getPDO()->query($statement); } // this way is much slower but supports overloading // http://php.net/manual/en/pdo.query.php return call_user_func_array(array($this->getPDO(), __FUNCTION__), func_get_args()); }
[ "public", "function", "query", "(", "$", "statement", ")", "{", "if", "(", "1", "==", "func_num_args", "(", ")", ")", "{", "return", "$", "this", "->", "getPDO", "(", ")", "->", "query", "(", "$", "statement", ")", ";", "}", "// this way is much slower but supports overloading", "// http://php.net/manual/en/pdo.query.php", "return", "call_user_func_array", "(", "array", "(", "$", "this", "->", "getPDO", "(", ")", ",", "__FUNCTION__", ")", ",", "func_get_args", "(", ")", ")", ";", "}" ]
Executes an SQL statement, returning a result set as a PDOStatement object, overloading is supported @param string $statement @return PDOStatement
[ "Executes", "an", "SQL", "statement", "returning", "a", "result", "set", "as", "a", "PDOStatement", "object", "overloading", "is", "supported" ]
train
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/PDODecorator.php#L167-L175
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.copyFromDFSToDFS
public function copyFromDFSToDFS( $srcFilePath, $dstFilePath ) { $srcHandler = $this->getHandler( $srcFilePath ); $dstHandler = $this->getHandler( $dstFilePath ); if ( $srcHandler === $dstHandler ) { return $srcHandler->copyFromDFSToDFS( $srcFilePath, $dstFilePath ); } else { return $dstHandler->createFileOnDFS( $dstFilePath, $srcHandler->getContents( $srcFilePath ) ); } }
php
public function copyFromDFSToDFS( $srcFilePath, $dstFilePath ) { $srcHandler = $this->getHandler( $srcFilePath ); $dstHandler = $this->getHandler( $dstFilePath ); if ( $srcHandler === $dstHandler ) { return $srcHandler->copyFromDFSToDFS( $srcFilePath, $dstFilePath ); } else { return $dstHandler->createFileOnDFS( $dstFilePath, $srcHandler->getContents( $srcFilePath ) ); } }
[ "public", "function", "copyFromDFSToDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", ")", "{", "$", "srcHandler", "=", "$", "this", "->", "getHandler", "(", "$", "srcFilePath", ")", ";", "$", "dstHandler", "=", "$", "this", "->", "getHandler", "(", "$", "dstFilePath", ")", ";", "if", "(", "$", "srcHandler", "===", "$", "dstHandler", ")", "{", "return", "$", "srcHandler", "->", "copyFromDFSToDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", ")", ";", "}", "else", "{", "return", "$", "dstHandler", "->", "createFileOnDFS", "(", "$", "dstFilePath", ",", "$", "srcHandler", "->", "getContents", "(", "$", "srcFilePath", ")", ")", ";", "}", "}" ]
Creates a copy of $srcFilePath from DFS to $dstFilePath on DFS @param string $srcFilePath Local source file path @param string $dstFilePath Local destination file path @return bool
[ "Creates", "a", "copy", "of", "$srcFilePath", "from", "DFS", "to", "$dstFilePath", "on", "DFS" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L63-L76
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.copyFromDFS
public function copyFromDFS( $srcFilePath, $dstFilePath = false ) { return $this->getHandler( $srcFilePath )->copyFromDFS( $srcFilePath, $dstFilePath ); }
php
public function copyFromDFS( $srcFilePath, $dstFilePath = false ) { return $this->getHandler( $srcFilePath )->copyFromDFS( $srcFilePath, $dstFilePath ); }
[ "public", "function", "copyFromDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", "=", "false", ")", "{", "return", "$", "this", "->", "getHandler", "(", "$", "srcFilePath", ")", "->", "copyFromDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", ")", ";", "}" ]
Copies the DFS file $srcFilePath to FS @param string $srcFilePath Source file path (on DFS) @param string|bool $dstFilePath Destination file path (on FS). If not specified, $srcFilePath is used @return bool
[ "Copies", "the", "DFS", "file", "$srcFilePath", "to", "FS" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L86-L89
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.copyToDFS
public function copyToDFS( $srcFilePath, $dstFilePath = false ) { return $this->getHandler( $dstFilePath ?: $srcFilePath )->copyToDFS( $srcFilePath, $dstFilePath ); }
php
public function copyToDFS( $srcFilePath, $dstFilePath = false ) { return $this->getHandler( $dstFilePath ?: $srcFilePath )->copyToDFS( $srcFilePath, $dstFilePath ); }
[ "public", "function", "copyToDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", "=", "false", ")", "{", "return", "$", "this", "->", "getHandler", "(", "$", "dstFilePath", "?", ":", "$", "srcFilePath", ")", "->", "copyToDFS", "(", "$", "srcFilePath", ",", "$", "dstFilePath", ")", ";", "}" ]
Copies the local file $filePath to DFS under the same name, or a new name if specified @param string $srcFilePath Local file path to copy from @param bool|string $dstFilePath Optional path to copy to. If not specified, $srcFilePath is used @return bool
[ "Copies", "the", "local", "file", "$filePath", "to", "DFS", "under", "the", "same", "name", "or", "a", "new", "name", "if", "specified" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L101-L104
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.delete
public function delete( $filePath ) { $map = $this->mapFilePathArray( (array)$filePath ); $returnValue = true; /** @var eZDFSFileHandlerDFSBackendInterface $handler */ foreach ( $map['handlers'] as $handlerClass => $handler ) { $returnValue &= $handler->delete( $map['files'][$handlerClass] ); } return (bool)$returnValue; }
php
public function delete( $filePath ) { $map = $this->mapFilePathArray( (array)$filePath ); $returnValue = true; /** @var eZDFSFileHandlerDFSBackendInterface $handler */ foreach ( $map['handlers'] as $handlerClass => $handler ) { $returnValue &= $handler->delete( $map['files'][$handlerClass] ); } return (bool)$returnValue; }
[ "public", "function", "delete", "(", "$", "filePath", ")", "{", "$", "map", "=", "$", "this", "->", "mapFilePathArray", "(", "(", "array", ")", "$", "filePath", ")", ";", "$", "returnValue", "=", "true", ";", "/** @var eZDFSFileHandlerDFSBackendInterface $handler */", "foreach", "(", "$", "map", "[", "'handlers'", "]", "as", "$", "handlerClass", "=>", "$", "handler", ")", "{", "$", "returnValue", "&=", "$", "handler", "->", "delete", "(", "$", "map", "[", "'files'", "]", "[", "$", "handlerClass", "]", ")", ";", "}", "return", "(", "bool", ")", "$", "returnValue", ";", "}" ]
Deletes one or more files from DFS @param string|array $filePath Single local filename, or array of local filenames @return bool true if deletion was successful, false otherwise
[ "Deletes", "one", "or", "more", "files", "from", "DFS" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L113-L125
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.passthrough
public function passthrough( $filePath, $startOffset = 0, $length = false ) { return $this->getHandler( $filePath )->passthrough( $filePath, $startOffset, $length ); }
php
public function passthrough( $filePath, $startOffset = 0, $length = false ) { return $this->getHandler( $filePath )->passthrough( $filePath, $startOffset, $length ); }
[ "public", "function", "passthrough", "(", "$", "filePath", ",", "$", "startOffset", "=", "0", ",", "$", "length", "=", "false", ")", "{", "return", "$", "this", "->", "getHandler", "(", "$", "filePath", ")", "->", "passthrough", "(", "$", "filePath", ",", "$", "startOffset", ",", "$", "length", ")", ";", "}" ]
Sends the contents of $filePath to default output @param string $filePath File path @param int $startOffset Starting offset @param bool|int $length Length to transmit, false means everything @return bool true, or false if operation failed
[ "Sends", "the", "contents", "of", "$filePath", "to", "default", "output" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L136-L139
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.renameOnDFS
public function renameOnDFS( $oldPath, $newPath ) { $oldPathHandler = $this->getHandler( $oldPath ); $newPathHandler = $this->getHandler( $newPath ); // same handler, normal rename if ( $oldPathHandler === $newPathHandler ) { return $oldPathHandler->renameOnDFS( $oldPath, $newPath ); } // different handlers, create on new, delete on old else { if ( $newPathHandler->createFileOnDFS( $newPath, $oldPathHandler->getContents( $oldPath ) ) !== true ) return false; return $oldPathHandler->delete( $oldPath ); } }
php
public function renameOnDFS( $oldPath, $newPath ) { $oldPathHandler = $this->getHandler( $oldPath ); $newPathHandler = $this->getHandler( $newPath ); // same handler, normal rename if ( $oldPathHandler === $newPathHandler ) { return $oldPathHandler->renameOnDFS( $oldPath, $newPath ); } // different handlers, create on new, delete on old else { if ( $newPathHandler->createFileOnDFS( $newPath, $oldPathHandler->getContents( $oldPath ) ) !== true ) return false; return $oldPathHandler->delete( $oldPath ); } }
[ "public", "function", "renameOnDFS", "(", "$", "oldPath", ",", "$", "newPath", ")", "{", "$", "oldPathHandler", "=", "$", "this", "->", "getHandler", "(", "$", "oldPath", ")", ";", "$", "newPathHandler", "=", "$", "this", "->", "getHandler", "(", "$", "newPath", ")", ";", "// same handler, normal rename", "if", "(", "$", "oldPathHandler", "===", "$", "newPathHandler", ")", "{", "return", "$", "oldPathHandler", "->", "renameOnDFS", "(", "$", "oldPath", ",", "$", "newPath", ")", ";", "}", "// different handlers, create on new, delete on old", "else", "{", "if", "(", "$", "newPathHandler", "->", "createFileOnDFS", "(", "$", "newPath", ",", "$", "oldPathHandler", "->", "getContents", "(", "$", "oldPath", ")", ")", "!==", "true", ")", "return", "false", ";", "return", "$", "oldPathHandler", "->", "delete", "(", "$", "oldPath", ")", ";", "}", "}" ]
Renamed DFS file $oldPath to DFS file $newPath @param string $oldPath @param string $newPath @return bool
[ "Renamed", "DFS", "file", "$oldPath", "to", "DFS", "file", "$newPath" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L174-L192
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.getFilesList
public function getFilesList( $basePath ) { $iterator = new AppendIterator(); foreach ( $this->getAllHandlers() as $handler ) { $iterator->append( $handler->getFilesList( $basePath ) ); } return $iterator; }
php
public function getFilesList( $basePath ) { $iterator = new AppendIterator(); foreach ( $this->getAllHandlers() as $handler ) { $iterator->append( $handler->getFilesList( $basePath ) ); } return $iterator; }
[ "public", "function", "getFilesList", "(", "$", "basePath", ")", "{", "$", "iterator", "=", "new", "AppendIterator", "(", ")", ";", "foreach", "(", "$", "this", "->", "getAllHandlers", "(", ")", "as", "$", "handler", ")", "{", "$", "iterator", "->", "append", "(", "$", "handler", "->", "getFilesList", "(", "$", "basePath", ")", ")", ";", "}", "return", "$", "iterator", ";", "}" ]
Returns an AppendIterator with every handler's iterator @param string $basePath @return Iterator
[ "Returns", "an", "AppendIterator", "with", "every", "handler", "s", "iterator" ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L225-L233
ezsystems/ezdfs-fsbackend-dispatcher
classes/ezdfsfilehandlerdfsdispatcher.php
eZDFSFileHandlerDFSDispatcher.mapFilePathArray
private function mapFilePathArray( array $filePath ) { $map = array( 'handlers' => array(), 'files' => array() ); foreach ( $filePath as $path ) { $handler = $this->getHandler( $path ); $handlerClass = get_class( $handler ); if ( !isset( $map['handlers'][$handlerClass] ) ) { $map['handlers'][$handlerClass] = $handler; $map['files'][$handlerClass]= array(); } $map['files'][$handlerClass][] = $path; } return $map; }
php
private function mapFilePathArray( array $filePath ) { $map = array( 'handlers' => array(), 'files' => array() ); foreach ( $filePath as $path ) { $handler = $this->getHandler( $path ); $handlerClass = get_class( $handler ); if ( !isset( $map['handlers'][$handlerClass] ) ) { $map['handlers'][$handlerClass] = $handler; $map['files'][$handlerClass]= array(); } $map['files'][$handlerClass][] = $path; } return $map; }
[ "private", "function", "mapFilePathArray", "(", "array", "$", "filePath", ")", "{", "$", "map", "=", "array", "(", "'handlers'", "=>", "array", "(", ")", ",", "'files'", "=>", "array", "(", ")", ")", ";", "foreach", "(", "$", "filePath", "as", "$", "path", ")", "{", "$", "handler", "=", "$", "this", "->", "getHandler", "(", "$", "path", ")", ";", "$", "handlerClass", "=", "get_class", "(", "$", "handler", ")", ";", "if", "(", "!", "isset", "(", "$", "map", "[", "'handlers'", "]", "[", "$", "handlerClass", "]", ")", ")", "{", "$", "map", "[", "'handlers'", "]", "[", "$", "handlerClass", "]", "=", "$", "handler", ";", "$", "map", "[", "'files'", "]", "[", "$", "handlerClass", "]", "=", "array", "(", ")", ";", "}", "$", "map", "[", "'files'", "]", "[", "$", "handlerClass", "]", "[", "]", "=", "$", "path", ";", "}", "return", "$", "map", ";", "}" ]
Groups file paths from $filePath by handlers. @param array $filePath @param eZDFSFileHandlerDFSBackendInterface[] $handler @param array $handlerClass @return array an array with two sub-arrays $return['handlers'] is a hash of eZDFSFileHandlerDFSBackendInterface, indexed by handler class name $return['files'] is a hash of file path arrays, indexed by handler class name
[ "Groups", "file", "paths", "from", "$filePath", "by", "handlers", "." ]
train
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L251-L268
alevilar/ristorantino-vendor
Compras/Model/PedidoMercaderia.php
PedidoMercaderia.getProveedoresInvolucrados
public function getProveedoresInvolucrados( $pedidoMercaderias ) { $provs = []; foreach ($pedidoMercaderias as $pm) { if ( !empty($pm['Mercaderia']['Proveedor']['id']) ) { $provs[] = $pm['Mercaderia']['Proveedor']['id']; } if ( !empty($pm['Mercaderia']['Rubro']['Proveedor']) ) { foreach ($pm['Mercaderia']['Rubro']['Proveedor'] as $rubro) { $provs[] = $rubro['id']; } } } return $provs; }
php
public function getProveedoresInvolucrados( $pedidoMercaderias ) { $provs = []; foreach ($pedidoMercaderias as $pm) { if ( !empty($pm['Mercaderia']['Proveedor']['id']) ) { $provs[] = $pm['Mercaderia']['Proveedor']['id']; } if ( !empty($pm['Mercaderia']['Rubro']['Proveedor']) ) { foreach ($pm['Mercaderia']['Rubro']['Proveedor'] as $rubro) { $provs[] = $rubro['id']; } } } return $provs; }
[ "public", "function", "getProveedoresInvolucrados", "(", "$", "pedidoMercaderias", ")", "{", "$", "provs", "=", "[", "]", ";", "foreach", "(", "$", "pedidoMercaderias", "as", "$", "pm", ")", "{", "if", "(", "!", "empty", "(", "$", "pm", "[", "'Mercaderia'", "]", "[", "'Proveedor'", "]", "[", "'id'", "]", ")", ")", "{", "$", "provs", "[", "]", "=", "$", "pm", "[", "'Mercaderia'", "]", "[", "'Proveedor'", "]", "[", "'id'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "pm", "[", "'Mercaderia'", "]", "[", "'Rubro'", "]", "[", "'Proveedor'", "]", ")", ")", "{", "foreach", "(", "$", "pm", "[", "'Mercaderia'", "]", "[", "'Rubro'", "]", "[", "'Proveedor'", "]", "as", "$", "rubro", ")", "{", "$", "provs", "[", "]", "=", "$", "rubro", "[", "'id'", "]", ";", "}", "}", "}", "return", "$", "provs", ";", "}" ]
filtrar los proveedores involucrados retornando un listado de ID's @param array $pedidoMercaderias array del find de PedidoMercaderia @return array con un list de id's de proveedores
[ "filtrar", "los", "proveedores", "involucrados", "retornando", "un", "listado", "de", "ID", "s" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Compras/Model/PedidoMercaderia.php#L153-L167
InfiniteSoftware/ISEcommpayPayum
Action/StatusAction.php
StatusAction.execute
public function execute($request) { ArrayObject::ensureArrayObject($request->getModel()); $this->gateway->execute($status = new GetHttpRequest()); if (isset($status->request['operation']) === false) { $request->markNew(); return; } if (isset($status->request['operation']['status'])) { $status = $status->request['operation']['status']; if (EcommpayBridgeInterface::STATUS_SUCCESS === $status) { $request->markCaptured(); return; } if (EcommpayBridgeInterface::STATUS_DECLINE === $status) { $request->markFailed(); } } }
php
public function execute($request) { ArrayObject::ensureArrayObject($request->getModel()); $this->gateway->execute($status = new GetHttpRequest()); if (isset($status->request['operation']) === false) { $request->markNew(); return; } if (isset($status->request['operation']['status'])) { $status = $status->request['operation']['status']; if (EcommpayBridgeInterface::STATUS_SUCCESS === $status) { $request->markCaptured(); return; } if (EcommpayBridgeInterface::STATUS_DECLINE === $status) { $request->markFailed(); } } }
[ "public", "function", "execute", "(", "$", "request", ")", "{", "ArrayObject", "::", "ensureArrayObject", "(", "$", "request", "->", "getModel", "(", ")", ")", ";", "$", "this", "->", "gateway", "->", "execute", "(", "$", "status", "=", "new", "GetHttpRequest", "(", ")", ")", ";", "if", "(", "isset", "(", "$", "status", "->", "request", "[", "'operation'", "]", ")", "===", "false", ")", "{", "$", "request", "->", "markNew", "(", ")", ";", "return", ";", "}", "if", "(", "isset", "(", "$", "status", "->", "request", "[", "'operation'", "]", "[", "'status'", "]", ")", ")", "{", "$", "status", "=", "$", "status", "->", "request", "[", "'operation'", "]", "[", "'status'", "]", ";", "if", "(", "EcommpayBridgeInterface", "::", "STATUS_SUCCESS", "===", "$", "status", ")", "{", "$", "request", "->", "markCaptured", "(", ")", ";", "return", ";", "}", "if", "(", "EcommpayBridgeInterface", "::", "STATUS_DECLINE", "===", "$", "status", ")", "{", "$", "request", "->", "markFailed", "(", ")", ";", "}", "}", "}" ]
{@inheritDoc} @param GetStatusInterface $request
[ "{", "@inheritDoc", "}" ]
train
https://github.com/InfiniteSoftware/ISEcommpayPayum/blob/44a073e3d885d9007aa54d6ff13aea93a9e52e7c/Action/StatusAction.php#L20-L43
K-Phoen/DoctrineStateMachineBehavior
src/StateMachine/StateMachineExtension.php
StateMachineExtension.canJumpToState
public function canJumpToState($state) { if ($state instanceof StateInterface) { $state = $state->getName(); } // assert that the given state exists $this->getState($state); return in_array($this->currentState->getName(), $this->statePrecedence[$state], true); }
php
public function canJumpToState($state) { if ($state instanceof StateInterface) { $state = $state->getName(); } // assert that the given state exists $this->getState($state); return in_array($this->currentState->getName(), $this->statePrecedence[$state], true); }
[ "public", "function", "canJumpToState", "(", "$", "state", ")", "{", "if", "(", "$", "state", "instanceof", "StateInterface", ")", "{", "$", "state", "=", "$", "state", "->", "getName", "(", ")", ";", "}", "// assert that the given state exists", "$", "this", "->", "getState", "(", "$", "state", ")", ";", "return", "in_array", "(", "$", "this", "->", "currentState", "->", "getName", "(", ")", ",", "$", "this", "->", "statePrecedence", "[", "$", "state", "]", ",", "true", ")", ";", "}" ]
Tells if moving to the given state is allowed. @param string|StateInterface $state @return bool
[ "Tells", "if", "moving", "to", "the", "given", "state", "is", "allowed", "." ]
train
https://github.com/K-Phoen/DoctrineStateMachineBehavior/blob/699880fed03dd777ddae6cd8cec4b3d61853d4d7/src/StateMachine/StateMachineExtension.php#L64-L74
K-Phoen/DoctrineStateMachineBehavior
src/StateMachine/StateMachineExtension.php
StateMachineExtension.jumpToState
public function jumpToState($state) { if (!$state instanceof StateInterface) { $state = $this->getState($state); } if (!$this->canJumpToState($state)) { throw new StateException(sprintf('Can not jump from state "%s" to "%s".',$this->currentState->getName(), $state->getName())); } $this->object->setFiniteState($state->getName()); $this->currentState = $state; }
php
public function jumpToState($state) { if (!$state instanceof StateInterface) { $state = $this->getState($state); } if (!$this->canJumpToState($state)) { throw new StateException(sprintf('Can not jump from state "%s" to "%s".',$this->currentState->getName(), $state->getName())); } $this->object->setFiniteState($state->getName()); $this->currentState = $state; }
[ "public", "function", "jumpToState", "(", "$", "state", ")", "{", "if", "(", "!", "$", "state", "instanceof", "StateInterface", ")", "{", "$", "state", "=", "$", "this", "->", "getState", "(", "$", "state", ")", ";", "}", "if", "(", "!", "$", "this", "->", "canJumpToState", "(", "$", "state", ")", ")", "{", "throw", "new", "StateException", "(", "sprintf", "(", "'Can not jump from state \"%s\" to \"%s\".'", ",", "$", "this", "->", "currentState", "->", "getName", "(", ")", ",", "$", "state", "->", "getName", "(", ")", ")", ")", ";", "}", "$", "this", "->", "object", "->", "setFiniteState", "(", "$", "state", "->", "getName", "(", ")", ")", ";", "$", "this", "->", "currentState", "=", "$", "state", ";", "}" ]
Moves to the given state if allowed. @param string|StateInterface $state @return bool
[ "Moves", "to", "the", "given", "state", "if", "allowed", "." ]
train
https://github.com/K-Phoen/DoctrineStateMachineBehavior/blob/699880fed03dd777ddae6cd8cec4b3d61853d4d7/src/StateMachine/StateMachineExtension.php#L83-L95
zhouyl/mellivora
Mellivora/Console/Parser.php
Parser.parseOption
protected static function parseOption($token) { list($token, $description) = static::extractDescription($token); $matches = preg_split('/\s*\|\s*/', $token, 2); if (isset($matches[1])) { $shortcut = $matches[0]; $token = $matches[1]; } else { $shortcut = null; } switch (true) { case Str::endsWith($token, '='): return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description); case Str::endsWith($token, '=*'): return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description); case preg_match('/(.+)\=(.+)/', $token, $matches): return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]); default: return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description); } }
php
protected static function parseOption($token) { list($token, $description) = static::extractDescription($token); $matches = preg_split('/\s*\|\s*/', $token, 2); if (isset($matches[1])) { $shortcut = $matches[0]; $token = $matches[1]; } else { $shortcut = null; } switch (true) { case Str::endsWith($token, '='): return new InputOption(trim($token, '='), $shortcut, InputOption::VALUE_OPTIONAL, $description); case Str::endsWith($token, '=*'): return new InputOption(trim($token, '=*'), $shortcut, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, $description); case preg_match('/(.+)\=(.+)/', $token, $matches): return new InputOption($matches[1], $shortcut, InputOption::VALUE_OPTIONAL, $description, $matches[2]); default: return new InputOption($token, $shortcut, InputOption::VALUE_NONE, $description); } }
[ "protected", "static", "function", "parseOption", "(", "$", "token", ")", "{", "list", "(", "$", "token", ",", "$", "description", ")", "=", "static", "::", "extractDescription", "(", "$", "token", ")", ";", "$", "matches", "=", "preg_split", "(", "'/\\s*\\|\\s*/'", ",", "$", "token", ",", "2", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "shortcut", "=", "$", "matches", "[", "0", "]", ";", "$", "token", "=", "$", "matches", "[", "1", "]", ";", "}", "else", "{", "$", "shortcut", "=", "null", ";", "}", "switch", "(", "true", ")", "{", "case", "Str", "::", "endsWith", "(", "$", "token", ",", "'='", ")", ":", "return", "new", "InputOption", "(", "trim", "(", "$", "token", ",", "'='", ")", ",", "$", "shortcut", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "$", "description", ")", ";", "case", "Str", "::", "endsWith", "(", "$", "token", ",", "'=*'", ")", ":", "return", "new", "InputOption", "(", "trim", "(", "$", "token", ",", "'=*'", ")", ",", "$", "shortcut", ",", "InputOption", "::", "VALUE_OPTIONAL", "|", "InputOption", "::", "VALUE_IS_ARRAY", ",", "$", "description", ")", ";", "case", "preg_match", "(", "'/(.+)\\=(.+)/'", ",", "$", "token", ",", "$", "matches", ")", ":", "return", "new", "InputOption", "(", "$", "matches", "[", "1", "]", ",", "$", "shortcut", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "$", "description", ",", "$", "matches", "[", "2", "]", ")", ";", "default", ":", "return", "new", "InputOption", "(", "$", "token", ",", "$", "shortcut", ",", "InputOption", "::", "VALUE_NONE", ",", "$", "description", ")", ";", "}", "}" ]
Parse an option expression. @param string $token @return \Symfony\Component\Console\Input\InputOption
[ "Parse", "an", "option", "expression", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/Parser.php#L110-L133
zhouyl/mellivora
Mellivora/Console/Parser.php
Parser.extractDescription
protected static function extractDescription($token) { $parts = preg_split('/\s+:\s+/', trim($token), 2); return count($parts) === 2 ? $parts : [$token, null]; }
php
protected static function extractDescription($token) { $parts = preg_split('/\s+:\s+/', trim($token), 2); return count($parts) === 2 ? $parts : [$token, null]; }
[ "protected", "static", "function", "extractDescription", "(", "$", "token", ")", "{", "$", "parts", "=", "preg_split", "(", "'/\\s+:\\s+/'", ",", "trim", "(", "$", "token", ")", ",", "2", ")", ";", "return", "count", "(", "$", "parts", ")", "===", "2", "?", "$", "parts", ":", "[", "$", "token", ",", "null", "]", ";", "}" ]
Parse the token into its token and description segments. @param string $token @return array
[ "Parse", "the", "token", "into", "its", "token", "and", "description", "segments", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/Parser.php#L142-L147
ajgarlag/AjglCsv
src/Writer/NativePhpWriter.php
NativePhpWriter.doWrite
protected function doWrite($fileHandler, array $row, $delimiter) { $res = @fputcsv($fileHandler, $row, $delimiter); if (false === $res) { throw new \RuntimeException('Cannot write to the given resource'); } }
php
protected function doWrite($fileHandler, array $row, $delimiter) { $res = @fputcsv($fileHandler, $row, $delimiter); if (false === $res) { throw new \RuntimeException('Cannot write to the given resource'); } }
[ "protected", "function", "doWrite", "(", "$", "fileHandler", ",", "array", "$", "row", ",", "$", "delimiter", ")", "{", "$", "res", "=", "@", "fputcsv", "(", "$", "fileHandler", ",", "$", "row", ",", "$", "delimiter", ")", ";", "if", "(", "false", "===", "$", "res", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot write to the given resource'", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Writer/NativePhpWriter.php#L22-L28
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Helper/AbstractModel.php
Aoe_Layout_Helper_AbstractModel.getViewUrl
public function getViewUrl($model = null) { if (!$model instanceof Mage_Core_Model_Abstract) { $model = $this->getCurrentRecord(); } else { $expectedClass = get_class($this->getModel()); if (!is_a($model, $expectedClass)) { throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model))); } } return $this->_getUrl($this->getViewRoute(), ['id' => $model->getId()]); }
php
public function getViewUrl($model = null) { if (!$model instanceof Mage_Core_Model_Abstract) { $model = $this->getCurrentRecord(); } else { $expectedClass = get_class($this->getModel()); if (!is_a($model, $expectedClass)) { throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model))); } } return $this->_getUrl($this->getViewRoute(), ['id' => $model->getId()]); }
[ "public", "function", "getViewUrl", "(", "$", "model", "=", "null", ")", "{", "if", "(", "!", "$", "model", "instanceof", "Mage_Core_Model_Abstract", ")", "{", "$", "model", "=", "$", "this", "->", "getCurrentRecord", "(", ")", ";", "}", "else", "{", "$", "expectedClass", "=", "get_class", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "if", "(", "!", "is_a", "(", "$", "model", ",", "$", "expectedClass", ")", ")", "{", "throw", "new", "RuntimeException", "(", "$", "this", "->", "__", "(", "'Invalid model class. Expected:%1$s Passed:%2$s'", ",", "$", "expectedClass", ",", "get_class", "(", "$", "model", ")", ")", ")", ";", "}", "}", "return", "$", "this", "->", "_getUrl", "(", "$", "this", "->", "getViewRoute", "(", ")", ",", "[", "'id'", "=>", "$", "model", "->", "getId", "(", ")", "]", ")", ";", "}" ]
@param Mage_Core_Model_Abstract $model @return string @throws RuntimeException
[ "@param", "Mage_Core_Model_Abstract", "$model" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/AbstractModel.php#L79-L91
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Helper/AbstractModel.php
Aoe_Layout_Helper_AbstractModel.setCurrentRecord
public function setCurrentRecord(Mage_Core_Model_Abstract $model = null) { if ($model) { $expectedClass = get_class($this->getModel()); if (!is_a($model, $expectedClass)) { throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model))); } } Mage::unregister($this->getCurrentRecordKey()); if ($model) { Mage::register($this->getCurrentRecordKey(), $model); } return $this; }
php
public function setCurrentRecord(Mage_Core_Model_Abstract $model = null) { if ($model) { $expectedClass = get_class($this->getModel()); if (!is_a($model, $expectedClass)) { throw new RuntimeException($this->__('Invalid model class. Expected:%1$s Passed:%2$s', $expectedClass, get_class($model))); } } Mage::unregister($this->getCurrentRecordKey()); if ($model) { Mage::register($this->getCurrentRecordKey(), $model); } return $this; }
[ "public", "function", "setCurrentRecord", "(", "Mage_Core_Model_Abstract", "$", "model", "=", "null", ")", "{", "if", "(", "$", "model", ")", "{", "$", "expectedClass", "=", "get_class", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "if", "(", "!", "is_a", "(", "$", "model", ",", "$", "expectedClass", ")", ")", "{", "throw", "new", "RuntimeException", "(", "$", "this", "->", "__", "(", "'Invalid model class. Expected:%1$s Passed:%2$s'", ",", "$", "expectedClass", ",", "get_class", "(", "$", "model", ")", ")", ")", ";", "}", "}", "Mage", "::", "unregister", "(", "$", "this", "->", "getCurrentRecordKey", "(", ")", ")", ";", "if", "(", "$", "model", ")", "{", "Mage", "::", "register", "(", "$", "this", "->", "getCurrentRecordKey", "(", ")", ",", "$", "model", ")", ";", "}", "return", "$", "this", ";", "}" ]
@param Mage_Core_Model_Abstract $model @return $this @throws RuntimeException
[ "@param", "Mage_Core_Model_Abstract", "$model" ]
train
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Helper/AbstractModel.php#L119-L135
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.getParentId
public function getParentId($id) { $path = $this->getProperty($id, self::PATH); array_pop($path); return empty($path) ? null // the given item is the root : array_pop($path); }
php
public function getParentId($id) { $path = $this->getProperty($id, self::PATH); array_pop($path); return empty($path) ? null // the given item is the root : array_pop($path); }
[ "public", "function", "getParentId", "(", "$", "id", ")", "{", "$", "path", "=", "$", "this", "->", "getProperty", "(", "$", "id", ",", "self", "::", "PATH", ")", ";", "array_pop", "(", "$", "path", ")", ";", "return", "empty", "(", "$", "path", ")", "?", "null", "// the given item is the root", ":", "array_pop", "(", "$", "path", ")", ";", "}" ]
Returns the id of the parent layout item @param string $id The id or alias of the layout item @return string|null The id of the parent layout item or null if the given item is the root
[ "Returns", "the", "id", "of", "the", "parent", "layout", "item" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L87-L95
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.resolveId
public function resolveId($id) { return $this->aliases->has($id) ? $this->aliases->getId($id) : $id; }
php
public function resolveId($id) { return $this->aliases->has($id) ? $this->aliases->getId($id) : $id; }
[ "public", "function", "resolveId", "(", "$", "id", ")", "{", "return", "$", "this", "->", "aliases", "->", "has", "(", "$", "id", ")", "?", "$", "this", "->", "aliases", "->", "getId", "(", "$", "id", ")", ":", "$", "id", ";", "}" ]
Returns real id of the layout item @param string $id The id or alias of the layout item @return string The layout item id
[ "Returns", "real", "id", "of", "the", "layout", "item" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L104-L109
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.has
public function has($id) { $id = $this->resolveId($id); return isset($this->items[$id]); }
php
public function has($id) { $id = $this->resolveId($id); return isset($this->items[$id]); }
[ "public", "function", "has", "(", "$", "id", ")", "{", "$", "id", "=", "$", "this", "->", "resolveId", "(", "$", "id", ")", ";", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "id", "]", ")", ";", "}" ]
Checks if the layout item with the given id exists @param string $id The id or alias of the layout item @return bool
[ "Checks", "if", "the", "layout", "item", "with", "the", "given", "id", "exists" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L118-L123
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.add
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->validateId($id, true); if (isset($this->items[$id])) { throw new Exception\ItemAlreadyExistsException( sprintf( 'The "%s" item already exists.' . ' Remove existing item before add the new item with the same id.', $id ) ); } if (!$parentId && !$this->hierarchy->isEmpty()) { throw new Exception\LogicException( sprintf( 'The "%s" item cannot be the root item' . ' because another root item ("%s") already exists.', $id, $this->hierarchy->getRootId() ) ); } if ($parentId) { $parentId = $this->validateAndResolveId($parentId); } if ($siblingId) { $siblingId = $this->resolveId($siblingId); if (!isset($this->items[$siblingId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId)); } if ($parentId && $siblingId === $parentId) { throw new Exception\LogicException('The sibling item cannot be the same as the parent item.'); } } $path = $parentId ? $this->getProperty($parentId, self::PATH, true) : []; $this->hierarchy->add($path, $id, $siblingId, $prepend); $path[] = $id; $this->items[$id] = [ self::PATH => $path, self::BLOCK_TYPE => $blockType, self::OPTIONS => $options ]; }
php
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->validateId($id, true); if (isset($this->items[$id])) { throw new Exception\ItemAlreadyExistsException( sprintf( 'The "%s" item already exists.' . ' Remove existing item before add the new item with the same id.', $id ) ); } if (!$parentId && !$this->hierarchy->isEmpty()) { throw new Exception\LogicException( sprintf( 'The "%s" item cannot be the root item' . ' because another root item ("%s") already exists.', $id, $this->hierarchy->getRootId() ) ); } if ($parentId) { $parentId = $this->validateAndResolveId($parentId); } if ($siblingId) { $siblingId = $this->resolveId($siblingId); if (!isset($this->items[$siblingId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId)); } if ($parentId && $siblingId === $parentId) { throw new Exception\LogicException('The sibling item cannot be the same as the parent item.'); } } $path = $parentId ? $this->getProperty($parentId, self::PATH, true) : []; $this->hierarchy->add($path, $id, $siblingId, $prepend); $path[] = $id; $this->items[$id] = [ self::PATH => $path, self::BLOCK_TYPE => $blockType, self::OPTIONS => $options ]; }
[ "public", "function", "add", "(", "$", "id", ",", "$", "parentId", ",", "$", "blockType", ",", "array", "$", "options", "=", "[", "]", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "this", "->", "validateId", "(", "$", "id", ",", "true", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "id", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ItemAlreadyExistsException", "(", "sprintf", "(", "'The \"%s\" item already exists.'", ".", "' Remove existing item before add the new item with the same id.'", ",", "$", "id", ")", ")", ";", "}", "if", "(", "!", "$", "parentId", "&&", "!", "$", "this", "->", "hierarchy", "->", "isEmpty", "(", ")", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "sprintf", "(", "'The \"%s\" item cannot be the root item'", ".", "' because another root item (\"%s\") already exists.'", ",", "$", "id", ",", "$", "this", "->", "hierarchy", "->", "getRootId", "(", ")", ")", ")", ";", "}", "if", "(", "$", "parentId", ")", "{", "$", "parentId", "=", "$", "this", "->", "validateAndResolveId", "(", "$", "parentId", ")", ";", "}", "if", "(", "$", "siblingId", ")", "{", "$", "siblingId", "=", "$", "this", "->", "resolveId", "(", "$", "siblingId", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "siblingId", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ItemNotFoundException", "(", "sprintf", "(", "'The \"%s\" sibling item does not exist.'", ",", "$", "siblingId", ")", ")", ";", "}", "if", "(", "$", "parentId", "&&", "$", "siblingId", "===", "$", "parentId", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'The sibling item cannot be the same as the parent item.'", ")", ";", "}", "}", "$", "path", "=", "$", "parentId", "?", "$", "this", "->", "getProperty", "(", "$", "parentId", ",", "self", "::", "PATH", ",", "true", ")", ":", "[", "]", ";", "$", "this", "->", "hierarchy", "->", "add", "(", "$", "path", ",", "$", "id", ",", "$", "siblingId", ",", "$", "prepend", ")", ";", "$", "path", "[", "]", "=", "$", "id", ";", "$", "this", "->", "items", "[", "$", "id", "]", "=", "[", "self", "::", "PATH", "=>", "$", "path", ",", "self", "::", "BLOCK_TYPE", "=>", "$", "blockType", ",", "self", "::", "OPTIONS", "=>", "$", "options", "]", ";", "}" ]
Adds a new item to the layout @param string $id The layout item id @param string $parentId The id or alias of parent item. Set null to add the root item @param mixed $blockType The block type associated with the layout item @param array $options The layout item options @param string|null $siblingId The id or alias of an item which should be nearest neighbor @param bool $prepend Determines whether the moving item should be located before or after the specified sibling item @throws Exception\InvalidArgumentException if the id or parent id are empty or invalid @throws Exception\ItemAlreadyExistsException if the layout item with the same id already exists @throws Exception\ItemNotFoundException if the parent layout item does not exist @throws Exception\LogicException if the layout item cannot be added by other reasons @SuppressWarnings(PHPMD.NPathComplexity)
[ "Adds", "a", "new", "item", "to", "the", "layout" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L143-L194
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.remove
public function remove($id) { $id = $this->validateAndResolveId($id); $path = $this->items[$id][self::PATH]; // remove item from hierarchy $this->hierarchy->remove($path); // remove item unset($this->items[$id]); $this->aliases->removeById($id); unset($this->blockThemes[$id]); // remove all children $pathLength = count($path); $pathLastIndex = $pathLength - 1; $ids = array_keys($this->items); foreach ($ids as $itemId) { $currentPath = $this->items[$itemId][self::PATH]; if (count($currentPath) > $pathLength && $currentPath[$pathLastIndex] === $id) { unset($this->items[$itemId]); $this->aliases->removeById($itemId); unset($this->blockThemes[$itemId]); } } }
php
public function remove($id) { $id = $this->validateAndResolveId($id); $path = $this->items[$id][self::PATH]; // remove item from hierarchy $this->hierarchy->remove($path); // remove item unset($this->items[$id]); $this->aliases->removeById($id); unset($this->blockThemes[$id]); // remove all children $pathLength = count($path); $pathLastIndex = $pathLength - 1; $ids = array_keys($this->items); foreach ($ids as $itemId) { $currentPath = $this->items[$itemId][self::PATH]; if (count($currentPath) > $pathLength && $currentPath[$pathLastIndex] === $id) { unset($this->items[$itemId]); $this->aliases->removeById($itemId); unset($this->blockThemes[$itemId]); } } }
[ "public", "function", "remove", "(", "$", "id", ")", "{", "$", "id", "=", "$", "this", "->", "validateAndResolveId", "(", "$", "id", ")", ";", "$", "path", "=", "$", "this", "->", "items", "[", "$", "id", "]", "[", "self", "::", "PATH", "]", ";", "// remove item from hierarchy", "$", "this", "->", "hierarchy", "->", "remove", "(", "$", "path", ")", ";", "// remove item", "unset", "(", "$", "this", "->", "items", "[", "$", "id", "]", ")", ";", "$", "this", "->", "aliases", "->", "removeById", "(", "$", "id", ")", ";", "unset", "(", "$", "this", "->", "blockThemes", "[", "$", "id", "]", ")", ";", "// remove all children", "$", "pathLength", "=", "count", "(", "$", "path", ")", ";", "$", "pathLastIndex", "=", "$", "pathLength", "-", "1", ";", "$", "ids", "=", "array_keys", "(", "$", "this", "->", "items", ")", ";", "foreach", "(", "$", "ids", "as", "$", "itemId", ")", "{", "$", "currentPath", "=", "$", "this", "->", "items", "[", "$", "itemId", "]", "[", "self", "::", "PATH", "]", ";", "if", "(", "count", "(", "$", "currentPath", ")", ">", "$", "pathLength", "&&", "$", "currentPath", "[", "$", "pathLastIndex", "]", "===", "$", "id", ")", "{", "unset", "(", "$", "this", "->", "items", "[", "$", "itemId", "]", ")", ";", "$", "this", "->", "aliases", "->", "removeById", "(", "$", "itemId", ")", ";", "unset", "(", "$", "this", "->", "blockThemes", "[", "$", "itemId", "]", ")", ";", "}", "}", "}" ]
Removes the given item from the layout @param string $id The id of the layout item to be removed @throws Exception\InvalidArgumentException if the id is empty @throws Exception\ItemNotFoundException if the layout item does not exist
[ "Removes", "the", "given", "item", "from", "the", "layout" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L204-L227
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.move
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $id = $this->validateAndResolveId($id); if ($parentId) { $parentId = $this->resolveId($parentId); if (!isset($this->items[$parentId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" parent item does not exist.', $parentId)); } if ($parentId === $id) { throw new Exception\LogicException('The parent item cannot be the same as the moving item.'); } } if ($siblingId) { $siblingId = $this->resolveId($siblingId); if (!isset($this->items[$siblingId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId)); } if ($siblingId === $id) { throw new Exception\LogicException('The sibling item cannot be the same as the moving item.'); } } if (!$parentId && !$siblingId) { throw new Exception\LogicException('At least one parent or sibling item must be specified.'); } $path = $this->items[$id][self::PATH]; if (!$parentId) { $parentPath = array_slice($path, 0, -1); } else { if ($siblingId && $siblingId === $parentId) { throw new Exception\LogicException('The sibling item cannot be the same as the parent item.'); } $parentPath = $this->items[$parentId][self::PATH]; if (strpos(implode('/', $parentPath) . '/', implode('/', $path) . '/') === 0) { throw new Exception\LogicException( sprintf( 'The parent item (path: %s) cannot be a child of the moving item (path: %s).', implode('/', $parentPath), implode('/', $path) ) ); } } // update hierarchy $hierarchy = $this->hierarchy->get($path); $this->hierarchy->remove($path); $this->hierarchy->add($parentPath, $id, $siblingId, $prepend, $hierarchy); if ($parentId) { // build the new path $newPath = $parentPath; $newPath[] = $id; // update the path of the moving item $this->items[$id][self::PATH] = $newPath; // update the path for all children $prevPathLength = count($path); $iterator = $this->getHierarchyIterator($id); foreach ($iterator as $childId) { $this->items[$childId][self::PATH] = array_merge( $newPath, array_slice($this->items[$childId][self::PATH], $prevPathLength) ); } } }
php
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $id = $this->validateAndResolveId($id); if ($parentId) { $parentId = $this->resolveId($parentId); if (!isset($this->items[$parentId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" parent item does not exist.', $parentId)); } if ($parentId === $id) { throw new Exception\LogicException('The parent item cannot be the same as the moving item.'); } } if ($siblingId) { $siblingId = $this->resolveId($siblingId); if (!isset($this->items[$siblingId])) { throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId)); } if ($siblingId === $id) { throw new Exception\LogicException('The sibling item cannot be the same as the moving item.'); } } if (!$parentId && !$siblingId) { throw new Exception\LogicException('At least one parent or sibling item must be specified.'); } $path = $this->items[$id][self::PATH]; if (!$parentId) { $parentPath = array_slice($path, 0, -1); } else { if ($siblingId && $siblingId === $parentId) { throw new Exception\LogicException('The sibling item cannot be the same as the parent item.'); } $parentPath = $this->items[$parentId][self::PATH]; if (strpos(implode('/', $parentPath) . '/', implode('/', $path) . '/') === 0) { throw new Exception\LogicException( sprintf( 'The parent item (path: %s) cannot be a child of the moving item (path: %s).', implode('/', $parentPath), implode('/', $path) ) ); } } // update hierarchy $hierarchy = $this->hierarchy->get($path); $this->hierarchy->remove($path); $this->hierarchy->add($parentPath, $id, $siblingId, $prepend, $hierarchy); if ($parentId) { // build the new path $newPath = $parentPath; $newPath[] = $id; // update the path of the moving item $this->items[$id][self::PATH] = $newPath; // update the path for all children $prevPathLength = count($path); $iterator = $this->getHierarchyIterator($id); foreach ($iterator as $childId) { $this->items[$childId][self::PATH] = array_merge( $newPath, array_slice($this->items[$childId][self::PATH], $prevPathLength) ); } } }
[ "public", "function", "move", "(", "$", "id", ",", "$", "parentId", "=", "null", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "id", "=", "$", "this", "->", "validateAndResolveId", "(", "$", "id", ")", ";", "if", "(", "$", "parentId", ")", "{", "$", "parentId", "=", "$", "this", "->", "resolveId", "(", "$", "parentId", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "parentId", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ItemNotFoundException", "(", "sprintf", "(", "'The \"%s\" parent item does not exist.'", ",", "$", "parentId", ")", ")", ";", "}", "if", "(", "$", "parentId", "===", "$", "id", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'The parent item cannot be the same as the moving item.'", ")", ";", "}", "}", "if", "(", "$", "siblingId", ")", "{", "$", "siblingId", "=", "$", "this", "->", "resolveId", "(", "$", "siblingId", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "siblingId", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "ItemNotFoundException", "(", "sprintf", "(", "'The \"%s\" sibling item does not exist.'", ",", "$", "siblingId", ")", ")", ";", "}", "if", "(", "$", "siblingId", "===", "$", "id", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'The sibling item cannot be the same as the moving item.'", ")", ";", "}", "}", "if", "(", "!", "$", "parentId", "&&", "!", "$", "siblingId", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'At least one parent or sibling item must be specified.'", ")", ";", "}", "$", "path", "=", "$", "this", "->", "items", "[", "$", "id", "]", "[", "self", "::", "PATH", "]", ";", "if", "(", "!", "$", "parentId", ")", "{", "$", "parentPath", "=", "array_slice", "(", "$", "path", ",", "0", ",", "-", "1", ")", ";", "}", "else", "{", "if", "(", "$", "siblingId", "&&", "$", "siblingId", "===", "$", "parentId", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'The sibling item cannot be the same as the parent item.'", ")", ";", "}", "$", "parentPath", "=", "$", "this", "->", "items", "[", "$", "parentId", "]", "[", "self", "::", "PATH", "]", ";", "if", "(", "strpos", "(", "implode", "(", "'/'", ",", "$", "parentPath", ")", ".", "'/'", ",", "implode", "(", "'/'", ",", "$", "path", ")", ".", "'/'", ")", "===", "0", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "sprintf", "(", "'The parent item (path: %s) cannot be a child of the moving item (path: %s).'", ",", "implode", "(", "'/'", ",", "$", "parentPath", ")", ",", "implode", "(", "'/'", ",", "$", "path", ")", ")", ")", ";", "}", "}", "// update hierarchy", "$", "hierarchy", "=", "$", "this", "->", "hierarchy", "->", "get", "(", "$", "path", ")", ";", "$", "this", "->", "hierarchy", "->", "remove", "(", "$", "path", ")", ";", "$", "this", "->", "hierarchy", "->", "add", "(", "$", "parentPath", ",", "$", "id", ",", "$", "siblingId", ",", "$", "prepend", ",", "$", "hierarchy", ")", ";", "if", "(", "$", "parentId", ")", "{", "// build the new path", "$", "newPath", "=", "$", "parentPath", ";", "$", "newPath", "[", "]", "=", "$", "id", ";", "// update the path of the moving item", "$", "this", "->", "items", "[", "$", "id", "]", "[", "self", "::", "PATH", "]", "=", "$", "newPath", ";", "// update the path for all children", "$", "prevPathLength", "=", "count", "(", "$", "path", ")", ";", "$", "iterator", "=", "$", "this", "->", "getHierarchyIterator", "(", "$", "id", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "childId", ")", "{", "$", "this", "->", "items", "[", "$", "childId", "]", "[", "self", "::", "PATH", "]", "=", "array_merge", "(", "$", "newPath", ",", "array_slice", "(", "$", "this", "->", "items", "[", "$", "childId", "]", "[", "self", "::", "PATH", "]", ",", "$", "prevPathLength", ")", ")", ";", "}", "}", "}" ]
Moves the given item to another location @param string $id The id or alias of the layout item to be moved @param string|null $parentId The id or alias of a parent item the specified item is moved to If this parameter is null only the order of the item is changed @param string|null $siblingId The id or alias of an item which should be nearest neighbor @param bool|null $prepend Determines whether the moving item should be located before or after the specified sibling item @throws Exception\InvalidArgumentException if the id is empty @throws Exception\ItemNotFoundException if the layout item, parent item or sibling item does not exist @throws Exception\LogicException if the layout item cannot be moved by other reasons @SuppressWarnings(PHPMD.NPathComplexity) @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Moves", "the", "given", "item", "to", "another", "location" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L246-L308
oroinc/OroLayoutComponent
RawLayout.php
RawLayout.hasProperty
public function hasProperty($id, $name, $directAccess = false) { if (!$directAccess) { $id = $this->validateAndResolveId($id); } return isset($this->items[$id][$name]) || array_key_exists($name, $this->items[$id]); }
php
public function hasProperty($id, $name, $directAccess = false) { if (!$directAccess) { $id = $this->validateAndResolveId($id); } return isset($this->items[$id][$name]) || array_key_exists($name, $this->items[$id]); }
[ "public", "function", "hasProperty", "(", "$", "id", ",", "$", "name", ",", "$", "directAccess", "=", "false", ")", "{", "if", "(", "!", "$", "directAccess", ")", "{", "$", "id", "=", "$", "this", "->", "validateAndResolveId", "(", "$", "id", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "id", "]", "[", "$", "name", "]", ")", "||", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "items", "[", "$", "id", "]", ")", ";", "}" ]
Checks if the layout item has the given additional property @param string $id The id or alias of the layout item @param string $name The property name @param bool $directAccess Indicated whether the item id validation should be skipped. This flag can be used to increase performance of get operation, but use it carefully and only when you absolutely sure that the value passed as the item id is not an alias @return bool @throws Exception\InvalidArgumentException if the id is empty @throws Exception\ItemNotFoundException if the layout item does not exist
[ "Checks", "if", "the", "layout", "item", "has", "the", "given", "additional", "property" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L325-L332