repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
SpoonX/SxBootstrap
src/SxBootstrap/View/Helper/Bootstrap/Form/Row.php
Row.renderError
protected function renderError(ElementInterface $element) { $messages = $element->getMessages(); if (empty($messages)) { return null; } $errorPlugin = $this->getView()->plugin('sxb_form_errors'); return $errorPlugin($element); }
php
protected function renderError(ElementInterface $element) { $messages = $element->getMessages(); if (empty($messages)) { return null; } $errorPlugin = $this->getView()->plugin('sxb_form_errors'); return $errorPlugin($element); }
[ "protected", "function", "renderError", "(", "ElementInterface", "$", "element", ")", "{", "$", "messages", "=", "$", "element", "->", "getMessages", "(", ")", ";", "if", "(", "empty", "(", "$", "messages", ")", ")", "{", "return", "null", ";", "}", "$", "errorPlugin", "=", "$", "this", "->", "getView", "(", ")", "->", "plugin", "(", "'sxb_form_errors'", ")", ";", "return", "$", "errorPlugin", "(", "$", "element", ")", ";", "}" ]
Render errors. @param ElementInterface $element @return null|\SxBootstrap\View\Helper\Bootstrap\Form\Errors
[ "Render", "errors", "." ]
768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6
https://github.com/SpoonX/SxBootstrap/blob/768b02e3b65f7dfe560e821cb0ff41ad3f86b3b6/src/SxBootstrap/View/Helper/Bootstrap/Form/Row.php#L134-L145
train
ben-gibson/foursquare-venue-client
src/Factory/Tip/TipGroupFactory.php
TipGroupFactory.getTips
private function getTips(Description $description) { return array_map( function (\stdClass $tipDescription) { return $this->tipFactory->create(new Description($tipDescription)); }, $description->getOptionalProperty('items', []) ); }
php
private function getTips(Description $description) { return array_map( function (\stdClass $tipDescription) { return $this->tipFactory->create(new Description($tipDescription)); }, $description->getOptionalProperty('items', []) ); }
[ "private", "function", "getTips", "(", "Description", "$", "description", ")", "{", "return", "array_map", "(", "function", "(", "\\", "stdClass", "$", "tipDescription", ")", "{", "return", "$", "this", "->", "tipFactory", "->", "create", "(", "new", "Description", "(", "$", "tipDescription", ")", ")", ";", "}", ",", "$", "description", "->", "getOptionalProperty", "(", "'items'", ",", "[", "]", ")", ")", ";", "}" ]
Get the venue tips. @param Description $description The tip group description. @return Tip[]
[ "Get", "the", "venue", "tips", "." ]
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Factory/Tip/TipGroupFactory.php#L49-L57
train
imatic/controller-bundle
Resource/ConfigurationProcessor.php
ConfigurationProcessor.arrayMap
public static function arrayMap(callable $callback, array $array) { foreach ($array as $key => $value) { $array[$key] = \call_user_func($callback, $value, $key); } return $array; }
php
public static function arrayMap(callable $callback, array $array) { foreach ($array as $key => $value) { $array[$key] = \call_user_func($callback, $value, $key); } return $array; }
[ "public", "static", "function", "arrayMap", "(", "callable", "$", "callback", ",", "array", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "array", "[", "$", "key", "]", "=", "\\", "call_user_func", "(", "$", "callback", ",", "$", "value", ",", "$", "key", ")", ";", "}", "return", "$", "array", ";", "}" ]
- array keys are available in callback - array keys have not been changed
[ "-", "array", "keys", "are", "available", "in", "callback", "-", "array", "keys", "have", "not", "been", "changed" ]
df71c12166928f9d4f1548d4ee1e09a183a68eb6
https://github.com/imatic/controller-bundle/blob/df71c12166928f9d4f1548d4ee1e09a183a68eb6/Resource/ConfigurationProcessor.php#L203-L210
train
danhanly/signalert
src/Signalert/Config.php
Config.expandConfigDirectories
private function expandConfigDirectories() { $newPaths = []; foreach ($this->configDirectories as $filePath) { $newPaths[] = __DIR__ . '/../../../../../' . $filePath; } $this->configDirectories = $newPaths; }
php
private function expandConfigDirectories() { $newPaths = []; foreach ($this->configDirectories as $filePath) { $newPaths[] = __DIR__ . '/../../../../../' . $filePath; } $this->configDirectories = $newPaths; }
[ "private", "function", "expandConfigDirectories", "(", ")", "{", "$", "newPaths", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "configDirectories", "as", "$", "filePath", ")", "{", "$", "newPaths", "[", "]", "=", "__DIR__", ".", "'/../../../../../'", ".", "$", "filePath", ";", "}", "$", "this", "->", "configDirectories", "=", "$", "newPaths", ";", "}" ]
Ensures that config directories are relative paths
[ "Ensures", "that", "config", "directories", "are", "relative", "paths" ]
21ee50e3fc0352306a2966b555984b5c9eada582
https://github.com/danhanly/signalert/blob/21ee50e3fc0352306a2966b555984b5c9eada582/src/Signalert/Config.php#L114-L121
train
neneaX/IoC
src/Container.php
Container.register
public function register($alias, $binding, $shared = false) { $this->registry[$alias] = new Resolver(new Builder($binding), $shared); }
php
public function register($alias, $binding, $shared = false) { $this->registry[$alias] = new Resolver(new Builder($binding), $shared); }
[ "public", "function", "register", "(", "$", "alias", ",", "$", "binding", ",", "$", "shared", "=", "false", ")", "{", "$", "this", "->", "registry", "[", "$", "alias", "]", "=", "new", "Resolver", "(", "new", "Builder", "(", "$", "binding", ")", ",", "$", "shared", ")", ";", "}" ]
Register a binding with the registry @param string $alias The alias used for registering the binding @param \Closure|object|string|null $binding The binding requested to register @param boolean $shared The type of the binding: shared (singleton) or not
[ "Register", "a", "binding", "with", "the", "registry" ]
404888c3252880f8bb48253f9aa636cd7c396416
https://github.com/neneaX/IoC/blob/404888c3252880f8bb48253f9aa636cd7c396416/src/Container.php#L108-L111
train
neneaX/IoC
src/Container.php
Container.resolve
public function resolve($alias, array $parameters = array(), $force = false) { if ($this->registered($alias)) { $resolver = $this->registry[$alias]; return $resolver->execute($parameters, $force); } throw new \Exception('No class found registered with that name: ' . $alias); }
php
public function resolve($alias, array $parameters = array(), $force = false) { if ($this->registered($alias)) { $resolver = $this->registry[$alias]; return $resolver->execute($parameters, $force); } throw new \Exception('No class found registered with that name: ' . $alias); }
[ "public", "function", "resolve", "(", "$", "alias", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "$", "force", "=", "false", ")", "{", "if", "(", "$", "this", "->", "registered", "(", "$", "alias", ")", ")", "{", "$", "resolver", "=", "$", "this", "->", "registry", "[", "$", "alias", "]", ";", "return", "$", "resolver", "->", "execute", "(", "$", "parameters", ",", "$", "force", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'No class found registered with that name: '", ".", "$", "alias", ")", ";", "}" ]
Execute the Resolver and return the requested binding instance @param string $alias The registered binding's alias @param array $parameters @param boolean $force Force the overriding of the "shared" option and return a new instance of the requested binding @return object @throws \Exception When no resolver is found for the handle name.
[ "Execute", "the", "Resolver", "and", "return", "the", "requested", "binding", "instance" ]
404888c3252880f8bb48253f9aa636cd7c396416
https://github.com/neneaX/IoC/blob/404888c3252880f8bb48253f9aa636cd7c396416/src/Container.php#L134-L143
train
acacha/forge-publish
src/Console/Commands/PublishUpdateAssignment.php
PublishUpdateAssignment.updateAssignment
protected function updateAssignment() { $uri = str_replace('{assignment}', $this->assignment, config('forge-publish.update_assignment_uri')); $url = config('forge-publish.url') . $uri; try { $response = $this->http->put($url, [ 'form_params' => [ 'name' => $this->assignmentName, 'repository_uri' => $this->repository_uri, 'repository_type' => $this->repository_type, 'forge_site' => $this->forge_site, 'forge_server' => $this->forge_server ], 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ]); } catch (\Exception $e) { $this->error('And error occurs connecting to the api url: ' . $url); $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase()); return []; } return json_decode((string) $response->getBody()); }
php
protected function updateAssignment() { $uri = str_replace('{assignment}', $this->assignment, config('forge-publish.update_assignment_uri')); $url = config('forge-publish.url') . $uri; try { $response = $this->http->put($url, [ 'form_params' => [ 'name' => $this->assignmentName, 'repository_uri' => $this->repository_uri, 'repository_type' => $this->repository_type, 'forge_site' => $this->forge_site, 'forge_server' => $this->forge_server ], 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ]); } catch (\Exception $e) { $this->error('And error occurs connecting to the api url: ' . $url); $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase()); return []; } return json_decode((string) $response->getBody()); }
[ "protected", "function", "updateAssignment", "(", ")", "{", "$", "uri", "=", "str_replace", "(", "'{assignment}'", ",", "$", "this", "->", "assignment", ",", "config", "(", "'forge-publish.update_assignment_uri'", ")", ")", ";", "$", "url", "=", "config", "(", "'forge-publish.url'", ")", ".", "$", "uri", ";", "try", "{", "$", "response", "=", "$", "this", "->", "http", "->", "put", "(", "$", "url", ",", "[", "'form_params'", "=>", "[", "'name'", "=>", "$", "this", "->", "assignmentName", ",", "'repository_uri'", "=>", "$", "this", "->", "repository_uri", ",", "'repository_type'", "=>", "$", "this", "->", "repository_type", ",", "'forge_site'", "=>", "$", "this", "->", "forge_site", ",", "'forge_server'", "=>", "$", "this", "->", "forge_server", "]", ",", "'headers'", "=>", "[", "'X-Requested-With'", "=>", "'XMLHttpRequest'", ",", "'Authorization'", "=>", "'Bearer '", ".", "fp_env", "(", "'ACACHA_FORGE_ACCESS_TOKEN'", ")", "]", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "error", "(", "'And error occurs connecting to the api url: '", ".", "$", "url", ")", ";", "$", "this", "->", "error", "(", "'Status code: '", ".", "$", "e", "->", "getResponse", "(", ")", "->", "getStatusCode", "(", ")", ".", "' | Reason : '", ".", "$", "e", "->", "getResponse", "(", ")", "->", "getReasonPhrase", "(", ")", ")", ";", "return", "[", "]", ";", "}", "return", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ")", ";", "}" ]
Update assignment. @return array|mixed
[ "Update", "assignment", "." ]
010779e3d2297c763b82dc3fbde992edffb3a6c6
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishUpdateAssignment.php#L130-L154
train
austinkregel/formmodel
src/FormModel/Frameworks/Bootstrap.php
Bootstrap.form
public function form(array $options = []) { $method = empty($options['method']) ? $options['method'] : ''; if (in_array(strtolower($method), ['get', 'post'])) { $real_method = $method; } else { $real_method = 'POST'; } $options['method'] = $real_method; $options['action'] = $this->location; return '<form '.$this->attributes($options).'>'.// Pass the method through so the form knows how to handle it's self (with laravel) $this->method($method).// Check and fill the csrf token if it's configured for it. $this->csrf().$this->buildForm().$this->submit([]).'</form>'; }
php
public function form(array $options = []) { $method = empty($options['method']) ? $options['method'] : ''; if (in_array(strtolower($method), ['get', 'post'])) { $real_method = $method; } else { $real_method = 'POST'; } $options['method'] = $real_method; $options['action'] = $this->location; return '<form '.$this->attributes($options).'>'.// Pass the method through so the form knows how to handle it's self (with laravel) $this->method($method).// Check and fill the csrf token if it's configured for it. $this->csrf().$this->buildForm().$this->submit([]).'</form>'; }
[ "public", "function", "form", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "method", "=", "empty", "(", "$", "options", "[", "'method'", "]", ")", "?", "$", "options", "[", "'method'", "]", ":", "''", ";", "if", "(", "in_array", "(", "strtolower", "(", "$", "method", ")", ",", "[", "'get'", ",", "'post'", "]", ")", ")", "{", "$", "real_method", "=", "$", "method", ";", "}", "else", "{", "$", "real_method", "=", "'POST'", ";", "}", "$", "options", "[", "'method'", "]", "=", "$", "real_method", ";", "$", "options", "[", "'action'", "]", "=", "$", "this", "->", "location", ";", "return", "'<form '", ".", "$", "this", "->", "attributes", "(", "$", "options", ")", ".", "'>'", ".", "// Pass the method through so the form knows how to handle it's self (with laravel)", "$", "this", "->", "method", "(", "$", "method", ")", ".", "// Check and fill the csrf token if it's configured for it.", "$", "this", "->", "csrf", "(", ")", ".", "$", "this", "->", "buildForm", "(", ")", ".", "$", "this", "->", "submit", "(", "[", "]", ")", ".", "'</form>'", ";", "}" ]
Generate the form. @param array $options @return string
[ "Generate", "the", "form", "." ]
49943a8f563d2e9028f6bc992708e104f9be22e3
https://github.com/austinkregel/formmodel/blob/49943a8f563d2e9028f6bc992708e104f9be22e3/src/FormModel/Frameworks/Bootstrap.php#L14-L28
train
selikhovleonid/nadir
src/core/Headers.php
Headers.add
public function add($sHeader) { foreach ($this->headerList as $sTmp) { if ($sTmp == $sHeader) { throw new Exception("The '{$sHeader}' header has already been added."); } } $this->headerList[] = $sHeader; return self::$instance; }
php
public function add($sHeader) { foreach ($this->headerList as $sTmp) { if ($sTmp == $sHeader) { throw new Exception("The '{$sHeader}' header has already been added."); } } $this->headerList[] = $sHeader; return self::$instance; }
[ "public", "function", "add", "(", "$", "sHeader", ")", "{", "foreach", "(", "$", "this", "->", "headerList", "as", "$", "sTmp", ")", "{", "if", "(", "$", "sTmp", "==", "$", "sHeader", ")", "{", "throw", "new", "Exception", "(", "\"The '{$sHeader}' header has already been added.\"", ")", ";", "}", "}", "$", "this", "->", "headerList", "[", "]", "=", "$", "sHeader", ";", "return", "self", "::", "$", "instance", ";", "}" ]
It adds the header to the stack. @param string $sHeader The page header. @return self. @throws \core\Exception It throws if passed header was already added earlier.
[ "It", "adds", "the", "header", "to", "the", "stack", "." ]
47545fccd8516c8f0a20c02ba62f68269c7199da
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/Headers.php#L136-L145
train
selikhovleonid/nadir
src/core/Headers.php
Headers.addByHttpCode
public function addByHttpCode($nCode) { $sProtocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; $sHeader = "{$sProtocol} {$nCode} " .self::getHTTPExplanationByCode($nCode); return $this->add($sHeader); }
php
public function addByHttpCode($nCode) { $sProtocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; $sHeader = "{$sProtocol} {$nCode} " .self::getHTTPExplanationByCode($nCode); return $this->add($sHeader); }
[ "public", "function", "addByHttpCode", "(", "$", "nCode", ")", "{", "$", "sProtocol", "=", "isset", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ")", "?", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ":", "'HTTP/1.1'", ";", "$", "sHeader", "=", "\"{$sProtocol} {$nCode} \"", ".", "self", "::", "getHTTPExplanationByCode", "(", "$", "nCode", ")", ";", "return", "$", "this", "->", "add", "(", "$", "sHeader", ")", ";", "}" ]
It adds the header to the stack by HTTP code. @param integer $nCode The code. @return self.
[ "It", "adds", "the", "header", "to", "the", "stack", "by", "HTTP", "code", "." ]
47545fccd8516c8f0a20c02ba62f68269c7199da
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/Headers.php#L152-L159
train
selikhovleonid/nadir
src/core/Headers.php
Headers.run
public function run() { $this->isRan = true; foreach ($this->headerList as $sHeader) { header($sHeader); } }
php
public function run() { $this->isRan = true; foreach ($this->headerList as $sHeader) { header($sHeader); } }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "isRan", "=", "true", ";", "foreach", "(", "$", "this", "->", "headerList", "as", "$", "sHeader", ")", "{", "header", "(", "$", "sHeader", ")", ";", "}", "}" ]
The main execution method. It sets all added headers into the page. @return void.
[ "The", "main", "execution", "method", ".", "It", "sets", "all", "added", "headers", "into", "the", "page", "." ]
47545fccd8516c8f0a20c02ba62f68269c7199da
https://github.com/selikhovleonid/nadir/blob/47545fccd8516c8f0a20c02ba62f68269c7199da/src/core/Headers.php#L183-L189
train
andyburton/Sonic-Framework
src/Controller/Tools.php
Tools.clearcache
public function clearcache () { if ($this->view instanceof \Sonic\View\Smarty) { $this->view->clearCompiledTemplate (); $this->view->clearAllCache (); } new \Sonic\Message ('success', 'Cache Cleared'); $this->template = 'tools/index.tpl'; }
php
public function clearcache () { if ($this->view instanceof \Sonic\View\Smarty) { $this->view->clearCompiledTemplate (); $this->view->clearAllCache (); } new \Sonic\Message ('success', 'Cache Cleared'); $this->template = 'tools/index.tpl'; }
[ "public", "function", "clearcache", "(", ")", "{", "if", "(", "$", "this", "->", "view", "instanceof", "\\", "Sonic", "\\", "View", "\\", "Smarty", ")", "{", "$", "this", "->", "view", "->", "clearCompiledTemplate", "(", ")", ";", "$", "this", "->", "view", "->", "clearAllCache", "(", ")", ";", "}", "new", "\\", "Sonic", "\\", "Message", "(", "'success'", ",", "'Cache Cleared'", ")", ";", "$", "this", "->", "template", "=", "'tools/index.tpl'", ";", "}" ]
Clear the view cache
[ "Clear", "the", "view", "cache" ]
a5999448a0abab4d542413002a780ede391e7374
https://github.com/andyburton/Sonic-Framework/blob/a5999448a0abab4d542413002a780ede391e7374/src/Controller/Tools.php#L41-L53
train
Phpillip/phpillip
src/Service/Pygments.php
Pygments.highlight
public function highlight($value, $language) { $path = tempnam($this->tmp, 'pyg'); if ($language === 'php' && substr($value, 0, 5) !== '<?php') { $value = '<?php ' . PHP_EOL . $value; } $this->files->dumpFile($path, $value); $value = $this->pygmentize($path, $language); unlink($path); if (preg_match('#^<div class="highlight"><pre>#', $value) && preg_match('#</pre></div>$#', $value)) { return substr($value, 28, strlen($value) - 40); } return $value; }
php
public function highlight($value, $language) { $path = tempnam($this->tmp, 'pyg'); if ($language === 'php' && substr($value, 0, 5) !== '<?php') { $value = '<?php ' . PHP_EOL . $value; } $this->files->dumpFile($path, $value); $value = $this->pygmentize($path, $language); unlink($path); if (preg_match('#^<div class="highlight"><pre>#', $value) && preg_match('#</pre></div>$#', $value)) { return substr($value, 28, strlen($value) - 40); } return $value; }
[ "public", "function", "highlight", "(", "$", "value", ",", "$", "language", ")", "{", "$", "path", "=", "tempnam", "(", "$", "this", "->", "tmp", ",", "'pyg'", ")", ";", "if", "(", "$", "language", "===", "'php'", "&&", "substr", "(", "$", "value", ",", "0", ",", "5", ")", "!==", "'<?php'", ")", "{", "$", "value", "=", "'<?php '", ".", "PHP_EOL", ".", "$", "value", ";", "}", "$", "this", "->", "files", "->", "dumpFile", "(", "$", "path", ",", "$", "value", ")", ";", "$", "value", "=", "$", "this", "->", "pygmentize", "(", "$", "path", ",", "$", "language", ")", ";", "unlink", "(", "$", "path", ")", ";", "if", "(", "preg_match", "(", "'#^<div class=\"highlight\"><pre>#'", ",", "$", "value", ")", "&&", "preg_match", "(", "'#</pre></div>$#'", ",", "$", "value", ")", ")", "{", "return", "substr", "(", "$", "value", ",", "28", ",", "strlen", "(", "$", "value", ")", "-", "40", ")", ";", "}", "return", "$", "value", ";", "}" ]
Highlight a portion of code with pygmentize @param string $value @param string $language @return string
[ "Highlight", "a", "portion", "of", "code", "with", "pygmentize" ]
c37afaafb536361e7e0b564659f1cd5b80b98be9
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Service/Pygments.php#L47-L66
train
Phpillip/phpillip
src/Service/Pygments.php
Pygments.pygmentize
public function pygmentize($path, $language) { $process = new Process(sprintf('pygmentize -f html -l %s %s', $language, $path)); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException($process->getErrorOutput()); } return trim($process->getOutput()); }
php
public function pygmentize($path, $language) { $process = new Process(sprintf('pygmentize -f html -l %s %s', $language, $path)); $process->run(); if (!$process->isSuccessful()) { throw new RuntimeException($process->getErrorOutput()); } return trim($process->getOutput()); }
[ "public", "function", "pygmentize", "(", "$", "path", ",", "$", "language", ")", "{", "$", "process", "=", "new", "Process", "(", "sprintf", "(", "'pygmentize -f html -l %s %s'", ",", "$", "language", ",", "$", "path", ")", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "$", "process", "->", "getErrorOutput", "(", ")", ")", ";", "}", "return", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ";", "}" ]
Run 'pygmentize' command on the given file @param string $path @param string $language @return string
[ "Run", "pygmentize", "command", "on", "the", "given", "file" ]
c37afaafb536361e7e0b564659f1cd5b80b98be9
https://github.com/Phpillip/phpillip/blob/c37afaafb536361e7e0b564659f1cd5b80b98be9/src/Service/Pygments.php#L76-L87
train
stonedz/pff2
src/modules/auth/Auth.php
Auth.checkAuth
public function checkAuth() { if (isset($_SESSION[$this->_sessionVarName]) && $_SESSION[$this->_sessionVarName] == 1 ) { return true; } else { return false; } }
php
public function checkAuth() { if (isset($_SESSION[$this->_sessionVarName]) && $_SESSION[$this->_sessionVarName] == 1 ) { return true; } else { return false; } }
[ "public", "function", "checkAuth", "(", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "this", "->", "_sessionVarName", "]", ")", "&&", "$", "_SESSION", "[", "$", "this", "->", "_sessionVarName", "]", "==", "1", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Checks if a client is logged-in @return bool
[ "Checks", "if", "a", "client", "is", "logged", "-", "in" ]
ec3b087d4d4732816f61ac487f0cb25511e0da88
https://github.com/stonedz/pff2/blob/ec3b087d4d4732816f61ac487f0cb25511e0da88/src/modules/auth/Auth.php#L119-L127
train
oliwierptak/Everon1
src/Everon/Helper/Asserts/IsNull.php
IsNull.assertIsNull
public function assertIsNull($value, $message='Unexpected null value: %s', $exception='Asserts') { if (is_null($value)) { $value = 'NULL'; $this->throwException($exception, $message, $value); } }
php
public function assertIsNull($value, $message='Unexpected null value: %s', $exception='Asserts') { if (is_null($value)) { $value = 'NULL'; $this->throwException($exception, $message, $value); } }
[ "public", "function", "assertIsNull", "(", "$", "value", ",", "$", "message", "=", "'Unexpected null value: %s'", ",", "$", "exception", "=", "'Asserts'", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "'NULL'", ";", "$", "this", "->", "throwException", "(", "$", "exception", ",", "$", "message", ",", "$", "value", ")", ";", "}", "}" ]
Verifies that the specified condition is not null. The assertion fails if the condition is null. @param mixed $value @param string $message @param string $exception @throws \Everon\Exception\Asserts
[ "Verifies", "that", "the", "specified", "condition", "is", "not", "null", ".", "The", "assertion", "fails", "if", "the", "condition", "is", "null", "." ]
ac93793d1fa517a8394db5f00062f1925dc218a3
https://github.com/oliwierptak/Everon1/blob/ac93793d1fa517a8394db5f00062f1925dc218a3/src/Everon/Helper/Asserts/IsNull.php#L23-L29
train
schpill/thin
src/Html/Row.php
Row.row
public function row(array $attributes = array()) { $row = new self(); if (count($attributes)) { $row->setAttributes($attributes); } return $row; }
php
public function row(array $attributes = array()) { $row = new self(); if (count($attributes)) { $row->setAttributes($attributes); } return $row; }
[ "public", "function", "row", "(", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "row", "=", "new", "self", "(", ")", ";", "if", "(", "count", "(", "$", "attributes", ")", ")", "{", "$", "row", "->", "setAttributes", "(", "$", "attributes", ")", ";", "}", "return", "$", "row", ";", "}" ]
Generates a new table row @param array $attributes @return Row
[ "Generates", "a", "new", "table", "row" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Row.php#L38-L47
train
schpill/thin
src/Html/Row.php
Row.add
public function add($value, array $attributes = null) { $cell = $value; if (is_string($value)) { $cell = new Cell($value, $attributes); } $this->_cells[] = $cell; return $this; }
php
public function add($value, array $attributes = null) { $cell = $value; if (is_string($value)) { $cell = new Cell($value, $attributes); } $this->_cells[] = $cell; return $this; }
[ "public", "function", "add", "(", "$", "value", ",", "array", "$", "attributes", "=", "null", ")", "{", "$", "cell", "=", "$", "value", ";", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "cell", "=", "new", "Cell", "(", "$", "value", ",", "$", "attributes", ")", ";", "}", "$", "this", "->", "_cells", "[", "]", "=", "$", "cell", ";", "return", "$", "this", ";", "}" ]
Adds a cell to the row @param string|Cell $cell @param array $attributes
[ "Adds", "a", "cell", "to", "the", "row" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Row.php#L97-L107
train
schpill/thin
src/Html/Row.php
Row.isHeader
public function isHeader($isHeader = true) { foreach ($this->_cells as $cell) { $cell->isHeader($isHeader); } return $this; }
php
public function isHeader($isHeader = true) { foreach ($this->_cells as $cell) { $cell->isHeader($isHeader); } return $this; }
[ "public", "function", "isHeader", "(", "$", "isHeader", "=", "true", ")", "{", "foreach", "(", "$", "this", "->", "_cells", "as", "$", "cell", ")", "{", "$", "cell", "->", "isHeader", "(", "$", "isHeader", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set whether this row should be a table header or not @param bool $isHeader @return Row
[ "Set", "whether", "this", "row", "should", "be", "a", "table", "header", "or", "not" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Row.php#L116-L123
train
schpill/thin
src/Html/Row.php
Row.setState
public function setState($state = null) { if (null === $state) { $this->_state = $state; return $this; } if (in_array($state, array(static::STATE_SUCCESS, static::STATE_ERROR, static::STATE_INFO))) { $this->_state = $state; } return $this; }
php
public function setState($state = null) { if (null === $state) { $this->_state = $state; return $this; } if (in_array($state, array(static::STATE_SUCCESS, static::STATE_ERROR, static::STATE_INFO))) { $this->_state = $state; } return $this; }
[ "public", "function", "setState", "(", "$", "state", "=", "null", ")", "{", "if", "(", "null", "===", "$", "state", ")", "{", "$", "this", "->", "_state", "=", "$", "state", ";", "return", "$", "this", ";", "}", "if", "(", "in_array", "(", "$", "state", ",", "array", "(", "static", "::", "STATE_SUCCESS", ",", "static", "::", "STATE_ERROR", ",", "static", "::", "STATE_INFO", ")", ")", ")", "{", "$", "this", "->", "_state", "=", "$", "state", ";", "}", "return", "$", "this", ";", "}" ]
Sets the row state @param string $state @return Row
[ "Sets", "the", "row", "state" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Row.php#L132-L144
train
ekyna/AdminBundle
Dashboard/Widget/Registry.php
Registry.hasType
public function hasType($nameOrType) { $name = $nameOrType instanceof WidgetTypeInterface ? $nameOrType->getName() : $nameOrType; return array_key_exists($name, $this->types); }
php
public function hasType($nameOrType) { $name = $nameOrType instanceof WidgetTypeInterface ? $nameOrType->getName() : $nameOrType; return array_key_exists($name, $this->types); }
[ "public", "function", "hasType", "(", "$", "nameOrType", ")", "{", "$", "name", "=", "$", "nameOrType", "instanceof", "WidgetTypeInterface", "?", "$", "nameOrType", "->", "getName", "(", ")", ":", "$", "nameOrType", ";", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "types", ")", ";", "}" ]
Returns whether the widget type is registered or not. @param $nameOrType @return bool
[ "Returns", "whether", "the", "widget", "type", "is", "registered", "or", "not", "." ]
3f58e253ae9cf651add7f3d587caec80eaea459a
https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/Dashboard/Widget/Registry.php#L36-L41
train
ekyna/AdminBundle
Dashboard/Widget/Registry.php
Registry.addType
public function addType(WidgetTypeInterface $widget) { if (!$this->hasType($widget)) { $this->types[$widget->getName()] = $widget; } else { throw new \InvalidArgumentException(sprintf('Widget type "%s" is already registered.', $widget->getName())); } }
php
public function addType(WidgetTypeInterface $widget) { if (!$this->hasType($widget)) { $this->types[$widget->getName()] = $widget; } else { throw new \InvalidArgumentException(sprintf('Widget type "%s" is already registered.', $widget->getName())); } }
[ "public", "function", "addType", "(", "WidgetTypeInterface", "$", "widget", ")", "{", "if", "(", "!", "$", "this", "->", "hasType", "(", "$", "widget", ")", ")", "{", "$", "this", "->", "types", "[", "$", "widget", "->", "getName", "(", ")", "]", "=", "$", "widget", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Widget type \"%s\" is already registered.'", ",", "$", "widget", "->", "getName", "(", ")", ")", ")", ";", "}", "}" ]
Adds the widget type. @param WidgetTypeInterface $widget @throws \InvalidArgumentException
[ "Adds", "the", "widget", "type", "." ]
3f58e253ae9cf651add7f3d587caec80eaea459a
https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/Dashboard/Widget/Registry.php#L49-L56
train
ekyna/AdminBundle
Dashboard/Widget/Registry.php
Registry.getType
public function getType($name) { if ($this->hasType($name)) { return $this->types[$name]; } else { throw new \InvalidArgumentException(sprintf('Widget type "%s" not found.', $name)); } }
php
public function getType($name) { if ($this->hasType($name)) { return $this->types[$name]; } else { throw new \InvalidArgumentException(sprintf('Widget type "%s" not found.', $name)); } }
[ "public", "function", "getType", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "hasType", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "types", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Widget type \"%s\" not found.'", ",", "$", "name", ")", ")", ";", "}", "}" ]
Returns the widget type by name. @param string $name @return WidgetTypeInterface @throws \InvalidArgumentException
[ "Returns", "the", "widget", "type", "by", "name", "." ]
3f58e253ae9cf651add7f3d587caec80eaea459a
https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/Dashboard/Widget/Registry.php#L65-L72
train
mobtexting/php-http-client
src/Client.php
Client.parseResponse
protected function parseResponse($channel, $content) { $headerSize = curl_getinfo($channel, CURLINFO_HEADER_SIZE); $statusCode = curl_getinfo($channel, CURLINFO_HTTP_CODE); $responseBody = substr($content, $headerSize); $responseHeaders = substr($content, 0, $headerSize); $responseHeaders = explode("\n", $responseHeaders); $responseHeaders = array_map('trim', $responseHeaders); return new Response($statusCode, $responseBody, $responseHeaders); }
php
protected function parseResponse($channel, $content) { $headerSize = curl_getinfo($channel, CURLINFO_HEADER_SIZE); $statusCode = curl_getinfo($channel, CURLINFO_HTTP_CODE); $responseBody = substr($content, $headerSize); $responseHeaders = substr($content, 0, $headerSize); $responseHeaders = explode("\n", $responseHeaders); $responseHeaders = array_map('trim', $responseHeaders); return new Response($statusCode, $responseBody, $responseHeaders); }
[ "protected", "function", "parseResponse", "(", "$", "channel", ",", "$", "content", ")", "{", "$", "headerSize", "=", "curl_getinfo", "(", "$", "channel", ",", "CURLINFO_HEADER_SIZE", ")", ";", "$", "statusCode", "=", "curl_getinfo", "(", "$", "channel", ",", "CURLINFO_HTTP_CODE", ")", ";", "$", "responseBody", "=", "substr", "(", "$", "content", ",", "$", "headerSize", ")", ";", "$", "responseHeaders", "=", "substr", "(", "$", "content", ",", "0", ",", "$", "headerSize", ")", ";", "$", "responseHeaders", "=", "explode", "(", "\"\\n\"", ",", "$", "responseHeaders", ")", ";", "$", "responseHeaders", "=", "array_map", "(", "'trim'", ",", "$", "responseHeaders", ")", ";", "return", "new", "Response", "(", "$", "statusCode", ",", "$", "responseBody", ",", "$", "responseHeaders", ")", ";", "}" ]
Prepare response object @param resource $channel the curl resource @param string $content @return Response object
[ "Prepare", "response", "object" ]
3925e841cfa0f8fcc35f57a6c0c0935076c7e6e3
https://github.com/mobtexting/php-http-client/blob/3925e841cfa0f8fcc35f57a6c0c0935076c7e6e3/src/Client.php#L252-L262
train
Dhii/output-renderer-abstract
src/ContextAwareTrait.php
ContextAwareTrait._setContext
protected function _setContext($context) { $this->context = ($context !== null) ? $this->_normalizeContainer($context) : null; }
php
protected function _setContext($context) { $this->context = ($context !== null) ? $this->_normalizeContainer($context) : null; }
[ "protected", "function", "_setContext", "(", "$", "context", ")", "{", "$", "this", "->", "context", "=", "(", "$", "context", "!==", "null", ")", "?", "$", "this", "->", "_normalizeContainer", "(", "$", "context", ")", ":", "null", ";", "}" ]
Sets the context for this instance. @since 0.1 @param array|ArrayAccess|stdClass|ContainerInterface|null $context The context instance, or null.
[ "Sets", "the", "context", "for", "this", "instance", "." ]
0f6e5eed940025332dd1986d6c771e10f7197b1a
https://github.com/Dhii/output-renderer-abstract/blob/0f6e5eed940025332dd1986d6c771e10f7197b1a/src/ContextAwareTrait.php#L45-L50
train
buse974/Dal
src/Dal/Model/AbstractModel.php
AbstractModel.toArray
public function toArray() { $hydrator = new ClassMethods(); $vars = $hydrator->extract($this); foreach ($vars as $key => &$value) { if ($value === null) { unset($vars[$key]); } elseif (is_object($value) && ! $value instanceof \ArrayObject) { if (method_exists($value, 'toArray')) { $value = $value->toArray(); if (count($value) == 0) { unset($vars[$key]); } } elseif ($value instanceof IsNull) { $vars[$key] = null; } elseif ($value instanceof \stdClass) { $vars[$key] = new \stdClass(); } else { unset($vars[$key]); } } elseif (is_bool($value)) { $vars[$key] = (int) $value; } } return $vars; }
php
public function toArray() { $hydrator = new ClassMethods(); $vars = $hydrator->extract($this); foreach ($vars as $key => &$value) { if ($value === null) { unset($vars[$key]); } elseif (is_object($value) && ! $value instanceof \ArrayObject) { if (method_exists($value, 'toArray')) { $value = $value->toArray(); if (count($value) == 0) { unset($vars[$key]); } } elseif ($value instanceof IsNull) { $vars[$key] = null; } elseif ($value instanceof \stdClass) { $vars[$key] = new \stdClass(); } else { unset($vars[$key]); } } elseif (is_bool($value)) { $vars[$key] = (int) $value; } } return $vars; }
[ "public", "function", "toArray", "(", ")", "{", "$", "hydrator", "=", "new", "ClassMethods", "(", ")", ";", "$", "vars", "=", "$", "hydrator", "->", "extract", "(", "$", "this", ")", ";", "foreach", "(", "$", "vars", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "unset", "(", "$", "vars", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", "&&", "!", "$", "value", "instanceof", "\\", "ArrayObject", ")", "{", "if", "(", "method_exists", "(", "$", "value", ",", "'toArray'", ")", ")", "{", "$", "value", "=", "$", "value", "->", "toArray", "(", ")", ";", "if", "(", "count", "(", "$", "value", ")", "==", "0", ")", "{", "unset", "(", "$", "vars", "[", "$", "key", "]", ")", ";", "}", "}", "elseif", "(", "$", "value", "instanceof", "IsNull", ")", "{", "$", "vars", "[", "$", "key", "]", "=", "null", ";", "}", "elseif", "(", "$", "value", "instanceof", "\\", "stdClass", ")", "{", "$", "vars", "[", "$", "key", "]", "=", "new", "\\", "stdClass", "(", ")", ";", "}", "else", "{", "unset", "(", "$", "vars", "[", "$", "key", "]", ")", ";", "}", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "vars", "[", "$", "key", "]", "=", "(", "int", ")", "$", "value", ";", "}", "}", "return", "$", "vars", ";", "}" ]
Convert the model to an array. @return array
[ "Convert", "the", "model", "to", "an", "array", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Model/AbstractModel.php#L108-L135
train
buse974/Dal
src/Dal/Model/AbstractModel.php
AbstractModel.isRepeatRelational
protected function isRepeatRelational() { $is_repeat = false; if (array_count_values($this->getParentArray())[$this->prefix] > 1) { $is_repeat = true; } return $is_repeat; }
php
protected function isRepeatRelational() { $is_repeat = false; if (array_count_values($this->getParentArray())[$this->prefix] > 1) { $is_repeat = true; } return $is_repeat; }
[ "protected", "function", "isRepeatRelational", "(", ")", "{", "$", "is_repeat", "=", "false", ";", "if", "(", "array_count_values", "(", "$", "this", "->", "getParentArray", "(", ")", ")", "[", "$", "this", "->", "prefix", "]", ">", "1", ")", "{", "$", "is_repeat", "=", "true", ";", "}", "return", "$", "is_repeat", ";", "}" ]
Return true if relation is boucle infinie. @return bool
[ "Return", "true", "if", "relation", "is", "boucle", "infinie", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Model/AbstractModel.php#L209-L218
train
buse974/Dal
src/Dal/Model/AbstractModel.php
AbstractModel.requireModel
public function requireModel($model, &$data, $prefix = null) { $class = null; $name = (null !== $prefix) ? $prefix : substr($model, strlen(explode('_', $model)[0]) + 7); foreach ($this->array_prefix as $k => $ap) { if (strrpos($ap, $name) === (strlen($ap) - strlen($name))) { unset($this->array_prefix[$k]); $class = clone $this->container->get($model); $class->setPrefix($prefix); $class->setArrayPrefix($this->array_prefix); $class->setParentModel($this); $class->exchangeArray($data); if (! $class->Keep()) { return new IsNull(); } break; } } return $class; }
php
public function requireModel($model, &$data, $prefix = null) { $class = null; $name = (null !== $prefix) ? $prefix : substr($model, strlen(explode('_', $model)[0]) + 7); foreach ($this->array_prefix as $k => $ap) { if (strrpos($ap, $name) === (strlen($ap) - strlen($name))) { unset($this->array_prefix[$k]); $class = clone $this->container->get($model); $class->setPrefix($prefix); $class->setArrayPrefix($this->array_prefix); $class->setParentModel($this); $class->exchangeArray($data); if (! $class->Keep()) { return new IsNull(); } break; } } return $class; }
[ "public", "function", "requireModel", "(", "$", "model", ",", "&", "$", "data", ",", "$", "prefix", "=", "null", ")", "{", "$", "class", "=", "null", ";", "$", "name", "=", "(", "null", "!==", "$", "prefix", ")", "?", "$", "prefix", ":", "substr", "(", "$", "model", ",", "strlen", "(", "explode", "(", "'_'", ",", "$", "model", ")", "[", "0", "]", ")", "+", "7", ")", ";", "foreach", "(", "$", "this", "->", "array_prefix", "as", "$", "k", "=>", "$", "ap", ")", "{", "if", "(", "strrpos", "(", "$", "ap", ",", "$", "name", ")", "===", "(", "strlen", "(", "$", "ap", ")", "-", "strlen", "(", "$", "name", ")", ")", ")", "{", "unset", "(", "$", "this", "->", "array_prefix", "[", "$", "k", "]", ")", ";", "$", "class", "=", "clone", "$", "this", "->", "container", "->", "get", "(", "$", "model", ")", ";", "$", "class", "->", "setPrefix", "(", "$", "prefix", ")", ";", "$", "class", "->", "setArrayPrefix", "(", "$", "this", "->", "array_prefix", ")", ";", "$", "class", "->", "setParentModel", "(", "$", "this", ")", ";", "$", "class", "->", "exchangeArray", "(", "$", "data", ")", ";", "if", "(", "!", "$", "class", "->", "Keep", "(", ")", ")", "{", "return", "new", "IsNull", "(", ")", ";", "}", "break", ";", "}", "}", "return", "$", "class", ";", "}" ]
return Model if needed. @param string $model @param array $data @param string $prefix @return AbstractModel|null
[ "return", "Model", "if", "needed", "." ]
faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab
https://github.com/buse974/Dal/blob/faeac9e260c5e675bc7ed1fcea77c7ba251bf8ab/src/Dal/Model/AbstractModel.php#L270-L291
train
phpcq/autoload-validation
src/AutoloadValidator/Psr0Validator.php
Psr0Validator.checkPearOrNoMatch
private function checkPearOrNoMatch($classNameSpace, $prefixLength, $prefix) { // No NS, separator in class namespace. if (!$classNameSpace) { return false; } if (substr($classNameSpace, 0, $prefixLength) === $prefix) { return false; } return true; }
php
private function checkPearOrNoMatch($classNameSpace, $prefixLength, $prefix) { // No NS, separator in class namespace. if (!$classNameSpace) { return false; } if (substr($classNameSpace, 0, $prefixLength) === $prefix) { return false; } return true; }
[ "private", "function", "checkPearOrNoMatch", "(", "$", "classNameSpace", ",", "$", "prefixLength", ",", "$", "prefix", ")", "{", "// No NS, separator in class namespace.", "if", "(", "!", "$", "classNameSpace", ")", "{", "return", "false", ";", "}", "if", "(", "substr", "(", "$", "classNameSpace", ",", "0", ",", "$", "prefixLength", ")", "===", "$", "prefix", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if the class is PEAR style or does not match at all. Return true if there is some problem, false otherwise. @param string $classNameSpace The namespace of the class. @param string $prefixLength The length of the namespace that must match. @param string $prefix The required namespace prefix. @return bool
[ "Check", "if", "the", "class", "is", "PEAR", "style", "or", "does", "not", "match", "at", "all", "." ]
c24d331f16034c2096ce0e55492993befbaa687a
https://github.com/phpcq/autoload-validation/blob/c24d331f16034c2096ce0e55492993befbaa687a/src/AutoloadValidator/Psr0Validator.php#L195-L207
train
AndyDune/Pipeline
src/Pipeline.php
Pipeline.pipe
public function pipe($pipe, $methodName = '', ...$params): self { if ($pipe instanceof Closure) { $this->pipes[] = $pipe; return $this; } $pipe = [ $pipe, $methodName, $params, false ]; $this->pipes[] = $pipe; return $this; }
php
public function pipe($pipe, $methodName = '', ...$params): self { if ($pipe instanceof Closure) { $this->pipes[] = $pipe; return $this; } $pipe = [ $pipe, $methodName, $params, false ]; $this->pipes[] = $pipe; return $this; }
[ "public", "function", "pipe", "(", "$", "pipe", ",", "$", "methodName", "=", "''", ",", "...", "$", "params", ")", ":", "self", "{", "if", "(", "$", "pipe", "instanceof", "Closure", ")", "{", "$", "this", "->", "pipes", "[", "]", "=", "$", "pipe", ";", "return", "$", "this", ";", "}", "$", "pipe", "=", "[", "$", "pipe", ",", "$", "methodName", ",", "$", "params", ",", "false", "]", ";", "$", "this", "->", "pipes", "[", "]", "=", "$", "pipe", ";", "return", "$", "this", ";", "}" ]
Add stage for workflow. @param $pipe class name or service name for stage. @param string $methodName method name for this object @param string $params additional params @return $this
[ "Add", "stage", "for", "workflow", "." ]
66bcc8ba7a0d74fecdf2f993995c1140c29fd91f
https://github.com/AndyDune/Pipeline/blob/66bcc8ba7a0d74fecdf2f993995c1140c29fd91f/src/Pipeline.php#L137-L152
train
AndyDune/Pipeline
src/Pipeline.php
Pipeline.pipeForContainer
public function pipeForContainer($pipe, $methodName = '', ...$params): self { if ($pipe instanceof Closure) { $this->pipes[] = $pipe; return $this; } $pipe = [ $pipe, $methodName, $params, true ]; $this->pipes[] = $pipe; return $this; }
php
public function pipeForContainer($pipe, $methodName = '', ...$params): self { if ($pipe instanceof Closure) { $this->pipes[] = $pipe; return $this; } $pipe = [ $pipe, $methodName, $params, true ]; $this->pipes[] = $pipe; return $this; }
[ "public", "function", "pipeForContainer", "(", "$", "pipe", ",", "$", "methodName", "=", "''", ",", "...", "$", "params", ")", ":", "self", "{", "if", "(", "$", "pipe", "instanceof", "Closure", ")", "{", "$", "this", "->", "pipes", "[", "]", "=", "$", "pipe", ";", "return", "$", "this", ";", "}", "$", "pipe", "=", "[", "$", "pipe", ",", "$", "methodName", ",", "$", "params", ",", "true", "]", ";", "$", "this", "->", "pipes", "[", "]", "=", "$", "pipe", ";", "return", "$", "this", ";", "}" ]
Add stage without middleware interface. @param $pipe description for stage @param string $methodName @param array ...$params @return $this
[ "Add", "stage", "without", "middleware", "interface", "." ]
66bcc8ba7a0d74fecdf2f993995c1140c29fd91f
https://github.com/AndyDune/Pipeline/blob/66bcc8ba7a0d74fecdf2f993995c1140c29fd91f/src/Pipeline.php#L163-L178
train
AndyDune/Pipeline
src/Pipeline.php
Pipeline.execute
public function execute() { $pipeline = array_reduce( array_reverse($this->pipes), $this->carry(), function ($passable) { return $passable; } ); return $pipeline($this->passable); }
php
public function execute() { $pipeline = array_reduce( array_reverse($this->pipes), $this->carry(), function ($passable) { return $passable; } ); return $pipeline($this->passable); }
[ "public", "function", "execute", "(", ")", "{", "$", "pipeline", "=", "array_reduce", "(", "array_reverse", "(", "$", "this", "->", "pipes", ")", ",", "$", "this", "->", "carry", "(", ")", ",", "function", "(", "$", "passable", ")", "{", "return", "$", "passable", ";", "}", ")", ";", "return", "$", "pipeline", "(", "$", "this", "->", "passable", ")", ";", "}" ]
Run the pipeline without a final destination callback. @return mixed
[ "Run", "the", "pipeline", "without", "a", "final", "destination", "callback", "." ]
66bcc8ba7a0d74fecdf2f993995c1140c29fd91f
https://github.com/AndyDune/Pipeline/blob/66bcc8ba7a0d74fecdf2f993995c1140c29fd91f/src/Pipeline.php#L201-L210
train
armazon/armazon
src/Armazon/Mvc/Vista.php
Vista.filtrarValor
public function filtrarValor($filtro, $texto) { if (isset($this->filtros[$filtro])) { $texto = $this->filtros[$filtro]($texto); } return $texto; }
php
public function filtrarValor($filtro, $texto) { if (isset($this->filtros[$filtro])) { $texto = $this->filtros[$filtro]($texto); } return $texto; }
[ "public", "function", "filtrarValor", "(", "$", "filtro", ",", "$", "texto", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "filtros", "[", "$", "filtro", "]", ")", ")", "{", "$", "texto", "=", "$", "this", "->", "filtros", "[", "$", "filtro", "]", "(", "$", "texto", ")", ";", "}", "return", "$", "texto", ";", "}" ]
Aplica el filtro solicitado al valor. @param string $filtro @param string $texto @return string
[ "Aplica", "el", "filtro", "solicitado", "al", "valor", "." ]
ec76385ff80ce1659d81bc4050ef9483ab0ebe52
https://github.com/armazon/armazon/blob/ec76385ff80ce1659d81bc4050ef9483ab0ebe52/src/Armazon/Mvc/Vista.php#L125-L132
train
SURFnet/yubikey-api-client
src/Crypto/Signer.php
Signer.sign
public function sign(array $data) { ksort($data); $queryString = $this->buildQueryString($data); $data['h'] = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true)); return $data; }
php
public function sign(array $data) { ksort($data); $queryString = $this->buildQueryString($data); $data['h'] = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true)); return $data; }
[ "public", "function", "sign", "(", "array", "$", "data", ")", "{", "ksort", "(", "$", "data", ")", ";", "$", "queryString", "=", "$", "this", "->", "buildQueryString", "(", "$", "data", ")", ";", "$", "data", "[", "'h'", "]", "=", "base64_encode", "(", "hash_hmac", "(", "'sha1'", ",", "$", "queryString", ",", "$", "this", "->", "clientSecret", ",", "true", ")", ")", ";", "return", "$", "data", ";", "}" ]
Signs an array by calculating a signature and setting it on the 'h' key. @param array $data @return array
[ "Signs", "an", "array", "by", "calculating", "a", "signature", "and", "setting", "it", "on", "the", "h", "key", "." ]
bbcb6340c89c5bcecf2f9258390cb9dfe2b87358
https://github.com/SURFnet/yubikey-api-client/blob/bbcb6340c89c5bcecf2f9258390cb9dfe2b87358/src/Crypto/Signer.php#L67-L75
train
SURFnet/yubikey-api-client
src/Crypto/Signer.php
Signer.verifySignature
public function verifySignature(array $data) { $signedData = array_intersect_key($data, array_flip(self::$validResponseParams)); ksort($signedData); $queryString = $this->buildQueryString($signedData); $signature = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true)); return hash_equals($signature, $data['h']); }
php
public function verifySignature(array $data) { $signedData = array_intersect_key($data, array_flip(self::$validResponseParams)); ksort($signedData); $queryString = $this->buildQueryString($signedData); $signature = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true)); return hash_equals($signature, $data['h']); }
[ "public", "function", "verifySignature", "(", "array", "$", "data", ")", "{", "$", "signedData", "=", "array_intersect_key", "(", "$", "data", ",", "array_flip", "(", "self", "::", "$", "validResponseParams", ")", ")", ";", "ksort", "(", "$", "signedData", ")", ";", "$", "queryString", "=", "$", "this", "->", "buildQueryString", "(", "$", "signedData", ")", ";", "$", "signature", "=", "base64_encode", "(", "hash_hmac", "(", "'sha1'", ",", "$", "queryString", ",", "$", "this", "->", "clientSecret", ",", "true", ")", ")", ";", "return", "hash_equals", "(", "$", "signature", ",", "$", "data", "[", "'h'", "]", ")", ";", "}" ]
Verifies that the signature in the 'h' key matches the expected signature. @param array $data @return bool
[ "Verifies", "that", "the", "signature", "in", "the", "h", "key", "matches", "the", "expected", "signature", "." ]
bbcb6340c89c5bcecf2f9258390cb9dfe2b87358
https://github.com/SURFnet/yubikey-api-client/blob/bbcb6340c89c5bcecf2f9258390cb9dfe2b87358/src/Crypto/Signer.php#L83-L92
train
denostr/stopforumspam
src/Client.php
Client.request
public function request() { $data = $this->prepareData(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiHost . '/api'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $this->checkResult($result); return $result; }
php
public function request() { $data = $this->prepareData(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->apiHost . '/api'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $this->checkResult($result); return $result; }
[ "public", "function", "request", "(", ")", "{", "$", "data", "=", "$", "this", "->", "prepareData", "(", ")", ";", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "this", "->", "apiHost", ".", "'/api'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "data", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "ch", ")", ";", "$", "this", "->", "checkResult", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Run API reauest @return mixed @throws \Exception
[ "Run", "API", "reauest" ]
afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca
https://github.com/denostr/stopforumspam/blob/afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca/src/Client.php#L147-L161
train
denostr/stopforumspam
src/Client.php
Client.prepareData
private function prepareData() { $data = []; foreach (get_object_vars($this) as $property => $value) { if (in_array($property, ['apiHost', 'debug'])) { continue; } if ($property == 'format') { $data[$value] = ''; } elseif (is_bool($value) && $value) { $data[$property] = ''; } elseif (!is_null($value) && !is_bool($value)) { if (is_array($value)) { foreach ($value as $key => $val) { $value[$key] = $val; } } else { $value = $value; } $data[$property] = $value; } } if (empty($data) && $this->debug) { throw new \Exception('Query have not data'); } $data = http_build_query($data); return $data; }
php
private function prepareData() { $data = []; foreach (get_object_vars($this) as $property => $value) { if (in_array($property, ['apiHost', 'debug'])) { continue; } if ($property == 'format') { $data[$value] = ''; } elseif (is_bool($value) && $value) { $data[$property] = ''; } elseif (!is_null($value) && !is_bool($value)) { if (is_array($value)) { foreach ($value as $key => $val) { $value[$key] = $val; } } else { $value = $value; } $data[$property] = $value; } } if (empty($data) && $this->debug) { throw new \Exception('Query have not data'); } $data = http_build_query($data); return $data; }
[ "private", "function", "prepareData", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "property", ",", "[", "'apiHost'", ",", "'debug'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "property", "==", "'format'", ")", "{", "$", "data", "[", "$", "value", "]", "=", "''", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", "&&", "$", "value", ")", "{", "$", "data", "[", "$", "property", "]", "=", "''", ";", "}", "elseif", "(", "!", "is_null", "(", "$", "value", ")", "&&", "!", "is_bool", "(", "$", "value", ")", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "value", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "else", "{", "$", "value", "=", "$", "value", ";", "}", "$", "data", "[", "$", "property", "]", "=", "$", "value", ";", "}", "}", "if", "(", "empty", "(", "$", "data", ")", "&&", "$", "this", "->", "debug", ")", "{", "throw", "new", "\\", "Exception", "(", "'Query have not data'", ")", ";", "}", "$", "data", "=", "http_build_query", "(", "$", "data", ")", ";", "return", "$", "data", ";", "}" ]
Preparing data before request @return string @throws \Exception
[ "Preparing", "data", "before", "request" ]
afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca
https://github.com/denostr/stopforumspam/blob/afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca/src/Client.php#L169-L201
train
denostr/stopforumspam
src/Client.php
Client.checkResult
private function checkResult($result) { if ($this->debug) { if (in_array($this->format, [self::FORMAT_JSON, self::FORMAT_JSONP])) { $result = json_decode($result, true); } elseif ($this->format == self::FORMAT_SERIAL) { $result = unserialize($result); } if (is_array($result)) { if (isset($result['success']) && $result['success'] == 0 && isset($result['error'])) { throw new \Exception($result['error']); } } } }
php
private function checkResult($result) { if ($this->debug) { if (in_array($this->format, [self::FORMAT_JSON, self::FORMAT_JSONP])) { $result = json_decode($result, true); } elseif ($this->format == self::FORMAT_SERIAL) { $result = unserialize($result); } if (is_array($result)) { if (isset($result['success']) && $result['success'] == 0 && isset($result['error'])) { throw new \Exception($result['error']); } } } }
[ "private", "function", "checkResult", "(", "$", "result", ")", "{", "if", "(", "$", "this", "->", "debug", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "format", ",", "[", "self", "::", "FORMAT_JSON", ",", "self", "::", "FORMAT_JSONP", "]", ")", ")", "{", "$", "result", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "}", "elseif", "(", "$", "this", "->", "format", "==", "self", "::", "FORMAT_SERIAL", ")", "{", "$", "result", "=", "unserialize", "(", "$", "result", ")", ";", "}", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "if", "(", "isset", "(", "$", "result", "[", "'success'", "]", ")", "&&", "$", "result", "[", "'success'", "]", "==", "0", "&&", "isset", "(", "$", "result", "[", "'error'", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "result", "[", "'error'", "]", ")", ";", "}", "}", "}", "}" ]
Check response data @param $result @throws \Exception
[ "Check", "response", "data" ]
afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca
https://github.com/denostr/stopforumspam/blob/afbab3bd33ea9b408ad7c3331e0dafa2f87ff3ca/src/Client.php#L209-L224
train
YiMAproject/yimaAdminor
src/yimaAdminor/Service/AuthServiceFactory.php
AuthServiceFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $serviceLocator = $serviceLocator->getServiceLocator(); $config = $serviceLocator->get('Config'); $config = (isset($config['yima_adminor']) && is_array($config['yima_adminor'])) ? $config['yima_adminor'] : []; $opts = []; if (isset($config['auth_service']) && is_array($config['auth_service']) ) $opts = $config['auth_service']; if (isset($opts['auth_adapter']) && $srvAdapter = $opts['auth_adapter']) { if (is_string($srvAdapter)) { if (!class_exists($srvAdapter)) // it's a registered service $opts['auth_adapter'] = $serviceLocator->get($srvAdapter); else $opts['auth_adapter'] = $serviceLocator->get($srvAdapter); } } $authService = new AuthService($opts); return $authService; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $serviceLocator = $serviceLocator->getServiceLocator(); $config = $serviceLocator->get('Config'); $config = (isset($config['yima_adminor']) && is_array($config['yima_adminor'])) ? $config['yima_adminor'] : []; $opts = []; if (isset($config['auth_service']) && is_array($config['auth_service']) ) $opts = $config['auth_service']; if (isset($opts['auth_adapter']) && $srvAdapter = $opts['auth_adapter']) { if (is_string($srvAdapter)) { if (!class_exists($srvAdapter)) // it's a registered service $opts['auth_adapter'] = $serviceLocator->get($srvAdapter); else $opts['auth_adapter'] = $serviceLocator->get($srvAdapter); } } $authService = new AuthService($opts); return $authService; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "serviceLocator", "=", "$", "serviceLocator", "->", "getServiceLocator", "(", ")", ";", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'Config'", ")", ";", "$", "config", "=", "(", "isset", "(", "$", "config", "[", "'yima_adminor'", "]", ")", "&&", "is_array", "(", "$", "config", "[", "'yima_adminor'", "]", ")", ")", "?", "$", "config", "[", "'yima_adminor'", "]", ":", "[", "]", ";", "$", "opts", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'auth_service'", "]", ")", "&&", "is_array", "(", "$", "config", "[", "'auth_service'", "]", ")", ")", "$", "opts", "=", "$", "config", "[", "'auth_service'", "]", ";", "if", "(", "isset", "(", "$", "opts", "[", "'auth_adapter'", "]", ")", "&&", "$", "srvAdapter", "=", "$", "opts", "[", "'auth_adapter'", "]", ")", "{", "if", "(", "is_string", "(", "$", "srvAdapter", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "srvAdapter", ")", ")", "// it's a registered service", "$", "opts", "[", "'auth_adapter'", "]", "=", "$", "serviceLocator", "->", "get", "(", "$", "srvAdapter", ")", ";", "else", "$", "opts", "[", "'auth_adapter'", "]", "=", "$", "serviceLocator", "->", "get", "(", "$", "srvAdapter", ")", ";", "}", "}", "$", "authService", "=", "new", "AuthService", "(", "$", "opts", ")", ";", "return", "$", "authService", ";", "}" ]
Create the Authentication Service @param ServiceLocatorInterface $serviceLocator @return iAuthenticateAdapter
[ "Create", "the", "Authentication", "Service" ]
7a6c66e05aedaef8061c8998dfa44ac1ce9cc319
https://github.com/YiMAproject/yimaAdminor/blob/7a6c66e05aedaef8061c8998dfa44ac1ce9cc319/src/yimaAdminor/Service/AuthServiceFactory.php#L18-L45
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._extractQuoteSkuData
protected function _extractQuoteSkuData(Mage_Sales_Model_Quote $quote) { $skuData = []; // use getAllVisibleItems to prevent dupes due to parent config + child used both being included foreach ($quote->getAllVisibleItems() as $item) { // before item's have been saved, getAllVisible items won't properly // filter child items...this extra check fixes it if ($item->getParentItem()) { continue; } $skuData[$item->getSku()] = [ 'item_id' => $item->getId(), 'managed' => Mage::helper('radial_core/quote_item')->isItemInventoried($item), 'virtual' => $item->getIsVirtual(), 'qty' => $item->getQty(), ]; } return $skuData; }
php
protected function _extractQuoteSkuData(Mage_Sales_Model_Quote $quote) { $skuData = []; // use getAllVisibleItems to prevent dupes due to parent config + child used both being included foreach ($quote->getAllVisibleItems() as $item) { // before item's have been saved, getAllVisible items won't properly // filter child items...this extra check fixes it if ($item->getParentItem()) { continue; } $skuData[$item->getSku()] = [ 'item_id' => $item->getId(), 'managed' => Mage::helper('radial_core/quote_item')->isItemInventoried($item), 'virtual' => $item->getIsVirtual(), 'qty' => $item->getQty(), ]; } return $skuData; }
[ "protected", "function", "_extractQuoteSkuData", "(", "Mage_Sales_Model_Quote", "$", "quote", ")", "{", "$", "skuData", "=", "[", "]", ";", "// use getAllVisibleItems to prevent dupes due to parent config + child used both being included", "foreach", "(", "$", "quote", "->", "getAllVisibleItems", "(", ")", "as", "$", "item", ")", "{", "// before item's have been saved, getAllVisible items won't properly", "// filter child items...this extra check fixes it", "if", "(", "$", "item", "->", "getParentItem", "(", ")", ")", "{", "continue", ";", "}", "$", "skuData", "[", "$", "item", "->", "getSku", "(", ")", "]", "=", "[", "'item_id'", "=>", "$", "item", "->", "getId", "(", ")", ",", "'managed'", "=>", "Mage", "::", "helper", "(", "'radial_core/quote_item'", ")", "->", "isItemInventoried", "(", "$", "item", ")", ",", "'virtual'", "=>", "$", "item", "->", "getIsVirtual", "(", ")", ",", "'qty'", "=>", "$", "item", "->", "getQty", "(", ")", ",", "]", ";", "}", "return", "$", "skuData", ";", "}" ]
Get sku and qty data for a given quote @param Mage_Sales_Model_Quote $quote Quote object to extract data from @return array Array of 'sku' => qty
[ "Get", "sku", "and", "qty", "data", "for", "a", "given", "quote" ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L57-L75
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._extractAddressData
protected function _extractAddressData(Mage_Customer_Model_Address_Abstract $address) { return array( 'street' => $address->getStreet(), 'city' => $address->getCity(), 'region_code' => $address->getRegionCode(), 'country_id' => $address->getCountryId(), 'postcode' => $address->getPostcode(), ); }
php
protected function _extractAddressData(Mage_Customer_Model_Address_Abstract $address) { return array( 'street' => $address->getStreet(), 'city' => $address->getCity(), 'region_code' => $address->getRegionCode(), 'country_id' => $address->getCountryId(), 'postcode' => $address->getPostcode(), ); }
[ "protected", "function", "_extractAddressData", "(", "Mage_Customer_Model_Address_Abstract", "$", "address", ")", "{", "return", "array", "(", "'street'", "=>", "$", "address", "->", "getStreet", "(", ")", ",", "'city'", "=>", "$", "address", "->", "getCity", "(", ")", ",", "'region_code'", "=>", "$", "address", "->", "getRegionCode", "(", ")", ",", "'country_id'", "=>", "$", "address", "->", "getCountryId", "(", ")", ",", "'postcode'", "=>", "$", "address", "->", "getPostcode", "(", ")", ",", ")", ";", "}" ]
Extract array of address data - street, city, region code, etc. from an address object @param Mage_Customer_Model_Address_Abstract $address Address object to pull data from @return array Extracted data
[ "Extract", "array", "of", "address", "data", "-", "street", "city", "region", "code", "etc", ".", "from", "an", "address", "object" ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L81-L90
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._extractQuoteShippingData
protected function _extractQuoteShippingData(Mage_Sales_Model_Quote $quote) { $shippingData = array(); foreach ($quote->getAllShippingAddresses() as $address) { $shippingData[] = array( 'method' => $address->getShippingMethod(), 'address' => $this->_extractAddressData($address), ); } return $shippingData; }
php
protected function _extractQuoteShippingData(Mage_Sales_Model_Quote $quote) { $shippingData = array(); foreach ($quote->getAllShippingAddresses() as $address) { $shippingData[] = array( 'method' => $address->getShippingMethod(), 'address' => $this->_extractAddressData($address), ); } return $shippingData; }
[ "protected", "function", "_extractQuoteShippingData", "(", "Mage_Sales_Model_Quote", "$", "quote", ")", "{", "$", "shippingData", "=", "array", "(", ")", ";", "foreach", "(", "$", "quote", "->", "getAllShippingAddresses", "(", ")", "as", "$", "address", ")", "{", "$", "shippingData", "[", "]", "=", "array", "(", "'method'", "=>", "$", "address", "->", "getShippingMethod", "(", ")", ",", "'address'", "=>", "$", "this", "->", "_extractAddressData", "(", "$", "address", ")", ",", ")", ";", "}", "return", "$", "shippingData", ";", "}" ]
Extract shipping data from a quote - the shipping method and address for each shipping address in the quote. @param Mage_Sales_Model_Quote $quote The quote to extract the data from @return array Map of shipping method and address for each shipping address in the quote
[ "Extract", "shipping", "data", "from", "a", "quote", "-", "the", "shipping", "method", "and", "address", "for", "each", "shipping", "address", "in", "the", "quote", "." ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L97-L107
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._extractQuoteBillingData
protected function _extractQuoteBillingData(Mage_Sales_Model_Quote $quote) { $address = $quote->getBillingAddress(); return $address ? $this->_extractAddressData($address) : array(); }
php
protected function _extractQuoteBillingData(Mage_Sales_Model_Quote $quote) { $address = $quote->getBillingAddress(); return $address ? $this->_extractAddressData($address) : array(); }
[ "protected", "function", "_extractQuoteBillingData", "(", "Mage_Sales_Model_Quote", "$", "quote", ")", "{", "$", "address", "=", "$", "quote", "->", "getBillingAddress", "(", ")", ";", "return", "$", "address", "?", "$", "this", "->", "_extractAddressData", "(", "$", "address", ")", ":", "array", "(", ")", ";", "}" ]
Return array of billing address data if available, otherwise, an empty array @param Mage_Sales_Model_Quote $quote Quote object to extract data from @return array Array of billing address data
[ "Return", "array", "of", "billing", "address", "data", "if", "available", "otherwise", "an", "empty", "array" ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L122-L128
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._extractQuoteAmounts
protected function _extractQuoteAmounts(Mage_Sales_Model_Quote $quote) { return array_map( function ($address) { return array( 'subtotal' => round($address->getSubtotal(), 4) ?: 0.0000, 'discount' => round($address->getDiscountAmount(), 4) ?: 0.0000, 'ship_amount' => round($address->getShippingAmount(), 4) ?: 0.0000, 'ship_discount' => round($address->getShippingDiscountAmount(), 4) ?: 0.0000, 'giftwrap_amount' => round($address->getGwPrice() + $address->getGwItemsPrice(), 4) ?: 0.0000, ); }, $quote->getAllShippingAddresses() ); }
php
protected function _extractQuoteAmounts(Mage_Sales_Model_Quote $quote) { return array_map( function ($address) { return array( 'subtotal' => round($address->getSubtotal(), 4) ?: 0.0000, 'discount' => round($address->getDiscountAmount(), 4) ?: 0.0000, 'ship_amount' => round($address->getShippingAmount(), 4) ?: 0.0000, 'ship_discount' => round($address->getShippingDiscountAmount(), 4) ?: 0.0000, 'giftwrap_amount' => round($address->getGwPrice() + $address->getGwItemsPrice(), 4) ?: 0.0000, ); }, $quote->getAllShippingAddresses() ); }
[ "protected", "function", "_extractQuoteAmounts", "(", "Mage_Sales_Model_Quote", "$", "quote", ")", "{", "return", "array_map", "(", "function", "(", "$", "address", ")", "{", "return", "array", "(", "'subtotal'", "=>", "round", "(", "$", "address", "->", "getSubtotal", "(", ")", ",", "4", ")", "?", ":", "0.0000", ",", "'discount'", "=>", "round", "(", "$", "address", "->", "getDiscountAmount", "(", ")", ",", "4", ")", "?", ":", "0.0000", ",", "'ship_amount'", "=>", "round", "(", "$", "address", "->", "getShippingAmount", "(", ")", ",", "4", ")", "?", ":", "0.0000", ",", "'ship_discount'", "=>", "round", "(", "$", "address", "->", "getShippingDiscountAmount", "(", ")", ",", "4", ")", "?", ":", "0.0000", ",", "'giftwrap_amount'", "=>", "round", "(", "$", "address", "->", "getGwPrice", "(", ")", "+", "$", "address", "->", "getGwItemsPrice", "(", ")", ",", "4", ")", "?", ":", "0.0000", ",", ")", ";", "}", ",", "$", "quote", "->", "getAllShippingAddresses", "(", ")", ")", ";", "}" ]
Extract quote amounts from each address. @param Mage_Sales_Model_Quote $quote @return array
[ "Extract", "quote", "amounts", "from", "each", "address", "." ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L134-L148
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._diffQuoteData
protected function _diffQuoteData($oldQuote, $newQuote) { if (empty($oldQuote)) { return $newQuote; } return $this->_diffBilling($oldQuote['billing'], $newQuote['billing']) + $this->_diffCoupon($oldQuote['coupon'], $newQuote['coupon']) + $this->_diffShipping($oldQuote['shipping'], $newQuote['shipping']) + $this->_diffSkus($oldQuote['skus'], $newQuote['skus']) + $this->_diffAmounts($oldQuote['amounts'], $newQuote['amounts']); }
php
protected function _diffQuoteData($oldQuote, $newQuote) { if (empty($oldQuote)) { return $newQuote; } return $this->_diffBilling($oldQuote['billing'], $newQuote['billing']) + $this->_diffCoupon($oldQuote['coupon'], $newQuote['coupon']) + $this->_diffShipping($oldQuote['shipping'], $newQuote['shipping']) + $this->_diffSkus($oldQuote['skus'], $newQuote['skus']) + $this->_diffAmounts($oldQuote['amounts'], $newQuote['amounts']); }
[ "protected", "function", "_diffQuoteData", "(", "$", "oldQuote", ",", "$", "newQuote", ")", "{", "if", "(", "empty", "(", "$", "oldQuote", ")", ")", "{", "return", "$", "newQuote", ";", "}", "return", "$", "this", "->", "_diffBilling", "(", "$", "oldQuote", "[", "'billing'", "]", ",", "$", "newQuote", "[", "'billing'", "]", ")", "+", "$", "this", "->", "_diffCoupon", "(", "$", "oldQuote", "[", "'coupon'", "]", ",", "$", "newQuote", "[", "'coupon'", "]", ")", "+", "$", "this", "->", "_diffShipping", "(", "$", "oldQuote", "[", "'shipping'", "]", ",", "$", "newQuote", "[", "'shipping'", "]", ")", "+", "$", "this", "->", "_diffSkus", "(", "$", "oldQuote", "[", "'skus'", "]", ",", "$", "newQuote", "[", "'skus'", "]", ")", "+", "$", "this", "->", "_diffAmounts", "(", "$", "oldQuote", "[", "'amounts'", "]", ",", "$", "newQuote", "[", "'amounts'", "]", ")", ";", "}" ]
Diff the new quote to the old quote. May contain keys for 'billing', 'coupon', 'shipping' and 'skus'. For more details on the type of changes detected for each key, see the responsible methods for diffing those sets of data. @param array $oldQuote Array of data extracted from a quote @param array $newQuote Array of data extracted from a quote @return array Array of changes made between the two sets of quote data
[ "Diff", "the", "new", "quote", "to", "the", "old", "quote", ".", "May", "contain", "keys", "for", "billing", "coupon", "shipping", "and", "skus", ".", "For", "more", "details", "on", "the", "type", "of", "changes", "detected", "for", "each", "key", "see", "the", "responsible", "methods", "for", "diffing", "those", "sets", "of", "data", "." ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L252-L262
train
RadialCorp/magento-core
src/app/code/community/Radial/Core/Model/Session.php
Radial_Core_Model_Session._anyItem
protected function _anyItem($items, $key) { foreach ($items as $item) { if (isset($item[$key]) && $item[$key]) { return true; } } return false; }
php
protected function _anyItem($items, $key) { foreach ($items as $item) { if (isset($item[$key]) && $item[$key]) { return true; } } return false; }
[ "protected", "function", "_anyItem", "(", "$", "items", ",", "$", "key", ")", "{", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "$", "key", "]", ")", "&&", "$", "item", "[", "$", "key", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check the set of items to have an item with the given key set to a truthy value. @param array $items array of item data @param string $key array key to check @return bool true if any item has a truthy value at the given key
[ "Check", "the", "set", "of", "items", "to", "have", "an", "item", "with", "the", "given", "key", "set", "to", "a", "truthy", "value", "." ]
9bb5f218d9caf79eab8598f4f8447037a0cc6355
https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Model/Session.php#L270-L278
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.keepOpen
public function keepOpen() { $stoppedProperty = new \ReflectionProperty(get_parent_class($this), 'stopped'); $stoppedProperty->setAccessible(TRUE); $stoppedProperty->setValue($this, TRUE); }
php
public function keepOpen() { $stoppedProperty = new \ReflectionProperty(get_parent_class($this), 'stopped'); $stoppedProperty->setAccessible(TRUE); $stoppedProperty->setValue($this, TRUE); }
[ "public", "function", "keepOpen", "(", ")", "{", "$", "stoppedProperty", "=", "new", "\\", "ReflectionProperty", "(", "get_parent_class", "(", "$", "this", ")", ",", "'stopped'", ")", ";", "$", "stoppedProperty", "->", "setAccessible", "(", "TRUE", ")", ";", "$", "stoppedProperty", "->", "setValue", "(", "$", "this", ",", "TRUE", ")", ";", "}" ]
Calling this method avoids destructor to send DELETE session request. The browser window will close either way, but after some quite long timeout (at least with ChromeDriver).
[ "Calling", "this", "method", "avoids", "destructor", "to", "send", "DELETE", "session", "request", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L109-L114
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.getLink
public function getLink($presenterName, $parameters = array()) { $url = new \Nette\Http\UrlScript($this->context->parameters['selenium']['baseUrl']); $url->scriptPath = $url->path; $appRequest = new \Nette\Application\Request($presenterName, 'GET', Utils::strToArray($parameters)); return $this->context->router->constructUrl($appRequest, $url); }
php
public function getLink($presenterName, $parameters = array()) { $url = new \Nette\Http\UrlScript($this->context->parameters['selenium']['baseUrl']); $url->scriptPath = $url->path; $appRequest = new \Nette\Application\Request($presenterName, 'GET', Utils::strToArray($parameters)); return $this->context->router->constructUrl($appRequest, $url); }
[ "public", "function", "getLink", "(", "$", "presenterName", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "url", "=", "new", "\\", "Nette", "\\", "Http", "\\", "UrlScript", "(", "$", "this", "->", "context", "->", "parameters", "[", "'selenium'", "]", "[", "'baseUrl'", "]", ")", ";", "$", "url", "->", "scriptPath", "=", "$", "url", "->", "path", ";", "$", "appRequest", "=", "new", "\\", "Nette", "\\", "Application", "\\", "Request", "(", "$", "presenterName", ",", "'GET'", ",", "Utils", "::", "strToArray", "(", "$", "parameters", ")", ")", ";", "return", "$", "this", "->", "context", "->", "router", "->", "constructUrl", "(", "$", "appRequest", ",", "$", "url", ")", ";", "}" ]
Creates an URL. Parameters can be either a PHP array, or a Neon array without brackets. Ie. Instead of `array('a' => 'b', 'c' => 'd')` you can pass `'a=b,c=d'`. @param string $presenterName @param array|string $parameters
[ "Creates", "an", "URL", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L146-L152
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.getAppRequest
public function getAppRequest($url = NULL) { $httpRequest = new \Nette\Http\Request($this->getUrlScriptForUrl($url ? : $this->url())); return $this->context->router->match($httpRequest); }
php
public function getAppRequest($url = NULL) { $httpRequest = new \Nette\Http\Request($this->getUrlScriptForUrl($url ? : $this->url())); return $this->context->router->match($httpRequest); }
[ "public", "function", "getAppRequest", "(", "$", "url", "=", "NULL", ")", "{", "$", "httpRequest", "=", "new", "\\", "Nette", "\\", "Http", "\\", "Request", "(", "$", "this", "->", "getUrlScriptForUrl", "(", "$", "url", "?", ":", "$", "this", "->", "url", "(", ")", ")", ")", ";", "return", "$", "this", "->", "context", "->", "router", "->", "match", "(", "$", "httpRequest", ")", ";", "}" ]
URL back-routed into application request object. @param string|NULL $url URL or NULL for current URL. @return \Nette\Application\Request
[ "URL", "back", "-", "routed", "into", "application", "request", "object", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L160-L164
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.waitForAlert
public function waitForAlert($timeout = 60) { $result = FALSE; $i = 0; do { sleep(1); try { $result = $this->alertText(); } catch (\RuntimeException $e) { ; } } while (++$i < $timeout && $result === FALSE); return $result; }
php
public function waitForAlert($timeout = 60) { $result = FALSE; $i = 0; do { sleep(1); try { $result = $this->alertText(); } catch (\RuntimeException $e) { ; } } while (++$i < $timeout && $result === FALSE); return $result; }
[ "public", "function", "waitForAlert", "(", "$", "timeout", "=", "60", ")", "{", "$", "result", "=", "FALSE", ";", "$", "i", "=", "0", ";", "do", "{", "sleep", "(", "1", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "alertText", "(", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", ";", "}", "}", "while", "(", "++", "$", "i", "<", "$", "timeout", "&&", "$", "result", "===", "FALSE", ")", ";", "return", "$", "result", ";", "}" ]
Wait for javascript alert, prompt or confirm dialog. @param int $timeout Patience in seconds. @return string|bool Alert text, or FALSE if waiting times out.
[ "Wait", "for", "javascript", "alert", "prompt", "or", "confirm", "dialog", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L172-L189
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.waitForCondition
public function waitForCondition($jsCondition, $timeout = 60) { $i = 0; do { sleep(1); } while ( !($result = $this->execute(array('script' => 'return ' . $jsCondition, 'args' => array()))) && $i++ < $timeout ); return $result; }
php
public function waitForCondition($jsCondition, $timeout = 60) { $i = 0; do { sleep(1); } while ( !($result = $this->execute(array('script' => 'return ' . $jsCondition, 'args' => array()))) && $i++ < $timeout ); return $result; }
[ "public", "function", "waitForCondition", "(", "$", "jsCondition", ",", "$", "timeout", "=", "60", ")", "{", "$", "i", "=", "0", ";", "do", "{", "sleep", "(", "1", ")", ";", "}", "while", "(", "!", "(", "$", "result", "=", "$", "this", "->", "execute", "(", "array", "(", "'script'", "=>", "'return '", ".", "$", "jsCondition", ",", "'args'", "=>", "array", "(", ")", ")", ")", ")", "&&", "$", "i", "++", "<", "$", "timeout", ")", ";", "return", "$", "result", ";", "}" ]
Wait for fulfilment of some javascript condition. @param string $jsCondition Javascript code. @param int $timeout Amount of patience in seconds. @return bool Whether the condition was fulfilled.
[ "Wait", "for", "fulfilment", "of", "some", "javascript", "condition", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L220-L231
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.getActiveElement
public function getActiveElement() { $response = $this->driver->curl('POST', $this->url->addCommand('element/active')); return Element::fromResponseValue($response->getValue(), $this->url->descend('element'), $this->driver); }
php
public function getActiveElement() { $response = $this->driver->curl('POST', $this->url->addCommand('element/active')); return Element::fromResponseValue($response->getValue(), $this->url->descend('element'), $this->driver); }
[ "public", "function", "getActiveElement", "(", ")", "{", "$", "response", "=", "$", "this", "->", "driver", "->", "curl", "(", "'POST'", ",", "$", "this", "->", "url", "->", "addCommand", "(", "'element/active'", ")", ")", ";", "return", "Element", "::", "fromResponseValue", "(", "$", "response", "->", "getValue", "(", ")", ",", "$", "this", "->", "url", "->", "descend", "(", "'element'", ")", ",", "$", "this", "->", "driver", ")", ";", "}" ]
Get the element on the page that currently has focus. @return Element
[ "Get", "the", "element", "on", "the", "page", "that", "currently", "has", "focus", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L249-L253
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.element
public function element(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) { $value = $this->postCommand('element', $criteria); return Element::fromResponseValue($value, $this->url->descend('element'), $this->driver); }
php
public function element(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) { $value = $this->postCommand('element', $criteria); return Element::fromResponseValue($value, $this->url->descend('element'), $this->driver); }
[ "public", "function", "element", "(", "\\", "PHPUnit_Extensions_Selenium2TestCase_ElementCriteria", "$", "criteria", ")", "{", "$", "value", "=", "$", "this", "->", "postCommand", "(", "'element'", ",", "$", "criteria", ")", ";", "return", "Element", "::", "fromResponseValue", "(", "$", "value", ",", "$", "this", "->", "url", "->", "descend", "(", "'element'", ")", ",", "$", "this", "->", "driver", ")", ";", "}" ]
Finds an element using the criteria. Criteria are set by this WTF way: <code> $session->element($session->using('xpath')->value('//input[type="text"]')); </code> @param \PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria @return Element
[ "Finds", "an", "element", "using", "the", "criteria", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L266-L270
train
Clevis/Se34
Se34/BrowserSession.php
BrowserSession.elements
public function elements(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) { $values = $this->postCommand('elements', $criteria); $elements = array(); foreach ($values as $value) { $elements[] = Element::fromResponseValue($value, $this->url->descend('element'), $this->driver); } return $elements; }
php
public function elements(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria) { $values = $this->postCommand('elements', $criteria); $elements = array(); foreach ($values as $value) { $elements[] = Element::fromResponseValue($value, $this->url->descend('element'), $this->driver); } return $elements; }
[ "public", "function", "elements", "(", "\\", "PHPUnit_Extensions_Selenium2TestCase_ElementCriteria", "$", "criteria", ")", "{", "$", "values", "=", "$", "this", "->", "postCommand", "(", "'elements'", ",", "$", "criteria", ")", ";", "$", "elements", "=", "array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "elements", "[", "]", "=", "Element", "::", "fromResponseValue", "(", "$", "value", ",", "$", "this", "->", "url", "->", "descend", "(", "'element'", ")", ",", "$", "this", "->", "driver", ")", ";", "}", "return", "$", "elements", ";", "}" ]
Finds elements using given criteria. Similar to {@see BrowserSession::element()}, only this returns all matched elements as an array. Also, this doesn't throw an exception if no element was found. @param \PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria @return Element[] array of instances of Se34\Element
[ "Finds", "elements", "using", "given", "criteria", "." ]
c52d579a831ba5642dae464882da012b0409ae46
https://github.com/Clevis/Se34/blob/c52d579a831ba5642dae464882da012b0409ae46/Se34/BrowserSession.php#L282-L291
train
stonedz/pff2
src/Abs/AModule.php
AModule.getRequiredModules
public function getRequiredModules($moduleName) { $moduleName = strtolower($moduleName); if (isset($this->_requiredModules[$moduleName])) { return $this->_requiredModules[$moduleName]; } else { return null; } }
php
public function getRequiredModules($moduleName) { $moduleName = strtolower($moduleName); if (isset($this->_requiredModules[$moduleName])) { return $this->_requiredModules[$moduleName]; } else { return null; } }
[ "public", "function", "getRequiredModules", "(", "$", "moduleName", ")", "{", "$", "moduleName", "=", "strtolower", "(", "$", "moduleName", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_requiredModules", "[", "$", "moduleName", "]", ")", ")", "{", "return", "$", "this", "->", "_requiredModules", "[", "$", "moduleName", "]", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets a module @param string $moduleName @return AModule|null
[ "Gets", "a", "module" ]
ec3b087d4d4732816f61ac487f0cb25511e0da88
https://github.com/stonedz/pff2/blob/ec3b087d4d4732816f61ac487f0cb25511e0da88/src/Abs/AModule.php#L122-L130
train
stonedz/pff2
src/Abs/AModule.php
AModule.readConfig
public function readConfig($configFile) { $yamlParser = new \Symfony\Component\Yaml\Parser(); $userConfPath = ROOT . DS . 'app' . DS . 'config' . DS . 'modules' . DS . $configFile; $userCustomPath = ROOT. DS . 'app'. DS.'modules'.DS.$configFile; $composerConfPath = ROOT . DS . 'modules' . DS . $configFile; $libConfPath = ROOT_LIB . DS . 'src' . DS . 'modules' . DS . $configFile; if (file_exists($userConfPath)) { $confPath = $userConfPath; } elseif (file_exists($userCustomPath)) { $confPath = $userCustomPath; } elseif (file_exists($composerConfPath)) { $confPath = $composerConfPath; } elseif (file_exists($libConfPath)) { $confPath = $libConfPath; } else { throw new ModuleException ("Module configuration file not found!"); } try { $conf = $yamlParser->parse(file_get_contents($confPath)); } catch (\Symfony\Component\Yaml\Exception\ParseException $e) { throw new ModuleException("Unable to parse module configuration file for AutomaticHeaderFooter module: " . $e->getMessage()); } return $conf; }
php
public function readConfig($configFile) { $yamlParser = new \Symfony\Component\Yaml\Parser(); $userConfPath = ROOT . DS . 'app' . DS . 'config' . DS . 'modules' . DS . $configFile; $userCustomPath = ROOT. DS . 'app'. DS.'modules'.DS.$configFile; $composerConfPath = ROOT . DS . 'modules' . DS . $configFile; $libConfPath = ROOT_LIB . DS . 'src' . DS . 'modules' . DS . $configFile; if (file_exists($userConfPath)) { $confPath = $userConfPath; } elseif (file_exists($userCustomPath)) { $confPath = $userCustomPath; } elseif (file_exists($composerConfPath)) { $confPath = $composerConfPath; } elseif (file_exists($libConfPath)) { $confPath = $libConfPath; } else { throw new ModuleException ("Module configuration file not found!"); } try { $conf = $yamlParser->parse(file_get_contents($confPath)); } catch (\Symfony\Component\Yaml\Exception\ParseException $e) { throw new ModuleException("Unable to parse module configuration file for AutomaticHeaderFooter module: " . $e->getMessage()); } return $conf; }
[ "public", "function", "readConfig", "(", "$", "configFile", ")", "{", "$", "yamlParser", "=", "new", "\\", "Symfony", "\\", "Component", "\\", "Yaml", "\\", "Parser", "(", ")", ";", "$", "userConfPath", "=", "ROOT", ".", "DS", ".", "'app'", ".", "DS", ".", "'config'", ".", "DS", ".", "'modules'", ".", "DS", ".", "$", "configFile", ";", "$", "userCustomPath", "=", "ROOT", ".", "DS", ".", "'app'", ".", "DS", ".", "'modules'", ".", "DS", ".", "$", "configFile", ";", "$", "composerConfPath", "=", "ROOT", ".", "DS", ".", "'modules'", ".", "DS", ".", "$", "configFile", ";", "$", "libConfPath", "=", "ROOT_LIB", ".", "DS", ".", "'src'", ".", "DS", ".", "'modules'", ".", "DS", ".", "$", "configFile", ";", "if", "(", "file_exists", "(", "$", "userConfPath", ")", ")", "{", "$", "confPath", "=", "$", "userConfPath", ";", "}", "elseif", "(", "file_exists", "(", "$", "userCustomPath", ")", ")", "{", "$", "confPath", "=", "$", "userCustomPath", ";", "}", "elseif", "(", "file_exists", "(", "$", "composerConfPath", ")", ")", "{", "$", "confPath", "=", "$", "composerConfPath", ";", "}", "elseif", "(", "file_exists", "(", "$", "libConfPath", ")", ")", "{", "$", "confPath", "=", "$", "libConfPath", ";", "}", "else", "{", "throw", "new", "ModuleException", "(", "\"Module configuration file not found!\"", ")", ";", "}", "try", "{", "$", "conf", "=", "$", "yamlParser", "->", "parse", "(", "file_get_contents", "(", "$", "confPath", ")", ")", ";", "}", "catch", "(", "\\", "Symfony", "\\", "Component", "\\", "Yaml", "\\", "Exception", "\\", "ParseException", "$", "e", ")", "{", "throw", "new", "ModuleException", "(", "\"Unable to parse module configuration\n file for AutomaticHeaderFooter module: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "conf", ";", "}" ]
Reads the configuration file ad returns a configuration array @param string $configFile The module filename @throws ModuleException @return array
[ "Reads", "the", "configuration", "file", "ad", "returns", "a", "configuration", "array" ]
ec3b087d4d4732816f61ac487f0cb25511e0da88
https://github.com/stonedz/pff2/blob/ec3b087d4d4732816f61ac487f0cb25511e0da88/src/Abs/AModule.php#L195-L220
train
schpill/thin
src/Injection/Manager.php
InstanceManager.addSharedInstance
public function addSharedInstance($instance, $classOrAlias) { if (!is_object($instance)) { throw new Exception('This method requires an object to be shared. Class or Alias given: ' . $classOrAlias); } $this->sharedInstances[$classOrAlias] = $instance; }
php
public function addSharedInstance($instance, $classOrAlias) { if (!is_object($instance)) { throw new Exception('This method requires an object to be shared. Class or Alias given: ' . $classOrAlias); } $this->sharedInstances[$classOrAlias] = $instance; }
[ "public", "function", "addSharedInstance", "(", "$", "instance", ",", "$", "classOrAlias", ")", "{", "if", "(", "!", "is_object", "(", "$", "instance", ")", ")", "{", "throw", "new", "Exception", "(", "'This method requires an object to be shared. Class or Alias given: '", ".", "$", "classOrAlias", ")", ";", "}", "$", "this", "->", "sharedInstances", "[", "$", "classOrAlias", "]", "=", "$", "instance", ";", "}" ]
Add shared instance @param object $instance @param string $classOrAlias @throws Exception
[ "Add", "shared", "instance" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L88-L95
train
schpill/thin
src/Injection/Manager.php
InstanceManager.getSharedInstanceWithParameters
public function getSharedInstanceWithParameters($classOrAlias, array $params, $fastHashFromHasLookup = null) { if ($fastHashFromHasLookup) { return $this->sharedInstancesWithParams['hashLong'][$fastHashFromHasLookup]; } ksort($params); $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params)); if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) { $hashValue = $this->createHashForValues($classOrAlias, $params); if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) { return $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue]; } } return false; }
php
public function getSharedInstanceWithParameters($classOrAlias, array $params, $fastHashFromHasLookup = null) { if ($fastHashFromHasLookup) { return $this->sharedInstancesWithParams['hashLong'][$fastHashFromHasLookup]; } ksort($params); $hashKey = $this->createHashForKeys($classOrAlias, array_keys($params)); if (isset($this->sharedInstancesWithParams['hashShort'][$hashKey])) { $hashValue = $this->createHashForValues($classOrAlias, $params); if (isset($this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue])) { return $this->sharedInstancesWithParams['hashLong'][$hashKey . '/' . $hashValue]; } } return false; }
[ "public", "function", "getSharedInstanceWithParameters", "(", "$", "classOrAlias", ",", "array", "$", "params", ",", "$", "fastHashFromHasLookup", "=", "null", ")", "{", "if", "(", "$", "fastHashFromHasLookup", ")", "{", "return", "$", "this", "->", "sharedInstancesWithParams", "[", "'hashLong'", "]", "[", "$", "fastHashFromHasLookup", "]", ";", "}", "ksort", "(", "$", "params", ")", ";", "$", "hashKey", "=", "$", "this", "->", "createHashForKeys", "(", "$", "classOrAlias", ",", "array_keys", "(", "$", "params", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "sharedInstancesWithParams", "[", "'hashShort'", "]", "[", "$", "hashKey", "]", ")", ")", "{", "$", "hashValue", "=", "$", "this", "->", "createHashForValues", "(", "$", "classOrAlias", ",", "$", "params", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "sharedInstancesWithParams", "[", "'hashLong'", "]", "[", "$", "hashKey", ".", "'/'", ".", "$", "hashValue", "]", ")", ")", "{", "return", "$", "this", "->", "sharedInstancesWithParams", "[", "'hashLong'", "]", "[", "$", "hashKey", ".", "'/'", ".", "$", "hashValue", "]", ";", "}", "}", "return", "false", ";", "}" ]
Retrieves an instance by its name and the parameters stored at its instantiation @param string $classOrAlias @param array $params @param bool|null $fastHashFromHasLookup @return object|bool false if no instance was found
[ "Retrieves", "an", "instance", "by", "its", "name", "and", "the", "parameters", "stored", "at", "its", "instantiation" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L150-L168
train
schpill/thin
src/Injection/Manager.php
InstanceManager.hasConfig
public function hasConfig($aliasOrClass) { $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass; if (!isset($this->configurations[$key])) { return false; } if ($this->configurations[$key] === $this->configurationTemplate) { return false; } return true; }
php
public function hasConfig($aliasOrClass) { $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass; if (!isset($this->configurations[$key])) { return false; } if ($this->configurations[$key] === $this->configurationTemplate) { return false; } return true; }
[ "public", "function", "hasConfig", "(", "$", "aliasOrClass", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "aliasOrClass", ")", ")", "?", "'alias:'", ".", "$", "this", "->", "getBaseAlias", "(", "$", "aliasOrClass", ")", ":", "$", "aliasOrClass", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "configurations", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "configurations", "[", "$", "key", "]", "===", "$", "this", "->", "configurationTemplate", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check for configuration @param string $aliasOrClass @return bool
[ "Check", "for", "configuration" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L279-L292
train
schpill/thin
src/Injection/Manager.php
InstanceManager.hasTypePreferences
public function hasTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; return (isset($this->typePreferences[$key]) && $this->typePreferences[$key]); }
php
public function hasTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; return (isset($this->typePreferences[$key]) && $this->typePreferences[$key]); }
[ "public", "function", "hasTypePreferences", "(", "$", "interfaceOrAbstract", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "interfaceOrAbstract", ")", ")", "?", "'alias:'", ".", "$", "interfaceOrAbstract", ":", "$", "interfaceOrAbstract", ";", "return", "(", "isset", "(", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", "&&", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", ";", "}" ]
Check for type preferences @param string $interfaceOrAbstract @return bool
[ "Check", "for", "type", "preferences" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L397-L402
train
schpill/thin
src/Injection/Manager.php
InstanceManager.setTypePreference
public function setTypePreference($interfaceOrAbstract, array $preferredImplementations) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; foreach ($preferredImplementations as $preferredImplementation) { $this->addTypePreference($key, $preferredImplementation); } return $this; }
php
public function setTypePreference($interfaceOrAbstract, array $preferredImplementations) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; foreach ($preferredImplementations as $preferredImplementation) { $this->addTypePreference($key, $preferredImplementation); } return $this; }
[ "public", "function", "setTypePreference", "(", "$", "interfaceOrAbstract", ",", "array", "$", "preferredImplementations", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "interfaceOrAbstract", ")", ")", "?", "'alias:'", ".", "$", "interfaceOrAbstract", ":", "$", "interfaceOrAbstract", ";", "foreach", "(", "$", "preferredImplementations", "as", "$", "preferredImplementation", ")", "{", "$", "this", "->", "addTypePreference", "(", "$", "key", ",", "$", "preferredImplementation", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set type preference @param string $interfaceOrAbstract @param array $preferredImplementations @return InstanceManager
[ "Set", "type", "preference" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L411-L420
train
schpill/thin
src/Injection/Manager.php
InstanceManager.getTypePreferences
public function getTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; if (isset($this->typePreferences[$key])) { return $this->typePreferences[$key]; } return []; }
php
public function getTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; if (isset($this->typePreferences[$key])) { return $this->typePreferences[$key]; } return []; }
[ "public", "function", "getTypePreferences", "(", "$", "interfaceOrAbstract", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "interfaceOrAbstract", ")", ")", "?", "'alias:'", ".", "$", "interfaceOrAbstract", ":", "$", "interfaceOrAbstract", ";", "if", "(", "isset", "(", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ";", "}", "return", "[", "]", ";", "}" ]
Get type preferences @param string $interfaceOrAbstract @return array
[ "Get", "type", "preferences" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L428-L437
train
schpill/thin
src/Injection/Manager.php
InstanceManager.unsetTypePreferences
public function unsetTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; unset($this->typePreferences[$key]); }
php
public function unsetTypePreferences($interfaceOrAbstract) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; unset($this->typePreferences[$key]); }
[ "public", "function", "unsetTypePreferences", "(", "$", "interfaceOrAbstract", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "interfaceOrAbstract", ")", ")", "?", "'alias:'", ".", "$", "interfaceOrAbstract", ":", "$", "interfaceOrAbstract", ";", "unset", "(", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", ";", "}" ]
Unset type preferences @param string $interfaceOrAbstract @return void
[ "Unset", "type", "preferences" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L445-L450
train
schpill/thin
src/Injection/Manager.php
InstanceManager.removeTypePreference
public function removeTypePreference($interfaceOrAbstract, $preferredType) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; if (!isset($this->typePreferences[$key]) || !Arrays::in($preferredType, $this->typePreferences[$key])) { return false; } unset($this->typePreferences[$key][array_search($key, $this->typePreferences)]); return $this; }
php
public function removeTypePreference($interfaceOrAbstract, $preferredType) { $key = ($this->hasAlias($interfaceOrAbstract)) ? 'alias:' . $interfaceOrAbstract : $interfaceOrAbstract; if (!isset($this->typePreferences[$key]) || !Arrays::in($preferredType, $this->typePreferences[$key])) { return false; } unset($this->typePreferences[$key][array_search($key, $this->typePreferences)]); return $this; }
[ "public", "function", "removeTypePreference", "(", "$", "interfaceOrAbstract", ",", "$", "preferredType", ")", "{", "$", "key", "=", "(", "$", "this", "->", "hasAlias", "(", "$", "interfaceOrAbstract", ")", ")", "?", "'alias:'", ".", "$", "interfaceOrAbstract", ":", "$", "interfaceOrAbstract", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", "||", "!", "Arrays", "::", "in", "(", "$", "preferredType", ",", "$", "this", "->", "typePreferences", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "unset", "(", "$", "this", "->", "typePreferences", "[", "$", "key", "]", "[", "array_search", "(", "$", "key", ",", "$", "this", "->", "typePreferences", ")", "]", ")", ";", "return", "$", "this", ";", "}" ]
Removes a previously set type preference @param string $interfaceOrAbstract @param string $preferredType @return bool|self
[ "Removes", "a", "previously", "set", "type", "preference" ]
a9102d9d6f70e8b0f6be93153f70849f46489ee1
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Injection/Manager.php#L480-L491
train
jasny/entity
src/EventListener/ToAssocRecursive.php
ToAssocRecursive.toAssocRecursive
protected function toAssocRecursive($input, SplObjectStorage $list): array { $values = is_iterable($input) ? i\iterable_to_array($input) : object_get_properties($input, $input instanceof stdClass || $input instanceof DynamicEntity); foreach ($values as $key => &$value) { if ($value instanceof Entity) { $value = $list->contains($value) ? $list[$value] : $this->toAssocEntity($value, $list); if ($value === null && !is_int($key)) { unset($values[$key]); } } elseif (is_iterable($value) || $value instanceof stdClass) { $value = $this->toAssocRecursive($value, $list); } } return $values; }
php
protected function toAssocRecursive($input, SplObjectStorage $list): array { $values = is_iterable($input) ? i\iterable_to_array($input) : object_get_properties($input, $input instanceof stdClass || $input instanceof DynamicEntity); foreach ($values as $key => &$value) { if ($value instanceof Entity) { $value = $list->contains($value) ? $list[$value] : $this->toAssocEntity($value, $list); if ($value === null && !is_int($key)) { unset($values[$key]); } } elseif (is_iterable($value) || $value instanceof stdClass) { $value = $this->toAssocRecursive($value, $list); } } return $values; }
[ "protected", "function", "toAssocRecursive", "(", "$", "input", ",", "SplObjectStorage", "$", "list", ")", ":", "array", "{", "$", "values", "=", "is_iterable", "(", "$", "input", ")", "?", "i", "\\", "iterable_to_array", "(", "$", "input", ")", ":", "object_get_properties", "(", "$", "input", ",", "$", "input", "instanceof", "stdClass", "||", "$", "input", "instanceof", "DynamicEntity", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Entity", ")", "{", "$", "value", "=", "$", "list", "->", "contains", "(", "$", "value", ")", "?", "$", "list", "[", "$", "value", "]", ":", "$", "this", "->", "toAssocEntity", "(", "$", "value", ",", "$", "list", ")", ";", "if", "(", "$", "value", "===", "null", "&&", "!", "is_int", "(", "$", "key", ")", ")", "{", "unset", "(", "$", "values", "[", "$", "key", "]", ")", ";", "}", "}", "elseif", "(", "is_iterable", "(", "$", "value", ")", "||", "$", "value", "instanceof", "stdClass", ")", "{", "$", "value", "=", "$", "this", "->", "toAssocRecursive", "(", "$", "value", ",", "$", "list", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
Recursively cast to associative arrays. @param iterable|object $input @param SplObjectStorage $list Entity / assoc map for entities that already have been converted @return array
[ "Recursively", "cast", "to", "associative", "arrays", "." ]
5af7c94645671a3257d6565ff1891ff61fdcf69b
https://github.com/jasny/entity/blob/5af7c94645671a3257d6565ff1891ff61fdcf69b/src/EventListener/ToAssocRecursive.php#L62-L81
train
MovingImage24/VM6ApiClient
lib/Entity/Video.php
Video.getStills
public function getStills() { if (!isset($this->stills)) { $this->stills = [ new Still($this->thumbnail_url, 'default'), new Still($this->thumbnail_url_lq, 'lq'), new Still($this->thumbnail_url_mq, 'mq'), ]; } return $this->stills; }
php
public function getStills() { if (!isset($this->stills)) { $this->stills = [ new Still($this->thumbnail_url, 'default'), new Still($this->thumbnail_url_lq, 'lq'), new Still($this->thumbnail_url_mq, 'mq'), ]; } return $this->stills; }
[ "public", "function", "getStills", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "stills", ")", ")", "{", "$", "this", "->", "stills", "=", "[", "new", "Still", "(", "$", "this", "->", "thumbnail_url", ",", "'default'", ")", ",", "new", "Still", "(", "$", "this", "->", "thumbnail_url_lq", ",", "'lq'", ")", ",", "new", "Still", "(", "$", "this", "->", "thumbnail_url_mq", ",", "'mq'", ")", ",", "]", ";", "}", "return", "$", "this", "->", "stills", ";", "}" ]
Generate a list of Still entities based on other properties that come from VM 6. @return Still[]
[ "Generate", "a", "list", "of", "Still", "entities", "based", "on", "other", "properties", "that", "come", "from", "VM", "6", "." ]
84e6510fa0fb71cfbb42ea9f23775f681c266fac
https://github.com/MovingImage24/VM6ApiClient/blob/84e6510fa0fb71cfbb42ea9f23775f681c266fac/lib/Entity/Video.php#L267-L278
train
PhoxPHP/Glider
src/Connection/ConnectionManager.php
ConnectionManager.get
private function get(String $id) { if (!$id) { $id = ConnectionManager::DEFAULT_CONNECTION_ID; } if (count($this->loadedConnections) < 1) { return false; } if (isset($this->loadedConnections[$id])) { $this->configuredConnectionId = $id; $this->platformConnector = [$id => $this->loadedConnections[$id]]; $connector = new PlatformResolver($this); return $connector->resolvePlatform(new EventManager()); } }
php
private function get(String $id) { if (!$id) { $id = ConnectionManager::DEFAULT_CONNECTION_ID; } if (count($this->loadedConnections) < 1) { return false; } if (isset($this->loadedConnections[$id])) { $this->configuredConnectionId = $id; $this->platformConnector = [$id => $this->loadedConnections[$id]]; $connector = new PlatformResolver($this); return $connector->resolvePlatform(new EventManager()); } }
[ "private", "function", "get", "(", "String", "$", "id", ")", "{", "if", "(", "!", "$", "id", ")", "{", "$", "id", "=", "ConnectionManager", "::", "DEFAULT_CONNECTION_ID", ";", "}", "if", "(", "count", "(", "$", "this", "->", "loadedConnections", ")", "<", "1", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "loadedConnections", "[", "$", "id", "]", ")", ")", "{", "$", "this", "->", "configuredConnectionId", "=", "$", "id", ";", "$", "this", "->", "platformConnector", "=", "[", "$", "id", "=>", "$", "this", "->", "loadedConnections", "[", "$", "id", "]", "]", ";", "$", "connector", "=", "new", "PlatformResolver", "(", "$", "this", ")", ";", "return", "$", "connector", "->", "resolvePlatform", "(", "new", "EventManager", "(", ")", ")", ";", "}", "}" ]
Try to connection with this id from the loaded connections in the configuration file. @param $id <String> @access private @return <Mixed>
[ "Try", "to", "connection", "with", "this", "id", "from", "the", "loaded", "connections", "in", "the", "configuration", "file", "." ]
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Connection/ConnectionManager.php#L223-L239
train
phramework/testphase
src/Globals.php
Globals.toString
public static function toString() { $return = []; foreach (static::$globals as $key => $value) { $type = gettype($value); if (is_callable($value)) { $valueString = 'callable'; $type = 'callable'; } elseif (is_array($value)) { $valueString = implode(', ', $value); } else { $valueString = (string)$value; } $return[] = sprintf( '"%s": (%s) %s', $key, $type, $valueString ); } return implode(PHP_EOL, $return); }
php
public static function toString() { $return = []; foreach (static::$globals as $key => $value) { $type = gettype($value); if (is_callable($value)) { $valueString = 'callable'; $type = 'callable'; } elseif (is_array($value)) { $valueString = implode(', ', $value); } else { $valueString = (string)$value; } $return[] = sprintf( '"%s": (%s) %s', $key, $type, $valueString ); } return implode(PHP_EOL, $return); }
[ "public", "static", "function", "toString", "(", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "static", "::", "$", "globals", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "type", "=", "gettype", "(", "$", "value", ")", ";", "if", "(", "is_callable", "(", "$", "value", ")", ")", "{", "$", "valueString", "=", "'callable'", ";", "$", "type", "=", "'callable'", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "valueString", "=", "implode", "(", "', '", ",", "$", "value", ")", ";", "}", "else", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "}", "$", "return", "[", "]", "=", "sprintf", "(", "'\"%s\": (%s) %s'", ",", "$", "key", ",", "$", "type", ",", "$", "valueString", ")", ";", "}", "return", "implode", "(", "PHP_EOL", ",", "$", "return", ")", ";", "}" ]
Return keys and values of global variables as string @return string
[ "Return", "keys", "and", "values", "of", "global", "variables", "as", "string" ]
b00107b7a37cf1a1b9b8860b3eb031aacfa2634c
https://github.com/phramework/testphase/blob/b00107b7a37cf1a1b9b8860b3eb031aacfa2634c/src/Globals.php#L245-L270
train
DBRisinajumi/d2company
controllers/CcucUserCompanyController.php
CcucUserCompanyController.actionEditableSaver
public function actionEditableSaver() { Yii::import('EditableSaver'); //or you can add import 'ext.editable.*' to config $es = new EditableSaver('CcucUserCompany'); // classname of model to be updated $es->update(); //verify if change statuss if($es->attribute != 'ccuc_status'){ return; } //verify if status changet to USER if($es->value != CcucUserCompany::CCUC_STATUS_USER){ return; } //if do not have user, create $m = Person::model(); return $m->createUser($es->model->ccucPerson->id); }
php
public function actionEditableSaver() { Yii::import('EditableSaver'); //or you can add import 'ext.editable.*' to config $es = new EditableSaver('CcucUserCompany'); // classname of model to be updated $es->update(); //verify if change statuss if($es->attribute != 'ccuc_status'){ return; } //verify if status changet to USER if($es->value != CcucUserCompany::CCUC_STATUS_USER){ return; } //if do not have user, create $m = Person::model(); return $m->createUser($es->model->ccucPerson->id); }
[ "public", "function", "actionEditableSaver", "(", ")", "{", "Yii", "::", "import", "(", "'EditableSaver'", ")", ";", "//or you can add import 'ext.editable.*' to config", "$", "es", "=", "new", "EditableSaver", "(", "'CcucUserCompany'", ")", ";", "// classname of model to be updated", "$", "es", "->", "update", "(", ")", ";", "//verify if change statuss ", "if", "(", "$", "es", "->", "attribute", "!=", "'ccuc_status'", ")", "{", "return", ";", "}", "//verify if status changet to USER", "if", "(", "$", "es", "->", "value", "!=", "CcucUserCompany", "::", "CCUC_STATUS_USER", ")", "{", "return", ";", "}", "//if do not have user, create", "$", "m", "=", "Person", "::", "model", "(", ")", ";", "return", "$", "m", "->", "createUser", "(", "$", "es", "->", "model", "->", "ccucPerson", "->", "id", ")", ";", "}" ]
for company ccuc on change status to USER create customer office uses @return type
[ "for", "company", "ccuc", "on", "change", "status", "to", "USER", "create", "customer", "office", "uses" ]
20df0db96ac2c8e73471c4bab7d487b67ef4ed0a
https://github.com/DBRisinajumi/d2company/blob/20df0db96ac2c8e73471c4bab7d487b67ef4ed0a/controllers/CcucUserCompanyController.php#L129-L149
train
rbone/phactory
lib/Phactory/Loader.php
Loader.load
public function load($name) { $factoryClass = ucfirst($name) . "Phactory"; if (!class_exists($factoryClass)) { throw new \Exception("Unknown factory '$name'"); } return new Factory($name, new $factoryClass); }
php
public function load($name) { $factoryClass = ucfirst($name) . "Phactory"; if (!class_exists($factoryClass)) { throw new \Exception("Unknown factory '$name'"); } return new Factory($name, new $factoryClass); }
[ "public", "function", "load", "(", "$", "name", ")", "{", "$", "factoryClass", "=", "ucfirst", "(", "$", "name", ")", ".", "\"Phactory\"", ";", "if", "(", "!", "class_exists", "(", "$", "factoryClass", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Unknown factory '$name'\"", ")", ";", "}", "return", "new", "Factory", "(", "$", "name", ",", "new", "$", "factoryClass", ")", ";", "}" ]
Loads the factory according to the object class name @param string $name @return \Phactory\Factory @throws \Exception
[ "Loads", "the", "factory", "according", "to", "the", "object", "class", "name" ]
f1c474084f9b310d171f393fe196e8a2a7aae1ec
https://github.com/rbone/phactory/blob/f1c474084f9b310d171f393fe196e8a2a7aae1ec/lib/Phactory/Loader.php#L17-L26
train
newestindustry/ginger-rest
src/Ginger/XMLSerializer.php
XMLSerializer.generateValidXmlFromArray
public static function generateValidXmlFromArray($array, $node_block='response', $node_name='item') { $xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= '<' . $node_block . '>'; $xml .= self::generateXmlFromArray($array, $node_name); $xml .= '</' . $node_block . '>'; return $xml; }
php
public static function generateValidXmlFromArray($array, $node_block='response', $node_name='item') { $xml = '<?xml version="1.0" encoding="UTF-8" ?>'; $xml .= '<' . $node_block . '>'; $xml .= self::generateXmlFromArray($array, $node_name); $xml .= '</' . $node_block . '>'; return $xml; }
[ "public", "static", "function", "generateValidXmlFromArray", "(", "$", "array", ",", "$", "node_block", "=", "'response'", ",", "$", "node_name", "=", "'item'", ")", "{", "$", "xml", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\" ?>'", ";", "$", "xml", ".=", "'<'", ".", "$", "node_block", ".", "'>'", ";", "$", "xml", ".=", "self", "::", "generateXmlFromArray", "(", "$", "array", ",", "$", "node_name", ")", ";", "$", "xml", ".=", "'</'", ".", "$", "node_block", ".", "'>'", ";", "return", "$", "xml", ";", "}" ]
Generate valid xml from array @param array $array @param string $node_block @param string $node_name @return string
[ "Generate", "valid", "xml", "from", "array" ]
482b77dc122a60ab0bf143a3c4a1e67168985c83
https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/XMLSerializer.php#L38-L47
train
newestindustry/ginger-rest
src/Ginger/XMLSerializer.php
XMLSerializer.generateXmlFromArray
private static function generateXmlFromArray($array, $node_name) { $xml = ''; if (is_array($array) || is_object($array)) { foreach ($array as $key=>$value) { if (is_numeric($key)) { $key = $node_name; } $xml .= '<' . $key . '>' . self::generateXmlFromArray($value, $node_name) . '</' . $key . '>'; } } else { $xml = htmlspecialchars($array, ENT_QUOTES); } return $xml; }
php
private static function generateXmlFromArray($array, $node_name) { $xml = ''; if (is_array($array) || is_object($array)) { foreach ($array as $key=>$value) { if (is_numeric($key)) { $key = $node_name; } $xml .= '<' . $key . '>' . self::generateXmlFromArray($value, $node_name) . '</' . $key . '>'; } } else { $xml = htmlspecialchars($array, ENT_QUOTES); } return $xml; }
[ "private", "static", "function", "generateXmlFromArray", "(", "$", "array", ",", "$", "node_name", ")", "{", "$", "xml", "=", "''", ";", "if", "(", "is_array", "(", "$", "array", ")", "||", "is_object", "(", "$", "array", ")", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "key", "=", "$", "node_name", ";", "}", "$", "xml", ".=", "'<'", ".", "$", "key", ".", "'>'", ".", "self", "::", "generateXmlFromArray", "(", "$", "value", ",", "$", "node_name", ")", ".", "'</'", ".", "$", "key", ".", "'>'", ";", "}", "}", "else", "{", "$", "xml", "=", "htmlspecialchars", "(", "$", "array", ",", "ENT_QUOTES", ")", ";", "}", "return", "$", "xml", ";", "}" ]
Generate XML from array @param array $array @param string $node_name @return string
[ "Generate", "XML", "from", "array" ]
482b77dc122a60ab0bf143a3c4a1e67168985c83
https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/XMLSerializer.php#L56-L73
train
luoxiaojun1992/lb_framework
components/Log.php
Log.addDeferLog
protected function addDeferLog($role, $level, $message, $context) { $this->deferLogs[] = compact('role', 'level', 'message', 'context'); $this->deferLogsCount++; }
php
protected function addDeferLog($role, $level, $message, $context) { $this->deferLogs[] = compact('role', 'level', 'message', 'context'); $this->deferLogsCount++; }
[ "protected", "function", "addDeferLog", "(", "$", "role", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", "{", "$", "this", "->", "deferLogs", "[", "]", "=", "compact", "(", "'role'", ",", "'level'", ",", "'message'", ",", "'context'", ")", ";", "$", "this", "->", "deferLogsCount", "++", ";", "}" ]
Add a defer log @param $role @param $level @param $message @param $context
[ "Add", "a", "defer", "log" ]
12a865729e7738d7d1e07371ad7203243c4571fa
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/Log.php#L145-L149
train
luoxiaojun1992/lb_framework
components/Log.php
Log.removeDeferLog
protected function removeDeferLog($k) { if (!isset($this->deferLogs[$k])) { return; } unset($this->deferLogs[$k]); $this->deferLogsCount--; }
php
protected function removeDeferLog($k) { if (!isset($this->deferLogs[$k])) { return; } unset($this->deferLogs[$k]); $this->deferLogsCount--; }
[ "protected", "function", "removeDeferLog", "(", "$", "k", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "deferLogs", "[", "$", "k", "]", ")", ")", "{", "return", ";", "}", "unset", "(", "$", "this", "->", "deferLogs", "[", "$", "k", "]", ")", ";", "$", "this", "->", "deferLogsCount", "--", ";", "}" ]
Remove a defer log @param $k
[ "Remove", "a", "defer", "log" ]
12a865729e7738d7d1e07371ad7203243c4571fa
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/Log.php#L156-L164
train
luoxiaojun1992/lb_framework
components/Log.php
Log.flush
public function flush() { //todo bugfix batch record foreach ($this->deferLogs as $k => $deferLog) { $this->record($deferLog['message'], $deferLog['context'], $deferLog['level'], $deferLog['role']); $this->removeDeferLog($k); } }
php
public function flush() { //todo bugfix batch record foreach ($this->deferLogs as $k => $deferLog) { $this->record($deferLog['message'], $deferLog['context'], $deferLog['level'], $deferLog['role']); $this->removeDeferLog($k); } }
[ "public", "function", "flush", "(", ")", "{", "//todo bugfix batch record", "foreach", "(", "$", "this", "->", "deferLogs", "as", "$", "k", "=>", "$", "deferLog", ")", "{", "$", "this", "->", "record", "(", "$", "deferLog", "[", "'message'", "]", ",", "$", "deferLog", "[", "'context'", "]", ",", "$", "deferLog", "[", "'level'", "]", ",", "$", "deferLog", "[", "'role'", "]", ")", ";", "$", "this", "->", "removeDeferLog", "(", "$", "k", ")", ";", "}", "}" ]
Flush defer logs
[ "Flush", "defer", "logs" ]
12a865729e7738d7d1e07371ad7203243c4571fa
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/Log.php#L169-L176
train
factorio-item-browser/api-client
src/Serializer/SerializerFactory.php
SerializerFactory.addCacheDirectory
protected function addCacheDirectory(ContainerInterface $container, SerializerBuilder $builder): void { $config = $container->get('config'); $libraryConfig = $config[ConfigKey::PROJECT][ConfigKey::API_CLIENT] ?? []; $cacheDir = (string) ($libraryConfig[ConfigKey::CACHE_DIR] ?? ''); if ($cacheDir !== '') { $builder->setCacheDir($cacheDir); } }
php
protected function addCacheDirectory(ContainerInterface $container, SerializerBuilder $builder): void { $config = $container->get('config'); $libraryConfig = $config[ConfigKey::PROJECT][ConfigKey::API_CLIENT] ?? []; $cacheDir = (string) ($libraryConfig[ConfigKey::CACHE_DIR] ?? ''); if ($cacheDir !== '') { $builder->setCacheDir($cacheDir); } }
[ "protected", "function", "addCacheDirectory", "(", "ContainerInterface", "$", "container", ",", "SerializerBuilder", "$", "builder", ")", ":", "void", "{", "$", "config", "=", "$", "container", "->", "get", "(", "'config'", ")", ";", "$", "libraryConfig", "=", "$", "config", "[", "ConfigKey", "::", "PROJECT", "]", "[", "ConfigKey", "::", "API_CLIENT", "]", "??", "[", "]", ";", "$", "cacheDir", "=", "(", "string", ")", "(", "$", "libraryConfig", "[", "ConfigKey", "::", "CACHE_DIR", "]", "??", "''", ")", ";", "if", "(", "$", "cacheDir", "!==", "''", ")", "{", "$", "builder", "->", "setCacheDir", "(", "$", "cacheDir", ")", ";", "}", "}" ]
Adds the cache directory from the config to the builder. @param ContainerInterface $container @param SerializerBuilder $builder
[ "Adds", "the", "cache", "directory", "from", "the", "config", "to", "the", "builder", "." ]
ebda897483bd537c310a17ff868ca40c0568f728
https://github.com/factorio-item-browser/api-client/blob/ebda897483bd537c310a17ff868ca40c0568f728/src/Serializer/SerializerFactory.php#L56-L65
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.setOptions
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new \InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value){ $key = strtolower($key); if($key == 'loader'){ $this->setLoader($value); } } return $this; }
php
public function setOptions($options) { if (!is_array($options) && !$options instanceof Traversable) { throw new \InvalidArgumentException(sprintf( 'Expected an array or Traversable; received "%s"', (is_object($options) ? get_class($options) : gettype($options)) )); } foreach ($options as $key => $value){ $key = strtolower($key); if($key == 'loader'){ $this->setLoader($value); } } return $this; }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", "&&", "!", "$", "options", "instanceof", "Traversable", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected an array or Traversable; received \"%s\"'", ",", "(", "is_object", "(", "$", "options", ")", "?", "get_class", "(", "$", "options", ")", ":", "gettype", "(", "$", "options", ")", ")", ")", ")", ";", "}", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "if", "(", "$", "key", "==", "'loader'", ")", "{", "$", "this", "->", "setLoader", "(", "$", "value", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Configure service broker Use this method to configure service broker. Currently supports only option 'loader' which calls {@see setLoader()}. @param array|Traversable $options @throws \InvalidArgumentException @return \ValuSo\Broker\ServiceBroker
[ "Configure", "service", "broker" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L96-L115
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.getDefaultIdentity
public function getDefaultIdentity() { if (!$this->defaultIdentity) { $this->defaultIdentity = new ArrayObject(array()); if ($this->exists('Identity')) { $responses = $this->execute( 'Identity', 'getIdentity', array(), function($response){if($response instanceof ArrayAccess) return true;}); if (sizeof($responses)) { $this->defaultIdentity = $responses->last(); } if ($this->defaultIdentity instanceof \ArrayObject) { $this->defaultIdentity->setFlags(\ArrayObject::ARRAY_AS_PROPS); } elseif(!$this->defaultIdentity) { return new \ArrayObject([]); } } } return $this->defaultIdentity; }
php
public function getDefaultIdentity() { if (!$this->defaultIdentity) { $this->defaultIdentity = new ArrayObject(array()); if ($this->exists('Identity')) { $responses = $this->execute( 'Identity', 'getIdentity', array(), function($response){if($response instanceof ArrayAccess) return true;}); if (sizeof($responses)) { $this->defaultIdentity = $responses->last(); } if ($this->defaultIdentity instanceof \ArrayObject) { $this->defaultIdentity->setFlags(\ArrayObject::ARRAY_AS_PROPS); } elseif(!$this->defaultIdentity) { return new \ArrayObject([]); } } } return $this->defaultIdentity; }
[ "public", "function", "getDefaultIdentity", "(", ")", "{", "if", "(", "!", "$", "this", "->", "defaultIdentity", ")", "{", "$", "this", "->", "defaultIdentity", "=", "new", "ArrayObject", "(", "array", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exists", "(", "'Identity'", ")", ")", "{", "$", "responses", "=", "$", "this", "->", "execute", "(", "'Identity'", ",", "'getIdentity'", ",", "array", "(", ")", ",", "function", "(", "$", "response", ")", "{", "if", "(", "$", "response", "instanceof", "ArrayAccess", ")", "return", "true", ";", "}", ")", ";", "if", "(", "sizeof", "(", "$", "responses", ")", ")", "{", "$", "this", "->", "defaultIdentity", "=", "$", "responses", "->", "last", "(", ")", ";", "}", "if", "(", "$", "this", "->", "defaultIdentity", "instanceof", "\\", "ArrayObject", ")", "{", "$", "this", "->", "defaultIdentity", "->", "setFlags", "(", "\\", "ArrayObject", "::", "ARRAY_AS_PROPS", ")", ";", "}", "elseif", "(", "!", "$", "this", "->", "defaultIdentity", ")", "{", "return", "new", "\\", "ArrayObject", "(", "[", "]", ")", ";", "}", "}", "}", "return", "$", "this", "->", "defaultIdentity", ";", "}" ]
Retrieve default identity @return \ArrayAccess|null
[ "Retrieve", "default", "identity" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L141-L167
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.setLoader
public function setLoader(ServiceLoader $loader){ $this->loader = $loader; $that = $this; $this->loader->addInitializer(function ($instance) use ($that) { // Inject broker to services if ($instance instanceof Feature\ServiceBrokerAwareInterface) { $instance->setServiceBroker($that); } // Inject event manager to services if ($instance instanceof EventManagerAwareInterface) { $instance->setEventManager($that->getEventManager()); } }); return $this; }
php
public function setLoader(ServiceLoader $loader){ $this->loader = $loader; $that = $this; $this->loader->addInitializer(function ($instance) use ($that) { // Inject broker to services if ($instance instanceof Feature\ServiceBrokerAwareInterface) { $instance->setServiceBroker($that); } // Inject event manager to services if ($instance instanceof EventManagerAwareInterface) { $instance->setEventManager($that->getEventManager()); } }); return $this; }
[ "public", "function", "setLoader", "(", "ServiceLoader", "$", "loader", ")", "{", "$", "this", "->", "loader", "=", "$", "loader", ";", "$", "that", "=", "$", "this", ";", "$", "this", "->", "loader", "->", "addInitializer", "(", "function", "(", "$", "instance", ")", "use", "(", "$", "that", ")", "{", "// Inject broker to services", "if", "(", "$", "instance", "instanceof", "Feature", "\\", "ServiceBrokerAwareInterface", ")", "{", "$", "instance", "->", "setServiceBroker", "(", "$", "that", ")", ";", "}", "// Inject event manager to services", "if", "(", "$", "instance", "instanceof", "EventManagerAwareInterface", ")", "{", "$", "instance", "->", "setEventManager", "(", "$", "that", "->", "getEventManager", "(", ")", ")", ";", "}", "}", ")", ";", "return", "$", "this", ";", "}" ]
Set service loader instance @param ServiceLoader $loader
[ "Set", "service", "loader", "instance" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L185-L204
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.service
public function service($service){ if(!$this->exists($service)){ throw new ServiceNotFoundException(sprintf('Service "%s" not found', $service)); } return new Worker($this, $service); }
php
public function service($service){ if(!$this->exists($service)){ throw new ServiceNotFoundException(sprintf('Service "%s" not found', $service)); } return new Worker($this, $service); }
[ "public", "function", "service", "(", "$", "service", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "service", ")", ")", "{", "throw", "new", "ServiceNotFoundException", "(", "sprintf", "(", "'Service \"%s\" not found'", ",", "$", "service", ")", ")", ";", "}", "return", "new", "Worker", "(", "$", "this", ",", "$", "service", ")", ";", "}" ]
Initialize and retrieve a new service Worker @param string $service @throws ServiceNotFoundException @return Worker
[ "Initialize", "and", "retrieve", "a", "new", "service", "Worker" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L257-L264
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.executeInContext
public function executeInContext($context, $service, $operation, $argv = array(), $callback = null) { $command = new Command( $service, $operation, $argv, $context); return $this->dispatch($command, $callback); }
php
public function executeInContext($context, $service, $operation, $argv = array(), $callback = null) { $command = new Command( $service, $operation, $argv, $context); return $this->dispatch($command, $callback); }
[ "public", "function", "executeInContext", "(", "$", "context", ",", "$", "service", ",", "$", "operation", ",", "$", "argv", "=", "array", "(", ")", ",", "$", "callback", "=", "null", ")", "{", "$", "command", "=", "new", "Command", "(", "$", "service", ",", "$", "operation", ",", "$", "argv", ",", "$", "context", ")", ";", "return", "$", "this", "->", "dispatch", "(", "$", "command", ",", "$", "callback", ")", ";", "}" ]
Execute service operation in context @param string $context @param string $service @param string $operation @param array $argv @param mixed $callback Valid PHP callback @param string $context @return ResponseCollection
[ "Execute", "service", "operation", "in", "context" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L290-L299
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.queue
public function queue(CommandInterface $command, array $options = []) { $queueName = null; if (array_key_exists(self::QUEUE_OPTION_NAME, $options)) { $queueName = $options[self::QUEUE_OPTION_NAME] ?: null; unset($options[self::QUEUE_OPTION_NAME]); } $queue = $this->getQueue($queueName); if ($command->getIdentity()) { $identity = $command->getIdentity(); } else if ($this->getDefaultIdentity()) { $identity = $this->getDefaultIdentity(); } else { $identity = null; } if (method_exists($identity, 'toArray')) { $identity = $identity->toArray(); } else if ($identity instanceof \ArrayObject) { $identity = $identity->getArrayCopy(); } $job = new ServiceJob(); $job->setup($command, $identity); $job->setServiceBroker($this); $queue->push($job, $options); return $job; }
php
public function queue(CommandInterface $command, array $options = []) { $queueName = null; if (array_key_exists(self::QUEUE_OPTION_NAME, $options)) { $queueName = $options[self::QUEUE_OPTION_NAME] ?: null; unset($options[self::QUEUE_OPTION_NAME]); } $queue = $this->getQueue($queueName); if ($command->getIdentity()) { $identity = $command->getIdentity(); } else if ($this->getDefaultIdentity()) { $identity = $this->getDefaultIdentity(); } else { $identity = null; } if (method_exists($identity, 'toArray')) { $identity = $identity->toArray(); } else if ($identity instanceof \ArrayObject) { $identity = $identity->getArrayCopy(); } $job = new ServiceJob(); $job->setup($command, $identity); $job->setServiceBroker($this); $queue->push($job, $options); return $job; }
[ "public", "function", "queue", "(", "CommandInterface", "$", "command", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "queueName", "=", "null", ";", "if", "(", "array_key_exists", "(", "self", "::", "QUEUE_OPTION_NAME", ",", "$", "options", ")", ")", "{", "$", "queueName", "=", "$", "options", "[", "self", "::", "QUEUE_OPTION_NAME", "]", "?", ":", "null", ";", "unset", "(", "$", "options", "[", "self", "::", "QUEUE_OPTION_NAME", "]", ")", ";", "}", "$", "queue", "=", "$", "this", "->", "getQueue", "(", "$", "queueName", ")", ";", "if", "(", "$", "command", "->", "getIdentity", "(", ")", ")", "{", "$", "identity", "=", "$", "command", "->", "getIdentity", "(", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getDefaultIdentity", "(", ")", ")", "{", "$", "identity", "=", "$", "this", "->", "getDefaultIdentity", "(", ")", ";", "}", "else", "{", "$", "identity", "=", "null", ";", "}", "if", "(", "method_exists", "(", "$", "identity", ",", "'toArray'", ")", ")", "{", "$", "identity", "=", "$", "identity", "->", "toArray", "(", ")", ";", "}", "else", "if", "(", "$", "identity", "instanceof", "\\", "ArrayObject", ")", "{", "$", "identity", "=", "$", "identity", "->", "getArrayCopy", "(", ")", ";", "}", "$", "job", "=", "new", "ServiceJob", "(", ")", ";", "$", "job", "->", "setup", "(", "$", "command", ",", "$", "identity", ")", ";", "$", "job", "->", "setServiceBroker", "(", "$", "this", ")", ";", "$", "queue", "->", "push", "(", "$", "job", ",", "$", "options", ")", ";", "return", "$", "job", ";", "}" ]
Queue execution of service operation @param CommandInterface $command @param array $options @return ServiceJob
[ "Queue", "execution", "of", "service", "operation" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L308-L339
train
valu-digital/valuso
src/ValuSo/Broker/ServiceBroker.php
ServiceBroker.createEvent
protected function createEvent($name, CommandInterface $command) { $event = new ServiceEvent(); $event->setName($name); $event->setCommand($command); $event->setParams($command->getParams()); return $event; }
php
protected function createEvent($name, CommandInterface $command) { $event = new ServiceEvent(); $event->setName($name); $event->setCommand($command); $event->setParams($command->getParams()); return $event; }
[ "protected", "function", "createEvent", "(", "$", "name", ",", "CommandInterface", "$", "command", ")", "{", "$", "event", "=", "new", "ServiceEvent", "(", ")", ";", "$", "event", "->", "setName", "(", "$", "name", ")", ";", "$", "event", "->", "setCommand", "(", "$", "command", ")", ";", "$", "event", "->", "setParams", "(", "$", "command", "->", "getParams", "(", ")", ")", ";", "return", "$", "event", ";", "}" ]
Create a new service event @param string $name @param CommandInterface $command @return \ValuSo\Broker\ServiceEvent
[ "Create", "a", "new", "service", "event" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBroker.php#L515-L523
train
worldnettps/magento2-module-subscription
Model/Status.php
Status.getCurrency
public function getCurrency() { $options = [ 'EUR' => __('Euro'), 'GBP' => __('Sterling'), 'USD' => __('US Dollar'), 'CAD' => __('Canadian Dollar'), 'AUD' => __('Australian Dollar'), 'DKK' => __('Danish Krone'), 'SEK' => __('Swedish Krona'), 'NOK' => __('Norwegian Krone') ]; return $options; }
php
public function getCurrency() { $options = [ 'EUR' => __('Euro'), 'GBP' => __('Sterling'), 'USD' => __('US Dollar'), 'CAD' => __('Canadian Dollar'), 'AUD' => __('Australian Dollar'), 'DKK' => __('Danish Krone'), 'SEK' => __('Swedish Krona'), 'NOK' => __('Norwegian Krone') ]; return $options; }
[ "public", "function", "getCurrency", "(", ")", "{", "$", "options", "=", "[", "'EUR'", "=>", "__", "(", "'Euro'", ")", ",", "'GBP'", "=>", "__", "(", "'Sterling'", ")", ",", "'USD'", "=>", "__", "(", "'US Dollar'", ")", ",", "'CAD'", "=>", "__", "(", "'Canadian Dollar'", ")", ",", "'AUD'", "=>", "__", "(", "'Australian Dollar'", ")", ",", "'DKK'", "=>", "__", "(", "'Danish Krone'", ")", ",", "'SEK'", "=>", "__", "(", "'Swedish Krona'", ")", ",", "'NOK'", "=>", "__", "(", "'Norwegian Krone'", ")", "]", ";", "return", "$", "options", ";", "}" ]
Get Grid row currency labels array. @return array
[ "Get", "Grid", "row", "currency", "labels", "array", "." ]
dcac6fb7f13bc9a3d47cb9ca04734fef627b0eab
https://github.com/worldnettps/magento2-module-subscription/blob/dcac6fb7f13bc9a3d47cb9ca04734fef627b0eab/Model/Status.php#L11-L23
train
bariew/yii2-doctest-extension
MethodParser.php
MethodParser.processComment
protected function processComment() { $comment=strtr(trim(preg_replace('/^\s*\**( |\t)?/m','',trim($this->getDocComment(),'/'))),"\r",''); if(preg_match('/^\s*@\w+/m',$comment, $matches, PREG_OFFSET_CAPTURE)){ $meta=substr($comment,$matches[0][1]); $this->processTags($meta); } }
php
protected function processComment() { $comment=strtr(trim(preg_replace('/^\s*\**( |\t)?/m','',trim($this->getDocComment(),'/'))),"\r",''); if(preg_match('/^\s*@\w+/m',$comment, $matches, PREG_OFFSET_CAPTURE)){ $meta=substr($comment,$matches[0][1]); $this->processTags($meta); } }
[ "protected", "function", "processComment", "(", ")", "{", "$", "comment", "=", "strtr", "(", "trim", "(", "preg_replace", "(", "'/^\\s*\\**( |\\t)?/m'", ",", "''", ",", "trim", "(", "$", "this", "->", "getDocComment", "(", ")", ",", "'/'", ")", ")", ")", ",", "\"\\r\"", ",", "''", ")", ";", "if", "(", "preg_match", "(", "'/^\\s*@\\w+/m'", ",", "$", "comment", ",", "$", "matches", ",", "PREG_OFFSET_CAPTURE", ")", ")", "{", "$", "meta", "=", "substr", "(", "$", "comment", ",", "$", "matches", "[", "0", "]", "[", "1", "]", ")", ";", "$", "this", "->", "processTags", "(", "$", "meta", ")", ";", "}", "}" ]
gets tags lines from docblock @author Qiang Xue <qiang.xue@gmail.com>
[ "gets", "tags", "lines", "from", "docblock" ]
526e0281f055dbd55ad5fbcb2a3104164a056e0b
https://github.com/bariew/yii2-doctest-extension/blob/526e0281f055dbd55ad5fbcb2a3104164a056e0b/MethodParser.php#L23-L30
train
bariew/yii2-doctest-extension
MethodParser.php
MethodParser.processTags
protected function processTags($comment) { $tags = preg_split('/^\s*@/m',$comment,-1,PREG_SPLIT_NO_EMPTY); foreach($tags as $tag){ $segs = preg_split('/\s+/',trim($tag),2); $tagName= $segs[0]; $param = isset($segs[1]) ? trim($segs[1]) : ''; $this->tags[$tagName][] = $param; } }
php
protected function processTags($comment) { $tags = preg_split('/^\s*@/m',$comment,-1,PREG_SPLIT_NO_EMPTY); foreach($tags as $tag){ $segs = preg_split('/\s+/',trim($tag),2); $tagName= $segs[0]; $param = isset($segs[1]) ? trim($segs[1]) : ''; $this->tags[$tagName][] = $param; } }
[ "protected", "function", "processTags", "(", "$", "comment", ")", "{", "$", "tags", "=", "preg_split", "(", "'/^\\s*@/m'", ",", "$", "comment", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "segs", "=", "preg_split", "(", "'/\\s+/'", ",", "trim", "(", "$", "tag", ")", ",", "2", ")", ";", "$", "tagName", "=", "$", "segs", "[", "0", "]", ";", "$", "param", "=", "isset", "(", "$", "segs", "[", "1", "]", ")", "?", "trim", "(", "$", "segs", "[", "1", "]", ")", ":", "''", ";", "$", "this", "->", "tags", "[", "$", "tagName", "]", "[", "]", "=", "$", "param", ";", "}", "}" ]
extracts tags array from docblock @param string $comment docblock @author Qiang Xue <qiang.xue@gmail.com>
[ "extracts", "tags", "array", "from", "docblock" ]
526e0281f055dbd55ad5fbcb2a3104164a056e0b
https://github.com/bariew/yii2-doctest-extension/blob/526e0281f055dbd55ad5fbcb2a3104164a056e0b/MethodParser.php#L36-L45
train
gbprod/doctrine-specification
src/DoctrineSpecification/Registry.php
Registry.getFactory
public function getFactory(Specification $spec): Factory { if(!isset($this->factories[get_class($spec)])) { throw new \OutOfRangeException(sprintf( 'Factory for Specification "%s" not registred', get_class($spec) )); } return $this->factories[get_class($spec)]; }
php
public function getFactory(Specification $spec): Factory { if(!isset($this->factories[get_class($spec)])) { throw new \OutOfRangeException(sprintf( 'Factory for Specification "%s" not registred', get_class($spec) )); } return $this->factories[get_class($spec)]; }
[ "public", "function", "getFactory", "(", "Specification", "$", "spec", ")", ":", "Factory", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factories", "[", "get_class", "(", "$", "spec", ")", "]", ")", ")", "{", "throw", "new", "\\", "OutOfRangeException", "(", "sprintf", "(", "'Factory for Specification \"%s\" not registred'", ",", "get_class", "(", "$", "spec", ")", ")", ")", ";", "}", "return", "$", "this", "->", "factories", "[", "get_class", "(", "$", "spec", ")", "]", ";", "}" ]
Get registred factory for Specification @param Specification $spec @return Factory @throw OutOfRangeException if Factory not found
[ "Get", "registred", "factory", "for", "Specification" ]
348e8ec31547f4949a193d21b3a1d5cdb48b23cb
https://github.com/gbprod/doctrine-specification/blob/348e8ec31547f4949a193d21b3a1d5cdb48b23cb/src/DoctrineSpecification/Registry.php#L42-L52
train
carno-php/nsq
src/Chips/TMCommands.php
TMCommands.retry
public function retry(int $delayed = 0) : void { $this->link->req($this->id(), $delayed); }
php
public function retry(int $delayed = 0) : void { $this->link->req($this->id(), $delayed); }
[ "public", "function", "retry", "(", "int", "$", "delayed", "=", "0", ")", ":", "void", "{", "$", "this", "->", "link", "->", "req", "(", "$", "this", "->", "id", "(", ")", ",", "$", "delayed", ")", ";", "}" ]
delayed in milliseconds @param int $delayed
[ "delayed", "in", "milliseconds" ]
cc4f1278556ff530bbe2e03345bdeb54fef1275a
https://github.com/carno-php/nsq/blob/cc4f1278556ff530bbe2e03345bdeb54fef1275a/src/Chips/TMCommands.php#L41-L44
train
bruno-barros/w.eloquent-framework
src/weloquent/Plugins/Blade/blade.php
BladePlugin.parse
public function parse($template) { $viewsFromConfig = $this->app['config']->get('view.paths'); $views = array_merge((array)$viewsFromConfig, (array)$this->paths['theme']); $cache = $this->paths['storage'] . '/views'; $blade = new BladeAdapter($views, $cache); if (!$blade->getCompiler()->isExpired($template)) { return $blade->getCompiler()->getCompiledPath($template); } $blade->getCompiler()->compile($template); return $blade->getCompiler()->getCompiledPath($template); }
php
public function parse($template) { $viewsFromConfig = $this->app['config']->get('view.paths'); $views = array_merge((array)$viewsFromConfig, (array)$this->paths['theme']); $cache = $this->paths['storage'] . '/views'; $blade = new BladeAdapter($views, $cache); if (!$blade->getCompiler()->isExpired($template)) { return $blade->getCompiler()->getCompiledPath($template); } $blade->getCompiler()->compile($template); return $blade->getCompiler()->getCompiledPath($template); }
[ "public", "function", "parse", "(", "$", "template", ")", "{", "$", "viewsFromConfig", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'view.paths'", ")", ";", "$", "views", "=", "array_merge", "(", "(", "array", ")", "$", "viewsFromConfig", ",", "(", "array", ")", "$", "this", "->", "paths", "[", "'theme'", "]", ")", ";", "$", "cache", "=", "$", "this", "->", "paths", "[", "'storage'", "]", ".", "'/views'", ";", "$", "blade", "=", "new", "BladeAdapter", "(", "$", "views", ",", "$", "cache", ")", ";", "if", "(", "!", "$", "blade", "->", "getCompiler", "(", ")", "->", "isExpired", "(", "$", "template", ")", ")", "{", "return", "$", "blade", "->", "getCompiler", "(", ")", "->", "getCompiledPath", "(", "$", "template", ")", ";", "}", "$", "blade", "->", "getCompiler", "(", ")", "->", "compile", "(", "$", "template", ")", ";", "return", "$", "blade", "->", "getCompiler", "(", ")", "->", "getCompiledPath", "(", "$", "template", ")", ";", "}" ]
Handle the compilation of the templates @param $template
[ "Handle", "the", "compilation", "of", "the", "templates" ]
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Plugins/Blade/blade.php#L103-L122
train
Anahkiasen/php-configuration
src/TreeBuilder/ClosureNode.php
ClosureNode.validateType
protected function validateType($value) { if (!$value instanceof Closure && $value !== null) { $exception = new InvalidTypeException(sprintf( 'Invalid type for path "%s". Expected closure, but got %s.', $this->getPath(), gettype($value) )); if ($hint = $this->getInfo()) { $exception->addHint($hint); } $exception->setPath($this->getPath()); throw $exception; } }
php
protected function validateType($value) { if (!$value instanceof Closure && $value !== null) { $exception = new InvalidTypeException(sprintf( 'Invalid type for path "%s". Expected closure, but got %s.', $this->getPath(), gettype($value) )); if ($hint = $this->getInfo()) { $exception->addHint($hint); } $exception->setPath($this->getPath()); throw $exception; } }
[ "protected", "function", "validateType", "(", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "Closure", "&&", "$", "value", "!==", "null", ")", "{", "$", "exception", "=", "new", "InvalidTypeException", "(", "sprintf", "(", "'Invalid type for path \"%s\". Expected closure, but got %s.'", ",", "$", "this", "->", "getPath", "(", ")", ",", "gettype", "(", "$", "value", ")", ")", ")", ";", "if", "(", "$", "hint", "=", "$", "this", "->", "getInfo", "(", ")", ")", "{", "$", "exception", "->", "addHint", "(", "$", "hint", ")", ";", "}", "$", "exception", "->", "setPath", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "throw", "$", "exception", ";", "}", "}" ]
Validates the type of a Node. @param mixed $value The value to validate @throws InvalidTypeException when the value is invalid
[ "Validates", "the", "type", "of", "a", "Node", "." ]
f67f1e045f3e2e3dc8bd88c66caf960095e69d97
https://github.com/Anahkiasen/php-configuration/blob/f67f1e045f3e2e3dc8bd88c66caf960095e69d97/src/TreeBuilder/ClosureNode.php#L27-L44
train
rackberg/para
src/Service/Strategy/DisplayCombinedOutputStrategy.php
DisplayCombinedOutputStrategy.addProcessInfo
private function addProcessInfo(Process $process, Project $project) { $this->processes[$project->getName()] = [ 'process' => $process, 'project' => $project, ]; }
php
private function addProcessInfo(Process $process, Project $project) { $this->processes[$project->getName()] = [ 'process' => $process, 'project' => $project, ]; }
[ "private", "function", "addProcessInfo", "(", "Process", "$", "process", ",", "Project", "$", "project", ")", "{", "$", "this", "->", "processes", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "[", "'process'", "=>", "$", "process", ",", "'project'", "=>", "$", "project", ",", "]", ";", "}" ]
Adds the process and project info. @param \Symfony\Component\Process\Process $process @param \Para\Entity\Project $project
[ "Adds", "the", "process", "and", "project", "info", "." ]
e0ef1356ed2979670eb7c670d88921406cade46e
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/Service/Strategy/DisplayCombinedOutputStrategy.php#L78-L84
train
rackberg/para
src/Service/Strategy/DisplayCombinedOutputStrategy.php
DisplayCombinedOutputStrategy.workaroundForSingleChar
private function workaroundForSingleChar( string &$incrementalOutput, Project $project ) { // Check if there is a temporarily stored char. if (!empty($this->tmpChar[$project->getName()]) && !empty($incrementalOutput)) { // Add the char directly at the beginning of the current // incremental output value. $incrementalOutput = $this->tmpChar[$project->getName()] . $incrementalOutput; // Clear the temporarily stored char. $this->tmpChar[$project->getName()] = ''; } // If there is a single char store it temporarily. if (strlen($incrementalOutput) == 1) { $this->tmpChar[$project->getName()] = $incrementalOutput; // Clear the current incremental output value so that nothing will be written to the console. $incrementalOutput = ''; } }
php
private function workaroundForSingleChar( string &$incrementalOutput, Project $project ) { // Check if there is a temporarily stored char. if (!empty($this->tmpChar[$project->getName()]) && !empty($incrementalOutput)) { // Add the char directly at the beginning of the current // incremental output value. $incrementalOutput = $this->tmpChar[$project->getName()] . $incrementalOutput; // Clear the temporarily stored char. $this->tmpChar[$project->getName()] = ''; } // If there is a single char store it temporarily. if (strlen($incrementalOutput) == 1) { $this->tmpChar[$project->getName()] = $incrementalOutput; // Clear the current incremental output value so that nothing will be written to the console. $incrementalOutput = ''; } }
[ "private", "function", "workaroundForSingleChar", "(", "string", "&", "$", "incrementalOutput", ",", "Project", "$", "project", ")", "{", "// Check if there is a temporarily stored char.", "if", "(", "!", "empty", "(", "$", "this", "->", "tmpChar", "[", "$", "project", "->", "getName", "(", ")", "]", ")", "&&", "!", "empty", "(", "$", "incrementalOutput", ")", ")", "{", "// Add the char directly at the beginning of the current", "// incremental output value.", "$", "incrementalOutput", "=", "$", "this", "->", "tmpChar", "[", "$", "project", "->", "getName", "(", ")", "]", ".", "$", "incrementalOutput", ";", "// Clear the temporarily stored char.", "$", "this", "->", "tmpChar", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "''", ";", "}", "// If there is a single char store it temporarily.", "if", "(", "strlen", "(", "$", "incrementalOutput", ")", "==", "1", ")", "{", "$", "this", "->", "tmpChar", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "$", "incrementalOutput", ";", "// Clear the current incremental output value so that nothing will be written to the console.", "$", "incrementalOutput", "=", "''", ";", "}", "}" ]
Workaround for single char. Sometimes it happens that only one char has been returned by $process->getIncrementalOutput() even if there are more chars that could also be returned. In this case we need to create a workaround, that temporarily stores the single char returned to output it in front of the next incremental output value. @param string $incrementalOutput @param Project $project
[ "Workaround", "for", "single", "char", "." ]
e0ef1356ed2979670eb7c670d88921406cade46e
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/Service/Strategy/DisplayCombinedOutputStrategy.php#L118-L136
train
rackberg/para
src/Service/Strategy/DisplayCombinedOutputStrategy.php
DisplayCombinedOutputStrategy.handleProcessOutput
protected function handleProcessOutput( array $processInfo, BufferedOutputInterface $output, callable $processTerminatedCallback ) { // Get the process. /** @var Process $process */ $process = $processInfo['process']; // Get the project. /** @var Project $project */ $project = $processInfo['project']; // Start the process if not already started. if (!$process->isStarted()) { $process->start(); } // Get the last output from the process. $incrementalOutput = $this->getIncrementalProcessOutput($process); $this->workaroundForSingleChar( $incrementalOutput, $project ); // Show the output. if ($incrementalOutput != '') { // Dispatch an event. $this->dispatcher->dispatch( IncrementalOutputReceivedEvent::NAME, new IncrementalOutputReceivedEvent( $incrementalOutput, $project, $process ) ); if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) { if ($project->getForegroundColor() <= 0) { $output->write( sprintf( '%s:' . "\t" . '%s', $project->getName(), $incrementalOutput ) ); } else { if ($this->writtenToBuffer) { $output->write("\n"); } $projectName = sprintf( "\033[38;5;%dm%s:\033[0m", $project->getForegroundColor(), $project->getName() ); if (!empty($project->getBackgroundColor())) { $projectName = sprintf( "\033[38;5;%dm%s:\033[0m", $project->getBackgroundColor(), $project->getName() ); $projectOutput = sprintf( "\t\033[38;5;%dm\033[48;5;%dm%s\033[0m", $project->getForegroundColor(), $project->getBackgroundColor(), $incrementalOutput ); } else { $projectOutput = sprintf( "\t%s", $incrementalOutput ); } $output->write( sprintf( '%s%s', $projectName, $projectOutput ) ); $this->writtenToBuffer = true; } } } if ($process->isTerminated()) { $processTerminatedCallback(); } }
php
protected function handleProcessOutput( array $processInfo, BufferedOutputInterface $output, callable $processTerminatedCallback ) { // Get the process. /** @var Process $process */ $process = $processInfo['process']; // Get the project. /** @var Project $project */ $project = $processInfo['project']; // Start the process if not already started. if (!$process->isStarted()) { $process->start(); } // Get the last output from the process. $incrementalOutput = $this->getIncrementalProcessOutput($process); $this->workaroundForSingleChar( $incrementalOutput, $project ); // Show the output. if ($incrementalOutput != '') { // Dispatch an event. $this->dispatcher->dispatch( IncrementalOutputReceivedEvent::NAME, new IncrementalOutputReceivedEvent( $incrementalOutput, $project, $process ) ); if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) { if ($project->getForegroundColor() <= 0) { $output->write( sprintf( '%s:' . "\t" . '%s', $project->getName(), $incrementalOutput ) ); } else { if ($this->writtenToBuffer) { $output->write("\n"); } $projectName = sprintf( "\033[38;5;%dm%s:\033[0m", $project->getForegroundColor(), $project->getName() ); if (!empty($project->getBackgroundColor())) { $projectName = sprintf( "\033[38;5;%dm%s:\033[0m", $project->getBackgroundColor(), $project->getName() ); $projectOutput = sprintf( "\t\033[38;5;%dm\033[48;5;%dm%s\033[0m", $project->getForegroundColor(), $project->getBackgroundColor(), $incrementalOutput ); } else { $projectOutput = sprintf( "\t%s", $incrementalOutput ); } $output->write( sprintf( '%s%s', $projectName, $projectOutput ) ); $this->writtenToBuffer = true; } } } if ($process->isTerminated()) { $processTerminatedCallback(); } }
[ "protected", "function", "handleProcessOutput", "(", "array", "$", "processInfo", ",", "BufferedOutputInterface", "$", "output", ",", "callable", "$", "processTerminatedCallback", ")", "{", "// Get the process.", "/** @var Process $process */", "$", "process", "=", "$", "processInfo", "[", "'process'", "]", ";", "// Get the project.", "/** @var Project $project */", "$", "project", "=", "$", "processInfo", "[", "'project'", "]", ";", "// Start the process if not already started.", "if", "(", "!", "$", "process", "->", "isStarted", "(", ")", ")", "{", "$", "process", "->", "start", "(", ")", ";", "}", "// Get the last output from the process.", "$", "incrementalOutput", "=", "$", "this", "->", "getIncrementalProcessOutput", "(", "$", "process", ")", ";", "$", "this", "->", "workaroundForSingleChar", "(", "$", "incrementalOutput", ",", "$", "project", ")", ";", "// Show the output.", "if", "(", "$", "incrementalOutput", "!=", "''", ")", "{", "// Dispatch an event.", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "IncrementalOutputReceivedEvent", "::", "NAME", ",", "new", "IncrementalOutputReceivedEvent", "(", "$", "incrementalOutput", ",", "$", "project", ",", "$", "process", ")", ")", ";", "if", "(", "$", "output", "->", "getVerbosity", "(", ")", ">=", "OutputInterface", "::", "VERBOSITY_NORMAL", ")", "{", "if", "(", "$", "project", "->", "getForegroundColor", "(", ")", "<=", "0", ")", "{", "$", "output", "->", "write", "(", "sprintf", "(", "'%s:'", ".", "\"\\t\"", ".", "'%s'", ",", "$", "project", "->", "getName", "(", ")", ",", "$", "incrementalOutput", ")", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "writtenToBuffer", ")", "{", "$", "output", "->", "write", "(", "\"\\n\"", ")", ";", "}", "$", "projectName", "=", "sprintf", "(", "\"\\033[38;5;%dm%s:\\033[0m\"", ",", "$", "project", "->", "getForegroundColor", "(", ")", ",", "$", "project", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "project", "->", "getBackgroundColor", "(", ")", ")", ")", "{", "$", "projectName", "=", "sprintf", "(", "\"\\033[38;5;%dm%s:\\033[0m\"", ",", "$", "project", "->", "getBackgroundColor", "(", ")", ",", "$", "project", "->", "getName", "(", ")", ")", ";", "$", "projectOutput", "=", "sprintf", "(", "\"\\t\\033[38;5;%dm\\033[48;5;%dm%s\\033[0m\"", ",", "$", "project", "->", "getForegroundColor", "(", ")", ",", "$", "project", "->", "getBackgroundColor", "(", ")", ",", "$", "incrementalOutput", ")", ";", "}", "else", "{", "$", "projectOutput", "=", "sprintf", "(", "\"\\t%s\"", ",", "$", "incrementalOutput", ")", ";", "}", "$", "output", "->", "write", "(", "sprintf", "(", "'%s%s'", ",", "$", "projectName", ",", "$", "projectOutput", ")", ")", ";", "$", "this", "->", "writtenToBuffer", "=", "true", ";", "}", "}", "}", "if", "(", "$", "process", "->", "isTerminated", "(", ")", ")", "{", "$", "processTerminatedCallback", "(", ")", ";", "}", "}" ]
Handles the output for a process. @param array $processInfo The process information. @param \Para\Service\Output\BufferedOutputInterface $output @param callable $processTerminatedCallback
[ "Handles", "the", "output", "for", "a", "process", "." ]
e0ef1356ed2979670eb7c670d88921406cade46e
https://github.com/rackberg/para/blob/e0ef1356ed2979670eb7c670d88921406cade46e/src/Service/Strategy/DisplayCombinedOutputStrategy.php#L145-L239
train
ossbrownie/util
src/Brownie/Util/StorageList.php
StorageList.get
public function get($keyName, $defaultValue = null) { $this->initList(); $keyName = strtolower($keyName); if (empty($this->list[$keyName])) { return $defaultValue; } return $this->list[$keyName]; }
php
public function get($keyName, $defaultValue = null) { $this->initList(); $keyName = strtolower($keyName); if (empty($this->list[$keyName])) { return $defaultValue; } return $this->list[$keyName]; }
[ "public", "function", "get", "(", "$", "keyName", ",", "$", "defaultValue", "=", "null", ")", "{", "$", "this", "->", "initList", "(", ")", ";", "$", "keyName", "=", "strtolower", "(", "$", "keyName", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "list", "[", "$", "keyName", "]", ")", ")", "{", "return", "$", "defaultValue", ";", "}", "return", "$", "this", "->", "list", "[", "$", "keyName", "]", ";", "}" ]
Gets value of by key name. @param string $keyName Key name. @param mixed $defaultValue Default value. @return string|mixed
[ "Gets", "value", "of", "by", "key", "name", "." ]
d60edd989f4c1e3caad243a75020f251a4b80283
https://github.com/ossbrownie/util/blob/d60edd989f4c1e3caad243a75020f251a4b80283/src/Brownie/Util/StorageList.php#L71-L79
train
kiler129/TinyWs
src/UpgradeHandler.php
UpgradeHandler.generateSwitchResponse
private function generateSwitchResponse($client, $request) { $acceptHeader = sha1($request->getHeader("sec-websocket-key") . self::WEBSOCKET_GUID, true); $switchParams = array( "Upgrade" => "websocket", "Connection" => "Upgrade", "Sec-WebSocket-Accept" => base64_encode($acceptHeader) ); $response = new HttpResponse("", $switchParams, HttpCode::SWITCHING_PROTOCOLS); $response = $this->clientsHandler->onUpgrade($client, $request, $response); return $response; }
php
private function generateSwitchResponse($client, $request) { $acceptHeader = sha1($request->getHeader("sec-websocket-key") . self::WEBSOCKET_GUID, true); $switchParams = array( "Upgrade" => "websocket", "Connection" => "Upgrade", "Sec-WebSocket-Accept" => base64_encode($acceptHeader) ); $response = new HttpResponse("", $switchParams, HttpCode::SWITCHING_PROTOCOLS); $response = $this->clientsHandler->onUpgrade($client, $request, $response); return $response; }
[ "private", "function", "generateSwitchResponse", "(", "$", "client", ",", "$", "request", ")", "{", "$", "acceptHeader", "=", "sha1", "(", "$", "request", "->", "getHeader", "(", "\"sec-websocket-key\"", ")", ".", "self", "::", "WEBSOCKET_GUID", ",", "true", ")", ";", "$", "switchParams", "=", "array", "(", "\"Upgrade\"", "=>", "\"websocket\"", ",", "\"Connection\"", "=>", "\"Upgrade\"", ",", "\"Sec-WebSocket-Accept\"", "=>", "base64_encode", "(", "$", "acceptHeader", ")", ")", ";", "$", "response", "=", "new", "HttpResponse", "(", "\"\"", ",", "$", "switchParams", ",", "HttpCode", "::", "SWITCHING_PROTOCOLS", ")", ";", "$", "response", "=", "$", "this", "->", "clientsHandler", "->", "onUpgrade", "(", "$", "client", ",", "$", "request", ",", "$", "response", ")", ";", "return", "$", "response", ";", "}" ]
Generates WebSocket upgrade response & notifies clients handler @param HttpClient|StreamServerNodeInterface $client WebSocketClient which should be upgraded to WebSocket protocol @param HttpRequest $request Original HTTP upgrade handshake sent by client @return HttpResponse
[ "Generates", "WebSocket", "upgrade", "response", "&", "notifies", "clients", "handler" ]
85f0335b87b3ec73ab47f5a5631eb86ba70b64a1
https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/UpgradeHandler.php#L76-L88
train
kiler129/TinyWs
src/UpgradeHandler.php
UpgradeHandler.verifyUpgradeRequest
private function verifyUpgradeRequest(HttpRequest $request) { $this->logger->debug("Attempting to switch protocols (checking preconditions per RFC)"); //That "ifology" is ugly, but I don't have better idea to perform checks //Check request to conform with RFC 6455 [see page 16] if ($request->getMethod() !== "GET") { throw new HttpException("Cannot upgrade to WebSocket - invalid method", HttpCode::METHOD_NOT_ALLOWED); } if ($request->getProtocolVersion() != 1.1) { throw new HttpException("Cannot upgrade to WebSockets - http version not supported", HttpCode::VERSION_NOT_SUPPORTED); } //Intentionally skipped host & origin validation here if (strtolower($request->getHeader("upgrade")) !== "websocket") { throw new HttpException("Cannot upgrade to WebSockets - invalid upgrade header", HttpCode::BAD_REQUEST); } if (strpos(strtolower($request->getHeader("connection")), "upgrade") === false) { throw new HttpException("Cannot upgrade to WebSockets - invalid connection header", HttpCode::BAD_REQUEST); } $wsNoonce = base64_decode($request->getHeader("sec-websocket-key")); if (strlen($wsNoonce) !== 16) { throw new HttpException("Cannot upgrade to WebSockets - invalid key", HttpCode::BAD_REQUEST); } if (strtolower($request->getHeader("sec-websocket-version")) != self::SUPPORTED_WEBSOCKET_VERSION) { throw new HttpException("Cannot upgrade to WebSockets - version not supported", HttpCode::UPGRADE_REQUIRED, array("Sec-WebSocket-Version" => self::SUPPORTED_WEBSOCKET_VERSION)); } $this->logger->debug("RFC check OK"); }
php
private function verifyUpgradeRequest(HttpRequest $request) { $this->logger->debug("Attempting to switch protocols (checking preconditions per RFC)"); //That "ifology" is ugly, but I don't have better idea to perform checks //Check request to conform with RFC 6455 [see page 16] if ($request->getMethod() !== "GET") { throw new HttpException("Cannot upgrade to WebSocket - invalid method", HttpCode::METHOD_NOT_ALLOWED); } if ($request->getProtocolVersion() != 1.1) { throw new HttpException("Cannot upgrade to WebSockets - http version not supported", HttpCode::VERSION_NOT_SUPPORTED); } //Intentionally skipped host & origin validation here if (strtolower($request->getHeader("upgrade")) !== "websocket") { throw new HttpException("Cannot upgrade to WebSockets - invalid upgrade header", HttpCode::BAD_REQUEST); } if (strpos(strtolower($request->getHeader("connection")), "upgrade") === false) { throw new HttpException("Cannot upgrade to WebSockets - invalid connection header", HttpCode::BAD_REQUEST); } $wsNoonce = base64_decode($request->getHeader("sec-websocket-key")); if (strlen($wsNoonce) !== 16) { throw new HttpException("Cannot upgrade to WebSockets - invalid key", HttpCode::BAD_REQUEST); } if (strtolower($request->getHeader("sec-websocket-version")) != self::SUPPORTED_WEBSOCKET_VERSION) { throw new HttpException("Cannot upgrade to WebSockets - version not supported", HttpCode::UPGRADE_REQUIRED, array("Sec-WebSocket-Version" => self::SUPPORTED_WEBSOCKET_VERSION)); } $this->logger->debug("RFC check OK"); }
[ "private", "function", "verifyUpgradeRequest", "(", "HttpRequest", "$", "request", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "\"Attempting to switch protocols (checking preconditions per RFC)\"", ")", ";", "//That \"ifology\" is ugly, but I don't have better idea to perform checks", "//Check request to conform with RFC 6455 [see page 16]", "if", "(", "$", "request", "->", "getMethod", "(", ")", "!==", "\"GET\"", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSocket - invalid method\"", ",", "HttpCode", "::", "METHOD_NOT_ALLOWED", ")", ";", "}", "if", "(", "$", "request", "->", "getProtocolVersion", "(", ")", "!=", "1.1", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSockets - http version not supported\"", ",", "HttpCode", "::", "VERSION_NOT_SUPPORTED", ")", ";", "}", "//Intentionally skipped host & origin validation here", "if", "(", "strtolower", "(", "$", "request", "->", "getHeader", "(", "\"upgrade\"", ")", ")", "!==", "\"websocket\"", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSockets - invalid upgrade header\"", ",", "HttpCode", "::", "BAD_REQUEST", ")", ";", "}", "if", "(", "strpos", "(", "strtolower", "(", "$", "request", "->", "getHeader", "(", "\"connection\"", ")", ")", ",", "\"upgrade\"", ")", "===", "false", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSockets - invalid connection header\"", ",", "HttpCode", "::", "BAD_REQUEST", ")", ";", "}", "$", "wsNoonce", "=", "base64_decode", "(", "$", "request", "->", "getHeader", "(", "\"sec-websocket-key\"", ")", ")", ";", "if", "(", "strlen", "(", "$", "wsNoonce", ")", "!==", "16", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSockets - invalid key\"", ",", "HttpCode", "::", "BAD_REQUEST", ")", ";", "}", "if", "(", "strtolower", "(", "$", "request", "->", "getHeader", "(", "\"sec-websocket-version\"", ")", ")", "!=", "self", "::", "SUPPORTED_WEBSOCKET_VERSION", ")", "{", "throw", "new", "HttpException", "(", "\"Cannot upgrade to WebSockets - version not supported\"", ",", "HttpCode", "::", "UPGRADE_REQUIRED", ",", "array", "(", "\"Sec-WebSocket-Version\"", "=>", "self", "::", "SUPPORTED_WEBSOCKET_VERSION", ")", ")", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "\"RFC check OK\"", ")", ";", "}" ]
Validates HTTP => WebSocket upgrade request @param HttpRequest $request HTTP request, it's assumed upgrade request @throws HttpException
[ "Validates", "HTTP", "=", ">", "WebSocket", "upgrade", "request" ]
85f0335b87b3ec73ab47f5a5631eb86ba70b64a1
https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/UpgradeHandler.php#L97-L134
train
kiler129/TinyWs
src/UpgradeHandler.php
UpgradeHandler.populatePaths
private function populatePaths($paths) { if (!is_array($paths)) { $paths = array($paths); } foreach ($paths as $path) { if ($path[0] !== "/" && $path[0] !== "*") { throw new InvalidArgumentException("Invalid handler path specified"); } $this->handlerPaths[] = $path; } }
php
private function populatePaths($paths) { if (!is_array($paths)) { $paths = array($paths); } foreach ($paths as $path) { if ($path[0] !== "/" && $path[0] !== "*") { throw new InvalidArgumentException("Invalid handler path specified"); } $this->handlerPaths[] = $path; } }
[ "private", "function", "populatePaths", "(", "$", "paths", ")", "{", "if", "(", "!", "is_array", "(", "$", "paths", ")", ")", "{", "$", "paths", "=", "array", "(", "$", "paths", ")", ";", "}", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "$", "path", "[", "0", "]", "!==", "\"/\"", "&&", "$", "path", "[", "0", "]", "!==", "\"*\"", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Invalid handler path specified\"", ")", ";", "}", "$", "this", "->", "handlerPaths", "[", "]", "=", "$", "path", ";", "}", "}" ]
Verifies & adds paths handled by this handler It's private due to fact that for performance reasons CherryHttp will cache paths for each handler @param string|string[] $paths One (or more) paths to be handled @throws InvalidArgumentException Raised if any of paths is invalid
[ "Verifies", "&", "adds", "paths", "handled", "by", "this", "handler", "It", "s", "private", "due", "to", "fact", "that", "for", "performance", "reasons", "CherryHttp", "will", "cache", "paths", "for", "each", "handler" ]
85f0335b87b3ec73ab47f5a5631eb86ba70b64a1
https://github.com/kiler129/TinyWs/blob/85f0335b87b3ec73ab47f5a5631eb86ba70b64a1/src/UpgradeHandler.php#L144-L157
train
pmdevelopment/tool-bundle
Framework/PMKernel.php
PMKernel.getBaseTmpDir
public function getBaseTmpDir() { $folders = explode(DIRECTORY_SEPARATOR, $this->getRootDir()); $foldersCount = count($folders); /** * Base Path */ $projectDir = ''; if (true === isset($folders[$foldersCount - 2])) { $projectDir = $folders[$foldersCount - 2]; } $tempDirPath = FileUtility::getUserBasedCachedDir(sprintf('%s-%s', $projectDir, $this->getEnvironment())); FileUtility::mkdir($tempDirPath); return $tempDirPath; }
php
public function getBaseTmpDir() { $folders = explode(DIRECTORY_SEPARATOR, $this->getRootDir()); $foldersCount = count($folders); /** * Base Path */ $projectDir = ''; if (true === isset($folders[$foldersCount - 2])) { $projectDir = $folders[$foldersCount - 2]; } $tempDirPath = FileUtility::getUserBasedCachedDir(sprintf('%s-%s', $projectDir, $this->getEnvironment())); FileUtility::mkdir($tempDirPath); return $tempDirPath; }
[ "public", "function", "getBaseTmpDir", "(", ")", "{", "$", "folders", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "this", "->", "getRootDir", "(", ")", ")", ";", "$", "foldersCount", "=", "count", "(", "$", "folders", ")", ";", "/**\n * Base Path\n */", "$", "projectDir", "=", "''", ";", "if", "(", "true", "===", "isset", "(", "$", "folders", "[", "$", "foldersCount", "-", "2", "]", ")", ")", "{", "$", "projectDir", "=", "$", "folders", "[", "$", "foldersCount", "-", "2", "]", ";", "}", "$", "tempDirPath", "=", "FileUtility", "::", "getUserBasedCachedDir", "(", "sprintf", "(", "'%s-%s'", ",", "$", "projectDir", ",", "$", "this", "->", "getEnvironment", "(", ")", ")", ")", ";", "FileUtility", "::", "mkdir", "(", "$", "tempDirPath", ")", ";", "return", "$", "tempDirPath", ";", "}" ]
Get Base Tmp Dir @return string
[ "Get", "Base", "Tmp", "Dir" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Framework/PMKernel.php#L97-L114
train
valu-digital/valuso
src/ValuSo/Service/MetaService.php
MetaService.describe
public function describe($serviceId) { $cache = $this->getCache(); $cacheId = self::CACHE_ID_PREFIX . $serviceId; if ($cache && ($description = $this->getCache()->getItem($cacheId))) { return $description; } $loader = $this->getServiceLoader(); $options = $loader->getServiceOptions($serviceId); $service = $loader->getServicePluginManager()->get($serviceId, $options, true, false); if (!$service) { return null; } $description = []; $description['id'] = $serviceId; $description['name'] = $loader->getServiceName($serviceId); if (!is_callable($service)) { $specs = $this->getAnnotationBuilder()->getServiceSpecification($service); $specs = $specs->getArrayCopy(); $description = array_merge($specs, $description); } $reflectionClass = new ReflectionClass($service); // Convert associative 'operations' array into numeric array if (isset($description['operations'])) { $description['operations'] = $this->decorateOperations($reflectionClass, $description['operations']); } if ($cache) { $cache->setItem($cacheId, $description); } return $description; }
php
public function describe($serviceId) { $cache = $this->getCache(); $cacheId = self::CACHE_ID_PREFIX . $serviceId; if ($cache && ($description = $this->getCache()->getItem($cacheId))) { return $description; } $loader = $this->getServiceLoader(); $options = $loader->getServiceOptions($serviceId); $service = $loader->getServicePluginManager()->get($serviceId, $options, true, false); if (!$service) { return null; } $description = []; $description['id'] = $serviceId; $description['name'] = $loader->getServiceName($serviceId); if (!is_callable($service)) { $specs = $this->getAnnotationBuilder()->getServiceSpecification($service); $specs = $specs->getArrayCopy(); $description = array_merge($specs, $description); } $reflectionClass = new ReflectionClass($service); // Convert associative 'operations' array into numeric array if (isset($description['operations'])) { $description['operations'] = $this->decorateOperations($reflectionClass, $description['operations']); } if ($cache) { $cache->setItem($cacheId, $description); } return $description; }
[ "public", "function", "describe", "(", "$", "serviceId", ")", "{", "$", "cache", "=", "$", "this", "->", "getCache", "(", ")", ";", "$", "cacheId", "=", "self", "::", "CACHE_ID_PREFIX", ".", "$", "serviceId", ";", "if", "(", "$", "cache", "&&", "(", "$", "description", "=", "$", "this", "->", "getCache", "(", ")", "->", "getItem", "(", "$", "cacheId", ")", ")", ")", "{", "return", "$", "description", ";", "}", "$", "loader", "=", "$", "this", "->", "getServiceLoader", "(", ")", ";", "$", "options", "=", "$", "loader", "->", "getServiceOptions", "(", "$", "serviceId", ")", ";", "$", "service", "=", "$", "loader", "->", "getServicePluginManager", "(", ")", "->", "get", "(", "$", "serviceId", ",", "$", "options", ",", "true", ",", "false", ")", ";", "if", "(", "!", "$", "service", ")", "{", "return", "null", ";", "}", "$", "description", "=", "[", "]", ";", "$", "description", "[", "'id'", "]", "=", "$", "serviceId", ";", "$", "description", "[", "'name'", "]", "=", "$", "loader", "->", "getServiceName", "(", "$", "serviceId", ")", ";", "if", "(", "!", "is_callable", "(", "$", "service", ")", ")", "{", "$", "specs", "=", "$", "this", "->", "getAnnotationBuilder", "(", ")", "->", "getServiceSpecification", "(", "$", "service", ")", ";", "$", "specs", "=", "$", "specs", "->", "getArrayCopy", "(", ")", ";", "$", "description", "=", "array_merge", "(", "$", "specs", ",", "$", "description", ")", ";", "}", "$", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "service", ")", ";", "// Convert associative 'operations' array into numeric array", "if", "(", "isset", "(", "$", "description", "[", "'operations'", "]", ")", ")", "{", "$", "description", "[", "'operations'", "]", "=", "$", "this", "->", "decorateOperations", "(", "$", "reflectionClass", ",", "$", "description", "[", "'operations'", "]", ")", ";", "}", "if", "(", "$", "cache", ")", "{", "$", "cache", "->", "setItem", "(", "$", "cacheId", ",", "$", "description", ")", ";", "}", "return", "$", "description", ";", "}" ]
Retrieve service description @param string $serviceId Service ID @ValuService\Context({"cli", "http", "http-get"})
[ "Retrieve", "service", "description" ]
c96bed0f6bd21551822334fe6cfe913a7436dd17
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Service/MetaService.php#L52-L92
train
pmdevelopment/tool-bundle
Services/PdfService.php
PdfService.get
public function get($html) { $kernel_dir = $this->kerneldir; require __DIR__ . "/../Resources/config/dompdf.php"; $this->pdf = new DOMPDF; foreach ($this->options as $optionKey => $optionValue) { $this->pdf->set_option($optionKey, $optionValue); } $this->pdf->load_html($html); $this->pdf->set_paper("a4", 'portrait'); $this->pdf->render(); $response = new Response(); $response->setContent($this->pdf->output()); $response->setStatusCode(200); $response->headers->set('Content-Type', 'application/pdf'); return $response; }
php
public function get($html) { $kernel_dir = $this->kerneldir; require __DIR__ . "/../Resources/config/dompdf.php"; $this->pdf = new DOMPDF; foreach ($this->options as $optionKey => $optionValue) { $this->pdf->set_option($optionKey, $optionValue); } $this->pdf->load_html($html); $this->pdf->set_paper("a4", 'portrait'); $this->pdf->render(); $response = new Response(); $response->setContent($this->pdf->output()); $response->setStatusCode(200); $response->headers->set('Content-Type', 'application/pdf'); return $response; }
[ "public", "function", "get", "(", "$", "html", ")", "{", "$", "kernel_dir", "=", "$", "this", "->", "kerneldir", ";", "require", "__DIR__", ".", "\"/../Resources/config/dompdf.php\"", ";", "$", "this", "->", "pdf", "=", "new", "DOMPDF", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "optionKey", "=>", "$", "optionValue", ")", "{", "$", "this", "->", "pdf", "->", "set_option", "(", "$", "optionKey", ",", "$", "optionValue", ")", ";", "}", "$", "this", "->", "pdf", "->", "load_html", "(", "$", "html", ")", ";", "$", "this", "->", "pdf", "->", "set_paper", "(", "\"a4\"", ",", "'portrait'", ")", ";", "$", "this", "->", "pdf", "->", "render", "(", ")", ";", "$", "response", "=", "new", "Response", "(", ")", ";", "$", "response", "->", "setContent", "(", "$", "this", "->", "pdf", "->", "output", "(", ")", ")", ";", "$", "response", "->", "setStatusCode", "(", "200", ")", ";", "$", "response", "->", "headers", "->", "set", "(", "'Content-Type'", ",", "'application/pdf'", ")", ";", "return", "$", "response", ";", "}" ]
Get PDF By HTML @param string $html @return Response
[ "Get", "PDF", "By", "HTML" ]
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Services/PdfService.php#L55-L76
train