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
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TraitConverter.php
TraitConverter.convert
public function convert(\DOMElement $parent, TraitDescriptor $trait) { $child = new \DOMElement('trait'); $parent->appendChild($child); $namespace = $trait->getNamespace()->getFullyQualifiedStructuralElementName(); $child->setAttribute('namespace', ltrim($namespace, '\\')); $child->setAttribute('line', $trait->getLine()); $child->appendChild(new \DOMElement('name', $trait->getName())); $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $trait); foreach ($trait->getProperties() as $property) { $this->propertyConverter->convert($child, $property); } foreach ($trait->getMethods() as $method) { $this->methodConverter->convert($child, $method); } return $child; }
php
public function convert(\DOMElement $parent, TraitDescriptor $trait) { $child = new \DOMElement('trait'); $parent->appendChild($child); $namespace = $trait->getNamespace()->getFullyQualifiedStructuralElementName(); $child->setAttribute('namespace', ltrim($namespace, '\\')); $child->setAttribute('line', $trait->getLine()); $child->appendChild(new \DOMElement('name', $trait->getName())); $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $trait); foreach ($trait->getProperties() as $property) { $this->propertyConverter->convert($child, $property); } foreach ($trait->getMethods() as $method) { $this->methodConverter->convert($child, $method); } return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "TraitDescriptor", "$", "trait", ")", "{", "$", "child", "=", "new", "\\", "DOMElement", "(", "'trait'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "namespace", "=", "$", "trait", "->", "getNamespace", "(", ")", "->", "getFullyQualifiedStructuralElementName", "(", ")", ";", "$", "child", "->", "setAttribute", "(", "'namespace'", ",", "ltrim", "(", "$", "namespace", ",", "'\\\\'", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "$", "trait", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "trait", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'full_name'", ",", "$", "trait", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ")", ";", "$", "this", "->", "docBlockConverter", "->", "convert", "(", "$", "child", ",", "$", "trait", ")", ";", "foreach", "(", "$", "trait", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "this", "->", "propertyConverter", "->", "convert", "(", "$", "child", ",", "$", "property", ")", ";", "}", "foreach", "(", "$", "trait", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "this", "->", "methodConverter", "->", "convert", "(", "$", "child", ",", "$", "method", ")", ";", "}", "return", "$", "child", ";", "}" ]
Export the given reflected Trait definition to the provided parent element. This method creates a new child element on the given parent XML element and takes the properties of the Reflection argument and sets the elements and attributes on the child. If a child DOMElement is provided then the properties and attributes are set on this but the child element is not appended onto the parent. This is the responsibility of the invoker. Essentially this means that the $parent argument is ignored in this case. @param \DOMElement $parent Element to augment. @param TraitDescriptor $trait Element to export. @return \DOMElement
[ "Export", "the", "given", "reflected", "Trait", "definition", "to", "the", "provided", "parent", "element", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TraitConverter.php#L66-L89
zhouyl/mellivora
Mellivora/View/Compilers/BladeCompiler.php
BladeCompiler.compile
public function compile($path = null) { if ($path) { $this->setPath($path); } if (!is_null($this->cachePath)) { if (!is_file($path)) { throw new \RuntimeException("File does not exist at path {$path}"); } file_put_contents( $this->getCompiledPath($path), $this->compileString(file_get_contents($path)) ); } }
php
public function compile($path = null) { if ($path) { $this->setPath($path); } if (!is_null($this->cachePath)) { if (!is_file($path)) { throw new \RuntimeException("File does not exist at path {$path}"); } file_put_contents( $this->getCompiledPath($path), $this->compileString(file_get_contents($path)) ); } }
[ "public", "function", "compile", "(", "$", "path", "=", "null", ")", "{", "if", "(", "$", "path", ")", "{", "$", "this", "->", "setPath", "(", "$", "path", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "cachePath", ")", ")", "{", "if", "(", "!", "is_file", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"File does not exist at path {$path}\"", ")", ";", "}", "file_put_contents", "(", "$", "this", "->", "getCompiledPath", "(", "$", "path", ")", ",", "$", "this", "->", "compileString", "(", "file_get_contents", "(", "$", "path", ")", ")", ")", ";", "}", "}" ]
Compile the view at the given path. @param string $path @return void
[ "Compile", "the", "view", "at", "the", "given", "path", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Compilers/BladeCompiler.php#L114-L130
ekuiter/feature-php
FeaturePhp/Specification/ChunkSpecification.php
ChunkSpecification.fromArrayAndSettings
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) { $chunkSpecification = new static($cfg, $settings->getDirectory()); $chunkSpecification->set("source", null); $chunkSpecification->set("target", fphp\Helper\Path::join( $settings->getOptional("target", null), $chunkSpecification->getTarget())); return $chunkSpecification; }
php
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) { $chunkSpecification = new static($cfg, $settings->getDirectory()); $chunkSpecification->set("source", null); $chunkSpecification->set("target", fphp\Helper\Path::join( $settings->getOptional("target", null), $chunkSpecification->getTarget())); return $chunkSpecification; }
[ "public", "static", "function", "fromArrayAndSettings", "(", "$", "cfg", ",", "$", "settings", ",", "$", "artifact", "=", "null", ")", "{", "$", "chunkSpecification", "=", "new", "static", "(", "$", "cfg", ",", "$", "settings", "->", "getDirectory", "(", ")", ")", ";", "$", "chunkSpecification", "->", "set", "(", "\"source\"", ",", "null", ")", ";", "$", "chunkSpecification", "->", "set", "(", "\"target\"", ",", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "settings", "->", "getOptional", "(", "\"target\"", ",", "null", ")", ",", "$", "chunkSpecification", "->", "getTarget", "(", ")", ")", ")", ";", "return", "$", "chunkSpecification", ";", "}" ]
Creates a chunk specification from a plain settings array. The settings context is taken into consideration to generate paths relative to the settings. @param array $cfg a plain settings array @param \FeaturePhp\Settings $settings the settings context @param \FeaturePhp\Artifact\Artifact $artifact is ignored @return ChunkSpecification
[ "Creates", "a", "chunk", "specification", "from", "a", "plain", "settings", "array", ".", "The", "settings", "context", "is", "taken", "into", "consideration", "to", "generate", "paths", "relative", "to", "the", "settings", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Specification/ChunkSpecification.php#L57-L63
OKTOTV/OktolabMediaBundle
Model/SpriteService.php
SpriteService.getSpriteWebvttForEpisode
public function getSpriteWebvttForEpisode($episode, $player_type = "jwplayer") { $this->calculateInterval($episode); switch ($player_type) { case 'jwplayer': return $this->getSpriteWebvttForJwPlayer($episode); break; default: return $this->getSpriteWebvttForJwPlayer($episode); break; } }
php
public function getSpriteWebvttForEpisode($episode, $player_type = "jwplayer") { $this->calculateInterval($episode); switch ($player_type) { case 'jwplayer': return $this->getSpriteWebvttForJwPlayer($episode); break; default: return $this->getSpriteWebvttForJwPlayer($episode); break; } }
[ "public", "function", "getSpriteWebvttForEpisode", "(", "$", "episode", ",", "$", "player_type", "=", "\"jwplayer\"", ")", "{", "$", "this", "->", "calculateInterval", "(", "$", "episode", ")", ";", "switch", "(", "$", "player_type", ")", "{", "case", "'jwplayer'", ":", "return", "$", "this", "->", "getSpriteWebvttForJwPlayer", "(", "$", "episode", ")", ";", "break", ";", "default", ":", "return", "$", "this", "->", "getSpriteWebvttForJwPlayer", "(", "$", "episode", ")", ";", "break", ";", "}", "}" ]
returns webvtt formated string for webplayers to display thumbnails
[ "returns", "webvtt", "formated", "string", "for", "webplayers", "to", "display", "thumbnails" ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/SpriteService.php#L23-L35
OKTOTV/OktolabMediaBundle
Model/SpriteService.php
SpriteService.calculateInterval
private function calculateInterval($episode) { $max_image = floor(65500/$this->sprite_height); $calculated_interval = ceil($episode->getDuration()/$max_image); if ($calculated_interval > $this->sprite_interval) { $this->sprite_interval = $calculated_interval; } }
php
private function calculateInterval($episode) { $max_image = floor(65500/$this->sprite_height); $calculated_interval = ceil($episode->getDuration()/$max_image); if ($calculated_interval > $this->sprite_interval) { $this->sprite_interval = $calculated_interval; } }
[ "private", "function", "calculateInterval", "(", "$", "episode", ")", "{", "$", "max_image", "=", "floor", "(", "65500", "/", "$", "this", "->", "sprite_height", ")", ";", "$", "calculated_interval", "=", "ceil", "(", "$", "episode", "->", "getDuration", "(", ")", "/", "$", "max_image", ")", ";", "if", "(", "$", "calculated_interval", ">", "$", "this", "->", "sprite_interval", ")", "{", "$", "this", "->", "sprite_interval", "=", "$", "calculated_interval", ";", "}", "}" ]
calculates the interval time for the length of an episode and considers jpeg dimension limit of 65500 px.
[ "calculates", "the", "interval", "time", "for", "the", "length", "of", "an", "episode", "and", "considers", "jpeg", "dimension", "limit", "of", "65500", "px", "." ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/SpriteService.php#L66-L73
eghojansu/moe
src/tools/Markdown.php
Markdown._a
protected function _a($str) { $self=$this; return preg_replace_callback( '/(?<!\\\\)\[(.+?)(?!\\\\)\]\h*\(<?(.*?)>?(?:\h*"(.*?)"\h*)?\)/', function($expr) use($self) { return '<a href="'.$self->esc($expr[2]).'"'. (empty($expr[3])? '': (' title="'.$self->esc($expr[3]).'"')). '>'.$self->scan($expr[1]).'</a>'; }, $str ); }
php
protected function _a($str) { $self=$this; return preg_replace_callback( '/(?<!\\\\)\[(.+?)(?!\\\\)\]\h*\(<?(.*?)>?(?:\h*"(.*?)"\h*)?\)/', function($expr) use($self) { return '<a href="'.$self->esc($expr[2]).'"'. (empty($expr[3])? '': (' title="'.$self->esc($expr[3]).'"')). '>'.$self->scan($expr[1]).'</a>'; }, $str ); }
[ "protected", "function", "_a", "(", "$", "str", ")", "{", "$", "self", "=", "$", "this", ";", "return", "preg_replace_callback", "(", "'/(?<!\\\\\\\\)\\[(.+?)(?!\\\\\\\\)\\]\\h*\\(<?(.*?)>?(?:\\h*\"(.*?)\"\\h*)?\\)/'", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "self", ")", "{", "return", "'<a href=\"'", ".", "$", "self", "->", "esc", "(", "$", "expr", "[", "2", "]", ")", ".", "'\"'", ".", "(", "empty", "(", "$", "expr", "[", "3", "]", ")", "?", "''", ":", "(", "' title=\"'", ".", "$", "self", "->", "esc", "(", "$", "expr", "[", "3", "]", ")", ".", "'\"'", ")", ")", ".", "'>'", ".", "$", "self", "->", "scan", "(", "$", "expr", "[", "1", "]", ")", ".", "'</a>'", ";", "}", ",", "$", "str", ")", ";", "}" ]
Process anchor span @return string @param $str string
[ "Process", "anchor", "span" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L356-L369
eghojansu/moe
src/tools/Markdown.php
Markdown._auto
protected function _auto($str) { $self=$this; return preg_replace_callback( '/`.*?<(.+?)>.*?`|<(.+?)>/', function($expr) use($self) { if (empty($expr[1]) && parse_url($expr[2],PHP_URL_SCHEME)) { $expr[2]=$self->esc($expr[2]); return '<a href="'.$expr[2].'">'.$expr[2].'</a>'; } return $expr[0]; }, $str ); }
php
protected function _auto($str) { $self=$this; return preg_replace_callback( '/`.*?<(.+?)>.*?`|<(.+?)>/', function($expr) use($self) { if (empty($expr[1]) && parse_url($expr[2],PHP_URL_SCHEME)) { $expr[2]=$self->esc($expr[2]); return '<a href="'.$expr[2].'">'.$expr[2].'</a>'; } return $expr[0]; }, $str ); }
[ "protected", "function", "_auto", "(", "$", "str", ")", "{", "$", "self", "=", "$", "this", ";", "return", "preg_replace_callback", "(", "'/`.*?<(.+?)>.*?`|<(.+?)>/'", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "self", ")", "{", "if", "(", "empty", "(", "$", "expr", "[", "1", "]", ")", "&&", "parse_url", "(", "$", "expr", "[", "2", "]", ",", "PHP_URL_SCHEME", ")", ")", "{", "$", "expr", "[", "2", "]", "=", "$", "self", "->", "esc", "(", "$", "expr", "[", "2", "]", ")", ";", "return", "'<a href=\"'", ".", "$", "expr", "[", "2", "]", ".", "'\">'", ".", "$", "expr", "[", "2", "]", ".", "'</a>'", ";", "}", "return", "$", "expr", "[", "0", "]", ";", "}", ",", "$", "str", ")", ";", "}" ]
Auto-convert links @return string @param $str string
[ "Auto", "-", "convert", "links" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L376-L389
eghojansu/moe
src/tools/Markdown.php
Markdown._code
protected function _code($str) { $self=$this; return preg_replace_callback( '/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/', function($expr) use($self) { return '<code>'. $self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>'; }, $str ); }
php
protected function _code($str) { $self=$this; return preg_replace_callback( '/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/', function($expr) use($self) { return '<code>'. $self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>'; }, $str ); }
[ "protected", "function", "_code", "(", "$", "str", ")", "{", "$", "self", "=", "$", "this", ";", "return", "preg_replace_callback", "(", "'/`` (.+?) ``|(?<!\\\\\\\\)`(.+?)(?!\\\\\\\\)`/'", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "self", ")", "{", "return", "'<code>'", ".", "$", "self", "->", "esc", "(", "empty", "(", "$", "expr", "[", "1", "]", ")", "?", "$", "expr", "[", "2", "]", ":", "$", "expr", "[", "1", "]", ")", ".", "'</code>'", ";", "}", ",", "$", "str", ")", ";", "}" ]
Process code span @return string @param $str string
[ "Process", "code", "span" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L396-L406
eghojansu/moe
src/tools/Markdown.php
Markdown.esc
function esc($str) { if (!$this->special) $this->special=array( '...'=>'&hellip;', '(tm)'=>'&trade;', '(r)'=>'&reg;', '(c)'=>'&copy;' ); foreach ($this->special as $key=>$val) $str=preg_replace('/'.preg_quote($key,'/').'/i',$val,$str); return htmlspecialchars($str,ENT_COMPAT, Base::instance()->get('ENCODING'),FALSE); }
php
function esc($str) { if (!$this->special) $this->special=array( '...'=>'&hellip;', '(tm)'=>'&trade;', '(r)'=>'&reg;', '(c)'=>'&copy;' ); foreach ($this->special as $key=>$val) $str=preg_replace('/'.preg_quote($key,'/').'/i',$val,$str); return htmlspecialchars($str,ENT_COMPAT, Base::instance()->get('ENCODING'),FALSE); }
[ "function", "esc", "(", "$", "str", ")", "{", "if", "(", "!", "$", "this", "->", "special", ")", "$", "this", "->", "special", "=", "array", "(", "'...'", "=>", "'&hellip;'", ",", "'(tm)'", "=>", "'&trade;'", ",", "'(r)'", "=>", "'&reg;'", ",", "'(c)'", "=>", "'&copy;'", ")", ";", "foreach", "(", "$", "this", "->", "special", "as", "$", "key", "=>", "$", "val", ")", "$", "str", "=", "preg_replace", "(", "'/'", ".", "preg_quote", "(", "$", "key", ",", "'/'", ")", ".", "'/i'", ",", "$", "val", ",", "$", "str", ")", ";", "return", "htmlspecialchars", "(", "$", "str", ",", "ENT_COMPAT", ",", "Base", "::", "instance", "(", ")", "->", "get", "(", "'ENCODING'", ")", ",", "FALSE", ")", ";", "}" ]
Convert characters to HTML entities @return string @param $str string
[ "Convert", "characters", "to", "HTML", "entities" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L413-L425
old-town/workflow-designer-server
src/View/ApiProblemInjectResponse.php
ApiProblemInjectResponse.attach
public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, [$this, 'injectResponse'], $priority); }
php
public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, [$this, 'injectResponse'], $priority); }
[ "public", "function", "attach", "(", "EventManagerInterface", "$", "events", ",", "$", "priority", "=", "1", ")", "{", "$", "this", "->", "listeners", "[", "]", "=", "$", "events", "->", "attach", "(", "ViewEvent", "::", "EVENT_RESPONSE", ",", "[", "$", "this", ",", "'injectResponse'", "]", ",", "$", "priority", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/ApiProblemInjectResponse.php#L29-L32
old-town/workflow-designer-server
src/View/ApiProblemInjectResponse.php
ApiProblemInjectResponse.injectResponse
public function injectResponse(ViewEvent $e) { $model = $e->getModel(); if (!$model instanceof ApiProblemModel) { // Model is not an ApiProblemModel; we cannot handle it here return null; } /** @var Request $request */ $request = $e->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if (!($accept instanceof Accept && $accept->hasMediaType('text/xml'))) { return null; } $problem = $model->getApiProblem(); $statusCode = $this->getStatusCodeFromApiProblem($problem); $contentType = 'text/xml'; /** @var Response $response */ $response = $e->getResponse(); $problemData = $problem->toArray(); $xmlWriter = new XmlWriter(); $output = $xmlWriter->processConfig($problemData); $response->setStatusCode($statusCode); $response->setContent($output); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', $contentType); }
php
public function injectResponse(ViewEvent $e) { $model = $e->getModel(); if (!$model instanceof ApiProblemModel) { // Model is not an ApiProblemModel; we cannot handle it here return null; } /** @var Request $request */ $request = $e->getRequest(); /** @var Accept $accept */ $accept = $request->getHeader('Accept'); if (!($accept instanceof Accept && $accept->hasMediaType('text/xml'))) { return null; } $problem = $model->getApiProblem(); $statusCode = $this->getStatusCodeFromApiProblem($problem); $contentType = 'text/xml'; /** @var Response $response */ $response = $e->getResponse(); $problemData = $problem->toArray(); $xmlWriter = new XmlWriter(); $output = $xmlWriter->processConfig($problemData); $response->setStatusCode($statusCode); $response->setContent($output); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', $contentType); }
[ "public", "function", "injectResponse", "(", "ViewEvent", "$", "e", ")", "{", "$", "model", "=", "$", "e", "->", "getModel", "(", ")", ";", "if", "(", "!", "$", "model", "instanceof", "ApiProblemModel", ")", "{", "// Model is not an ApiProblemModel; we cannot handle it here", "return", "null", ";", "}", "/** @var Request $request */", "$", "request", "=", "$", "e", "->", "getRequest", "(", ")", ";", "/** @var Accept $accept */", "$", "accept", "=", "$", "request", "->", "getHeader", "(", "'Accept'", ")", ";", "if", "(", "!", "(", "$", "accept", "instanceof", "Accept", "&&", "$", "accept", "->", "hasMediaType", "(", "'text/xml'", ")", ")", ")", "{", "return", "null", ";", "}", "$", "problem", "=", "$", "model", "->", "getApiProblem", "(", ")", ";", "$", "statusCode", "=", "$", "this", "->", "getStatusCodeFromApiProblem", "(", "$", "problem", ")", ";", "$", "contentType", "=", "'text/xml'", ";", "/** @var Response $response */", "$", "response", "=", "$", "e", "->", "getResponse", "(", ")", ";", "$", "problemData", "=", "$", "problem", "->", "toArray", "(", ")", ";", "$", "xmlWriter", "=", "new", "XmlWriter", "(", ")", ";", "$", "output", "=", "$", "xmlWriter", "->", "processConfig", "(", "$", "problemData", ")", ";", "$", "response", "->", "setStatusCode", "(", "$", "statusCode", ")", ";", "$", "response", "->", "setContent", "(", "$", "output", ")", ";", "$", "headers", "=", "$", "response", "->", "getHeaders", "(", ")", ";", "$", "headers", "->", "addHeaderLine", "(", "'Content-Type'", ",", "$", "contentType", ")", ";", "}" ]
@param ViewEvent $e @return null @throws \Zend\Config\Exception\RuntimeException @throws \Zend\Http\Exception\InvalidArgumentException
[ "@param", "ViewEvent", "$e" ]
train
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/ApiProblemInjectResponse.php#L42-L77
old-town/workflow-designer-server
src/View/ApiProblemInjectResponse.php
ApiProblemInjectResponse.getStatusCodeFromApiProblem
protected function getStatusCodeFromApiProblem(ApiProblem $problem) { $problemData = $problem->toArray(); $status = array_key_exists('status', $problemData) ? $problemData['status'] : 0; if ($status < 100 || $status >= 600) { return 500; } return $status; }
php
protected function getStatusCodeFromApiProblem(ApiProblem $problem) { $problemData = $problem->toArray(); $status = array_key_exists('status', $problemData) ? $problemData['status'] : 0; if ($status < 100 || $status >= 600) { return 500; } return $status; }
[ "protected", "function", "getStatusCodeFromApiProblem", "(", "ApiProblem", "$", "problem", ")", "{", "$", "problemData", "=", "$", "problem", "->", "toArray", "(", ")", ";", "$", "status", "=", "array_key_exists", "(", "'status'", ",", "$", "problemData", ")", "?", "$", "problemData", "[", "'status'", "]", ":", "0", ";", "if", "(", "$", "status", "<", "100", "||", "$", "status", ">=", "600", ")", "{", "return", "500", ";", "}", "return", "$", "status", ";", "}" ]
Retrieve the HTTP status from an ApiProblem object Ensures that the status falls within the acceptable range (100 - 599). @param ApiProblem $problem @return int
[ "Retrieve", "the", "HTTP", "status", "from", "an", "ApiProblem", "object" ]
train
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/ApiProblemInjectResponse.php#L87-L97
arndtteunissen/column-layout
Classes/Utility/ColumnLayoutUtility.php
ColumnLayoutUtility.getSizesFor
public static function getSizesFor(string $size, string $type, int $pageUid): array { $settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid); if (!array_key_exists($size . '.', $settings['sizes.'])) { throw new Exception(sprintf('The given size "%s" is not defined in the gridsystem', $size), 1520324173); } if (!array_key_exists($type, $settings['sizes.'][$size . '.'])) { throw new Exception(sprintf('The given type "%s" does not exist for size "%s"', $type, $size), 1520324252); } return ColumnLayoutUtility::processColumnSizes($settings['sizes.'][$size . '.'][$type], $settings['columnsCount']); }
php
public static function getSizesFor(string $size, string $type, int $pageUid): array { $settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid); if (!array_key_exists($size . '.', $settings['sizes.'])) { throw new Exception(sprintf('The given size "%s" is not defined in the gridsystem', $size), 1520324173); } if (!array_key_exists($type, $settings['sizes.'][$size . '.'])) { throw new Exception(sprintf('The given type "%s" does not exist for size "%s"', $type, $size), 1520324252); } return ColumnLayoutUtility::processColumnSizes($settings['sizes.'][$size . '.'][$type], $settings['columnsCount']); }
[ "public", "static", "function", "getSizesFor", "(", "string", "$", "size", ",", "string", "$", "type", ",", "int", "$", "pageUid", ")", ":", "array", "{", "$", "settings", "=", "ColumnLayoutUtility", "::", "getColumnLayoutSettings", "(", "$", "pageUid", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "size", ".", "'.'", ",", "$", "settings", "[", "'sizes.'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'The given size \"%s\" is not defined in the gridsystem'", ",", "$", "size", ")", ",", "1520324173", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "settings", "[", "'sizes.'", "]", "[", "$", "size", ".", "'.'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'The given type \"%s\" does not exist for size \"%s\"'", ",", "$", "type", ",", "$", "size", ")", ",", "1520324252", ")", ";", "}", "return", "ColumnLayoutUtility", "::", "processColumnSizes", "(", "$", "settings", "[", "'sizes.'", "]", "[", "$", "size", ".", "'.'", "]", "[", "$", "type", "]", ",", "$", "settings", "[", "'columnsCount'", "]", ")", ";", "}" ]
Calculates the column sizes for the given size and the given size type @param string $size name of the sizes identifier (e.g. large, medium) @param string $type size type (e.g. columns, offset, order) @param int $pageUid the page which's TSConfig should be used @return array of column sizes @throws Exception when the given size or type is not defined
[ "Calculates", "the", "column", "sizes", "for", "the", "given", "size", "and", "the", "given", "size", "type" ]
train
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L31-L44
arndtteunissen/column-layout
Classes/Utility/ColumnLayoutUtility.php
ColumnLayoutUtility.processColumnSizes
protected static function processColumnSizes(string $values, int $maxColumns) { $columns = []; if ($values == '*') { $columns = range(0, $maxColumns); } else { $values = explode(',', $values); foreach ($values as $value) { if (strpos($value, '-') !== false) { list($from, $to) = explode('-', $value); $columns = array_merge($columns, range($from, $to)); } else { $columns[] = (int)$value; } } } return array_unique($columns); }
php
protected static function processColumnSizes(string $values, int $maxColumns) { $columns = []; if ($values == '*') { $columns = range(0, $maxColumns); } else { $values = explode(',', $values); foreach ($values as $value) { if (strpos($value, '-') !== false) { list($from, $to) = explode('-', $value); $columns = array_merge($columns, range($from, $to)); } else { $columns[] = (int)$value; } } } return array_unique($columns); }
[ "protected", "static", "function", "processColumnSizes", "(", "string", "$", "values", ",", "int", "$", "maxColumns", ")", "{", "$", "columns", "=", "[", "]", ";", "if", "(", "$", "values", "==", "'*'", ")", "{", "$", "columns", "=", "range", "(", "0", ",", "$", "maxColumns", ")", ";", "}", "else", "{", "$", "values", "=", "explode", "(", "','", ",", "$", "values", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "value", ",", "'-'", ")", "!==", "false", ")", "{", "list", "(", "$", "from", ",", "$", "to", ")", "=", "explode", "(", "'-'", ",", "$", "value", ")", ";", "$", "columns", "=", "array_merge", "(", "$", "columns", ",", "range", "(", "$", "from", ",", "$", "to", ")", ")", ";", "}", "else", "{", "$", "columns", "[", "]", "=", "(", "int", ")", "$", "value", ";", "}", "}", "}", "return", "array_unique", "(", "$", "columns", ")", ";", "}" ]
Processes values of size types (e.g. columns, offset, order) and generates an array of column sizes for that type. @param string $values @param int $maxColumns @return array
[ "Processes", "values", "of", "size", "types", "(", "e", ".", "g", ".", "columns", "offset", "order", ")", "and", "generates", "an", "array", "of", "column", "sizes", "for", "that", "type", "." ]
train
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L53-L72
arndtteunissen/column-layout
Classes/Utility/ColumnLayoutUtility.php
ColumnLayoutUtility.getColumnLayoutSettings
public static function getColumnLayoutSettings(int $page): array { $pageTSConfig = BackendUtility::getPagesTSconfig($page); if (!array_key_exists('column_layout.', $pageTSConfig['mod.'])) { throw new Exception(sprintf('No column layout found for page "%d". Please define the column_layout settings in your page TSConfig.', $page), 1520323245); } return $pageTSConfig['mod.']['column_layout.']; }
php
public static function getColumnLayoutSettings(int $page): array { $pageTSConfig = BackendUtility::getPagesTSconfig($page); if (!array_key_exists('column_layout.', $pageTSConfig['mod.'])) { throw new Exception(sprintf('No column layout found for page "%d". Please define the column_layout settings in your page TSConfig.', $page), 1520323245); } return $pageTSConfig['mod.']['column_layout.']; }
[ "public", "static", "function", "getColumnLayoutSettings", "(", "int", "$", "page", ")", ":", "array", "{", "$", "pageTSConfig", "=", "BackendUtility", "::", "getPagesTSconfig", "(", "$", "page", ")", ";", "if", "(", "!", "array_key_exists", "(", "'column_layout.'", ",", "$", "pageTSConfig", "[", "'mod.'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'No column layout found for page \"%d\". Please define the column_layout settings in your page TSConfig.'", ",", "$", "page", ")", ",", "1520323245", ")", ";", "}", "return", "$", "pageTSConfig", "[", "'mod.'", "]", "[", "'column_layout.'", "]", ";", "}" ]
Returns the column layout configuration from page TSConfig. @param int $page uid of the page @return array column layout settings @throws Exception when the column_layout setting hasn't been defined
[ "Returns", "the", "column", "layout", "configuration", "from", "page", "TSConfig", "." ]
train
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L81-L90
arndtteunissen/column-layout
Classes/Utility/ColumnLayoutUtility.php
ColumnLayoutUtility.hydrateLayoutConfigFlexFormData
public static function hydrateLayoutConfigFlexFormData($flexFormData): array { $dataStructure = $flexFormData; if (is_string($flexFormData)) { $dataStructure = GeneralUtility::xml2array($flexFormData); } // Level: FlexForm Sheets return array_map(function ($sheet) { // Level: FlexForm Sheet Fields return array_map(function ($field) { // Level: FlexForm Field return $field['vDEF']; }, $sheet['lDEF']); }, $dataStructure['data']); }
php
public static function hydrateLayoutConfigFlexFormData($flexFormData): array { $dataStructure = $flexFormData; if (is_string($flexFormData)) { $dataStructure = GeneralUtility::xml2array($flexFormData); } // Level: FlexForm Sheets return array_map(function ($sheet) { // Level: FlexForm Sheet Fields return array_map(function ($field) { // Level: FlexForm Field return $field['vDEF']; }, $sheet['lDEF']); }, $dataStructure['data']); }
[ "public", "static", "function", "hydrateLayoutConfigFlexFormData", "(", "$", "flexFormData", ")", ":", "array", "{", "$", "dataStructure", "=", "$", "flexFormData", ";", "if", "(", "is_string", "(", "$", "flexFormData", ")", ")", "{", "$", "dataStructure", "=", "GeneralUtility", "::", "xml2array", "(", "$", "flexFormData", ")", ";", "}", "// Level: FlexForm Sheets", "return", "array_map", "(", "function", "(", "$", "sheet", ")", "{", "// Level: FlexForm Sheet Fields", "return", "array_map", "(", "function", "(", "$", "field", ")", "{", "// Level: FlexForm Field", "return", "$", "field", "[", "'vDEF'", "]", ";", "}", ",", "$", "sheet", "[", "'lDEF'", "]", ")", ";", "}", ",", "$", "dataStructure", "[", "'data'", "]", ")", ";", "}" ]
Simplify a FlexForm DataStructure array. Removes all unnecessary sheet, field or value identifiers. @param string|array $flexFormData either a converted FlexForm array or the raw FlexForm string @return array simplified FlexForm data structure
[ "Simplify", "a", "FlexForm", "DataStructure", "array", ".", "Removes", "all", "unnecessary", "sheet", "field", "or", "value", "identifiers", "." ]
train
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L99-L114
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getColumn
public function getColumn($name) { if (!$this->hasColumn($name)) { throw new InvalidArgumentException(sprintf('The column "%s" could not be found.', $name)); } return $this->columns[$name]; }
php
public function getColumn($name) { if (!$this->hasColumn($name)) { throw new InvalidArgumentException(sprintf('The column "%s" could not be found.', $name)); } return $this->columns[$name]; }
[ "public", "function", "getColumn", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasColumn", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The column \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "columns", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L136-L143
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getFilter
public function getFilter($name) { if (!$this->hasFilter($name)) { throw new InvalidArgumentException(sprintf('The filter "%s" could not be found.', $name)); } return $this->filters[$name]; }
php
public function getFilter($name) { if (!$this->hasFilter($name)) { throw new InvalidArgumentException(sprintf('The filter "%s" could not be found.', $name)); } return $this->filters[$name]; }
[ "public", "function", "getFilter", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasFilter", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The filter \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "filters", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L172-L179
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getSort
public function getSort($name) { if (!$this->hasSort($name)) { throw new InvalidArgumentException(sprintf('The sort "%s" could not be found.', $name)); } return $this->sorts[$name]; }
php
public function getSort($name) { if (!$this->hasSort($name)) { throw new InvalidArgumentException(sprintf('The sort "%s" could not be found.', $name)); } return $this->sorts[$name]; }
[ "public", "function", "getSort", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasSort", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The sort \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "sorts", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L208-L215
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getGlobalAction
public function getGlobalAction($name) { if (!$this->hasGlobalAction($name)) { throw new InvalidArgumentException(sprintf('The global action "%s" could not be found.', $name)); } return $this->globalActions[$name]; }
php
public function getGlobalAction($name) { if (!$this->hasGlobalAction($name)) { throw new InvalidArgumentException(sprintf('The global action "%s" could not be found.', $name)); } return $this->globalActions[$name]; }
[ "public", "function", "getGlobalAction", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasGlobalAction", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The global action \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "globalActions", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L244-L251
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getColumnAction
public function getColumnAction($name) { if (!$this->hasColumnAction($name)) { throw new InvalidArgumentException(sprintf('The column action "%s" could not be found.', $name)); } return $this->columnActions[$name]; }
php
public function getColumnAction($name) { if (!$this->hasColumnAction($name)) { throw new InvalidArgumentException(sprintf('The column action "%s" could not be found.', $name)); } return $this->columnActions[$name]; }
[ "public", "function", "getColumnAction", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasColumnAction", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The column action \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "columnActions", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L280-L287
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getBatch
public function getBatch($name) { if (!$this->hasBatch($name)) { throw new InvalidArgumentException(sprintf('The batch "%s" could not be found.', $name)); } return $this->batches[$name]; }
php
public function getBatch($name) { if (!$this->hasBatch($name)) { throw new InvalidArgumentException(sprintf('The batch "%s" could not be found.', $name)); } return $this->batches[$name]; }
[ "public", "function", "getBatch", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasBatch", "(", "$", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The batch \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "batches", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L316-L323
php-lug/lug
src/Component/Grid/Model/Grid.php
Grid.getOption
public function getOption($name) { if (!$this->hasOption($name)) { throw new OptionNotFoundException(sprintf('The grid option "%s" could not be found.', $name)); } return $this->options[$name]; }
php
public function getOption($name) { if (!$this->hasOption($name)) { throw new OptionNotFoundException(sprintf('The grid option "%s" could not be found.', $name)); } return $this->options[$name]; }
[ "public", "function", "getOption", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "name", ")", ")", "{", "throw", "new", "OptionNotFoundException", "(", "sprintf", "(", "'The grid option \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "options", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Model/Grid.php#L368-L375
frdl/webfan
.ApplicationComposer/lib/webdof/SumaTag.php
SumaTag.loadDefaults
public function loadDefaults() { $this->addSe('*.google.*', 'q'); $this->addSe('*.yahoo.*', 'p'); $this->addSe('*.live.*', 'q'); $this->addSe('*.bing.*', 'q'); $this->addSe('*.aolsvc.*', 'q'); $this->addSe('suche.webfan.de', 'q'); }
php
public function loadDefaults() { $this->addSe('*.google.*', 'q'); $this->addSe('*.yahoo.*', 'p'); $this->addSe('*.live.*', 'q'); $this->addSe('*.bing.*', 'q'); $this->addSe('*.aolsvc.*', 'q'); $this->addSe('suche.webfan.de', 'q'); }
[ "public", "function", "loadDefaults", "(", ")", "{", "$", "this", "->", "addSe", "(", "'*.google.*'", ",", "'q'", ")", ";", "$", "this", "->", "addSe", "(", "'*.yahoo.*'", ",", "'p'", ")", ";", "$", "this", "->", "addSe", "(", "'*.live.*'", ",", "'q'", ")", ";", "$", "this", "->", "addSe", "(", "'*.bing.*'", ",", "'q'", ")", ";", "$", "this", "->", "addSe", "(", "'*.aolsvc.*'", ",", "'q'", ")", ";", "$", "this", "->", "addSe", "(", "'suche.webfan.de'", ",", "'q'", ")", ";", "}" ]
/* Example settings: 'google', 'q', 'yahoo', 'p', 'live', 'q', 'aolsvc', 'q', 'bing', 'q', 'suche.webfan.de', 'q', Test: 'localhost', 'q',
[ "/", "*", "Example", "settings", ":", "google", "q", "yahoo", "p", "live", "q", "aolsvc", "q", "bing", "q", "suche", ".", "webfan", ".", "de", "q", "Test", ":", "localhost", "q" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/SumaTag.php#L50-L58
frdl/webfan
.ApplicationComposer/lib/webdof/SumaTag.php
SumaTag.addSe
public function addSe($host, $kpn) { $host = trim($host); $regex = str_replace('.', '\\.', $host); if(substr($host, 0, 1) !== '*')$regex = '^'.$regex; if(substr($host, -1, 1) !== '*')$regex.= '$'; $regex = str_replace('*', '', $regex); $this->se[$host] = array( 'name' => $host, 'regex' => $regex, 'kpn' => $kpn, ); }
php
public function addSe($host, $kpn) { $host = trim($host); $regex = str_replace('.', '\\.', $host); if(substr($host, 0, 1) !== '*')$regex = '^'.$regex; if(substr($host, -1, 1) !== '*')$regex.= '$'; $regex = str_replace('*', '', $regex); $this->se[$host] = array( 'name' => $host, 'regex' => $regex, 'kpn' => $kpn, ); }
[ "public", "function", "addSe", "(", "$", "host", ",", "$", "kpn", ")", "{", "$", "host", "=", "trim", "(", "$", "host", ")", ";", "$", "regex", "=", "str_replace", "(", "'.'", ",", "'\\\\.'", ",", "$", "host", ")", ";", "if", "(", "substr", "(", "$", "host", ",", "0", ",", "1", ")", "!==", "'*'", ")", "$", "regex", "=", "'^'", ".", "$", "regex", ";", "if", "(", "substr", "(", "$", "host", ",", "-", "1", ",", "1", ")", "!==", "'*'", ")", "$", "regex", ".=", "'$'", ";", "$", "regex", "=", "str_replace", "(", "'*'", ",", "''", ",", "$", "regex", ")", ";", "$", "this", "->", "se", "[", "$", "host", "]", "=", "array", "(", "'name'", "=>", "$", "host", ",", "'regex'", "=>", "$", "regex", ",", "'kpn'", "=>", "$", "kpn", ",", ")", ";", "}" ]
/* addSe - add search engine @param string $host E.g.: 'sub.google.com' OR '*.google.com' OR 'google.*' OR '*.*' @param string $kpn - keywordParameterName - The query parameter of the referer url where the search-keyword is found e.g. for google it is 'q' e.g. for yahoo it is 'p'
[ "/", "*", "addSe", "-", "add", "search", "engine" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/SumaTag.php#L67-L81
frdl/webfan
.ApplicationComposer/lib/webdof/SumaTag.php
SumaTag.check
public function check($ref = NULL, $loc = NULL) { if($loc === NULL || parse_url($loc) === FALSE) { $u = $this->u->getU(); $loc = $u->location; } if($ref === NULL)$ref = strip_tags($_SERVER['HTTP_REFERER']); $ru = parse_url($ref); if($ref === '' || $ru === FALSE)return FALSE; $r = $this->u->parse_uri($ru['scheme'], $ru['host'], $ru['path'].'?'.$ru['query']); foreach($this->se as $host => $h) { $regex = "/".$h['regex']."/"; if(!preg_match($regex, $r->server) )continue; if(!isset($r->query[$h['kpn']]) )continue; return array( 'host' => $h['name'], 'keyword' => trim(urldecode($r->query[$h['kpn']])), 'url' => $loc, ); } return FALSE; }
php
public function check($ref = NULL, $loc = NULL) { if($loc === NULL || parse_url($loc) === FALSE) { $u = $this->u->getU(); $loc = $u->location; } if($ref === NULL)$ref = strip_tags($_SERVER['HTTP_REFERER']); $ru = parse_url($ref); if($ref === '' || $ru === FALSE)return FALSE; $r = $this->u->parse_uri($ru['scheme'], $ru['host'], $ru['path'].'?'.$ru['query']); foreach($this->se as $host => $h) { $regex = "/".$h['regex']."/"; if(!preg_match($regex, $r->server) )continue; if(!isset($r->query[$h['kpn']]) )continue; return array( 'host' => $h['name'], 'keyword' => trim(urldecode($r->query[$h['kpn']])), 'url' => $loc, ); } return FALSE; }
[ "public", "function", "check", "(", "$", "ref", "=", "NULL", ",", "$", "loc", "=", "NULL", ")", "{", "if", "(", "$", "loc", "===", "NULL", "||", "parse_url", "(", "$", "loc", ")", "===", "FALSE", ")", "{", "$", "u", "=", "$", "this", "->", "u", "->", "getU", "(", ")", ";", "$", "loc", "=", "$", "u", "->", "location", ";", "}", "if", "(", "$", "ref", "===", "NULL", ")", "$", "ref", "=", "strip_tags", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", ";", "$", "ru", "=", "parse_url", "(", "$", "ref", ")", ";", "if", "(", "$", "ref", "===", "''", "||", "$", "ru", "===", "FALSE", ")", "return", "FALSE", ";", "$", "r", "=", "$", "this", "->", "u", "->", "parse_uri", "(", "$", "ru", "[", "'scheme'", "]", ",", "$", "ru", "[", "'host'", "]", ",", "$", "ru", "[", "'path'", "]", ".", "'?'", ".", "$", "ru", "[", "'query'", "]", ")", ";", "foreach", "(", "$", "this", "->", "se", "as", "$", "host", "=>", "$", "h", ")", "{", "$", "regex", "=", "\"/\"", ".", "$", "h", "[", "'regex'", "]", ".", "\"/\"", ";", "if", "(", "!", "preg_match", "(", "$", "regex", ",", "$", "r", "->", "server", ")", ")", "continue", ";", "if", "(", "!", "isset", "(", "$", "r", "->", "query", "[", "$", "h", "[", "'kpn'", "]", "]", ")", ")", "continue", ";", "return", "array", "(", "'host'", "=>", "$", "h", "[", "'name'", "]", ",", "'keyword'", "=>", "trim", "(", "urldecode", "(", "$", "r", "->", "query", "[", "$", "h", "[", "'kpn'", "]", "]", ")", ")", ",", "'url'", "=>", "$", "loc", ",", ")", ";", "}", "return", "FALSE", ";", "}" ]
/* check - check for keyword in referer !Returns only the first match! @param string $ref - referer url to check @param string $loc - url found on your page - OPTIONAL @return FALSE || array(host, keyword, url)
[ "/", "*", "check", "-", "check", "for", "keyword", "in", "referer", "!Returns", "only", "the", "first", "match!", "@param", "string", "$ref", "-", "referer", "url", "to", "check", "@param", "string", "$loc", "-", "url", "found", "on", "your", "page", "-", "OPTIONAL" ]
train
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/webdof/SumaTag.php#L108-L133
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.setId
public function setId($v) { if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; $this->modifiedColumns[CustomerGroupI18nTableMap::ID] = true; } if ($this->aCustomerGroup !== null && $this->aCustomerGroup->getId() !== $v) { $this->aCustomerGroup = null; } return $this; }
php
public function setId($v) { if ($v !== null) { $v = (int) $v; } if ($this->id !== $v) { $this->id = $v; $this->modifiedColumns[CustomerGroupI18nTableMap::ID] = true; } if ($this->aCustomerGroup !== null && $this->aCustomerGroup->getId() !== $v) { $this->aCustomerGroup = null; } return $this; }
[ "public", "function", "setId", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "int", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "id", "!==", "$", "v", ")", "{", "$", "this", "->", "id", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "CustomerGroupI18nTableMap", "::", "ID", "]", "=", "true", ";", "}", "if", "(", "$", "this", "->", "aCustomerGroup", "!==", "null", "&&", "$", "this", "->", "aCustomerGroup", "->", "getId", "(", ")", "!==", "$", "v", ")", "{", "$", "this", "->", "aCustomerGroup", "=", "null", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [id] column. @param int $v new value @return \CustomerGroup\Model\CustomerGroupI18n The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "id", "]", "column", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L415-L432
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.ensureConsistency
public function ensureConsistency() { if ($this->aCustomerGroup !== null && $this->id !== $this->aCustomerGroup->getId()) { $this->aCustomerGroup = null; } }
php
public function ensureConsistency() { if ($this->aCustomerGroup !== null && $this->id !== $this->aCustomerGroup->getId()) { $this->aCustomerGroup = null; } }
[ "public", "function", "ensureConsistency", "(", ")", "{", "if", "(", "$", "this", "->", "aCustomerGroup", "!==", "null", "&&", "$", "this", "->", "id", "!==", "$", "this", "->", "aCustomerGroup", "->", "getId", "(", ")", ")", "{", "$", "this", "->", "aCustomerGroup", "=", "null", ";", "}", "}" ]
Checks and repairs the internal consistency of the object. This method is executed after an already-instantiated object is re-hydrated from the database. It exists to check any foreign keys to make sure that the objects related to the current object are correct based on foreign key. You can override this method in the stub class, but you should always invoke the base method from the overridden method (i.e. parent::ensureConsistency()), in case your model changes. @throws PropelException
[ "Checks", "and", "repairs", "the", "internal", "consistency", "of", "the", "object", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L577-L582
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.doSave
protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aCustomerGroup !== null) { if ($this->aCustomerGroup->isModified() || $this->aCustomerGroup->isNew()) { $affectedRows += $this->aCustomerGroup->save($con); } $this->setCustomerGroup($this->aCustomerGroup); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
php
protected function doSave(ConnectionInterface $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their corresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aCustomerGroup !== null) { if ($this->aCustomerGroup->isModified() || $this->aCustomerGroup->isNew()) { $affectedRows += $this->aCustomerGroup->save($con); } $this->setCustomerGroup($this->aCustomerGroup); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } $this->alreadyInSave = false; } return $affectedRows; }
[ "protected", "function", "doSave", "(", "ConnectionInterface", "$", "con", ")", "{", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "if", "(", "!", "$", "this", "->", "alreadyInSave", ")", "{", "$", "this", "->", "alreadyInSave", "=", "true", ";", "// We call the save method on the following object(s) if they", "// were passed to this object by their corresponding set", "// method. This object relates to these object(s) by a", "// foreign key reference.", "if", "(", "$", "this", "->", "aCustomerGroup", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "aCustomerGroup", "->", "isModified", "(", ")", "||", "$", "this", "->", "aCustomerGroup", "->", "isNew", "(", ")", ")", "{", "$", "affectedRows", "+=", "$", "this", "->", "aCustomerGroup", "->", "save", "(", "$", "con", ")", ";", "}", "$", "this", "->", "setCustomerGroup", "(", "$", "this", "->", "aCustomerGroup", ")", ";", "}", "if", "(", "$", "this", "->", "isNew", "(", ")", "||", "$", "this", "->", "isModified", "(", ")", ")", "{", "// persist changes", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "$", "this", "->", "doInsert", "(", "$", "con", ")", ";", "}", "else", "{", "$", "this", "->", "doUpdate", "(", "$", "con", ")", ";", "}", "$", "affectedRows", "+=", "1", ";", "$", "this", "->", "resetModified", "(", ")", ";", "}", "$", "this", "->", "alreadyInSave", "=", "false", ";", "}", "return", "$", "affectedRows", ";", "}" ]
Performs the work of inserting or updating the row in the database. If the object is new, it inserts it; otherwise an update is performed. All related objects are also updated in this method. @param ConnectionInterface $con @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. @throws PropelException @see save()
[ "Performs", "the", "work", "of", "inserting", "or", "updating", "the", "row", "in", "the", "database", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L727-L761
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.buildCriteria
public function buildCriteria() { $criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME); if ($this->isColumnModified(CustomerGroupI18nTableMap::ID)) $criteria->add(CustomerGroupI18nTableMap::ID, $this->id); if ($this->isColumnModified(CustomerGroupI18nTableMap::LOCALE)) $criteria->add(CustomerGroupI18nTableMap::LOCALE, $this->locale); if ($this->isColumnModified(CustomerGroupI18nTableMap::TITLE)) $criteria->add(CustomerGroupI18nTableMap::TITLE, $this->title); if ($this->isColumnModified(CustomerGroupI18nTableMap::DESCRIPTION)) $criteria->add(CustomerGroupI18nTableMap::DESCRIPTION, $this->description); return $criteria; }
php
public function buildCriteria() { $criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME); if ($this->isColumnModified(CustomerGroupI18nTableMap::ID)) $criteria->add(CustomerGroupI18nTableMap::ID, $this->id); if ($this->isColumnModified(CustomerGroupI18nTableMap::LOCALE)) $criteria->add(CustomerGroupI18nTableMap::LOCALE, $this->locale); if ($this->isColumnModified(CustomerGroupI18nTableMap::TITLE)) $criteria->add(CustomerGroupI18nTableMap::TITLE, $this->title); if ($this->isColumnModified(CustomerGroupI18nTableMap::DESCRIPTION)) $criteria->add(CustomerGroupI18nTableMap::DESCRIPTION, $this->description); return $criteria; }
[ "public", "function", "buildCriteria", "(", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", "CustomerGroupI18nTableMap", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "CustomerGroupI18nTableMap", "::", "ID", ")", ")", "$", "criteria", "->", "add", "(", "CustomerGroupI18nTableMap", "::", "ID", ",", "$", "this", "->", "id", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "CustomerGroupI18nTableMap", "::", "LOCALE", ")", ")", "$", "criteria", "->", "add", "(", "CustomerGroupI18nTableMap", "::", "LOCALE", ",", "$", "this", "->", "locale", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "CustomerGroupI18nTableMap", "::", "TITLE", ")", ")", "$", "criteria", "->", "add", "(", "CustomerGroupI18nTableMap", "::", "TITLE", ",", "$", "this", "->", "title", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "CustomerGroupI18nTableMap", "::", "DESCRIPTION", ")", ")", "$", "criteria", "->", "add", "(", "CustomerGroupI18nTableMap", "::", "DESCRIPTION", ",", "$", "this", "->", "description", ")", ";", "return", "$", "criteria", ";", "}" ]
Build a Criteria object containing the values of all modified columns in this object. @return Criteria The Criteria object containing all modified values.
[ "Build", "a", "Criteria", "object", "containing", "the", "values", "of", "all", "modified", "columns", "in", "this", "object", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L1004-L1014
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.setCustomerGroup
public function setCustomerGroup(ChildCustomerGroup $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aCustomerGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildCustomerGroup object, it will not be re-added. if ($v !== null) { $v->addCustomerGroupI18n($this); } return $this; }
php
public function setCustomerGroup(ChildCustomerGroup $v = null) { if ($v === null) { $this->setId(NULL); } else { $this->setId($v->getId()); } $this->aCustomerGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildCustomerGroup object, it will not be re-added. if ($v !== null) { $v->addCustomerGroupI18n($this); } return $this; }
[ "public", "function", "setCustomerGroup", "(", "ChildCustomerGroup", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aCustomerGroup", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the ChildCustomerGroup object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addCustomerGroupI18n", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a ChildCustomerGroup object. @param ChildCustomerGroup $v @return \CustomerGroup\Model\CustomerGroupI18n The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "ChildCustomerGroup", "object", "." ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L1120-L1138
thelia-modules/CustomerGroup
Model/Base/CustomerGroupI18n.php
CustomerGroupI18n.getCustomerGroup
public function getCustomerGroup(ConnectionInterface $con = null) { if ($this->aCustomerGroup === null && ($this->id !== null)) { $this->aCustomerGroup = ChildCustomerGroupQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aCustomerGroup->addCustomerGroupI18ns($this); */ } return $this->aCustomerGroup; }
php
public function getCustomerGroup(ConnectionInterface $con = null) { if ($this->aCustomerGroup === null && ($this->id !== null)) { $this->aCustomerGroup = ChildCustomerGroupQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aCustomerGroup->addCustomerGroupI18ns($this); */ } return $this->aCustomerGroup; }
[ "public", "function", "getCustomerGroup", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aCustomerGroup", "===", "null", "&&", "(", "$", "this", "->", "id", "!==", "null", ")", ")", "{", "$", "this", "->", "aCustomerGroup", "=", "ChildCustomerGroupQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "id", ",", "$", "con", ")", ";", "/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aCustomerGroup->addCustomerGroupI18ns($this);\n */", "}", "return", "$", "this", "->", "aCustomerGroup", ";", "}" ]
Get the associated ChildCustomerGroup object @param ConnectionInterface $con Optional Connection object. @return ChildCustomerGroup The associated ChildCustomerGroup object. @throws PropelException
[ "Get", "the", "associated", "ChildCustomerGroup", "object" ]
train
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L1148-L1162
99designs/ergo-http
src/Url.php
Url.getHostWithPort
public function getHostWithPort() { if ($this->hasPort() && (!$this->hasDefaultPort() || !$this->isPortDefault())) { return $this->getHost() . ':' . $this->getPort(); } else { return $this->getHost(); } }
php
public function getHostWithPort() { if ($this->hasPort() && (!$this->hasDefaultPort() || !$this->isPortDefault())) { return $this->getHost() . ':' . $this->getPort(); } else { return $this->getHost(); } }
[ "public", "function", "getHostWithPort", "(", ")", "{", "if", "(", "$", "this", "->", "hasPort", "(", ")", "&&", "(", "!", "$", "this", "->", "hasDefaultPort", "(", ")", "||", "!", "$", "this", "->", "isPortDefault", "(", ")", ")", ")", "{", "return", "$", "this", "->", "getHost", "(", ")", ".", "':'", ".", "$", "this", "->", "getPort", "(", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getHost", "(", ")", ";", "}", "}" ]
Host, including port unless it is the default port for the scheme. @return string
[ "Host", "including", "port", "unless", "it", "is", "the", "default", "port", "for", "the", "scheme", "." ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L89-L96
99designs/ergo-http
src/Url.php
Url.getDefaultPort
public function getDefaultPort() { if (!$this->hasDefaultPort()) throw new UrlException(sprintf( "No default port for URL '%s'", $this->_inputString )); $scheme = $this->getScheme(); if ($scheme == 'http') return 80; elseif ($scheme == 'https') return 443; else throw new UrlException("No default port for scheme '$scheme'"); }
php
public function getDefaultPort() { if (!$this->hasDefaultPort()) throw new UrlException(sprintf( "No default port for URL '%s'", $this->_inputString )); $scheme = $this->getScheme(); if ($scheme == 'http') return 80; elseif ($scheme == 'https') return 443; else throw new UrlException("No default port for scheme '$scheme'"); }
[ "public", "function", "getDefaultPort", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasDefaultPort", "(", ")", ")", "throw", "new", "UrlException", "(", "sprintf", "(", "\"No default port for URL '%s'\"", ",", "$", "this", "->", "_inputString", ")", ")", ";", "$", "scheme", "=", "$", "this", "->", "getScheme", "(", ")", ";", "if", "(", "$", "scheme", "==", "'http'", ")", "return", "80", ";", "elseif", "(", "$", "scheme", "==", "'https'", ")", "return", "443", ";", "else", "throw", "new", "UrlException", "(", "\"No default port for scheme '$scheme'\"", ")", ";", "}" ]
The default TCP port for the scheme of the URL @return int or null
[ "The", "default", "TCP", "port", "for", "the", "scheme", "of", "the", "URL" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L176-L187
99designs/ergo-http
src/Url.php
Url.getHostRelativeUrl
public function getHostRelativeUrl() { $url = $this->getPath(); if ($this->hasQueryString()) $url .= '?' . $this->getQueryString(); if ($this->hasFragmentString()) $url .= '#' . $this->getFragmentString(); return $url; }
php
public function getHostRelativeUrl() { $url = $this->getPath(); if ($this->hasQueryString()) $url .= '?' . $this->getQueryString(); if ($this->hasFragmentString()) $url .= '#' . $this->getFragmentString(); return $url; }
[ "public", "function", "getHostRelativeUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "$", "this", "->", "hasQueryString", "(", ")", ")", "$", "url", ".=", "'?'", ".", "$", "this", "->", "getQueryString", "(", ")", ";", "if", "(", "$", "this", "->", "hasFragmentString", "(", ")", ")", "$", "url", ".=", "'#'", ".", "$", "this", "->", "getFragmentString", "(", ")", ";", "return", "$", "url", ";", "}" ]
The URL components after the host. @return string
[ "The", "URL", "components", "after", "the", "host", "." ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L210-L216
99designs/ergo-http
src/Url.php
Url.getUrlForPath
public function getUrlForPath($path) { $fragments = parse_url($path); if (!isset($fragments['path'])) throw new UrlException("URL is not a valid path: '$path'"); $newUrl = clone $this; $newUrl->_fragments['path'] = $fragments['path']; // overwrite RHS components foreach (array('query', 'fragment') as $component) { if (isset($fragments[$component])) $newUrl->_fragments[$component] = $fragments[$component]; elseif (isset($newUrl->_fragments[$component])) unset($newUrl->_fragments[$component]); } // store the new URL internally $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
php
public function getUrlForPath($path) { $fragments = parse_url($path); if (!isset($fragments['path'])) throw new UrlException("URL is not a valid path: '$path'"); $newUrl = clone $this; $newUrl->_fragments['path'] = $fragments['path']; // overwrite RHS components foreach (array('query', 'fragment') as $component) { if (isset($fragments[$component])) $newUrl->_fragments[$component] = $fragments[$component]; elseif (isset($newUrl->_fragments[$component])) unset($newUrl->_fragments[$component]); } // store the new URL internally $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
[ "public", "function", "getUrlForPath", "(", "$", "path", ")", "{", "$", "fragments", "=", "parse_url", "(", "$", "path", ")", ";", "if", "(", "!", "isset", "(", "$", "fragments", "[", "'path'", "]", ")", ")", "throw", "new", "UrlException", "(", "\"URL is not a valid path: '$path'\"", ")", ";", "$", "newUrl", "=", "clone", "$", "this", ";", "$", "newUrl", "->", "_fragments", "[", "'path'", "]", "=", "$", "fragments", "[", "'path'", "]", ";", "// overwrite RHS components", "foreach", "(", "array", "(", "'query'", ",", "'fragment'", ")", "as", "$", "component", ")", "{", "if", "(", "isset", "(", "$", "fragments", "[", "$", "component", "]", ")", ")", "$", "newUrl", "->", "_fragments", "[", "$", "component", "]", "=", "$", "fragments", "[", "$", "component", "]", ";", "elseif", "(", "isset", "(", "$", "newUrl", "->", "_fragments", "[", "$", "component", "]", ")", ")", "unset", "(", "$", "newUrl", "->", "_fragments", "[", "$", "component", "]", ")", ";", "}", "// store the new URL internally", "$", "newUrl", "->", "_inputString", "=", "$", "newUrl", "->", "__toString", "(", ")", ";", "return", "$", "newUrl", ";", "}" ]
Builds a URL with a different path component @return Url
[ "Builds", "a", "URL", "with", "a", "different", "path", "component" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L235-L257
99designs/ergo-http
src/Url.php
Url.getUrlForHost
public function getUrlForHost($host) { $newUrl = clone $this; $newUrl->_fragments['host'] = $host; $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
php
public function getUrlForHost($host) { $newUrl = clone $this; $newUrl->_fragments['host'] = $host; $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
[ "public", "function", "getUrlForHost", "(", "$", "host", ")", "{", "$", "newUrl", "=", "clone", "$", "this", ";", "$", "newUrl", "->", "_fragments", "[", "'host'", "]", "=", "$", "host", ";", "$", "newUrl", "->", "_inputString", "=", "$", "newUrl", "->", "__toString", "(", ")", ";", "return", "$", "newUrl", ";", "}" ]
Builds a URL with a different host @return Url
[ "Builds", "a", "URL", "with", "a", "different", "host" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L263-L270
99designs/ergo-http
src/Url.php
Url.getUrlForScheme
public function getUrlForScheme($scheme) { $newUrl = clone $this; $wasDefaultPort = ($newUrl->hasScheme() && $newUrl->isPortDefault()); $newUrl->_fragments['scheme'] = $scheme; if ($wasDefaultPort) { $newUrl->_fragments['port'] = $newUrl->getDefaultPort(); } $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
php
public function getUrlForScheme($scheme) { $newUrl = clone $this; $wasDefaultPort = ($newUrl->hasScheme() && $newUrl->isPortDefault()); $newUrl->_fragments['scheme'] = $scheme; if ($wasDefaultPort) { $newUrl->_fragments['port'] = $newUrl->getDefaultPort(); } $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
[ "public", "function", "getUrlForScheme", "(", "$", "scheme", ")", "{", "$", "newUrl", "=", "clone", "$", "this", ";", "$", "wasDefaultPort", "=", "(", "$", "newUrl", "->", "hasScheme", "(", ")", "&&", "$", "newUrl", "->", "isPortDefault", "(", ")", ")", ";", "$", "newUrl", "->", "_fragments", "[", "'scheme'", "]", "=", "$", "scheme", ";", "if", "(", "$", "wasDefaultPort", ")", "{", "$", "newUrl", "->", "_fragments", "[", "'port'", "]", "=", "$", "newUrl", "->", "getDefaultPort", "(", ")", ";", "}", "$", "newUrl", "->", "_inputString", "=", "$", "newUrl", "->", "__toString", "(", ")", ";", "return", "$", "newUrl", ";", "}" ]
Builds a URL with a different scheme @return Url
[ "Builds", "a", "URL", "with", "a", "different", "scheme" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L276-L290
99designs/ergo-http
src/Url.php
Url.getUrlForFragment
public function getUrlForFragment($fragment) { $newUrl = clone $this; $newUrl->_fragments['fragment'] = $fragment; $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
php
public function getUrlForFragment($fragment) { $newUrl = clone $this; $newUrl->_fragments['fragment'] = $fragment; $newUrl->_inputString = $newUrl->__toString(); return $newUrl; }
[ "public", "function", "getUrlForFragment", "(", "$", "fragment", ")", "{", "$", "newUrl", "=", "clone", "$", "this", ";", "$", "newUrl", "->", "_fragments", "[", "'fragment'", "]", "=", "$", "fragment", ";", "$", "newUrl", "->", "_inputString", "=", "$", "newUrl", "->", "__toString", "(", ")", ";", "return", "$", "newUrl", ";", "}" ]
Builds a url with a different fragment (the part after # in the url) @param string @return Url
[ "Builds", "a", "url", "with", "a", "different", "fragment", "(", "the", "part", "after", "#", "in", "the", "url", ")" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L297-L303
99designs/ergo-http
src/Url.php
Url._joinPathComponents
private function _joinPathComponents($path) { $result = null; foreach (func_get_args() as $p) { $leading = substr($p, 0, 1); $trailing = substr($result, -1); if (!empty($p) && $leading != '/' && $leading != '?' && $trailing != '/') $result .= '/'; $result .= $p; } return $result; }
php
private function _joinPathComponents($path) { $result = null; foreach (func_get_args() as $p) { $leading = substr($p, 0, 1); $trailing = substr($result, -1); if (!empty($p) && $leading != '/' && $leading != '?' && $trailing != '/') $result .= '/'; $result .= $p; } return $result; }
[ "private", "function", "_joinPathComponents", "(", "$", "path", ")", "{", "$", "result", "=", "null", ";", "foreach", "(", "func_get_args", "(", ")", "as", "$", "p", ")", "{", "$", "leading", "=", "substr", "(", "$", "p", ",", "0", ",", "1", ")", ";", "$", "trailing", "=", "substr", "(", "$", "result", ",", "-", "1", ")", ";", "if", "(", "!", "empty", "(", "$", "p", ")", "&&", "$", "leading", "!=", "'/'", "&&", "$", "leading", "!=", "'?'", "&&", "$", "trailing", "!=", "'/'", ")", "$", "result", ".=", "'/'", ";", "$", "result", ".=", "$", "p", ";", "}", "return", "$", "result", ";", "}" ]
Join path/querystring/fragment components together
[ "Join", "path", "/", "querystring", "/", "fragment", "components", "together" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L308-L321
99designs/ergo-http
src/Url.php
Url.getUrlForRelativePath
public function getUrlForRelativePath($path) { return $this->getUrlForPath( $this->_joinPathComponents($this->getPath(), ltrim($path, '/'))); }
php
public function getUrlForRelativePath($path) { return $this->getUrlForPath( $this->_joinPathComponents($this->getPath(), ltrim($path, '/'))); }
[ "public", "function", "getUrlForRelativePath", "(", "$", "path", ")", "{", "return", "$", "this", "->", "getUrlForPath", "(", "$", "this", "->", "_joinPathComponents", "(", "$", "this", "->", "getPath", "(", ")", ",", "ltrim", "(", "$", "path", ",", "'/'", ")", ")", ")", ";", "}" ]
Builds a URL with a path component that is relative to the current one @return Url
[ "Builds", "a", "URL", "with", "a", "path", "component", "that", "is", "relative", "to", "the", "current", "one" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L327-L331
99designs/ergo-http
src/Url.php
Url.getUrlForMergedParameters
public function getUrlForMergedParameters($queryParameters) { if ($this->hasQueryString()) { $querystring = new QueryString($this->getQueryString()); $querystring->addParameters($queryParameters); $queryParameters = $querystring->toArray(); } return $this->getUrlForParameters($queryParameters); }
php
public function getUrlForMergedParameters($queryParameters) { if ($this->hasQueryString()) { $querystring = new QueryString($this->getQueryString()); $querystring->addParameters($queryParameters); $queryParameters = $querystring->toArray(); } return $this->getUrlForParameters($queryParameters); }
[ "public", "function", "getUrlForMergedParameters", "(", "$", "queryParameters", ")", "{", "if", "(", "$", "this", "->", "hasQueryString", "(", ")", ")", "{", "$", "querystring", "=", "new", "QueryString", "(", "$", "this", "->", "getQueryString", "(", ")", ")", ";", "$", "querystring", "->", "addParameters", "(", "$", "queryParameters", ")", ";", "$", "queryParameters", "=", "$", "querystring", "->", "toArray", "(", ")", ";", "}", "return", "$", "this", "->", "getUrlForParameters", "(", "$", "queryParameters", ")", ";", "}" ]
Builds a URL with added/merged query parameters @param array $queryParameters
[ "Builds", "a", "URL", "with", "added", "/", "merged", "query", "parameters" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L349-L358
DotZecker/Larafeed
src/Larafeed.php
Larafeed.setEntry
public function setEntry(Entry $entry) { $entry->format = $this->format; $entry->prepare(); $this->entries->add($entry); }
php
public function setEntry(Entry $entry) { $entry->format = $this->format; $entry->prepare(); $this->entries->add($entry); }
[ "public", "function", "setEntry", "(", "Entry", "$", "entry", ")", "{", "$", "entry", "->", "format", "=", "$", "this", "->", "format", ";", "$", "entry", "->", "prepare", "(", ")", ";", "$", "this", "->", "entries", "->", "add", "(", "$", "entry", ")", ";", "}" ]
Prepare and push the entry to the feed (if it's valid) @param Entry $entry @return void
[ "Prepare", "and", "push", "the", "entry", "to", "the", "feed", "(", "if", "it", "s", "valid", ")" ]
train
https://github.com/DotZecker/Larafeed/blob/d696e2f97b584ed690fe7ba4ac5d739e266c75dd/src/Larafeed.php#L82-L88
DotZecker/Larafeed
src/Larafeed.php
Larafeed.addAuthor
public function addAuthor($author) { if (!is_array($author)) { $author = ['name' => $author]; } $this->authors->add((object) $author); }
php
public function addAuthor($author) { if (!is_array($author)) { $author = ['name' => $author]; } $this->authors->add((object) $author); }
[ "public", "function", "addAuthor", "(", "$", "author", ")", "{", "if", "(", "!", "is_array", "(", "$", "author", ")", ")", "{", "$", "author", "=", "[", "'name'", "=>", "$", "author", "]", ";", "}", "$", "this", "->", "authors", "->", "add", "(", "(", "object", ")", "$", "author", ")", ";", "}" ]
Add an Author to the feed @param mixed $author It can be an array with name, email and uri, or just and string with the name.
[ "Add", "an", "Author", "to", "the", "feed" ]
train
https://github.com/DotZecker/Larafeed/blob/d696e2f97b584ed690fe7ba4ac5d739e266c75dd/src/Larafeed.php#L108-L115
DotZecker/Larafeed
src/Larafeed.php
Larafeed.render
public function render() { $this->prepare(); $view = $this->twig->render(sprintf('%s.twig.html', $this->format), ['feed' => $this]); return Response::create( $view, 200, [ 'Content-Type' => "{$this->getContentType()}; charset={$this->charset}", ] ); }
php
public function render() { $this->prepare(); $view = $this->twig->render(sprintf('%s.twig.html', $this->format), ['feed' => $this]); return Response::create( $view, 200, [ 'Content-Type' => "{$this->getContentType()}; charset={$this->charset}", ] ); }
[ "public", "function", "render", "(", ")", "{", "$", "this", "->", "prepare", "(", ")", ";", "$", "view", "=", "$", "this", "->", "twig", "->", "render", "(", "sprintf", "(", "'%s.twig.html'", ",", "$", "this", "->", "format", ")", ",", "[", "'feed'", "=>", "$", "this", "]", ")", ";", "return", "Response", "::", "create", "(", "$", "view", ",", "200", ",", "[", "'Content-Type'", "=>", "\"{$this->getContentType()}; charset={$this->charset}\"", ",", "]", ")", ";", "}" ]
Prepare the feed and if it's valid, renders it @return Response
[ "Prepare", "the", "feed", "and", "if", "it", "s", "valid", "renders", "it" ]
train
https://github.com/DotZecker/Larafeed/blob/d696e2f97b584ed690fe7ba4ac5d739e266c75dd/src/Larafeed.php#L122-L135
simbiosis-group/yii2-helper
actions/AutoCompleteAction.php
AutoCompleteAction.run
public function run() { $data = []; if ($this->term) { $data = $this->query->asArray()->all(); } Yii::$app->response->format = Response::FORMAT_JSON; return $data; }
php
public function run() { $data = []; if ($this->term) { $data = $this->query->asArray()->all(); } Yii::$app->response->format = Response::FORMAT_JSON; return $data; }
[ "public", "function", "run", "(", ")", "{", "$", "data", "=", "[", "]", ";", "if", "(", "$", "this", "->", "term", ")", "{", "$", "data", "=", "$", "this", "->", "query", "->", "asArray", "(", ")", "->", "all", "(", ")", ";", "}", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "return", "$", "data", ";", "}" ]
Runs the action @return string result content
[ "Runs", "the", "action" ]
train
https://github.com/simbiosis-group/yii2-helper/blob/c85c4204dd06b16e54210e75fe6deb51869d1dd9/actions/AutoCompleteAction.php#L38-L48
ronaldborla/chikka
src/Borla/Chikka/Models/Mobile.php
Mobile.format
public function format($format) { // C = Country Code // c = Carrier code // n = Number return str_replace( ['C', 'c', 'n', 'l'], [$this->country->code, $this->carrier->code, $this->number, $this->getLocalCode()], $format); }
php
public function format($format) { // C = Country Code // c = Carrier code // n = Number return str_replace( ['C', 'c', 'n', 'l'], [$this->country->code, $this->carrier->code, $this->number, $this->getLocalCode()], $format); }
[ "public", "function", "format", "(", "$", "format", ")", "{", "// C = Country Code", "// c = Carrier code", "// n = Number", "return", "str_replace", "(", "[", "'C'", ",", "'c'", ",", "'n'", ",", "'l'", "]", ",", "[", "$", "this", "->", "country", "->", "code", ",", "$", "this", "->", "carrier", "->", "code", ",", "$", "this", "->", "number", ",", "$", "this", "->", "getLocalCode", "(", ")", "]", ",", "$", "format", ")", ";", "}" ]
Format number
[ "Format", "number" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Mobile.php#L66-L74
expectation-php/expect
src/configurator/FileConfigurator.php
FileConfigurator.configure
public function configure() { $registry = new DefaultMatcherRegistry(); $packages = $this->config->getMatcherRegistrars(); foreach ($packages as $package) { $package->registerTo($registry); } $dictionary = $registry->toDictionary(); $matcherFactory = new DefaultMatcherFactory($dictionary); $resultReporter = $this->config->getResultReporter(); return new DefaultContextFactory($matcherFactory, $resultReporter); }
php
public function configure() { $registry = new DefaultMatcherRegistry(); $packages = $this->config->getMatcherRegistrars(); foreach ($packages as $package) { $package->registerTo($registry); } $dictionary = $registry->toDictionary(); $matcherFactory = new DefaultMatcherFactory($dictionary); $resultReporter = $this->config->getResultReporter(); return new DefaultContextFactory($matcherFactory, $resultReporter); }
[ "public", "function", "configure", "(", ")", "{", "$", "registry", "=", "new", "DefaultMatcherRegistry", "(", ")", ";", "$", "packages", "=", "$", "this", "->", "config", "->", "getMatcherRegistrars", "(", ")", ";", "foreach", "(", "$", "packages", "as", "$", "package", ")", "{", "$", "package", "->", "registerTo", "(", "$", "registry", ")", ";", "}", "$", "dictionary", "=", "$", "registry", "->", "toDictionary", "(", ")", ";", "$", "matcherFactory", "=", "new", "DefaultMatcherFactory", "(", "$", "dictionary", ")", ";", "$", "resultReporter", "=", "$", "this", "->", "config", "->", "getResultReporter", "(", ")", ";", "return", "new", "DefaultContextFactory", "(", "$", "matcherFactory", ",", "$", "resultReporter", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/configurator/FileConfigurator.php#L48-L63
Eresus/EresusCMS
src/core/classes/helpers/PaginationHelper.php
PaginationHelper.rewind
public function rewind() { $this->items = array(); $this->prepareUrlTemplate(); /* * Если страниц больше чем задано показывать за один раз, то будем показывать только часть * страниц, наиболее близких к текущей. */ if ($this->total > $this->size) { // Начинаем показ с текущей, минус половину видимых $first = (int) floor($this->current - $this->size / 2); if ($first < 1) { // Страниц меньше 1-й не существует $first = 1; } $last = $first + $this->size - 1; if ($last > $this->total) { // Но если это больше чем страниц всего, вносим исправления $last = $this->total; $first = $last - $this->size + 1; } } else { $first = 1; $last = $this->total; } if ($first > 1) { $pageNumber = $this->current - $this->size; if ($pageNumber < 1) { $pageNumber = 1; } $this->items []= $this->itemFactory($pageNumber, '&larr;'); } for ($pageNumber = $first; $pageNumber <= $last; $pageNumber++) { $item = $this->itemFactory($pageNumber); $item['current'] = $pageNumber == $this->current; $this->items []= $item; } if ($last < $this->total) { $pageNumber = $this->current + $this->size; if ($pageNumber > $this->total) { $pageNumber = $this->total; } $this->items []= $this->itemFactory($pageNumber, '&rarr;'); } $this->iteration = 1; }
php
public function rewind() { $this->items = array(); $this->prepareUrlTemplate(); /* * Если страниц больше чем задано показывать за один раз, то будем показывать только часть * страниц, наиболее близких к текущей. */ if ($this->total > $this->size) { // Начинаем показ с текущей, минус половину видимых $first = (int) floor($this->current - $this->size / 2); if ($first < 1) { // Страниц меньше 1-й не существует $first = 1; } $last = $first + $this->size - 1; if ($last > $this->total) { // Но если это больше чем страниц всего, вносим исправления $last = $this->total; $first = $last - $this->size + 1; } } else { $first = 1; $last = $this->total; } if ($first > 1) { $pageNumber = $this->current - $this->size; if ($pageNumber < 1) { $pageNumber = 1; } $this->items []= $this->itemFactory($pageNumber, '&larr;'); } for ($pageNumber = $first; $pageNumber <= $last; $pageNumber++) { $item = $this->itemFactory($pageNumber); $item['current'] = $pageNumber == $this->current; $this->items []= $item; } if ($last < $this->total) { $pageNumber = $this->current + $this->size; if ($pageNumber > $this->total) { $pageNumber = $this->total; } $this->items []= $this->itemFactory($pageNumber, '&rarr;'); } $this->iteration = 1; }
[ "public", "function", "rewind", "(", ")", "{", "$", "this", "->", "items", "=", "array", "(", ")", ";", "$", "this", "->", "prepareUrlTemplate", "(", ")", ";", "/*\n * Если страниц больше чем задано показывать за один раз, то будем показывать только часть\n * страниц, наиболее близких к текущей.\n */", "if", "(", "$", "this", "->", "total", ">", "$", "this", "->", "size", ")", "{", "// Начинаем показ с текущей, минус половину видимых", "$", "first", "=", "(", "int", ")", "floor", "(", "$", "this", "->", "current", "-", "$", "this", "->", "size", "/", "2", ")", ";", "if", "(", "$", "first", "<", "1", ")", "{", "// Страниц меньше 1-й не существует", "$", "first", "=", "1", ";", "}", "$", "last", "=", "$", "first", "+", "$", "this", "->", "size", "-", "1", ";", "if", "(", "$", "last", ">", "$", "this", "->", "total", ")", "{", "// Но если это больше чем страниц всего, вносим исправления", "$", "last", "=", "$", "this", "->", "total", ";", "$", "first", "=", "$", "last", "-", "$", "this", "->", "size", "+", "1", ";", "}", "}", "else", "{", "$", "first", "=", "1", ";", "$", "last", "=", "$", "this", "->", "total", ";", "}", "if", "(", "$", "first", ">", "1", ")", "{", "$", "pageNumber", "=", "$", "this", "->", "current", "-", "$", "this", "->", "size", ";", "if", "(", "$", "pageNumber", "<", "1", ")", "{", "$", "pageNumber", "=", "1", ";", "}", "$", "this", "->", "items", "[", "]", "=", "$", "this", "->", "itemFactory", "(", "$", "pageNumber", ",", "'&larr;'", ")", ";", "}", "for", "(", "$", "pageNumber", "=", "$", "first", ";", "$", "pageNumber", "<=", "$", "last", ";", "$", "pageNumber", "++", ")", "{", "$", "item", "=", "$", "this", "->", "itemFactory", "(", "$", "pageNumber", ")", ";", "$", "item", "[", "'current'", "]", "=", "$", "pageNumber", "==", "$", "this", "->", "current", ";", "$", "this", "->", "items", "[", "]", "=", "$", "item", ";", "}", "if", "(", "$", "last", "<", "$", "this", "->", "total", ")", "{", "$", "pageNumber", "=", "$", "this", "->", "current", "+", "$", "this", "->", "size", ";", "if", "(", "$", "pageNumber", ">", "$", "this", "->", "total", ")", "{", "$", "pageNumber", "=", "$", "this", "->", "total", ";", "}", "$", "this", "->", "items", "[", "]", "=", "$", "this", "->", "itemFactory", "(", "$", "pageNumber", ",", "'&rarr;'", ")", ";", "}", "$", "this", "->", "iteration", "=", "1", ";", "}" ]
Подготовливает объект к первой итерации @return void @since 2.14 @see Iterator::rewind() @internal
[ "Подготовливает", "объект", "к", "первой", "итерации" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/helpers/PaginationHelper.php#L313-L376
Eresus/EresusCMS
src/core/classes/helpers/PaginationHelper.php
PaginationHelper.render
public function render() { $tmpl = new Eresus_Template($this->getTemplate()); $data = array('pagination' => $this); return $tmpl->compile($data); }
php
public function render() { $tmpl = new Eresus_Template($this->getTemplate()); $data = array('pagination' => $this); return $tmpl->compile($data); }
[ "public", "function", "render", "(", ")", "{", "$", "tmpl", "=", "new", "Eresus_Template", "(", "$", "this", "->", "getTemplate", "(", ")", ")", ";", "$", "data", "=", "array", "(", "'pagination'", "=>", "$", "this", ")", ";", "return", "$", "tmpl", "->", "compile", "(", "$", "data", ")", ";", "}" ]
Создаёт разметку переключателя страниц @return string HTML @since 2.14
[ "Создаёт", "разметку", "переключателя", "страниц" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/helpers/PaginationHelper.php#L416-L423
Eresus/EresusCMS
src/core/classes/helpers/PaginationHelper.php
PaginationHelper.itemFactory
private function itemFactory($pageNumber, $title = null) { return array( 'url' => sprintf($this->urlTemplate, $pageNumber), 'title' => $title ? $title : $pageNumber, 'current' => false ); }
php
private function itemFactory($pageNumber, $title = null) { return array( 'url' => sprintf($this->urlTemplate, $pageNumber), 'title' => $title ? $title : $pageNumber, 'current' => false ); }
[ "private", "function", "itemFactory", "(", "$", "pageNumber", ",", "$", "title", "=", "null", ")", "{", "return", "array", "(", "'url'", "=>", "sprintf", "(", "$", "this", "->", "urlTemplate", ",", "$", "pageNumber", ")", ",", "'title'", "=>", "$", "title", "?", "$", "title", ":", "$", "pageNumber", ",", "'current'", "=>", "false", ")", ";", "}" ]
Создаёт элемент нумерации @param int $pageNumber Номер страницы @param string $title[optional] Название страницы @return array @since 2.14
[ "Создаёт", "элемент", "нумерации" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/classes/helpers/PaginationHelper.php#L451-L458
surebert/surebert-framework
src/sb/Excel/Writer.php
Writer.setCell
public function setCell($cell, $value, $type = "auto") { if ($type == "auto") { $type = \gettype($value); } if (\is_array($cell)) { $parts["row"] = $cell[0]; $parts["col"] = $cell[1]; } else { $parts = $this->refToArray($cell); } if (!\is_array($parts)) { \trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR); return false; } $row = $parts["row"]; $col = $parts["col"]; switch ($type) { case "string" : /** * @todo it would be nice if we were able to keep that * characters UTF-8 or unicode */ $value = \mb_convert_encoding($value, "Windows-1252", "UTF-8"); $length = \mb_strlen($value, "Windows-1252"); if ($length > 255) { \trigger_error("String '$value' is too long. " ."Please keep to a max of 255 characters.", E_USER_ERROR); return false; } $this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length); $this->contents .= $value; break; case "integer" : $this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00); $this->contents .= \pack("d", $value); break; } return true; }
php
public function setCell($cell, $value, $type = "auto") { if ($type == "auto") { $type = \gettype($value); } if (\is_array($cell)) { $parts["row"] = $cell[0]; $parts["col"] = $cell[1]; } else { $parts = $this->refToArray($cell); } if (!\is_array($parts)) { \trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR); return false; } $row = $parts["row"]; $col = $parts["col"]; switch ($type) { case "string" : /** * @todo it would be nice if we were able to keep that * characters UTF-8 or unicode */ $value = \mb_convert_encoding($value, "Windows-1252", "UTF-8"); $length = \mb_strlen($value, "Windows-1252"); if ($length > 255) { \trigger_error("String '$value' is too long. " ."Please keep to a max of 255 characters.", E_USER_ERROR); return false; } $this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length); $this->contents .= $value; break; case "integer" : $this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00); $this->contents .= \pack("d", $value); break; } return true; }
[ "public", "function", "setCell", "(", "$", "cell", ",", "$", "value", ",", "$", "type", "=", "\"auto\"", ")", "{", "if", "(", "$", "type", "==", "\"auto\"", ")", "{", "$", "type", "=", "\\", "gettype", "(", "$", "value", ")", ";", "}", "if", "(", "\\", "is_array", "(", "$", "cell", ")", ")", "{", "$", "parts", "[", "\"row\"", "]", "=", "$", "cell", "[", "0", "]", ";", "$", "parts", "[", "\"col\"", "]", "=", "$", "cell", "[", "1", "]", ";", "}", "else", "{", "$", "parts", "=", "$", "this", "->", "refToArray", "(", "$", "cell", ")", ";", "}", "if", "(", "!", "\\", "is_array", "(", "$", "parts", ")", ")", "{", "\\", "trigger_error", "(", "\"Cell reference should be in the format A1 or array(0,0).\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "$", "row", "=", "$", "parts", "[", "\"row\"", "]", ";", "$", "col", "=", "$", "parts", "[", "\"col\"", "]", ";", "switch", "(", "$", "type", ")", "{", "case", "\"string\"", ":", "/**\n * @todo it would be nice if we were able to keep that\n * characters UTF-8 or unicode\n */", "$", "value", "=", "\\", "mb_convert_encoding", "(", "$", "value", ",", "\"Windows-1252\"", ",", "\"UTF-8\"", ")", ";", "$", "length", "=", "\\", "mb_strlen", "(", "$", "value", ",", "\"Windows-1252\"", ")", ";", "if", "(", "$", "length", ">", "255", ")", "{", "\\", "trigger_error", "(", "\"String '$value' is too long. \"", ".", "\"Please keep to a max of 255 characters.\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "$", "this", "->", "contents", ".=", "\\", "pack", "(", "\"s*\"", ",", "0x0204", ",", "8", "+", "$", "length", ",", "$", "row", ",", "$", "col", ",", "0x00", ",", "$", "length", ")", ";", "$", "this", "->", "contents", ".=", "$", "value", ";", "break", ";", "case", "\"integer\"", ":", "$", "this", "->", "contents", ".=", "\\", "pack", "(", "\"s*\"", ",", "0x0203", ",", "14", ",", "$", "row", ",", "$", "col", ",", "0x00", ")", ";", "$", "this", "->", "contents", ".=", "\\", "pack", "(", "\"d\"", ",", "$", "value", ")", ";", "break", ";", "}", "return", "true", ";", "}" ]
Set the value of an individual cell @param mixed An excel cell reference such as A1, or an array in the format of ($row, $col) usign zero-based integers @param mixed the value to put in this cell @param the type of value (string|integer). Autodetects by default @return boolean Success
[ "Set", "the", "value", "of", "an", "individual", "cell" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L60-L111
surebert/surebert-framework
src/sb/Excel/Writer.php
Writer.setRow
public function setRow($row, $values) { if (!\is_array($values)) { \trigger_error("Values must be an array.", E_USER_ERROR); return false; } if (intval($row) < 1) { \trigger_error("Row number must be an integer greater than 1.", E_USER_ERROR); return false; } $i = 0; foreach ($values as $value) { $this->setCell(array($row - 1, $i), $value); $i++; } return true; }
php
public function setRow($row, $values) { if (!\is_array($values)) { \trigger_error("Values must be an array.", E_USER_ERROR); return false; } if (intval($row) < 1) { \trigger_error("Row number must be an integer greater than 1.", E_USER_ERROR); return false; } $i = 0; foreach ($values as $value) { $this->setCell(array($row - 1, $i), $value); $i++; } return true; }
[ "public", "function", "setRow", "(", "$", "row", ",", "$", "values", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "values", ")", ")", "{", "\\", "trigger_error", "(", "\"Values must be an array.\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "intval", "(", "$", "row", ")", "<", "1", ")", "{", "\\", "trigger_error", "(", "\"Row number must be an integer greater than 1.\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "$", "i", "=", "0", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "this", "->", "setCell", "(", "array", "(", "$", "row", "-", "1", ",", "$", "i", ")", ",", "$", "value", ")", ";", "$", "i", "++", ";", "}", "return", "true", ";", "}" ]
Set the values for a row @param integer The Excel row number to place these values @param array An array of values @return boolean Success
[ "Set", "the", "values", "for", "a", "row" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L120-L139
surebert/surebert-framework
src/sb/Excel/Writer.php
Writer.setColumn
public function setColumn($col, $values) { if (!\is_array($values)) { \trigger_error("Values must be an array.", E_USER_ERROR); return false; } if (\is_numeric($col)) { \trigger_error("Column must be a letter, eg column D.", E_USER_ERROR); return false; } //todo check array $i = 0; foreach ($values as $value) { $this->setCell($col . ($i + 1), $value); $i++; } return true; }
php
public function setColumn($col, $values) { if (!\is_array($values)) { \trigger_error("Values must be an array.", E_USER_ERROR); return false; } if (\is_numeric($col)) { \trigger_error("Column must be a letter, eg column D.", E_USER_ERROR); return false; } //todo check array $i = 0; foreach ($values as $value) { $this->setCell($col . ($i + 1), $value); $i++; } return true; }
[ "public", "function", "setColumn", "(", "$", "col", ",", "$", "values", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "values", ")", ")", "{", "\\", "trigger_error", "(", "\"Values must be an array.\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "\\", "is_numeric", "(", "$", "col", ")", ")", "{", "\\", "trigger_error", "(", "\"Column must be a letter, eg column D.\"", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "//todo check array", "$", "i", "=", "0", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "this", "->", "setCell", "(", "$", "col", ".", "(", "$", "i", "+", "1", ")", ",", "$", "value", ")", ";", "$", "i", "++", ";", "}", "return", "true", ";", "}" ]
undocumented function @param string The Excel column letter @param array An array of values @return Success
[ "undocumented", "function" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L148-L167
surebert/surebert-framework
src/sb/Excel/Writer.php
Writer.outputWithHeaders
public function outputWithHeaders($filename = 'output.xls') { \header("Expires: " . date("r", 0)); \header("Last-Modified: " . gmdate("r") . " GMT"); \header("Content-Type: application/x-msexcel"); \header("Content-Disposition: attachment; filename=" . $filename); echo $this->__toString(); }
php
public function outputWithHeaders($filename = 'output.xls') { \header("Expires: " . date("r", 0)); \header("Last-Modified: " . gmdate("r") . " GMT"); \header("Content-Type: application/x-msexcel"); \header("Content-Disposition: attachment; filename=" . $filename); echo $this->__toString(); }
[ "public", "function", "outputWithHeaders", "(", "$", "filename", "=", "'output.xls'", ")", "{", "\\", "header", "(", "\"Expires: \"", ".", "date", "(", "\"r\"", ",", "0", ")", ")", ";", "\\", "header", "(", "\"Last-Modified: \"", ".", "gmdate", "(", "\"r\"", ")", ".", "\" GMT\"", ")", ";", "\\", "header", "(", "\"Content-Type: application/x-msexcel\"", ")", ";", "\\", "header", "(", "\"Content-Disposition: attachment; filename=\"", ".", "$", "filename", ")", ";", "echo", "$", "this", "->", "__toString", "(", ")", ";", "}" ]
Stream this file over HTTP @return void
[ "Stream", "this", "file", "over", "HTTP" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L174-L181
surebert/surebert-framework
src/sb/Excel/Writer.php
Writer.refToArray
protected function refToArray($ref) { $offset = 64; $len = strlen($ref); $div = 0; for ($i = 0; $i < $len; $i++) { $char = substr($ref, $i, 1); if (is_numeric($char)) { $div = $i; break; } } if ($div < 1) { return false; } $row = substr($ref, $div); $place_col = 0; $col = 0; for ($i = $div - 1; $i >= 0; $i--) { $place_weight = pow(26, $place_col); $place_value = ord(substr($ref, $i, 1)) - $offset; $col += $place_value * $place_weight; $place_col++; } //return as 0 based return array("row" => $row - 1, "col" => $col - 1); }
php
protected function refToArray($ref) { $offset = 64; $len = strlen($ref); $div = 0; for ($i = 0; $i < $len; $i++) { $char = substr($ref, $i, 1); if (is_numeric($char)) { $div = $i; break; } } if ($div < 1) { return false; } $row = substr($ref, $div); $place_col = 0; $col = 0; for ($i = $div - 1; $i >= 0; $i--) { $place_weight = pow(26, $place_col); $place_value = ord(substr($ref, $i, 1)) - $offset; $col += $place_value * $place_weight; $place_col++; } //return as 0 based return array("row" => $row - 1, "col" => $col - 1); }
[ "protected", "function", "refToArray", "(", "$", "ref", ")", "{", "$", "offset", "=", "64", ";", "$", "len", "=", "strlen", "(", "$", "ref", ")", ";", "$", "div", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "$", "i", "++", ")", "{", "$", "char", "=", "substr", "(", "$", "ref", ",", "$", "i", ",", "1", ")", ";", "if", "(", "is_numeric", "(", "$", "char", ")", ")", "{", "$", "div", "=", "$", "i", ";", "break", ";", "}", "}", "if", "(", "$", "div", "<", "1", ")", "{", "return", "false", ";", "}", "$", "row", "=", "substr", "(", "$", "ref", ",", "$", "div", ")", ";", "$", "place_col", "=", "0", ";", "$", "col", "=", "0", ";", "for", "(", "$", "i", "=", "$", "div", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "place_weight", "=", "pow", "(", "26", ",", "$", "place_col", ")", ";", "$", "place_value", "=", "ord", "(", "substr", "(", "$", "ref", ",", "$", "i", ",", "1", ")", ")", "-", "$", "offset", ";", "$", "col", "+=", "$", "place_value", "*", "$", "place_weight", ";", "$", "place_col", "++", ";", "}", "//return as 0 based", "return", "array", "(", "\"row\"", "=>", "$", "row", "-", "1", ",", "\"col\"", "=>", "$", "col", "-", "1", ")", ";", "}" ]
Convert a Excel Cell Reference to an array of component integers -- A5 becomes (6, 0); @param string An Excel cell reference such as A1, B7 @return array An associative array of row/column integers
[ "Convert", "a", "Excel", "Cell", "Reference", "to", "an", "array", "of", "component", "integers", "--", "A5", "becomes", "(", "6", "0", ")", ";" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L212-L243
romainbessugesmeusy/php-datagrid
library/RBM/Datagrid/Data/Processor/ArrayProcessor.php
ArrayProcessor._sort
protected function _sort() { if (!isset($this->_sorts) || count($this->_sorts) === 0) { return; } $columns = $this->_dataGrid->getActiveColumnsOrdered(); $sorts = $this->_sorts; $sortPosition = $this->_sortPositions; usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) { foreach ($sortPosition as $colIndex) { $sort = $sorts[$colIndex]; /** @var $sort\RBM\Datagrid\Data\Sort */ /** @var $column\RBM\Datagrid\Column */ $column = $columns[$colIndex]; $valueA = $column->getSortData($a); $valueB = $column->getSortData($b); if ($valueA == $valueB) { continue; } $arr = array($valueA, $valueB); $args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType())); call_user_func_array('array_multisort', $args); return ($arr[0] == $valueA) ? -1 : 1; } return 0; }); }
php
protected function _sort() { if (!isset($this->_sorts) || count($this->_sorts) === 0) { return; } $columns = $this->_dataGrid->getActiveColumnsOrdered(); $sorts = $this->_sorts; $sortPosition = $this->_sortPositions; usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) { foreach ($sortPosition as $colIndex) { $sort = $sorts[$colIndex]; /** @var $sort\RBM\Datagrid\Data\Sort */ /** @var $column\RBM\Datagrid\Column */ $column = $columns[$colIndex]; $valueA = $column->getSortData($a); $valueB = $column->getSortData($b); if ($valueA == $valueB) { continue; } $arr = array($valueA, $valueB); $args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType())); call_user_func_array('array_multisort', $args); return ($arr[0] == $valueA) ? -1 : 1; } return 0; }); }
[ "protected", "function", "_sort", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_sorts", ")", "||", "count", "(", "$", "this", "->", "_sorts", ")", "===", "0", ")", "{", "return", ";", "}", "$", "columns", "=", "$", "this", "->", "_dataGrid", "->", "getActiveColumnsOrdered", "(", ")", ";", "$", "sorts", "=", "$", "this", "->", "_sorts", ";", "$", "sortPosition", "=", "$", "this", "->", "_sortPositions", ";", "usort", "(", "$", "this", "->", "_output", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "columns", ",", "$", "sortPosition", ",", "$", "sorts", ")", "{", "foreach", "(", "$", "sortPosition", "as", "$", "colIndex", ")", "{", "$", "sort", "=", "$", "sorts", "[", "$", "colIndex", "]", ";", "/** @var $sort\\RBM\\Datagrid\\Data\\Sort */", "/** @var $column\\RBM\\Datagrid\\Column */", "$", "column", "=", "$", "columns", "[", "$", "colIndex", "]", ";", "$", "valueA", "=", "$", "column", "->", "getSortData", "(", "$", "a", ")", ";", "$", "valueB", "=", "$", "column", "->", "getSortData", "(", "$", "b", ")", ";", "if", "(", "$", "valueA", "==", "$", "valueB", ")", "{", "continue", ";", "}", "$", "arr", "=", "array", "(", "$", "valueA", ",", "$", "valueB", ")", ";", "$", "args", "=", "array_merge", "(", "array", "(", "&", "$", "arr", ")", ",", "array", "(", "$", "sort", "->", "getDirection", "(", ")", ",", "$", "sort", "->", "getType", "(", ")", ")", ")", ";", "call_user_func_array", "(", "'array_multisort'", ",", "$", "args", ")", ";", "return", "(", "$", "arr", "[", "0", "]", "==", "$", "valueA", ")", "?", "-", "1", ":", "1", ";", "}", "return", "0", ";", "}", ")", ";", "}" ]
Performs an array_multisort, based on the sorts defined
[ "Performs", "an", "array_multisort", "based", "on", "the", "sorts", "defined" ]
train
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ArrayProcessor.php#L72-L104
romainbessugesmeusy/php-datagrid
library/RBM/Datagrid/Data/Processor/ArrayProcessor.php
ArrayProcessor._truncate
protected function _truncate() { if (!$this->getLimit()->isNull()) { if (is_null($this->getLimit()->getCount())) { $this->_output = array_splice($this->_output, $this->getLimit()->getStart()); } else { $this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount()); } } }
php
protected function _truncate() { if (!$this->getLimit()->isNull()) { if (is_null($this->getLimit()->getCount())) { $this->_output = array_splice($this->_output, $this->getLimit()->getStart()); } else { $this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount()); } } }
[ "protected", "function", "_truncate", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getLimit", "(", ")", "->", "isNull", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "getLimit", "(", ")", "->", "getCount", "(", ")", ")", ")", "{", "$", "this", "->", "_output", "=", "array_splice", "(", "$", "this", "->", "_output", ",", "$", "this", "->", "getLimit", "(", ")", "->", "getStart", "(", ")", ")", ";", "}", "else", "{", "$", "this", "->", "_output", "=", "array_splice", "(", "$", "this", "->", "_output", ",", "$", "this", "->", "getLimit", "(", ")", "->", "getStart", "(", ")", ",", "$", "this", "->", "getLimit", "(", ")", "->", "getCount", "(", ")", ")", ";", "}", "}", "}" ]
Simply splice the array
[ "Simply", "splice", "the", "array" ]
train
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ArrayProcessor.php#L109-L118
gdbots/iam-php
src/RevokeRolesFromAppHandler.php
RevokeRolesFromAppHandler.createAppRolesRevoked
protected function createAppRolesRevoked(RevokeRolesFromApp $command, Pbjx $pbjx): AppRolesRevoked { /** @var AppRolesRevoked $event */ $event = AppRolesRevokedV1Mixin::findOne()->createMessage(); return $event; }
php
protected function createAppRolesRevoked(RevokeRolesFromApp $command, Pbjx $pbjx): AppRolesRevoked { /** @var AppRolesRevoked $event */ $event = AppRolesRevokedV1Mixin::findOne()->createMessage(); return $event; }
[ "protected", "function", "createAppRolesRevoked", "(", "RevokeRolesFromApp", "$", "command", ",", "Pbjx", "$", "pbjx", ")", ":", "AppRolesRevoked", "{", "/** @var AppRolesRevoked $event */", "$", "event", "=", "AppRolesRevokedV1Mixin", "::", "findOne", "(", ")", "->", "createMessage", "(", ")", ";", "return", "$", "event", ";", "}" ]
@param RevokeRolesFromApp $command @param Pbjx $pbjx @return AppRolesRevoked
[ "@param", "RevokeRolesFromApp", "$command", "@param", "Pbjx", "$pbjx" ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/RevokeRolesFromAppHandler.php#L68-L73
ekuiter/feature-php
FeaturePhp/Model/ConstraintSolver.php
ConstraintSolver.mandatory
private static function mandatory($feature) { if ($feature->getParent() && $feature->getMandatory()) return Logic::equiv(Logic::is($feature), Logic::is($feature->getParent())); }
php
private static function mandatory($feature) { if ($feature->getParent() && $feature->getMandatory()) return Logic::equiv(Logic::is($feature), Logic::is($feature->getParent())); }
[ "private", "static", "function", "mandatory", "(", "$", "feature", ")", "{", "if", "(", "$", "feature", "->", "getParent", "(", ")", "&&", "$", "feature", "->", "getMandatory", "(", ")", ")", "return", "Logic", "::", "equiv", "(", "Logic", "::", "is", "(", "$", "feature", ")", ",", "Logic", "::", "is", "(", "$", "feature", "->", "getParent", "(", ")", ")", ")", ";", "}" ]
Semantics for a mandatory feature. A mandatory feature is selected iff its parent is selected. @param Feature $feature @return callable
[ "Semantics", "for", "a", "mandatory", "feature", ".", "A", "mandatory", "feature", "is", "selected", "iff", "its", "parent", "is", "selected", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L117-L120
ekuiter/feature-php
FeaturePhp/Model/ConstraintSolver.php
ConstraintSolver.optional
private static function optional($feature) { if ($feature->getParent()) return Logic::implies(Logic::is($feature), Logic::is($feature->getParent())); }
php
private static function optional($feature) { if ($feature->getParent()) return Logic::implies(Logic::is($feature), Logic::is($feature->getParent())); }
[ "private", "static", "function", "optional", "(", "$", "feature", ")", "{", "if", "(", "$", "feature", "->", "getParent", "(", ")", ")", "return", "Logic", "::", "implies", "(", "Logic", "::", "is", "(", "$", "feature", ")", ",", "Logic", "::", "is", "(", "$", "feature", "->", "getParent", "(", ")", ")", ")", ";", "}" ]
Semantics for an optional feature. If an optional feature is selected, its parent is selected. @param Feature $feature @return callable
[ "Semantics", "for", "an", "optional", "feature", ".", "If", "an", "optional", "feature", "is", "selected", "its", "parent", "is", "selected", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L128-L131
ekuiter/feature-php
FeaturePhp/Model/ConstraintSolver.php
ConstraintSolver.alternative
private static function alternative($feature) { if ($feature->getAlternative()) { $children = array(); foreach ($feature->getChildren() as $child) $children[] = Logic::is($child); $alternativeConstraints = array(); for ($i = 0; $i < count($children); $i++) for ($j = 0; $j < $i; $j++) $alternativeConstraints[] = Logic::not(Logic::_and($children[$i], $children[$j])); return Logic::_and(Logic::equiv(Logic::is($feature), call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)), call_user_func_array("\FeaturePhp\Helper\Logic::_and", $alternativeConstraints)); } }
php
private static function alternative($feature) { if ($feature->getAlternative()) { $children = array(); foreach ($feature->getChildren() as $child) $children[] = Logic::is($child); $alternativeConstraints = array(); for ($i = 0; $i < count($children); $i++) for ($j = 0; $j < $i; $j++) $alternativeConstraints[] = Logic::not(Logic::_and($children[$i], $children[$j])); return Logic::_and(Logic::equiv(Logic::is($feature), call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)), call_user_func_array("\FeaturePhp\Helper\Logic::_and", $alternativeConstraints)); } }
[ "private", "static", "function", "alternative", "(", "$", "feature", ")", "{", "if", "(", "$", "feature", "->", "getAlternative", "(", ")", ")", "{", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "feature", "->", "getChildren", "(", ")", "as", "$", "child", ")", "$", "children", "[", "]", "=", "Logic", "::", "is", "(", "$", "child", ")", ";", "$", "alternativeConstraints", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "children", ")", ";", "$", "i", "++", ")", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "i", ";", "$", "j", "++", ")", "$", "alternativeConstraints", "[", "]", "=", "Logic", "::", "not", "(", "Logic", "::", "_and", "(", "$", "children", "[", "$", "i", "]", ",", "$", "children", "[", "$", "j", "]", ")", ")", ";", "return", "Logic", "::", "_and", "(", "Logic", "::", "equiv", "(", "Logic", "::", "is", "(", "$", "feature", ")", ",", "call_user_func_array", "(", "\"\\FeaturePhp\\Helper\\Logic::_or\"", ",", "$", "children", ")", ")", ",", "call_user_func_array", "(", "\"\\FeaturePhp\\Helper\\Logic::_and\"", ",", "$", "alternativeConstraints", ")", ")", ";", "}", "}" ]
Semantics for a feature that provides an alternative choice. Exactly one child of such a feature is selected. @param Feature $feature @return callable
[ "Semantics", "for", "a", "feature", "that", "provides", "an", "alternative", "choice", ".", "Exactly", "one", "child", "of", "such", "a", "feature", "is", "selected", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L139-L154
ekuiter/feature-php
FeaturePhp/Model/ConstraintSolver.php
ConstraintSolver._or
private static function _or($feature) { if ($feature->getOr()) { $children = array(); foreach ($feature->getChildren() as $child) $children[] = Logic::is($child); return Logic::equiv(Logic::is($feature), call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)); } }
php
private static function _or($feature) { if ($feature->getOr()) { $children = array(); foreach ($feature->getChildren() as $child) $children[] = Logic::is($child); return Logic::equiv(Logic::is($feature), call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)); } }
[ "private", "static", "function", "_or", "(", "$", "feature", ")", "{", "if", "(", "$", "feature", "->", "getOr", "(", ")", ")", "{", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "feature", "->", "getChildren", "(", ")", "as", "$", "child", ")", "$", "children", "[", "]", "=", "Logic", "::", "is", "(", "$", "child", ")", ";", "return", "Logic", "::", "equiv", "(", "Logic", "::", "is", "(", "$", "feature", ")", ",", "call_user_func_array", "(", "\"\\FeaturePhp\\Helper\\Logic::_or\"", ",", "$", "children", ")", ")", ";", "}", "}" ]
Semantics for a feature that provides a choice using an inclusive or. At least one child of such a feature is selected. @param Feature $feature @return callable
[ "Semantics", "for", "a", "feature", "that", "provides", "a", "choice", "using", "an", "inclusive", "or", ".", "At", "least", "one", "child", "of", "such", "a", "feature", "is", "selected", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L162-L170
ekuiter/feature-php
FeaturePhp/Model/ConstraintSolver.php
ConstraintSolver.crossTreeConstraint
private function crossTreeConstraint($rule) { $op = $rule->getName(); $num = $rule->count(); if ($op === "eq" && $num === 2) return Logic::equiv($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "imp" && $num === 2) return Logic::implies($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "conj" && $num === 2) return Logic::_and($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "disj" && $num === 2) return Logic::_or($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "not" && $num === 1) return Logic::not($this->crossTreeConstraint($rule->children()[0])); if ($op === "var" && $num === 0) return Logic::is($this->model->getFeature((string) $rule)); throw new ConstraintSolverException("unknown operation $op with $num arguments encountered"); }
php
private function crossTreeConstraint($rule) { $op = $rule->getName(); $num = $rule->count(); if ($op === "eq" && $num === 2) return Logic::equiv($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "imp" && $num === 2) return Logic::implies($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "conj" && $num === 2) return Logic::_and($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "disj" && $num === 2) return Logic::_or($this->crossTreeConstraint($rule->children()[0]), $this->crossTreeConstraint($rule->children()[1])); if ($op === "not" && $num === 1) return Logic::not($this->crossTreeConstraint($rule->children()[0])); if ($op === "var" && $num === 0) return Logic::is($this->model->getFeature((string) $rule)); throw new ConstraintSolverException("unknown operation $op with $num arguments encountered"); }
[ "private", "function", "crossTreeConstraint", "(", "$", "rule", ")", "{", "$", "op", "=", "$", "rule", "->", "getName", "(", ")", ";", "$", "num", "=", "$", "rule", "->", "count", "(", ")", ";", "if", "(", "$", "op", "===", "\"eq\"", "&&", "$", "num", "===", "2", ")", "return", "Logic", "::", "equiv", "(", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "0", "]", ")", ",", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "1", "]", ")", ")", ";", "if", "(", "$", "op", "===", "\"imp\"", "&&", "$", "num", "===", "2", ")", "return", "Logic", "::", "implies", "(", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "0", "]", ")", ",", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "1", "]", ")", ")", ";", "if", "(", "$", "op", "===", "\"conj\"", "&&", "$", "num", "===", "2", ")", "return", "Logic", "::", "_and", "(", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "0", "]", ")", ",", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "1", "]", ")", ")", ";", "if", "(", "$", "op", "===", "\"disj\"", "&&", "$", "num", "===", "2", ")", "return", "Logic", "::", "_or", "(", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "0", "]", ")", ",", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "1", "]", ")", ")", ";", "if", "(", "$", "op", "===", "\"not\"", "&&", "$", "num", "===", "1", ")", "return", "Logic", "::", "not", "(", "$", "this", "->", "crossTreeConstraint", "(", "$", "rule", "->", "children", "(", ")", "[", "0", "]", ")", ")", ";", "if", "(", "$", "op", "===", "\"var\"", "&&", "$", "num", "===", "0", ")", "return", "Logic", "::", "is", "(", "$", "this", "->", "model", "->", "getFeature", "(", "(", "string", ")", "$", "rule", ")", ")", ";", "throw", "new", "ConstraintSolverException", "(", "\"unknown operation $op with $num arguments encountered\"", ")", ";", "}" ]
Transforms a cross-tree constraint from an XML rule to a formula. @param \SimpleXMLElement $rule @return callable
[ "Transforms", "a", "cross", "-", "tree", "constraint", "from", "an", "XML", "rule", "to", "a", "formula", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L177-L199
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
ValidatorAbstract.dispatch
public function dispatch($name, $event) { if (!$this->event_dispatcher) { return null; } if (!$this->event_dispatcher instanceof Dispatcher) { throw new \Exception( 'Expected the event dispatcher to be an instance of phpDocumentor\Event\Dispatcher' ); } $this->event_dispatcher->dispatch($name, $event); }
php
public function dispatch($name, $event) { if (!$this->event_dispatcher) { return null; } if (!$this->event_dispatcher instanceof Dispatcher) { throw new \Exception( 'Expected the event dispatcher to be an instance of phpDocumentor\Event\Dispatcher' ); } $this->event_dispatcher->dispatch($name, $event); }
[ "public", "function", "dispatch", "(", "$", "name", ",", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "event_dispatcher", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "this", "->", "event_dispatcher", "instanceof", "Dispatcher", ")", "{", "throw", "new", "\\", "Exception", "(", "'Expected the event dispatcher to be an instance of phpDocumentor\\Event\\Dispatcher'", ")", ";", "}", "$", "this", "->", "event_dispatcher", "->", "dispatch", "(", "$", "name", ",", "$", "event", ")", ";", "}" ]
Dispatches an event to the Event Dispatcher. This method tries to dispatch an event; if no Event Dispatcher has been set than this method will explicitly not fail and return null. By not failing we make the Event Dispatcher optional and is it easier for people to re-use this component in their own application. @param string $name Name of the event to dispatch. @param EventAbstract $event Arguments for this event. @throws \Exception if there is a dispatcher but it is not of type EventDispatcher @return void
[ "Dispatches", "an", "event", "to", "the", "Event", "Dispatcher", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L115-L128
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
ValidatorAbstract.logParserError
public function logParserError($type, $code, $line, $variables = array()) { $message = $this->__($code, $variables); $this->log($message, LogLevel::ERROR); $this->dispatch( 'parser.log', LogEvent::createInstance($this) ->setMessage($message) ->setType($type) ->setCode($code) ->setLine($line) ); }
php
public function logParserError($type, $code, $line, $variables = array()) { $message = $this->__($code, $variables); $this->log($message, LogLevel::ERROR); $this->dispatch( 'parser.log', LogEvent::createInstance($this) ->setMessage($message) ->setType($type) ->setCode($code) ->setLine($line) ); }
[ "public", "function", "logParserError", "(", "$", "type", ",", "$", "code", ",", "$", "line", ",", "$", "variables", "=", "array", "(", ")", ")", "{", "$", "message", "=", "$", "this", "->", "__", "(", "$", "code", ",", "$", "variables", ")", ";", "$", "this", "->", "log", "(", "$", "message", ",", "LogLevel", "::", "ERROR", ")", ";", "$", "this", "->", "dispatch", "(", "'parser.log'", ",", "LogEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setMessage", "(", "$", "message", ")", "->", "setType", "(", "$", "type", ")", "->", "setCode", "(", "$", "code", ")", "->", "setLine", "(", "$", "line", ")", ")", ";", "}" ]
Dispatches a parser error to be logged. @param string $type The logging priority as string @param string $code The message to log. @param string $line The line number where the error occurred.. @param string[] $variables an array with message substitution variables. @return void
[ "Dispatches", "a", "parser", "error", "to", "be", "logged", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L158-L170
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
ValidatorAbstract.__
public function __($message, $variables = array()) { if (!$this->translate) { return vsprintf($message, $variables); } $translator = $this->translate; return vsprintf($translator->translate($message), $variables); }
php
public function __($message, $variables = array()) { if (!$this->translate) { return vsprintf($message, $variables); } $translator = $this->translate; return vsprintf($translator->translate($message), $variables); }
[ "public", "function", "__", "(", "$", "message", ",", "$", "variables", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "translate", ")", "{", "return", "vsprintf", "(", "$", "message", ",", "$", "variables", ")", ";", "}", "$", "translator", "=", "$", "this", "->", "translate", ";", "return", "vsprintf", "(", "$", "translator", "->", "translate", "(", "$", "message", ")", ",", "$", "variables", ")", ";", "}" ]
Translates the ID or message in the given language. Translation messages may contain any formatting as used by the php vsprintf function. @param string $message ID or message to translate. @param array $variables Variables to use for substitution. @codingStandardsIgnoreStart @return string
[ "Translates", "the", "ID", "or", "message", "in", "the", "given", "language", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L196-L205
alevilar/ristorantino-vendor
Printers/Lib/PrinterOutput/CupsPrinterOutput.php
CupsPrinterOutput.send
public function send( $printaitorViewObj ) { $texto = $printaitorViewObj->viewTextRender; $idFiscalPrinter = $printaitorViewObj->printerId; $hostname = $printaitorViewObj->hostName; if ( empty($hostname) ) { $hostname = Configure::read('Printers.server'); } if ( !$hostname || $hostname == 'auto' ) { $hostname = getenv('HTTP_X_FORWARDED_FOR'); if ( empty($hostname) ){ $hostname = $_SERVER['REMOTE_ADDR']; } } $Printer = ClassRegistry::init('Printers.Printer'); $printer = $Printer->read(null, $idFiscalPrinter); // cambiar el encoding del texto si esta configurado $encoding = Configure::read('Printers.encoding'); CakeLog::write('debug', "Encoding actual es ::: " . mb_detect_encoding($texto)); if (!empty( $encoding )) { CakeLog::write('debug', "Cambiando encoding x ::: $encoding "); $texto = mb_convert_encoding($texto, $encoding, mb_detect_encoding($texto)); } // preparar argumentos del proc_open $descriptorspec = array( 0 => array("pipe", "r"), //esto lo uso para mandarle comandos 1 => array("pipe", "w"), // el stdout a un archivo tmp 2 => array("file", "/tmp/lprerrout.txt", "a") // el stderr a un archivo tmp ); $comando = 'lp -h '.$hostname.' -d '.$printer['Printer']['alias']; CakeLog::write('debug', "Se envió a imprimir por CUPS ::: $comando"); CakeLog::write('debug', "TEXT ::: $texto "); $process = proc_open($comando, $descriptorspec, $pipes, '/tmp'); // escribir en el pipe de escritura if (is_resource($process)) { fwrite($pipes[0],$texto); fclose($pipes[0]); fclose($pipes[1]); $ret = proc_close($process); return true; } return false; }
php
public function send( $printaitorViewObj ) { $texto = $printaitorViewObj->viewTextRender; $idFiscalPrinter = $printaitorViewObj->printerId; $hostname = $printaitorViewObj->hostName; if ( empty($hostname) ) { $hostname = Configure::read('Printers.server'); } if ( !$hostname || $hostname == 'auto' ) { $hostname = getenv('HTTP_X_FORWARDED_FOR'); if ( empty($hostname) ){ $hostname = $_SERVER['REMOTE_ADDR']; } } $Printer = ClassRegistry::init('Printers.Printer'); $printer = $Printer->read(null, $idFiscalPrinter); // cambiar el encoding del texto si esta configurado $encoding = Configure::read('Printers.encoding'); CakeLog::write('debug', "Encoding actual es ::: " . mb_detect_encoding($texto)); if (!empty( $encoding )) { CakeLog::write('debug', "Cambiando encoding x ::: $encoding "); $texto = mb_convert_encoding($texto, $encoding, mb_detect_encoding($texto)); } // preparar argumentos del proc_open $descriptorspec = array( 0 => array("pipe", "r"), //esto lo uso para mandarle comandos 1 => array("pipe", "w"), // el stdout a un archivo tmp 2 => array("file", "/tmp/lprerrout.txt", "a") // el stderr a un archivo tmp ); $comando = 'lp -h '.$hostname.' -d '.$printer['Printer']['alias']; CakeLog::write('debug', "Se envió a imprimir por CUPS ::: $comando"); CakeLog::write('debug', "TEXT ::: $texto "); $process = proc_open($comando, $descriptorspec, $pipes, '/tmp'); // escribir en el pipe de escritura if (is_resource($process)) { fwrite($pipes[0],$texto); fclose($pipes[0]); fclose($pipes[1]); $ret = proc_close($process); return true; } return false; }
[ "public", "function", "send", "(", "$", "printaitorViewObj", ")", "{", "$", "texto", "=", "$", "printaitorViewObj", "->", "viewTextRender", ";", "$", "idFiscalPrinter", "=", "$", "printaitorViewObj", "->", "printerId", ";", "$", "hostname", "=", "$", "printaitorViewObj", "->", "hostName", ";", "if", "(", "empty", "(", "$", "hostname", ")", ")", "{", "$", "hostname", "=", "Configure", "::", "read", "(", "'Printers.server'", ")", ";", "}", "if", "(", "!", "$", "hostname", "||", "$", "hostname", "==", "'auto'", ")", "{", "$", "hostname", "=", "getenv", "(", "'HTTP_X_FORWARDED_FOR'", ")", ";", "if", "(", "empty", "(", "$", "hostname", ")", ")", "{", "$", "hostname", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "}", "$", "Printer", "=", "ClassRegistry", "::", "init", "(", "'Printers.Printer'", ")", ";", "$", "printer", "=", "$", "Printer", "->", "read", "(", "null", ",", "$", "idFiscalPrinter", ")", ";", "// cambiar el encoding del texto si esta configurado", "$", "encoding", "=", "Configure", "::", "read", "(", "'Printers.encoding'", ")", ";", "CakeLog", "::", "write", "(", "'debug'", ",", "\"Encoding actual es ::: \"", ".", "mb_detect_encoding", "(", "$", "texto", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "encoding", ")", ")", "{", "CakeLog", "::", "write", "(", "'debug'", ",", "\"Cambiando encoding x ::: $encoding \"", ")", ";", "$", "texto", "=", "mb_convert_encoding", "(", "$", "texto", ",", "$", "encoding", ",", "mb_detect_encoding", "(", "$", "texto", ")", ")", ";", "}", "// preparar argumentos del proc_open", "$", "descriptorspec", "=", "array", "(", "0", "=>", "array", "(", "\"pipe\"", ",", "\"r\"", ")", ",", "//esto lo uso para mandarle comandos", "1", "=>", "array", "(", "\"pipe\"", ",", "\"w\"", ")", ",", "// el stdout a un archivo tmp", "2", "=>", "array", "(", "\"file\"", ",", "\"/tmp/lprerrout.txt\"", ",", "\"a\"", ")", "// el stderr a un archivo tmp", ")", ";", "$", "comando", "=", "'lp -h '", ".", "$", "hostname", ".", "' -d '", ".", "$", "printer", "[", "'Printer'", "]", "[", "'alias'", "]", ";", "CakeLog", "::", "write", "(", "'debug'", ",", "\"Se envió a imprimir por CUPS ::: $comando\")", ";", "", "CakeLog", "::", "write", "(", "'debug'", ",", "\"TEXT ::: $texto \"", ")", ";", "$", "process", "=", "proc_open", "(", "$", "comando", ",", "$", "descriptorspec", ",", "$", "pipes", ",", "'/tmp'", ")", ";", "// escribir en el pipe de escritura", "if", "(", "is_resource", "(", "$", "process", ")", ")", "{", "fwrite", "(", "$", "pipes", "[", "0", "]", ",", "$", "texto", ")", ";", "fclose", "(", "$", "pipes", "[", "0", "]", ")", ";", "fclose", "(", "$", "pipes", "[", "1", "]", ")", ";", "$", "ret", "=", "proc_close", "(", "$", "process", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Comando cups de impresion @param PrintaitorViewObj @return type boolean true si salio todo bien false caso contrario
[ "Comando", "cups", "de", "impresion" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/PrinterOutput/CupsPrinterOutput.php#L37-L93
php-lug/lug
src/Bundle/GridBundle/Model/Filter.php
Filter.getFormOption
public function getFormOption($name) { if (!$this->hasFormOption($name)) { throw new OptionNotFoundException(sprintf('The filter form option "%s" could not be found.', $name)); } return $this->formOptions[$name]; }
php
public function getFormOption($name) { if (!$this->hasFormOption($name)) { throw new OptionNotFoundException(sprintf('The filter form option "%s" could not be found.', $name)); } return $this->formOptions[$name]; }
[ "public", "function", "getFormOption", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasFormOption", "(", "$", "name", ")", ")", "{", "throw", "new", "OptionNotFoundException", "(", "sprintf", "(", "'The filter form option \"%s\" could not be found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "formOptions", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/Model/Filter.php#L83-L90
syzygypl/page-media-set-bundle
Service/PageMediaSetService.php
PageMediaSetService.getPageMediaSet
private function getPageMediaSet(HasMediaSetInterface $page) { if (false === $this->preloadedMediaSets) { $data = $this->repository ->createQueryBuilder('pm') ->join(Media::class, 'media', Join::WITH, 'pm.media = media.id') ->select(['pm.pageType', 'pm.pageId', 'pm.type', 'media.url']) ->getQuery() ->getResult(); $this->preloadedMediaSets = true; foreach ($data as $media) { $this->mediaSets[$media['pageType']][$media['pageId']][$media['type']] = $media['url']; } } if (false === isset($this->mediaSets[$page->getType()][$page->getId()])) { return []; } return $this->mediaSets[$page->getType()][$page->getId()]; }
php
private function getPageMediaSet(HasMediaSetInterface $page) { if (false === $this->preloadedMediaSets) { $data = $this->repository ->createQueryBuilder('pm') ->join(Media::class, 'media', Join::WITH, 'pm.media = media.id') ->select(['pm.pageType', 'pm.pageId', 'pm.type', 'media.url']) ->getQuery() ->getResult(); $this->preloadedMediaSets = true; foreach ($data as $media) { $this->mediaSets[$media['pageType']][$media['pageId']][$media['type']] = $media['url']; } } if (false === isset($this->mediaSets[$page->getType()][$page->getId()])) { return []; } return $this->mediaSets[$page->getType()][$page->getId()]; }
[ "private", "function", "getPageMediaSet", "(", "HasMediaSetInterface", "$", "page", ")", "{", "if", "(", "false", "===", "$", "this", "->", "preloadedMediaSets", ")", "{", "$", "data", "=", "$", "this", "->", "repository", "->", "createQueryBuilder", "(", "'pm'", ")", "->", "join", "(", "Media", "::", "class", ",", "'media'", ",", "Join", "::", "WITH", ",", "'pm.media = media.id'", ")", "->", "select", "(", "[", "'pm.pageType'", ",", "'pm.pageId'", ",", "'pm.type'", ",", "'media.url'", "]", ")", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "$", "this", "->", "preloadedMediaSets", "=", "true", ";", "foreach", "(", "$", "data", "as", "$", "media", ")", "{", "$", "this", "->", "mediaSets", "[", "$", "media", "[", "'pageType'", "]", "]", "[", "$", "media", "[", "'pageId'", "]", "]", "[", "$", "media", "[", "'type'", "]", "]", "=", "$", "media", "[", "'url'", "]", ";", "}", "}", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "mediaSets", "[", "$", "page", "->", "getType", "(", ")", "]", "[", "$", "page", "->", "getId", "(", ")", "]", ")", ")", "{", "return", "[", "]", ";", "}", "return", "$", "this", "->", "mediaSets", "[", "$", "page", "->", "getType", "(", ")", "]", "[", "$", "page", "->", "getId", "(", ")", "]", ";", "}" ]
@param HasMediaSetInterface $page @return PageMedia[]
[ "@param", "HasMediaSetInterface", "$page" ]
train
https://github.com/syzygypl/page-media-set-bundle/blob/013d5321518755b07d292d63d5b3f1ddeb635107/Service/PageMediaSetService.php#L56-L78
mothership-ec/composer
src/Composer/IO/BaseIO.php
BaseIO.loadConfiguration
public function loadConfiguration(Config $config) { // reload oauth token from config if available if ($tokens = $config->get('github-oauth')) { foreach ($tokens as $domain => $token) { if (!preg_match('{^[a-z0-9]+$}', $token)) { throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"'); } $this->setAuthentication($domain, $token, 'x-oauth-basic'); } } // reload http basic credentials from config if available if ($creds = $config->get('http-basic')) { foreach ($creds as $domain => $cred) { $this->setAuthentication($domain, $cred['username'], $cred['password']); } } // setup process timeout ProcessExecutor::setTimeout((int) $config->get('process-timeout')); }
php
public function loadConfiguration(Config $config) { // reload oauth token from config if available if ($tokens = $config->get('github-oauth')) { foreach ($tokens as $domain => $token) { if (!preg_match('{^[a-z0-9]+$}', $token)) { throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"'); } $this->setAuthentication($domain, $token, 'x-oauth-basic'); } } // reload http basic credentials from config if available if ($creds = $config->get('http-basic')) { foreach ($creds as $domain => $cred) { $this->setAuthentication($domain, $cred['username'], $cred['password']); } } // setup process timeout ProcessExecutor::setTimeout((int) $config->get('process-timeout')); }
[ "public", "function", "loadConfiguration", "(", "Config", "$", "config", ")", "{", "// reload oauth token from config if available", "if", "(", "$", "tokens", "=", "$", "config", "->", "get", "(", "'github-oauth'", ")", ")", "{", "foreach", "(", "$", "tokens", "as", "$", "domain", "=>", "$", "token", ")", "{", "if", "(", "!", "preg_match", "(", "'{^[a-z0-9]+$}'", ",", "$", "token", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'Your github oauth token for '", ".", "$", "domain", ".", "' contains invalid characters: \"'", ".", "$", "token", ".", "'\"'", ")", ";", "}", "$", "this", "->", "setAuthentication", "(", "$", "domain", ",", "$", "token", ",", "'x-oauth-basic'", ")", ";", "}", "}", "// reload http basic credentials from config if available", "if", "(", "$", "creds", "=", "$", "config", "->", "get", "(", "'http-basic'", ")", ")", "{", "foreach", "(", "$", "creds", "as", "$", "domain", "=>", "$", "cred", ")", "{", "$", "this", "->", "setAuthentication", "(", "$", "domain", ",", "$", "cred", "[", "'username'", "]", ",", "$", "cred", "[", "'password'", "]", ")", ";", "}", "}", "// setup process timeout", "ProcessExecutor", "::", "setTimeout", "(", "(", "int", ")", "$", "config", "->", "get", "(", "'process-timeout'", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/IO/BaseIO.php#L61-L82
gdbots/iam-php
src/Util/AppPbjxHelperTrait.php
AppPbjxHelperTrait.createEventFromCommand
protected function createEventFromCommand(Command $command, string $suffix): Event { $curie = $command::schema()->getCurie(); $eventCurie = "{$curie->getVendor()}:{$curie->getPackage()}:event:app-{$suffix}"; /** @var Event $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($eventCurie)); return $class::create(); }
php
protected function createEventFromCommand(Command $command, string $suffix): Event { $curie = $command::schema()->getCurie(); $eventCurie = "{$curie->getVendor()}:{$curie->getPackage()}:event:app-{$suffix}"; /** @var Event $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($eventCurie)); return $class::create(); }
[ "protected", "function", "createEventFromCommand", "(", "Command", "$", "command", ",", "string", "$", "suffix", ")", ":", "Event", "{", "$", "curie", "=", "$", "command", "::", "schema", "(", ")", "->", "getCurie", "(", ")", ";", "$", "eventCurie", "=", "\"{$curie->getVendor()}:{$curie->getPackage()}:event:app-{$suffix}\"", ";", "/** @var Event $class */", "$", "class", "=", "MessageResolver", "::", "resolveCurie", "(", "SchemaCurie", "::", "fromString", "(", "$", "eventCurie", ")", ")", ";", "return", "$", "class", "::", "create", "(", ")", ";", "}" ]
@param Command $command @param string $suffix @return Event
[ "@param", "Command", "$command", "@param", "string", "$suffix" ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/Util/AppPbjxHelperTrait.php#L31-L39
gordalina/mangopay-php
src/Gordalina/Mangopay/Request/RequestModel.php
RequestModel.handle
public function handle(ResponseInterface $response) { $class = get_class($this->model); $model = new $class(); $model->jsonUnserialize($response->getBody()); $response->setModel($model); }
php
public function handle(ResponseInterface $response) { $class = get_class($this->model); $model = new $class(); $model->jsonUnserialize($response->getBody()); $response->setModel($model); }
[ "public", "function", "handle", "(", "ResponseInterface", "$", "response", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", "->", "model", ")", ";", "$", "model", "=", "new", "$", "class", "(", ")", ";", "$", "model", "->", "jsonUnserialize", "(", "$", "response", "->", "getBody", "(", ")", ")", ";", "$", "response", "->", "setModel", "(", "$", "model", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/gordalina/mangopay-php/blob/6807992416d964e25670d961b66dbccd7a46ef62/src/Gordalina/Mangopay/Request/RequestModel.php#L35-L43
MASNathan/Parser
src/Data/Content.php
Content.from
public function from($type) { switch ($type) { case 'ini': $this->data = Ini::decode($this->string); break; case 'json': $this->data = Json::decode($this->string); break; case 'php': $this->data = Php::decode($this->string); break; case 'xml': $this->data = Xml::decode($this->string); break; case 'yml': case 'yaml': $this->data = Yaml::decode($this->string); break; default: throw new \Exception("Format not supported: " . $type); } return $this; }
php
public function from($type) { switch ($type) { case 'ini': $this->data = Ini::decode($this->string); break; case 'json': $this->data = Json::decode($this->string); break; case 'php': $this->data = Php::decode($this->string); break; case 'xml': $this->data = Xml::decode($this->string); break; case 'yml': case 'yaml': $this->data = Yaml::decode($this->string); break; default: throw new \Exception("Format not supported: " . $type); } return $this; }
[ "public", "function", "from", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'ini'", ":", "$", "this", "->", "data", "=", "Ini", "::", "decode", "(", "$", "this", "->", "string", ")", ";", "break", ";", "case", "'json'", ":", "$", "this", "->", "data", "=", "Json", "::", "decode", "(", "$", "this", "->", "string", ")", ";", "break", ";", "case", "'php'", ":", "$", "this", "->", "data", "=", "Php", "::", "decode", "(", "$", "this", "->", "string", ")", ";", "break", ";", "case", "'xml'", ":", "$", "this", "->", "data", "=", "Xml", "::", "decode", "(", "$", "this", "->", "string", ")", ";", "break", ";", "case", "'yml'", ":", "case", "'yaml'", ":", "$", "this", "->", "data", "=", "Yaml", "::", "decode", "(", "$", "this", "->", "string", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "\"Format not supported: \"", ".", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
Specifies the structure type which the content will be parsed from @param string $type Type [ini, json, php, xml or yaml] @return Content
[ "Specifies", "the", "structure", "type", "which", "the", "content", "will", "be", "parsed", "from" ]
train
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Data/Content.php#L82-L111
MASNathan/Parser
src/Data/Content.php
Content.to
public function to($type) { switch ($type) { case 'ini': $this->string = Ini::encode($this->data); break; case 'json': $this->string = Json::encode($this->data, $this->prettyOutput); break; case 'php': $this->string = Php::encode($this->data); break; case 'xml': $this->string = Xml::encode($this->data, $this->prettyOutput); break; case 'yml': case 'yaml': $this->string = Yaml::encode($this->data); break; default: throw new \Exception("Format not supported: " . $type); } return $this->string; }
php
public function to($type) { switch ($type) { case 'ini': $this->string = Ini::encode($this->data); break; case 'json': $this->string = Json::encode($this->data, $this->prettyOutput); break; case 'php': $this->string = Php::encode($this->data); break; case 'xml': $this->string = Xml::encode($this->data, $this->prettyOutput); break; case 'yml': case 'yaml': $this->string = Yaml::encode($this->data); break; default: throw new \Exception("Format not supported: " . $type); } return $this->string; }
[ "public", "function", "to", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'ini'", ":", "$", "this", "->", "string", "=", "Ini", "::", "encode", "(", "$", "this", "->", "data", ")", ";", "break", ";", "case", "'json'", ":", "$", "this", "->", "string", "=", "Json", "::", "encode", "(", "$", "this", "->", "data", ",", "$", "this", "->", "prettyOutput", ")", ";", "break", ";", "case", "'php'", ":", "$", "this", "->", "string", "=", "Php", "::", "encode", "(", "$", "this", "->", "data", ")", ";", "break", ";", "case", "'xml'", ":", "$", "this", "->", "string", "=", "Xml", "::", "encode", "(", "$", "this", "->", "data", ",", "$", "this", "->", "prettyOutput", ")", ";", "break", ";", "case", "'yml'", ":", "case", "'yaml'", ":", "$", "this", "->", "string", "=", "Yaml", "::", "encode", "(", "$", "this", "->", "data", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "\"Format not supported: \"", ".", "$", "type", ")", ";", "}", "return", "$", "this", "->", "string", ";", "}" ]
Specifies the format you want to encode the data to @param string $type Type [ini, json, php, xml or yaml] @return string
[ "Specifies", "the", "format", "you", "want", "to", "encode", "the", "data", "to" ]
train
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Data/Content.php#L118-L147
99designs/ergo-http
src/Request.php
Request.copy
public function copy($headers = false, $body = false, $url = false, $method = false) { $copy = clone $this; if ($headers !== false) $copy->_headers = new HeaderCollection($headers); if ($body !== false) $copy->_body = $body; if ($url !== false) $copy->_url = $url; if ($method !== false) $copy->_method = $method; unset($copy->_querystring); return $copy; }
php
public function copy($headers = false, $body = false, $url = false, $method = false) { $copy = clone $this; if ($headers !== false) $copy->_headers = new HeaderCollection($headers); if ($body !== false) $copy->_body = $body; if ($url !== false) $copy->_url = $url; if ($method !== false) $copy->_method = $method; unset($copy->_querystring); return $copy; }
[ "public", "function", "copy", "(", "$", "headers", "=", "false", ",", "$", "body", "=", "false", ",", "$", "url", "=", "false", ",", "$", "method", "=", "false", ")", "{", "$", "copy", "=", "clone", "$", "this", ";", "if", "(", "$", "headers", "!==", "false", ")", "$", "copy", "->", "_headers", "=", "new", "HeaderCollection", "(", "$", "headers", ")", ";", "if", "(", "$", "body", "!==", "false", ")", "$", "copy", "->", "_body", "=", "$", "body", ";", "if", "(", "$", "url", "!==", "false", ")", "$", "copy", "->", "_url", "=", "$", "url", ";", "if", "(", "$", "method", "!==", "false", ")", "$", "copy", "->", "_method", "=", "$", "method", ";", "unset", "(", "$", "copy", "->", "_querystring", ")", ";", "return", "$", "copy", ";", "}" ]
Creates a new Request object with the parameters specified, or uses the current object's parameters @return object
[ "Creates", "a", "new", "Request", "object", "with", "the", "parameters", "specified", "or", "uses", "the", "current", "object", "s", "parameters" ]
train
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Request.php#L87-L99
kouks/laravel-filters
src/Filters/Filter.php
Filter.apply
public function apply(Builder $builder) { $this->builder = $builder; // We need to select all columns from the original // table, since many joins can mess up the selected fields $this->builder->select("{$this->getTableName()}.*"); foreach ($this->filters() as $name => $value) { $this->callFilterMethod($name, $value); } return $this->builder; }
php
public function apply(Builder $builder) { $this->builder = $builder; // We need to select all columns from the original // table, since many joins can mess up the selected fields $this->builder->select("{$this->getTableName()}.*"); foreach ($this->filters() as $name => $value) { $this->callFilterMethod($name, $value); } return $this->builder; }
[ "public", "function", "apply", "(", "Builder", "$", "builder", ")", "{", "$", "this", "->", "builder", "=", "$", "builder", ";", "// We need to select all columns from the original", "// table, since many joins can mess up the selected fields", "$", "this", "->", "builder", "->", "select", "(", "\"{$this->getTableName()}.*\"", ")", ";", "foreach", "(", "$", "this", "->", "filters", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "callFilterMethod", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", "->", "builder", ";", "}" ]
Applies all available filters. @param \Illuminate\Database\Eloquent\Builder $builder @return \Illuminate\Database\Eloquent\Builder
[ "Applies", "all", "available", "filters", "." ]
train
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Filter.php#L66-L79
kouks/laravel-filters
src/Filters/Filter.php
Filter.resolve
protected function resolve($column, $key, $last, callable $callback) { if (! strpos($column, '.')) { return $callback("{$last}.{$column}", $key); } $scope = strstr($column, '.', true); $singular = str_singular($scope); $next = substr(strstr($column, '.'), 1); if (! in_array($scope, $this->loaded)) { $this->loaded[] = $scope; $this->builder->join($scope, "{$last}.{$singular}_id", "{$scope}.id"); } return $this->resolve($next, $key, $scope, $callback); }
php
protected function resolve($column, $key, $last, callable $callback) { if (! strpos($column, '.')) { return $callback("{$last}.{$column}", $key); } $scope = strstr($column, '.', true); $singular = str_singular($scope); $next = substr(strstr($column, '.'), 1); if (! in_array($scope, $this->loaded)) { $this->loaded[] = $scope; $this->builder->join($scope, "{$last}.{$singular}_id", "{$scope}.id"); } return $this->resolve($next, $key, $scope, $callback); }
[ "protected", "function", "resolve", "(", "$", "column", ",", "$", "key", ",", "$", "last", ",", "callable", "$", "callback", ")", "{", "if", "(", "!", "strpos", "(", "$", "column", ",", "'.'", ")", ")", "{", "return", "$", "callback", "(", "\"{$last}.{$column}\"", ",", "$", "key", ")", ";", "}", "$", "scope", "=", "strstr", "(", "$", "column", ",", "'.'", ",", "true", ")", ";", "$", "singular", "=", "str_singular", "(", "$", "scope", ")", ";", "$", "next", "=", "substr", "(", "strstr", "(", "$", "column", ",", "'.'", ")", ",", "1", ")", ";", "if", "(", "!", "in_array", "(", "$", "scope", ",", "$", "this", "->", "loaded", ")", ")", "{", "$", "this", "->", "loaded", "[", "]", "=", "$", "scope", ";", "$", "this", "->", "builder", "->", "join", "(", "$", "scope", ",", "\"{$last}.{$singular}_id\"", ",", "\"{$scope}.id\"", ")", ";", "}", "return", "$", "this", "->", "resolve", "(", "$", "next", ",", "$", "key", ",", "$", "scope", ",", "$", "callback", ")", ";", "}" ]
Recursively build up the query. @param string $column @param string $key @param string $last @param callable $callback @return void
[ "Recursively", "build", "up", "the", "query", "." ]
train
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Filter.php#L121-L138
songshenzong/log
src/Middleware.php
Middleware.handle
public function handle($request, Closure $next) { try { $response = $next($request); } catch (Exception $e) { $response = $this->handleException($request, $e); } catch (Error $error) { $e = new FatalThrowableError($error); $response = $this->handleException($request, $e); } $this->debugbar->modifyResponse($request, $response); return $response; }
php
public function handle($request, Closure $next) { try { $response = $next($request); } catch (Exception $e) { $response = $this->handleException($request, $e); } catch (Error $error) { $e = new FatalThrowableError($error); $response = $this->handleException($request, $e); } $this->debugbar->modifyResponse($request, $response); return $response; }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "try", "{", "$", "response", "=", "$", "next", "(", "$", "request", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "response", "=", "$", "this", "->", "handleException", "(", "$", "request", ",", "$", "e", ")", ";", "}", "catch", "(", "Error", "$", "error", ")", "{", "$", "e", "=", "new", "FatalThrowableError", "(", "$", "error", ")", ";", "$", "response", "=", "$", "this", "->", "handleException", "(", "$", "request", ",", "$", "e", ")", ";", "}", "$", "this", "->", "debugbar", "->", "modifyResponse", "(", "$", "request", ",", "$", "response", ")", ";", "return", "$", "response", ";", "}" ]
Handle an incoming request. @param Request $request @param Closure $next @return mixed @throws DebugBarException @throws Exception
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Middleware.php#L55-L70
giftcards/Encryption
Form/Type/Extension/EncryptTypeExtension.php
EncryptTypeExtension.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['encryption_profile'] === false) { return; } $builder->addModelTransformer(new EncryptTransformer( $this->cipherTextGenerator, $options['encryption_profile'] )); }
php
public function buildForm(FormBuilderInterface $builder, array $options) { if ($options['encryption_profile'] === false) { return; } $builder->addModelTransformer(new EncryptTransformer( $this->cipherTextGenerator, $options['encryption_profile'] )); }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "if", "(", "$", "options", "[", "'encryption_profile'", "]", "===", "false", ")", "{", "return", ";", "}", "$", "builder", "->", "addModelTransformer", "(", "new", "EncryptTransformer", "(", "$", "this", "->", "cipherTextGenerator", ",", "$", "options", "[", "'encryption_profile'", "]", ")", ")", ";", "}" ]
Builds the form. This method is called after the extended type has built the form to further modify it. @see FormTypeInterface::buildForm() @param FormBuilderInterface $builder The form builder @param array $options The options
[ "Builds", "the", "form", "." ]
train
https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/Form/Type/Extension/EncryptTypeExtension.php#L41-L51
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_view
public function get_view( $name, $args = [], $echo = false, $error = true, $remove_nl = false ) { $name = trim( $name, '/' . DS ); $name = str_replace( '/', DS, $name ); $name .= '.php'; $path = null; foreach ( $this->get_check_view_dirs() as $dir ) { $dir = rtrim( $dir, DS . '/' ); if ( is_readable( $dir . DS . $name ) ) { $path = $dir . DS . $name; break; } } $view = ''; if ( isset( $path ) ) { unset( $name ); $args = $this->get_presenter_args( $args ); extract( $args, EXTR_SKIP ); ob_start(); /** @noinspection PhpIncludeInspection */ @include $path; $view = ob_get_contents(); ob_end_clean(); } elseif ( $error ) { $this->app->log( sprintf( 'View file [ %s ] not found.', $name ) ); } if ( $remove_nl ) { $view = str_replace( [ "\r\n", "\r", "\n" ], ' ', $view ); } if ( $echo ) { echo $view; } return $view; }
php
public function get_view( $name, $args = [], $echo = false, $error = true, $remove_nl = false ) { $name = trim( $name, '/' . DS ); $name = str_replace( '/', DS, $name ); $name .= '.php'; $path = null; foreach ( $this->get_check_view_dirs() as $dir ) { $dir = rtrim( $dir, DS . '/' ); if ( is_readable( $dir . DS . $name ) ) { $path = $dir . DS . $name; break; } } $view = ''; if ( isset( $path ) ) { unset( $name ); $args = $this->get_presenter_args( $args ); extract( $args, EXTR_SKIP ); ob_start(); /** @noinspection PhpIncludeInspection */ @include $path; $view = ob_get_contents(); ob_end_clean(); } elseif ( $error ) { $this->app->log( sprintf( 'View file [ %s ] not found.', $name ) ); } if ( $remove_nl ) { $view = str_replace( [ "\r\n", "\r", "\n" ], ' ', $view ); } if ( $echo ) { echo $view; } return $view; }
[ "public", "function", "get_view", "(", "$", "name", ",", "$", "args", "=", "[", "]", ",", "$", "echo", "=", "false", ",", "$", "error", "=", "true", ",", "$", "remove_nl", "=", "false", ")", "{", "$", "name", "=", "trim", "(", "$", "name", ",", "'/'", ".", "DS", ")", ";", "$", "name", "=", "str_replace", "(", "'/'", ",", "DS", ",", "$", "name", ")", ";", "$", "name", ".=", "'.php'", ";", "$", "path", "=", "null", ";", "foreach", "(", "$", "this", "->", "get_check_view_dirs", "(", ")", "as", "$", "dir", ")", "{", "$", "dir", "=", "rtrim", "(", "$", "dir", ",", "DS", ".", "'/'", ")", ";", "if", "(", "is_readable", "(", "$", "dir", ".", "DS", ".", "$", "name", ")", ")", "{", "$", "path", "=", "$", "dir", ".", "DS", ".", "$", "name", ";", "break", ";", "}", "}", "$", "view", "=", "''", ";", "if", "(", "isset", "(", "$", "path", ")", ")", "{", "unset", "(", "$", "name", ")", ";", "$", "args", "=", "$", "this", "->", "get_presenter_args", "(", "$", "args", ")", ";", "extract", "(", "$", "args", ",", "EXTR_SKIP", ")", ";", "ob_start", "(", ")", ";", "/** @noinspection PhpIncludeInspection */", "@", "include", "$", "path", ";", "$", "view", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "}", "elseif", "(", "$", "error", ")", "{", "$", "this", "->", "app", "->", "log", "(", "sprintf", "(", "'View file [ %s ] not found.'", ",", "$", "name", ")", ")", ";", "}", "if", "(", "$", "remove_nl", ")", "{", "$", "view", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", "]", ",", "' '", ",", "$", "view", ")", ";", "}", "if", "(", "$", "echo", ")", "{", "echo", "$", "view", ";", "}", "return", "$", "view", ";", "}" ]
@param string $name @param array $args @param bool $echo @param bool $error @param bool $remove_nl @return string
[ "@param", "string", "$name", "@param", "array", "$args", "@param", "bool", "$echo", "@param", "bool", "$error", "@param", "bool", "$remove_nl" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L59-L96
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_presenter_args
private function get_presenter_args( $args ) { $args['field'] = array_merge( $this->app->utility->array_get( $args, 'field', [] ), $this->app->input->all() ); if ( $this instanceof \Technote\Interfaces\Nonce ) { $args['nonce_key'] = $this->get_nonce_key(); $args['nonce_value'] = $this->create_nonce(); } $args['instance'] = $this; $args['action'] = $this->app->input->server( "REQUEST_URI" ); $args['is_admin'] = is_admin(); $args['user_can'] = $this->app->user_can(); $args['api_class'] = $this->get_api_class(); return $this->filter_presenter_args( $args ); }
php
private function get_presenter_args( $args ) { $args['field'] = array_merge( $this->app->utility->array_get( $args, 'field', [] ), $this->app->input->all() ); if ( $this instanceof \Technote\Interfaces\Nonce ) { $args['nonce_key'] = $this->get_nonce_key(); $args['nonce_value'] = $this->create_nonce(); } $args['instance'] = $this; $args['action'] = $this->app->input->server( "REQUEST_URI" ); $args['is_admin'] = is_admin(); $args['user_can'] = $this->app->user_can(); $args['api_class'] = $this->get_api_class(); return $this->filter_presenter_args( $args ); }
[ "private", "function", "get_presenter_args", "(", "$", "args", ")", "{", "$", "args", "[", "'field'", "]", "=", "array_merge", "(", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "args", ",", "'field'", ",", "[", "]", ")", ",", "$", "this", "->", "app", "->", "input", "->", "all", "(", ")", ")", ";", "if", "(", "$", "this", "instanceof", "\\", "Technote", "\\", "Interfaces", "\\", "Nonce", ")", "{", "$", "args", "[", "'nonce_key'", "]", "=", "$", "this", "->", "get_nonce_key", "(", ")", ";", "$", "args", "[", "'nonce_value'", "]", "=", "$", "this", "->", "create_nonce", "(", ")", ";", "}", "$", "args", "[", "'instance'", "]", "=", "$", "this", ";", "$", "args", "[", "'action'", "]", "=", "$", "this", "->", "app", "->", "input", "->", "server", "(", "\"REQUEST_URI\"", ")", ";", "$", "args", "[", "'is_admin'", "]", "=", "is_admin", "(", ")", ";", "$", "args", "[", "'user_can'", "]", "=", "$", "this", "->", "app", "->", "user_can", "(", ")", ";", "$", "args", "[", "'api_class'", "]", "=", "$", "this", "->", "get_api_class", "(", ")", ";", "return", "$", "this", "->", "filter_presenter_args", "(", "$", "args", ")", ";", "}" ]
@param array $args @return array
[ "@param", "array", "$args" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L110-L123
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.form
public function form( $name, $args = [], $overwrite = [], $echo = true, $error = true ) { return $this->get_view( 'include/form/' . trim( $name, '/' . DS ), array_replace_recursive( $args, $overwrite ), $echo, $error ); }
php
public function form( $name, $args = [], $overwrite = [], $echo = true, $error = true ) { return $this->get_view( 'include/form/' . trim( $name, '/' . DS ), array_replace_recursive( $args, $overwrite ), $echo, $error ); }
[ "public", "function", "form", "(", "$", "name", ",", "$", "args", "=", "[", "]", ",", "$", "overwrite", "=", "[", "]", ",", "$", "echo", "=", "true", ",", "$", "error", "=", "true", ")", "{", "return", "$", "this", "->", "get_view", "(", "'include/form/'", ".", "trim", "(", "$", "name", ",", "'/'", ".", "DS", ")", ",", "array_replace_recursive", "(", "$", "args", ",", "$", "overwrite", ")", ",", "$", "echo", ",", "$", "error", ")", ";", "}" ]
@param string $name @param array $args @param array $overwrite @param bool $echo @param bool $error @return string
[ "@param", "string", "$name", "@param", "array", "$args", "@param", "array", "$overwrite", "@param", "bool", "$echo", "@param", "bool", "$error" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L143-L145
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.old
public function old( $name, $data, $key = null, $default = '', $checkbox = false ) { if ( is_array( $data ) ) { $default = $this->app->utility->array_get( $data, $key, $default ); } elseif ( $data instanceof \stdClass ) { $default = property_exists( $data, $key ) ? $data->$key : $default; } elseif ( ! isset( $key ) ) { $default = $data; } if ( ! isset( $this->_prev_post ) ) { $this->_prev_post = $this->app->session->get( $this->get_old_post_session_key(), null ); if ( empty( $this->_prev_post ) ) { $this->_prev_post = []; } $this->app->session->delete( $this->get_old_post_session_key() ); } if ( $checkbox && ! empty( $this->_prev_post ) ) { $default = false; } return $this->app->utility->array_get( $this->_prev_post, $name, $default ); }
php
public function old( $name, $data, $key = null, $default = '', $checkbox = false ) { if ( is_array( $data ) ) { $default = $this->app->utility->array_get( $data, $key, $default ); } elseif ( $data instanceof \stdClass ) { $default = property_exists( $data, $key ) ? $data->$key : $default; } elseif ( ! isset( $key ) ) { $default = $data; } if ( ! isset( $this->_prev_post ) ) { $this->_prev_post = $this->app->session->get( $this->get_old_post_session_key(), null ); if ( empty( $this->_prev_post ) ) { $this->_prev_post = []; } $this->app->session->delete( $this->get_old_post_session_key() ); } if ( $checkbox && ! empty( $this->_prev_post ) ) { $default = false; } return $this->app->utility->array_get( $this->_prev_post, $name, $default ); }
[ "public", "function", "old", "(", "$", "name", ",", "$", "data", ",", "$", "key", "=", "null", ",", "$", "default", "=", "''", ",", "$", "checkbox", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "default", "=", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "data", ",", "$", "key", ",", "$", "default", ")", ";", "}", "elseif", "(", "$", "data", "instanceof", "\\", "stdClass", ")", "{", "$", "default", "=", "property_exists", "(", "$", "data", ",", "$", "key", ")", "?", "$", "data", "->", "$", "key", ":", "$", "default", ";", "}", "elseif", "(", "!", "isset", "(", "$", "key", ")", ")", "{", "$", "default", "=", "$", "data", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "_prev_post", ")", ")", "{", "$", "this", "->", "_prev_post", "=", "$", "this", "->", "app", "->", "session", "->", "get", "(", "$", "this", "->", "get_old_post_session_key", "(", ")", ",", "null", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "_prev_post", ")", ")", "{", "$", "this", "->", "_prev_post", "=", "[", "]", ";", "}", "$", "this", "->", "app", "->", "session", "->", "delete", "(", "$", "this", "->", "get_old_post_session_key", "(", ")", ")", ";", "}", "if", "(", "$", "checkbox", "&&", "!", "empty", "(", "$", "this", "->", "_prev_post", ")", ")", "{", "$", "default", "=", "false", ";", "}", "return", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "this", "->", "_prev_post", ",", "$", "name", ",", "$", "default", ")", ";", "}" ]
@param string $name @param mixed $data @param string|null $key @param string $default @param bool $checkbox @return mixed
[ "@param", "string", "$name", "@param", "mixed", "$data", "@param", "string|null", "$key", "@param", "string", "$default", "@param", "bool", "$checkbox" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L156-L176
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.h
public function h( $value, $translate = false, $echo = true, $escape = true, ...$args ) { if ( $translate ) { $value = $this->app->translate( $value ); } if ( ! empty( $args ) ) { $value = sprintf( $value, ...$args ); } if ( $escape ) { $value = esc_html( $value ); $value = nl2br( $value ); } if ( $echo ) { echo $value; } return $value; }
php
public function h( $value, $translate = false, $echo = true, $escape = true, ...$args ) { if ( $translate ) { $value = $this->app->translate( $value ); } if ( ! empty( $args ) ) { $value = sprintf( $value, ...$args ); } if ( $escape ) { $value = esc_html( $value ); $value = nl2br( $value ); } if ( $echo ) { echo $value; } return $value; }
[ "public", "function", "h", "(", "$", "value", ",", "$", "translate", "=", "false", ",", "$", "echo", "=", "true", ",", "$", "escape", "=", "true", ",", "...", "$", "args", ")", "{", "if", "(", "$", "translate", ")", "{", "$", "value", "=", "$", "this", "->", "app", "->", "translate", "(", "$", "value", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "args", ")", ")", "{", "$", "value", "=", "sprintf", "(", "$", "value", ",", "...", "$", "args", ")", ";", "}", "if", "(", "$", "escape", ")", "{", "$", "value", "=", "esc_html", "(", "$", "value", ")", ";", "$", "value", "=", "nl2br", "(", "$", "value", ")", ";", "}", "if", "(", "$", "echo", ")", "{", "echo", "$", "value", ";", "}", "return", "$", "value", ";", "}" ]
@param string $value @param bool $translate @param bool $echo @param bool $escape @param array $args @return string
[ "@param", "string", "$value", "@param", "bool", "$translate", "@param", "bool", "$echo", "@param", "bool", "$escape", "@param", "array", "$args" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L238-L254
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.url
public function url( $url, $contents, $translate = false, $new_tab = false, $args = [], $echo = true, $escape = true ) { $overwrite = [ 'href' => $url, 'contents' => $this->h( $contents, $translate, false, $escape ), ]; if ( $new_tab ) { $overwrite['target'] = '_blank'; } return $this->get_view( 'include/url', array_replace_recursive( $args, $overwrite ), $echo, true, true ); }
php
public function url( $url, $contents, $translate = false, $new_tab = false, $args = [], $echo = true, $escape = true ) { $overwrite = [ 'href' => $url, 'contents' => $this->h( $contents, $translate, false, $escape ), ]; if ( $new_tab ) { $overwrite['target'] = '_blank'; } return $this->get_view( 'include/url', array_replace_recursive( $args, $overwrite ), $echo, true, true ); }
[ "public", "function", "url", "(", "$", "url", ",", "$", "contents", ",", "$", "translate", "=", "false", ",", "$", "new_tab", "=", "false", ",", "$", "args", "=", "[", "]", ",", "$", "echo", "=", "true", ",", "$", "escape", "=", "true", ")", "{", "$", "overwrite", "=", "[", "'href'", "=>", "$", "url", ",", "'contents'", "=>", "$", "this", "->", "h", "(", "$", "contents", ",", "$", "translate", ",", "false", ",", "$", "escape", ")", ",", "]", ";", "if", "(", "$", "new_tab", ")", "{", "$", "overwrite", "[", "'target'", "]", "=", "'_blank'", ";", "}", "return", "$", "this", "->", "get_view", "(", "'include/url'", ",", "array_replace_recursive", "(", "$", "args", ",", "$", "overwrite", ")", ",", "$", "echo", ",", "true", ",", "true", ")", ";", "}" ]
@param string $url @param string $contents @param bool $translate @param bool $new_tab @param array $args @param bool $echo @param bool $escape @return string
[ "@param", "string", "$url", "@param", "string", "$contents", "@param", "bool", "$translate", "@param", "bool", "$new_tab", "@param", "array", "$args", "@param", "bool", "$echo", "@param", "bool", "$escape" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L310-L320
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_assets_version
private function get_assets_version( $append_version, $q = 'v' ) { if ( ! $append_version ) { return ''; } $append = trim( $this->apply_filters( 'assets_version' ) ); if ( $append !== '' ) { if ( $q ) { return '?' . $q . '=' . $append; } return '?' . $append; } return ''; }
php
private function get_assets_version( $append_version, $q = 'v' ) { if ( ! $append_version ) { return ''; } $append = trim( $this->apply_filters( 'assets_version' ) ); if ( $append !== '' ) { if ( $q ) { return '?' . $q . '=' . $append; } return '?' . $append; } return ''; }
[ "private", "function", "get_assets_version", "(", "$", "append_version", ",", "$", "q", "=", "'v'", ")", "{", "if", "(", "!", "$", "append_version", ")", "{", "return", "''", ";", "}", "$", "append", "=", "trim", "(", "$", "this", "->", "apply_filters", "(", "'assets_version'", ")", ")", ";", "if", "(", "$", "append", "!==", "''", ")", "{", "if", "(", "$", "q", ")", "{", "return", "'?'", ".", "$", "q", ".", "'='", ".", "$", "append", ";", "}", "return", "'?'", ".", "$", "append", ";", "}", "return", "''", ";", "}" ]
@since 2.0.3 Changed: trim assets_version @param bool $append_version @param string $q @return string
[ "@since", "2", ".", "0", ".", "3", "Changed", ":", "trim", "assets_version" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L330-L344
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_check_assets_dirs
private function get_check_assets_dirs( $allow_multiple = false ) { $dirs = []; if ( $this->app->is_theme ) { if ( $allow_multiple ) { $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; ! empty( $this->app->define->child_theme_assets_dir ) and $dirs[ $this->app->define->child_theme_assets_dir ] = $this->app->define->child_theme_assets_url; } else { ! empty( $this->app->define->child_theme_assets_dir ) and $dirs[ $this->app->define->child_theme_assets_dir ] = $this->app->define->child_theme_assets_url; $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; } } else { $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; } return $this->apply_filters( 'check_assets_dirs', $dirs ); }
php
private function get_check_assets_dirs( $allow_multiple = false ) { $dirs = []; if ( $this->app->is_theme ) { if ( $allow_multiple ) { $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; ! empty( $this->app->define->child_theme_assets_dir ) and $dirs[ $this->app->define->child_theme_assets_dir ] = $this->app->define->child_theme_assets_url; } else { ! empty( $this->app->define->child_theme_assets_dir ) and $dirs[ $this->app->define->child_theme_assets_dir ] = $this->app->define->child_theme_assets_url; $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; } } else { $dirs[ $this->app->define->plugin_assets_dir ] = $this->app->define->plugin_assets_url; $dirs[ $this->app->define->lib_assets_dir ] = $this->app->define->lib_assets_url; } return $this->apply_filters( 'check_assets_dirs', $dirs ); }
[ "private", "function", "get_check_assets_dirs", "(", "$", "allow_multiple", "=", "false", ")", "{", "$", "dirs", "=", "[", "]", ";", "if", "(", "$", "this", "->", "app", "->", "is_theme", ")", "{", "if", "(", "$", "allow_multiple", ")", "{", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "lib_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "lib_assets_url", ";", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_url", ";", "!", "empty", "(", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_dir", ")", "and", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_url", ";", "}", "else", "{", "!", "empty", "(", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_dir", ")", "and", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "child_theme_assets_url", ";", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_url", ";", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "lib_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "lib_assets_url", ";", "}", "}", "else", "{", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "plugin_assets_url", ";", "$", "dirs", "[", "$", "this", "->", "app", "->", "define", "->", "lib_assets_dir", "]", "=", "$", "this", "->", "app", "->", "define", "->", "lib_assets_url", ";", "}", "return", "$", "this", "->", "apply_filters", "(", "'check_assets_dirs'", ",", "$", "dirs", ")", ";", "}" ]
@since 2.10.1 Added: $allow_multiple param @since 2.10.1 Improved: for theme (#115) @param bool $allow_multiple @return array
[ "@since", "2", ".", "10", ".", "1", "Added", ":", "$allow_multiple", "param", "@since", "2", ".", "10", ".", "1", "Improved", ":", "for", "theme", "(", "#115", ")" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L354-L372
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_assets
private function get_assets( $path, $default = '', $url = false, $append_version = true ) { if ( empty( $path ) ) { return ''; } $path = trim( $path ); $path = trim( $path, '/' . DS ); $path = str_replace( '/', DS, $path ); foreach ( $this->get_check_assets_dirs() as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { if ( $url ) { return rtrim( $_url, '/' ) . '/' . str_replace( DS, '/', $path ) . $this->apply_filters( 'get_assets_version', $this->get_assets_version( $append_version ), $append_version ); } return $_dir . DS . $path; } } if ( empty( $default ) ) { return ''; } return $this->get_assets( $default, '', $url, false ); }
php
private function get_assets( $path, $default = '', $url = false, $append_version = true ) { if ( empty( $path ) ) { return ''; } $path = trim( $path ); $path = trim( $path, '/' . DS ); $path = str_replace( '/', DS, $path ); foreach ( $this->get_check_assets_dirs() as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { if ( $url ) { return rtrim( $_url, '/' ) . '/' . str_replace( DS, '/', $path ) . $this->apply_filters( 'get_assets_version', $this->get_assets_version( $append_version ), $append_version ); } return $_dir . DS . $path; } } if ( empty( $default ) ) { return ''; } return $this->get_assets( $default, '', $url, false ); }
[ "private", "function", "get_assets", "(", "$", "path", ",", "$", "default", "=", "''", ",", "$", "url", "=", "false", ",", "$", "append_version", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "return", "''", ";", "}", "$", "path", "=", "trim", "(", "$", "path", ")", ";", "$", "path", "=", "trim", "(", "$", "path", ",", "'/'", ".", "DS", ")", ";", "$", "path", "=", "str_replace", "(", "'/'", ",", "DS", ",", "$", "path", ")", ";", "foreach", "(", "$", "this", "->", "get_check_assets_dirs", "(", ")", "as", "$", "_dir", "=>", "$", "_url", ")", "{", "$", "_dir", "=", "rtrim", "(", "$", "_dir", ",", "DS", ".", "'/'", ")", ";", "if", "(", "file_exists", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", "&&", "is_file", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", ")", "{", "if", "(", "$", "url", ")", "{", "return", "rtrim", "(", "$", "_url", ",", "'/'", ")", ".", "'/'", ".", "str_replace", "(", "DS", ",", "'/'", ",", "$", "path", ")", ".", "$", "this", "->", "apply_filters", "(", "'get_assets_version'", ",", "$", "this", "->", "get_assets_version", "(", "$", "append_version", ")", ",", "$", "append_version", ")", ";", "}", "return", "$", "_dir", ".", "DS", ".", "$", "path", ";", "}", "}", "if", "(", "empty", "(", "$", "default", ")", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "get_assets", "(", "$", "default", ",", "''", ",", "$", "url", ",", "false", ")", ";", "}" ]
@param string $path @param string $default @param bool $url @param bool $append_version @return string
[ "@param", "string", "$path", "@param", "string", "$default", "@param", "bool", "$url", "@param", "bool", "$append_version" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L382-L406
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.get_img_url
public function get_img_url( $path, $default = 'img/no_img.png', $append_version = true ) { return empty( $path ) ? '' : $this->get_assets_url( 'img/' . $path, $default, $append_version ); }
php
public function get_img_url( $path, $default = 'img/no_img.png', $append_version = true ) { return empty( $path ) ? '' : $this->get_assets_url( 'img/' . $path, $default, $append_version ); }
[ "public", "function", "get_img_url", "(", "$", "path", ",", "$", "default", "=", "'img/no_img.png'", ",", "$", "append_version", "=", "true", ")", "{", "return", "empty", "(", "$", "path", ")", "?", "''", ":", "$", "this", "->", "get_assets_url", "(", "'img/'", ".", "$", "path", ",", "$", "default", ",", "$", "append_version", ")", ";", "}" ]
@param string $path @param string $default @param bool $append_version @return string
[ "@param", "string", "$path", "@param", "string", "$default", "@param", "bool", "$append_version" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L436-L438
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.assets
public function assets( $url, $view, $args, $field, $echo = true ) { return $this->get_view( $view, array_merge( $args, [ $field => $url, ] ), $echo, true, true ); }
php
public function assets( $url, $view, $args, $field, $echo = true ) { return $this->get_view( $view, array_merge( $args, [ $field => $url, ] ), $echo, true, true ); }
[ "public", "function", "assets", "(", "$", "url", ",", "$", "view", ",", "$", "args", ",", "$", "field", ",", "$", "echo", "=", "true", ")", "{", "return", "$", "this", "->", "get_view", "(", "$", "view", ",", "array_merge", "(", "$", "args", ",", "[", "$", "field", "=>", "$", "url", ",", "]", ")", ",", "$", "echo", ",", "true", ",", "true", ")", ";", "}" ]
@param string $url @param string $view @param array $args @param string $field @param bool $echo @return string
[ "@param", "string", "$url", "@param", "string", "$view", "@param", "array", "$args", "@param", "string", "$field", "@param", "bool", "$echo" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L469-L473
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.img
public function img( $path, $args = [], $echo = true ) { return $this->assets( $this->get_img_url( $path ), 'include/img', $args, 'src', $echo ); }
php
public function img( $path, $args = [], $echo = true ) { return $this->assets( $this->get_img_url( $path ), 'include/img', $args, 'src', $echo ); }
[ "public", "function", "img", "(", "$", "path", ",", "$", "args", "=", "[", "]", ",", "$", "echo", "=", "true", ")", "{", "return", "$", "this", "->", "assets", "(", "$", "this", "->", "get_img_url", "(", "$", "path", ")", ",", "'include/img'", ",", "$", "args", ",", "'src'", ",", "$", "echo", ")", ";", "}" ]
@param string $path @param array $args @param bool $echo @return string
[ "@param", "string", "$path", "@param", "array", "$args", "@param", "bool", "$echo" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L482-L484
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.css
public function css( $path, $priority = 10 ) { $css = $this->get_css_path( $path ); if ( ! empty( $css ) ) { $this->app->minify->register_css_file( $css, $priority ); return true; } return false; }
php
public function css( $path, $priority = 10 ) { $css = $this->get_css_path( $path ); if ( ! empty( $css ) ) { $this->app->minify->register_css_file( $css, $priority ); return true; } return false; }
[ "public", "function", "css", "(", "$", "path", ",", "$", "priority", "=", "10", ")", "{", "$", "css", "=", "$", "this", "->", "get_css_path", "(", "$", "path", ")", ";", "if", "(", "!", "empty", "(", "$", "css", ")", ")", "{", "$", "this", "->", "app", "->", "minify", "->", "register_css_file", "(", "$", "css", ",", "$", "priority", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
@param string $path @param int $priority @return bool
[ "@param", "string", "$path", "@param", "int", "$priority" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L512-L521
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.js
public function js( $path, $priority = 10 ) { $js = $this->get_js_path( $path ); if ( ! empty( $js ) ) { $this->app->minify->register_js_file( $js, $priority ); return true; } return false; }
php
public function js( $path, $priority = 10 ) { $js = $this->get_js_path( $path ); if ( ! empty( $js ) ) { $this->app->minify->register_js_file( $js, $priority ); return true; } return false; }
[ "public", "function", "js", "(", "$", "path", ",", "$", "priority", "=", "10", ")", "{", "$", "js", "=", "$", "this", "->", "get_js_path", "(", "$", "path", ")", ";", "if", "(", "!", "empty", "(", "$", "js", ")", ")", "{", "$", "this", "->", "app", "->", "minify", "->", "register_js_file", "(", "$", "js", ",", "$", "priority", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
@param string $path @param int $priority @return bool
[ "@param", "string", "$path", "@param", "int", "$priority" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L529-L538
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.enqueue_style
public function enqueue_style( $handle, $file, $depends = [], $ver = false, $media = 'all', $dir = 'css' ) { $path = $dir . DS . $file; $result = false; $_handle = $handle; $index = 0; foreach ( $this->get_check_assets_dirs( true ) as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { wp_enqueue_style( $handle, $_url . '/' . $dir . '/' . $file, $depends, $ver, $media ); if ( ! $this->app->is_theme ) { return true; } $result = true; $handle = "{$_handle}-{$index}"; $index ++; } } return $result; }
php
public function enqueue_style( $handle, $file, $depends = [], $ver = false, $media = 'all', $dir = 'css' ) { $path = $dir . DS . $file; $result = false; $_handle = $handle; $index = 0; foreach ( $this->get_check_assets_dirs( true ) as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { wp_enqueue_style( $handle, $_url . '/' . $dir . '/' . $file, $depends, $ver, $media ); if ( ! $this->app->is_theme ) { return true; } $result = true; $handle = "{$_handle}-{$index}"; $index ++; } } return $result; }
[ "public", "function", "enqueue_style", "(", "$", "handle", ",", "$", "file", ",", "$", "depends", "=", "[", "]", ",", "$", "ver", "=", "false", ",", "$", "media", "=", "'all'", ",", "$", "dir", "=", "'css'", ")", "{", "$", "path", "=", "$", "dir", ".", "DS", ".", "$", "file", ";", "$", "result", "=", "false", ";", "$", "_handle", "=", "$", "handle", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "this", "->", "get_check_assets_dirs", "(", "true", ")", "as", "$", "_dir", "=>", "$", "_url", ")", "{", "$", "_dir", "=", "rtrim", "(", "$", "_dir", ",", "DS", ".", "'/'", ")", ";", "if", "(", "file_exists", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", "&&", "is_file", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", ")", "{", "wp_enqueue_style", "(", "$", "handle", ",", "$", "_url", ".", "'/'", ".", "$", "dir", ".", "'/'", ".", "$", "file", ",", "$", "depends", ",", "$", "ver", ",", "$", "media", ")", ";", "if", "(", "!", "$", "this", "->", "app", "->", "is_theme", ")", "{", "return", "true", ";", "}", "$", "result", "=", "true", ";", "$", "handle", "=", "\"{$_handle}-{$index}\"", ";", "$", "index", "++", ";", "}", "}", "return", "$", "result", ";", "}" ]
@since 2.10.1 Improved: for theme (#115) @param string $handle @param string $file @param array $depends @param string|bool|null $ver @param string $media @param string $dir @return bool
[ "@since", "2", ".", "10", ".", "1", "Improved", ":", "for", "theme", "(", "#115", ")" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L552-L572
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.enqueue_script
public function enqueue_script( $handle, $file, $depends = [], $ver = false, $in_footer = true, $dir = 'js' ) { $path = $dir . DS . $file; $result = false; $_handle = $handle; $index = 0; foreach ( $this->get_check_assets_dirs( true ) as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { wp_enqueue_script( $handle, $_url . '/' . $dir . '/' . $file, $depends, $ver, $in_footer ); if ( ! $this->app->is_theme ) { return true; } $result = true; $handle = "{$_handle}-{$index}"; $index ++; } } return $result; }
php
public function enqueue_script( $handle, $file, $depends = [], $ver = false, $in_footer = true, $dir = 'js' ) { $path = $dir . DS . $file; $result = false; $_handle = $handle; $index = 0; foreach ( $this->get_check_assets_dirs( true ) as $_dir => $_url ) { $_dir = rtrim( $_dir, DS . '/' ); if ( file_exists( $_dir . DS . $path ) && is_file( $_dir . DS . $path ) ) { wp_enqueue_script( $handle, $_url . '/' . $dir . '/' . $file, $depends, $ver, $in_footer ); if ( ! $this->app->is_theme ) { return true; } $result = true; $handle = "{$_handle}-{$index}"; $index ++; } } return $result; }
[ "public", "function", "enqueue_script", "(", "$", "handle", ",", "$", "file", ",", "$", "depends", "=", "[", "]", ",", "$", "ver", "=", "false", ",", "$", "in_footer", "=", "true", ",", "$", "dir", "=", "'js'", ")", "{", "$", "path", "=", "$", "dir", ".", "DS", ".", "$", "file", ";", "$", "result", "=", "false", ";", "$", "_handle", "=", "$", "handle", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "this", "->", "get_check_assets_dirs", "(", "true", ")", "as", "$", "_dir", "=>", "$", "_url", ")", "{", "$", "_dir", "=", "rtrim", "(", "$", "_dir", ",", "DS", ".", "'/'", ")", ";", "if", "(", "file_exists", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", "&&", "is_file", "(", "$", "_dir", ".", "DS", ".", "$", "path", ")", ")", "{", "wp_enqueue_script", "(", "$", "handle", ",", "$", "_url", ".", "'/'", ".", "$", "dir", ".", "'/'", ".", "$", "file", ",", "$", "depends", ",", "$", "ver", ",", "$", "in_footer", ")", ";", "if", "(", "!", "$", "this", "->", "app", "->", "is_theme", ")", "{", "return", "true", ";", "}", "$", "result", "=", "true", ";", "$", "handle", "=", "\"{$_handle}-{$index}\"", ";", "$", "index", "++", ";", "}", "}", "return", "$", "result", ";", "}" ]
@since 2.10.1 Improved: for theme (#115) @param string $handle @param string $file @param array $depends @param string|bool|null $ver @param bool $in_footer @param string $dir @return bool
[ "@since", "2", ".", "10", ".", "1", "Improved", ":", "for", "theme", "(", "#115", ")" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L586-L606
technote-space/wordpress-plugin-base
src/traits/presenter.php
Presenter.set_script_translations
public function set_script_translations( $handle ) { if ( $this->_set_script_translations ) { return; } $this->_set_script_translations = true; $text_domain = $this->app->get_text_domain(); if ( empty( $text_domain ) ) { return; } if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( $handle, $text_domain ); } elseif ( function_exists( 'wp_get_jed_locale_data' ) || function_exists( 'gutenberg_get_jed_locale_data' ) ) { $json = function_exists( 'wp_get_jed_locale_data' ) ? wp_get_jed_locale_data( $text_domain ) : gutenberg_get_jed_locale_data( $text_domain ); wp_add_inline_script( 'wp-i18n', sprintf( 'wp.i18n.setLocaleData( %s, "%s" );', wp_json_encode( $json ), $text_domain ), 'after' ); } }
php
public function set_script_translations( $handle ) { if ( $this->_set_script_translations ) { return; } $this->_set_script_translations = true; $text_domain = $this->app->get_text_domain(); if ( empty( $text_domain ) ) { return; } if ( function_exists( 'wp_set_script_translations' ) ) { wp_set_script_translations( $handle, $text_domain ); } elseif ( function_exists( 'wp_get_jed_locale_data' ) || function_exists( 'gutenberg_get_jed_locale_data' ) ) { $json = function_exists( 'wp_get_jed_locale_data' ) ? wp_get_jed_locale_data( $text_domain ) : gutenberg_get_jed_locale_data( $text_domain ); wp_add_inline_script( 'wp-i18n', sprintf( 'wp.i18n.setLocaleData( %s, "%s" );', wp_json_encode( $json ), $text_domain ), 'after' ); } }
[ "public", "function", "set_script_translations", "(", "$", "handle", ")", "{", "if", "(", "$", "this", "->", "_set_script_translations", ")", "{", "return", ";", "}", "$", "this", "->", "_set_script_translations", "=", "true", ";", "$", "text_domain", "=", "$", "this", "->", "app", "->", "get_text_domain", "(", ")", ";", "if", "(", "empty", "(", "$", "text_domain", ")", ")", "{", "return", ";", "}", "if", "(", "function_exists", "(", "'wp_set_script_translations'", ")", ")", "{", "wp_set_script_translations", "(", "$", "handle", ",", "$", "text_domain", ")", ";", "}", "elseif", "(", "function_exists", "(", "'wp_get_jed_locale_data'", ")", "||", "function_exists", "(", "'gutenberg_get_jed_locale_data'", ")", ")", "{", "$", "json", "=", "function_exists", "(", "'wp_get_jed_locale_data'", ")", "?", "wp_get_jed_locale_data", "(", "$", "text_domain", ")", ":", "gutenberg_get_jed_locale_data", "(", "$", "text_domain", ")", ";", "wp_add_inline_script", "(", "'wp-i18n'", ",", "sprintf", "(", "'wp.i18n.setLocaleData( %s, \"%s\" );'", ",", "wp_json_encode", "(", "$", "json", ")", ",", "$", "text_domain", ")", ",", "'after'", ")", ";", "}", "}" ]
@since 1.1.73 @param string $handle
[ "@since", "1", ".", "1", ".", "73" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/presenter.php#L658-L678
ekuiter/feature-php
FeaturePhp/ProductLine/ProductRenderer.php
ProductRenderer._render
public function _render($textOnly) { $featureNum = count($this->product->getConfiguration()->getSelectedFeatures()); $fileNum = count($this->files); $str = ""; $maxLen = fphp\Helper\_String::getMaxLength($this->files, "getTarget"); if ($textOnly) $str .= "\nProduct Analysis\n================\n" . "For the given product, $featureNum features were selected and the following $fileNum files were generated:\n\n"; else { $str .= "<h2>Product Analysis</h2>"; $str .= "<div>"; $str .= "<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>"; $str .= "<ul>"; } foreach ($this->files as $file) { $summary = $file->getContent()->getSummary(); if ($textOnly) { $str .= sprintf("$this->accentColor%-{$maxLen}s$this->defaultColor %s\n", $file->getTarget(), fphp\Helper\_String::truncate($summary)); } else $str .= "<li><span class='fileName' onclick='var style = this.parentElement.children[1].style; style.display = style.display === \"block\" ? \"none\" : \"block\";'>" . $file->getTarget() . "</span><pre style='font-size: 0.8em; display: none'>" . str_replace("\n", "<br />", htmlspecialchars($summary)) . "</pre>" . "</li>"; } if (!$textOnly) { $str .= "</ul>"; $str .= "</div>"; } $str .= (new fphp\Artifact\TracingLinkRenderer($this->tracingLinks))->render($textOnly); return $str; }
php
public function _render($textOnly) { $featureNum = count($this->product->getConfiguration()->getSelectedFeatures()); $fileNum = count($this->files); $str = ""; $maxLen = fphp\Helper\_String::getMaxLength($this->files, "getTarget"); if ($textOnly) $str .= "\nProduct Analysis\n================\n" . "For the given product, $featureNum features were selected and the following $fileNum files were generated:\n\n"; else { $str .= "<h2>Product Analysis</h2>"; $str .= "<div>"; $str .= "<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>"; $str .= "<ul>"; } foreach ($this->files as $file) { $summary = $file->getContent()->getSummary(); if ($textOnly) { $str .= sprintf("$this->accentColor%-{$maxLen}s$this->defaultColor %s\n", $file->getTarget(), fphp\Helper\_String::truncate($summary)); } else $str .= "<li><span class='fileName' onclick='var style = this.parentElement.children[1].style; style.display = style.display === \"block\" ? \"none\" : \"block\";'>" . $file->getTarget() . "</span><pre style='font-size: 0.8em; display: none'>" . str_replace("\n", "<br />", htmlspecialchars($summary)) . "</pre>" . "</li>"; } if (!$textOnly) { $str .= "</ul>"; $str .= "</div>"; } $str .= (new fphp\Artifact\TracingLinkRenderer($this->tracingLinks))->render($textOnly); return $str; }
[ "public", "function", "_render", "(", "$", "textOnly", ")", "{", "$", "featureNum", "=", "count", "(", "$", "this", "->", "product", "->", "getConfiguration", "(", ")", "->", "getSelectedFeatures", "(", ")", ")", ";", "$", "fileNum", "=", "count", "(", "$", "this", "->", "files", ")", ";", "$", "str", "=", "\"\"", ";", "$", "maxLen", "=", "fphp", "\\", "Helper", "\\", "_String", "::", "getMaxLength", "(", "$", "this", "->", "files", ",", "\"getTarget\"", ")", ";", "if", "(", "$", "textOnly", ")", "$", "str", ".=", "\"\\nProduct Analysis\\n================\\n\"", ".", "\"For the given product, $featureNum features were selected and the following $fileNum files were generated:\\n\\n\"", ";", "else", "{", "$", "str", ".=", "\"<h2>Product Analysis</h2>\"", ";", "$", "str", ".=", "\"<div>\"", ";", "$", "str", ".=", "\"<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>\"", ";", "$", "str", ".=", "\"<ul>\"", ";", "}", "foreach", "(", "$", "this", "->", "files", "as", "$", "file", ")", "{", "$", "summary", "=", "$", "file", "->", "getContent", "(", ")", "->", "getSummary", "(", ")", ";", "if", "(", "$", "textOnly", ")", "{", "$", "str", ".=", "sprintf", "(", "\"$this->accentColor%-{$maxLen}s$this->defaultColor %s\\n\"", ",", "$", "file", "->", "getTarget", "(", ")", ",", "fphp", "\\", "Helper", "\\", "_String", "::", "truncate", "(", "$", "summary", ")", ")", ";", "}", "else", "$", "str", ".=", "\"<li><span class='fileName' onclick='var style = this.parentElement.children[1].style;\n style.display = style.display === \\\"block\\\" ? \\\"none\\\" : \\\"block\\\";'>\"", ".", "$", "file", "->", "getTarget", "(", ")", ".", "\"</span><pre style='font-size: 0.8em; display: none'>\"", ".", "str_replace", "(", "\"\\n\"", ",", "\"<br />\"", ",", "htmlspecialchars", "(", "$", "summary", ")", ")", ".", "\"</pre>\"", ".", "\"</li>\"", ";", "}", "if", "(", "!", "$", "textOnly", ")", "{", "$", "str", ".=", "\"</ul>\"", ";", "$", "str", ".=", "\"</div>\"", ";", "}", "$", "str", ".=", "(", "new", "fphp", "\\", "Artifact", "\\", "TracingLinkRenderer", "(", "$", "this", "->", "tracingLinks", ")", ")", "->", "render", "(", "$", "textOnly", ")", ";", "return", "$", "str", ";", "}" ]
Returns the product analysis. @param bool $textOnly whether to render text or HTML @return string
[ "Returns", "the", "product", "analysis", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductRenderer.php#L47-L85
eghojansu/moe
src/AbstractModel.php
AbstractModel.table
public function table() { if (!$this->_properties['table_name']) { $class = explode('\\', get_called_class()); $this->_properties['table_name'] = Instance::snakecase(lcfirst(end($class))); } return $this->_properties['table_name']; }
php
public function table() { if (!$this->_properties['table_name']) { $class = explode('\\', get_called_class()); $this->_properties['table_name'] = Instance::snakecase(lcfirst(end($class))); } return $this->_properties['table_name']; }
[ "public", "function", "table", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_properties", "[", "'table_name'", "]", ")", "{", "$", "class", "=", "explode", "(", "'\\\\'", ",", "get_called_class", "(", ")", ")", ";", "$", "this", "->", "_properties", "[", "'table_name'", "]", "=", "Instance", "::", "snakecase", "(", "lcfirst", "(", "end", "(", "$", "class", ")", ")", ")", ";", "}", "return", "$", "this", "->", "_properties", "[", "'table_name'", "]", ";", "}" ]
Return table name
[ "Return", "table", "name" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L160-L168
eghojansu/moe
src/AbstractModel.php
AbstractModel.field
public function field($name) { return isset($this->_properties['fields'][$name])? $this->_properties['fields'][$name]:null; }
php
public function field($name) { return isset($this->_properties['fields'][$name])? $this->_properties['fields'][$name]:null; }
[ "public", "function", "field", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "_properties", "[", "'fields'", "]", "[", "$", "name", "]", ")", "?", "$", "this", "->", "_properties", "[", "'fields'", "]", "[", "$", "name", "]", ":", "null", ";", "}" ]
return field alias
[ "return", "field", "alias" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L278-L282