id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
9,700
mleczek/xml
src/XmlElement.php
XmlElement.innerXml
public function innerXml() { $children = ''; foreach ($this->getChildren() as $child) { $children .= (string)$child; } return $this->getText() . $children; }
php
public function innerXml() { $children = ''; foreach ($this->getChildren() as $child) { $children .= (string)$child; } return $this->getText() . $children; }
[ "public", "function", "innerXml", "(", ")", "{", "$", "children", "=", "''", ";", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "children", ".=", "(", "string", ")", "$", "child", ";", "}", "return", "$", "this", "->", "getText", "(", ")", ".", "$", "children", ";", "}" ]
Get xml without root element. @return string
[ "Get", "xml", "without", "root", "element", "." ]
3360020e7acf6cd81cdf5bb349920e8425f84608
https://github.com/mleczek/xml/blob/3360020e7acf6cd81cdf5bb349920e8425f84608/src/XmlElement.php#L193-L201
9,701
mleczek/xml
src/XmlElement.php
XmlElement.outerXml
public function outerXml() { $attributes = ''; foreach ($this->getAttributes() as $name => $value) { if ($value === null) { // Self-closing attribute format. $attributes .= " $name"; } else { // Full attribute format. $value = addslashes($value); $attributes .= " $name=\"$value\""; } } // Self-closing element format. if ($this->getText() === null && count($this->getChildren()) == 0) { return "<{$this->getName()}$attributes/>"; } // Full element format. return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>"; }
php
public function outerXml() { $attributes = ''; foreach ($this->getAttributes() as $name => $value) { if ($value === null) { // Self-closing attribute format. $attributes .= " $name"; } else { // Full attribute format. $value = addslashes($value); $attributes .= " $name=\"$value\""; } } // Self-closing element format. if ($this->getText() === null && count($this->getChildren()) == 0) { return "<{$this->getName()}$attributes/>"; } // Full element format. return "<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>"; }
[ "public", "function", "outerXml", "(", ")", "{", "$", "attributes", "=", "''", ";", "foreach", "(", "$", "this", "->", "getAttributes", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "// Self-closing attribute format.", "$", "attributes", ".=", "\" $name\"", ";", "}", "else", "{", "// Full attribute format.", "$", "value", "=", "addslashes", "(", "$", "value", ")", ";", "$", "attributes", ".=", "\" $name=\\\"$value\\\"\"", ";", "}", "}", "// Self-closing element format.", "if", "(", "$", "this", "->", "getText", "(", ")", "===", "null", "&&", "count", "(", "$", "this", "->", "getChildren", "(", ")", ")", "==", "0", ")", "{", "return", "\"<{$this->getName()}$attributes/>\"", ";", "}", "// Full element format.", "return", "\"<{$this->getName()}$attributes>{$this->innerXml()}</{$this->getName()}>\"", ";", "}" ]
Get xml with root element. @return string
[ "Get", "xml", "with", "root", "element", "." ]
3360020e7acf6cd81cdf5bb349920e8425f84608
https://github.com/mleczek/xml/blob/3360020e7acf6cd81cdf5bb349920e8425f84608/src/XmlElement.php#L208-L229
9,702
calgamo/logger
src/Util/LogLevelComparator.php
LogLevelComparator.compareLogLevel
private static function compareLogLevel( $a, $b ) { static $defs; if ( !$defs ){ $defs = array( 'F' => LogLevel::FATAL, 'E' => LogLevel::ERROR, 'W' => LogLevel::WARNING, 'I' => LogLevel::INFO, 'D' => LogLevel::DEBUG, 'T' => LogLevel::TRACE, ); } $a = $defs[$a] ?? LogLevel::INFO; $b = $defs[$b] ?? LogLevel::INFO; return ($a - $b); }
php
private static function compareLogLevel( $a, $b ) { static $defs; if ( !$defs ){ $defs = array( 'F' => LogLevel::FATAL, 'E' => LogLevel::ERROR, 'W' => LogLevel::WARNING, 'I' => LogLevel::INFO, 'D' => LogLevel::DEBUG, 'T' => LogLevel::TRACE, ); } $a = $defs[$a] ?? LogLevel::INFO; $b = $defs[$b] ?? LogLevel::INFO; return ($a - $b); }
[ "private", "static", "function", "compareLogLevel", "(", "$", "a", ",", "$", "b", ")", "{", "static", "$", "defs", ";", "if", "(", "!", "$", "defs", ")", "{", "$", "defs", "=", "array", "(", "'F'", "=>", "LogLevel", "::", "FATAL", ",", "'E'", "=>", "LogLevel", "::", "ERROR", ",", "'W'", "=>", "LogLevel", "::", "WARNING", ",", "'I'", "=>", "LogLevel", "::", "INFO", ",", "'D'", "=>", "LogLevel", "::", "DEBUG", ",", "'T'", "=>", "LogLevel", "::", "TRACE", ",", ")", ";", "}", "$", "a", "=", "$", "defs", "[", "$", "a", "]", "??", "LogLevel", "::", "INFO", ";", "$", "b", "=", "$", "defs", "[", "$", "b", "]", "??", "LogLevel", "::", "INFO", ";", "return", "(", "$", "a", "-", "$", "b", ")", ";", "}" ]
compare log levels @param int $a @param int $b @return integer
[ "compare", "log", "levels" ]
58aab9ddfe3f383337c61cad1f4742ce5afb9591
https://github.com/calgamo/logger/blob/58aab9ddfe3f383337c61cad1f4742ce5afb9591/src/Util/LogLevelComparator.php#L16-L35
9,703
FiveLab/ResourceBundle
src/EventListener/ExceptionListener.php
ExceptionListener.onKernelException
public function onKernelException(GetResponseForExceptionEvent $event): void { $request = $event->getRequest(); if ($this->kernelDebug && $this->debugParameter && $request->query->has($this->debugParameter)) { return; } $exception = $event->getException(); $errorPresentation = $this->errorPresentationFactory->create($exception); if (!$errorPresentation) { return; } if (!$errorPresentation->getResource()) { // The presentation not have resource. Send response with only status code. $event->setResponse(new Response('', $errorPresentation->getStatusCode())); return; } $acceptMediaType = null; try { $serializer = $this->serializerResolver->resolveByMediaTypes( get_class($errorPresentation->getResource()), $request->getAcceptableContentTypes(), $acceptMediaType ); } catch (ResourceSerializerNotFoundException $e) { // Cannot resolve the serializer for accept media types. return; } $context = $this->serializationContextCollector->collect(); $serializedData = $serializer->serialize($errorPresentation->getResource(), $context); $response = new Response($serializedData, $errorPresentation->getStatusCode(), [ 'Content-Type' => $acceptMediaType, ]); $event->setResponse($response); }
php
public function onKernelException(GetResponseForExceptionEvent $event): void { $request = $event->getRequest(); if ($this->kernelDebug && $this->debugParameter && $request->query->has($this->debugParameter)) { return; } $exception = $event->getException(); $errorPresentation = $this->errorPresentationFactory->create($exception); if (!$errorPresentation) { return; } if (!$errorPresentation->getResource()) { // The presentation not have resource. Send response with only status code. $event->setResponse(new Response('', $errorPresentation->getStatusCode())); return; } $acceptMediaType = null; try { $serializer = $this->serializerResolver->resolveByMediaTypes( get_class($errorPresentation->getResource()), $request->getAcceptableContentTypes(), $acceptMediaType ); } catch (ResourceSerializerNotFoundException $e) { // Cannot resolve the serializer for accept media types. return; } $context = $this->serializationContextCollector->collect(); $serializedData = $serializer->serialize($errorPresentation->getResource(), $context); $response = new Response($serializedData, $errorPresentation->getStatusCode(), [ 'Content-Type' => $acceptMediaType, ]); $event->setResponse($response); }
[ "public", "function", "onKernelException", "(", "GetResponseForExceptionEvent", "$", "event", ")", ":", "void", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "this", "->", "kernelDebug", "&&", "$", "this", "->", "debugParameter", "&&", "$", "request", "->", "query", "->", "has", "(", "$", "this", "->", "debugParameter", ")", ")", "{", "return", ";", "}", "$", "exception", "=", "$", "event", "->", "getException", "(", ")", ";", "$", "errorPresentation", "=", "$", "this", "->", "errorPresentationFactory", "->", "create", "(", "$", "exception", ")", ";", "if", "(", "!", "$", "errorPresentation", ")", "{", "return", ";", "}", "if", "(", "!", "$", "errorPresentation", "->", "getResource", "(", ")", ")", "{", "// The presentation not have resource. Send response with only status code.", "$", "event", "->", "setResponse", "(", "new", "Response", "(", "''", ",", "$", "errorPresentation", "->", "getStatusCode", "(", ")", ")", ")", ";", "return", ";", "}", "$", "acceptMediaType", "=", "null", ";", "try", "{", "$", "serializer", "=", "$", "this", "->", "serializerResolver", "->", "resolveByMediaTypes", "(", "get_class", "(", "$", "errorPresentation", "->", "getResource", "(", ")", ")", ",", "$", "request", "->", "getAcceptableContentTypes", "(", ")", ",", "$", "acceptMediaType", ")", ";", "}", "catch", "(", "ResourceSerializerNotFoundException", "$", "e", ")", "{", "// Cannot resolve the serializer for accept media types.", "return", ";", "}", "$", "context", "=", "$", "this", "->", "serializationContextCollector", "->", "collect", "(", ")", ";", "$", "serializedData", "=", "$", "serializer", "->", "serialize", "(", "$", "errorPresentation", "->", "getResource", "(", ")", ",", "$", "context", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "serializedData", ",", "$", "errorPresentation", "->", "getStatusCode", "(", ")", ",", "[", "'Content-Type'", "=>", "$", "acceptMediaType", ",", "]", ")", ";", "$", "event", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Render the exception for sending to client @param GetResponseForExceptionEvent $event
[ "Render", "the", "exception", "for", "sending", "to", "client" ]
048fce7be5357dc23fef1402ef8ca213489e8154
https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/EventListener/ExceptionListener.php#L83-L127
9,704
velkuns/eureka-package-password
src/Password/Generator.php
Generator.help
public function help() { $style = new Style(' *** RUN - HELP ***'); Out::std($style->color('fg', Style::COLOR_GREEN)->get()); Out::std(''); $help = new Eurekon\Help('...', true); $help->addArgument('p', 'password', 'Password to hash. If empty, generate on', true, false); $help->addArgument('l', 'length', 'Length for password generated (default 16 chars)', true, false); $help->display(); }
php
public function help() { $style = new Style(' *** RUN - HELP ***'); Out::std($style->color('fg', Style::COLOR_GREEN)->get()); Out::std(''); $help = new Eurekon\Help('...', true); $help->addArgument('p', 'password', 'Password to hash. If empty, generate on', true, false); $help->addArgument('l', 'length', 'Length for password generated (default 16 chars)', true, false); $help->display(); }
[ "public", "function", "help", "(", ")", "{", "$", "style", "=", "new", "Style", "(", "' *** RUN - HELP ***'", ")", ";", "Out", "::", "std", "(", "$", "style", "->", "color", "(", "'fg'", ",", "Style", "::", "COLOR_GREEN", ")", "->", "get", "(", ")", ")", ";", "Out", "::", "std", "(", "''", ")", ";", "$", "help", "=", "new", "Eurekon", "\\", "Help", "(", "'...'", ",", "true", ")", ";", "$", "help", "->", "addArgument", "(", "'p'", ",", "'password'", ",", "'Password to hash. If empty, generate on'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "'l'", ",", "'length'", ",", "'Length for password generated (default 16 chars)'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "display", "(", ")", ";", "}" ]
Help method. Must be overridden. @return void
[ "Help", "method", ".", "Must", "be", "overridden", "." ]
7b8ef83837d05d81aa2be4f3c21ef241a54a4d11
https://github.com/velkuns/eureka-package-password/blob/7b8ef83837d05d81aa2be4f3c21ef241a54a4d11/src/Password/Generator.php#L46-L57
9,705
velkuns/eureka-package-password
src/Password/Generator.php
Generator.run
public function run() { $argument = Eurekon\Argument::getInstance(); $passwordPlain = (string) $argument->get('p', 'password'); $length = (int) $argument->get('l', 'length', 16); $password = new Password($passwordPlain); if (empty($passwordPlain)) { $password->generate($length); } $password->hash(); $green = (new Style())->highlight('fg')->color('fg', Style::COLOR_GREEN); $white = (new Style())->highlight('fg')->color('fg', Style::COLOR_WHITE); Out::std((string) $green->setText('Password: ') . (string) $white->setText($password->getPlain())); Out::std((string) $green->setText('Hash: ') . (string) $white->setText($password->getHash())); }
php
public function run() { $argument = Eurekon\Argument::getInstance(); $passwordPlain = (string) $argument->get('p', 'password'); $length = (int) $argument->get('l', 'length', 16); $password = new Password($passwordPlain); if (empty($passwordPlain)) { $password->generate($length); } $password->hash(); $green = (new Style())->highlight('fg')->color('fg', Style::COLOR_GREEN); $white = (new Style())->highlight('fg')->color('fg', Style::COLOR_WHITE); Out::std((string) $green->setText('Password: ') . (string) $white->setText($password->getPlain())); Out::std((string) $green->setText('Hash: ') . (string) $white->setText($password->getHash())); }
[ "public", "function", "run", "(", ")", "{", "$", "argument", "=", "Eurekon", "\\", "Argument", "::", "getInstance", "(", ")", ";", "$", "passwordPlain", "=", "(", "string", ")", "$", "argument", "->", "get", "(", "'p'", ",", "'password'", ")", ";", "$", "length", "=", "(", "int", ")", "$", "argument", "->", "get", "(", "'l'", ",", "'length'", ",", "16", ")", ";", "$", "password", "=", "new", "Password", "(", "$", "passwordPlain", ")", ";", "if", "(", "empty", "(", "$", "passwordPlain", ")", ")", "{", "$", "password", "->", "generate", "(", "$", "length", ")", ";", "}", "$", "password", "->", "hash", "(", ")", ";", "$", "green", "=", "(", "new", "Style", "(", ")", ")", "->", "highlight", "(", "'fg'", ")", "->", "color", "(", "'fg'", ",", "Style", "::", "COLOR_GREEN", ")", ";", "$", "white", "=", "(", "new", "Style", "(", ")", ")", "->", "highlight", "(", "'fg'", ")", "->", "color", "(", "'fg'", ",", "Style", "::", "COLOR_WHITE", ")", ";", "Out", "::", "std", "(", "(", "string", ")", "$", "green", "->", "setText", "(", "'Password: '", ")", ".", "(", "string", ")", "$", "white", "->", "setText", "(", "$", "password", "->", "getPlain", "(", ")", ")", ")", ";", "Out", "::", "std", "(", "(", "string", ")", "$", "green", "->", "setText", "(", "'Hash: '", ")", ".", "(", "string", ")", "$", "white", "->", "setText", "(", "$", "password", "->", "getHash", "(", ")", ")", ")", ";", "}" ]
Run method. Must be overridden. @return void
[ "Run", "method", ".", "Must", "be", "overridden", "." ]
7b8ef83837d05d81aa2be4f3c21ef241a54a4d11
https://github.com/velkuns/eureka-package-password/blob/7b8ef83837d05d81aa2be4f3c21ef241a54a4d11/src/Password/Generator.php#L65-L84
9,706
diskerror/Utilities
src/Registry.php
Registry.set
final public static function set($key, $value) { self::_checkInstance(); self::$_instance->offsetSet($key, $value); }
php
final public static function set($key, $value) { self::_checkInstance(); self::$_instance->offsetSet($key, $value); }
[ "final", "public", "static", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "self", "::", "_checkInstance", "(", ")", ";", "self", "::", "$", "_instance", "->", "offsetSet", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Sets data to singleton instance. @param string|int $key @param mixed $value
[ "Sets", "data", "to", "singleton", "instance", "." ]
cc5eec2417f7c2c76a84584ebd5237197dc54236
https://github.com/diskerror/Utilities/blob/cc5eec2417f7c2c76a84584ebd5237197dc54236/src/Registry.php#L82-L86
9,707
tekkla/core-framework
Core/Framework/Amvc/AbstractMvc.php
AbstractMvc.checkAccess
protected function checkAccess($permission): bool { return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission); }
php
protected function checkAccess($permission): bool { return $this->app->core->user->permissions[$this->app->getName()]->allowedTo($permission); }
[ "protected", "function", "checkAccess", "(", "$", "permission", ")", ":", "bool", "{", "return", "$", "this", "->", "app", "->", "core", "->", "user", "->", "permissions", "[", "$", "this", "->", "app", "->", "getName", "(", ")", "]", "->", "allowedTo", "(", "$", "permission", ")", ";", "}" ]
Checks the current users permissions against one or more permissions @param string|array $perm One permission by it'S name or an array of permissionnames @return bool
[ "Checks", "the", "current", "users", "permissions", "against", "one", "or", "more", "permissions" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/AbstractMvc.php#L82-L85
9,708
tekkla/core-framework
Core/Framework/Amvc/AbstractMvc.php
AbstractMvc.setAction
public function setAction(string $action) { $string = new CamelCase($action); $this->action = $string->camelize(); }
php
public function setAction(string $action) { $string = new CamelCase($action); $this->action = $string->camelize(); }
[ "public", "function", "setAction", "(", "string", "$", "action", ")", "{", "$", "string", "=", "new", "CamelCase", "(", "$", "action", ")", ";", "$", "this", "->", "action", "=", "$", "string", "->", "camelize", "(", ")", ";", "}" ]
Sets controller action @param string $action
[ "Sets", "controller", "action" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/AbstractMvc.php#L159-L163
9,709
krutush/krutush
src/Route.php
Route.with
public function with(string $param, string $regex): Route{ $this->params[$param] = str_replace('(', '(?:', $regex); return $this; }
php
public function with(string $param, string $regex): Route{ $this->params[$param] = str_replace('(', '(?:', $regex); return $this; }
[ "public", "function", "with", "(", "string", "$", "param", ",", "string", "$", "regex", ")", ":", "Route", "{", "$", "this", "->", "params", "[", "$", "param", "]", "=", "str_replace", "(", "'('", ",", "'(?:'", ",", "$", "regex", ")", ";", "return", "$", "this", ";", "}" ]
Params match regex @param string $param @param string $regex @return Route
[ "Params", "match", "regex" ]
3c42b524d7bd199d43fb3a5035b9e1bb39f5575b
https://github.com/krutush/krutush/blob/3c42b524d7bd199d43fb3a5035b9e1bb39f5575b/src/Route.php#L84-L87
9,710
roboapp/crud
src/View.php
View.run
public function run($id) { $model = $this->getModel($id); return $this->controller->render($this->view, [ $this->nameVariableModel => $model, ]); }
php
public function run($id) { $model = $this->getModel($id); return $this->controller->render($this->view, [ $this->nameVariableModel => $model, ]); }
[ "public", "function", "run", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "getModel", "(", "$", "id", ")", ";", "return", "$", "this", "->", "controller", "->", "render", "(", "$", "this", "->", "view", ",", "[", "$", "this", "->", "nameVariableModel", "=>", "$", "model", ",", "]", ")", ";", "}" ]
Views existing record. @param mixed $id ID of the model to be view @return mixed response
[ "Views", "existing", "record", "." ]
cda8ce1b8996157e08df949fcc83e314e25621f1
https://github.com/roboapp/crud/blob/cda8ce1b8996157e08df949fcc83e314e25621f1/src/View.php#L33-L40
9,711
uthando-cms/uthando-common
src/UthandoCommon/Stdlib/OptionsTrait.php
OptionsTrait.getOption
public function getOption($name) { if (!$this->hasOption($name)) { return null; } $getter = 'get' . ucfirst($name); return $this->options->{$getter}(); }
php
public function getOption($name) { if (!$this->hasOption($name)) { return null; } $getter = 'get' . ucfirst($name); return $this->options->{$getter}(); }
[ "public", "function", "getOption", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasOption", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "name", ")", ";", "return", "$", "this", "->", "options", "->", "{", "$", "getter", "}", "(", ")", ";", "}" ]
get an option by name @param string $name @return mixed
[ "get", "an", "option", "by", "name" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/OptionsTrait.php#L32-L41
9,712
uthando-cms/uthando-common
src/UthandoCommon/Stdlib/OptionsTrait.php
OptionsTrait.hasOption
public function hasOption($prop) { $prop = (string)$prop; if (is_object($this->options)) { $getter = 'get' . ucfirst($prop); return method_exists($this->options, $getter); } return false; }
php
public function hasOption($prop) { $prop = (string)$prop; if (is_object($this->options)) { $getter = 'get' . ucfirst($prop); return method_exists($this->options, $getter); } return false; }
[ "public", "function", "hasOption", "(", "$", "prop", ")", "{", "$", "prop", "=", "(", "string", ")", "$", "prop", ";", "if", "(", "is_object", "(", "$", "this", "->", "options", ")", ")", "{", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "prop", ")", ";", "return", "method_exists", "(", "$", "this", "->", "options", ",", "$", "getter", ")", ";", "}", "return", "false", ";", "}" ]
Check to see if option exists @param string $prop @return boolean
[ "Check", "to", "see", "if", "option", "exists" ]
feb915da5d26b60f536282e1bc3ad5c22e53f485
https://github.com/uthando-cms/uthando-common/blob/feb915da5d26b60f536282e1bc3ad5c22e53f485/src/UthandoCommon/Stdlib/OptionsTrait.php#L49-L60
9,713
eureka-framework/Eurekon
Argument.php
Argument.get
public function get($argument, $alias = null, $default = null) { if (isset($this->arguments[$argument])) { return $this->arguments[$argument]; } else if (! empty($alias) && isset($this->arguments[$alias])) { return $this->arguments[$alias]; } else { return $default; } }
php
public function get($argument, $alias = null, $default = null) { if (isset($this->arguments[$argument])) { return $this->arguments[$argument]; } else if (! empty($alias) && isset($this->arguments[$alias])) { return $this->arguments[$alias]; } else { return $default; } }
[ "public", "function", "get", "(", "$", "argument", ",", "$", "alias", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arguments", "[", "$", "argument", "]", ")", ")", "{", "return", "$", "this", "->", "arguments", "[", "$", "argument", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "alias", ")", "&&", "isset", "(", "$", "this", "->", "arguments", "[", "$", "alias", "]", ")", ")", "{", "return", "$", "this", "->", "arguments", "[", "$", "alias", "]", ";", "}", "else", "{", "return", "$", "default", ";", "}", "}" ]
Get specified argument value. @param string $argument Argument name @param string|null $alias Argument alias name (if exists) @param mixed|null $default Default value if argument does not exists. @return mixed
[ "Get", "specified", "argument", "value", "." ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Argument.php#L70-L80
9,714
eureka-framework/Eurekon
Argument.php
Argument.has
public function has($argument, $alias = null) { if (isset($this->arguments[$argument])) { return true; } else if (! empty($alias) && isset($this->arguments[$alias])) { return true; } else { return false; } }
php
public function has($argument, $alias = null) { if (isset($this->arguments[$argument])) { return true; } else if (! empty($alias) && isset($this->arguments[$alias])) { return true; } else { return false; } }
[ "public", "function", "has", "(", "$", "argument", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "arguments", "[", "$", "argument", "]", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "alias", ")", "&&", "isset", "(", "$", "this", "->", "arguments", "[", "$", "alias", "]", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Check if argument exists. @param string $argument Argument name @param string|null $alias Argument alias name (if exists) @return bool
[ "Check", "if", "argument", "exists", "." ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Argument.php#L89-L99
9,715
eureka-framework/Eurekon
Argument.php
Argument.parse
public function parse(Array $arguments) { $this->arguments = array(); $arguments = new ArgumentIterator($arguments); foreach ($arguments as $current) { $arguments->next(); $next = ($arguments->valid() ? $arguments->current() : ''); $arguments->prev(); $arg1 = substr($current, 0, 1); $arg2 = substr($current, 0, 2); if ('--' == $arg2) { // ~ Case '--test' $arg = array(); $match = preg_match('`--([0-9a-z_-]+)="?(.+)"?`', $current, $arg); if ($match > 0) { $this->arguments[$arg[1]] = $arg[2]; } else if (! empty($next) && '-' !== substr($next, 0, 1)) { $this->arguments[substr($current, 2)] = $next; } else { $this->arguments[substr($current, 2)] = true; } } elseif ('-' == $arg1) { // ~ case -t $arg = substr($current, 1); $len = strlen($arg); if (1 == $len && ! empty($next) && '-' != substr($next, 0, 1)) { $this->arguments[$arg] = $next; } else { for ($letter = 0; $letter < $len; $letter ++) { $this->arguments[$arg[$letter]] = true; } } } } return $this; }
php
public function parse(Array $arguments) { $this->arguments = array(); $arguments = new ArgumentIterator($arguments); foreach ($arguments as $current) { $arguments->next(); $next = ($arguments->valid() ? $arguments->current() : ''); $arguments->prev(); $arg1 = substr($current, 0, 1); $arg2 = substr($current, 0, 2); if ('--' == $arg2) { // ~ Case '--test' $arg = array(); $match = preg_match('`--([0-9a-z_-]+)="?(.+)"?`', $current, $arg); if ($match > 0) { $this->arguments[$arg[1]] = $arg[2]; } else if (! empty($next) && '-' !== substr($next, 0, 1)) { $this->arguments[substr($current, 2)] = $next; } else { $this->arguments[substr($current, 2)] = true; } } elseif ('-' == $arg1) { // ~ case -t $arg = substr($current, 1); $len = strlen($arg); if (1 == $len && ! empty($next) && '-' != substr($next, 0, 1)) { $this->arguments[$arg] = $next; } else { for ($letter = 0; $letter < $len; $letter ++) { $this->arguments[$arg[$letter]] = true; } } } } return $this; }
[ "public", "function", "parse", "(", "Array", "$", "arguments", ")", "{", "$", "this", "->", "arguments", "=", "array", "(", ")", ";", "$", "arguments", "=", "new", "ArgumentIterator", "(", "$", "arguments", ")", ";", "foreach", "(", "$", "arguments", "as", "$", "current", ")", "{", "$", "arguments", "->", "next", "(", ")", ";", "$", "next", "=", "(", "$", "arguments", "->", "valid", "(", ")", "?", "$", "arguments", "->", "current", "(", ")", ":", "''", ")", ";", "$", "arguments", "->", "prev", "(", ")", ";", "$", "arg1", "=", "substr", "(", "$", "current", ",", "0", ",", "1", ")", ";", "$", "arg2", "=", "substr", "(", "$", "current", ",", "0", ",", "2", ")", ";", "if", "(", "'--'", "==", "$", "arg2", ")", "{", "// ~ Case '--test'", "$", "arg", "=", "array", "(", ")", ";", "$", "match", "=", "preg_match", "(", "'`--([0-9a-z_-]+)=\"?(.+)\"?`'", ",", "$", "current", ",", "$", "arg", ")", ";", "if", "(", "$", "match", ">", "0", ")", "{", "$", "this", "->", "arguments", "[", "$", "arg", "[", "1", "]", "]", "=", "$", "arg", "[", "2", "]", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "next", ")", "&&", "'-'", "!==", "substr", "(", "$", "next", ",", "0", ",", "1", ")", ")", "{", "$", "this", "->", "arguments", "[", "substr", "(", "$", "current", ",", "2", ")", "]", "=", "$", "next", ";", "}", "else", "{", "$", "this", "->", "arguments", "[", "substr", "(", "$", "current", ",", "2", ")", "]", "=", "true", ";", "}", "}", "elseif", "(", "'-'", "==", "$", "arg1", ")", "{", "// ~ case -t", "$", "arg", "=", "substr", "(", "$", "current", ",", "1", ")", ";", "$", "len", "=", "strlen", "(", "$", "arg", ")", ";", "if", "(", "1", "==", "$", "len", "&&", "!", "empty", "(", "$", "next", ")", "&&", "'-'", "!=", "substr", "(", "$", "next", ",", "0", ",", "1", ")", ")", "{", "$", "this", "->", "arguments", "[", "$", "arg", "]", "=", "$", "next", ";", "}", "else", "{", "for", "(", "$", "letter", "=", "0", ";", "$", "letter", "<", "$", "len", ";", "$", "letter", "++", ")", "{", "$", "this", "->", "arguments", "[", "$", "arg", "[", "$", "letter", "]", "]", "=", "true", ";", "}", "}", "}", "}", "return", "$", "this", ";", "}" ]
Parse argument from command lines. @param array $arguments Parameter for this function is $argv global variable. @return Argument
[ "Parse", "argument", "from", "command", "lines", "." ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Argument.php#L107-L152
9,716
nwjeffm/laravel-pattern-generator
src/Core/Traits/ParseInputName.php
ParseInputName.getCommandNamespace
private function getCommandNamespace() { $concrete_namespace = $this->getCommandDeclaredNamespace(); if ($this->hasOption('system-folder')) { $concrete_namespace = $concrete_namespace . '\\' . $this->option('system-folder'); } if ($this->hasOption('folder')) { if ($this->option('folder')) { $concrete_namespace = $concrete_namespace . '\\' . $this->option('folder'); } } return $this->sanitizedPath($concrete_namespace); }
php
private function getCommandNamespace() { $concrete_namespace = $this->getCommandDeclaredNamespace(); if ($this->hasOption('system-folder')) { $concrete_namespace = $concrete_namespace . '\\' . $this->option('system-folder'); } if ($this->hasOption('folder')) { if ($this->option('folder')) { $concrete_namespace = $concrete_namespace . '\\' . $this->option('folder'); } } return $this->sanitizedPath($concrete_namespace); }
[ "private", "function", "getCommandNamespace", "(", ")", "{", "$", "concrete_namespace", "=", "$", "this", "->", "getCommandDeclaredNamespace", "(", ")", ";", "if", "(", "$", "this", "->", "hasOption", "(", "'system-folder'", ")", ")", "{", "$", "concrete_namespace", "=", "$", "concrete_namespace", ".", "'\\\\'", ".", "$", "this", "->", "option", "(", "'system-folder'", ")", ";", "}", "if", "(", "$", "this", "->", "hasOption", "(", "'folder'", ")", ")", "{", "if", "(", "$", "this", "->", "option", "(", "'folder'", ")", ")", "{", "$", "concrete_namespace", "=", "$", "concrete_namespace", ".", "'\\\\'", ".", "$", "this", "->", "option", "(", "'folder'", ")", ";", "}", "}", "return", "$", "this", "->", "sanitizedPath", "(", "$", "concrete_namespace", ")", ";", "}" ]
Get the namespace for the generator. This will set the system folder | folder of the module. @return string
[ "Get", "the", "namespace", "for", "the", "generator", ".", "This", "will", "set", "the", "system", "folder", "|", "folder", "of", "the", "module", "." ]
1a1964917b67be9fdf29a4959781bfef84a70c82
https://github.com/nwjeffm/laravel-pattern-generator/blob/1a1964917b67be9fdf29a4959781bfef84a70c82/src/Core/Traits/ParseInputName.php#L46-L64
9,717
consigliere/components
src/Component.php
Component.json
public function json($file = null) { if (is_null($file)) { $file = 'component.json'; } return new Json($this->getPath() . '/' . $file, $this->app['files']); }
php
public function json($file = null) { if (is_null($file)) { $file = 'component.json'; } return new Json($this->getPath() . '/' . $file, $this->app['files']); }
[ "public", "function", "json", "(", "$", "file", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "file", ")", ")", "{", "$", "file", "=", "'component.json'", ";", "}", "return", "new", "Json", "(", "$", "this", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "file", ",", "$", "this", "->", "app", "[", "'files'", "]", ")", ";", "}" ]
Get json contents. @return Json
[ "Get", "json", "contents", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Component.php#L174-L181
9,718
consigliere/components
src/Component.php
Component.enable
public function enable() { $this->app['events']->fire('component.enabling', [$this]); $this->setActive(1); $this->app['events']->fire('component.enabled', [$this]); }
php
public function enable() { $this->app['events']->fire('component.enabling', [$this]); $this->setActive(1); $this->app['events']->fire('component.enabled', [$this]); }
[ "public", "function", "enable", "(", ")", "{", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'component.enabling'", ",", "[", "$", "this", "]", ")", ";", "$", "this", "->", "setActive", "(", "1", ")", ";", "$", "this", "->", "app", "[", "'events'", "]", "->", "fire", "(", "'component.enabled'", ",", "[", "$", "this", "]", ")", ";", "}" ]
Enable the current component.
[ "Enable", "the", "current", "component", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Component.php#L355-L362
9,719
tenside/core
src/Util/RuntimeHelper.php
RuntimeHelper.setupHome
public static function setupHome($home) { if (empty($home)) { throw new \InvalidArgumentException('Empty home directory encountered.'); } if (false === getenv('COMPOSER')) { putenv('COMPOSER=' . $home . DIRECTORY_SEPARATOR . 'composer.json'); } chdir($home); // Ensure at least one of the environment variables is available. if (!getenv('COMPOSER_HOME') && !getenv('HOME')) { putenv('COMPOSER_HOME=' . $home); } }
php
public static function setupHome($home) { if (empty($home)) { throw new \InvalidArgumentException('Empty home directory encountered.'); } if (false === getenv('COMPOSER')) { putenv('COMPOSER=' . $home . DIRECTORY_SEPARATOR . 'composer.json'); } chdir($home); // Ensure at least one of the environment variables is available. if (!getenv('COMPOSER_HOME') && !getenv('HOME')) { putenv('COMPOSER_HOME=' . $home); } }
[ "public", "static", "function", "setupHome", "(", "$", "home", ")", "{", "if", "(", "empty", "(", "$", "home", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Empty home directory encountered.'", ")", ";", "}", "if", "(", "false", "===", "getenv", "(", "'COMPOSER'", ")", ")", "{", "putenv", "(", "'COMPOSER='", ".", "$", "home", ".", "DIRECTORY_SEPARATOR", ".", "'composer.json'", ")", ";", "}", "chdir", "(", "$", "home", ")", ";", "// Ensure at least one of the environment variables is available.", "if", "(", "!", "getenv", "(", "'COMPOSER_HOME'", ")", "&&", "!", "getenv", "(", "'HOME'", ")", ")", "{", "putenv", "(", "'COMPOSER_HOME='", ".", "$", "home", ")", ";", "}", "}" ]
Detect the correct tenside home dir and set the environment variable. @param string $home The home directory. @return void @throws \InvalidArgumentException For empty value of $home.
[ "Detect", "the", "correct", "tenside", "home", "dir", "and", "set", "the", "environment", "variable", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Util/RuntimeHelper.php#L37-L52
9,720
crysalead/jit
src/Parser.php
Parser._useNode
protected function _useNode() { $current = $this->_states['current']; $token = $this->_stream->current(true); $last = $alias = $use = ''; $as = false; $stop = ';'; $prefix = ''; while ($token[1] !== $stop) { $this->_states['body'] .= $token[1]; if (!$token = $this->_stream->next(true)) { break; } switch ($token[0]) { case ',': $as ? $this->_states['uses'][$alias] = $prefix . $use : $this->_states['uses'][$last] = $prefix . $use; $last = $alias = $use = ''; $as = false; break; case T_STRING: $last = $token[1]; case T_NS_SEPARATOR: $as ? $alias .= $token[1] : $use .= $token[1]; break; case T_AS: $as = true; break; case '{': $prefix = $use; $use = ''; $stop = $current->type === 'class' ? '}' : ';'; break; } } $this->_states['body'] .= $token[0]; $as ? $this->_states['uses'][$alias] = $prefix . $use : $this->_states['uses'][$last] = $prefix . $use; $this->_codeNode('use'); }
php
protected function _useNode() { $current = $this->_states['current']; $token = $this->_stream->current(true); $last = $alias = $use = ''; $as = false; $stop = ';'; $prefix = ''; while ($token[1] !== $stop) { $this->_states['body'] .= $token[1]; if (!$token = $this->_stream->next(true)) { break; } switch ($token[0]) { case ',': $as ? $this->_states['uses'][$alias] = $prefix . $use : $this->_states['uses'][$last] = $prefix . $use; $last = $alias = $use = ''; $as = false; break; case T_STRING: $last = $token[1]; case T_NS_SEPARATOR: $as ? $alias .= $token[1] : $use .= $token[1]; break; case T_AS: $as = true; break; case '{': $prefix = $use; $use = ''; $stop = $current->type === 'class' ? '}' : ';'; break; } } $this->_states['body'] .= $token[0]; $as ? $this->_states['uses'][$alias] = $prefix . $use : $this->_states['uses'][$last] = $prefix . $use; $this->_codeNode('use'); }
[ "protected", "function", "_useNode", "(", ")", "{", "$", "current", "=", "$", "this", "->", "_states", "[", "'current'", "]", ";", "$", "token", "=", "$", "this", "->", "_stream", "->", "current", "(", "true", ")", ";", "$", "last", "=", "$", "alias", "=", "$", "use", "=", "''", ";", "$", "as", "=", "false", ";", "$", "stop", "=", "';'", ";", "$", "prefix", "=", "''", ";", "while", "(", "$", "token", "[", "1", "]", "!==", "$", "stop", ")", "{", "$", "this", "->", "_states", "[", "'body'", "]", ".=", "$", "token", "[", "1", "]", ";", "if", "(", "!", "$", "token", "=", "$", "this", "->", "_stream", "->", "next", "(", "true", ")", ")", "{", "break", ";", "}", "switch", "(", "$", "token", "[", "0", "]", ")", "{", "case", "','", ":", "$", "as", "?", "$", "this", "->", "_states", "[", "'uses'", "]", "[", "$", "alias", "]", "=", "$", "prefix", ".", "$", "use", ":", "$", "this", "->", "_states", "[", "'uses'", "]", "[", "$", "last", "]", "=", "$", "prefix", ".", "$", "use", ";", "$", "last", "=", "$", "alias", "=", "$", "use", "=", "''", ";", "$", "as", "=", "false", ";", "break", ";", "case", "T_STRING", ":", "$", "last", "=", "$", "token", "[", "1", "]", ";", "case", "T_NS_SEPARATOR", ":", "$", "as", "?", "$", "alias", ".=", "$", "token", "[", "1", "]", ":", "$", "use", ".=", "$", "token", "[", "1", "]", ";", "break", ";", "case", "T_AS", ":", "$", "as", "=", "true", ";", "break", ";", "case", "'{'", ":", "$", "prefix", "=", "$", "use", ";", "$", "use", "=", "''", ";", "$", "stop", "=", "$", "current", "->", "type", "===", "'class'", "?", "'}'", ":", "';'", ";", "break", ";", "}", "}", "$", "this", "->", "_states", "[", "'body'", "]", ".=", "$", "token", "[", "0", "]", ";", "$", "as", "?", "$", "this", "->", "_states", "[", "'uses'", "]", "[", "$", "alias", "]", "=", "$", "prefix", ".", "$", "use", ":", "$", "this", "->", "_states", "[", "'uses'", "]", "[", "$", "last", "]", "=", "$", "prefix", ".", "$", "use", ";", "$", "this", "->", "_codeNode", "(", "'use'", ")", ";", "}" ]
Manage use statement.
[ "Manage", "use", "statement", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Parser.php#L253-L290
9,721
crysalead/jit
src/Parser.php
Parser._functionNode
protected function _functionNode() { $node = new FunctionDef(); $token = $this->_stream->current(true); $parent = $this->_states['current']; $body = $token[1]; $name = substr($this->_stream->next('('), 0, -1); $body .= $name; $node->name = trim($name); $args = $this->_parseArgs(); $node->args = $args['args']; $body .= $args['body'] . $this->_stream->next([';', '{']); if ($parent) { $isMethod = $parent->hasMethods; if ($parent->type === 'interface') { $node->type = 'signature'; } } else { $isMethod = false; } $node->isMethod = $isMethod; $node->isClosure = !$node->name; if ($isMethod) { $node->visibility = $this->_states['visibility']; $this->_states['visibility'] = []; } $node->body = $body; $this->_codeNode(); $this->_states['body'] = $body; $this->_contextualize($node); // Looking for curly brackets only if not an "abstract function" if ($this->_stream->current() === '{') { $this->_states['current'] = $node; } return $node->function = $node; }
php
protected function _functionNode() { $node = new FunctionDef(); $token = $this->_stream->current(true); $parent = $this->_states['current']; $body = $token[1]; $name = substr($this->_stream->next('('), 0, -1); $body .= $name; $node->name = trim($name); $args = $this->_parseArgs(); $node->args = $args['args']; $body .= $args['body'] . $this->_stream->next([';', '{']); if ($parent) { $isMethod = $parent->hasMethods; if ($parent->type === 'interface') { $node->type = 'signature'; } } else { $isMethod = false; } $node->isMethod = $isMethod; $node->isClosure = !$node->name; if ($isMethod) { $node->visibility = $this->_states['visibility']; $this->_states['visibility'] = []; } $node->body = $body; $this->_codeNode(); $this->_states['body'] = $body; $this->_contextualize($node); // Looking for curly brackets only if not an "abstract function" if ($this->_stream->current() === '{') { $this->_states['current'] = $node; } return $node->function = $node; }
[ "protected", "function", "_functionNode", "(", ")", "{", "$", "node", "=", "new", "FunctionDef", "(", ")", ";", "$", "token", "=", "$", "this", "->", "_stream", "->", "current", "(", "true", ")", ";", "$", "parent", "=", "$", "this", "->", "_states", "[", "'current'", "]", ";", "$", "body", "=", "$", "token", "[", "1", "]", ";", "$", "name", "=", "substr", "(", "$", "this", "->", "_stream", "->", "next", "(", "'('", ")", ",", "0", ",", "-", "1", ")", ";", "$", "body", ".=", "$", "name", ";", "$", "node", "->", "name", "=", "trim", "(", "$", "name", ")", ";", "$", "args", "=", "$", "this", "->", "_parseArgs", "(", ")", ";", "$", "node", "->", "args", "=", "$", "args", "[", "'args'", "]", ";", "$", "body", ".=", "$", "args", "[", "'body'", "]", ".", "$", "this", "->", "_stream", "->", "next", "(", "[", "';'", ",", "'{'", "]", ")", ";", "if", "(", "$", "parent", ")", "{", "$", "isMethod", "=", "$", "parent", "->", "hasMethods", ";", "if", "(", "$", "parent", "->", "type", "===", "'interface'", ")", "{", "$", "node", "->", "type", "=", "'signature'", ";", "}", "}", "else", "{", "$", "isMethod", "=", "false", ";", "}", "$", "node", "->", "isMethod", "=", "$", "isMethod", ";", "$", "node", "->", "isClosure", "=", "!", "$", "node", "->", "name", ";", "if", "(", "$", "isMethod", ")", "{", "$", "node", "->", "visibility", "=", "$", "this", "->", "_states", "[", "'visibility'", "]", ";", "$", "this", "->", "_states", "[", "'visibility'", "]", "=", "[", "]", ";", "}", "$", "node", "->", "body", "=", "$", "body", ";", "$", "this", "->", "_codeNode", "(", ")", ";", "$", "this", "->", "_states", "[", "'body'", "]", "=", "$", "body", ";", "$", "this", "->", "_contextualize", "(", "$", "node", ")", ";", "// Looking for curly brackets only if not an \"abstract function\"", "if", "(", "$", "this", "->", "_stream", "->", "current", "(", ")", "===", "'{'", ")", "{", "$", "this", "->", "_states", "[", "'current'", "]", "=", "$", "node", ";", "}", "return", "$", "node", "->", "function", "=", "$", "node", ";", "}" ]
Build a function node.
[ "Build", "a", "function", "node", "." ]
7bcccbd12d30887b19d64d488b6c4b2693eebaa4
https://github.com/crysalead/jit/blob/7bcccbd12d30887b19d64d488b6c4b2693eebaa4/src/Parser.php#L470-L508
9,722
laravel-commode/validation-locator
src/LaravelCommode/ValidationLocator/Locator/ValidationLocator.php
ValidationLocator.getValidator
public function getValidator($alias) { if (array_key_exists($alias, $this->validators)) { $validator = $this->validators[$alias]; return new $validator($this->translator, $this->presenceVerifier); } throw new \UnexpectedValueException("Unknown validator {$alias}"); }
php
public function getValidator($alias) { if (array_key_exists($alias, $this->validators)) { $validator = $this->validators[$alias]; return new $validator($this->translator, $this->presenceVerifier); } throw new \UnexpectedValueException("Unknown validator {$alias}"); }
[ "public", "function", "getValidator", "(", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "validators", ")", ")", "{", "$", "validator", "=", "$", "this", "->", "validators", "[", "$", "alias", "]", ";", "return", "new", "$", "validator", "(", "$", "this", "->", "translator", ",", "$", "this", "->", "presenceVerifier", ")", ";", "}", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Unknown validator {$alias}\"", ")", ";", "}" ]
Returns validator by it's alias. If validator is registered under given alias method will return new instance of validator, otherwise it will throw an exception @param string $alias Validator alias. @throws \UnexpectedValueException @return Validator
[ "Returns", "validator", "by", "it", "s", "alias", "." ]
b26e8b1f4f59ad95f786ea18c1d3d23a5f38dcd4
https://github.com/laravel-commode/validation-locator/blob/b26e8b1f4f59ad95f786ea18c1d3d23a5f38dcd4/src/LaravelCommode/ValidationLocator/Locator/ValidationLocator.php#L54-L62
9,723
ddehart/dilmun
src/Anshar/Http/UriParts/Host.php
Host.compileValidPattern
protected static function compileValidPattern() { self::compileUnencodedCharacters(); $valid_characters = self::$unreserved_pattern . self::$sub_delims_pattern; $ip_v_future_pattern = '\[[\:' . $valid_characters . ']+\]'; $reg_name_pattern = '([' . $valid_characters . ']|' . self::$pct_encoded_pattern . ')*'; self::$part_pattern = $ip_v_future_pattern . '|'. $reg_name_pattern; self::$valid_pattern = '/^$|^' . //allows part to be empty $ip_v_future_pattern . '$|^' . $reg_name_pattern . '$/'; }
php
protected static function compileValidPattern() { self::compileUnencodedCharacters(); $valid_characters = self::$unreserved_pattern . self::$sub_delims_pattern; $ip_v_future_pattern = '\[[\:' . $valid_characters . ']+\]'; $reg_name_pattern = '([' . $valid_characters . ']|' . self::$pct_encoded_pattern . ')*'; self::$part_pattern = $ip_v_future_pattern . '|'. $reg_name_pattern; self::$valid_pattern = '/^$|^' . //allows part to be empty $ip_v_future_pattern . '$|^' . $reg_name_pattern . '$/'; }
[ "protected", "static", "function", "compileValidPattern", "(", ")", "{", "self", "::", "compileUnencodedCharacters", "(", ")", ";", "$", "valid_characters", "=", "self", "::", "$", "unreserved_pattern", ".", "self", "::", "$", "sub_delims_pattern", ";", "$", "ip_v_future_pattern", "=", "'\\[[\\:'", ".", "$", "valid_characters", ".", "']+\\]'", ";", "$", "reg_name_pattern", "=", "'(['", ".", "$", "valid_characters", ".", "']|'", ".", "self", "::", "$", "pct_encoded_pattern", ".", "')*'", ";", "self", "::", "$", "part_pattern", "=", "$", "ip_v_future_pattern", ".", "'|'", ".", "$", "reg_name_pattern", ";", "self", "::", "$", "valid_pattern", "=", "'/^$|^'", ".", "//allows part to be empty", "$", "ip_v_future_pattern", ".", "'$|^'", ".", "$", "reg_name_pattern", ".", "'$/'", ";", "}" ]
Compiles validation patterns for a URI host. @return void
[ "Compiles", "validation", "patterns", "for", "a", "URI", "host", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/UriParts/Host.php#L77-L91
9,724
onesimus-systems/seed-catalog
src/SC.php
SC.connect
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array()) { if ($this->PDO) { // If this object already has a PDO object, don't attempt a new connection return $this; } $dsn = ''; if ($type == 'sqlite') { $dsn = "{$type}:{$host}"; } else { $dsn = "{$type}:host={$host};dbname={$dbname}"; } $PDO = new PDO($dsn, $username, $password, $options); if (!$PDO) { return false; } $this->PDO = $PDO; $this->setEscapeChar(); return $this; }
php
public function connect($type, $host, $dbname = '', $username = null, $password = null, array $options = array()) { if ($this->PDO) { // If this object already has a PDO object, don't attempt a new connection return $this; } $dsn = ''; if ($type == 'sqlite') { $dsn = "{$type}:{$host}"; } else { $dsn = "{$type}:host={$host};dbname={$dbname}"; } $PDO = new PDO($dsn, $username, $password, $options); if (!$PDO) { return false; } $this->PDO = $PDO; $this->setEscapeChar(); return $this; }
[ "public", "function", "connect", "(", "$", "type", ",", "$", "host", ",", "$", "dbname", "=", "''", ",", "$", "username", "=", "null", ",", "$", "password", "=", "null", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "PDO", ")", "{", "// If this object already has a PDO object, don't attempt a new connection", "return", "$", "this", ";", "}", "$", "dsn", "=", "''", ";", "if", "(", "$", "type", "==", "'sqlite'", ")", "{", "$", "dsn", "=", "\"{$type}:{$host}\"", ";", "}", "else", "{", "$", "dsn", "=", "\"{$type}:host={$host};dbname={$dbname}\"", ";", "}", "$", "PDO", "=", "new", "PDO", "(", "$", "dsn", ",", "$", "username", ",", "$", "password", ",", "$", "options", ")", ";", "if", "(", "!", "$", "PDO", ")", "{", "return", "false", ";", "}", "$", "this", "->", "PDO", "=", "$", "PDO", ";", "$", "this", "->", "setEscapeChar", "(", ")", ";", "return", "$", "this", ";", "}" ]
Connect to a database @param string $type @param string $host @param string $dbname [optional] @param string $username [optional] @param string $password [optional] @param array $options [optional] @return SC $this
[ "Connect", "to", "a", "database" ]
0a4e1e5c42938c841947229f61c3a120868ec810
https://github.com/onesimus-systems/seed-catalog/blob/0a4e1e5c42938c841947229f61c3a120868ec810/src/SC.php#L41-L65
9,725
nice-php/templating
src/Extension/TemplatingExtension.php
TemplatingExtension.load
public function load(array $configs, ContainerBuilder $container) { $configs[] = $this->options; $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $container->register('templating', 'Symfony\Component\Templating\DelegatingEngine'); $container->register('templating.template_name_parser', 'Symfony\Component\Templating\TemplateNameParser'); if (true === $config['enable_php_engine']) { $container->setParameter('php.template_dir', $config['template_dir']); $container->register('templating.engine.php.loader', 'Symfony\Component\Templating\Loader\FilesystemLoader') ->setPublic(false) ->addArgument('%php.template_dir%/%%name%%'); $container->register('templating.engine.php.helper.slots', 'Symfony\Component\Templating\Helper\SlotsHelper'); $container->register('templating.engine.php.helper.assets', 'Nice\Templating\Helper\AssetsHelper') ->addArgument(new Reference('service_container')); $container->register('templating.engine.php.helper.router', 'Nice\Templating\Helper\RouterHelper') ->addArgument(new Reference('service_container')); $container->register('templating.engine.php', 'Symfony\Component\Templating\PhpEngine') ->addArgument(new Reference('templating.template_name_parser')) ->addArgument(new Reference('templating.engine.php.loader')) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.slots'))) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.assets'))) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.router'))) ->addTag('templating.engine'); } }
php
public function load(array $configs, ContainerBuilder $container) { $configs[] = $this->options; $configuration = $this->getConfiguration($configs, $container); $config = $this->processConfiguration($configuration, $configs); $container->register('templating', 'Symfony\Component\Templating\DelegatingEngine'); $container->register('templating.template_name_parser', 'Symfony\Component\Templating\TemplateNameParser'); if (true === $config['enable_php_engine']) { $container->setParameter('php.template_dir', $config['template_dir']); $container->register('templating.engine.php.loader', 'Symfony\Component\Templating\Loader\FilesystemLoader') ->setPublic(false) ->addArgument('%php.template_dir%/%%name%%'); $container->register('templating.engine.php.helper.slots', 'Symfony\Component\Templating\Helper\SlotsHelper'); $container->register('templating.engine.php.helper.assets', 'Nice\Templating\Helper\AssetsHelper') ->addArgument(new Reference('service_container')); $container->register('templating.engine.php.helper.router', 'Nice\Templating\Helper\RouterHelper') ->addArgument(new Reference('service_container')); $container->register('templating.engine.php', 'Symfony\Component\Templating\PhpEngine') ->addArgument(new Reference('templating.template_name_parser')) ->addArgument(new Reference('templating.engine.php.loader')) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.slots'))) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.assets'))) ->addMethodCall('set', array(new Reference('templating.engine.php.helper.router'))) ->addTag('templating.engine'); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "configs", "[", "]", "=", "$", "this", "->", "options", ";", "$", "configuration", "=", "$", "this", "->", "getConfiguration", "(", "$", "configs", ",", "$", "container", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "container", "->", "register", "(", "'templating'", ",", "'Symfony\\Component\\Templating\\DelegatingEngine'", ")", ";", "$", "container", "->", "register", "(", "'templating.template_name_parser'", ",", "'Symfony\\Component\\Templating\\TemplateNameParser'", ")", ";", "if", "(", "true", "===", "$", "config", "[", "'enable_php_engine'", "]", ")", "{", "$", "container", "->", "setParameter", "(", "'php.template_dir'", ",", "$", "config", "[", "'template_dir'", "]", ")", ";", "$", "container", "->", "register", "(", "'templating.engine.php.loader'", ",", "'Symfony\\Component\\Templating\\Loader\\FilesystemLoader'", ")", "->", "setPublic", "(", "false", ")", "->", "addArgument", "(", "'%php.template_dir%/%%name%%'", ")", ";", "$", "container", "->", "register", "(", "'templating.engine.php.helper.slots'", ",", "'Symfony\\Component\\Templating\\Helper\\SlotsHelper'", ")", ";", "$", "container", "->", "register", "(", "'templating.engine.php.helper.assets'", ",", "'Nice\\Templating\\Helper\\AssetsHelper'", ")", "->", "addArgument", "(", "new", "Reference", "(", "'service_container'", ")", ")", ";", "$", "container", "->", "register", "(", "'templating.engine.php.helper.router'", ",", "'Nice\\Templating\\Helper\\RouterHelper'", ")", "->", "addArgument", "(", "new", "Reference", "(", "'service_container'", ")", ")", ";", "$", "container", "->", "register", "(", "'templating.engine.php'", ",", "'Symfony\\Component\\Templating\\PhpEngine'", ")", "->", "addArgument", "(", "new", "Reference", "(", "'templating.template_name_parser'", ")", ")", "->", "addArgument", "(", "new", "Reference", "(", "'templating.engine.php.loader'", ")", ")", "->", "addMethodCall", "(", "'set'", ",", "array", "(", "new", "Reference", "(", "'templating.engine.php.helper.slots'", ")", ")", ")", "->", "addMethodCall", "(", "'set'", ",", "array", "(", "new", "Reference", "(", "'templating.engine.php.helper.assets'", ")", ")", ")", "->", "addMethodCall", "(", "'set'", ",", "array", "(", "new", "Reference", "(", "'templating.engine.php.helper.router'", ")", ")", ")", "->", "addTag", "(", "'templating.engine'", ")", ";", "}", "}" ]
Loads a specific configuration @param array $configs An array of configuration values @param ContainerBuilder $container A ContainerBuilder instance
[ "Loads", "a", "specific", "configuration" ]
2f3869e839801d0d3d99907261002a80e31d14b7
https://github.com/nice-php/templating/blob/2f3869e839801d0d3d99907261002a80e31d14b7/src/Extension/TemplatingExtension.php#L58-L86
9,726
Commercie/money
src/Amount.php
Amount.validateOtherAmount
protected function validateOtherAmount(AmountInterface $amount) { if ($this->getCurrency()->getCurrencyCode() !== $amount->getCurrency()->getCurrencyCode()) { throw new \InvalidArgumentException(sprintf('Both amounts must be in %s, but the other amount is in %s.', $this->getCurrency()->getCurrencyCode(), $amount->getCurrency()->getCurrencyCode())); } }
php
protected function validateOtherAmount(AmountInterface $amount) { if ($this->getCurrency()->getCurrencyCode() !== $amount->getCurrency()->getCurrencyCode()) { throw new \InvalidArgumentException(sprintf('Both amounts must be in %s, but the other amount is in %s.', $this->getCurrency()->getCurrencyCode(), $amount->getCurrency()->getCurrencyCode())); } }
[ "protected", "function", "validateOtherAmount", "(", "AmountInterface", "$", "amount", ")", "{", "if", "(", "$", "this", "->", "getCurrency", "(", ")", "->", "getCurrencyCode", "(", ")", "!==", "$", "amount", "->", "getCurrency", "(", ")", "->", "getCurrencyCode", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Both amounts must be in %s, but the other amount is in %s.'", ",", "$", "this", "->", "getCurrency", "(", ")", "->", "getCurrencyCode", "(", ")", ",", "$", "amount", "->", "getCurrency", "(", ")", "->", "getCurrencyCode", "(", ")", ")", ")", ";", "}", "}" ]
Validates another amount against this one. @param \Commercie\Money\AmountInterface $amount @throws \InvalidArgumentException
[ "Validates", "another", "amount", "against", "this", "one", "." ]
21a666150f21d82e3f8bc01d7c69e84361908662
https://github.com/Commercie/money/blob/21a666150f21d82e3f8bc01d7c69e84361908662/src/Amount.php#L64-L68
9,727
Commercie/money
src/Amount.php
Amount.validateNumber
protected function validateNumber($number) { if (!(is_int($number) || is_string($number) && is_numeric($number))) { $type = is_object($number) ? get_class($number) : gettype($number); throw new \InvalidArgumentException(sprintf('An integer or numeric string was expected, but %s was given.', $type)); } }
php
protected function validateNumber($number) { if (!(is_int($number) || is_string($number) && is_numeric($number))) { $type = is_object($number) ? get_class($number) : gettype($number); throw new \InvalidArgumentException(sprintf('An integer or numeric string was expected, but %s was given.', $type)); } }
[ "protected", "function", "validateNumber", "(", "$", "number", ")", "{", "if", "(", "!", "(", "is_int", "(", "$", "number", ")", "||", "is_string", "(", "$", "number", ")", "&&", "is_numeric", "(", "$", "number", ")", ")", ")", "{", "$", "type", "=", "is_object", "(", "$", "number", ")", "?", "get_class", "(", "$", "number", ")", ":", "gettype", "(", "$", "number", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'An integer or numeric string was expected, but %s was given.'", ",", "$", "type", ")", ")", ";", "}", "}" ]
Checks that a value is a number. @param mixed $number
[ "Checks", "that", "a", "value", "is", "a", "number", "." ]
21a666150f21d82e3f8bc01d7c69e84361908662
https://github.com/Commercie/money/blob/21a666150f21d82e3f8bc01d7c69e84361908662/src/Amount.php#L87-L92
9,728
Commercie/money
src/Amount.php
Amount.comparesTo
protected function comparesTo(AmountInterface $amount) { $this->validateOtherAmount($amount); return bccomp($this->getAmount(), $amount->getAmount(), static::BC_MATH_SCALE); }
php
protected function comparesTo(AmountInterface $amount) { $this->validateOtherAmount($amount); return bccomp($this->getAmount(), $amount->getAmount(), static::BC_MATH_SCALE); }
[ "protected", "function", "comparesTo", "(", "AmountInterface", "$", "amount", ")", "{", "$", "this", "->", "validateOtherAmount", "(", "$", "amount", ")", ";", "return", "bccomp", "(", "$", "this", "->", "getAmount", "(", ")", ",", "$", "amount", "->", "getAmount", "(", ")", ",", "static", "::", "BC_MATH_SCALE", ")", ";", "}" ]
Compares this amount to another. @param \Commercie\Money\AmountInterface $amount @return int -1, 0, or 1 if this amount is respectively less than, equal to, or more than the other amount.
[ "Compares", "this", "amount", "to", "another", "." ]
21a666150f21d82e3f8bc01d7c69e84361908662
https://github.com/Commercie/money/blob/21a666150f21d82e3f8bc01d7c69e84361908662/src/Amount.php#L130-L134
9,729
LaBlog/LaBlog
src/controllers/PageController.php
PageController.showPage
public function showPage($pageName = 'index') { if (!$this->page->exists($pageName)) { return \Response::view($this->theme.'.404', array('global' => $this->global), 404); } $page = $this->page->get($pageName); $viewParamaters = array( 'global' => $this->global, 'page' => $page ); if (\View::exists($this->theme.'.'.$pageName)) { return \View::make($this->theme.'.'.$pageName, $viewParamaters); } else { return \View::make($this->theme.'.page', $viewParamaters); } }
php
public function showPage($pageName = 'index') { if (!$this->page->exists($pageName)) { return \Response::view($this->theme.'.404', array('global' => $this->global), 404); } $page = $this->page->get($pageName); $viewParamaters = array( 'global' => $this->global, 'page' => $page ); if (\View::exists($this->theme.'.'.$pageName)) { return \View::make($this->theme.'.'.$pageName, $viewParamaters); } else { return \View::make($this->theme.'.page', $viewParamaters); } }
[ "public", "function", "showPage", "(", "$", "pageName", "=", "'index'", ")", "{", "if", "(", "!", "$", "this", "->", "page", "->", "exists", "(", "$", "pageName", ")", ")", "{", "return", "\\", "Response", "::", "view", "(", "$", "this", "->", "theme", ".", "'.404'", ",", "array", "(", "'global'", "=>", "$", "this", "->", "global", ")", ",", "404", ")", ";", "}", "$", "page", "=", "$", "this", "->", "page", "->", "get", "(", "$", "pageName", ")", ";", "$", "viewParamaters", "=", "array", "(", "'global'", "=>", "$", "this", "->", "global", ",", "'page'", "=>", "$", "page", ")", ";", "if", "(", "\\", "View", "::", "exists", "(", "$", "this", "->", "theme", ".", "'.'", ".", "$", "pageName", ")", ")", "{", "return", "\\", "View", "::", "make", "(", "$", "this", "->", "theme", ".", "'.'", ".", "$", "pageName", ",", "$", "viewParamaters", ")", ";", "}", "else", "{", "return", "\\", "View", "::", "make", "(", "$", "this", "->", "theme", ".", "'.page'", ",", "$", "viewParamaters", ")", ";", "}", "}" ]
Show a single requested page. @param string $pageName The name of the page to show. @return \View
[ "Show", "a", "single", "requested", "page", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/controllers/PageController.php#L23-L41
9,730
railsphp/framework
src/Rails/ActionMailer/Deliverer.php
Deliverer.addAttachments
protected function addAttachments() { if (class_exists('Finfo', false)) { $finfo = new \Finfo(FILEINFO_MIME_TYPE); } else { $finfo = null; } foreach ($this->mail->attachments as $filename => $attachment) { if (!is_array($attachment)) { throw new Exception\RuntimeException( sprintf("Attachments must be array, %s passed", gettype($attachment)) ); } elseif ( !is_string($attachment['content']) && ( !is_resource($attachment['content']) || !get_resource_type($attachment['content']) == 'stream' ) ) { throw new Exception\RuntimeException( sprintf( "Attachment content must be string or stream, %s passed", gettype($attachment['content']) ) ); } $type = null; if (empty($attachment['mime_type']) && $finfo) { if (is_resource($attachment['content'])) { $type = $finfo->buffer(stream_get_contents($attachment['content'])); rewind($attachment['content']); } else { $type = $finfo->buffer($attachment['content']); } } $part = new Mime\Part($attachment['content']); if (empty($attachment['encoding'])) { $attachment['encoding'] = Mime\Mime::ENCODING_BASE64; } $part->encoding = $attachment['encoding']; if ($type) { $part->type = $type; } if (!empty($attachment['inline'])) { $part->disposition = Mime\Mime::DISPOSITION_INLINE; } else { $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT; } $this->body->addPart($part); } }
php
protected function addAttachments() { if (class_exists('Finfo', false)) { $finfo = new \Finfo(FILEINFO_MIME_TYPE); } else { $finfo = null; } foreach ($this->mail->attachments as $filename => $attachment) { if (!is_array($attachment)) { throw new Exception\RuntimeException( sprintf("Attachments must be array, %s passed", gettype($attachment)) ); } elseif ( !is_string($attachment['content']) && ( !is_resource($attachment['content']) || !get_resource_type($attachment['content']) == 'stream' ) ) { throw new Exception\RuntimeException( sprintf( "Attachment content must be string or stream, %s passed", gettype($attachment['content']) ) ); } $type = null; if (empty($attachment['mime_type']) && $finfo) { if (is_resource($attachment['content'])) { $type = $finfo->buffer(stream_get_contents($attachment['content'])); rewind($attachment['content']); } else { $type = $finfo->buffer($attachment['content']); } } $part = new Mime\Part($attachment['content']); if (empty($attachment['encoding'])) { $attachment['encoding'] = Mime\Mime::ENCODING_BASE64; } $part->encoding = $attachment['encoding']; if ($type) { $part->type = $type; } if (!empty($attachment['inline'])) { $part->disposition = Mime\Mime::DISPOSITION_INLINE; } else { $part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT; } $this->body->addPart($part); } }
[ "protected", "function", "addAttachments", "(", ")", "{", "if", "(", "class_exists", "(", "'Finfo'", ",", "false", ")", ")", "{", "$", "finfo", "=", "new", "\\", "Finfo", "(", "FILEINFO_MIME_TYPE", ")", ";", "}", "else", "{", "$", "finfo", "=", "null", ";", "}", "foreach", "(", "$", "this", "->", "mail", "->", "attachments", "as", "$", "filename", "=>", "$", "attachment", ")", "{", "if", "(", "!", "is_array", "(", "$", "attachment", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "\"Attachments must be array, %s passed\"", ",", "gettype", "(", "$", "attachment", ")", ")", ")", ";", "}", "elseif", "(", "!", "is_string", "(", "$", "attachment", "[", "'content'", "]", ")", "&&", "(", "!", "is_resource", "(", "$", "attachment", "[", "'content'", "]", ")", "||", "!", "get_resource_type", "(", "$", "attachment", "[", "'content'", "]", ")", "==", "'stream'", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "\"Attachment content must be string or stream, %s passed\"", ",", "gettype", "(", "$", "attachment", "[", "'content'", "]", ")", ")", ")", ";", "}", "$", "type", "=", "null", ";", "if", "(", "empty", "(", "$", "attachment", "[", "'mime_type'", "]", ")", "&&", "$", "finfo", ")", "{", "if", "(", "is_resource", "(", "$", "attachment", "[", "'content'", "]", ")", ")", "{", "$", "type", "=", "$", "finfo", "->", "buffer", "(", "stream_get_contents", "(", "$", "attachment", "[", "'content'", "]", ")", ")", ";", "rewind", "(", "$", "attachment", "[", "'content'", "]", ")", ";", "}", "else", "{", "$", "type", "=", "$", "finfo", "->", "buffer", "(", "$", "attachment", "[", "'content'", "]", ")", ";", "}", "}", "$", "part", "=", "new", "Mime", "\\", "Part", "(", "$", "attachment", "[", "'content'", "]", ")", ";", "if", "(", "empty", "(", "$", "attachment", "[", "'encoding'", "]", ")", ")", "{", "$", "attachment", "[", "'encoding'", "]", "=", "Mime", "\\", "Mime", "::", "ENCODING_BASE64", ";", "}", "$", "part", "->", "encoding", "=", "$", "attachment", "[", "'encoding'", "]", ";", "if", "(", "$", "type", ")", "{", "$", "part", "->", "type", "=", "$", "type", ";", "}", "if", "(", "!", "empty", "(", "$", "attachment", "[", "'inline'", "]", ")", ")", "{", "$", "part", "->", "disposition", "=", "Mime", "\\", "Mime", "::", "DISPOSITION_INLINE", ";", "}", "else", "{", "$", "part", "->", "disposition", "=", "Mime", "\\", "Mime", "::", "DISPOSITION_ATTACHMENT", ";", "}", "$", "this", "->", "body", "->", "addPart", "(", "$", "part", ")", ";", "}", "}" ]
Requires Fileinfo.
[ "Requires", "Fileinfo", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionMailer/Deliverer.php#L205-L264
9,731
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-filter/src/Compress/Tar.php
Tar.setMode
public function setMode($mode) { $mode = strtolower($mode); if (($mode != 'bz2') && ($mode != 'gz')) { throw new Exception\InvalidArgumentException("The mode '$mode' is unknown"); } if (($mode == 'bz2') && (!extension_loaded('bz2'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the bz2 extension'); } if (($mode == 'gz') && (!extension_loaded('zlib'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the zlib extension'); } $this->options['mode'] = $mode; return $this; }
php
public function setMode($mode) { $mode = strtolower($mode); if (($mode != 'bz2') && ($mode != 'gz')) { throw new Exception\InvalidArgumentException("The mode '$mode' is unknown"); } if (($mode == 'bz2') && (!extension_loaded('bz2'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the bz2 extension'); } if (($mode == 'gz') && (!extension_loaded('zlib'))) { throw new Exception\ExtensionNotLoadedException('This mode needs the zlib extension'); } $this->options['mode'] = $mode; return $this; }
[ "public", "function", "setMode", "(", "$", "mode", ")", "{", "$", "mode", "=", "strtolower", "(", "$", "mode", ")", ";", "if", "(", "(", "$", "mode", "!=", "'bz2'", ")", "&&", "(", "$", "mode", "!=", "'gz'", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "\"The mode '$mode' is unknown\"", ")", ";", "}", "if", "(", "(", "$", "mode", "==", "'bz2'", ")", "&&", "(", "!", "extension_loaded", "(", "'bz2'", ")", ")", ")", "{", "throw", "new", "Exception", "\\", "ExtensionNotLoadedException", "(", "'This mode needs the bz2 extension'", ")", ";", "}", "if", "(", "(", "$", "mode", "==", "'gz'", ")", "&&", "(", "!", "extension_loaded", "(", "'zlib'", ")", ")", ")", "{", "throw", "new", "Exception", "\\", "ExtensionNotLoadedException", "(", "'This mode needs the zlib extension'", ")", ";", "}", "$", "this", "->", "options", "[", "'mode'", "]", "=", "$", "mode", ";", "return", "$", "this", ";", "}" ]
Compression mode to use Either Gz or Bz2. @param string $mode @return self @throws Exception\InvalidArgumentException for invalid $mode values @throws Exception\ExtensionNotLoadedException if bz2 mode selected but extension not loaded @throws Exception\ExtensionNotLoadedException if gz mode selected but extension not loaded
[ "Compression", "mode", "to", "use" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Compress/Tar.php#L128-L145
9,732
joaogl/base
src/Controllers/BaseController.php
BaseController.ajaxGetQueues
public function ajaxGetQueues() { $data = Base::getJobsRepository()->orderBy('created_at', 'desc')->take(300)->get(['queue', 'payload', 'attempts', 'reserved', 'reserved_at', 'created_at']); foreach ($data as $d) { $obj = json_decode($d->payload); $d->payload = $obj->job; $d->data = json_encode($obj->data->data); } return \Response::json(array('data' => $data)); }
php
public function ajaxGetQueues() { $data = Base::getJobsRepository()->orderBy('created_at', 'desc')->take(300)->get(['queue', 'payload', 'attempts', 'reserved', 'reserved_at', 'created_at']); foreach ($data as $d) { $obj = json_decode($d->payload); $d->payload = $obj->job; $d->data = json_encode($obj->data->data); } return \Response::json(array('data' => $data)); }
[ "public", "function", "ajaxGetQueues", "(", ")", "{", "$", "data", "=", "Base", "::", "getJobsRepository", "(", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "->", "take", "(", "300", ")", "->", "get", "(", "[", "'queue'", ",", "'payload'", ",", "'attempts'", ",", "'reserved'", ",", "'reserved_at'", ",", "'created_at'", "]", ")", ";", "foreach", "(", "$", "data", "as", "$", "d", ")", "{", "$", "obj", "=", "json_decode", "(", "$", "d", "->", "payload", ")", ";", "$", "d", "->", "payload", "=", "$", "obj", "->", "job", ";", "$", "d", "->", "data", "=", "json_encode", "(", "$", "obj", "->", "data", "->", "data", ")", ";", "}", "return", "\\", "Response", "::", "json", "(", "array", "(", "'data'", "=>", "$", "data", ")", ")", ";", "}" ]
Ajax call to get all the queues @return View
[ "Ajax", "call", "to", "get", "all", "the", "queues" ]
e6a4e9f4d3c75efc92545941ea5c9810d3291b56
https://github.com/joaogl/base/blob/e6a4e9f4d3c75efc92545941ea5c9810d3291b56/src/Controllers/BaseController.php#L52-L64
9,733
joaogl/base
src/Controllers/BaseController.php
BaseController.ajaxGetVisits
public function ajaxGetVisits() { $data = Base::getVisitsRepository()->orderBy('created_at', 'desc')->take(300)->get(['url', 'browser', 'ip', 'created_at', 'country']); return \Response::json(array('data' => $data)); }
php
public function ajaxGetVisits() { $data = Base::getVisitsRepository()->orderBy('created_at', 'desc')->take(300)->get(['url', 'browser', 'ip', 'created_at', 'country']); return \Response::json(array('data' => $data)); }
[ "public", "function", "ajaxGetVisits", "(", ")", "{", "$", "data", "=", "Base", "::", "getVisitsRepository", "(", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "->", "take", "(", "300", ")", "->", "get", "(", "[", "'url'", ",", "'browser'", ",", "'ip'", ",", "'created_at'", ",", "'country'", "]", ")", ";", "return", "\\", "Response", "::", "json", "(", "array", "(", "'data'", "=>", "$", "data", ")", ")", ";", "}" ]
Ajax call to get all the visits @return View
[ "Ajax", "call", "to", "get", "all", "the", "visits" ]
e6a4e9f4d3c75efc92545941ea5c9810d3291b56
https://github.com/joaogl/base/blob/e6a4e9f4d3c75efc92545941ea5c9810d3291b56/src/Controllers/BaseController.php#L82-L87
9,734
hediet/php-type-reflection
src/Hediet/Types/ObjectType.php
ObjectType.getReflectionClass
public function getReflectionClass() { if ($this->reflectionClass === null) { $this->reflectionClass = new ReflectionClass($this->getName()); } return $this->reflectionClass; }
php
public function getReflectionClass() { if ($this->reflectionClass === null) { $this->reflectionClass = new ReflectionClass($this->getName()); } return $this->reflectionClass; }
[ "public", "function", "getReflectionClass", "(", ")", "{", "if", "(", "$", "this", "->", "reflectionClass", "===", "null", ")", "{", "$", "this", "->", "reflectionClass", "=", "new", "ReflectionClass", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "return", "$", "this", "->", "reflectionClass", ";", "}" ]
Gets the reflection class for this object type. @return ReflectionClass
[ "Gets", "the", "reflection", "class", "for", "this", "object", "type", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ObjectType.php#L23-L30
9,735
hediet/php-type-reflection
src/Hediet/Types/ObjectType.php
ObjectType.getMethods
public function getMethods() { //todo cache $result = array(); foreach ($this->getReflectionClass()->getMethods() as $m) { $result[] = MethodInfo::__internal_create($this, $m); } return $result; }
php
public function getMethods() { //todo cache $result = array(); foreach ($this->getReflectionClass()->getMethods() as $m) { $result[] = MethodInfo::__internal_create($this, $m); } return $result; }
[ "public", "function", "getMethods", "(", ")", "{", "//todo cache", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getReflectionClass", "(", ")", "->", "getMethods", "(", ")", "as", "$", "m", ")", "{", "$", "result", "[", "]", "=", "MethodInfo", "::", "__internal_create", "(", "$", "this", ",", "$", "m", ")", ";", "}", "return", "$", "result", ";", "}" ]
Gets a list of all defined methods. @return MethodInfo[]
[ "Gets", "a", "list", "of", "all", "defined", "methods", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ObjectType.php#L37-L46
9,736
hediet/php-type-reflection
src/Hediet/Types/ObjectType.php
ObjectType.getMethod
public function getMethod($name) { $m = $this->getReflectionClass()->getMethod($name); return MethodInfo::__internal_create($this, $m); }
php
public function getMethod($name) { $m = $this->getReflectionClass()->getMethod($name); return MethodInfo::__internal_create($this, $m); }
[ "public", "function", "getMethod", "(", "$", "name", ")", "{", "$", "m", "=", "$", "this", "->", "getReflectionClass", "(", ")", "->", "getMethod", "(", "$", "name", ")", ";", "return", "MethodInfo", "::", "__internal_create", "(", "$", "this", ",", "$", "m", ")", ";", "}" ]
Gets as method by its name. @param string $name @return MethodInfo @throws ReflectionException A reflection exception will be thrown, if the method does not exist.
[ "Gets", "as", "method", "by", "its", "name", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ObjectType.php#L55-L59
9,737
bishopb/vanilla
applications/dashboard/models/class.invitationmodel.php
InvitationModel.GetInvitationCode
protected function GetInvitationCode() { // Generate a new invitation code. $Code = RandomString(8); // Make sure the string doesn't already exist in the invitation table $CodeData = $this->GetWhere(array('Code' => $Code)); if ($CodeData->NumRows() > 0) { return $this->GetInvitationCode(); } else { return $Code; } }
php
protected function GetInvitationCode() { // Generate a new invitation code. $Code = RandomString(8); // Make sure the string doesn't already exist in the invitation table $CodeData = $this->GetWhere(array('Code' => $Code)); if ($CodeData->NumRows() > 0) { return $this->GetInvitationCode(); } else { return $Code; } }
[ "protected", "function", "GetInvitationCode", "(", ")", "{", "// Generate a new invitation code.", "$", "Code", "=", "RandomString", "(", "8", ")", ";", "// Make sure the string doesn't already exist in the invitation table", "$", "CodeData", "=", "$", "this", "->", "GetWhere", "(", "array", "(", "'Code'", "=>", "$", "Code", ")", ")", ";", "if", "(", "$", "CodeData", "->", "NumRows", "(", ")", ">", "0", ")", "{", "return", "$", "this", "->", "GetInvitationCode", "(", ")", ";", "}", "else", "{", "return", "$", "Code", ";", "}", "}" ]
Returns a unique 8 character invitation code
[ "Returns", "a", "unique", "8", "character", "invitation", "code" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.invitationmodel.php#L167-L178
9,738
face-orm/face
lib/Face/Core/FaceLoader.php
FaceLoader.addFace
public function addFace(EntityFace $face){ $this->facesByName[$face->getName()] = $face; $this->facesByClass[$face->getClass()] = $face->getName(); }
php
public function addFace(EntityFace $face){ $this->facesByName[$face->getName()] = $face; $this->facesByClass[$face->getClass()] = $face->getName(); }
[ "public", "function", "addFace", "(", "EntityFace", "$", "face", ")", "{", "$", "this", "->", "facesByName", "[", "$", "face", "->", "getName", "(", ")", "]", "=", "$", "face", ";", "$", "this", "->", "facesByClass", "[", "$", "face", "->", "getClass", "(", ")", "]", "=", "$", "face", "->", "getName", "(", ")", ";", "}" ]
Add a face to the list of available faces @param EntityFace $face
[ "Add", "a", "face", "to", "the", "list", "of", "available", "faces" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Core/FaceLoader.php#L31-L34
9,739
ddehart/dilmun
src/Anshar/Http/Uri.php
Uri.withAuthority
public function withAuthority($authority) { $with_authority = new Authority($authority); $new_authority_uri = clone $this; $new_authority_uri->authority = $with_authority; $new_authority_uri->user_info = $with_authority->getUserInfo(); $new_authority_uri->host = $with_authority->getHost(); $new_authority_uri->port = $with_authority->getPort(); return $new_authority_uri; }
php
public function withAuthority($authority) { $with_authority = new Authority($authority); $new_authority_uri = clone $this; $new_authority_uri->authority = $with_authority; $new_authority_uri->user_info = $with_authority->getUserInfo(); $new_authority_uri->host = $with_authority->getHost(); $new_authority_uri->port = $with_authority->getPort(); return $new_authority_uri; }
[ "public", "function", "withAuthority", "(", "$", "authority", ")", "{", "$", "with_authority", "=", "new", "Authority", "(", "$", "authority", ")", ";", "$", "new_authority_uri", "=", "clone", "$", "this", ";", "$", "new_authority_uri", "->", "authority", "=", "$", "with_authority", ";", "$", "new_authority_uri", "->", "user_info", "=", "$", "with_authority", "->", "getUserInfo", "(", ")", ";", "$", "new_authority_uri", "->", "host", "=", "$", "with_authority", "->", "getHost", "(", ")", ";", "$", "new_authority_uri", "->", "port", "=", "$", "with_authority", "->", "getPort", "(", ")", ";", "return", "$", "new_authority_uri", ";", "}" ]
Return an instance with the specified authority. This method MUST retain the state of the current instance, and return an instance that contains the specified authority. Replacing the authority is equivalent to replacing or removing all authority components depending upon the composition of the authority. An empty authority is equivalent to removing the authority and all authority components. @param string $authority The scheme to use with the new instance. @return static A new instance with the specified authority. @throws \InvalidArgumentException for invalid authorities.
[ "Return", "an", "instance", "with", "the", "specified", "authority", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/Uri.php#L288-L301
9,740
ddehart/dilmun
src/Anshar/Http/Uri.php
Uri.explodeUri
private function explodeUri($uri) { $uri_parts = array ( "scheme" => "", "hier_part" => "", "authority" => "", "path" => "", "query" => "", "fragment" => "", ); $uri_syntax = $this->compileUriRegEx(); $uri_valid = preg_match($uri_syntax, $uri, $parts); $uri_parts = array_merge($uri_parts, $parts); //overwriting default values with matches $this->parseExplosions($uri_parts); return (bool) $uri_valid; }
php
private function explodeUri($uri) { $uri_parts = array ( "scheme" => "", "hier_part" => "", "authority" => "", "path" => "", "query" => "", "fragment" => "", ); $uri_syntax = $this->compileUriRegEx(); $uri_valid = preg_match($uri_syntax, $uri, $parts); $uri_parts = array_merge($uri_parts, $parts); //overwriting default values with matches $this->parseExplosions($uri_parts); return (bool) $uri_valid; }
[ "private", "function", "explodeUri", "(", "$", "uri", ")", "{", "$", "uri_parts", "=", "array", "(", "\"scheme\"", "=>", "\"\"", ",", "\"hier_part\"", "=>", "\"\"", ",", "\"authority\"", "=>", "\"\"", ",", "\"path\"", "=>", "\"\"", ",", "\"query\"", "=>", "\"\"", ",", "\"fragment\"", "=>", "\"\"", ",", ")", ";", "$", "uri_syntax", "=", "$", "this", "->", "compileUriRegEx", "(", ")", ";", "$", "uri_valid", "=", "preg_match", "(", "$", "uri_syntax", ",", "$", "uri", ",", "$", "parts", ")", ";", "$", "uri_parts", "=", "array_merge", "(", "$", "uri_parts", ",", "$", "parts", ")", ";", "//overwriting default values with matches", "$", "this", "->", "parseExplosions", "(", "$", "uri_parts", ")", ";", "return", "(", "bool", ")", "$", "uri_valid", ";", "}" ]
Splits a string URI into its component parts, returning true if the URI string matches a valid URI's syntax and false if the URI string does not @param string $uri The URI string to be decomposed @return bool Returns true if the URI string matches a valid URI's syntax Returns false otherwise
[ "Splits", "a", "string", "URI", "into", "its", "component", "parts", "returning", "true", "if", "the", "URI", "string", "matches", "a", "valid", "URI", "s", "syntax", "and", "false", "if", "the", "URI", "string", "does", "not" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/Uri.php#L530-L551
9,741
ddehart/dilmun
src/Anshar/Http/Uri.php
Uri.compileUriRegEx
private function compileUriRegEx() { $reg_start = '/^'; $scheme_part = '(?:(?\'scheme\'[A-Za-z0-9][^\/\?#:]+):)?'; $authority_part = '(?:(?:\/\/)(?\'authority\'[^\/]*))?'; $path_part = '(?\'path\'[^\?#]*)?'; $query_part = '(?:\?(?\'query\'[^#]*))?'; $fragment_part = '(?:#(?\'fragment\'.*))?'; $reg_end = '/'; return $reg_start . $scheme_part . $authority_part . $path_part . $query_part . $fragment_part . $reg_end; }
php
private function compileUriRegEx() { $reg_start = '/^'; $scheme_part = '(?:(?\'scheme\'[A-Za-z0-9][^\/\?#:]+):)?'; $authority_part = '(?:(?:\/\/)(?\'authority\'[^\/]*))?'; $path_part = '(?\'path\'[^\?#]*)?'; $query_part = '(?:\?(?\'query\'[^#]*))?'; $fragment_part = '(?:#(?\'fragment\'.*))?'; $reg_end = '/'; return $reg_start . $scheme_part . $authority_part . $path_part . $query_part . $fragment_part . $reg_end; }
[ "private", "function", "compileUriRegEx", "(", ")", "{", "$", "reg_start", "=", "'/^'", ";", "$", "scheme_part", "=", "'(?:(?\\'scheme\\'[A-Za-z0-9][^\\/\\?#:]+):)?'", ";", "$", "authority_part", "=", "'(?:(?:\\/\\/)(?\\'authority\\'[^\\/]*))?'", ";", "$", "path_part", "=", "'(?\\'path\\'[^\\?#]*)?'", ";", "$", "query_part", "=", "'(?:\\?(?\\'query\\'[^#]*))?'", ";", "$", "fragment_part", "=", "'(?:#(?\\'fragment\\'.*))?'", ";", "$", "reg_end", "=", "'/'", ";", "return", "$", "reg_start", ".", "$", "scheme_part", ".", "$", "authority_part", ".", "$", "path_part", ".", "$", "query_part", ".", "$", "fragment_part", ".", "$", "reg_end", ";", "}" ]
Compiles a regular expression to match URI component parts @return string The regular expression to match URI component parts
[ "Compiles", "a", "regular", "expression", "to", "match", "URI", "component", "parts" ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/Uri.php#L558-L569
9,742
ddehart/dilmun
src/Anshar/Http/Uri.php
Uri.parseExplosions
private function parseExplosions($uri_parts) { $this->scheme = new Scheme($uri_parts["scheme"]); $this->query = new Query($uri_parts["query"]); $this->fragment = new Fragment($uri_parts["fragment"]); $this->authority = new Authority($uri_parts["authority"]); $this->user_info = $this->authority->getUserInfo(); $this->host = $this->authority->getHost(); $this->port = $this->authority->getPort(); $this->path = new Path($uri_parts["path"]); }
php
private function parseExplosions($uri_parts) { $this->scheme = new Scheme($uri_parts["scheme"]); $this->query = new Query($uri_parts["query"]); $this->fragment = new Fragment($uri_parts["fragment"]); $this->authority = new Authority($uri_parts["authority"]); $this->user_info = $this->authority->getUserInfo(); $this->host = $this->authority->getHost(); $this->port = $this->authority->getPort(); $this->path = new Path($uri_parts["path"]); }
[ "private", "function", "parseExplosions", "(", "$", "uri_parts", ")", "{", "$", "this", "->", "scheme", "=", "new", "Scheme", "(", "$", "uri_parts", "[", "\"scheme\"", "]", ")", ";", "$", "this", "->", "query", "=", "new", "Query", "(", "$", "uri_parts", "[", "\"query\"", "]", ")", ";", "$", "this", "->", "fragment", "=", "new", "Fragment", "(", "$", "uri_parts", "[", "\"fragment\"", "]", ")", ";", "$", "this", "->", "authority", "=", "new", "Authority", "(", "$", "uri_parts", "[", "\"authority\"", "]", ")", ";", "$", "this", "->", "user_info", "=", "$", "this", "->", "authority", "->", "getUserInfo", "(", ")", ";", "$", "this", "->", "host", "=", "$", "this", "->", "authority", "->", "getHost", "(", ")", ";", "$", "this", "->", "port", "=", "$", "this", "->", "authority", "->", "getPort", "(", ")", ";", "$", "this", "->", "path", "=", "new", "Path", "(", "$", "uri_parts", "[", "\"path\"", "]", ")", ";", "}" ]
Parses the results of exploding URI parts. Creates component objects. @param string[] $uri_parts An array of strings representing the parts of a uri @return void
[ "Parses", "the", "results", "of", "exploding", "URI", "parts", ".", "Creates", "component", "objects", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/Uri.php#L578-L588
9,743
fabsgc/framework
Core/Security/Firewall.php
Firewall._setFirewall
protected function _setFirewall() { $csrf = explode('.', $this->_configFirewall['csrf']['name']); $logged = explode('.', $this->_configFirewall['logged']['name']); $role = explode('.', $this->_configFirewall['roles']['name']); $this->_csrf['POST'] = $this->_setFirewallConfigArray($_POST, $csrf); $this->_csrf['GET'] = $this->_setFirewallConfigArray($_GET, $csrf); $this->_csrf['SESSION'] = $this->_setFirewallConfigArray($_SESSION, $csrf); $this->_logged = $this->_setFirewallConfigArray($_SESSION, $logged); $this->_role = $this->_setFirewallConfigArray($_SESSION, $role); }
php
protected function _setFirewall() { $csrf = explode('.', $this->_configFirewall['csrf']['name']); $logged = explode('.', $this->_configFirewall['logged']['name']); $role = explode('.', $this->_configFirewall['roles']['name']); $this->_csrf['POST'] = $this->_setFirewallConfigArray($_POST, $csrf); $this->_csrf['GET'] = $this->_setFirewallConfigArray($_GET, $csrf); $this->_csrf['SESSION'] = $this->_setFirewallConfigArray($_SESSION, $csrf); $this->_logged = $this->_setFirewallConfigArray($_SESSION, $logged); $this->_role = $this->_setFirewallConfigArray($_SESSION, $role); }
[ "protected", "function", "_setFirewall", "(", ")", "{", "$", "csrf", "=", "explode", "(", "'.'", ",", "$", "this", "->", "_configFirewall", "[", "'csrf'", "]", "[", "'name'", "]", ")", ";", "$", "logged", "=", "explode", "(", "'.'", ",", "$", "this", "->", "_configFirewall", "[", "'logged'", "]", "[", "'name'", "]", ")", ";", "$", "role", "=", "explode", "(", "'.'", ",", "$", "this", "->", "_configFirewall", "[", "'roles'", "]", "[", "'name'", "]", ")", ";", "$", "this", "->", "_csrf", "[", "'POST'", "]", "=", "$", "this", "->", "_setFirewallConfigArray", "(", "$", "_POST", ",", "$", "csrf", ")", ";", "$", "this", "->", "_csrf", "[", "'GET'", "]", "=", "$", "this", "->", "_setFirewallConfigArray", "(", "$", "_GET", ",", "$", "csrf", ")", ";", "$", "this", "->", "_csrf", "[", "'SESSION'", "]", "=", "$", "this", "->", "_setFirewallConfigArray", "(", "$", "_SESSION", ",", "$", "csrf", ")", ";", "$", "this", "->", "_logged", "=", "$", "this", "->", "_setFirewallConfigArray", "(", "$", "_SESSION", ",", "$", "logged", ")", ";", "$", "this", "->", "_role", "=", "$", "this", "->", "_setFirewallConfigArray", "(", "$", "_SESSION", ",", "$", "role", ")", ";", "}" ]
set firewall configuration @access public @return void @since 3.0 @package Gcs\Framework\Core\Security
[ "set", "firewall", "configuration" ]
45e58182aba6a3c6381970a1fd3c17662cff2168
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Security/Firewall.php#L82-L92
9,744
RitaCo/cakephp-tools-plugin
View/Helper/PersiandateHelper.php
PersiandateHelper.lastday
function lastday ($month,$day,$year) { $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year)); list( $jyear, $jmonth, $jday ) = $this->gregorian_to_jalali($year, $month, $day); $lastdatep=$jday; $jday=$jday2; while($jday2!="1") { if($day<$lastdayen) { $day++; list( $jyear, $jmonth, $jday2 ) = $this->gregorian_to_jalali($year, $month, $day); if($pdate2=="1") break; if($pdate2!="1") $lastdatep++; } else { $day=0; $month++; if($month==13) { $month="1"; $year++; } } } return $lastdatep-1; }
php
function lastday ($month,$day,$year) { $lastdayen=date("d",mktime(0,0,0,$month+1,0,$year)); list( $jyear, $jmonth, $jday ) = $this->gregorian_to_jalali($year, $month, $day); $lastdatep=$jday; $jday=$jday2; while($jday2!="1") { if($day<$lastdayen) { $day++; list( $jyear, $jmonth, $jday2 ) = $this->gregorian_to_jalali($year, $month, $day); if($pdate2=="1") break; if($pdate2!="1") $lastdatep++; } else { $day=0; $month++; if($month==13) { $month="1"; $year++; } } } return $lastdatep-1; }
[ "function", "lastday", "(", "$", "month", ",", "$", "day", ",", "$", "year", ")", "{", "$", "lastdayen", "=", "date", "(", "\"d\"", ",", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "month", "+", "1", ",", "0", ",", "$", "year", ")", ")", ";", "list", "(", "$", "jyear", ",", "$", "jmonth", ",", "$", "jday", ")", "=", "$", "this", "->", "gregorian_to_jalali", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "$", "lastdatep", "=", "$", "jday", ";", "$", "jday", "=", "$", "jday2", ";", "while", "(", "$", "jday2", "!=", "\"1\"", ")", "{", "if", "(", "$", "day", "<", "$", "lastdayen", ")", "{", "$", "day", "++", ";", "list", "(", "$", "jyear", ",", "$", "jmonth", ",", "$", "jday2", ")", "=", "$", "this", "->", "gregorian_to_jalali", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "if", "(", "$", "pdate2", "==", "\"1\"", ")", "break", ";", "if", "(", "$", "pdate2", "!=", "\"1\"", ")", "$", "lastdatep", "++", ";", "}", "else", "{", "$", "day", "=", "0", ";", "$", "month", "++", ";", "if", "(", "$", "month", "==", "13", ")", "{", "$", "month", "=", "\"1\"", ";", "$", "year", "++", ";", "}", "}", "}", "return", "$", "lastdatep", "-", "1", ";", "}" ]
Find Number Of Days In This Month
[ "Find", "Number", "Of", "Days", "In", "This", "Month" ]
e9581f1d666560721d70f5dad116f52f77a687ff
https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/View/Helper/PersiandateHelper.php#L415-L471
9,745
score-ya/cinderella-sdk
src/Template/Command/Fetch.php
Fetch.prepare
public function prepare() { $request = parent::prepare(); $url = $request->getUrl(true); $query = $url->getQuery(); $query->merge($this->templateVariables); $request->setUrl($url); return $request; }
php
public function prepare() { $request = parent::prepare(); $url = $request->getUrl(true); $query = $url->getQuery(); $query->merge($this->templateVariables); $request->setUrl($url); return $request; }
[ "public", "function", "prepare", "(", ")", "{", "$", "request", "=", "parent", "::", "prepare", "(", ")", ";", "$", "url", "=", "$", "request", "->", "getUrl", "(", "true", ")", ";", "$", "query", "=", "$", "url", "->", "getQuery", "(", ")", ";", "$", "query", "->", "merge", "(", "$", "this", "->", "templateVariables", ")", ";", "$", "request", "->", "setUrl", "(", "$", "url", ")", ";", "return", "$", "request", ";", "}" ]
add the template variables to the query part @return \Guzzle\Http\Message\RequestInterface
[ "add", "the", "template", "variables", "to", "the", "query", "part" ]
bed7371cb1caeefd1efcb09306c10d8805270e17
https://github.com/score-ya/cinderella-sdk/blob/bed7371cb1caeefd1efcb09306c10d8805270e17/src/Template/Command/Fetch.php#L36-L47
9,746
martinhej/robocloud
src/robocloud/DependencyInjection/Configuration.php
Configuration.addKinesisConfiguration
protected function addKinesisConfiguration(ArrayNodeDefinition $rootNode) { $rootNode->children() ->arrayNode('kinesis') ->children() ->scalarNode('api_version')->defaultValue('2013-12-02')->end() ->scalarNode('region')->isRequired()->end() ->arrayNode('consumer') ->children() ->scalarNode('recovery_file')->isRequired()->end() ->scalarNode('key')->isRequired()->end() ->scalarNode('secret')->isRequired()->end() ->end() ->end() ->arrayNode('producer') ->children() ->scalarNode('key')->isRequired()->end() ->scalarNode('secret')->isRequired()->end() ->end() ->end() ->end() ->end() ->end(); }
php
protected function addKinesisConfiguration(ArrayNodeDefinition $rootNode) { $rootNode->children() ->arrayNode('kinesis') ->children() ->scalarNode('api_version')->defaultValue('2013-12-02')->end() ->scalarNode('region')->isRequired()->end() ->arrayNode('consumer') ->children() ->scalarNode('recovery_file')->isRequired()->end() ->scalarNode('key')->isRequired()->end() ->scalarNode('secret')->isRequired()->end() ->end() ->end() ->arrayNode('producer') ->children() ->scalarNode('key')->isRequired()->end() ->scalarNode('secret')->isRequired()->end() ->end() ->end() ->end() ->end() ->end(); }
[ "protected", "function", "addKinesisConfiguration", "(", "ArrayNodeDefinition", "$", "rootNode", ")", "{", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'kinesis'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'api_version'", ")", "->", "defaultValue", "(", "'2013-12-02'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'region'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'consumer'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'recovery_file'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'key'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'secret'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'producer'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'key'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'secret'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Adds Kinesis configuration. @param ArrayNodeDefinition $rootNode
[ "Adds", "Kinesis", "configuration", "." ]
108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229
https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/DependencyInjection/Configuration.php#L42-L64
9,747
martinhej/robocloud
src/robocloud/DependencyInjection/Configuration.php
Configuration.addDynamoDBConfiguration
protected function addDynamoDBConfiguration(ArrayNodeDefinition $rootNode) { $rootNode->children() ->arrayNode('dynamodb') ->children() ->scalarNode('api_version')->defaultValue('2012-08-10')->end() ->scalarNode('region')->isRequired()->end() ->end() ->end() ->end(); }
php
protected function addDynamoDBConfiguration(ArrayNodeDefinition $rootNode) { $rootNode->children() ->arrayNode('dynamodb') ->children() ->scalarNode('api_version')->defaultValue('2012-08-10')->end() ->scalarNode('region')->isRequired()->end() ->end() ->end() ->end(); }
[ "protected", "function", "addDynamoDBConfiguration", "(", "ArrayNodeDefinition", "$", "rootNode", ")", "{", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", "(", "'dynamodb'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'api_version'", ")", "->", "defaultValue", "(", "'2012-08-10'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'region'", ")", "->", "isRequired", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Adds DynamoDb configuration. @param ArrayNodeDefinition $rootNode
[ "Adds", "DynamoDb", "configuration", "." ]
108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229
https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/DependencyInjection/Configuration.php#L71-L80
9,748
Eresus/Gallery
src/gallery/phpthumb/GdThumb.inc.php
GdThumb.crop
public function crop ($startX, $startY, $cropWidth, $cropHeight) { // validate input if (!is_numeric($startX)) { throw new InvalidArgumentException('$startX must be numeric'); } if (!is_numeric($startY)) { throw new InvalidArgumentException('$startY must be numeric'); } if (!is_numeric($cropWidth)) { throw new InvalidArgumentException('$cropWidth must be numeric'); } if (!is_numeric($cropHeight)) { throw new InvalidArgumentException('$cropHeight must be numeric'); } // do some calculations $cropWidth = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth; $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight; // ensure everything's in bounds if (($startX + $cropWidth) > $this->currentDimensions['width']) { $startX = ($this->currentDimensions['width'] - $cropWidth); } if (($startY + $cropHeight) > $this->currentDimensions['height']) { $startY = ($this->currentDimensions['height'] - $cropHeight); } if ($startX < 0) { $startX = 0; } if ($startY < 0) { $startY = 0; } // create the working image if (function_exists('imagecreatetruecolor')) { $this->workingImage = imagecreatetruecolor($cropWidth, $cropHeight); } else { $this->workingImage = imagecreate($cropWidth, $cropHeight); } $this->preserveAlpha(); imagecopyresampled ( $this->workingImage, $this->oldImage, 0, 0, $startX, $startY, $cropWidth, $cropHeight, $cropWidth, $cropHeight ); $this->oldImage = $this->workingImage; $this->currentDimensions['width'] = $cropWidth; $this->currentDimensions['height'] = $cropHeight; return $this; }
php
public function crop ($startX, $startY, $cropWidth, $cropHeight) { // validate input if (!is_numeric($startX)) { throw new InvalidArgumentException('$startX must be numeric'); } if (!is_numeric($startY)) { throw new InvalidArgumentException('$startY must be numeric'); } if (!is_numeric($cropWidth)) { throw new InvalidArgumentException('$cropWidth must be numeric'); } if (!is_numeric($cropHeight)) { throw new InvalidArgumentException('$cropHeight must be numeric'); } // do some calculations $cropWidth = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth; $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight; // ensure everything's in bounds if (($startX + $cropWidth) > $this->currentDimensions['width']) { $startX = ($this->currentDimensions['width'] - $cropWidth); } if (($startY + $cropHeight) > $this->currentDimensions['height']) { $startY = ($this->currentDimensions['height'] - $cropHeight); } if ($startX < 0) { $startX = 0; } if ($startY < 0) { $startY = 0; } // create the working image if (function_exists('imagecreatetruecolor')) { $this->workingImage = imagecreatetruecolor($cropWidth, $cropHeight); } else { $this->workingImage = imagecreate($cropWidth, $cropHeight); } $this->preserveAlpha(); imagecopyresampled ( $this->workingImage, $this->oldImage, 0, 0, $startX, $startY, $cropWidth, $cropHeight, $cropWidth, $cropHeight ); $this->oldImage = $this->workingImage; $this->currentDimensions['width'] = $cropWidth; $this->currentDimensions['height'] = $cropHeight; return $this; }
[ "public", "function", "crop", "(", "$", "startX", ",", "$", "startY", ",", "$", "cropWidth", ",", "$", "cropHeight", ")", "{", "// validate input", "if", "(", "!", "is_numeric", "(", "$", "startX", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$startX must be numeric'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "startY", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$startY must be numeric'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "cropWidth", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$cropWidth must be numeric'", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "cropHeight", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$cropHeight must be numeric'", ")", ";", "}", "// do some calculations", "$", "cropWidth", "=", "(", "$", "this", "->", "currentDimensions", "[", "'width'", "]", "<", "$", "cropWidth", ")", "?", "$", "this", "->", "currentDimensions", "[", "'width'", "]", ":", "$", "cropWidth", ";", "$", "cropHeight", "=", "(", "$", "this", "->", "currentDimensions", "[", "'height'", "]", "<", "$", "cropHeight", ")", "?", "$", "this", "->", "currentDimensions", "[", "'height'", "]", ":", "$", "cropHeight", ";", "// ensure everything's in bounds", "if", "(", "(", "$", "startX", "+", "$", "cropWidth", ")", ">", "$", "this", "->", "currentDimensions", "[", "'width'", "]", ")", "{", "$", "startX", "=", "(", "$", "this", "->", "currentDimensions", "[", "'width'", "]", "-", "$", "cropWidth", ")", ";", "}", "if", "(", "(", "$", "startY", "+", "$", "cropHeight", ")", ">", "$", "this", "->", "currentDimensions", "[", "'height'", "]", ")", "{", "$", "startY", "=", "(", "$", "this", "->", "currentDimensions", "[", "'height'", "]", "-", "$", "cropHeight", ")", ";", "}", "if", "(", "$", "startX", "<", "0", ")", "{", "$", "startX", "=", "0", ";", "}", "if", "(", "$", "startY", "<", "0", ")", "{", "$", "startY", "=", "0", ";", "}", "// create the working image", "if", "(", "function_exists", "(", "'imagecreatetruecolor'", ")", ")", "{", "$", "this", "->", "workingImage", "=", "imagecreatetruecolor", "(", "$", "cropWidth", ",", "$", "cropHeight", ")", ";", "}", "else", "{", "$", "this", "->", "workingImage", "=", "imagecreate", "(", "$", "cropWidth", ",", "$", "cropHeight", ")", ";", "}", "$", "this", "->", "preserveAlpha", "(", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "workingImage", ",", "$", "this", "->", "oldImage", ",", "0", ",", "0", ",", "$", "startX", ",", "$", "startY", ",", "$", "cropWidth", ",", "$", "cropHeight", ",", "$", "cropWidth", ",", "$", "cropHeight", ")", ";", "$", "this", "->", "oldImage", "=", "$", "this", "->", "workingImage", ";", "$", "this", "->", "currentDimensions", "[", "'width'", "]", "=", "$", "cropWidth", ";", "$", "this", "->", "currentDimensions", "[", "'height'", "]", "=", "$", "cropHeight", ";", "return", "$", "this", ";", "}" ]
Vanilla Cropping - Crops from x,y with specified width and height @param int $startX @param int $startY @param int $cropWidth @param int $cropHeight @return GdThumb
[ "Vanilla", "Cropping", "-", "Crops", "from", "x", "y", "with", "specified", "width", "and", "height" ]
1088c5563597abc38c3772b335ca62de47721af8
https://github.com/Eresus/Gallery/blob/1088c5563597abc38c3772b335ca62de47721af8/src/gallery/phpthumb/GdThumb.inc.php#L424-L504
9,749
Eresus/Gallery
src/gallery/phpthumb/GdThumb.inc.php
GdThumb.rotateImageNDegrees
public function rotateImageNDegrees ($degrees) { if (!is_numeric($degrees)) { throw new InvalidArgumentException('$degrees must be numeric'); } if (!function_exists('imagerotate')) { throw new RuntimeException('Your version of GD does not support image rotation.'); } $this->workingImage = imagerotate($this->oldImage, $degrees, 0); $newWidth = $this->currentDimensions['height']; $newHeight = $this->currentDimensions['width']; $this->oldImage = $this->workingImage; $this->currentDimensions['width'] = $newWidth; $this->currentDimensions['height'] = $newHeight; return $this; }
php
public function rotateImageNDegrees ($degrees) { if (!is_numeric($degrees)) { throw new InvalidArgumentException('$degrees must be numeric'); } if (!function_exists('imagerotate')) { throw new RuntimeException('Your version of GD does not support image rotation.'); } $this->workingImage = imagerotate($this->oldImage, $degrees, 0); $newWidth = $this->currentDimensions['height']; $newHeight = $this->currentDimensions['width']; $this->oldImage = $this->workingImage; $this->currentDimensions['width'] = $newWidth; $this->currentDimensions['height'] = $newHeight; return $this; }
[ "public", "function", "rotateImageNDegrees", "(", "$", "degrees", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "degrees", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$degrees must be numeric'", ")", ";", "}", "if", "(", "!", "function_exists", "(", "'imagerotate'", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Your version of GD does not support image rotation.'", ")", ";", "}", "$", "this", "->", "workingImage", "=", "imagerotate", "(", "$", "this", "->", "oldImage", ",", "$", "degrees", ",", "0", ")", ";", "$", "newWidth", "=", "$", "this", "->", "currentDimensions", "[", "'height'", "]", ";", "$", "newHeight", "=", "$", "this", "->", "currentDimensions", "[", "'width'", "]", ";", "$", "this", "->", "oldImage", "=", "$", "this", "->", "workingImage", ";", "$", "this", "->", "currentDimensions", "[", "'width'", "]", "=", "$", "newWidth", ";", "$", "this", "->", "currentDimensions", "[", "'height'", "]", "=", "$", "newHeight", ";", "return", "$", "this", ";", "}" ]
Rotates image specified number of degrees @param int $degrees @return GdThumb
[ "Rotates", "image", "specified", "number", "of", "degrees" ]
1088c5563597abc38c3772b335ca62de47721af8
https://github.com/Eresus/Gallery/blob/1088c5563597abc38c3772b335ca62de47721af8/src/gallery/phpthumb/GdThumb.inc.php#L532-L553
9,750
Eresus/Gallery
src/gallery/phpthumb/GdThumb.inc.php
GdThumb.verifyFormatCompatiblity
protected function verifyFormatCompatiblity () { $isCompatible = true; $gdInfo = gd_info(); switch ($this->format) { case 'GIF': $isCompatible = $gdInfo['GIF Create Support']; break; case 'JPG': $isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false; break; case 'PNG': $isCompatible = $gdInfo[$this->format . ' Support']; break; default: $isCompatible = false; } if (!$isCompatible) { // one last check for "JPEG" instead $isCompatible = $gdInfo['JPEG Support']; if (!$isCompatible) { $this->triggerError('Your GD installation does not support ' . $this->format . ' image types'); } } }
php
protected function verifyFormatCompatiblity () { $isCompatible = true; $gdInfo = gd_info(); switch ($this->format) { case 'GIF': $isCompatible = $gdInfo['GIF Create Support']; break; case 'JPG': $isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false; break; case 'PNG': $isCompatible = $gdInfo[$this->format . ' Support']; break; default: $isCompatible = false; } if (!$isCompatible) { // one last check for "JPEG" instead $isCompatible = $gdInfo['JPEG Support']; if (!$isCompatible) { $this->triggerError('Your GD installation does not support ' . $this->format . ' image types'); } } }
[ "protected", "function", "verifyFormatCompatiblity", "(", ")", "{", "$", "isCompatible", "=", "true", ";", "$", "gdInfo", "=", "gd_info", "(", ")", ";", "switch", "(", "$", "this", "->", "format", ")", "{", "case", "'GIF'", ":", "$", "isCompatible", "=", "$", "gdInfo", "[", "'GIF Create Support'", "]", ";", "break", ";", "case", "'JPG'", ":", "$", "isCompatible", "=", "(", "isset", "(", "$", "gdInfo", "[", "'JPG Support'", "]", ")", "||", "isset", "(", "$", "gdInfo", "[", "'JPEG Support'", "]", ")", ")", "?", "true", ":", "false", ";", "break", ";", "case", "'PNG'", ":", "$", "isCompatible", "=", "$", "gdInfo", "[", "$", "this", "->", "format", ".", "' Support'", "]", ";", "break", ";", "default", ":", "$", "isCompatible", "=", "false", ";", "}", "if", "(", "!", "$", "isCompatible", ")", "{", "// one last check for \"JPEG\" instead", "$", "isCompatible", "=", "$", "gdInfo", "[", "'JPEG Support'", "]", ";", "if", "(", "!", "$", "isCompatible", ")", "{", "$", "this", "->", "triggerError", "(", "'Your GD installation does not support '", ".", "$", "this", "->", "format", ".", "' image types'", ")", ";", "}", "}", "}" ]
Makes sure the correct GD implementation exists for the file type
[ "Makes", "sure", "the", "correct", "GD", "implementation", "exists", "for", "the", "file", "type" ]
1088c5563597abc38c3772b335ca62de47721af8
https://github.com/Eresus/Gallery/blob/1088c5563597abc38c3772b335ca62de47721af8/src/gallery/phpthumb/GdThumb.inc.php#L1110-L1140
9,751
opis-colibri/user-sql
src/Repositories/UserRepository.php
UserRepository.save
public function save(IUser $user): bool { if ($user instanceof AnonymousUser) { return false; } if ($user->isNew()) { $roles = $this->filterRoles($user->getUserRoles()); $user->addRoles(array_values($roles)); return entityManager()->save($user); } if (!entityManager()->save($user)) { return false; } if (null !== $roles = $user->getUserRoles()) { $toAdd = $this->filterRoles($roles); $toRemove = []; foreach ($user->roles() as $role) { $name = $role->name(); if (!isset($toAdd[$name])) { $toRemove[] = $role; } else { unset($toAdd[$name]); } } if (!empty($toRemove)) { $user->removeRoles($toRemove); } if (!empty($toAdd)) { $user->addRoles(array_values($toAdd)); } } return true; }
php
public function save(IUser $user): bool { if ($user instanceof AnonymousUser) { return false; } if ($user->isNew()) { $roles = $this->filterRoles($user->getUserRoles()); $user->addRoles(array_values($roles)); return entityManager()->save($user); } if (!entityManager()->save($user)) { return false; } if (null !== $roles = $user->getUserRoles()) { $toAdd = $this->filterRoles($roles); $toRemove = []; foreach ($user->roles() as $role) { $name = $role->name(); if (!isset($toAdd[$name])) { $toRemove[] = $role; } else { unset($toAdd[$name]); } } if (!empty($toRemove)) { $user->removeRoles($toRemove); } if (!empty($toAdd)) { $user->addRoles(array_values($toAdd)); } } return true; }
[ "public", "function", "save", "(", "IUser", "$", "user", ")", ":", "bool", "{", "if", "(", "$", "user", "instanceof", "AnonymousUser", ")", "{", "return", "false", ";", "}", "if", "(", "$", "user", "->", "isNew", "(", ")", ")", "{", "$", "roles", "=", "$", "this", "->", "filterRoles", "(", "$", "user", "->", "getUserRoles", "(", ")", ")", ";", "$", "user", "->", "addRoles", "(", "array_values", "(", "$", "roles", ")", ")", ";", "return", "entityManager", "(", ")", "->", "save", "(", "$", "user", ")", ";", "}", "if", "(", "!", "entityManager", "(", ")", "->", "save", "(", "$", "user", ")", ")", "{", "return", "false", ";", "}", "if", "(", "null", "!==", "$", "roles", "=", "$", "user", "->", "getUserRoles", "(", ")", ")", "{", "$", "toAdd", "=", "$", "this", "->", "filterRoles", "(", "$", "roles", ")", ";", "$", "toRemove", "=", "[", "]", ";", "foreach", "(", "$", "user", "->", "roles", "(", ")", "as", "$", "role", ")", "{", "$", "name", "=", "$", "role", "->", "name", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "toAdd", "[", "$", "name", "]", ")", ")", "{", "$", "toRemove", "[", "]", "=", "$", "role", ";", "}", "else", "{", "unset", "(", "$", "toAdd", "[", "$", "name", "]", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "toRemove", ")", ")", "{", "$", "user", "->", "removeRoles", "(", "$", "toRemove", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "toAdd", ")", ")", "{", "$", "user", "->", "addRoles", "(", "array_values", "(", "$", "toAdd", ")", ")", ";", "}", "}", "return", "true", ";", "}" ]
Save modified user @param IUser|User $user @return bool
[ "Save", "modified", "user" ]
68c7765cda02992bf2d8302afb2b519b8b0bdf2f
https://github.com/opis-colibri/user-sql/blob/68c7765cda02992bf2d8302afb2b519b8b0bdf2f/src/Repositories/UserRepository.php#L78-L117
9,752
satooshi/ltsv-encoder
src/Contrib/Component/Serializer/Factory.php
Factory.createSerializer
public static function createSerializer() { $encoders = array(new XmlEncoder(), new JsonEncoder(), new LtsvEncoder()); $normalizers = array(new GetSetMethodNormalizer()); return new Serializer($normalizers, $encoders); }
php
public static function createSerializer() { $encoders = array(new XmlEncoder(), new JsonEncoder(), new LtsvEncoder()); $normalizers = array(new GetSetMethodNormalizer()); return new Serializer($normalizers, $encoders); }
[ "public", "static", "function", "createSerializer", "(", ")", "{", "$", "encoders", "=", "array", "(", "new", "XmlEncoder", "(", ")", ",", "new", "JsonEncoder", "(", ")", ",", "new", "LtsvEncoder", "(", ")", ")", ";", "$", "normalizers", "=", "array", "(", "new", "GetSetMethodNormalizer", "(", ")", ")", ";", "return", "new", "Serializer", "(", "$", "normalizers", ",", "$", "encoders", ")", ";", "}" ]
Create LTSV serializer. @return \Symfony\Component\Serializer\Serializer
[ "Create", "LTSV", "serializer", "." ]
ef906c2ffe33315ae63678fc6dc116ed26fea959
https://github.com/satooshi/ltsv-encoder/blob/ef906c2ffe33315ae63678fc6dc116ed26fea959/src/Contrib/Component/Serializer/Factory.php#L22-L28
9,753
samurai-fw/samurai
src/Samurai/Component/Migration/Phinx/Db/Table.php
Table.addColumn
public function addColumn($columnName, $type = null, $options = []) { $column = new Column(); $column->setName($columnName); $column->setType($type); $column->setOptions($options); $column->setTable($this); parent::addColumn($column); return $column; }
php
public function addColumn($columnName, $type = null, $options = []) { $column = new Column(); $column->setName($columnName); $column->setType($type); $column->setOptions($options); $column->setTable($this); parent::addColumn($column); return $column; }
[ "public", "function", "addColumn", "(", "$", "columnName", ",", "$", "type", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "column", "=", "new", "Column", "(", ")", ";", "$", "column", "->", "setName", "(", "$", "columnName", ")", ";", "$", "column", "->", "setType", "(", "$", "type", ")", ";", "$", "column", "->", "setOptions", "(", "$", "options", ")", ";", "$", "column", "->", "setTable", "(", "$", "this", ")", ";", "parent", "::", "addColumn", "(", "$", "column", ")", ";", "return", "$", "column", ";", "}" ]
addColumn wrapper. {@inheritdoc}
[ "addColumn", "wrapper", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Migration/Phinx/Db/Table.php#L60-L72
9,754
samurai-fw/samurai
src/Samurai/Component/Migration/Phinx/Db/Table.php
Table.changeColumn
public function changeColumn($columnName, $newColumnType, $options = []) { if (!$newColumnType instanceof Column) { $newColumn = new Column(); $newColumn->setType($newColumnType); $newColumn->setOptions($options); } else { $newColumn = $newColumnType; } return parent::changeColumn($columnName, $newColumn); }
php
public function changeColumn($columnName, $newColumnType, $options = []) { if (!$newColumnType instanceof Column) { $newColumn = new Column(); $newColumn->setType($newColumnType); $newColumn->setOptions($options); } else { $newColumn = $newColumnType; } return parent::changeColumn($columnName, $newColumn); }
[ "public", "function", "changeColumn", "(", "$", "columnName", ",", "$", "newColumnType", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "newColumnType", "instanceof", "Column", ")", "{", "$", "newColumn", "=", "new", "Column", "(", ")", ";", "$", "newColumn", "->", "setType", "(", "$", "newColumnType", ")", ";", "$", "newColumn", "->", "setOptions", "(", "$", "options", ")", ";", "}", "else", "{", "$", "newColumn", "=", "$", "newColumnType", ";", "}", "return", "parent", "::", "changeColumn", "(", "$", "columnName", ",", "$", "newColumn", ")", ";", "}" ]
changeColumn wrapper. {@inheritdoc}
[ "changeColumn", "wrapper", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Migration/Phinx/Db/Table.php#L79-L90
9,755
samurai-fw/samurai
src/Samurai/Component/Migration/Phinx/Db/Table.php
Table.column
public function column($name, $type = null, $options = []) { return $this->addColumn($name, $type, $options); }
php
public function column($name, $type = null, $options = []) { return $this->addColumn($name, $type, $options); }
[ "public", "function", "column", "(", "$", "name", ",", "$", "type", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "addColumn", "(", "$", "name", ",", "$", "type", ",", "$", "options", ")", ";", "}" ]
add column bridge @param string $name @param string $type @param array $options @return Samurai\Samurai\Component\Migration\Phinx\Db\Column
[ "add", "column", "bridge" ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Migration/Phinx/Db/Table.php#L100-L103
9,756
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.sys_get_errors
protected function sys_get_errors() { $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); if (empty($errors)) { return ""; } $message_array = []; foreach ($errors as $error) { $message_array[$error['message']] = $error['message']; } return implode("\n", $message_array); }
php
protected function sys_get_errors() { $errors = sqlsrv_errors(SQLSRV_ERR_ERRORS); if (empty($errors)) { return ""; } $message_array = []; foreach ($errors as $error) { $message_array[$error['message']] = $error['message']; } return implode("\n", $message_array); }
[ "protected", "function", "sys_get_errors", "(", ")", "{", "$", "errors", "=", "sqlsrv_errors", "(", "SQLSRV_ERR_ERRORS", ")", ";", "if", "(", "empty", "(", "$", "errors", ")", ")", "{", "return", "\"\"", ";", "}", "$", "message_array", "=", "[", "]", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "message_array", "[", "$", "error", "[", "'message'", "]", "]", "=", "$", "error", "[", "'message'", "]", ";", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "message_array", ")", ";", "}" ]
Retrieves the last errors ocurend while execution of the query. @return string Returns the string of errors separated by the new line symbol. @author Oleg Schildt
[ "Retrieves", "the", "last", "errors", "ocurend", "while", "execution", "of", "the", "query", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L104-L118
9,757
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.init
public function init($parameters) { if (!empty($parameters["db_server"])) { $this->db_server = $parameters["db_server"]; } if (!empty($parameters["db_name"])) { $this->db_name = $parameters["db_name"]; } if (!empty($parameters["db_user"])) { $this->db_user = $parameters["db_user"]; } if (!empty($parameters["db_password"])) { $this->db_password = $parameters["db_password"]; } return true; }
php
public function init($parameters) { if (!empty($parameters["db_server"])) { $this->db_server = $parameters["db_server"]; } if (!empty($parameters["db_name"])) { $this->db_name = $parameters["db_name"]; } if (!empty($parameters["db_user"])) { $this->db_user = $parameters["db_user"]; } if (!empty($parameters["db_password"])) { $this->db_password = $parameters["db_password"]; } return true; }
[ "public", "function", "init", "(", "$", "parameters", ")", "{", "if", "(", "!", "empty", "(", "$", "parameters", "[", "\"db_server\"", "]", ")", ")", "{", "$", "this", "->", "db_server", "=", "$", "parameters", "[", "\"db_server\"", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "parameters", "[", "\"db_name\"", "]", ")", ")", "{", "$", "this", "->", "db_name", "=", "$", "parameters", "[", "\"db_name\"", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "parameters", "[", "\"db_user\"", "]", ")", ")", "{", "$", "this", "->", "db_user", "=", "$", "parameters", "[", "\"db_user\"", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "parameters", "[", "\"db_password\"", "]", ")", ")", "{", "$", "this", "->", "db_password", "=", "$", "parameters", "[", "\"db_password\"", "]", ";", "}", "return", "true", ";", "}" ]
Initializes the dbworker with connection paramters. @param array $parameters Connection settings as an associative array in the form key => value: - $parameters["db_server"] - server address. - $parameters["db_name"] - database name. - $parameters["db_user"] - user name. - $parameters["db_password"] - user password. @return boolean Returns true upon successful initialization, otherwise false. @author Oleg Schildt
[ "Initializes", "the", "dbworker", "with", "connection", "paramters", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L189-L205
9,758
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.qualify_name_with_schema
public function qualify_name_with_schema($name) { $schema = $this->get_schema(); if (!empty($schema)) { $schema .= "."; } return $schema . $name; }
php
public function qualify_name_with_schema($name) { $schema = $this->get_schema(); if (!empty($schema)) { $schema .= "."; } return $schema . $name; }
[ "public", "function", "qualify_name_with_schema", "(", "$", "name", ")", "{", "$", "schema", "=", "$", "this", "->", "get_schema", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "schema", ")", ")", "{", "$", "schema", ".=", "\".\"", ";", "}", "return", "$", "schema", ".", "$", "name", ";", "}" ]
Completes the name of a database object with the schema name if applicable. @param string $name The name of the database object to be completed with the schema name. @return string Returns the name of the database object with the schema name if applicable, otherwise the name of the database object remains unchanged. @see get_schema() @author Oleg Schildt
[ "Completes", "the", "name", "of", "a", "database", "object", "with", "the", "schema", "name", "if", "applicable", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L416-L425
9,759
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.insert_id
public function insert_id() { if (!$this->connection) { $this->last_error_id = "db_server_conn_error"; return false; } if ($this->last_query_is_insert) { if (!$this->statement) { return null; } if (!sqlsrv_next_result($this->statement)) { $this->last_error = $this->sys_get_errors(); $this->last_error_id = "db_query_error"; trigger_error($this->last_error, E_USER_ERROR); return false; } $id = null; if (@sqlsrv_fetch($this->statement)) { $id = sqlsrv_get_field($this->statement, 0); } return $id; } $this->statement = @sqlsrv_query($this->connection, "SELECT SCOPE_IDENTITY() AS IID"); if (!$this->statement) { $this->last_error = $this->sys_get_errors(); $this->last_error_id = "db_query_error"; trigger_error($this->last_error, E_USER_ERROR); return false; } if (!$this->fetch_row()) { $this->last_error_id = "db_query_error"; return false; } $id = $this->field_by_name("IID"); $this->free_result(); return $id; }
php
public function insert_id() { if (!$this->connection) { $this->last_error_id = "db_server_conn_error"; return false; } if ($this->last_query_is_insert) { if (!$this->statement) { return null; } if (!sqlsrv_next_result($this->statement)) { $this->last_error = $this->sys_get_errors(); $this->last_error_id = "db_query_error"; trigger_error($this->last_error, E_USER_ERROR); return false; } $id = null; if (@sqlsrv_fetch($this->statement)) { $id = sqlsrv_get_field($this->statement, 0); } return $id; } $this->statement = @sqlsrv_query($this->connection, "SELECT SCOPE_IDENTITY() AS IID"); if (!$this->statement) { $this->last_error = $this->sys_get_errors(); $this->last_error_id = "db_query_error"; trigger_error($this->last_error, E_USER_ERROR); return false; } if (!$this->fetch_row()) { $this->last_error_id = "db_query_error"; return false; } $id = $this->field_by_name("IID"); $this->free_result(); return $id; }
[ "public", "function", "insert_id", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connection", ")", "{", "$", "this", "->", "last_error_id", "=", "\"db_server_conn_error\"", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "last_query_is_insert", ")", "{", "if", "(", "!", "$", "this", "->", "statement", ")", "{", "return", "null", ";", "}", "if", "(", "!", "sqlsrv_next_result", "(", "$", "this", "->", "statement", ")", ")", "{", "$", "this", "->", "last_error", "=", "$", "this", "->", "sys_get_errors", "(", ")", ";", "$", "this", "->", "last_error_id", "=", "\"db_query_error\"", ";", "trigger_error", "(", "$", "this", "->", "last_error", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "$", "id", "=", "null", ";", "if", "(", "@", "sqlsrv_fetch", "(", "$", "this", "->", "statement", ")", ")", "{", "$", "id", "=", "sqlsrv_get_field", "(", "$", "this", "->", "statement", ",", "0", ")", ";", "}", "return", "$", "id", ";", "}", "$", "this", "->", "statement", "=", "@", "sqlsrv_query", "(", "$", "this", "->", "connection", ",", "\"SELECT SCOPE_IDENTITY() AS IID\"", ")", ";", "if", "(", "!", "$", "this", "->", "statement", ")", "{", "$", "this", "->", "last_error", "=", "$", "this", "->", "sys_get_errors", "(", ")", ";", "$", "this", "->", "last_error_id", "=", "\"db_query_error\"", ";", "trigger_error", "(", "$", "this", "->", "last_error", ",", "E_USER_ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "fetch_row", "(", ")", ")", "{", "$", "this", "->", "last_error_id", "=", "\"db_query_error\"", ";", "return", "false", ";", "}", "$", "id", "=", "$", "this", "->", "field_by_name", "(", "\"IID\"", ")", ";", "$", "this", "->", "free_result", "(", ")", ";", "return", "$", "id", ";", "}" ]
Returns the value of the auto increment field by the last insertion. @return int|false Returns the value of the auto increment field by the last insertion. In the case of any error returns false. @author Oleg Schildt
[ "Returns", "the", "value", "of", "the", "auto", "increment", "field", "by", "the", "last", "insertion", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L1162-L1210
9,760
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.field_by_name
public function field_by_name($name) { if (!$this->row) { return null; } if (!array_key_exists($name, $this->row)) { trigger_error("Field with the name '$name' does not exist in the result set!", E_USER_ERROR); return null; } return $this->row[$name]; }
php
public function field_by_name($name) { if (!$this->row) { return null; } if (!array_key_exists($name, $this->row)) { trigger_error("Field with the name '$name' does not exist in the result set!", E_USER_ERROR); return null; } return $this->row[$name]; }
[ "public", "function", "field_by_name", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "row", ")", "{", "return", "null", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "row", ")", ")", "{", "trigger_error", "(", "\"Field with the name '$name' does not exist in the result set!\"", ",", "E_USER_ERROR", ")", ";", "return", "null", ";", "}", "return", "$", "this", "->", "row", "[", "$", "name", "]", ";", "}" ]
Returns the value of a field specified by name. @param string $name The name of the field. @return mixed|null Returns the value of a field specified by name. In the case of any error returns null. @see field_by_num() @see field_name() @author Oleg Schildt
[ "Returns", "the", "value", "of", "a", "field", "specified", "by", "name", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L1227-L1239
9,761
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.field_by_num
public function field_by_num($num) { if (!$this->row) { return null; } if (!array_key_exists($num, $this->field_names)) { trigger_error("Field with the index $num does not exist in the result set!", E_USER_ERROR); return null; } return $this->row[$this->field_names[$num]]; }
php
public function field_by_num($num) { if (!$this->row) { return null; } if (!array_key_exists($num, $this->field_names)) { trigger_error("Field with the index $num does not exist in the result set!", E_USER_ERROR); return null; } return $this->row[$this->field_names[$num]]; }
[ "public", "function", "field_by_num", "(", "$", "num", ")", "{", "if", "(", "!", "$", "this", "->", "row", ")", "{", "return", "null", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "num", ",", "$", "this", "->", "field_names", ")", ")", "{", "trigger_error", "(", "\"Field with the index $num does not exist in the result set!\"", ",", "E_USER_ERROR", ")", ";", "return", "null", ";", "}", "return", "$", "this", "->", "row", "[", "$", "this", "->", "field_names", "[", "$", "num", "]", "]", ";", "}" ]
Returns the value of a field specified by number. @param int $num The number of the field. @return mixed|null Returns the value of a field specified by number. In the case of any error returns null. @see field_by_name() @see field_info_by_num() @see field_name() @author Oleg Schildt
[ "Returns", "the", "value", "of", "a", "field", "specified", "by", "number", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L1257-L1269
9,762
oschildt/SmartFactory
src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php
MSSQL_DBWorker.field_name
public function field_name($num) { $info = $this->field_info_by_num($num); if (!$info) { return null; } return \SmartFactory\checkempty($info["name"]); }
php
public function field_name($num) { $info = $this->field_info_by_num($num); if (!$info) { return null; } return \SmartFactory\checkempty($info["name"]); }
[ "public", "function", "field_name", "(", "$", "num", ")", "{", "$", "info", "=", "$", "this", "->", "field_info_by_num", "(", "$", "num", ")", ";", "if", "(", "!", "$", "info", ")", "{", "return", "null", ";", "}", "return", "\\", "SmartFactory", "\\", "checkempty", "(", "$", "info", "[", "\"name\"", "]", ")", ";", "}" ]
Returns the name of the field by number. @param int $num The number of the field. @return string|null Returns the name of the field by number. @see field_by_num() @see field_info_by_num() @author Oleg Schildt
[ "Returns", "the", "name", "of", "the", "field", "by", "number", "." ]
efd289961a720d5f3103a3c696e2beee16e9644d
https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MSSQL_DBWorker.php#L1388-L1396
9,763
ForceLabsDev/framework
src/Cache/Cache.php
Cache.resolvePath
private function resolvePath($key, $createDir = true): string { $hash = self::createKeyHash($key); $path = $this->cachePath.$this->cacheName.'/'; for ($i = 0; $i < self::CACHE_LEVEL; $i++) { $path .= substr($hash, 2 * ($i), 2).'/'; if ($createDir && !is_dir($path)) { mkdir($path); } } return $path.$hash; }
php
private function resolvePath($key, $createDir = true): string { $hash = self::createKeyHash($key); $path = $this->cachePath.$this->cacheName.'/'; for ($i = 0; $i < self::CACHE_LEVEL; $i++) { $path .= substr($hash, 2 * ($i), 2).'/'; if ($createDir && !is_dir($path)) { mkdir($path); } } return $path.$hash; }
[ "private", "function", "resolvePath", "(", "$", "key", ",", "$", "createDir", "=", "true", ")", ":", "string", "{", "$", "hash", "=", "self", "::", "createKeyHash", "(", "$", "key", ")", ";", "$", "path", "=", "$", "this", "->", "cachePath", ".", "$", "this", "->", "cacheName", ".", "'/'", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "self", "::", "CACHE_LEVEL", ";", "$", "i", "++", ")", "{", "$", "path", ".=", "substr", "(", "$", "hash", ",", "2", "*", "(", "$", "i", ")", ",", "2", ")", ".", "'/'", ";", "if", "(", "$", "createDir", "&&", "!", "is_dir", "(", "$", "path", ")", ")", "{", "mkdir", "(", "$", "path", ")", ";", "}", "}", "return", "$", "path", ".", "$", "hash", ";", "}" ]
Resolves the path for a cache key. @param string $key @param bool $createDir @return string
[ "Resolves", "the", "path", "for", "a", "cache", "key", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Cache/Cache.php#L84-L96
9,764
ForceLabsDev/framework
src/Cache/Cache.php
Cache.get
public function get($cacheKey) { // TODO: Refactor for strict types! $path = $this->resolvePath($cacheKey, false); if (file_exists($path)) { return file_get_contents($path); } return null; }
php
public function get($cacheKey) { // TODO: Refactor for strict types! $path = $this->resolvePath($cacheKey, false); if (file_exists($path)) { return file_get_contents($path); } return null; }
[ "public", "function", "get", "(", "$", "cacheKey", ")", "{", "// TODO: Refactor for strict types!", "$", "path", "=", "$", "this", "->", "resolvePath", "(", "$", "cacheKey", ",", "false", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "return", "file_get_contents", "(", "$", "path", ")", ";", "}", "return", "null", ";", "}" ]
Gets a value from the cache. @param string $cacheKey @return null|string
[ "Gets", "a", "value", "from", "the", "cache", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Cache/Cache.php#L104-L113
9,765
ForceLabsDev/framework
src/Cache/Cache.php
Cache.isCached
public function isCached($cacheKey) { // TODO: Refactor for strict types! $path = $this->resolvePath($cacheKey, false); if (file_exists($path)) { return $path; } else { return false; } }
php
public function isCached($cacheKey) { // TODO: Refactor for strict types! $path = $this->resolvePath($cacheKey, false); if (file_exists($path)) { return $path; } else { return false; } }
[ "public", "function", "isCached", "(", "$", "cacheKey", ")", "{", "// TODO: Refactor for strict types!", "$", "path", "=", "$", "this", "->", "resolvePath", "(", "$", "cacheKey", ",", "false", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "return", "$", "path", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
checks if a value is cached for a cache key. @param string $cacheKey @return bool|string
[ "checks", "if", "a", "value", "is", "cached", "for", "a", "cache", "key", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Cache/Cache.php#L132-L141
9,766
ForceLabsDev/framework
src/Cache/Cache.php
Cache.setObject
public function setObject(ICacheable $cacheable) { if (!$this->isDisabled()) { $path = $this->resolvePath($cacheable->getCacheKey(), true); file_put_contents($path, $cacheable->getCacheValue()); } }
php
public function setObject(ICacheable $cacheable) { if (!$this->isDisabled()) { $path = $this->resolvePath($cacheable->getCacheKey(), true); file_put_contents($path, $cacheable->getCacheValue()); } }
[ "public", "function", "setObject", "(", "ICacheable", "$", "cacheable", ")", "{", "if", "(", "!", "$", "this", "->", "isDisabled", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "resolvePath", "(", "$", "cacheable", "->", "getCacheKey", "(", ")", ",", "true", ")", ";", "file_put_contents", "(", "$", "path", ",", "$", "cacheable", "->", "getCacheValue", "(", ")", ")", ";", "}", "}" ]
puts a cacheable object into the cache. @param ICacheable $cacheable
[ "puts", "a", "cacheable", "object", "into", "the", "cache", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Cache/Cache.php#L148-L154
9,767
ForceLabsDev/framework
src/Cache/Cache.php
Cache.setString
public function setString($key, $value) { if (!$this->isDisabled()) { $path = $this->resolvePath($key, true); file_put_contents($path, $value); } }
php
public function setString($key, $value) { if (!$this->isDisabled()) { $path = $this->resolvePath($key, true); file_put_contents($path, $value); } }
[ "public", "function", "setString", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "isDisabled", "(", ")", ")", "{", "$", "path", "=", "$", "this", "->", "resolvePath", "(", "$", "key", ",", "true", ")", ";", "file_put_contents", "(", "$", "path", ",", "$", "value", ")", ";", "}", "}" ]
puts a string into the cache. @param string $key @param string $value
[ "puts", "a", "string", "into", "the", "cache", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Cache/Cache.php#L162-L168
9,768
shopery/view
src/Extension/ExtensibleViewFactory.php
ExtensibleViewFactory.createView
public function createView($object) { $view = $this->viewFactory->createView($object); if ($view instanceof View) { $this->extend($view, $object); } return $view; }
php
public function createView($object) { $view = $this->viewFactory->createView($object); if ($view instanceof View) { $this->extend($view, $object); } return $view; }
[ "public", "function", "createView", "(", "$", "object", ")", "{", "$", "view", "=", "$", "this", "->", "viewFactory", "->", "createView", "(", "$", "object", ")", ";", "if", "(", "$", "view", "instanceof", "View", ")", "{", "$", "this", "->", "extend", "(", "$", "view", ",", "$", "object", ")", ";", "}", "return", "$", "view", ";", "}" ]
Create a view for the object. @param $object @return View
[ "Create", "a", "view", "for", "the", "object", "." ]
cc38154a2b649ec99e7eb13f79b99cdf143bd4af
https://github.com/shopery/view/blob/cc38154a2b649ec99e7eb13f79b99cdf143bd4af/src/Extension/ExtensibleViewFactory.php#L55-L64
9,769
integratedfordevelopers/integrated-page-bundle
Services/RouteCache.php
RouteCache.clear
public function clear() { $finder = new Finder(); /** @var \Symfony\Component\Finder\SplFileInfo $file */ foreach ($finder->files()->in($this->cacheDir)->depth(0)->name(self::CACHE_PATH_REGEX) as $file) { @unlink($file->getRealPath()); } }
php
public function clear() { $finder = new Finder(); /** @var \Symfony\Component\Finder\SplFileInfo $file */ foreach ($finder->files()->in($this->cacheDir)->depth(0)->name(self::CACHE_PATH_REGEX) as $file) { @unlink($file->getRealPath()); } }
[ "public", "function", "clear", "(", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "/** @var \\Symfony\\Component\\Finder\\SplFileInfo $file */", "foreach", "(", "$", "finder", "->", "files", "(", ")", "->", "in", "(", "$", "this", "->", "cacheDir", ")", "->", "depth", "(", "0", ")", "->", "name", "(", "self", "::", "CACHE_PATH_REGEX", ")", "as", "$", "file", ")", "{", "@", "unlink", "(", "$", "file", "->", "getRealPath", "(", ")", ")", ";", "}", "}" ]
The routing cache needs to be cleared after a change. This is faster then clearing the cache with the responsible command.
[ "The", "routing", "cache", "needs", "to", "be", "cleared", "after", "a", "change", ".", "This", "is", "faster", "then", "clearing", "the", "cache", "with", "the", "responsible", "command", "." ]
a1a8640c2b5af2ef6e2f7806fcffa7009bb5294e
https://github.com/integratedfordevelopers/integrated-page-bundle/blob/a1a8640c2b5af2ef6e2f7806fcffa7009bb5294e/Services/RouteCache.php#L40-L48
9,770
PSESD/chms-common
lib/Http/Controllers/Base/ObjectController.php
ObjectController.loadAuthorizeObject
protected function loadAuthorizeObject($id, $action) { $model = $this->getRepository()->findById($id, [], app('context')); if (empty($model)) { throw new NotFoundHttpException("Object ($id) not found"); } if (!$model->isAllowed($action)) { throw new AccessDeniedHttpException("Forbidden"); } return $model; }
php
protected function loadAuthorizeObject($id, $action) { $model = $this->getRepository()->findById($id, [], app('context')); if (empty($model)) { throw new NotFoundHttpException("Object ($id) not found"); } if (!$model->isAllowed($action)) { throw new AccessDeniedHttpException("Forbidden"); } return $model; }
[ "protected", "function", "loadAuthorizeObject", "(", "$", "id", ",", "$", "action", ")", "{", "$", "model", "=", "$", "this", "->", "getRepository", "(", ")", "->", "findById", "(", "$", "id", ",", "[", "]", ",", "app", "(", "'context'", ")", ")", ";", "if", "(", "empty", "(", "$", "model", ")", ")", "{", "throw", "new", "NotFoundHttpException", "(", "\"Object ($id) not found\"", ")", ";", "}", "if", "(", "!", "$", "model", "->", "isAllowed", "(", "$", "action", ")", ")", "{", "throw", "new", "AccessDeniedHttpException", "(", "\"Forbidden\"", ")", ";", "}", "return", "$", "model", ";", "}" ]
Get the object and check to make sure the authorized user has access @param string|int $id @param string $action Action to be taken (read, update, delete) @throws NotFoundHttpException Model could not be found @throws AccessDeniedHttpException User is not allowed to perform the action with this model @return Model Loaded model
[ "Get", "the", "object", "and", "check", "to", "make", "sure", "the", "authorized", "user", "has", "access" ]
dba29f95de57cb6b1113c169ccb911152b18e288
https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Http/Controllers/Base/ObjectController.php#L29-L39
9,771
PSESD/chms-common
lib/Http/Controllers/Base/ObjectController.php
ObjectController.getFractalItem
protected function getFractalItem($model) { $transformer = $this->getTransformer(); $item = new FractalItem($model, $transformer, $this->getResourceKey()); $item->setMeta($transformer->getMeta($model)); return $item; }
php
protected function getFractalItem($model) { $transformer = $this->getTransformer(); $item = new FractalItem($model, $transformer, $this->getResourceKey()); $item->setMeta($transformer->getMeta($model)); return $item; }
[ "protected", "function", "getFractalItem", "(", "$", "model", ")", "{", "$", "transformer", "=", "$", "this", "->", "getTransformer", "(", ")", ";", "$", "item", "=", "new", "FractalItem", "(", "$", "model", ",", "$", "transformer", ",", "$", "this", "->", "getResourceKey", "(", ")", ")", ";", "$", "item", "->", "setMeta", "(", "$", "transformer", "->", "getMeta", "(", "$", "model", ")", ")", ";", "return", "$", "item", ";", "}" ]
Get the fractal item object @param Model $model @return FractalItem
[ "Get", "the", "fractal", "item", "object" ]
dba29f95de57cb6b1113c169ccb911152b18e288
https://github.com/PSESD/chms-common/blob/dba29f95de57cb6b1113c169ccb911152b18e288/lib/Http/Controllers/Base/ObjectController.php#L47-L53
9,772
xloit/xloit-bridge-zend-filter
src/DateToDateTime.php
DateToDateTime.setOptions
public function setOptions($options) { $format = null; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($options['date_format'])) { $format = $options['date_format']; unset($options['date_format']); } /** @noinspection UnSafeIsSetOverArrayInspection */ elseif (isset($options['format'])) { $format = $options['format']; unset($options['format']); } if ($format) { $options['format'] = $format; } parent::setOptions($options); return $this; }
php
public function setOptions($options) { $format = null; /** @noinspection UnSafeIsSetOverArrayInspection */ if (isset($options['date_format'])) { $format = $options['date_format']; unset($options['date_format']); } /** @noinspection UnSafeIsSetOverArrayInspection */ elseif (isset($options['format'])) { $format = $options['format']; unset($options['format']); } if ($format) { $options['format'] = $format; } parent::setOptions($options); return $this; }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "$", "format", "=", "null", ";", "/** @noinspection UnSafeIsSetOverArrayInspection */", "if", "(", "isset", "(", "$", "options", "[", "'date_format'", "]", ")", ")", "{", "$", "format", "=", "$", "options", "[", "'date_format'", "]", ";", "unset", "(", "$", "options", "[", "'date_format'", "]", ")", ";", "}", "/** @noinspection UnSafeIsSetOverArrayInspection */", "elseif", "(", "isset", "(", "$", "options", "[", "'format'", "]", ")", ")", "{", "$", "format", "=", "$", "options", "[", "'format'", "]", ";", "unset", "(", "$", "options", "[", "'format'", "]", ")", ";", "}", "if", "(", "$", "format", ")", "{", "$", "options", "[", "'format'", "]", "=", "$", "format", ";", "}", "parent", "::", "setOptions", "(", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Allow the format key to be format and date_format For consistency with the ZF2 Date Element. @param array|Traversable $options @throws \Zend\Filter\Exception\InvalidArgumentException @return $this
[ "Allow", "the", "format", "key", "to", "be", "format", "and", "date_format", "For", "consistency", "with", "the", "ZF2", "Date", "Element", "." ]
2bce36194cd8636484f1b06ad13f33d953f477e0
https://github.com/xloit/xloit-bridge-zend-filter/blob/2bce36194cd8636484f1b06ad13f33d953f477e0/src/DateToDateTime.php#L53-L75
9,773
marando/phpSOFA
src/Marando/IAU/iauAnp.php
iauAnp.Anp
public static function Anp($a) { $w; $w = fmod($a, D2PI); if ($w < 0) $w += D2PI; return $w; }
php
public static function Anp($a) { $w; $w = fmod($a, D2PI); if ($w < 0) $w += D2PI; return $w; }
[ "public", "static", "function", "Anp", "(", "$", "a", ")", "{", "$", "w", ";", "$", "w", "=", "fmod", "(", "$", "a", ",", "D2PI", ")", ";", "if", "(", "$", "w", "<", "0", ")", "$", "w", "+=", "D2PI", ";", "return", "$", "w", ";", "}" ]
- - - - - - - i a u A n p - - - - - - - Normalize angle into the range 0 <= a < 2pi. This function is part of the International Astronomical Union's SOFA (Standards Of Fundamental Astronomy) software collection. Status: vector/matrix support function. Given: a double angle (radians) Returned (function value): double angle in range 0-2pi This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "A", "n", "p", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauAnp.php#L31-L39
9,774
OWeb/OWeb-Framework
OWeb/manage/Events.php
Events.registerEvent
public function registerEvent($event, $object, $fn){ $this->actions[$event][] = new \OWeb\manage\events\Event($object, $fn); }
php
public function registerEvent($event, $object, $fn){ $this->actions[$event][] = new \OWeb\manage\events\Event($object, $fn); }
[ "public", "function", "registerEvent", "(", "$", "event", ",", "$", "object", ",", "$", "fn", ")", "{", "$", "this", "->", "actions", "[", "$", "event", "]", "[", "]", "=", "new", "\\", "OWeb", "\\", "manage", "\\", "events", "\\", "Event", "(", "$", "object", ",", "$", "fn", ")", ";", "}" ]
Register a function to be called in a certain event. @param type $event The name of the Event @param type $object The object of which the function will be called @param type $fn The name of the function to call
[ "Register", "a", "function", "to", "be", "called", "in", "a", "certain", "event", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Events.php#L41-L43
9,775
OWeb/OWeb-Framework
OWeb/manage/Events.php
Events.sendEvent
public function sendEvent($event, $params = array()){ if(isset ($this->actions[$event])){ foreach ($this->actions[$event] as $eventO){ $eventO->doEvent($params); } } }
php
public function sendEvent($event, $params = array()){ if(isset ($this->actions[$event])){ foreach ($this->actions[$event] as $eventO){ $eventO->doEvent($params); } } }
[ "public", "function", "sendEvent", "(", "$", "event", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "actions", "[", "$", "event", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "actions", "[", "$", "event", "]", "as", "$", "eventO", ")", "{", "$", "eventO", "->", "doEvent", "(", "$", "params", ")", ";", "}", "}", "}" ]
Will send and event and call the functions that has registered to that Event. @param String $event The name of the Event @param Array(mixed) $params The parameters array you want to send with the event.
[ "Will", "send", "and", "event", "and", "call", "the", "functions", "that", "has", "registered", "to", "that", "Event", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Events.php#L51-L58
9,776
atelierspierrot/webfilesystem
src/WebFilesystem/WebFilesystem.php
WebFilesystem.getTransformedFilesize
public static function getTransformedFilesize($size = 0, $round = 3, $dec_delimiter = ',') { $count=0; while ($size >= 1024 && $count < (count(self::$FILESIZE_ORDERED_UNITS)-1)) { $count++; $size /= 1024; } if ($round>=0) { $arr = pow(10, $round); $number = round($size * $arr) / $arr; } else { $number = $size; } return str_replace('.', $dec_delimiter, $number).' '.self::$FILESIZE_ORDERED_UNITS[$count]; }
php
public static function getTransformedFilesize($size = 0, $round = 3, $dec_delimiter = ',') { $count=0; while ($size >= 1024 && $count < (count(self::$FILESIZE_ORDERED_UNITS)-1)) { $count++; $size /= 1024; } if ($round>=0) { $arr = pow(10, $round); $number = round($size * $arr) / $arr; } else { $number = $size; } return str_replace('.', $dec_delimiter, $number).' '.self::$FILESIZE_ORDERED_UNITS[$count]; }
[ "public", "static", "function", "getTransformedFilesize", "(", "$", "size", "=", "0", ",", "$", "round", "=", "3", ",", "$", "dec_delimiter", "=", "','", ")", "{", "$", "count", "=", "0", ";", "while", "(", "$", "size", ">=", "1024", "&&", "$", "count", "<", "(", "count", "(", "self", "::", "$", "FILESIZE_ORDERED_UNITS", ")", "-", "1", ")", ")", "{", "$", "count", "++", ";", "$", "size", "/=", "1024", ";", "}", "if", "(", "$", "round", ">=", "0", ")", "{", "$", "arr", "=", "pow", "(", "10", ",", "$", "round", ")", ";", "$", "number", "=", "round", "(", "$", "size", "*", "$", "arr", ")", "/", "$", "arr", ";", "}", "else", "{", "$", "number", "=", "$", "size", ";", "}", "return", "str_replace", "(", "'.'", ",", "$", "dec_delimiter", ",", "$", "number", ")", ".", "' '", ".", "self", "::", "$", "FILESIZE_ORDERED_UNITS", "[", "$", "count", "]", ";", "}" ]
Returns a formatted file size in bytes or derived unit This will return the size received transforming it to be readable, with the appropriate unit chosen in `WebFilesystem::$FILESIZE_ORDERED_UNITS`. @param float $size Refer to the size (in standard format given by the `stat()` function) @param int $round The number of decimal places (default is 3) @param string $dec_delimiter The decimal separator (default is a comma)
[ "Returns", "a", "formatted", "file", "size", "in", "bytes", "or", "derived", "unit" ]
3f7ebb678228a708896ce0dad9a688e336e79080
https://github.com/atelierspierrot/webfilesystem/blob/3f7ebb678228a708896ce0dad9a688e336e79080/src/WebFilesystem/WebFilesystem.php#L122-L136
9,777
atelierspierrot/webfilesystem
src/WebFilesystem/WebFilesystem.php
WebFilesystem.isCommonImage
public static function isCommonImage($file_name) { if (!self::isCommonFile($file_name) || $file_name{0}==='.' || @is_dir($file_name)) { return false; } $ext = self::getExtensionName($file_name); return ($ext ? in_array(strtolower($ext), self::$COMMON_IMG_EXTS) : false); }
php
public static function isCommonImage($file_name) { if (!self::isCommonFile($file_name) || $file_name{0}==='.' || @is_dir($file_name)) { return false; } $ext = self::getExtensionName($file_name); return ($ext ? in_array(strtolower($ext), self::$COMMON_IMG_EXTS) : false); }
[ "public", "static", "function", "isCommonImage", "(", "$", "file_name", ")", "{", "if", "(", "!", "self", "::", "isCommonFile", "(", "$", "file_name", ")", "||", "$", "file_name", "{", "0", "}", "===", "'.'", "||", "@", "is_dir", "(", "$", "file_name", ")", ")", "{", "return", "false", ";", "}", "$", "ext", "=", "self", "::", "getExtensionName", "(", "$", "file_name", ")", ";", "return", "(", "$", "ext", "?", "in_array", "(", "strtolower", "(", "$", "ext", ")", ",", "self", "::", "$", "COMMON_IMG_EXTS", ")", ":", "false", ")", ";", "}" ]
Tests if a file name seems to have a common image's extension Directories (if known) or file names beginning with a dot are skipped. @param string $file_name The file name to test @return bool `true` if the file_name seems to be an image, `false` otherwise
[ "Tests", "if", "a", "file", "name", "seems", "to", "have", "a", "common", "image", "s", "extension" ]
3f7ebb678228a708896ce0dad9a688e336e79080
https://github.com/atelierspierrot/webfilesystem/blob/3f7ebb678228a708896ce0dad9a688e336e79080/src/WebFilesystem/WebFilesystem.php#L200-L207
9,778
atelierspierrot/webfilesystem
src/WebFilesystem/WebFilesystem.php
WebFilesystem.isCommonVideo
public static function isCommonVideo($file_name) { if (!self::isCommonFile($file_name) || $file_name{0}==='.' || @is_dir($file_name)) { return false; } $ext = self::getExtensionName($file_name); return ($ext ? in_array(strtolower($ext), self::$COMMON_VIDEOS_EXTS) : false); }
php
public static function isCommonVideo($file_name) { if (!self::isCommonFile($file_name) || $file_name{0}==='.' || @is_dir($file_name)) { return false; } $ext = self::getExtensionName($file_name); return ($ext ? in_array(strtolower($ext), self::$COMMON_VIDEOS_EXTS) : false); }
[ "public", "static", "function", "isCommonVideo", "(", "$", "file_name", ")", "{", "if", "(", "!", "self", "::", "isCommonFile", "(", "$", "file_name", ")", "||", "$", "file_name", "{", "0", "}", "===", "'.'", "||", "@", "is_dir", "(", "$", "file_name", ")", ")", "{", "return", "false", ";", "}", "$", "ext", "=", "self", "::", "getExtensionName", "(", "$", "file_name", ")", ";", "return", "(", "$", "ext", "?", "in_array", "(", "strtolower", "(", "$", "ext", ")", ",", "self", "::", "$", "COMMON_VIDEOS_EXTS", ")", ":", "false", ")", ";", "}" ]
Tests if a file name seems to have a common video's extension Directories (if known) or file names beginning with a dot are skipped. @param string $file_name The file name to test @return bool `true` if the file_name seems to be a video, `false` otherwise
[ "Tests", "if", "a", "file", "name", "seems", "to", "have", "a", "common", "video", "s", "extension" ]
3f7ebb678228a708896ce0dad9a688e336e79080
https://github.com/atelierspierrot/webfilesystem/blob/3f7ebb678228a708896ce0dad9a688e336e79080/src/WebFilesystem/WebFilesystem.php#L217-L224
9,779
bytic/helpers
src/Strings.php
Nip_Helper_Strings.limitWords
public function limitWords($string, $limit = false, $end = '...') { $words = explode(" ", $string); if (count($words) <= $limit) { return $string; } $return = []; for ($wordCount = 0; $wordCount < $limit; $wordCount++) { $return[] = $words[$wordCount]; } $return[] = $end; return implode(" ", $return); }
php
public function limitWords($string, $limit = false, $end = '...') { $words = explode(" ", $string); if (count($words) <= $limit) { return $string; } $return = []; for ($wordCount = 0; $wordCount < $limit; $wordCount++) { $return[] = $words[$wordCount]; } $return[] = $end; return implode(" ", $return); }
[ "public", "function", "limitWords", "(", "$", "string", ",", "$", "limit", "=", "false", ",", "$", "end", "=", "'...'", ")", "{", "$", "words", "=", "explode", "(", "\" \"", ",", "$", "string", ")", ";", "if", "(", "count", "(", "$", "words", ")", "<=", "$", "limit", ")", "{", "return", "$", "string", ";", "}", "$", "return", "=", "[", "]", ";", "for", "(", "$", "wordCount", "=", "0", ";", "$", "wordCount", "<", "$", "limit", ";", "$", "wordCount", "++", ")", "{", "$", "return", "[", "]", "=", "$", "words", "[", "$", "wordCount", "]", ";", "}", "$", "return", "[", "]", "=", "$", "end", ";", "return", "implode", "(", "\" \"", ",", "$", "return", ")", ";", "}" ]
Limits a string to a certain number of words @param string $string @param int $limit @param string $end @return string
[ "Limits", "a", "string", "to", "a", "certain", "number", "of", "words" ]
6a4f0388ba8653d65058ce63cf7627e38b9df041
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/Strings.php#L17-L33
9,780
bytic/helpers
src/Strings.php
Nip_Helper_Strings.injectParams
public function injectParams($string, $params = array()) { $links = preg_split('#(<a\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $old = $links; foreach ($links as &$match) { if (preg_match('/<a\b/', $match) && !preg_match('/(?:#|mailto)/', $match)) { preg_match('/^([^"]+")([^"]+)/', $match, $matches); if ($matches) { $link = html_entity_decode($matches[2]); if (strpos($link, "?") === false) { $link .= "?"; } else { $link .= "&"; } $link .= http_build_query($params); $match = str_replace($matches[2], $link, $match); } } } $string = str_replace($old, $links, $string); return $string; }
php
public function injectParams($string, $params = array()) { $links = preg_split('#(<a\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $old = $links; foreach ($links as &$match) { if (preg_match('/<a\b/', $match) && !preg_match('/(?:#|mailto)/', $match)) { preg_match('/^([^"]+")([^"]+)/', $match, $matches); if ($matches) { $link = html_entity_decode($matches[2]); if (strpos($link, "?") === false) { $link .= "?"; } else { $link .= "&"; } $link .= http_build_query($params); $match = str_replace($matches[2], $link, $match); } } } $string = str_replace($old, $links, $string); return $string; }
[ "public", "function", "injectParams", "(", "$", "string", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "links", "=", "preg_split", "(", "'#(<a\\b[^>]+>)#'", ",", "$", "string", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "old", "=", "$", "links", ";", "foreach", "(", "$", "links", "as", "&", "$", "match", ")", "{", "if", "(", "preg_match", "(", "'/<a\\b/'", ",", "$", "match", ")", "&&", "!", "preg_match", "(", "'/(?:#|mailto)/'", ",", "$", "match", ")", ")", "{", "preg_match", "(", "'/^([^\"]+\")([^\"]+)/'", ",", "$", "match", ",", "$", "matches", ")", ";", "if", "(", "$", "matches", ")", "{", "$", "link", "=", "html_entity_decode", "(", "$", "matches", "[", "2", "]", ")", ";", "if", "(", "strpos", "(", "$", "link", ",", "\"?\"", ")", "===", "false", ")", "{", "$", "link", ".=", "\"?\"", ";", "}", "else", "{", "$", "link", ".=", "\"&\"", ";", "}", "$", "link", ".=", "http_build_query", "(", "$", "params", ")", ";", "$", "match", "=", "str_replace", "(", "$", "matches", "[", "2", "]", ",", "$", "link", ",", "$", "match", ")", ";", "}", "}", "}", "$", "string", "=", "str_replace", "(", "$", "old", ",", "$", "links", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
Injects GET params in links @param string $string @param array $params @return string
[ "Injects", "GET", "params", "in", "links" ]
6a4f0388ba8653d65058ce63cf7627e38b9df041
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/Strings.php#L43-L68
9,781
bytic/helpers
src/Strings.php
Nip_Helper_Strings.relativeToAbsolute
public function relativeToAbsolute($string, $base) { $matches = preg_split('#(<(a|img)\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $old = $matches; foreach ($matches as &$match) { if (preg_match('/<(a|img)\b/', $match) && !preg_match('/(?:http|#|mailto)/', $match)) { $match = preg_replace('/^([^"]+")([^"]+)/', '$1' . $base . '$2', $match); } } $string = str_replace($old, $matches, $string); return $string; }
php
public function relativeToAbsolute($string, $base) { $matches = preg_split('#(<(a|img)\b[^>]+>)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE); $old = $matches; foreach ($matches as &$match) { if (preg_match('/<(a|img)\b/', $match) && !preg_match('/(?:http|#|mailto)/', $match)) { $match = preg_replace('/^([^"]+")([^"]+)/', '$1' . $base . '$2', $match); } } $string = str_replace($old, $matches, $string); return $string; }
[ "public", "function", "relativeToAbsolute", "(", "$", "string", ",", "$", "base", ")", "{", "$", "matches", "=", "preg_split", "(", "'#(<(a|img)\\b[^>]+>)#'", ",", "$", "string", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "old", "=", "$", "matches", ";", "foreach", "(", "$", "matches", "as", "&", "$", "match", ")", "{", "if", "(", "preg_match", "(", "'/<(a|img)\\b/'", ",", "$", "match", ")", "&&", "!", "preg_match", "(", "'/(?:http|#|mailto)/'", ",", "$", "match", ")", ")", "{", "$", "match", "=", "preg_replace", "(", "'/^([^\"]+\")([^\"]+)/'", ",", "'$1'", ".", "$", "base", ".", "'$2'", ",", "$", "match", ")", ";", "}", "}", "$", "string", "=", "str_replace", "(", "$", "old", ",", "$", "matches", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
Converts all relative hrefs and image srcs to absolute @param string $string @param string $base @return string
[ "Converts", "all", "relative", "hrefs", "and", "image", "srcs", "to", "absolute" ]
6a4f0388ba8653d65058ce63cf7627e38b9df041
https://github.com/bytic/helpers/blob/6a4f0388ba8653d65058ce63cf7627e38b9df041/src/Strings.php#L78-L91
9,782
IVIR3zaM/ObjectArrayTools
src/Traits/BaseTrait.php
BaseTrait.internalSanitizeHooks
private function internalSanitizeHooks($key, $value, $type = 'input') { $hook = trim(strtolower($type)) == 'input' ? 'sanitizeInputHook' : 'sanitizeOutputHook'; return method_exists($this, $hook) ? $this->$hook($key, $value) : $value; }
php
private function internalSanitizeHooks($key, $value, $type = 'input') { $hook = trim(strtolower($type)) == 'input' ? 'sanitizeInputHook' : 'sanitizeOutputHook'; return method_exists($this, $hook) ? $this->$hook($key, $value) : $value; }
[ "private", "function", "internalSanitizeHooks", "(", "$", "key", ",", "$", "value", ",", "$", "type", "=", "'input'", ")", "{", "$", "hook", "=", "trim", "(", "strtolower", "(", "$", "type", ")", ")", "==", "'input'", "?", "'sanitizeInputHook'", ":", "'sanitizeOutputHook'", ";", "return", "method_exists", "(", "$", "this", ",", "$", "hook", ")", "?", "$", "this", "->", "$", "hook", "(", "$", "key", ",", "$", "value", ")", ":", "$", "value", ";", "}" ]
this function have the base logic of sanitizing an array element base on both of key and value and then return the sanitized value @param mixed $key the key of the element @param mixed $value the value of the element @param string $type which input or output are we sanitizing @return mixed sanitized or untouched $value of the element
[ "this", "function", "have", "the", "base", "logic", "of", "sanitizing", "an", "array", "element", "base", "on", "both", "of", "key", "and", "value", "and", "then", "return", "the", "sanitized", "value" ]
31c12fc6f8a40a36873c074409ae4299b35f9177
https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/BaseTrait.php#L47-L52
9,783
IVIR3zaM/ObjectArrayTools
src/Traits/BaseTrait.php
BaseTrait.internalFilterHooks
private function internalFilterHooks($key, $value, $type = 'input') { $hook = ''; switch (trim(strtolower($type))) { case 'output': $hook = 'filterOutputHook'; break; case 'remove': $hook = 'filterRemoveHook'; break; case 'input': $hook = 'filterInputHook'; break; } if ($hook && method_exists($this, $hook)) { $result = $this->$hook($key, $value); if ($result !== true && $result !== null) { return false; } } return true; }
php
private function internalFilterHooks($key, $value, $type = 'input') { $hook = ''; switch (trim(strtolower($type))) { case 'output': $hook = 'filterOutputHook'; break; case 'remove': $hook = 'filterRemoveHook'; break; case 'input': $hook = 'filterInputHook'; break; } if ($hook && method_exists($this, $hook)) { $result = $this->$hook($key, $value); if ($result !== true && $result !== null) { return false; } } return true; }
[ "private", "function", "internalFilterHooks", "(", "$", "key", ",", "$", "value", ",", "$", "type", "=", "'input'", ")", "{", "$", "hook", "=", "''", ";", "switch", "(", "trim", "(", "strtolower", "(", "$", "type", ")", ")", ")", "{", "case", "'output'", ":", "$", "hook", "=", "'filterOutputHook'", ";", "break", ";", "case", "'remove'", ":", "$", "hook", "=", "'filterRemoveHook'", ";", "break", ";", "case", "'input'", ":", "$", "hook", "=", "'filterInputHook'", ";", "break", ";", "}", "if", "(", "$", "hook", "&&", "method_exists", "(", "$", "this", ",", "$", "hook", ")", ")", "{", "$", "result", "=", "$", "this", "->", "$", "hook", "(", "$", "key", ",", "$", "value", ")", ";", "if", "(", "$", "result", "!==", "true", "&&", "$", "result", "!==", "null", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
this function have th base logic of filtering input and output base on both of key and value @param mixed $key the key of the element @param mixed $value the value of the element @param string $type which input or output are we sanitizing @return bool is current element valid for input or output
[ "this", "function", "have", "th", "base", "logic", "of", "filtering", "input", "and", "output", "base", "on", "both", "of", "key", "and", "value" ]
31c12fc6f8a40a36873c074409ae4299b35f9177
https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/BaseTrait.php#L62-L83
9,784
IVIR3zaM/ObjectArrayTools
src/Traits/BaseTrait.php
BaseTrait.internalChangingHooks
private function internalChangingHooks($key, $value, $oldValue = null, $type = 'insert') { switch (trim(strtolower($type))) { case 'update': $hook = 'updateHook'; if (method_exists($this, $hook)) { $this->$hook($key, $value, $oldValue); } break; case 'remove': $hook = 'removeHook'; if (method_exists($this, $hook)) { $this->$hook($key, $oldValue); } break; case 'insert': $hook = 'insertHook'; if (method_exists($this, $hook)) { $this->$hook($key, $value); } break; } }
php
private function internalChangingHooks($key, $value, $oldValue = null, $type = 'insert') { switch (trim(strtolower($type))) { case 'update': $hook = 'updateHook'; if (method_exists($this, $hook)) { $this->$hook($key, $value, $oldValue); } break; case 'remove': $hook = 'removeHook'; if (method_exists($this, $hook)) { $this->$hook($key, $oldValue); } break; case 'insert': $hook = 'insertHook'; if (method_exists($this, $hook)) { $this->$hook($key, $value); } break; } }
[ "private", "function", "internalChangingHooks", "(", "$", "key", ",", "$", "value", ",", "$", "oldValue", "=", "null", ",", "$", "type", "=", "'insert'", ")", "{", "switch", "(", "trim", "(", "strtolower", "(", "$", "type", ")", ")", ")", "{", "case", "'update'", ":", "$", "hook", "=", "'updateHook'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "hook", ")", ")", "{", "$", "this", "->", "$", "hook", "(", "$", "key", ",", "$", "value", ",", "$", "oldValue", ")", ";", "}", "break", ";", "case", "'remove'", ":", "$", "hook", "=", "'removeHook'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "hook", ")", ")", "{", "$", "this", "->", "$", "hook", "(", "$", "key", ",", "$", "oldValue", ")", ";", "}", "break", ";", "case", "'insert'", ":", "$", "hook", "=", "'insertHook'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "hook", ")", ")", "{", "$", "this", "->", "$", "hook", "(", "$", "key", ",", "$", "value", ")", ";", "}", "break", ";", "}", "}" ]
check for existing of changing element hook method in current object and send the key, the value and the old value of to it. tis helps you to have an active array @param mixed $key the key of the element @param mixed $value the value of the element @param mixed $oldValue the old value of the element @param string $type the type of changing (insert|update|remove) @return void
[ "check", "for", "existing", "of", "changing", "element", "hook", "method", "in", "current", "object", "and", "send", "the", "key", "the", "value", "and", "the", "old", "value", "of", "to", "it", ".", "tis", "helps", "you", "to", "have", "an", "active", "array" ]
31c12fc6f8a40a36873c074409ae4299b35f9177
https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/BaseTrait.php#L95-L117
9,785
bugotech/support
src/Arr.php
Arr.phpFile_item
protected static function phpFile_item(&$code, $array, $ident = 4) { $sident = str_pad('', $ident, ' '); foreach ($array as $key => $value) { $code .= $sident; $code .= '\'' . $key . '\' => '; if (is_array($value)) { $code .= '[' . "\r\n"; self::phpFile_item($code, $value, $ident + 4); $code .= $sident; $code .= '],' . "\r\n"; } else { $value = str_replace("\r\n", "\n\r" . $sident, $value); $value = str_replace("\n\r", "\r\n", $value); $code .= '"' . $value . '",' . "\r\n"; } } }
php
protected static function phpFile_item(&$code, $array, $ident = 4) { $sident = str_pad('', $ident, ' '); foreach ($array as $key => $value) { $code .= $sident; $code .= '\'' . $key . '\' => '; if (is_array($value)) { $code .= '[' . "\r\n"; self::phpFile_item($code, $value, $ident + 4); $code .= $sident; $code .= '],' . "\r\n"; } else { $value = str_replace("\r\n", "\n\r" . $sident, $value); $value = str_replace("\n\r", "\r\n", $value); $code .= '"' . $value . '",' . "\r\n"; } } }
[ "protected", "static", "function", "phpFile_item", "(", "&", "$", "code", ",", "$", "array", ",", "$", "ident", "=", "4", ")", "{", "$", "sident", "=", "str_pad", "(", "''", ",", "$", "ident", ",", "' '", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "code", ".=", "$", "sident", ";", "$", "code", ".=", "'\\''", ".", "$", "key", ".", "'\\' => '", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "code", ".=", "'['", ".", "\"\\r\\n\"", ";", "self", "::", "phpFile_item", "(", "$", "code", ",", "$", "value", ",", "$", "ident", "+", "4", ")", ";", "$", "code", ".=", "$", "sident", ";", "$", "code", ".=", "'],'", ".", "\"\\r\\n\"", ";", "}", "else", "{", "$", "value", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\\r\"", ".", "$", "sident", ",", "$", "value", ")", ";", "$", "value", "=", "str_replace", "(", "\"\\n\\r\"", ",", "\"\\r\\n\"", ",", "$", "value", ")", ";", "$", "code", ".=", "'\"'", ".", "$", "value", ".", "'\",'", ".", "\"\\r\\n\"", ";", "}", "}", "}" ]
Auxilia na geracao do arquivo PHP de um array. @param $code @param $array @param int $ident
[ "Auxilia", "na", "geracao", "do", "arquivo", "PHP", "de", "um", "array", "." ]
8938b8c83bdc414ea46bd6e41d1911282782be6c
https://github.com/bugotech/support/blob/8938b8c83bdc414ea46bd6e41d1911282782be6c/src/Arr.php#L27-L45
9,786
jerel/quick-cache
core/Quick/Cache/Config.php
Config.load
public function load($file) { $file_name = $this->_config_path.$file.'.php'; // load the file, but only once if (is_file($file_name) and ! array_key_exists($file, $this->_loaded)) { // the config file values are secondary to the config values that have already been set $this->_config = array_merge(require $file_name, $this->_config); $this->_loaded[$file] = true; return true; } elseif (! is_file($file_name)) { throw new \QuickCacheException('The config file "'.$file.'" does not exist'); } }
php
public function load($file) { $file_name = $this->_config_path.$file.'.php'; // load the file, but only once if (is_file($file_name) and ! array_key_exists($file, $this->_loaded)) { // the config file values are secondary to the config values that have already been set $this->_config = array_merge(require $file_name, $this->_config); $this->_loaded[$file] = true; return true; } elseif (! is_file($file_name)) { throw new \QuickCacheException('The config file "'.$file.'" does not exist'); } }
[ "public", "function", "load", "(", "$", "file", ")", "{", "$", "file_name", "=", "$", "this", "->", "_config_path", ".", "$", "file", ".", "'.php'", ";", "// load the file, but only once", "if", "(", "is_file", "(", "$", "file_name", ")", "and", "!", "array_key_exists", "(", "$", "file", ",", "$", "this", "->", "_loaded", ")", ")", "{", "// the config file values are secondary to the config values that have already been set", "$", "this", "->", "_config", "=", "array_merge", "(", "require", "$", "file_name", ",", "$", "this", "->", "_config", ")", ";", "$", "this", "->", "_loaded", "[", "$", "file", "]", "=", "true", ";", "return", "true", ";", "}", "elseif", "(", "!", "is_file", "(", "$", "file_name", ")", ")", "{", "throw", "new", "\\", "QuickCacheException", "(", "'The config file \"'", ".", "$", "file", ".", "'\" does not exist'", ")", ";", "}", "}" ]
Load a config file @param string $file The config file without the extension @return
[ "Load", "a", "config", "file" ]
e5963482c5f90fe866d4e87545cb7eab5cc65c43
https://github.com/jerel/quick-cache/blob/e5963482c5f90fe866d4e87545cb7eab5cc65c43/core/Quick/Cache/Config.php#L37-L52
9,787
jerel/quick-cache
core/Quick/Cache/Config.php
Config.get
public function get($key = false) { return isset($this->_config[$key]) ? $this->_config[$key] : null; }
php
public function get($key = false) { return isset($this->_config[$key]) ? $this->_config[$key] : null; }
[ "public", "function", "get", "(", "$", "key", "=", "false", ")", "{", "return", "isset", "(", "$", "this", "->", "_config", "[", "$", "key", "]", ")", "?", "$", "this", "->", "_config", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get a config value by key @param string $key Array element @return
[ "Get", "a", "config", "value", "by", "key" ]
e5963482c5f90fe866d4e87545cb7eab5cc65c43
https://github.com/jerel/quick-cache/blob/e5963482c5f90fe866d4e87545cb7eab5cc65c43/core/Quick/Cache/Config.php#L72-L75
9,788
coolms/authentication
src/Adapter/AdapterChain.php
AdapterChain.authenticate
public function authenticate() { $e = $this->getEvent(); $result = new Result( $e->getCode(), $e->getIdentity(), $e->getMessages() ); $this->resetAdapters(); return $result; }
php
public function authenticate() { $e = $this->getEvent(); $result = new Result( $e->getCode(), $e->getIdentity(), $e->getMessages() ); $this->resetAdapters(); return $result; }
[ "public", "function", "authenticate", "(", ")", "{", "$", "e", "=", "$", "this", "->", "getEvent", "(", ")", ";", "$", "result", "=", "new", "Result", "(", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getIdentity", "(", ")", ",", "$", "e", "->", "getMessages", "(", ")", ")", ";", "$", "this", "->", "resetAdapters", "(", ")", ";", "return", "$", "result", ";", "}" ]
Returns the authentication result @return Result
[ "Returns", "the", "authentication", "result" ]
4563cc4cc3a4d777db45977bd179cc5bd3f57cd8
https://github.com/coolms/authentication/blob/4563cc4cc3a4d777db45977bd179cc5bd3f57cd8/src/Adapter/AdapterChain.php#L36-L49
9,789
chriscollins/general-utils
lib/ChrisCollins/GeneralUtils/Json/JsonCodec.php
JsonCodec.encode
public function encode($value, $optionsMask = 0) { $encoded = json_encode($value, $optionsMask); $lastError = json_last_error(); if ($lastError !== JSON_ERROR_NONE) { throw new JsonException($this->translateErrorMessage($lastError)); } return $encoded; }
php
public function encode($value, $optionsMask = 0) { $encoded = json_encode($value, $optionsMask); $lastError = json_last_error(); if ($lastError !== JSON_ERROR_NONE) { throw new JsonException($this->translateErrorMessage($lastError)); } return $encoded; }
[ "public", "function", "encode", "(", "$", "value", ",", "$", "optionsMask", "=", "0", ")", "{", "$", "encoded", "=", "json_encode", "(", "$", "value", ",", "$", "optionsMask", ")", ";", "$", "lastError", "=", "json_last_error", "(", ")", ";", "if", "(", "$", "lastError", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "JsonException", "(", "$", "this", "->", "translateErrorMessage", "(", "$", "lastError", ")", ")", ";", "}", "return", "$", "encoded", ";", "}" ]
Encode a PHP value as a JSON string. @param mixed $value The value to encode. @param int $optionsMask A bitmask of options (see PHP's json_encode function for acceptable values). @return string A JSON string. @todo Support the depth parameter when PHP 5.5 is more prevalent.
[ "Encode", "a", "PHP", "value", "as", "a", "JSON", "string", "." ]
3fef519f3dd97bf15aa16ff528152ae663e027ac
https://github.com/chriscollins/general-utils/blob/3fef519f3dd97bf15aa16ff528152ae663e027ac/lib/ChrisCollins/GeneralUtils/Json/JsonCodec.php#L61-L72
9,790
webriq/core
module/Paragraph/src/Grid/Paragraph/Model/Dashboard/Mapper.php
Mapper.setStructurePrototype
public function setStructurePrototype( $structurePrototype ) { if ( $structurePrototype instanceof MapperAwareInterface ) { $structurePrototype->setMapper( $this ); } $this->structurePrototype = $structurePrototype; return $this; }
php
public function setStructurePrototype( $structurePrototype ) { if ( $structurePrototype instanceof MapperAwareInterface ) { $structurePrototype->setMapper( $this ); } $this->structurePrototype = $structurePrototype; return $this; }
[ "public", "function", "setStructurePrototype", "(", "$", "structurePrototype", ")", "{", "if", "(", "$", "structurePrototype", "instanceof", "MapperAwareInterface", ")", "{", "$", "structurePrototype", "->", "setMapper", "(", "$", "this", ")", ";", "}", "$", "this", "->", "structurePrototype", "=", "$", "structurePrototype", ";", "return", "$", "this", ";", "}" ]
Set structure prototype @param \Zork\Model\Structure\StructureAbstract $structurePrototype @return \Zork\Model\Mapper\DbAware\ReadOnlyMapperAbstract
[ "Set", "structure", "prototype" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Model/Dashboard/Mapper.php#L149-L158
9,791
tekkla/core-framework
Core/Framework/Amvc/App/AppHandler.php
AppHandler.autodiscover
public function autodiscover($path) { if (!is_array($path)) { $path = (array) $path; } foreach ($path as $apps_dir) { if (is_dir($apps_dir)) { if (($dh = opendir($apps_dir)) !== false) { while (($name = readdir($dh)) !== false) { if ($name{0} == '.' || $name == 'Core' || is_file($apps_dir . '/' . $name)) { continue; } $app = $this->getAppInstance($name); } closedir($dh); } } } }
php
public function autodiscover($path) { if (!is_array($path)) { $path = (array) $path; } foreach ($path as $apps_dir) { if (is_dir($apps_dir)) { if (($dh = opendir($apps_dir)) !== false) { while (($name = readdir($dh)) !== false) { if ($name{0} == '.' || $name == 'Core' || is_file($apps_dir . '/' . $name)) { continue; } $app = $this->getAppInstance($name); } closedir($dh); } } } }
[ "public", "function", "autodiscover", "(", "$", "path", ")", "{", "if", "(", "!", "is_array", "(", "$", "path", ")", ")", "{", "$", "path", "=", "(", "array", ")", "$", "path", ";", "}", "foreach", "(", "$", "path", "as", "$", "apps_dir", ")", "{", "if", "(", "is_dir", "(", "$", "apps_dir", ")", ")", "{", "if", "(", "(", "$", "dh", "=", "opendir", "(", "$", "apps_dir", ")", ")", "!==", "false", ")", "{", "while", "(", "(", "$", "name", "=", "readdir", "(", "$", "dh", ")", ")", "!==", "false", ")", "{", "if", "(", "$", "name", "{", "0", "}", "==", "'.'", "||", "$", "name", "==", "'Core'", "||", "is_file", "(", "$", "apps_dir", ".", "'/'", ".", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "app", "=", "$", "this", "->", "getAppInstance", "(", "$", "name", ")", ";", "}", "closedir", "(", "$", "dh", ")", ";", "}", "}", "}", "}" ]
Autodiscovers installed apps in the given path When an app is found an instance of it will be created. @param string|array $path Path to check for apps. Can be an array of paths
[ "Autodiscovers", "installed", "apps", "in", "the", "given", "path" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Amvc/App/AppHandler.php#L154-L179
9,792
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.init
public function init(ServletConfigInterface $servletConfig) { parent::init($servletConfig); $this->applicationContext = $this->getServletContext()->getApplication(); $this->initialContext = new InitialContext(); $this->initialContext->injectApplication($this->applicationContext); $this->logger = $this->applicationContext->getInitialContext()->getSystemLogger(); $this->logger->debug('Initializing Servlet '.str_replace("\n", " - ", $this->servletInfo)); if (file_exists(__DIR__."/DispatcherServlet.properties") && is_readable(__DIR__."/DispatcherServlet.properties")) { $this->defaultStrategies = new Properties(); try { $this->defaultStrategies->load(__DIR__."/DispatcherServlet.properties"); } catch (PropertyFileParseException $exc) { $this->logger->error("Could not read default strategies"); } } $this->initStrategies(); }
php
public function init(ServletConfigInterface $servletConfig) { parent::init($servletConfig); $this->applicationContext = $this->getServletContext()->getApplication(); $this->initialContext = new InitialContext(); $this->initialContext->injectApplication($this->applicationContext); $this->logger = $this->applicationContext->getInitialContext()->getSystemLogger(); $this->logger->debug('Initializing Servlet '.str_replace("\n", " - ", $this->servletInfo)); if (file_exists(__DIR__."/DispatcherServlet.properties") && is_readable(__DIR__."/DispatcherServlet.properties")) { $this->defaultStrategies = new Properties(); try { $this->defaultStrategies->load(__DIR__."/DispatcherServlet.properties"); } catch (PropertyFileParseException $exc) { $this->logger->error("Could not read default strategies"); } } $this->initStrategies(); }
[ "public", "function", "init", "(", "ServletConfigInterface", "$", "servletConfig", ")", "{", "parent", "::", "init", "(", "$", "servletConfig", ")", ";", "$", "this", "->", "applicationContext", "=", "$", "this", "->", "getServletContext", "(", ")", "->", "getApplication", "(", ")", ";", "$", "this", "->", "initialContext", "=", "new", "InitialContext", "(", ")", ";", "$", "this", "->", "initialContext", "->", "injectApplication", "(", "$", "this", "->", "applicationContext", ")", ";", "$", "this", "->", "logger", "=", "$", "this", "->", "applicationContext", "->", "getInitialContext", "(", ")", "->", "getSystemLogger", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'Initializing Servlet '", ".", "str_replace", "(", "\"\\n\"", ",", "\" - \"", ",", "$", "this", "->", "servletInfo", ")", ")", ";", "if", "(", "file_exists", "(", "__DIR__", ".", "\"/DispatcherServlet.properties\"", ")", "&&", "is_readable", "(", "__DIR__", ".", "\"/DispatcherServlet.properties\"", ")", ")", "{", "$", "this", "->", "defaultStrategies", "=", "new", "Properties", "(", ")", ";", "try", "{", "$", "this", "->", "defaultStrategies", "->", "load", "(", "__DIR__", ".", "\"/DispatcherServlet.properties\"", ")", ";", "}", "catch", "(", "PropertyFileParseException", "$", "exc", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "\"Could not read default strategies\"", ")", ";", "}", "}", "$", "this", "->", "initStrategies", "(", ")", ";", "}" ]
Overridden init function to initialize application context @param ServletConfigInterface $servletConfig The servlet config @return void
[ "Overridden", "init", "function", "to", "initialize", "application", "context" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L129-L146
9,793
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.initHandlerMappings
protected function initHandlerMappings() { $this->logger->debug('Initializing HandlerMappings.'); $this->handlerMappings = array(); if ($this->detectAllHandlerMappings) { $this->logger->debug('Scanning beans for HandlerMappings.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping"); if (!empty($beans)) { $this->handlerMappings = array_values($beans); } } else { $this->logger->debug('Looking up HandlerMapping bean by name.'); $handlerMapping = $this->initialContext->lookup(self::HANDLER_MAPPING_BEAN_NAME); if ($handlerMapping != null && $handlerMapping instanceof HandlerMapping) { $this->handlerMappings = array($handlerMapping); } } if (empty($this->handlerMappings)) { $this->logger->warning('Could not find any bean of type HandlerMapping, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping"); } }
php
protected function initHandlerMappings() { $this->logger->debug('Initializing HandlerMappings.'); $this->handlerMappings = array(); if ($this->detectAllHandlerMappings) { $this->logger->debug('Scanning beans for HandlerMappings.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping"); if (!empty($beans)) { $this->handlerMappings = array_values($beans); } } else { $this->logger->debug('Looking up HandlerMapping bean by name.'); $handlerMapping = $this->initialContext->lookup(self::HANDLER_MAPPING_BEAN_NAME); if ($handlerMapping != null && $handlerMapping instanceof HandlerMapping) { $this->handlerMappings = array($handlerMapping); } } if (empty($this->handlerMappings)) { $this->logger->warning('Could not find any bean of type HandlerMapping, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\HandlerMapping"); } }
[ "protected", "function", "initHandlerMappings", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Initializing HandlerMappings.'", ")", ";", "$", "this", "->", "handlerMappings", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "detectAllHandlerMappings", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Scanning beans for HandlerMappings.'", ")", ";", "$", "beans", "=", "BeanUtils", "::", "beansOfType", "(", "$", "this", "->", "applicationContext", ",", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\HandlerMapping\"", ")", ";", "if", "(", "!", "empty", "(", "$", "beans", ")", ")", "{", "$", "this", "->", "handlerMappings", "=", "array_values", "(", "$", "beans", ")", ";", "}", "}", "else", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Looking up HandlerMapping bean by name.'", ")", ";", "$", "handlerMapping", "=", "$", "this", "->", "initialContext", "->", "lookup", "(", "self", "::", "HANDLER_MAPPING_BEAN_NAME", ")", ";", "if", "(", "$", "handlerMapping", "!=", "null", "&&", "$", "handlerMapping", "instanceof", "HandlerMapping", ")", "{", "$", "this", "->", "handlerMappings", "=", "array", "(", "$", "handlerMapping", ")", ";", "}", "}", "if", "(", "empty", "(", "$", "this", "->", "handlerMappings", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "'Could not find any bean of type HandlerMapping, falling back to default strategy.'", ")", ";", "$", "this", "->", "viewResolvers", "=", "$", "this", "->", "getDefaultStrategies", "(", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\HandlerMapping\"", ")", ";", "}", "}" ]
Initialize the HandlerMappings used by this class. @return void
[ "Initialize", "the", "HandlerMappings", "used", "by", "this", "class", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L169-L190
9,794
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.initHandlerAdapters
protected function initHandlerAdapters() { $this->logger->debug('Initializing HandlerAdapters.'); $this->handlerAdapters = array(); if ($this->detectAllHandlerAdapters) { $this->logger->debug('Scanning beans for HandlerAdapters.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter"); if (!empty($beans)) { $this->handlerAdapters = array_values($beans); } } else { $this->logger->debug('Looking up HandlerAdapter bean by name.'); $handlerAdapter = $this->initialContext->lookup(self::HANDLER_ADAPTER_BEAN_NAME); if ($handlerAdapter != null && $handlerAdapter instanceof HandlerAdapter) { $this->handlerAdapters = array($handlerAdapter); } } if (empty($this->handlerAdapters)) { $this->logger->warning('Could not find any bean of type HandlerAdapter, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter"); } }
php
protected function initHandlerAdapters() { $this->logger->debug('Initializing HandlerAdapters.'); $this->handlerAdapters = array(); if ($this->detectAllHandlerAdapters) { $this->logger->debug('Scanning beans for HandlerAdapters.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter"); if (!empty($beans)) { $this->handlerAdapters = array_values($beans); } } else { $this->logger->debug('Looking up HandlerAdapter bean by name.'); $handlerAdapter = $this->initialContext->lookup(self::HANDLER_ADAPTER_BEAN_NAME); if ($handlerAdapter != null && $handlerAdapter instanceof HandlerAdapter) { $this->handlerAdapters = array($handlerAdapter); } } if (empty($this->handlerAdapters)) { $this->logger->warning('Could not find any bean of type HandlerAdapter, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\HandlerAdapter"); } }
[ "protected", "function", "initHandlerAdapters", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Initializing HandlerAdapters.'", ")", ";", "$", "this", "->", "handlerAdapters", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "detectAllHandlerAdapters", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Scanning beans for HandlerAdapters.'", ")", ";", "$", "beans", "=", "BeanUtils", "::", "beansOfType", "(", "$", "this", "->", "applicationContext", ",", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\HandlerAdapter\"", ")", ";", "if", "(", "!", "empty", "(", "$", "beans", ")", ")", "{", "$", "this", "->", "handlerAdapters", "=", "array_values", "(", "$", "beans", ")", ";", "}", "}", "else", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Looking up HandlerAdapter bean by name.'", ")", ";", "$", "handlerAdapter", "=", "$", "this", "->", "initialContext", "->", "lookup", "(", "self", "::", "HANDLER_ADAPTER_BEAN_NAME", ")", ";", "if", "(", "$", "handlerAdapter", "!=", "null", "&&", "$", "handlerAdapter", "instanceof", "HandlerAdapter", ")", "{", "$", "this", "->", "handlerAdapters", "=", "array", "(", "$", "handlerAdapter", ")", ";", "}", "}", "if", "(", "empty", "(", "$", "this", "->", "handlerAdapters", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "'Could not find any bean of type HandlerAdapter, falling back to default strategy.'", ")", ";", "$", "this", "->", "viewResolvers", "=", "$", "this", "->", "getDefaultStrategies", "(", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\HandlerAdapter\"", ")", ";", "}", "}" ]
Initialize the HandlerAdapters used by this class. @return void
[ "Initialize", "the", "HandlerAdapters", "used", "by", "this", "class", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L196-L217
9,795
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.initViewResolvers
protected function initViewResolvers() { $this->logger->debug('Initializing ViewResolvers.'); $this->viewResolvers = array(); if ($this->detectAllViewResolvers) { $this->logger->debug('Scanning beans for ViewResolvers.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\ViewResolver"); if (!empty($beans)) { $this->viewResolvers = array_values($beans); } } else { $this->logger->debug('Looking up ViewResolver bean by name.'); $viewResolver = $this->initialContext->lookup(self::VIEW_RESOLVER_BEAN_NAME); if ($viewResolver != null && $viewResolver instanceof ViewResolver) { $this->viewResolvers = array($viewResolver); } } if (empty($this->viewResolvers)) { $this->logger->warning('Could not find any bean of type ViewResolver, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\ViewResolver"); } }
php
protected function initViewResolvers() { $this->logger->debug('Initializing ViewResolvers.'); $this->viewResolvers = array(); if ($this->detectAllViewResolvers) { $this->logger->debug('Scanning beans for ViewResolvers.'); $beans = BeanUtils::beansOfType($this->applicationContext, "Ocelot\\Mvc\\Web\\Servlet\\ViewResolver"); if (!empty($beans)) { $this->viewResolvers = array_values($beans); } } else { $this->logger->debug('Looking up ViewResolver bean by name.'); $viewResolver = $this->initialContext->lookup(self::VIEW_RESOLVER_BEAN_NAME); if ($viewResolver != null && $viewResolver instanceof ViewResolver) { $this->viewResolvers = array($viewResolver); } } if (empty($this->viewResolvers)) { $this->logger->warning('Could not find any bean of type ViewResolver, falling back to default strategy.'); $this->viewResolvers = $this->getDefaultStrategies("Ocelot\\Mvc\\Web\\Servlet\\ViewResolver"); } }
[ "protected", "function", "initViewResolvers", "(", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Initializing ViewResolvers.'", ")", ";", "$", "this", "->", "viewResolvers", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "detectAllViewResolvers", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Scanning beans for ViewResolvers.'", ")", ";", "$", "beans", "=", "BeanUtils", "::", "beansOfType", "(", "$", "this", "->", "applicationContext", ",", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\ViewResolver\"", ")", ";", "if", "(", "!", "empty", "(", "$", "beans", ")", ")", "{", "$", "this", "->", "viewResolvers", "=", "array_values", "(", "$", "beans", ")", ";", "}", "}", "else", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Looking up ViewResolver bean by name.'", ")", ";", "$", "viewResolver", "=", "$", "this", "->", "initialContext", "->", "lookup", "(", "self", "::", "VIEW_RESOLVER_BEAN_NAME", ")", ";", "if", "(", "$", "viewResolver", "!=", "null", "&&", "$", "viewResolver", "instanceof", "ViewResolver", ")", "{", "$", "this", "->", "viewResolvers", "=", "array", "(", "$", "viewResolver", ")", ";", "}", "}", "if", "(", "empty", "(", "$", "this", "->", "viewResolvers", ")", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "'Could not find any bean of type ViewResolver, falling back to default strategy.'", ")", ";", "$", "this", "->", "viewResolvers", "=", "$", "this", "->", "getDefaultStrategies", "(", "\"Ocelot\\\\Mvc\\\\Web\\\\Servlet\\\\ViewResolver\"", ")", ";", "}", "}" ]
Initialize the ViewResolvers used by this class. @return void
[ "Initialize", "the", "ViewResolvers", "used", "by", "this", "class", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L223-L244
9,796
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.service
public function service(ServletRequestInterface $servletRequest, ServletResponseInterface $servletResponse) { // TODO: Add debug logging /** * @var $logger \Psr\Log\LoggerInterface */ $logger = $servletRequest->getContext()->getInitialContext()->getSystemLogger(); $logger->debug('Starting dispatch process for a new http request.'); $attributeSnapshot = array_merge(array(), $servletRequest->getParameterMap()); // TODO: Inject ViewResolver & Application Context into request try { $this->dispatch($servletRequest, $servletResponse); } catch (\Exception $ex) { $logger->error('Dispatch failed', $ex); } }
php
public function service(ServletRequestInterface $servletRequest, ServletResponseInterface $servletResponse) { // TODO: Add debug logging /** * @var $logger \Psr\Log\LoggerInterface */ $logger = $servletRequest->getContext()->getInitialContext()->getSystemLogger(); $logger->debug('Starting dispatch process for a new http request.'); $attributeSnapshot = array_merge(array(), $servletRequest->getParameterMap()); // TODO: Inject ViewResolver & Application Context into request try { $this->dispatch($servletRequest, $servletResponse); } catch (\Exception $ex) { $logger->error('Dispatch failed', $ex); } }
[ "public", "function", "service", "(", "ServletRequestInterface", "$", "servletRequest", ",", "ServletResponseInterface", "$", "servletResponse", ")", "{", "// TODO: Add debug logging", "/**\n * @var $logger \\Psr\\Log\\LoggerInterface\n */", "$", "logger", "=", "$", "servletRequest", "->", "getContext", "(", ")", "->", "getInitialContext", "(", ")", "->", "getSystemLogger", "(", ")", ";", "$", "logger", "->", "debug", "(", "'Starting dispatch process for a new http request.'", ")", ";", "$", "attributeSnapshot", "=", "array_merge", "(", "array", "(", ")", ",", "$", "servletRequest", "->", "getParameterMap", "(", ")", ")", ";", "// TODO: Inject ViewResolver & Application Context into request", "try", "{", "$", "this", "->", "dispatch", "(", "$", "servletRequest", ",", "$", "servletResponse", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "logger", "->", "error", "(", "'Dispatch failed'", ",", "$", "ex", ")", ";", "}", "}" ]
Entry point for requests. Dispatch the request to a controller here @param ServletRequestInterface $servletRequest The current request @param ServletResponseInterface $servletResponse The current response @return void
[ "Entry", "point", "for", "requests", ".", "Dispatch", "the", "request", "to", "a", "controller", "here" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L293-L308
9,797
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.dispatch
protected function dispatch(Request $servletRequest, Response $servletResponse) { $mapperHandler = null; try { /** * @var $mv ModelAndView */ $mv = null; $dispatchException = null; try { $mappedHandler = $this->getHandler($servletRequest); if ($mappedHandler == null || $mappedHandler->getHandler() == null) { $this->noHandlerFound($servletRequest, $servletResponse); return; } $ha = $this->getHandlerAdapter($mappedHandler->getHandler()); if (!$mappedHandler->applyPreHandle($servletRequest, $servletResponse)) { return; } $mv = $ha->handle($servletRequest, $servletResponse, $mappedHandler->getHandler()); $mappedHandler->applyPostHandle($servletRequest, $servletResponse, $mv); } catch (\Exception $ex) { $dispatchException = $ex; } $this->processDispatchResult($servletRequest, $servletResponse, $mappedHandler, $mv, $dispatchException); } catch (\Exception $ex) { $this->triggerAfterCompletion($servletRequest, $servletResponse, $mappedHandler, $ex); } }
php
protected function dispatch(Request $servletRequest, Response $servletResponse) { $mapperHandler = null; try { /** * @var $mv ModelAndView */ $mv = null; $dispatchException = null; try { $mappedHandler = $this->getHandler($servletRequest); if ($mappedHandler == null || $mappedHandler->getHandler() == null) { $this->noHandlerFound($servletRequest, $servletResponse); return; } $ha = $this->getHandlerAdapter($mappedHandler->getHandler()); if (!$mappedHandler->applyPreHandle($servletRequest, $servletResponse)) { return; } $mv = $ha->handle($servletRequest, $servletResponse, $mappedHandler->getHandler()); $mappedHandler->applyPostHandle($servletRequest, $servletResponse, $mv); } catch (\Exception $ex) { $dispatchException = $ex; } $this->processDispatchResult($servletRequest, $servletResponse, $mappedHandler, $mv, $dispatchException); } catch (\Exception $ex) { $this->triggerAfterCompletion($servletRequest, $servletResponse, $mappedHandler, $ex); } }
[ "protected", "function", "dispatch", "(", "Request", "$", "servletRequest", ",", "Response", "$", "servletResponse", ")", "{", "$", "mapperHandler", "=", "null", ";", "try", "{", "/**\n * @var $mv ModelAndView\n */", "$", "mv", "=", "null", ";", "$", "dispatchException", "=", "null", ";", "try", "{", "$", "mappedHandler", "=", "$", "this", "->", "getHandler", "(", "$", "servletRequest", ")", ";", "if", "(", "$", "mappedHandler", "==", "null", "||", "$", "mappedHandler", "->", "getHandler", "(", ")", "==", "null", ")", "{", "$", "this", "->", "noHandlerFound", "(", "$", "servletRequest", ",", "$", "servletResponse", ")", ";", "return", ";", "}", "$", "ha", "=", "$", "this", "->", "getHandlerAdapter", "(", "$", "mappedHandler", "->", "getHandler", "(", ")", ")", ";", "if", "(", "!", "$", "mappedHandler", "->", "applyPreHandle", "(", "$", "servletRequest", ",", "$", "servletResponse", ")", ")", "{", "return", ";", "}", "$", "mv", "=", "$", "ha", "->", "handle", "(", "$", "servletRequest", ",", "$", "servletResponse", ",", "$", "mappedHandler", "->", "getHandler", "(", ")", ")", ";", "$", "mappedHandler", "->", "applyPostHandle", "(", "$", "servletRequest", ",", "$", "servletResponse", ",", "$", "mv", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "dispatchException", "=", "$", "ex", ";", "}", "$", "this", "->", "processDispatchResult", "(", "$", "servletRequest", ",", "$", "servletResponse", ",", "$", "mappedHandler", ",", "$", "mv", ",", "$", "dispatchException", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "$", "this", "->", "triggerAfterCompletion", "(", "$", "servletRequest", ",", "$", "servletResponse", ",", "$", "mappedHandler", ",", "$", "ex", ")", ";", "}", "}" ]
Internal dispatch function that gets called by service @param \AppserverIo\Appserver\ServletEngine\Http\Request $servletRequest The current request @param \AppserverIo\Appserver\ServletEngine\Http\Response $servletResponse The current response @see DispatcherServlet::service @return void
[ "Internal", "dispatch", "function", "that", "gets", "called", "by", "service" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L317-L345
9,798
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.getHandler
protected function getHandler(ServletRequestInterface $servletRequest) { foreach ($this->handlerMappings as $handlerMapping) { $handler = $handlerMapping->getHandler($servletRequest); if ($handler != null) { return $handler; } } return null; }
php
protected function getHandler(ServletRequestInterface $servletRequest) { foreach ($this->handlerMappings as $handlerMapping) { $handler = $handlerMapping->getHandler($servletRequest); if ($handler != null) { return $handler; } } return null; }
[ "protected", "function", "getHandler", "(", "ServletRequestInterface", "$", "servletRequest", ")", "{", "foreach", "(", "$", "this", "->", "handlerMappings", "as", "$", "handlerMapping", ")", "{", "$", "handler", "=", "$", "handlerMapping", "->", "getHandler", "(", "$", "servletRequest", ")", ";", "if", "(", "$", "handler", "!=", "null", ")", "{", "return", "$", "handler", ";", "}", "}", "return", "null", ";", "}" ]
Return the HandlerExecutionChain for this request @param ServletRequestInterface $servletRequest current HTTP request @return HandlerExecutionChain the HandlerExecutionChain or {@code null} is no handler could be found
[ "Return", "the", "HandlerExecutionChain", "for", "this", "request" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L352-L361
9,799
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/DispatcherServlet.php
DispatcherServlet.noHandlerFound
protected function noHandlerFound(Request $servletRequest, Response $servletResponse) { $this->logger->warning("No mapping found for HTTP request with URI [".$servletRequest->getRequestUri()."]"); throw new \Exception("No mapping found for HTTP request with URI [".$servletRequest->getRequestUri()."]"); }
php
protected function noHandlerFound(Request $servletRequest, Response $servletResponse) { $this->logger->warning("No mapping found for HTTP request with URI [".$servletRequest->getRequestUri()."]"); throw new \Exception("No mapping found for HTTP request with URI [".$servletRequest->getRequestUri()."]"); }
[ "protected", "function", "noHandlerFound", "(", "Request", "$", "servletRequest", ",", "Response", "$", "servletResponse", ")", "{", "$", "this", "->", "logger", "->", "warning", "(", "\"No mapping found for HTTP request with URI [\"", ".", "$", "servletRequest", "->", "getRequestUri", "(", ")", ".", "\"]\"", ")", ";", "throw", "new", "\\", "Exception", "(", "\"No mapping found for HTTP request with URI [\"", ".", "$", "servletRequest", "->", "getRequestUri", "(", ")", ".", "\"]\"", ")", ";", "}" ]
No handler found -> throw exception @param \AppserverIo\Appserver\ServletEngine\Http\Request $servletRequest The current HTTP request @param \AppserverIo\Appserver\ServletEngine\Http\Response $servletResponse The current HTTP response @throws \Exception @return void
[ "No", "handler", "found", "-", ">", "throw", "exception" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L370-L374