id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
238,100
laradic/service-provider
src/Plugins/Routing.php
Routing.startRoutingPlugin
protected function startRoutingPlugin($app) { $this->requiresPlugins(Paths::class, Resources::class); $this->onRegister('routing', function (Application $app) { if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) { $router = $app->make('router'); $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); foreach ($this->prependMiddleware as $class) { $kernel->prependMiddleware($class); } foreach ($this->middleware as $class) { $kernel->pushMiddleware($class); } foreach ($this->routeMiddleware as $name => $class) { if (method_exists($router, 'middleware')) { $router->middleware($name, $class); } else { $router->aliasMiddleware($name, $class); } } foreach ($this->middlewareGroups as $groupName => $classes) { $router->middlewareGroup($groupName, $classes); } foreach ($this->prependGroupMiddleware as $group => $class) { $router->prependMiddlewareToGroup($group, $class); } foreach ($this->groupMiddleware as $group => $class) { $router->pushMiddlewareToGroup($group, $class); } } }); $this->onBoot('routing', function (Application $app) { foreach ($this->routeFiles as $routeFile) { $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php'))); } }); static::refreshRoutes($app); }
php
protected function startRoutingPlugin($app) { $this->requiresPlugins(Paths::class, Resources::class); $this->onRegister('routing', function (Application $app) { if (PHP_SAPI !== 'cli' || $this->app->runningUnitTests()) { $router = $app->make('router'); $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); foreach ($this->prependMiddleware as $class) { $kernel->prependMiddleware($class); } foreach ($this->middleware as $class) { $kernel->pushMiddleware($class); } foreach ($this->routeMiddleware as $name => $class) { if (method_exists($router, 'middleware')) { $router->middleware($name, $class); } else { $router->aliasMiddleware($name, $class); } } foreach ($this->middlewareGroups as $groupName => $classes) { $router->middlewareGroup($groupName, $classes); } foreach ($this->prependGroupMiddleware as $group => $class) { $router->prependMiddlewareToGroup($group, $class); } foreach ($this->groupMiddleware as $group => $class) { $router->pushMiddlewareToGroup($group, $class); } } }); $this->onBoot('routing', function (Application $app) { foreach ($this->routeFiles as $routeFile) { $this->loadRoutesFrom(path_join($this->resolvePath('routesPath'), str_ensure_right($routeFile, '.php'))); } }); static::refreshRoutes($app); }
[ "protected", "function", "startRoutingPlugin", "(", "$", "app", ")", "{", "$", "this", "->", "requiresPlugins", "(", "Paths", "::", "class", ",", "Resources", "::", "class", ")", ";", "$", "this", "->", "onRegister", "(", "'routing'", ",", "function", "(", "Application", "$", "app", ")", "{", "if", "(", "PHP_SAPI", "!==", "'cli'", "||", "$", "this", "->", "app", "->", "runningUnitTests", "(", ")", ")", "{", "$", "router", "=", "$", "app", "->", "make", "(", "'router'", ")", ";", "$", "kernel", "=", "$", "app", "->", "make", "(", "'Illuminate\\Contracts\\Http\\Kernel'", ")", ";", "foreach", "(", "$", "this", "->", "prependMiddleware", "as", "$", "class", ")", "{", "$", "kernel", "->", "prependMiddleware", "(", "$", "class", ")", ";", "}", "foreach", "(", "$", "this", "->", "middleware", "as", "$", "class", ")", "{", "$", "kernel", "->", "pushMiddleware", "(", "$", "class", ")", ";", "}", "foreach", "(", "$", "this", "->", "routeMiddleware", "as", "$", "name", "=>", "$", "class", ")", "{", "if", "(", "method_exists", "(", "$", "router", ",", "'middleware'", ")", ")", "{", "$", "router", "->", "middleware", "(", "$", "name", ",", "$", "class", ")", ";", "}", "else", "{", "$", "router", "->", "aliasMiddleware", "(", "$", "name", ",", "$", "class", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "middlewareGroups", "as", "$", "groupName", "=>", "$", "classes", ")", "{", "$", "router", "->", "middlewareGroup", "(", "$", "groupName", ",", "$", "classes", ")", ";", "}", "foreach", "(", "$", "this", "->", "prependGroupMiddleware", "as", "$", "group", "=>", "$", "class", ")", "{", "$", "router", "->", "prependMiddlewareToGroup", "(", "$", "group", ",", "$", "class", ")", ";", "}", "foreach", "(", "$", "this", "->", "groupMiddleware", "as", "$", "group", "=>", "$", "class", ")", "{", "$", "router", "->", "pushMiddlewareToGroup", "(", "$", "group", ",", "$", "class", ")", ";", "}", "}", "}", ")", ";", "$", "this", "->", "onBoot", "(", "'routing'", ",", "function", "(", "Application", "$", "app", ")", "{", "foreach", "(", "$", "this", "->", "routeFiles", "as", "$", "routeFile", ")", "{", "$", "this", "->", "loadRoutesFrom", "(", "path_join", "(", "$", "this", "->", "resolvePath", "(", "'routesPath'", ")", ",", "str_ensure_right", "(", "$", "routeFile", ",", "'.php'", ")", ")", ")", ";", "}", "}", ")", ";", "static", "::", "refreshRoutes", "(", "$", "app", ")", ";", "}" ]
startMiddlewarePlugin method. @param Application $app
[ "startMiddlewarePlugin", "method", "." ]
b1428d566b97b3662b405c64ff0cad8a89102033
https://github.com/laradic/service-provider/blob/b1428d566b97b3662b405c64ff0cad8a89102033/src/Plugins/Routing.php#L81-L126
238,101
dlabas/DlcDiagramm
src/DlcDiagramm/Proxy/Yuml.php
Yuml.getUriForDiagrammType
public function getUriForDiagrammType($type) { switch ($type) { case Diagramm::TYPE_ACTIVITY: $uri = $this->getOptions()->getYumlActivityDiagrammUrl(); break; case Diagramm::TYPE_CLASS: $uri = $this->getOptions()->getYumlClassDiagrammUrl(); break; case Diagramm::TYPE_DIAGRAMM: throw new \InvalidArgumentException('Unsupported diagramm type "' . $type . '"'); break; case Diagramm::TYPE_USE_CASE: $uri = $this->getOptions()->getYumlUseCaseDiagrammUrl(); break; default: throw new \InvalidArgumentException('Unkown diagramm type "' . $type . '"'); break; } return $uri; }
php
public function getUriForDiagrammType($type) { switch ($type) { case Diagramm::TYPE_ACTIVITY: $uri = $this->getOptions()->getYumlActivityDiagrammUrl(); break; case Diagramm::TYPE_CLASS: $uri = $this->getOptions()->getYumlClassDiagrammUrl(); break; case Diagramm::TYPE_DIAGRAMM: throw new \InvalidArgumentException('Unsupported diagramm type "' . $type . '"'); break; case Diagramm::TYPE_USE_CASE: $uri = $this->getOptions()->getYumlUseCaseDiagrammUrl(); break; default: throw new \InvalidArgumentException('Unkown diagramm type "' . $type . '"'); break; } return $uri; }
[ "public", "function", "getUriForDiagrammType", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "Diagramm", "::", "TYPE_ACTIVITY", ":", "$", "uri", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getYumlActivityDiagrammUrl", "(", ")", ";", "break", ";", "case", "Diagramm", "::", "TYPE_CLASS", ":", "$", "uri", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getYumlClassDiagrammUrl", "(", ")", ";", "break", ";", "case", "Diagramm", "::", "TYPE_DIAGRAMM", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unsupported diagramm type \"'", ".", "$", "type", ".", "'\"'", ")", ";", "break", ";", "case", "Diagramm", "::", "TYPE_USE_CASE", ":", "$", "uri", "=", "$", "this", "->", "getOptions", "(", ")", "->", "getYumlUseCaseDiagrammUrl", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unkown diagramm type \"'", ".", "$", "type", ".", "'\"'", ")", ";", "break", ";", "}", "return", "$", "uri", ";", "}" ]
Returns the URI for the yuml service for a diagramm type @param string $type @throws \InvalidArgumentException @return string
[ "Returns", "the", "URI", "for", "the", "yuml", "service", "for", "a", "diagramm", "type" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Proxy/Yuml.php#L46-L66
238,102
dlabas/DlcDiagramm
src/DlcDiagramm/Proxy/Yuml.php
Yuml.requestDiagramm
public function requestDiagramm($type, $dslText) { if ($this->getOptions()->getReturnDummyImage()) { return $this->getOptions()->getDummyImage(); } $httpClient = $this->getHttpClient(); $httpClient->setUri($this->getUriForDiagrammType($type)); $httpClient->setParameterPost(array('dsl_text' => $dslText)); $response = $httpClient->send(); if (!$response->isSuccess()) { throw new \UnexpectedValueException('HTTP Request failed'); } return $this->getOptions()->getYumlUrl() . $response->getBody(); }
php
public function requestDiagramm($type, $dslText) { if ($this->getOptions()->getReturnDummyImage()) { return $this->getOptions()->getDummyImage(); } $httpClient = $this->getHttpClient(); $httpClient->setUri($this->getUriForDiagrammType($type)); $httpClient->setParameterPost(array('dsl_text' => $dslText)); $response = $httpClient->send(); if (!$response->isSuccess()) { throw new \UnexpectedValueException('HTTP Request failed'); } return $this->getOptions()->getYumlUrl() . $response->getBody(); }
[ "public", "function", "requestDiagramm", "(", "$", "type", ",", "$", "dslText", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getReturnDummyImage", "(", ")", ")", "{", "return", "$", "this", "->", "getOptions", "(", ")", "->", "getDummyImage", "(", ")", ";", "}", "$", "httpClient", "=", "$", "this", "->", "getHttpClient", "(", ")", ";", "$", "httpClient", "->", "setUri", "(", "$", "this", "->", "getUriForDiagrammType", "(", "$", "type", ")", ")", ";", "$", "httpClient", "->", "setParameterPost", "(", "array", "(", "'dsl_text'", "=>", "$", "dslText", ")", ")", ";", "$", "response", "=", "$", "httpClient", "->", "send", "(", ")", ";", "if", "(", "!", "$", "response", "->", "isSuccess", "(", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "'HTTP Request failed'", ")", ";", "}", "return", "$", "this", "->", "getOptions", "(", ")", "->", "getYumlUrl", "(", ")", ".", "$", "response", "->", "getBody", "(", ")", ";", "}" ]
Requests a diagramm from yuml web service @param string $type @param string $dslText @throws \UnexpectedValueException @return string
[ "Requests", "a", "diagramm", "from", "yuml", "web", "service" ]
a8d6e6ad01943512fd9e4799278c031332a86400
https://github.com/dlabas/DlcDiagramm/blob/a8d6e6ad01943512fd9e4799278c031332a86400/src/DlcDiagramm/Proxy/Yuml.php#L76-L93
238,103
loopsframework/base
src/Loops/Service.php
Service.getConfig
public static function getConfig(Loops $loops = NULL, ArrayObject $config = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } if(!$config) { $parts = explode("\\", get_called_class()); if(count($parts) > 2 && array_slice($parts, 0, 2) == [ "Loops", "Service" ]) { $parts = array_slice($parts, 2); } $sectionname = Misc::underscore(implode("\\", $parts)); $config = $loops->getService('config'); $config = $config->offsetExists($sectionname) ? $config->offsetGet($sectionname) : new ArrayObject; } $result = static::getDefaultConfig($loops); $result->merge($config); $result->offsetSet('loops', $loops); return $result; }
php
public static function getConfig(Loops $loops = NULL, ArrayObject $config = NULL) { if(!$loops) { $loops = Loops::getCurrentLoops(); } if(!$config) { $parts = explode("\\", get_called_class()); if(count($parts) > 2 && array_slice($parts, 0, 2) == [ "Loops", "Service" ]) { $parts = array_slice($parts, 2); } $sectionname = Misc::underscore(implode("\\", $parts)); $config = $loops->getService('config'); $config = $config->offsetExists($sectionname) ? $config->offsetGet($sectionname) : new ArrayObject; } $result = static::getDefaultConfig($loops); $result->merge($config); $result->offsetSet('loops', $loops); return $result; }
[ "public", "static", "function", "getConfig", "(", "Loops", "$", "loops", "=", "NULL", ",", "ArrayObject", "$", "config", "=", "NULL", ")", "{", "if", "(", "!", "$", "loops", ")", "{", "$", "loops", "=", "Loops", "::", "getCurrentLoops", "(", ")", ";", "}", "if", "(", "!", "$", "config", ")", "{", "$", "parts", "=", "explode", "(", "\"\\\\\"", ",", "get_called_class", "(", ")", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "2", "&&", "array_slice", "(", "$", "parts", ",", "0", ",", "2", ")", "==", "[", "\"Loops\"", ",", "\"Service\"", "]", ")", "{", "$", "parts", "=", "array_slice", "(", "$", "parts", ",", "2", ")", ";", "}", "$", "sectionname", "=", "Misc", "::", "underscore", "(", "implode", "(", "\"\\\\\"", ",", "$", "parts", ")", ")", ";", "$", "config", "=", "$", "loops", "->", "getService", "(", "'config'", ")", ";", "$", "config", "=", "$", "config", "->", "offsetExists", "(", "$", "sectionname", ")", "?", "$", "config", "->", "offsetGet", "(", "$", "sectionname", ")", ":", "new", "ArrayObject", ";", "}", "$", "result", "=", "static", "::", "getDefaultConfig", "(", "$", "loops", ")", ";", "$", "result", "->", "merge", "(", "$", "config", ")", ";", "$", "result", "->", "offsetSet", "(", "'loops'", ",", "$", "loops", ")", ";", "return", "$", "result", ";", "}" ]
Returns the complete config of a service A Loops context will be included in the configuration. The config value will be generated by getting the default configuration of this class to which additional config values can be merged. If no additional values have been set, the config service of the Loops context will be looked for extra values. Here, the value at the key that is determined as follows will be used: 1. Get the classname of this class without the "Loops\Service\" part. e.g. "SmartyRenderer" for class "Loops\Service\SmartyRenderer" 2. Underscore the classname (see Misc::undercore). e.g. "smarty_renderer" for classname "SmartyRenderer" So in order to define extra configuration values for the service "Loops\Service\SmartyRenderer" these values must be accessable by key "smarty_renderer" in the config service. Example in case a config.ini file is used (which is true for most cases): <code> ... [smarty_renderer] disable_security = TRUE ... </code> @param Loops $loops The Loops context. It will be included in the configuration. Defaults to the current Loops context if not set. @param Loops\ArrayObject $config Additional config values that should be merged to the default config. @return Loops\ArrayObject The configuration which combines default values with additional values and the loops context
[ "Returns", "the", "complete", "config", "of", "a", "service" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L224-L245
238,104
loopsframework/base
src/Loops/Service.php
Service.getService
public static function getService(ArrayObject $config, Loops $loops) { return Misc::reflectionInstance(static::getClassname($loops), static::getConfig($loops, $config)); }
php
public static function getService(ArrayObject $config, Loops $loops) { return Misc::reflectionInstance(static::getClassname($loops), static::getConfig($loops, $config)); }
[ "public", "static", "function", "getService", "(", "ArrayObject", "$", "config", ",", "Loops", "$", "loops", ")", "{", "return", "Misc", "::", "reflectionInstance", "(", "static", "::", "getClassname", "(", "$", "loops", ")", ",", "static", "::", "getConfig", "(", "$", "loops", ",", "$", "config", ")", ")", ";", "}" ]
The factory method that creates the service instance The service is instantiated by Misc::reflectionInstance. The classname that is returned by function getClassname will be instanciated and arguments for the constructor are retrieved by function getConfig. Without further changes in the child class, an instance of the service class will be instantiated and returned. @param Loops\ArrayObject $config The additiona config that will be merged into the default config. @param Loops $loops The loops context @return object The service object
[ "The", "factory", "method", "that", "creates", "the", "service", "instance" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L260-L262
238,105
loopsframework/base
src/Loops/Service.php
Service.hasService
public static function hasService(Loops $loops) { foreach(static::getDependencies($loops) as $classname) { if(!class_exists($classname)) { return FALSE; } } return TRUE; }
php
public static function hasService(Loops $loops) { foreach(static::getDependencies($loops) as $classname) { if(!class_exists($classname)) { return FALSE; } } return TRUE; }
[ "public", "static", "function", "hasService", "(", "Loops", "$", "loops", ")", "{", "foreach", "(", "static", "::", "getDependencies", "(", "$", "loops", ")", "as", "$", "classname", ")", "{", "if", "(", "!", "class_exists", "(", "$", "classname", ")", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}" ]
Checks if all dependent classnames are defined @param Loops\ArrayObject $config The additiona config that will be merged into the default config. @param Loops $loops The loops context @return bool TRUE if all dependencies are defined
[ "Checks", "if", "all", "dependent", "classnames", "are", "defined" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service.php#L271-L279
238,106
phergie/phergie-irc-event
src/EventConverter.php
EventConverter.convert
public function convert(EventInterface $event) { $connection = $event->getConnection(); $array = array( 'message' => $event->getMessage(), 'params' => $event->getParams(), 'command' => $event->getCommand(), 'connection' => array( 'serverHostname' => $connection->getServerHostname(), 'serverPort' => $connection->getServerPort(), 'nickname' => $connection->getNickname(), 'username' => $connection->getUsername(), 'hostname' => $connection->getHostname(), 'servername' => $connection->getServername(), 'realname' => $connection->getRealname(), ), ); if ($event instanceof UserEventInterface) { $array['user'] = array( 'prefix' => $event->getPrefix(), 'nick' => $event->getNick(), 'username' => $event->getUsername(), 'host' => $event->getHost(), 'targets' => $event->getTargets(), ); } if ($event instanceof CtcpEventInterface) { $array['ctcp'] = array( 'command' => $event->getCtcpCommand(), 'params' => $event->getCtcpParams(), ); } return $array; }
php
public function convert(EventInterface $event) { $connection = $event->getConnection(); $array = array( 'message' => $event->getMessage(), 'params' => $event->getParams(), 'command' => $event->getCommand(), 'connection' => array( 'serverHostname' => $connection->getServerHostname(), 'serverPort' => $connection->getServerPort(), 'nickname' => $connection->getNickname(), 'username' => $connection->getUsername(), 'hostname' => $connection->getHostname(), 'servername' => $connection->getServername(), 'realname' => $connection->getRealname(), ), ); if ($event instanceof UserEventInterface) { $array['user'] = array( 'prefix' => $event->getPrefix(), 'nick' => $event->getNick(), 'username' => $event->getUsername(), 'host' => $event->getHost(), 'targets' => $event->getTargets(), ); } if ($event instanceof CtcpEventInterface) { $array['ctcp'] = array( 'command' => $event->getCtcpCommand(), 'params' => $event->getCtcpParams(), ); } return $array; }
[ "public", "function", "convert", "(", "EventInterface", "$", "event", ")", "{", "$", "connection", "=", "$", "event", "->", "getConnection", "(", ")", ";", "$", "array", "=", "array", "(", "'message'", "=>", "$", "event", "->", "getMessage", "(", ")", ",", "'params'", "=>", "$", "event", "->", "getParams", "(", ")", ",", "'command'", "=>", "$", "event", "->", "getCommand", "(", ")", ",", "'connection'", "=>", "array", "(", "'serverHostname'", "=>", "$", "connection", "->", "getServerHostname", "(", ")", ",", "'serverPort'", "=>", "$", "connection", "->", "getServerPort", "(", ")", ",", "'nickname'", "=>", "$", "connection", "->", "getNickname", "(", ")", ",", "'username'", "=>", "$", "connection", "->", "getUsername", "(", ")", ",", "'hostname'", "=>", "$", "connection", "->", "getHostname", "(", ")", ",", "'servername'", "=>", "$", "connection", "->", "getServername", "(", ")", ",", "'realname'", "=>", "$", "connection", "->", "getRealname", "(", ")", ",", ")", ",", ")", ";", "if", "(", "$", "event", "instanceof", "UserEventInterface", ")", "{", "$", "array", "[", "'user'", "]", "=", "array", "(", "'prefix'", "=>", "$", "event", "->", "getPrefix", "(", ")", ",", "'nick'", "=>", "$", "event", "->", "getNick", "(", ")", ",", "'username'", "=>", "$", "event", "->", "getUsername", "(", ")", ",", "'host'", "=>", "$", "event", "->", "getHost", "(", ")", ",", "'targets'", "=>", "$", "event", "->", "getTargets", "(", ")", ",", ")", ";", "}", "if", "(", "$", "event", "instanceof", "CtcpEventInterface", ")", "{", "$", "array", "[", "'ctcp'", "]", "=", "array", "(", "'command'", "=>", "$", "event", "->", "getCtcpCommand", "(", ")", ",", "'params'", "=>", "$", "event", "->", "getCtcpParams", "(", ")", ",", ")", ";", "}", "return", "$", "array", ";", "}" ]
Converts an event object into an array. @param \Phergie\Irc\Event\EventInterface $event @return array
[ "Converts", "an", "event", "object", "into", "an", "array", "." ]
8650778727fc03af7fbfa2e4db9762e8521bc09e
https://github.com/phergie/phergie-irc-event/blob/8650778727fc03af7fbfa2e4db9762e8521bc09e/src/EventConverter.php#L28-L65
238,107
sheychen290/colis
src/Stream.php
Stream.attach
protected function attach($stream) { if (is_resource($stream) === false) { throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource'); } if (is_resource($this->stream) === true) { $this->detach(); } $this->stream = $stream; }
php
protected function attach($stream) { if (is_resource($stream) === false) { throw new InvalidArgumentException(__METHOD__ . ' argument must be a valid PHP resource'); } if (is_resource($this->stream) === true) { $this->detach(); } $this->stream = $stream; }
[ "protected", "function", "attach", "(", "$", "stream", ")", "{", "if", "(", "is_resource", "(", "$", "stream", ")", "===", "false", ")", "{", "throw", "new", "InvalidArgumentException", "(", "__METHOD__", ".", "' argument must be a valid PHP resource'", ")", ";", "}", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "$", "this", "->", "detach", "(", ")", ";", "}", "$", "this", "->", "stream", "=", "$", "stream", ";", "}" ]
Attach new resource to this object
[ "Attach", "new", "resource", "to", "this", "object" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L40-L51
238,108
sheychen290/colis
src/Stream.php
Stream.close
public function close() { if (is_resource($this->stream) === true) { fclose($this->stream); } $this->detach(); }
php
public function close() { if (is_resource($this->stream) === true) { fclose($this->stream); } $this->detach(); }
[ "public", "function", "close", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "fclose", "(", "$", "this", "->", "stream", ")", ";", "}", "$", "this", "->", "detach", "(", ")", ";", "}" ]
Closes the stream and any underlying resources
[ "Closes", "the", "stream", "and", "any", "underlying", "resources" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L54-L61
238,109
sheychen290/colis
src/Stream.php
Stream.getSize
public function getSize() { if (is_resource($this->stream) === true) { $stats = fstat($this->stream); if (isset($stats['size'])) { return $stats['size']; } } return null; }
php
public function getSize() { if (is_resource($this->stream) === true) { $stats = fstat($this->stream); if (isset($stats['size'])) { return $stats['size']; } } return null; }
[ "public", "function", "getSize", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "$", "stats", "=", "fstat", "(", "$", "this", "->", "stream", ")", ";", "if", "(", "isset", "(", "$", "stats", "[", "'size'", "]", ")", ")", "{", "return", "$", "stats", "[", "'size'", "]", ";", "}", "}", "return", "null", ";", "}" ]
Get the size of the stream if known
[ "Get", "the", "size", "of", "the", "stream", "if", "known" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L72-L81
238,110
sheychen290/colis
src/Stream.php
Stream.isWritable
public function isWritable() { if (is_resource($this->stream) === true) { $metadata = $this->getMetadata(); return Validator::isWritable($metadata); } return false; }
php
public function isWritable() { if (is_resource($this->stream) === true) { $metadata = $this->getMetadata(); return Validator::isWritable($metadata); } return false; }
[ "public", "function", "isWritable", "(", ")", "{", "if", "(", "is_resource", "(", "$", "this", "->", "stream", ")", "===", "true", ")", "{", "$", "metadata", "=", "$", "this", "->", "getMetadata", "(", ")", ";", "return", "Validator", "::", "isWritable", "(", "$", "metadata", ")", ";", "}", "return", "false", ";", "}" ]
Returns whether or not the stream is writable
[ "Returns", "whether", "or", "not", "the", "stream", "is", "writable" ]
b0552ece885d6b258e73ddbccf0b52c5c28e6054
https://github.com/sheychen290/colis/blob/b0552ece885d6b258e73ddbccf0b52c5c28e6054/src/Stream.php#L127-L134
238,111
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & AddFields ($fields) { /** @var $this \MvcCore\Ext\Forms\IForm */ $fields = func_get_args(); if (count($fields) === 1 && is_array($fields[0])) $fields = $fields[0]; foreach ($fields as & $field) $this->AddField($field); return $this; }
php
public function & AddFields ($fields) { /** @var $this \MvcCore\Ext\Forms\IForm */ $fields = func_get_args(); if (count($fields) === 1 && is_array($fields[0])) $fields = $fields[0]; foreach ($fields as & $field) $this->AddField($field); return $this; }
[ "public", "function", "&", "AddFields", "(", "$", "fields", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "fields", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "fields", ")", "===", "1", "&&", "is_array", "(", "$", "fields", "[", "0", "]", ")", ")", "$", "fields", "=", "$", "fields", "[", "0", "]", ";", "foreach", "(", "$", "fields", "as", "&", "$", "field", ")", "$", "this", "->", "AddField", "(", "$", "field", ")", ";", "return", "$", "this", ";", "}" ]
Add multiple fully configured form field instances, function have infinite params with new field instances. @param \MvcCore\Ext\Forms\Field[]|\MvcCore\Ext\Forms\IField[] $fields,... Any `\MvcCore\Ext\Forms\IField` fully configured instance to add into form. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "multiple", "fully", "configured", "form", "field", "instances", "function", "have", "infinite", "params", "with", "new", "field", "instances", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L58-L65
238,112
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & AddField (\MvcCore\Ext\Forms\IField $field) { /** @var $this \MvcCore\Ext\Forms\IForm */ /** @var $field \MvcCore\Ext\Forms\Field */ if ($this->dispatchState < 1) $this->Init(); $fieldName = $field->GetName(); $field->SetForm($this); $this->fields[$fieldName] = & $field; if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) { $this->submitFields[$fieldName] = & $field; $fieldCustomResultState = $field->GetCustomResultState(); if ($fieldCustomResultState !== NULL) $this->customResultStates[$fieldName] = $fieldCustomResultState; } return $this; }
php
public function & AddField (\MvcCore\Ext\Forms\IField $field) { /** @var $this \MvcCore\Ext\Forms\IForm */ /** @var $field \MvcCore\Ext\Forms\Field */ if ($this->dispatchState < 1) $this->Init(); $fieldName = $field->GetName(); $field->SetForm($this); $this->fields[$fieldName] = & $field; if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) { $this->submitFields[$fieldName] = & $field; $fieldCustomResultState = $field->GetCustomResultState(); if ($fieldCustomResultState !== NULL) $this->customResultStates[$fieldName] = $fieldCustomResultState; } return $this; }
[ "public", "function", "&", "AddField", "(", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IField", "$", "field", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "/** @var $field \\MvcCore\\Ext\\Forms\\Field */", "if", "(", "$", "this", "->", "dispatchState", "<", "1", ")", "$", "this", "->", "Init", "(", ")", ";", "$", "fieldName", "=", "$", "field", "->", "GetName", "(", ")", ";", "$", "field", "->", "SetForm", "(", "$", "this", ")", ";", "$", "this", "->", "fields", "[", "$", "fieldName", "]", "=", "&", "$", "field", ";", "if", "(", "$", "field", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "Fields", "\\", "ISubmit", ")", "{", "$", "this", "->", "submitFields", "[", "$", "fieldName", "]", "=", "&", "$", "field", ";", "$", "fieldCustomResultState", "=", "$", "field", "->", "GetCustomResultState", "(", ")", ";", "if", "(", "$", "fieldCustomResultState", "!==", "NULL", ")", "$", "this", "->", "customResultStates", "[", "$", "fieldName", "]", "=", "$", "fieldCustomResultState", ";", "}", "return", "$", "this", ";", "}" ]
Add fully configured form field instance. @param \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField $field @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "fully", "configured", "form", "field", "instance", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L72-L86
238,113
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.HasField
public function HasField ($fieldOrFieldName = NULL) { $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } return isset($this->fields[$fieldName]); }
php
public function HasField ($fieldOrFieldName = NULL) { $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } return isset($this->fields[$fieldName]); }
[ "public", "function", "HasField", "(", "$", "fieldOrFieldName", "=", "NULL", ")", "{", "$", "fieldName", "=", "NULL", ";", "if", "(", "$", "fieldOrFieldName", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IField", ")", "{", "$", "fieldName", "=", "$", "fieldOrFieldName", "->", "GetName", "(", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "fieldOrFieldName", ")", ")", "{", "$", "fieldName", "=", "$", "fieldOrFieldName", ";", "}", "return", "isset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ";", "}" ]
If `TRUE` if given field instance or given field name exists in form, `FALSE` otherwise. @param \MvcCore\Ext\Forms\IField|string $fieldOrFieldName @return bool
[ "If", "TRUE", "if", "given", "field", "instance", "or", "given", "field", "name", "exists", "in", "form", "FALSE", "otherwise", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L94-L102
238,114
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & RemoveField ($fieldOrFieldName = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ if ($this->dispatchState < 1) $this->Init(); $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } if (isset($this->fields[$fieldName])) unset($this->fields[$fieldName]); return $this; }
php
public function & RemoveField ($fieldOrFieldName = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ if ($this->dispatchState < 1) $this->Init(); $fieldName = NULL; if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) { $fieldName = $fieldOrFieldName->GetName(); } else if (is_string($fieldOrFieldName)) { $fieldName = $fieldOrFieldName; } if (isset($this->fields[$fieldName])) unset($this->fields[$fieldName]); return $this; }
[ "public", "function", "&", "RemoveField", "(", "$", "fieldOrFieldName", "=", "NULL", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "if", "(", "$", "this", "->", "dispatchState", "<", "1", ")", "$", "this", "->", "Init", "(", ")", ";", "$", "fieldName", "=", "NULL", ";", "if", "(", "$", "fieldOrFieldName", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IField", ")", "{", "$", "fieldName", "=", "$", "fieldOrFieldName", "->", "GetName", "(", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "fieldOrFieldName", ")", ")", "{", "$", "fieldName", "=", "$", "fieldOrFieldName", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ")", "unset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ";", "return", "$", "this", ";", "}" ]
Remove configured form field instance by given instance or given field name. If field is not found by it's name, no error happened. @param \MvcCore\Ext\Forms\IField|string $fieldOrFieldName @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Remove", "configured", "form", "field", "instance", "by", "given", "instance", "or", "given", "field", "name", ".", "If", "field", "is", "not", "found", "by", "it", "s", "name", "no", "error", "happened", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L110-L122
238,115
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & GetField ($fieldName = '') { $result = NULL; if (isset($this->fields[$fieldName])) $result = & $this->fields[$fieldName]; return $result; }
php
public function & GetField ($fieldName = '') { $result = NULL; if (isset($this->fields[$fieldName])) $result = & $this->fields[$fieldName]; return $result; }
[ "public", "function", "&", "GetField", "(", "$", "fieldName", "=", "''", ")", "{", "$", "result", "=", "NULL", ";", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ")", "$", "result", "=", "&", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ";", "return", "$", "result", ";", "}" ]
Return form field instance by form field name if it exists, else return null; @param string $fieldName @return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField|NULL
[ "Return", "form", "field", "instance", "by", "form", "field", "name", "if", "it", "exists", "else", "return", "null", ";" ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L129-L134
238,116
mvccore/ext-form
src/MvcCore/Ext/Form/FieldMethods.php
FieldMethods.&
public function & GetFirstFieldByType ($fieldType = '') { $result = NULL; foreach ($this->fields as & $field) { if ($field->GetType() == $fieldType) { $result = & $field; } } return $result; }
php
public function & GetFirstFieldByType ($fieldType = '') { $result = NULL; foreach ($this->fields as & $field) { if ($field->GetType() == $fieldType) { $result = & $field; } } return $result; }
[ "public", "function", "&", "GetFirstFieldByType", "(", "$", "fieldType", "=", "''", ")", "{", "$", "result", "=", "NULL", ";", "foreach", "(", "$", "this", "->", "fields", "as", "&", "$", "field", ")", "{", "if", "(", "$", "field", "->", "GetType", "(", ")", "==", "$", "fieldType", ")", "{", "$", "result", "=", "&", "$", "field", ";", "}", "}", "return", "$", "result", ";", "}" ]
Return first caught form field instance by given field type string. If no field found, `NULL` is returned. @param string $fieldType @return \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField|NULL
[ "Return", "first", "caught", "form", "field", "instance", "by", "given", "field", "type", "string", ".", "If", "no", "field", "found", "NULL", "is", "returned", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/FieldMethods.php#L158-L166
238,117
lamjack/php-tools
lib/Util/Date.php
Date.friendly
public static function friendly($time) { $now = time(); $delta = abs($time - $now); if ($delta < self::MINUTE) { return $delta === self::SECOND ? 'one second age' : ['%num% second ago', $delta]; } if ($delta < 2 * self::MINUTE) { return 'a minute ago'; } if ($delta < 45 * self::MINUTE) { return ['%num% minutes ago', (int)($delta / self::MINUTE)]; } if ($delta < 90 * self::MINUTE) { return 'an hour ago'; } if ($delta < 24 * self::HOUR) { return ['%num% hours ago', (int)($delta / self::HOUR)]; } if ($delta < 48 * self::HOUR) { return 'yesterday'; } if ($delta < self::MONTH) { return ['%num% days ago', (int)($delta / self::DAY)]; } if ($delta < self::YEAR) { $months = (int)($delta / self::MONTH); return $months <= 1 ? 'one month ago' : ['%num% months ago', $months]; } $years = (int)($delta / self::YEAR); return $years <= 1 ? 'one year ago' : ['%num% years ago', $years]; }
php
public static function friendly($time) { $now = time(); $delta = abs($time - $now); if ($delta < self::MINUTE) { return $delta === self::SECOND ? 'one second age' : ['%num% second ago', $delta]; } if ($delta < 2 * self::MINUTE) { return 'a minute ago'; } if ($delta < 45 * self::MINUTE) { return ['%num% minutes ago', (int)($delta / self::MINUTE)]; } if ($delta < 90 * self::MINUTE) { return 'an hour ago'; } if ($delta < 24 * self::HOUR) { return ['%num% hours ago', (int)($delta / self::HOUR)]; } if ($delta < 48 * self::HOUR) { return 'yesterday'; } if ($delta < self::MONTH) { return ['%num% days ago', (int)($delta / self::DAY)]; } if ($delta < self::YEAR) { $months = (int)($delta / self::MONTH); return $months <= 1 ? 'one month ago' : ['%num% months ago', $months]; } $years = (int)($delta / self::YEAR); return $years <= 1 ? 'one year ago' : ['%num% years ago', $years]; }
[ "public", "static", "function", "friendly", "(", "$", "time", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "delta", "=", "abs", "(", "$", "time", "-", "$", "now", ")", ";", "if", "(", "$", "delta", "<", "self", "::", "MINUTE", ")", "{", "return", "$", "delta", "===", "self", "::", "SECOND", "?", "'one second age'", ":", "[", "'%num% second ago'", ",", "$", "delta", "]", ";", "}", "if", "(", "$", "delta", "<", "2", "*", "self", "::", "MINUTE", ")", "{", "return", "'a minute ago'", ";", "}", "if", "(", "$", "delta", "<", "45", "*", "self", "::", "MINUTE", ")", "{", "return", "[", "'%num% minutes ago'", ",", "(", "int", ")", "(", "$", "delta", "/", "self", "::", "MINUTE", ")", "]", ";", "}", "if", "(", "$", "delta", "<", "90", "*", "self", "::", "MINUTE", ")", "{", "return", "'an hour ago'", ";", "}", "if", "(", "$", "delta", "<", "24", "*", "self", "::", "HOUR", ")", "{", "return", "[", "'%num% hours ago'", ",", "(", "int", ")", "(", "$", "delta", "/", "self", "::", "HOUR", ")", "]", ";", "}", "if", "(", "$", "delta", "<", "48", "*", "self", "::", "HOUR", ")", "{", "return", "'yesterday'", ";", "}", "if", "(", "$", "delta", "<", "self", "::", "MONTH", ")", "{", "return", "[", "'%num% days ago'", ",", "(", "int", ")", "(", "$", "delta", "/", "self", "::", "DAY", ")", "]", ";", "}", "if", "(", "$", "delta", "<", "self", "::", "YEAR", ")", "{", "$", "months", "=", "(", "int", ")", "(", "$", "delta", "/", "self", "::", "MONTH", ")", ";", "return", "$", "months", "<=", "1", "?", "'one month ago'", ":", "[", "'%num% months ago'", ",", "$", "months", "]", ";", "}", "$", "years", "=", "(", "int", ")", "(", "$", "delta", "/", "self", "::", "YEAR", ")", ";", "return", "$", "years", "<=", "1", "?", "'one year ago'", ":", "[", "'%num% years ago'", ",", "$", "years", "]", ";", "}" ]
get friendly time string @param int $time @return array|string
[ "get", "friendly", "time", "string" ]
f7d9ffa17312dc2378003e8f917543adc95dddbd
https://github.com/lamjack/php-tools/blob/f7d9ffa17312dc2378003e8f917543adc95dddbd/lib/Util/Date.php#L61-L101
238,118
drmvc/database
src/Database/Drivers/Mysql.php
Mysql.genDsn
public function genDsn($config): string { // Parse config $dsn = ''; foreach ($config as $key => $value) { if (\in_array($key, self::AVAILABLE_OPTIONS, false)) { $dsn .= "$key=$value;"; } } // Get driver of connection $driver = strtolower($config['driver']); return "$driver:$dsn"; }
php
public function genDsn($config): string { // Parse config $dsn = ''; foreach ($config as $key => $value) { if (\in_array($key, self::AVAILABLE_OPTIONS, false)) { $dsn .= "$key=$value;"; } } // Get driver of connection $driver = strtolower($config['driver']); return "$driver:$dsn"; }
[ "public", "function", "genDsn", "(", "$", "config", ")", ":", "string", "{", "// Parse config", "$", "dsn", "=", "''", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "\\", "in_array", "(", "$", "key", ",", "self", "::", "AVAILABLE_OPTIONS", ",", "false", ")", ")", "{", "$", "dsn", ".=", "\"$key=$value;\"", ";", "}", "}", "// Get driver of connection", "$", "driver", "=", "strtolower", "(", "$", "config", "[", "'driver'", "]", ")", ";", "return", "\"$driver:$dsn\"", ";", "}" ]
Generate DSN by parameters in config @param array $config @return string
[ "Generate", "DSN", "by", "parameters", "in", "config" ]
c6b4589d37743edef71b851c9176365956a73c80
https://github.com/drmvc/database/blob/c6b4589d37743edef71b851c9176365956a73c80/src/Database/Drivers/Mysql.php#L40-L54
238,119
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.buildStates
private function buildStates(): array { $states = []; foreach ($this->getOffsetFromArray($this->schema, 'states', []) as $state) { $states[] = new State( $this->getOffsetFromArray($state, 'name'), $this->buildEvents($state), $this->getAdditionalFromArray($state, ['events', 'name']) ); } return $states; }
php
private function buildStates(): array { $states = []; foreach ($this->getOffsetFromArray($this->schema, 'states', []) as $state) { $states[] = new State( $this->getOffsetFromArray($state, 'name'), $this->buildEvents($state), $this->getAdditionalFromArray($state, ['events', 'name']) ); } return $states; }
[ "private", "function", "buildStates", "(", ")", ":", "array", "{", "$", "states", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "this", "->", "schema", ",", "'states'", ",", "[", "]", ")", "as", "$", "state", ")", "{", "$", "states", "[", "]", "=", "new", "State", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "state", ",", "'name'", ")", ",", "$", "this", "->", "buildEvents", "(", "$", "state", ")", ",", "$", "this", "->", "getAdditionalFromArray", "(", "$", "state", ",", "[", "'events'", ",", "'name'", "]", ")", ")", ";", "}", "return", "$", "states", ";", "}" ]
Build states for process @return array
[ "Build", "states", "for", "process" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L72-L84
238,120
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.buildEvents
private function buildEvents(array $state): array { $events = []; foreach ($this->getOffsetFromArray($state, 'events', []) as $event) { $events[] = new Event( $this->getOffsetFromArray($event, 'name'), $this->getOffsetFromArray($event, 'targetState'), $this->getOffsetFromArray($event, 'errorState'), $this->getOffsetFromArray($event, 'command'), $this->getAdditionalFromArray($event, ['name', 'command', 'targetState', 'errorState']) ); } return $events; }
php
private function buildEvents(array $state): array { $events = []; foreach ($this->getOffsetFromArray($state, 'events', []) as $event) { $events[] = new Event( $this->getOffsetFromArray($event, 'name'), $this->getOffsetFromArray($event, 'targetState'), $this->getOffsetFromArray($event, 'errorState'), $this->getOffsetFromArray($event, 'command'), $this->getAdditionalFromArray($event, ['name', 'command', 'targetState', 'errorState']) ); } return $events; }
[ "private", "function", "buildEvents", "(", "array", "$", "state", ")", ":", "array", "{", "$", "events", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "state", ",", "'events'", ",", "[", "]", ")", "as", "$", "event", ")", "{", "$", "events", "[", "]", "=", "new", "Event", "(", "$", "this", "->", "getOffsetFromArray", "(", "$", "event", ",", "'name'", ")", ",", "$", "this", "->", "getOffsetFromArray", "(", "$", "event", ",", "'targetState'", ")", ",", "$", "this", "->", "getOffsetFromArray", "(", "$", "event", ",", "'errorState'", ")", ",", "$", "this", "->", "getOffsetFromArray", "(", "$", "event", ",", "'command'", ")", ",", "$", "this", "->", "getAdditionalFromArray", "(", "$", "event", ",", "[", "'name'", ",", "'command'", ",", "'targetState'", ",", "'errorState'", "]", ")", ")", ";", "}", "return", "$", "events", ";", "}" ]
Build state events @param array $state @return Event[]
[ "Build", "state", "events" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L93-L107
238,121
potfur/statemachine
src/StateMachine/ArrayFactory.php
ArrayFactory.getProcess
public function getProcess(): Process { if ($this->process === null) { $this->process = new Process( $this->getSchemaName(), $this->getInitialState(), $this->buildStates() ); } return $this->process; }
php
public function getProcess(): Process { if ($this->process === null) { $this->process = new Process( $this->getSchemaName(), $this->getInitialState(), $this->buildStates() ); } return $this->process; }
[ "public", "function", "getProcess", "(", ")", ":", "Process", "{", "if", "(", "$", "this", "->", "process", "===", "null", ")", "{", "$", "this", "->", "process", "=", "new", "Process", "(", "$", "this", "->", "getSchemaName", "(", ")", ",", "$", "this", "->", "getInitialState", "(", ")", ",", "$", "this", "->", "buildStates", "(", ")", ")", ";", "}", "return", "$", "this", "->", "process", ";", "}" ]
Return schema process @return Process
[ "Return", "schema", "process" ]
6b68535e6c94b10bf618a7809a48f6a8f6d30deb
https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/ArrayFactory.php#L114-L125
238,122
ironedgesoftware/file-utils
src/File/Base.php
Base.load
public function load($refresh = false, array $options = array()) { if ($refresh || $this->_contents === null) { $this->_contents = @file_get_contents($this->_path); if ($this->_contents === false) { throw LoadException::create($this->_path); } $this->setContents($this->decode($options)); } return $this; }
php
public function load($refresh = false, array $options = array()) { if ($refresh || $this->_contents === null) { $this->_contents = @file_get_contents($this->_path); if ($this->_contents === false) { throw LoadException::create($this->_path); } $this->setContents($this->decode($options)); } return $this; }
[ "public", "function", "load", "(", "$", "refresh", "=", "false", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "refresh", "||", "$", "this", "->", "_contents", "===", "null", ")", "{", "$", "this", "->", "_contents", "=", "@", "file_get_contents", "(", "$", "this", "->", "_path", ")", ";", "if", "(", "$", "this", "->", "_contents", "===", "false", ")", "{", "throw", "LoadException", "::", "create", "(", "$", "this", "->", "_path", ")", ";", "}", "$", "this", "->", "setContents", "(", "$", "this", "->", "decode", "(", "$", "options", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Opens a file. @param bool $refresh - If this is true then the file will be open even if it was open before. @param array $options - Options. @throws LoadException @return $this
[ "Opens", "a", "file", "." ]
d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb
https://github.com/ironedgesoftware/file-utils/blob/d9f79d6f23db0e5ccb147b4d1fdbccbb70bd5beb/src/File/Base.php#L159-L172
238,123
yftzeng/phpWowLog
patch/monolog/Logger.php
Logger.pushHandler
public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); if ($this->_startTime === null) { $this->_startTime = microtime(true); $this->_previousRecordTime = $this->_startTime; } }
php
public function pushHandler(HandlerInterface $handler) { array_unshift($this->handlers, $handler); if ($this->_startTime === null) { $this->_startTime = microtime(true); $this->_previousRecordTime = $this->_startTime; } }
[ "public", "function", "pushHandler", "(", "HandlerInterface", "$", "handler", ")", "{", "array_unshift", "(", "$", "this", "->", "handlers", ",", "$", "handler", ")", ";", "if", "(", "$", "this", "->", "_startTime", "===", "null", ")", "{", "$", "this", "->", "_startTime", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "_previousRecordTime", "=", "$", "this", "->", "_startTime", ";", "}", "}" ]
Pushes a handler on to the stack. @param HandlerInterface $handler
[ "Pushes", "a", "handler", "on", "to", "the", "stack", "." ]
0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082
https://github.com/yftzeng/phpWowLog/blob/0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082/patch/monolog/Logger.php#L111-L118
238,124
yftzeng/phpWowLog
patch/monolog/Logger.php
Logger.isHandling
public function isHandling($level) { $record = array( 'message' => '', 'context' => array(), 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => new \DateTime(), 'extra' => array(), ); foreach ($this->handlers as $key => $handler) { if ($handler->isHandling($record)) { return true; } } return false; }
php
public function isHandling($level) { $record = array( 'message' => '', 'context' => array(), 'level' => $level, 'level_name' => self::getLevelName($level), 'channel' => $this->name, 'datetime' => new \DateTime(), 'extra' => array(), ); foreach ($this->handlers as $key => $handler) { if ($handler->isHandling($record)) { return true; } } return false; }
[ "public", "function", "isHandling", "(", "$", "level", ")", "{", "$", "record", "=", "array", "(", "'message'", "=>", "''", ",", "'context'", "=>", "array", "(", ")", ",", "'level'", "=>", "$", "level", ",", "'level_name'", "=>", "self", "::", "getLevelName", "(", "$", "level", ")", ",", "'channel'", "=>", "$", "this", "->", "name", ",", "'datetime'", "=>", "new", "\\", "DateTime", "(", ")", ",", "'extra'", "=>", "array", "(", ")", ",", ")", ";", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "key", "=>", "$", "handler", ")", "{", "if", "(", "$", "handler", "->", "isHandling", "(", "$", "record", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks whether the Logger has a handler that listens on the given level @param integer $level @return Boolean
[ "Checks", "whether", "the", "Logger", "has", "a", "handler", "that", "listens", "on", "the", "given", "level" ]
0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082
https://github.com/yftzeng/phpWowLog/blob/0d2e7943bcce0f40c1e2a2aa74090cb2fa27d082/patch/monolog/Logger.php#L297-L316
238,125
lciolecki/zf-extensions-library
library/Extlib/Session/SaveHandler/Cache.php
Cache.normalizeId
protected function normalizeId($id) { if (null !== $this->getSessionPrefix()) { return $this->getSessionPrefix() . self::ID_SEPARATOR . $id; } return $id; }
php
protected function normalizeId($id) { if (null !== $this->getSessionPrefix()) { return $this->getSessionPrefix() . self::ID_SEPARATOR . $id; } return $id; }
[ "protected", "function", "normalizeId", "(", "$", "id", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "getSessionPrefix", "(", ")", ")", "{", "return", "$", "this", "->", "getSessionPrefix", "(", ")", ".", "self", "::", "ID_SEPARATOR", ".", "$", "id", ";", "}", "return", "$", "id", ";", "}" ]
Method prepare id @param string $id @return string
[ "Method", "prepare", "id" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Session/SaveHandler/Cache.php#L220-L227
238,126
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.computeSingleDocumentChangeSet
private function computeSingleDocumentChangeSet($document) { $state = $this->getDocumentState($document); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Document has to be managed or scheduled for removal for single computation " . self::objToStr($document)); } $class = $this->dm->getClassMetadata(get_class($document)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($document); } // Compute changes for INSERTed and UPSERTed documents first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); $this->computeScheduleUpsertsChangeSets(); // Ignore uninitialized proxy objects if ($document instanceof Proxy && ! $document->__isInitialized__) { return; } // Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here. $oid = spl_object_hash($document); if ( ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid]) && ! isset($this->documentDeletions[$oid]) && isset($this->documentStates[$oid]) ) { $this->computeChangeSet($class, $document); } }
php
private function computeSingleDocumentChangeSet($document) { $state = $this->getDocumentState($document); if ($state !== self::STATE_MANAGED && $state !== self::STATE_REMOVED) { throw new \InvalidArgumentException("Document has to be managed or scheduled for removal for single computation " . self::objToStr($document)); } $class = $this->dm->getClassMetadata(get_class($document)); if ($state === self::STATE_MANAGED && $class->isChangeTrackingDeferredImplicit()) { $this->persist($document); } // Compute changes for INSERTed and UPSERTed documents first. This must always happen even in this case. $this->computeScheduleInsertsChangeSets(); $this->computeScheduleUpsertsChangeSets(); // Ignore uninitialized proxy objects if ($document instanceof Proxy && ! $document->__isInitialized__) { return; } // Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here. $oid = spl_object_hash($document); if ( ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid]) && ! isset($this->documentDeletions[$oid]) && isset($this->documentStates[$oid]) ) { $this->computeChangeSet($class, $document); } }
[ "private", "function", "computeSingleDocumentChangeSet", "(", "$", "document", ")", "{", "$", "state", "=", "$", "this", "->", "getDocumentState", "(", "$", "document", ")", ";", "if", "(", "$", "state", "!==", "self", "::", "STATE_MANAGED", "&&", "$", "state", "!==", "self", "::", "STATE_REMOVED", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Document has to be managed or scheduled for removal for single computation \"", ".", "self", "::", "objToStr", "(", "$", "document", ")", ")", ";", "}", "$", "class", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "document", ")", ")", ";", "if", "(", "$", "state", "===", "self", "::", "STATE_MANAGED", "&&", "$", "class", "->", "isChangeTrackingDeferredImplicit", "(", ")", ")", "{", "$", "this", "->", "persist", "(", "$", "document", ")", ";", "}", "// Compute changes for INSERTed and UPSERTed documents first. This must always happen even in this case.", "$", "this", "->", "computeScheduleInsertsChangeSets", "(", ")", ";", "$", "this", "->", "computeScheduleUpsertsChangeSets", "(", ")", ";", "// Ignore uninitialized proxy objects", "if", "(", "$", "document", "instanceof", "Proxy", "&&", "!", "$", "document", "->", "__isInitialized__", ")", "{", "return", ";", "}", "// Only MANAGED documents that are NOT SCHEDULED FOR INSERTION, UPSERT OR DELETION are processed here.", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "documentInsertions", "[", "$", "oid", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "documentUpserts", "[", "$", "oid", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "documentDeletions", "[", "$", "oid", "]", ")", "&&", "isset", "(", "$", "this", "->", "documentStates", "[", "$", "oid", "]", ")", ")", "{", "$", "this", "->", "computeChangeSet", "(", "$", "class", ",", "$", "document", ")", ";", "}", "}" ]
Only flush the given document according to a ruleset that keeps the UoW consistent. 1. All documents scheduled for insertion, (orphan) removals and changes in collections are processed as well! 2. Proxies are skipped. 3. Only if document is properly managed. @param object $document @throws \InvalidArgumentException If the document is not STATE_MANAGED @return void
[ "Only", "flush", "the", "given", "document", "according", "to", "a", "ruleset", "that", "keeps", "the", "UoW", "consistent", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L542-L575
238,127
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.executeExtraUpdates
private function executeExtraUpdates(array $options) { foreach ($this->extraUpdates as $oid => $update) { list ($document, $changeset) = $update; $this->documentChangeSets[$oid] = $changeset; $this->getDocumentPersister(get_class($document))->update($document, $options); } }
php
private function executeExtraUpdates(array $options) { foreach ($this->extraUpdates as $oid => $update) { list ($document, $changeset) = $update; $this->documentChangeSets[$oid] = $changeset; $this->getDocumentPersister(get_class($document))->update($document, $options); } }
[ "private", "function", "executeExtraUpdates", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "this", "->", "extraUpdates", "as", "$", "oid", "=>", "$", "update", ")", "{", "list", "(", "$", "document", ",", "$", "changeset", ")", "=", "$", "update", ";", "$", "this", "->", "documentChangeSets", "[", "$", "oid", "]", "=", "$", "changeset", ";", "$", "this", "->", "getDocumentPersister", "(", "get_class", "(", "$", "document", ")", ")", "->", "update", "(", "$", "document", ",", "$", "options", ")", ";", "}", "}" ]
Executes reference updates
[ "Executes", "reference", "updates" ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L580-L587
238,128
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getDocumentChangeSet
public function getDocumentChangeSet($document) { $oid = spl_object_hash($document); if (isset($this->documentChangeSets[$oid])) { return $this->documentChangeSets[$oid]; } return array(); }
php
public function getDocumentChangeSet($document) { $oid = spl_object_hash($document); if (isset($this->documentChangeSets[$oid])) { return $this->documentChangeSets[$oid]; } return array(); }
[ "public", "function", "getDocumentChangeSet", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "documentChangeSets", "[", "$", "oid", "]", ")", ")", "{", "return", "$", "this", "->", "documentChangeSets", "[", "$", "oid", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
Gets the changeset for a document. @param object $document @return array
[ "Gets", "the", "changeset", "for", "a", "document", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L595-L602
238,129
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleForUpdate
public function scheduleForUpdate($document) { $oid = spl_object_hash($document); if ( ! isset($this->documentIdentifiers[$oid])) { throw new \InvalidArgumentException("Document has no identity."); } if (isset($this->documentDeletions[$oid])) { throw new \InvalidArgumentException("Document is removed."); } if ( ! isset($this->documentUpdates[$oid]) && ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid])) { $this->documentUpdates[$oid] = $document; } }
php
public function scheduleForUpdate($document) { $oid = spl_object_hash($document); if ( ! isset($this->documentIdentifiers[$oid])) { throw new \InvalidArgumentException("Document has no identity."); } if (isset($this->documentDeletions[$oid])) { throw new \InvalidArgumentException("Document is removed."); } if ( ! isset($this->documentUpdates[$oid]) && ! isset($this->documentInsertions[$oid]) && ! isset($this->documentUpserts[$oid])) { $this->documentUpdates[$oid] = $document; } }
[ "public", "function", "scheduleForUpdate", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "documentIdentifiers", "[", "$", "oid", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Document has no identity.\"", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "documentDeletions", "[", "$", "oid", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Document is removed.\"", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "documentUpdates", "[", "$", "oid", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "documentInsertions", "[", "$", "oid", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "documentUpserts", "[", "$", "oid", "]", ")", ")", "{", "$", "this", "->", "documentUpdates", "[", "$", "oid", "]", "=", "$", "document", ";", "}", "}" ]
Schedules a document for being updated. @param object $document The document to schedule for being updated. @throws \InvalidArgumentException
[ "Schedules", "a", "document", "for", "being", "updated", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1514-L1527
238,130
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.cascadePreRemove
private function cascadePreRemove(ClassMetadata $class, $document) { $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preRemove])) { $entryClass->invokeLifecycleCallbacks(Events::preRemove, $entry); } if ($hasPreRemoveListeners) { $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entry, $this->dm)); } $this->cascadePreRemove($entryClass, $entry); } } } }
php
private function cascadePreRemove(ClassMetadata $class, $document) { $hasPreRemoveListeners = $this->evm->hasListeners(Events::preRemove); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preRemove])) { $entryClass->invokeLifecycleCallbacks(Events::preRemove, $entry); } if ($hasPreRemoveListeners) { $this->evm->dispatchEvent(Events::preRemove, new LifecycleEventArgs($entry, $this->dm)); } $this->cascadePreRemove($entryClass, $entry); } } } }
[ "private", "function", "cascadePreRemove", "(", "ClassMetadata", "$", "class", ",", "$", "document", ")", "{", "$", "hasPreRemoveListeners", "=", "$", "this", "->", "evm", "->", "hasListeners", "(", "Events", "::", "preRemove", ")", ";", "foreach", "(", "$", "class", "->", "fieldMappings", "as", "$", "mapping", ")", "{", "if", "(", "isset", "(", "$", "mapping", "[", "'embedded'", "]", ")", ")", "{", "$", "value", "=", "$", "class", "->", "reflFields", "[", "$", "mapping", "[", "'fieldName'", "]", "]", "->", "getValue", "(", "$", "document", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "continue", ";", "}", "if", "(", "$", "mapping", "[", "'type'", "]", "===", "'one'", ")", "{", "$", "value", "=", "array", "(", "$", "value", ")", ";", "}", "foreach", "(", "$", "value", "as", "$", "entry", ")", "{", "$", "entryClass", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "entry", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "entryClass", "->", "lifecycleCallbacks", "[", "Events", "::", "preRemove", "]", ")", ")", "{", "$", "entryClass", "->", "invokeLifecycleCallbacks", "(", "Events", "::", "preRemove", ",", "$", "entry", ")", ";", "}", "if", "(", "$", "hasPreRemoveListeners", ")", "{", "$", "this", "->", "evm", "->", "dispatchEvent", "(", "Events", "::", "preRemove", ",", "new", "LifecycleEventArgs", "(", "$", "entry", ",", "$", "this", "->", "dm", ")", ")", ";", "}", "$", "this", "->", "cascadePreRemove", "(", "$", "entryClass", ",", "$", "entry", ")", ";", "}", "}", "}", "}" ]
Cascades the preRemove event to embedded documents. @param ClassMetadata $class @param object $document
[ "Cascades", "the", "preRemove", "event", "to", "embedded", "documents", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2012-L2037
238,131
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.cascadePreLoad
private function cascadePreLoad(ClassMetadata $class, $document, $data) { $hasPreLoadListeners = $this->evm->hasListeners(Events::preLoad); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $entryClass->invokeLifecycleCallbacks(Events::preLoad, $entry, $args); } if ($hasPreLoadListeners) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($entry, $this->dm, $data[$mapping['name']])); } $this->cascadePreLoad($entryClass, $entry, $data[$mapping['name']]); } } } }
php
private function cascadePreLoad(ClassMetadata $class, $document, $data) { $hasPreLoadListeners = $this->evm->hasListeners(Events::preLoad); foreach ($class->fieldMappings as $mapping) { if (isset($mapping['embedded'])) { $value = $class->reflFields[$mapping['fieldName']]->getValue($document); if ($value === null) { continue; } if ($mapping['type'] === 'one') { $value = array($value); } foreach ($value as $entry) { $entryClass = $this->dm->getClassMetadata(get_class($entry)); if ( ! empty($entryClass->lifecycleCallbacks[Events::preLoad])) { $args = array(&$data); $entryClass->invokeLifecycleCallbacks(Events::preLoad, $entry, $args); } if ($hasPreLoadListeners) { $this->evm->dispatchEvent(Events::preLoad, new PreLoadEventArgs($entry, $this->dm, $data[$mapping['name']])); } $this->cascadePreLoad($entryClass, $entry, $data[$mapping['name']]); } } } }
[ "private", "function", "cascadePreLoad", "(", "ClassMetadata", "$", "class", ",", "$", "document", ",", "$", "data", ")", "{", "$", "hasPreLoadListeners", "=", "$", "this", "->", "evm", "->", "hasListeners", "(", "Events", "::", "preLoad", ")", ";", "foreach", "(", "$", "class", "->", "fieldMappings", "as", "$", "mapping", ")", "{", "if", "(", "isset", "(", "$", "mapping", "[", "'embedded'", "]", ")", ")", "{", "$", "value", "=", "$", "class", "->", "reflFields", "[", "$", "mapping", "[", "'fieldName'", "]", "]", "->", "getValue", "(", "$", "document", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "continue", ";", "}", "if", "(", "$", "mapping", "[", "'type'", "]", "===", "'one'", ")", "{", "$", "value", "=", "array", "(", "$", "value", ")", ";", "}", "foreach", "(", "$", "value", "as", "$", "entry", ")", "{", "$", "entryClass", "=", "$", "this", "->", "dm", "->", "getClassMetadata", "(", "get_class", "(", "$", "entry", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "entryClass", "->", "lifecycleCallbacks", "[", "Events", "::", "preLoad", "]", ")", ")", "{", "$", "args", "=", "array", "(", "&", "$", "data", ")", ";", "$", "entryClass", "->", "invokeLifecycleCallbacks", "(", "Events", "::", "preLoad", ",", "$", "entry", ",", "$", "args", ")", ";", "}", "if", "(", "$", "hasPreLoadListeners", ")", "{", "$", "this", "->", "evm", "->", "dispatchEvent", "(", "Events", "::", "preLoad", ",", "new", "PreLoadEventArgs", "(", "$", "entry", ",", "$", "this", "->", "dm", ",", "$", "data", "[", "$", "mapping", "[", "'name'", "]", "]", ")", ")", ";", "}", "$", "this", "->", "cascadePreLoad", "(", "$", "entryClass", ",", "$", "entry", ",", "$", "data", "[", "$", "mapping", "[", "'name'", "]", "]", ")", ";", "}", "}", "}", "}" ]
Cascades the preLoad event to embedded documents. @param ClassMetadata $class @param object $document @param array $data
[ "Cascades", "the", "preLoad", "event", "to", "embedded", "documents", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2813-L2839
238,132
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getOriginalDocumentData
public function getOriginalDocumentData($document) { $oid = spl_object_hash($document); if (isset($this->originalDocumentData[$oid])) { return $this->originalDocumentData[$oid]; } return array(); }
php
public function getOriginalDocumentData($document) { $oid = spl_object_hash($document); if (isset($this->originalDocumentData[$oid])) { return $this->originalDocumentData[$oid]; } return array(); }
[ "public", "function", "getOriginalDocumentData", "(", "$", "document", ")", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "originalDocumentData", "[", "$", "oid", "]", ")", ")", "{", "return", "$", "this", "->", "originalDocumentData", "[", "$", "oid", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
Gets the original data of a document. The original data is the data that was present at the time the document was reconstituted from the database. @param object $document @return array
[ "Gets", "the", "original", "data", "of", "a", "document", ".", "The", "original", "data", "is", "the", "data", "that", "was", "present", "at", "the", "time", "the", "document", "was", "reconstituted", "from", "the", "database", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2868-L2875
238,133
squire-assistant/console
Event/ConsoleErrorEvent.php
ConsoleErrorEvent.setExitCode
public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); }
php
public function setExitCode($exitCode) { $this->exitCode = (int) $exitCode; $r = new \ReflectionProperty($this->error, 'code'); $r->setAccessible(true); $r->setValue($this->error, $this->exitCode); }
[ "public", "function", "setExitCode", "(", "$", "exitCode", ")", "{", "$", "this", "->", "exitCode", "=", "(", "int", ")", "$", "exitCode", ";", "$", "r", "=", "new", "\\", "ReflectionProperty", "(", "$", "this", "->", "error", ",", "'code'", ")", ";", "$", "r", "->", "setAccessible", "(", "true", ")", ";", "$", "r", "->", "setValue", "(", "$", "this", "->", "error", ",", "$", "this", "->", "exitCode", ")", ";", "}" ]
Sets the exit code. @param int $exitCode The command exit code
[ "Sets", "the", "exit", "code", "." ]
9e16b975a3b9403af52e2d1b465a625e8936076c
https://github.com/squire-assistant/console/blob/9e16b975a3b9403af52e2d1b465a625e8936076c/Event/ConsoleErrorEvent.php#L65-L72
238,134
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.index
public function index(PortfolioRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Portfolio\Repositories\Presenter\PortfolioPresenter::class) ->$function(); } $portfolios = $this->repository->paginate(); return $this->response->title(trans('portfolio::portfolio.names')) ->view('portfolio::portfolio.index', true) ->data(compact('portfolios')) ->output(); }
php
public function index(PortfolioRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\Portfolio\Repositories\Presenter\PortfolioPresenter::class) ->$function(); } $portfolios = $this->repository->paginate(); return $this->response->title(trans('portfolio::portfolio.names')) ->view('portfolio::portfolio.index', true) ->data(compact('portfolios')) ->output(); }
[ "public", "function", "index", "(", "PortfolioRequest", "$", "request", ")", "{", "$", "view", "=", "$", "this", "->", "response", "->", "theme", "->", "listView", "(", ")", ";", "if", "(", "$", "this", "->", "response", "->", "typeIs", "(", "'json'", ")", ")", "{", "$", "function", "=", "camel_case", "(", "'get-'", ".", "$", "view", ")", ";", "return", "$", "this", "->", "repository", "->", "setPresenter", "(", "\\", "Litecms", "\\", "Portfolio", "\\", "Repositories", "\\", "Presenter", "\\", "PortfolioPresenter", "::", "class", ")", "->", "$", "function", "(", ")", ";", "}", "$", "portfolios", "=", "$", "this", "->", "repository", "->", "paginate", "(", ")", ";", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'portfolio::portfolio.names'", ")", ")", "->", "view", "(", "'portfolio::portfolio.index'", ",", "true", ")", "->", "data", "(", "compact", "(", "'portfolios'", ")", ")", "->", "output", "(", ")", ";", "}" ]
Display a list of portfolio. @return Response
[ "Display", "a", "list", "of", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L38-L55
238,135
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.show
public function show(PortfolioRequest $request, Portfolio $portfolio) { if ($portfolio->exists) { $view = 'portfolio::portfolio.show'; } else { $view = 'portfolio::portfolio.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio::portfolio.name')) ->data(compact('portfolio')) ->view($view, true) ->output(); }
php
public function show(PortfolioRequest $request, Portfolio $portfolio) { if ($portfolio->exists) { $view = 'portfolio::portfolio.show'; } else { $view = 'portfolio::portfolio.new'; } return $this->response->title(trans('app.view') . ' ' . trans('portfolio::portfolio.name')) ->data(compact('portfolio')) ->view($view, true) ->output(); }
[ "public", "function", "show", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "if", "(", "$", "portfolio", "->", "exists", ")", "{", "$", "view", "=", "'portfolio::portfolio.show'", ";", "}", "else", "{", "$", "view", "=", "'portfolio::portfolio.new'", ";", "}", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.view'", ")", ".", "' '", ".", "trans", "(", "'portfolio::portfolio.name'", ")", ")", "->", "data", "(", "compact", "(", "'portfolio'", ")", ")", "->", "view", "(", "$", "view", ",", "true", ")", "->", "output", "(", ")", ";", "}" ]
Display portfolio. @param Request $request @param Model $portfolio @return Response
[ "Display", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L65-L78
238,136
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.edit
public function edit(PortfolioRequest $request, Portfolio $portfolio) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio::portfolio.name')) ->view('portfolio::portfolio.edit', true) ->data(compact('portfolio')) ->output(); }
php
public function edit(PortfolioRequest $request, Portfolio $portfolio) { return $this->response->title(trans('app.edit') . ' ' . trans('portfolio::portfolio.name')) ->view('portfolio::portfolio.edit', true) ->data(compact('portfolio')) ->output(); }
[ "public", "function", "edit", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "return", "$", "this", "->", "response", "->", "title", "(", "trans", "(", "'app.edit'", ")", ".", "' '", ".", "trans", "(", "'portfolio::portfolio.name'", ")", ")", "->", "view", "(", "'portfolio::portfolio.edit'", ",", "true", ")", "->", "data", "(", "compact", "(", "'portfolio'", ")", ")", "->", "output", "(", ")", ";", "}" ]
Show portfolio for editing. @param Request $request @param Model $portfolio @return Response
[ "Show", "portfolio", "for", "editing", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L135-L141
238,137
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.update
public function update(PortfolioRequest $request, Portfolio $portfolio) { try { $attributes = $request->all(); $portfolio->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
php
public function update(PortfolioRequest $request, Portfolio $portfolio) { try { $attributes = $request->all(); $portfolio->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('portfolio::portfolio.name')])) ->code(204) ->status('success') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
[ "public", "function", "update", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "try", "{", "$", "attributes", "=", "$", "request", "->", "all", "(", ")", ";", "$", "portfolio", "->", "update", "(", "$", "attributes", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "(", "'messages.success.updated'", ",", "[", "'Module'", "=>", "trans", "(", "'portfolio::portfolio.name'", ")", "]", ")", ")", "->", "code", "(", "204", ")", "->", "status", "(", "'success'", ")", "->", "url", "(", "guard_url", "(", "'portfolio/portfolio/'", ".", "$", "portfolio", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "response", "->", "message", "(", "$", "e", "->", "getMessage", "(", ")", ")", "->", "code", "(", "400", ")", "->", "status", "(", "'error'", ")", "->", "url", "(", "guard_url", "(", "'portfolio/portfolio/'", ".", "$", "portfolio", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "}" ]
Update the portfolio. @param Request $request @param Model $portfolio @return Response
[ "Update", "the", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L151-L170
238,138
Litecms/Portfolio
src/Http/Controllers/PortfolioResourceController.php
PortfolioResourceController.destroy
public function destroy(PortfolioRequest $request, Portfolio $portfolio) { try { $portfolio->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio::portfolio.name')])) ->code(202) ->status('success') ->url(guard_url('portfolio/portfolio/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
php
public function destroy(PortfolioRequest $request, Portfolio $portfolio) { try { $portfolio->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('portfolio::portfolio.name')])) ->code(202) ->status('success') ->url(guard_url('portfolio/portfolio/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('portfolio/portfolio/' . $portfolio->getRouteKey())) ->redirect(); } }
[ "public", "function", "destroy", "(", "PortfolioRequest", "$", "request", ",", "Portfolio", "$", "portfolio", ")", "{", "try", "{", "$", "portfolio", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "response", "->", "message", "(", "trans", "(", "'messages.success.deleted'", ",", "[", "'Module'", "=>", "trans", "(", "'portfolio::portfolio.name'", ")", "]", ")", ")", "->", "code", "(", "202", ")", "->", "status", "(", "'success'", ")", "->", "url", "(", "guard_url", "(", "'portfolio/portfolio/0'", ")", ")", "->", "redirect", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "$", "this", "->", "response", "->", "message", "(", "$", "e", "->", "getMessage", "(", ")", ")", "->", "code", "(", "400", ")", "->", "status", "(", "'error'", ")", "->", "url", "(", "guard_url", "(", "'portfolio/portfolio/'", ".", "$", "portfolio", "->", "getRouteKey", "(", ")", ")", ")", "->", "redirect", "(", ")", ";", "}", "}" ]
Remove the portfolio. @param Model $portfolio @return Response
[ "Remove", "the", "portfolio", "." ]
7d33624fbb63c21cb5315ea888da3784c15cea0e
https://github.com/Litecms/Portfolio/blob/7d33624fbb63c21cb5315ea888da3784c15cea0e/src/Http/Controllers/PortfolioResourceController.php#L179-L199
238,139
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.connect
public function connect() { $dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};"; $dsnString .= "charset={$this->dbCharset}"; /* * Try to connect to database */ try { $this->dbConnection = new \PDO( $dsnString, "{$this->dbUsername}", "{$this->dbPassword}", $this->driverOptions ); } catch (\PDOException $ex) { // Error during database connection, check params. throw new \InvalidArgumentException( __METHOD__.': '.$ex->getMessage() ); } return $this->dbConnection; }
php
public function connect() { $dsnString = "{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};"; $dsnString .= "charset={$this->dbCharset}"; /* * Try to connect to database */ try { $this->dbConnection = new \PDO( $dsnString, "{$this->dbUsername}", "{$this->dbPassword}", $this->driverOptions ); } catch (\PDOException $ex) { // Error during database connection, check params. throw new \InvalidArgumentException( __METHOD__.': '.$ex->getMessage() ); } return $this->dbConnection; }
[ "public", "function", "connect", "(", ")", "{", "$", "dsnString", "=", "\"{$this->dbDriver}:host={$this->dbHostname};dbname={$this->dbName};\"", ";", "$", "dsnString", ".=", "\"charset={$this->dbCharset}\"", ";", "/*\n * Try to connect to database\n */", "try", "{", "$", "this", "->", "dbConnection", "=", "new", "\\", "PDO", "(", "$", "dsnString", ",", "\"{$this->dbUsername}\"", ",", "\"{$this->dbPassword}\"", ",", "$", "this", "->", "driverOptions", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "ex", ")", "{", "// Error during database connection, check params.", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "': '", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}", "return", "$", "this", "->", "dbConnection", ";", "}" ]
Connect to a database by using constructor params @return PDO @throws \Exception
[ "Connect", "to", "a", "database", "by", "using", "constructor", "params" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L78-L100
238,140
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.query
public function query($queryString, array $queryValues = []) { if (!is_string($queryString) || empty($queryString)) { throw new \InvalidArgumentException( __METHOD__.': The specified query is not valid.' ); } $this->connect(); $this->resourceHandle = $this->dbConnection->prepare($queryString); try { // start transaction $this->dbConnection->beginTransaction(); // execute the query and return a status $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null); // get last inserted id if present $this->lastInsertedId = $this->dbConnection->lastInsertId(); // finally execute the query $this->dbConnection->commit(); } catch (\PDOException $ex) { // If an error occurs, execute rollback $this->dbConnection->rollBack(); // Return execution status to false $this->executionStatus = false; $this->resourceHandle->closeCursor(); throw new \RuntimeException( __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}" ); } return $this->resourceHandle; }
php
public function query($queryString, array $queryValues = []) { if (!is_string($queryString) || empty($queryString)) { throw new \InvalidArgumentException( __METHOD__.': The specified query is not valid.' ); } $this->connect(); $this->resourceHandle = $this->dbConnection->prepare($queryString); try { // start transaction $this->dbConnection->beginTransaction(); // execute the query and return a status $this->executionStatus = $this->resourceHandle->execute($queryValues ?: null); // get last inserted id if present $this->lastInsertedId = $this->dbConnection->lastInsertId(); // finally execute the query $this->dbConnection->commit(); } catch (\PDOException $ex) { // If an error occurs, execute rollback $this->dbConnection->rollBack(); // Return execution status to false $this->executionStatus = false; $this->resourceHandle->closeCursor(); throw new \RuntimeException( __METHOD__.": {$ex->getMessage()}\nqueryString: {$queryString}" ); } return $this->resourceHandle; }
[ "public", "function", "query", "(", "$", "queryString", ",", "array", "$", "queryValues", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "queryString", ")", "||", "empty", "(", "$", "queryString", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "': The specified query is not valid.'", ")", ";", "}", "$", "this", "->", "connect", "(", ")", ";", "$", "this", "->", "resourceHandle", "=", "$", "this", "->", "dbConnection", "->", "prepare", "(", "$", "queryString", ")", ";", "try", "{", "// start transaction", "$", "this", "->", "dbConnection", "->", "beginTransaction", "(", ")", ";", "// execute the query and return a status", "$", "this", "->", "executionStatus", "=", "$", "this", "->", "resourceHandle", "->", "execute", "(", "$", "queryValues", "?", ":", "null", ")", ";", "// get last inserted id if present", "$", "this", "->", "lastInsertedId", "=", "$", "this", "->", "dbConnection", "->", "lastInsertId", "(", ")", ";", "// finally execute the query", "$", "this", "->", "dbConnection", "->", "commit", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "ex", ")", "{", "// If an error occurs, execute rollback", "$", "this", "->", "dbConnection", "->", "rollBack", "(", ")", ";", "// Return execution status to false", "$", "this", "->", "executionStatus", "=", "false", ";", "$", "this", "->", "resourceHandle", "->", "closeCursor", "(", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "__METHOD__", ".", "\": {$ex->getMessage()}\\nqueryString: {$queryString}\"", ")", ";", "}", "return", "$", "this", "->", "resourceHandle", ";", "}" ]
Execute a query or a prepared statement with a params array values. @param string $queryString @param array $queryValues in format [:placeholder => 'value'] @return mixed
[ "Execute", "a", "query", "or", "a", "prepared", "statement", "with", "a", "params", "array", "values", "." ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L135-L172
238,141
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.select
public function select( $table, $conditions = null, $fields = null, $order = null, $limit = null, $offset = null ) { if (is_null($fields)) { $fields = "*"; } $queryString = "SELECT {$fields} FROM {$table} "; if (!is_null($conditions)) { $queryString .= "WHERE {$conditions} "; } if (!is_null($order)) { $queryString .= "ORDER BY {$order} "; } if (!is_null($limit)) { $queryString .= "LIMIT {$limit} "; } if (!is_null($offset) && !is_null($limit)) { $queryString .= "OFFSET {$offset} "; } $queryString .= ";"; $this->query($queryString); return $this->countRows(); }
php
public function select( $table, $conditions = null, $fields = null, $order = null, $limit = null, $offset = null ) { if (is_null($fields)) { $fields = "*"; } $queryString = "SELECT {$fields} FROM {$table} "; if (!is_null($conditions)) { $queryString .= "WHERE {$conditions} "; } if (!is_null($order)) { $queryString .= "ORDER BY {$order} "; } if (!is_null($limit)) { $queryString .= "LIMIT {$limit} "; } if (!is_null($offset) && !is_null($limit)) { $queryString .= "OFFSET {$offset} "; } $queryString .= ";"; $this->query($queryString); return $this->countRows(); }
[ "public", "function", "select", "(", "$", "table", ",", "$", "conditions", "=", "null", ",", "$", "fields", "=", "null", ",", "$", "order", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "\"*\"", ";", "}", "$", "queryString", "=", "\"SELECT {$fields} FROM {$table} \"", ";", "if", "(", "!", "is_null", "(", "$", "conditions", ")", ")", "{", "$", "queryString", ".=", "\"WHERE {$conditions} \"", ";", "}", "if", "(", "!", "is_null", "(", "$", "order", ")", ")", "{", "$", "queryString", ".=", "\"ORDER BY {$order} \"", ";", "}", "if", "(", "!", "is_null", "(", "$", "limit", ")", ")", "{", "$", "queryString", ".=", "\"LIMIT {$limit} \"", ";", "}", "if", "(", "!", "is_null", "(", "$", "offset", ")", "&&", "!", "is_null", "(", "$", "limit", ")", ")", "{", "$", "queryString", ".=", "\"OFFSET {$offset} \"", ";", "}", "$", "queryString", ".=", "\";\"", ";", "$", "this", "->", "query", "(", "$", "queryString", ")", ";", "return", "$", "this", "->", "countRows", "(", ")", ";", "}" ]
Perform a SELECT statement @param string $table @param string $conditions @param string $fields @param string $order @param string $limit @param string $offset @return int number of affected rows
[ "Perform", "a", "SELECT", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L204-L241
238,142
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.insert
public function insert($table, array $data) { $nameFields = join(',', array_keys($data)); $preparedValues = $this->prepareValues($data); $keyValues = join(",", array_keys($preparedValues)); $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});"; $this->query($queryString, $preparedValues); return $this->getInsertId(); }
php
public function insert($table, array $data) { $nameFields = join(',', array_keys($data)); $preparedValues = $this->prepareValues($data); $keyValues = join(",", array_keys($preparedValues)); $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});"; $this->query($queryString, $preparedValues); return $this->getInsertId(); }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "data", ")", "{", "$", "nameFields", "=", "join", "(", "','", ",", "array_keys", "(", "$", "data", ")", ")", ";", "$", "preparedValues", "=", "$", "this", "->", "prepareValues", "(", "$", "data", ")", ";", "$", "keyValues", "=", "join", "(", "\",\"", ",", "array_keys", "(", "$", "preparedValues", ")", ")", ";", "$", "queryString", "=", "\"INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});\"", ";", "$", "this", "->", "query", "(", "$", "queryString", ",", "$", "preparedValues", ")", ";", "return", "$", "this", "->", "getInsertId", "(", ")", ";", "}" ]
Perform a INSERT statement @param string $table @param array $data @return int last inserted id
[ "Perform", "a", "INSERT", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L251-L261
238,143
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.prepareValues
private function prepareValues($arrayData) { $arrayData = array_values($arrayData); $preparedValues = []; $vNumber = 1; foreach ($arrayData as $value) { $preparedValues[":value{$vNumber}"] = "$value"; $vNumber++; } unset($arrayData); unset($vNumber); return $preparedValues; }
php
private function prepareValues($arrayData) { $arrayData = array_values($arrayData); $preparedValues = []; $vNumber = 1; foreach ($arrayData as $value) { $preparedValues[":value{$vNumber}"] = "$value"; $vNumber++; } unset($arrayData); unset($vNumber); return $preparedValues; }
[ "private", "function", "prepareValues", "(", "$", "arrayData", ")", "{", "$", "arrayData", "=", "array_values", "(", "$", "arrayData", ")", ";", "$", "preparedValues", "=", "[", "]", ";", "$", "vNumber", "=", "1", ";", "foreach", "(", "$", "arrayData", "as", "$", "value", ")", "{", "$", "preparedValues", "[", "\":value{$vNumber}\"", "]", "=", "\"$value\"", ";", "$", "vNumber", "++", ";", "}", "unset", "(", "$", "arrayData", ")", ";", "unset", "(", "$", "vNumber", ")", ";", "return", "$", "preparedValues", ";", "}" ]
Preparate values for execute @param array $arrayData @return string
[ "Preparate", "values", "for", "execute" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L269-L284
238,144
clagiordano/weblibs-dbabstraction
src/PDOAdapter.php
PDOAdapter.update
public function update($table, array $data, $conditions) { $nameFields = array_keys($data); $preparedValues = $this->prepareValues($data); $queryString = "UPDATE {$table} SET "; $fNumber = 0; foreach ($preparedValues as $key => $value) { unset($value); $queryString .= "{$nameFields[$fNumber]} = {$key}, "; $fNumber++; } $queryString = preg_replace('/,\ $/', ' ', $queryString); $queryString .= "WHERE {$conditions};"; $this->query($queryString, $preparedValues); return $this->getAffectedRows(); }
php
public function update($table, array $data, $conditions) { $nameFields = array_keys($data); $preparedValues = $this->prepareValues($data); $queryString = "UPDATE {$table} SET "; $fNumber = 0; foreach ($preparedValues as $key => $value) { unset($value); $queryString .= "{$nameFields[$fNumber]} = {$key}, "; $fNumber++; } $queryString = preg_replace('/,\ $/', ' ', $queryString); $queryString .= "WHERE {$conditions};"; $this->query($queryString, $preparedValues); return $this->getAffectedRows(); }
[ "public", "function", "update", "(", "$", "table", ",", "array", "$", "data", ",", "$", "conditions", ")", "{", "$", "nameFields", "=", "array_keys", "(", "$", "data", ")", ";", "$", "preparedValues", "=", "$", "this", "->", "prepareValues", "(", "$", "data", ")", ";", "$", "queryString", "=", "\"UPDATE {$table} SET \"", ";", "$", "fNumber", "=", "0", ";", "foreach", "(", "$", "preparedValues", "as", "$", "key", "=>", "$", "value", ")", "{", "unset", "(", "$", "value", ")", ";", "$", "queryString", ".=", "\"{$nameFields[$fNumber]} = {$key}, \"", ";", "$", "fNumber", "++", ";", "}", "$", "queryString", "=", "preg_replace", "(", "'/,\\ $/'", ",", "' '", ",", "$", "queryString", ")", ";", "$", "queryString", ".=", "\"WHERE {$conditions};\"", ";", "$", "this", "->", "query", "(", "$", "queryString", ",", "$", "preparedValues", ")", ";", "return", "$", "this", "->", "getAffectedRows", "(", ")", ";", "}" ]
Perform a UPDATE statement @param string $table @param array $data @param string $conditions @return int number of affected rows
[ "Perform", "a", "UPDATE", "statement" ]
167988f73f1d6d0a013179c4a211bdc673a4667e
https://github.com/clagiordano/weblibs-dbabstraction/blob/167988f73f1d6d0a013179c4a211bdc673a4667e/src/PDOAdapter.php#L295-L314
238,145
elstamey/phergie-irc-plugin-react-tableflip
src/Plugin.php
Plugin.specialChar
private function specialChar($char) { switch($char) { case "!": return $this->hexToChar('00A1'); case "_": return $this->hexToChar('203E'); case "&": return $this->hexToChar('214B'); case "?": return $this->hexToChar('00BF'); case ".": return $this->hexToChar('U2D9'); case "\"": return $this->hexToChar('201E'); case "'": return $this->hexToChar('002C'); case "(": return $this->hexToChar('0029'); case ")": return $this->hexToChar('0028'); default: return $char; } }
php
private function specialChar($char) { switch($char) { case "!": return $this->hexToChar('00A1'); case "_": return $this->hexToChar('203E'); case "&": return $this->hexToChar('214B'); case "?": return $this->hexToChar('00BF'); case ".": return $this->hexToChar('U2D9'); case "\"": return $this->hexToChar('201E'); case "'": return $this->hexToChar('002C'); case "(": return $this->hexToChar('0029'); case ")": return $this->hexToChar('0028'); default: return $char; } }
[ "private", "function", "specialChar", "(", "$", "char", ")", "{", "switch", "(", "$", "char", ")", "{", "case", "\"!\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'00A1'", ")", ";", "case", "\"_\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'203E'", ")", ";", "case", "\"&\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'214B'", ")", ";", "case", "\"?\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'00BF'", ")", ";", "case", "\".\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'U2D9'", ")", ";", "case", "\"\\\"\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'201E'", ")", ";", "case", "\"'\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'002C'", ")", ";", "case", "\"(\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'0029'", ")", ";", "case", "\")\"", ":", "return", "$", "this", "->", "hexToChar", "(", "'0028'", ")", ";", "default", ":", "return", "$", "char", ";", "}", "}" ]
Switch statement to flip the special and punctuation characters @param string $char @return string
[ "Switch", "statement", "to", "flip", "the", "special", "and", "punctuation", "characters" ]
59cb591243597cbf6ff40d28696935099965cbeb
https://github.com/elstamey/phergie-irc-plugin-react-tableflip/blob/59cb591243597cbf6ff40d28696935099965cbeb/src/Plugin.php#L247-L272
238,146
Dhii/invocable-base
src/CreateInvocationExceptionCapableTrait.php
CreateInvocationExceptionCapableTrait._createInvocationException
protected function _createInvocationException( $message = null, $code = null, RootException $previous = null, callable $callable = null, $args = null ) { return new InvocationException($message, $code, $previous, $callable, $args); }
php
protected function _createInvocationException( $message = null, $code = null, RootException $previous = null, callable $callable = null, $args = null ) { return new InvocationException($message, $code, $previous, $callable, $args); }
[ "protected", "function", "_createInvocationException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "RootException", "$", "previous", "=", "null", ",", "callable", "$", "callable", "=", "null", ",", "$", "args", "=", "null", ")", "{", "return", "new", "InvocationException", "(", "$", "message", ",", "$", "code", ",", "$", "previous", ",", "$", "callable", ",", "$", "args", ")", ";", "}" ]
Creates a new Invocation exception. @since [*next-version*] @param string|Stringable|null $message The error message, if any. @param int|null $code The error code, if any. @param RootException|null $previous The inner exception for chaining, if any. @param callable $callable The callable that caused the problem, if any. @param Traversable|array $args The associated list of arguments, if any. @return InvocationExceptionInterface The new exception.
[ "Creates", "a", "new", "Invocation", "exception", "." ]
f8edf350653f1041388addb918a1478e46c3a83f
https://github.com/Dhii/invocable-base/blob/f8edf350653f1041388addb918a1478e46c3a83f/src/CreateInvocationExceptionCapableTrait.php#L31-L39
238,147
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.create
public static function create(string $locale = 'en'): ValidatorFactory { $translator = new Translator; $factory = new ValidatorFactory($translator); $factory = $factory->withBuiltInFactories(); $factory = $factory->withBuiltInTemplates($locale); return $factory; }
php
public static function create(string $locale = 'en'): ValidatorFactory { $translator = new Translator; $factory = new ValidatorFactory($translator); $factory = $factory->withBuiltInFactories(); $factory = $factory->withBuiltInTemplates($locale); return $factory; }
[ "public", "static", "function", "create", "(", "string", "$", "locale", "=", "'en'", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "new", "Translator", ";", "$", "factory", "=", "new", "ValidatorFactory", "(", "$", "translator", ")", ";", "$", "factory", "=", "$", "factory", "->", "withBuiltInFactories", "(", ")", ";", "$", "factory", "=", "$", "factory", "->", "withBuiltInTemplates", "(", "$", "locale", ")", ";", "return", "$", "factory", ";", "}" ]
Return a validator factory using all the default rule factories and the templates of the given locale. @param string $locale @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "validator", "factory", "using", "all", "the", "default", "rule", "factories", "and", "the", "templates", "of", "the", "given", "locale", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L72-L81
238,148
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withBuiltInFactories
private function withBuiltInFactories(): ValidatorFactory { $keys = array_keys(self::$defaults); return array_reduce($keys, function ($factory, $key) { $rule = self::$defaults[$key]; return $factory->withRuleFactory($key, function (array $parameters = []) use ($rule) { return new $rule(...$parameters); }); }, $this); }
php
private function withBuiltInFactories(): ValidatorFactory { $keys = array_keys(self::$defaults); return array_reduce($keys, function ($factory, $key) { $rule = self::$defaults[$key]; return $factory->withRuleFactory($key, function (array $parameters = []) use ($rule) { return new $rule(...$parameters); }); }, $this); }
[ "private", "function", "withBuiltInFactories", "(", ")", ":", "ValidatorFactory", "{", "$", "keys", "=", "array_keys", "(", "self", "::", "$", "defaults", ")", ";", "return", "array_reduce", "(", "$", "keys", ",", "function", "(", "$", "factory", ",", "$", "key", ")", "{", "$", "rule", "=", "self", "::", "$", "defaults", "[", "$", "key", "]", ";", "return", "$", "factory", "->", "withRuleFactory", "(", "$", "key", ",", "function", "(", "array", "$", "parameters", "=", "[", "]", ")", "use", "(", "$", "rule", ")", "{", "return", "new", "$", "rule", "(", "...", "$", "parameters", ")", ";", "}", ")", ";", "}", ",", "$", "this", ")", ";", "}" ]
Return a new validator factory with a rule factory for each default rules. @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "a", "rule", "factory", "for", "each", "default", "rules", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L102-L117
238,149
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withBuiltInTemplates
private function withBuiltInTemplates(string $locale): ValidatorFactory { $templates = include(__DIR__ . '/../lang/' . $locale . '.php'); return $this->withDefaultTemplates($templates); }
php
private function withBuiltInTemplates(string $locale): ValidatorFactory { $templates = include(__DIR__ . '/../lang/' . $locale . '.php'); return $this->withDefaultTemplates($templates); }
[ "private", "function", "withBuiltInTemplates", "(", "string", "$", "locale", ")", ":", "ValidatorFactory", "{", "$", "templates", "=", "include", "(", "__DIR__", ".", "'/../lang/'", ".", "$", "locale", ".", "'.php'", ")", ";", "return", "$", "this", "->", "withDefaultTemplates", "(", "$", "templates", ")", ";", "}" ]
Return a new validator factory using the built in templates for the given locale. @param string $locale @return \Ellipse\Validator\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "using", "the", "built", "in", "templates", "for", "the", "given", "locale", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L126-L131
238,150
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.getValidator
public function getValidator(array $rules = []): Validator { $parser = new RulesParser($this->factories); return new Validator($rules, $parser, $this->translator); }
php
public function getValidator(array $rules = []): Validator { $parser = new RulesParser($this->factories); return new Validator($rules, $parser, $this->translator); }
[ "public", "function", "getValidator", "(", "array", "$", "rules", "=", "[", "]", ")", ":", "Validator", "{", "$", "parser", "=", "new", "RulesParser", "(", "$", "this", "->", "factories", ")", ";", "return", "new", "Validator", "(", "$", "rules", ",", "$", "parser", ",", "$", "this", "->", "translator", ")", ";", "}" ]
Return a validator using the given rules. @param array $rules @return \Ellipse\Validation\Validator
[ "Return", "a", "validator", "using", "the", "given", "rules", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L139-L144
238,151
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withRuleFactory
public function withRuleFactory(string $name, callable $factory): ValidatorFactory { $factories = array_merge($this->factories, [$name => $factory]); return new ValidatorFactory($this->translator, $factories); }
php
public function withRuleFactory(string $name, callable $factory): ValidatorFactory { $factories = array_merge($this->factories, [$name => $factory]); return new ValidatorFactory($this->translator, $factories); }
[ "public", "function", "withRuleFactory", "(", "string", "$", "name", ",", "callable", "$", "factory", ")", ":", "ValidatorFactory", "{", "$", "factories", "=", "array_merge", "(", "$", "this", "->", "factories", ",", "[", "$", "name", "=>", "$", "factory", "]", ")", ";", "return", "new", "ValidatorFactory", "(", "$", "this", "->", "translator", ",", "$", "factories", ")", ";", "}" ]
Return a new validator factory with an additional rule factory. @param string $name @param callable $factory @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "rule", "factory", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L153-L158
238,152
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withDefaultLabels
public function withDefaultLabels(array $labels): ValidatorFactory { $translator = $this->translator->withLabels($labels); return new ValidatorFactory($translator, $this->factories); }
php
public function withDefaultLabels(array $labels): ValidatorFactory { $translator = $this->translator->withLabels($labels); return new ValidatorFactory($translator, $this->factories); }
[ "public", "function", "withDefaultLabels", "(", "array", "$", "labels", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withLabels", "(", "$", "labels", ")", ";", "return", "new", "ValidatorFactory", "(", "$", "translator", ",", "$", "this", "->", "factories", ")", ";", "}" ]
Return a new validator factory with an additional list of labels added to the translator. @param array $labels @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "list", "of", "labels", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L167-L172
238,153
ellipsephp/validation
src/ValidatorFactory.php
ValidatorFactory.withDefaultTemplates
public function withDefaultTemplates(array $templates): ValidatorFactory { $translator = $this->translator->withTemplates($templates); return new ValidatorFactory($translator, $this->factories); }
php
public function withDefaultTemplates(array $templates): ValidatorFactory { $translator = $this->translator->withTemplates($templates); return new ValidatorFactory($translator, $this->factories); }
[ "public", "function", "withDefaultTemplates", "(", "array", "$", "templates", ")", ":", "ValidatorFactory", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withTemplates", "(", "$", "templates", ")", ";", "return", "new", "ValidatorFactory", "(", "$", "translator", ",", "$", "this", "->", "factories", ")", ";", "}" ]
Return a new validator factory with an additional list of templates added to the translator. @param array $templates @return \Ellipse\Validation\ValidatorFactory
[ "Return", "a", "new", "validator", "factory", "with", "an", "additional", "list", "of", "templates", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/ValidatorFactory.php#L181-L186
238,154
CodeMommy/CookiePHP
source/Cookie.php
Cookie.clear
public static function clear() { $isClearAll = true; if ($_COOKIE) { foreach ($_COOKIE as $key => $value) { $result = self::delete($key); if (!$result) { $isClearAll = false; } } } return $isClearAll; }
php
public static function clear() { $isClearAll = true; if ($_COOKIE) { foreach ($_COOKIE as $key => $value) { $result = self::delete($key); if (!$result) { $isClearAll = false; } } } return $isClearAll; }
[ "public", "static", "function", "clear", "(", ")", "{", "$", "isClearAll", "=", "true", ";", "if", "(", "$", "_COOKIE", ")", "{", "foreach", "(", "$", "_COOKIE", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "=", "self", "::", "delete", "(", "$", "key", ")", ";", "if", "(", "!", "$", "result", ")", "{", "$", "isClearAll", "=", "false", ";", "}", "}", "}", "return", "$", "isClearAll", ";", "}" ]
Clear all cookies @param void @return bool
[ "Clear", "all", "cookies" ]
fc1a018db015299807c218be43383b8753bbe814
https://github.com/CodeMommy/CookiePHP/blob/fc1a018db015299807c218be43383b8753bbe814/source/Cookie.php#L83-L95
238,155
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.disableAction
public function disableAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('CoreExtraBundle:Actor')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Actor entity.'); } $user = $this->get('security.token_storage')->getToken()->getUser(); if (!$user->isGranted('ROLE_ADMIN')) { return $this->redirect($this->generateUrl('coreextra_newsletter_index')); } $entity->setNewsletter(false); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.subscripts.disable'); return $this->redirect($this->generateUrl('coreextra_newsletter_subscription')); }
php
public function disableAction($id) { $em = $this->getDoctrine()->getManager(); /** @var Actor $entity */ $entity = $em->getRepository('CoreExtraBundle:Actor')->find($id); if (!$entity) { throw $this->createNotFoundException('Unable to find Actor entity.'); } $user = $this->get('security.token_storage')->getToken()->getUser(); if (!$user->isGranted('ROLE_ADMIN')) { return $this->redirect($this->generateUrl('coreextra_newsletter_index')); } $entity->setNewsletter(false); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.subscripts.disable'); return $this->redirect($this->generateUrl('coreextra_newsletter_subscription')); }
[ "public", "function", "disableAction", "(", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var Actor $entity */", "$", "entity", "=", "$", "em", "->", "getRepository", "(", "'CoreExtraBundle:Actor'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "entity", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Actor entity.'", ")", ";", "}", "$", "user", "=", "$", "this", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "!", "$", "user", "->", "isGranted", "(", "'ROLE_ADMIN'", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'coreextra_newsletter_index'", ")", ")", ";", "}", "$", "entity", "->", "setNewsletter", "(", "false", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'newsletter.subscripts.disable'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'coreextra_newsletter_subscription'", ")", ")", ";", "}" ]
Edits an existing Subscriptors entity. @param Request $request The request @param int $id The entity id @throws NotFoundHttpException @return array|RedirectResponse @Route("/subscription/{id}/disable")
[ "Edits", "an", "existing", "Subscriptors", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L75-L98
238,156
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.showAction
public function showAction(Newsletter $newsletter) { $deleteForm = $this->createDeleteForm($newsletter); return array( 'entity' => $newsletter, 'delete_form' => $deleteForm->createView(), ); }
php
public function showAction(Newsletter $newsletter) { $deleteForm = $this->createDeleteForm($newsletter); return array( 'entity' => $newsletter, 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showAction", "(", "Newsletter", "$", "newsletter", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "newsletter", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "newsletter", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Finds and displays a Newsletter entity. @Route("/newsletter/{id}") @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "Newsletter", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L184-L192
238,157
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.newShippingAction
public function newShippingAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new NewsletterShipping(); $data = $request->request->get('corebundle_newslettershippingtype'); $formConfig = array(); if(isset($data['type']) && $data['type'] == 'token'){ $formConfig['token'] = true; } $form = $this->createForm('CoreExtraBundle\Form\NewsletterShippingType', $entity, $formConfig); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $emailArray = $this->get('core_manager')->getSubscriptorFromType($entity); $entity->setTotalSent(count($emailArray)); ///////////////////////////////////////////////////////// //Send every email with diferent token and store on DB // ///////////////////////////////////////////////////////// if($entity->getType() == NewsletterShipping::TYPE_TOKEN){ //truncate table email token $em = $this->getDoctrine()->getEntityManager(); $connection = $em->getConnection(); $statement = $connection->prepare("TRUNCATE TABLE email_token"); $statement->execute(); foreach ($emailArray as $email) { $emailToken = new EmailToken(); $emailToken->setEmail($email); $token = sha1(uniqid()); $emailToken->setToken($token); $em->persist($emailToken); $body = preg_replace('/(#TOKEN#)/', $token, $entity->getNewsletter()->getBody()); $this->get('core.mailer')->sendShipping(array($email), NewsletterShipping::TYPE_TOKEN, $body); } }else{ $body = $entity->getNewsletter()->getBody(); $this->get('core.mailer')->sendShipping($emailArray, $entity->getType(), $body); } $em->persist($entity); $em->flush(); //if come from popup if ($request->isXMLHttpRequest()) { return new JsonResponse(array( 'id' => $entity->getId() )); } $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.created'); return $this->redirect($this->generateUrl('coreextra_newsletter_showshipping', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newShippingAction(Request $request) { $em = $this->getDoctrine()->getManager(); $entity = new NewsletterShipping(); $data = $request->request->get('corebundle_newslettershippingtype'); $formConfig = array(); if(isset($data['type']) && $data['type'] == 'token'){ $formConfig['token'] = true; } $form = $this->createForm('CoreExtraBundle\Form\NewsletterShippingType', $entity, $formConfig); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $emailArray = $this->get('core_manager')->getSubscriptorFromType($entity); $entity->setTotalSent(count($emailArray)); ///////////////////////////////////////////////////////// //Send every email with diferent token and store on DB // ///////////////////////////////////////////////////////// if($entity->getType() == NewsletterShipping::TYPE_TOKEN){ //truncate table email token $em = $this->getDoctrine()->getEntityManager(); $connection = $em->getConnection(); $statement = $connection->prepare("TRUNCATE TABLE email_token"); $statement->execute(); foreach ($emailArray as $email) { $emailToken = new EmailToken(); $emailToken->setEmail($email); $token = sha1(uniqid()); $emailToken->setToken($token); $em->persist($emailToken); $body = preg_replace('/(#TOKEN#)/', $token, $entity->getNewsletter()->getBody()); $this->get('core.mailer')->sendShipping(array($email), NewsletterShipping::TYPE_TOKEN, $body); } }else{ $body = $entity->getNewsletter()->getBody(); $this->get('core.mailer')->sendShipping($emailArray, $entity->getType(), $body); } $em->persist($entity); $em->flush(); //if come from popup if ($request->isXMLHttpRequest()) { return new JsonResponse(array( 'id' => $entity->getId() )); } $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.created'); return $this->redirect($this->generateUrl('coreextra_newsletter_showshipping', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newShippingAction", "(", "Request", "$", "request", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "entity", "=", "new", "NewsletterShipping", "(", ")", ";", "$", "data", "=", "$", "request", "->", "request", "->", "get", "(", "'corebundle_newslettershippingtype'", ")", ";", "$", "formConfig", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'type'", "]", ")", "&&", "$", "data", "[", "'type'", "]", "==", "'token'", ")", "{", "$", "formConfig", "[", "'token'", "]", "=", "true", ";", "}", "$", "form", "=", "$", "this", "->", "createForm", "(", "'CoreExtraBundle\\Form\\NewsletterShippingType'", ",", "$", "entity", ",", "$", "formConfig", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "emailArray", "=", "$", "this", "->", "get", "(", "'core_manager'", ")", "->", "getSubscriptorFromType", "(", "$", "entity", ")", ";", "$", "entity", "->", "setTotalSent", "(", "count", "(", "$", "emailArray", ")", ")", ";", "/////////////////////////////////////////////////////////", "//Send every email with diferent token and store on DB //", "/////////////////////////////////////////////////////////", "if", "(", "$", "entity", "->", "getType", "(", ")", "==", "NewsletterShipping", "::", "TYPE_TOKEN", ")", "{", "//truncate table email token", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getEntityManager", "(", ")", ";", "$", "connection", "=", "$", "em", "->", "getConnection", "(", ")", ";", "$", "statement", "=", "$", "connection", "->", "prepare", "(", "\"TRUNCATE TABLE email_token\"", ")", ";", "$", "statement", "->", "execute", "(", ")", ";", "foreach", "(", "$", "emailArray", "as", "$", "email", ")", "{", "$", "emailToken", "=", "new", "EmailToken", "(", ")", ";", "$", "emailToken", "->", "setEmail", "(", "$", "email", ")", ";", "$", "token", "=", "sha1", "(", "uniqid", "(", ")", ")", ";", "$", "emailToken", "->", "setToken", "(", "$", "token", ")", ";", "$", "em", "->", "persist", "(", "$", "emailToken", ")", ";", "$", "body", "=", "preg_replace", "(", "'/(#TOKEN#)/'", ",", "$", "token", ",", "$", "entity", "->", "getNewsletter", "(", ")", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "get", "(", "'core.mailer'", ")", "->", "sendShipping", "(", "array", "(", "$", "email", ")", ",", "NewsletterShipping", "::", "TYPE_TOKEN", ",", "$", "body", ")", ";", "}", "}", "else", "{", "$", "body", "=", "$", "entity", "->", "getNewsletter", "(", ")", "->", "getBody", "(", ")", ";", "$", "this", "->", "get", "(", "'core.mailer'", ")", "->", "sendShipping", "(", "$", "emailArray", ",", "$", "entity", "->", "getType", "(", ")", ",", "$", "body", ")", ";", "}", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "//if come from popup", "if", "(", "$", "request", "->", "isXMLHttpRequest", "(", ")", ")", "{", "return", "new", "JsonResponse", "(", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ";", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'newsletter.shipping.created'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'coreextra_newsletter_showshipping'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Shipping entity. @param Request $request The request @return array|RedirectResponse @Route("/shipping/new") @Method({"GET", "POST"}) @Template("CoreExtraBundle:Newsletter/Shipping:new.html.twig")
[ "Creates", "a", "new", "Shipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L340-L399
238,158
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.showShippingAction
public function showShippingAction(NewsletterShipping $newsletterShipping) { $deleteForm = $this->createNShippingDeleteForm($newsletterShipping); return array( 'entity' => $newsletterShipping, 'delete_form' => $deleteForm->createView(), ); }
php
public function showShippingAction(NewsletterShipping $newsletterShipping) { $deleteForm = $this->createNShippingDeleteForm($newsletterShipping); return array( 'entity' => $newsletterShipping, 'delete_form' => $deleteForm->createView(), ); }
[ "public", "function", "showShippingAction", "(", "NewsletterShipping", "$", "newsletterShipping", ")", "{", "$", "deleteForm", "=", "$", "this", "->", "createNShippingDeleteForm", "(", "$", "newsletterShipping", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "newsletterShipping", ",", "'delete_form'", "=>", "$", "deleteForm", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Finds and displays a NewsletterShipping entity. @Route("/shipping/{id}") @Method("GET") @Template("CoreExtraBundle:Newsletter/Shipping:show.html.twig")
[ "Finds", "and", "displays", "a", "NewsletterShipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L408-L416
238,159
sebardo/core_extra
CoreExtraBundle/Controller/NewsletterController.php
NewsletterController.deleteShippingAction
public function deleteShippingAction(Request $request, NewsletterShipping $newsletterShipping) { $em = $this->getDoctrine()->getManager(); $em->remove($newsletterShipping); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.deleted'); if($request->query->get('redirect')!=''){ return $this->redirect($request->query->get('redirect')); } return $this->redirect($this->generateUrl('coreextra_newsletter_shipping')); }
php
public function deleteShippingAction(Request $request, NewsletterShipping $newsletterShipping) { $em = $this->getDoctrine()->getManager(); $em->remove($newsletterShipping); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'newsletter.shipping.deleted'); if($request->query->get('redirect')!=''){ return $this->redirect($request->query->get('redirect')); } return $this->redirect($this->generateUrl('coreextra_newsletter_shipping')); }
[ "public", "function", "deleteShippingAction", "(", "Request", "$", "request", ",", "NewsletterShipping", "$", "newsletterShipping", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "newsletterShipping", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'newsletter.shipping.deleted'", ")", ";", "if", "(", "$", "request", "->", "query", "->", "get", "(", "'redirect'", ")", "!=", "''", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "request", "->", "query", "->", "get", "(", "'redirect'", ")", ")", ";", "}", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'coreextra_newsletter_shipping'", ")", ")", ";", "}" ]
Deletes a NewsletterShipping entity. @param Request $request The request @param int $id The entity id @throws NotFoundHttpException @return RedirectResponse @Route("/shipping/{id}/delete")
[ "Deletes", "a", "NewsletterShipping", "entity", "." ]
b18f2eb40c5396eb4520a566971c6c0f27603f5f
https://github.com/sebardo/core_extra/blob/b18f2eb40c5396eb4520a566971c6c0f27603f5f/CoreExtraBundle/Controller/NewsletterController.php#L430-L443
238,160
phpffcms/ffcms-console
src/Command.php
Command.ask
public function ask($question, $default = null) { $que = new Question($question, $default); $helper = new SymfonyQuestionHelper(); return $helper->ask($this->input, $this->output, $que); }
php
public function ask($question, $default = null) { $que = new Question($question, $default); $helper = new SymfonyQuestionHelper(); return $helper->ask($this->input, $this->output, $que); }
[ "public", "function", "ask", "(", "$", "question", ",", "$", "default", "=", "null", ")", "{", "$", "que", "=", "new", "Question", "(", "$", "question", ",", "$", "default", ")", ";", "$", "helper", "=", "new", "SymfonyQuestionHelper", "(", ")", ";", "return", "$", "helper", "->", "ask", "(", "$", "this", "->", "input", ",", "$", "this", "->", "output", ",", "$", "que", ")", ";", "}" ]
Ask string param from stdin php input @param string $question @param string|null $default @return string
[ "Ask", "string", "param", "from", "stdin", "php", "input" ]
da5a37a34c29d256ea0f2835a44c01178c53922b
https://github.com/phpffcms/ffcms-console/blob/da5a37a34c29d256ea0f2835a44c01178c53922b/src/Command.php#L41-L46
238,161
phpffcms/ffcms-console
src/Command.php
Command.optionOrAsk
public function optionOrAsk($option, $question, $default = null) { $value = $this->input->getOption($option); if ($value === null || Str::likeEmpty($value)) { $value = $this->ask($question, $default); } return $value; }
php
public function optionOrAsk($option, $question, $default = null) { $value = $this->input->getOption($option); if ($value === null || Str::likeEmpty($value)) { $value = $this->ask($question, $default); } return $value; }
[ "public", "function", "optionOrAsk", "(", "$", "option", ",", "$", "question", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "input", "->", "getOption", "(", "$", "option", ")", ";", "if", "(", "$", "value", "===", "null", "||", "Str", "::", "likeEmpty", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "ask", "(", "$", "question", ",", "$", "default", ")", ";", "}", "return", "$", "value", ";", "}" ]
Get input option value or ask it if empty @param string $option @param string $question @param string|null $default @return string
[ "Get", "input", "option", "value", "or", "ask", "it", "if", "empty" ]
da5a37a34c29d256ea0f2835a44c01178c53922b
https://github.com/phpffcms/ffcms-console/blob/da5a37a34c29d256ea0f2835a44c01178c53922b/src/Command.php#L81-L89
238,162
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/Util.php
Util.post
public static function post($url, $payload, $contentType = 'Content-Type: application/json') { // TODO move constants to global configuration file $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ( $contentType, 'Content-Length: ' . strlen ( $payload ) ) ); $result = curl_exec ( $ch ); return $result; }
php
public static function post($url, $payload, $contentType = 'Content-Type: application/json') { // TODO move constants to global configuration file $ch = curl_init ( $url ); curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, $payload ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ( $contentType, 'Content-Length: ' . strlen ( $payload ) ) ); $result = curl_exec ( $ch ); return $result; }
[ "public", "static", "function", "post", "(", "$", "url", ",", "$", "payload", ",", "$", "contentType", "=", "'Content-Type: application/json'", ")", "{", "// TODO move constants to global configuration file", "$", "ch", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "\"POST\"", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "payload", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "$", "contentType", ",", "'Content-Length: '", ".", "strlen", "(", "$", "payload", ")", ")", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "ch", ")", ";", "return", "$", "result", ";", "}" ]
Function to post a payload to a url using cURL. @param string $url @param string $payload @param string $contentType @return mixed the result of the curl execution.
[ "Function", "to", "post", "a", "payload", "to", "a", "url", "using", "cURL", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/Util.php#L22-L34
238,163
digitalicagroup/slack-hook-framework
lib/SlackHookFramework/Util.php
Util.createField
public static function createField($title, $value, $short = true) { $field = new SlackResultAttachmentField (); $field->setTitle ( $title ); $field->setValue ( $value ); $field->setShort ( $short ); return $field; }
php
public static function createField($title, $value, $short = true) { $field = new SlackResultAttachmentField (); $field->setTitle ( $title ); $field->setValue ( $value ); $field->setShort ( $short ); return $field; }
[ "public", "static", "function", "createField", "(", "$", "title", ",", "$", "value", ",", "$", "short", "=", "true", ")", "{", "$", "field", "=", "new", "SlackResultAttachmentField", "(", ")", ";", "$", "field", "->", "setTitle", "(", "$", "title", ")", ";", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "$", "field", "->", "setShort", "(", "$", "short", ")", ";", "return", "$", "field", ";", "}" ]
Returns a \SlackHookFramework\SlackResultAttachmentField instance with the given values. @param string $title @param string $value @param boolean $short If true, returns a "short" field. Slack can render two short fields in two columns, or a "long" field ($short = false) in a single column. @return \SlackHookFramework\SlackResultAttachmentField
[ "Returns", "a", "\\", "SlackHookFramework", "\\", "SlackResultAttachmentField", "instance", "with", "the", "given", "values", "." ]
b2357275d6042e49cb082e375716effd4c001ee0
https://github.com/digitalicagroup/slack-hook-framework/blob/b2357275d6042e49cb082e375716effd4c001ee0/lib/SlackHookFramework/Util.php#L102-L108
238,164
samurai-fw/samurai
src/Samurai/Component/Core/Framework.php
Framework.initContainer
private function initContainer() { $dicons = (array)$this->app->config('container.dicon'); $container = ContainerFactory::create(); foreach ($dicons as $dicon) { $file = $this->app->getLoader()->find($dicon)->first(); $container->import($file); } $container->register('framework', $this); $container->register('application', $this->app); $container->register('loader', $this->app->getLoader()); $this->setContainer($container); $this->app->setContainer($container); // callback foreach ((array)$this->app->config('container.callback.initialized') as $callback) { $callback($container); } }
php
private function initContainer() { $dicons = (array)$this->app->config('container.dicon'); $container = ContainerFactory::create(); foreach ($dicons as $dicon) { $file = $this->app->getLoader()->find($dicon)->first(); $container->import($file); } $container->register('framework', $this); $container->register('application', $this->app); $container->register('loader', $this->app->getLoader()); $this->setContainer($container); $this->app->setContainer($container); // callback foreach ((array)$this->app->config('container.callback.initialized') as $callback) { $callback($container); } }
[ "private", "function", "initContainer", "(", ")", "{", "$", "dicons", "=", "(", "array", ")", "$", "this", "->", "app", "->", "config", "(", "'container.dicon'", ")", ";", "$", "container", "=", "ContainerFactory", "::", "create", "(", ")", ";", "foreach", "(", "$", "dicons", "as", "$", "dicon", ")", "{", "$", "file", "=", "$", "this", "->", "app", "->", "getLoader", "(", ")", "->", "find", "(", "$", "dicon", ")", "->", "first", "(", ")", ";", "$", "container", "->", "import", "(", "$", "file", ")", ";", "}", "$", "container", "->", "register", "(", "'framework'", ",", "$", "this", ")", ";", "$", "container", "->", "register", "(", "'application'", ",", "$", "this", "->", "app", ")", ";", "$", "container", "->", "register", "(", "'loader'", ",", "$", "this", "->", "app", "->", "getLoader", "(", ")", ")", ";", "$", "this", "->", "setContainer", "(", "$", "container", ")", ";", "$", "this", "->", "app", "->", "setContainer", "(", "$", "container", ")", ";", "// callback", "foreach", "(", "(", "array", ")", "$", "this", "->", "app", "->", "config", "(", "'container.callback.initialized'", ")", "as", "$", "callback", ")", "{", "$", "callback", "(", "$", "container", ")", ";", "}", "}" ]
initialize container. @access private
[ "initialize", "container", "." ]
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Core/Framework.php#L132-L152
238,165
gossi/trixionary
src/model/Base/Video.php
Video.setReference
public function setReference(ChildReference $v = null) { if ($v === null) { $this->setReferenceId(NULL); } else { $this->setReferenceId($v->getId()); } $this->aReference = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildReference object, it will not be re-added. if ($v !== null) { $v->addVideo($this); } return $this; }
php
public function setReference(ChildReference $v = null) { if ($v === null) { $this->setReferenceId(NULL); } else { $this->setReferenceId($v->getId()); } $this->aReference = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildReference object, it will not be re-added. if ($v !== null) { $v->addVideo($this); } return $this; }
[ "public", "function", "setReference", "(", "ChildReference", "$", "v", "=", "null", ")", "{", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setReferenceId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setReferenceId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aReference", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the ChildReference object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addVideo", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a ChildReference object. @param ChildReference $v @return $this|\gossi\trixionary\model\Video The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "ChildReference", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2066-L2084
238,166
gossi/trixionary
src/model/Base/Video.php
Video.getReference
public function getReference(ConnectionInterface $con = null) { if ($this->aReference === null && ($this->reference_id !== null)) { $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aReference->addVideos($this); */ } return $this->aReference; }
php
public function getReference(ConnectionInterface $con = null) { if ($this->aReference === null && ($this->reference_id !== null)) { $this->aReference = ChildReferenceQuery::create()->findPk($this->reference_id, $con); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aReference->addVideos($this); */ } return $this->aReference; }
[ "public", "function", "getReference", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aReference", "===", "null", "&&", "(", "$", "this", "->", "reference_id", "!==", "null", ")", ")", "{", "$", "this", "->", "aReference", "=", "ChildReferenceQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "reference_id", ",", "$", "con", ")", ";", "/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aReference->addVideos($this);\n */", "}", "return", "$", "this", "->", "aReference", ";", "}" ]
Get the associated ChildReference object @param ConnectionInterface $con Optional Connection object. @return ChildReference The associated ChildReference object. @throws PropelException
[ "Get", "the", "associated", "ChildReference", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2094-L2108
238,167
gossi/trixionary
src/model/Base/Video.php
Video.initFeaturedTutorialSkills
public function initFeaturedTutorialSkills($overrideExisting = true) { if (null !== $this->collFeaturedTutorialSkills && !$overrideExisting) { return; } $this->collFeaturedTutorialSkills = new ObjectCollection(); $this->collFeaturedTutorialSkills->setModel('\gossi\trixionary\model\Skill'); }
php
public function initFeaturedTutorialSkills($overrideExisting = true) { if (null !== $this->collFeaturedTutorialSkills && !$overrideExisting) { return; } $this->collFeaturedTutorialSkills = new ObjectCollection(); $this->collFeaturedTutorialSkills->setModel('\gossi\trixionary\model\Skill'); }
[ "public", "function", "initFeaturedTutorialSkills", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collFeaturedTutorialSkills", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collFeaturedTutorialSkills", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collFeaturedTutorialSkills", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Skill'", ")", ";", "}" ]
Initializes the collFeaturedTutorialSkills collection. By default this just sets the collFeaturedTutorialSkills collection to an empty array (like clearcollFeaturedTutorialSkills()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collFeaturedTutorialSkills", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2606-L2613
238,168
gossi/trixionary
src/model/Base/Video.php
Video.getFeaturedTutorialSkillsJoinSport
public function getFeaturedTutorialSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getFeaturedTutorialSkills($query, $con); }
php
public function getFeaturedTutorialSkillsJoinSport(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('Sport', $joinBehavior); return $this->getFeaturedTutorialSkills($query, $con); }
[ "public", "function", "getFeaturedTutorialSkillsJoinSport", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Sport'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getFeaturedTutorialSkills", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Video is new, it will return an empty collection; or if this Video has previously been saved, it will retrieve related FeaturedTutorialSkills from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Video. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Video", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Video", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "FeaturedTutorialSkills", "from", "storage", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Video.php#L2807-L2813
238,169
hermajan/lib
src/services/Gravatar.php
Gravatar.createURL
public function createURL() { $url = "https://secure.gravatar.com/avatar/".$this->createHash(); $url = $url."?s=".$this->size."&d=".$this->default."&r=".$this->rating; if($this->forceDefault == true) { $url = $url.'&f=y'; } return $url; }
php
public function createURL() { $url = "https://secure.gravatar.com/avatar/".$this->createHash(); $url = $url."?s=".$this->size."&d=".$this->default."&r=".$this->rating; if($this->forceDefault == true) { $url = $url.'&f=y'; } return $url; }
[ "public", "function", "createURL", "(", ")", "{", "$", "url", "=", "\"https://secure.gravatar.com/avatar/\"", ".", "$", "this", "->", "createHash", "(", ")", ";", "$", "url", "=", "$", "url", ".", "\"?s=\"", ".", "$", "this", "->", "size", ".", "\"&d=\"", ".", "$", "this", "->", "default", ".", "\"&r=\"", ".", "$", "this", "->", "rating", ";", "if", "(", "$", "this", "->", "forceDefault", "==", "true", ")", "{", "$", "url", "=", "$", "url", ".", "'&f=y'", ";", "}", "return", "$", "url", ";", "}" ]
Creates URL of a gravatar image. @return string Image URL.
[ "Creates", "URL", "of", "a", "gravatar", "image", "." ]
7d666260f5bcee041f130a3c3100f520b5e4bbd2
https://github.com/hermajan/lib/blob/7d666260f5bcee041f130a3c3100f520b5e4bbd2/src/services/Gravatar.php#L79-L87
238,170
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.css
public function css( $cssClasses ) { if ( ! $cssClasses ) { return $this; } $cssClasses = explode( ' ', $cssClasses ); foreach ( $cssClasses as $cssClass ) { if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) ) { $this->cssClasses[] = $cssClass; } } return $this; }
php
public function css( $cssClasses ) { if ( ! $cssClasses ) { return $this; } $cssClasses = explode( ' ', $cssClasses ); foreach ( $cssClasses as $cssClass ) { if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) ) { $this->cssClasses[] = $cssClass; } } return $this; }
[ "public", "function", "css", "(", "$", "cssClasses", ")", "{", "if", "(", "!", "$", "cssClasses", ")", "{", "return", "$", "this", ";", "}", "$", "cssClasses", "=", "explode", "(", "' '", ",", "$", "cssClasses", ")", ";", "foreach", "(", "$", "cssClasses", "as", "$", "cssClass", ")", "{", "if", "(", "$", "cssClass", "&&", "false", "===", "in_array", "(", "$", "cssClass", ",", "$", "this", "->", "cssClasses", ")", ")", "{", "$", "this", "->", "cssClasses", "[", "]", "=", "$", "cssClass", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add a CSS class to the element. Multiple classes can be passed as a space-separated string. @param $cssClasses @return $this
[ "Add", "a", "CSS", "class", "to", "the", "element", ".", "Multiple", "classes", "can", "be", "passed", "as", "a", "space", "-", "separated", "string", "." ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L129-L147
238,171
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.ghost
public function ghost( $ghostValue ) { if ( $this->isCheckbox() ) { $this->ghostCheckboxValue = $ghostValue; $this->avoidGhost = ( null === $ghostValue ); } return $this; }
php
public function ghost( $ghostValue ) { if ( $this->isCheckbox() ) { $this->ghostCheckboxValue = $ghostValue; $this->avoidGhost = ( null === $ghostValue ); } return $this; }
[ "public", "function", "ghost", "(", "$", "ghostValue", ")", "{", "if", "(", "$", "this", "->", "isCheckbox", "(", ")", ")", "{", "$", "this", "->", "ghostCheckboxValue", "=", "$", "ghostValue", ";", "$", "this", "->", "avoidGhost", "=", "(", "null", "===", "$", "ghostValue", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the "ghost value" for the checkbox. @see $ghostCheckboxValue @param $ghostValue
[ "Set", "the", "ghost", "value", "for", "the", "checkbox", "." ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L256-L265
238,172
lucavicidomini/blade-materialize
src/HtmlElement.php
HtmlElement.getGhost
protected function getGhost() { // A value is set for this checkbox, use it if ( null !== $this->ghostCheckboxValue ) { return $this->ghostCheckboxValue; } // No value is set, and it is not forced to null, so use default ghost (if any) if ( ! $this->avoidGhost ) { return config( 'blade-materialize.checkbox_ghost' ); } // No value is set, user didn't force ghost return null; }
php
protected function getGhost() { // A value is set for this checkbox, use it if ( null !== $this->ghostCheckboxValue ) { return $this->ghostCheckboxValue; } // No value is set, and it is not forced to null, so use default ghost (if any) if ( ! $this->avoidGhost ) { return config( 'blade-materialize.checkbox_ghost' ); } // No value is set, user didn't force ghost return null; }
[ "protected", "function", "getGhost", "(", ")", "{", "// A value is set for this checkbox, use it", "if", "(", "null", "!==", "$", "this", "->", "ghostCheckboxValue", ")", "{", "return", "$", "this", "->", "ghostCheckboxValue", ";", "}", "// No value is set, and it is not forced to null, so use default ghost (if any)", "if", "(", "!", "$", "this", "->", "avoidGhost", ")", "{", "return", "config", "(", "'blade-materialize.checkbox_ghost'", ")", ";", "}", "// No value is set, user didn't force ghost", "return", "null", ";", "}" ]
Return the checkbox ghost value, or null if there is no ghost value;
[ "Return", "the", "checkbox", "ghost", "value", "or", "null", "if", "there", "is", "no", "ghost", "value", ";" ]
4683c01f51c056d322fc9133eb5484a9b163e5d0
https://github.com/lucavicidomini/blade-materialize/blob/4683c01f51c056d322fc9133eb5484a9b163e5d0/src/HtmlElement.php#L270-L284
238,173
mauretto78/in-memory-list
src/InMemoryList/Infrastructure/Persistance/PdoRepository.php
PdoRepository.createSchema
public function createSchema() { $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query); $query2 = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) NOT NULL, `list` varchar(255) NOT NULL, `body` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`), CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'.self::LIST_COLLECTION_TABLE_NAME.'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query2); }
php
public function createSchema() { $query = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_COLLECTION_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) UNIQUE NOT NULL, `headers` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query); $query2 = 'CREATE TABLE IF NOT EXISTS `'.self::LIST_ELEMENT_TABLE_NAME.'` ( `id` int NOT NULL AUTO_INCREMENT, `uuid` varchar(255) NOT NULL, `list` varchar(255) NOT NULL, `body` text DEFAULT NULL, `created_at` TIMESTAMP NOT NULL, `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(), PRIMARY KEY (`id`), CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'.self::LIST_COLLECTION_TABLE_NAME.'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; $this->pdo->exec($query2); }
[ "public", "function", "createSchema", "(", ")", "{", "$", "query", "=", "'CREATE TABLE IF NOT EXISTS `'", ".", "self", "::", "LIST_COLLECTION_TABLE_NAME", ".", "'` (\n `id` int NOT NULL AUTO_INCREMENT,\n `uuid` varchar(255) UNIQUE NOT NULL,\n `headers` text DEFAULT NULL,\n `created_at` TIMESTAMP NOT NULL,\n `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'", ";", "$", "this", "->", "pdo", "->", "exec", "(", "$", "query", ")", ";", "$", "query2", "=", "'CREATE TABLE IF NOT EXISTS `'", ".", "self", "::", "LIST_ELEMENT_TABLE_NAME", ".", "'` (\n `id` int NOT NULL AUTO_INCREMENT,\n `uuid` varchar(255) NOT NULL,\n `list` varchar(255) NOT NULL,\n `body` text DEFAULT NULL,\n `created_at` TIMESTAMP NOT NULL,\n `updated_at` TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW(),\n PRIMARY KEY (`id`),\n CONSTRAINT `list_foreign_key` FOREIGN KEY (`list`) REFERENCES `'", ".", "self", "::", "LIST_COLLECTION_TABLE_NAME", ".", "'`(`uuid`) ON UPDATE CASCADE ON DELETE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'", ";", "$", "this", "->", "pdo", "->", "exec", "(", "$", "query2", ")", ";", "}" ]
creates database schema.
[ "creates", "database", "schema", "." ]
8c916641be09b2bc9adcf670bbc17906fea67727
https://github.com/mauretto78/in-memory-list/blob/8c916641be09b2bc9adcf670bbc17906fea67727/src/InMemoryList/Infrastructure/Persistance/PdoRepository.php#L411-L436
238,174
SagePHP/System
src/SagePHP/System/Hostname.php
Hostname.get
public function get() { $exec = $this->getExecutor(); $exec->setCommand('hostname'); $exec->run(); $output = $exec->getOutput(); return $output['stdout']; }
php
public function get() { $exec = $this->getExecutor(); $exec->setCommand('hostname'); $exec->run(); $output = $exec->getOutput(); return $output['stdout']; }
[ "public", "function", "get", "(", ")", "{", "$", "exec", "=", "$", "this", "->", "getExecutor", "(", ")", ";", "$", "exec", "->", "setCommand", "(", "'hostname'", ")", ";", "$", "exec", "->", "run", "(", ")", ";", "$", "output", "=", "$", "exec", "->", "getOutput", "(", ")", ";", "return", "$", "output", "[", "'stdout'", "]", ";", "}" ]
returns the current hostname @return string
[ "returns", "the", "current", "hostname" ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Hostname.php#L42-L52
238,175
SagePHP/System
src/SagePHP/System/Hostname.php
Hostname.set
public function set($name) { $exec = $this->getExecutor(); $exec->setCommand('hostname ' . $name); $exec->run(); return $exec->hasErrors(); }
php
public function set($name) { $exec = $this->getExecutor(); $exec->setCommand('hostname ' . $name); $exec->run(); return $exec->hasErrors(); }
[ "public", "function", "set", "(", "$", "name", ")", "{", "$", "exec", "=", "$", "this", "->", "getExecutor", "(", ")", ";", "$", "exec", "->", "setCommand", "(", "'hostname '", ".", "$", "name", ")", ";", "$", "exec", "->", "run", "(", ")", ";", "return", "$", "exec", "->", "hasErrors", "(", ")", ";", "}" ]
sets the hostname @param string $name @return boolean true on success falsr otherwise
[ "sets", "the", "hostname" ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Hostname.php#L61-L68
238,176
orchestral/studio
src/Traits/PublishFiles.php
PublishFiles.publishFiles
protected function publishFiles(Filesystem $filesystem, array $paths, $force = false) { foreach ($paths as $from => $to) { if ($filesystem->isFile($from)) { $this->publishFile($filesystem, $from, $to, $force); } elseif ($filesystem->isDirectory($from)) { $this->publishDirectory($from, $to, $force); } else { $this->error("Can't locate path: <{$from}>"); } } }
php
protected function publishFiles(Filesystem $filesystem, array $paths, $force = false) { foreach ($paths as $from => $to) { if ($filesystem->isFile($from)) { $this->publishFile($filesystem, $from, $to, $force); } elseif ($filesystem->isDirectory($from)) { $this->publishDirectory($from, $to, $force); } else { $this->error("Can't locate path: <{$from}>"); } } }
[ "protected", "function", "publishFiles", "(", "Filesystem", "$", "filesystem", ",", "array", "$", "paths", ",", "$", "force", "=", "false", ")", "{", "foreach", "(", "$", "paths", "as", "$", "from", "=>", "$", "to", ")", "{", "if", "(", "$", "filesystem", "->", "isFile", "(", "$", "from", ")", ")", "{", "$", "this", "->", "publishFile", "(", "$", "filesystem", ",", "$", "from", ",", "$", "to", ",", "$", "force", ")", ";", "}", "elseif", "(", "$", "filesystem", "->", "isDirectory", "(", "$", "from", ")", ")", "{", "$", "this", "->", "publishDirectory", "(", "$", "from", ",", "$", "to", ",", "$", "force", ")", ";", "}", "else", "{", "$", "this", "->", "error", "(", "\"Can't locate path: <{$from}>\"", ")", ";", "}", "}", "}" ]
Publish files. @param \Illuminate\Filesystem\Filesystem $filesystem @param array $paths @param bool $force @return void
[ "Publish", "files", "." ]
254d0d3296ff8b52cdb7f4eab2423fea2bcced3b
https://github.com/orchestral/studio/blob/254d0d3296ff8b52cdb7f4eab2423fea2bcced3b/src/Traits/PublishFiles.php#L21-L32
238,177
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.paths
public function paths(): void { $paths = $this->getConfigPaths(); WP_CLI::success(count($paths) . ' config files found.'); WP_CLI::success('The later ones override any previous configurations.'); foreach ($paths as $path) { WP_CLI::log($path); } }
php
public function paths(): void { $paths = $this->getConfigPaths(); WP_CLI::success(count($paths) . ' config files found.'); WP_CLI::success('The later ones override any previous configurations.'); foreach ($paths as $path) { WP_CLI::log($path); } }
[ "public", "function", "paths", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "WP_CLI", "::", "success", "(", "count", "(", "$", "paths", ")", ".", "' config files found.'", ")", ";", "WP_CLI", "::", "success", "(", "'The later ones override any previous configurations.'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "WP_CLI", "::", "log", "(", "$", "path", ")", ";", "}", "}" ]
Gets the paths to all config files. ## EXAMPLES # Get preflight.toml file paths $ wp preflight config paths Success: 3 config files found. Success: The later ones override any previous configurations. /x/.wp-cli/packages/vendor/y/z/config/default.toml /app/public/preflight.toml /app/preflight.toml # When paths not found $ wp preflight config paths wp preflight config paths No config file found. Perhaps 'preflight_config_paths_register' not filtering properly? Error: Abort!
[ "Gets", "the", "paths", "to", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L37-L47
238,178
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.cat
public function cat(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Printing $path%n") ); // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown $contents = file_get_contents($path); $contentsWithoutLineBreaks = str_replace(["\r", "\n"], '', $contents); if (empty($contentsWithoutLineBreaks)) { WP_CLI::error_multi_line([ "File '$path' is empty.", ]); } WP_CLI::line($contents); // Print a empty line for better UX. WP_CLI::line(''); } }
php
public function cat(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Printing $path%n") ); // phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown $contents = file_get_contents($path); $contentsWithoutLineBreaks = str_replace(["\r", "\n"], '', $contents); if (empty($contentsWithoutLineBreaks)) { WP_CLI::error_multi_line([ "File '$path' is empty.", ]); } WP_CLI::line($contents); // Print a empty line for better UX. WP_CLI::line(''); } }
[ "public", "function", "cat", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "WP_CLI", "::", "line", "(", "WP_CLI", "::", "colorize", "(", "\"%B====> Printing $path%n\"", ")", ")", ";", "// phpcs:ignore WordPressVIPMinimum.VIP.FetchingRemoteData.fileGetContentsUknown", "$", "contents", "=", "file_get_contents", "(", "$", "path", ")", ";", "$", "contentsWithoutLineBreaks", "=", "str_replace", "(", "[", "\"\\r\"", ",", "\"\\n\"", "]", ",", "''", ",", "$", "contents", ")", ";", "if", "(", "empty", "(", "$", "contentsWithoutLineBreaks", ")", ")", "{", "WP_CLI", "::", "error_multi_line", "(", "[", "\"File '$path' is empty.\"", ",", "]", ")", ";", "}", "WP_CLI", "::", "line", "(", "$", "contents", ")", ";", "// Print a empty line for better UX.", "WP_CLI", "::", "line", "(", "''", ")", ";", "}", "}" ]
Prints the content of all config files. ## EXAMPLES # Print the content of all config files $ wp preflight config cat
[ "Prints", "the", "content", "of", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L80-L103
238,179
ItinerisLtd/preflight-command
src/CLI/Commands/ConfigCommand.php
ConfigCommand.validate
public function validate(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Validating $path%n") ); try { Toml::parseFile($path); WP_CLI::success("File '$path' is valid."); } catch (ParseException $parseException) { WP_CLI::error_multi_line([ $parseException->getMessage(), ]); WP_CLI::warning("File '$path' will be ignored."); } // Print a empty line for better UX. WP_CLI::line(''); } }
php
public function validate(): void { $paths = $this->getConfigPaths(); foreach ($paths as $path) { WP_CLI::line( WP_CLI::colorize("%B====> Validating $path%n") ); try { Toml::parseFile($path); WP_CLI::success("File '$path' is valid."); } catch (ParseException $parseException) { WP_CLI::error_multi_line([ $parseException->getMessage(), ]); WP_CLI::warning("File '$path' will be ignored."); } // Print a empty line for better UX. WP_CLI::line(''); } }
[ "public", "function", "validate", "(", ")", ":", "void", "{", "$", "paths", "=", "$", "this", "->", "getConfigPaths", "(", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "WP_CLI", "::", "line", "(", "WP_CLI", "::", "colorize", "(", "\"%B====> Validating $path%n\"", ")", ")", ";", "try", "{", "Toml", "::", "parseFile", "(", "$", "path", ")", ";", "WP_CLI", "::", "success", "(", "\"File '$path' is valid.\"", ")", ";", "}", "catch", "(", "ParseException", "$", "parseException", ")", "{", "WP_CLI", "::", "error_multi_line", "(", "[", "$", "parseException", "->", "getMessage", "(", ")", ",", "]", ")", ";", "WP_CLI", "::", "warning", "(", "\"File '$path' will be ignored.\"", ")", ";", "}", "// Print a empty line for better UX.", "WP_CLI", "::", "line", "(", "''", ")", ";", "}", "}" ]
Validates the TOML syntax of all config files. ## EXAMPLES # Validate the TOML syntax of the config files $ wp preflight config validate
[ "Validates", "the", "TOML", "syntax", "of", "all", "config", "files", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/Commands/ConfigCommand.php#L113-L136
238,180
manacode/phalconlibs
Translate/NativeArray.php
NativeArray._
public function _($translateKey, $defaultTranslation = "", $placeholders = null) { $translation = $translateKey; if (is_array($defaultTranslation) && $placeholders === null) { $placeholders = $defaultTranslation; } else { if ($defaultTranslation!="") { $translation = $defaultTranslation; } } if ($this->exists($translateKey)) { $translation = $this->_translate[$translateKey]; } return $this->replacePlaceholders($translation, $placeholders); }
php
public function _($translateKey, $defaultTranslation = "", $placeholders = null) { $translation = $translateKey; if (is_array($defaultTranslation) && $placeholders === null) { $placeholders = $defaultTranslation; } else { if ($defaultTranslation!="") { $translation = $defaultTranslation; } } if ($this->exists($translateKey)) { $translation = $this->_translate[$translateKey]; } return $this->replacePlaceholders($translation, $placeholders); }
[ "public", "function", "_", "(", "$", "translateKey", ",", "$", "defaultTranslation", "=", "\"\"", ",", "$", "placeholders", "=", "null", ")", "{", "$", "translation", "=", "$", "translateKey", ";", "if", "(", "is_array", "(", "$", "defaultTranslation", ")", "&&", "$", "placeholders", "===", "null", ")", "{", "$", "placeholders", "=", "$", "defaultTranslation", ";", "}", "else", "{", "if", "(", "$", "defaultTranslation", "!=", "\"\"", ")", "{", "$", "translation", "=", "$", "defaultTranslation", ";", "}", "}", "if", "(", "$", "this", "->", "exists", "(", "$", "translateKey", ")", ")", "{", "$", "translation", "=", "$", "this", "->", "_translate", "[", "$", "translateKey", "]", ";", "}", "return", "$", "this", "->", "replacePlaceholders", "(", "$", "translation", ",", "$", "placeholders", ")", ";", "}" ]
Returns the translation related to the given key
[ "Returns", "the", "translation", "related", "to", "the", "given", "key" ]
e60864ac8305dd95e6804e4894193e5255725a5e
https://github.com/manacode/phalconlibs/blob/e60864ac8305dd95e6804e4894193e5255725a5e/Translate/NativeArray.php#L26-L41
238,181
manacode/phalconlibs
Translate/NativeArray.php
NativeArray.setTranslation
public function setTranslation($translation) { if (is_array($translation)) { $this->_translate = array_merge($this->_translate, $translation); } }
php
public function setTranslation($translation) { if (is_array($translation)) { $this->_translate = array_merge($this->_translate, $translation); } }
[ "public", "function", "setTranslation", "(", "$", "translation", ")", "{", "if", "(", "is_array", "(", "$", "translation", ")", ")", "{", "$", "this", "->", "_translate", "=", "array_merge", "(", "$", "this", "->", "_translate", ",", "$", "translation", ")", ";", "}", "}" ]
Set translation data @param array $translation translation data
[ "Set", "translation", "data" ]
e60864ac8305dd95e6804e4894193e5255725a5e
https://github.com/manacode/phalconlibs/blob/e60864ac8305dd95e6804e4894193e5255725a5e/Translate/NativeArray.php#L66-L71
238,182
phossa2/libs
src/Phossa2/Cache/Extension/DistributedExpiration.php
DistributedExpiration.distributeExpire
public function distributeExpire(EventInterface $event)/*# : bool */ { $dist = $this->distribution; $item = $event->getParam('item'); if ($item instanceof CacheItemExtendedInterface) { // expire ttl $ttl = $item->getExpiration()->getTimestamp() - time(); // percentage $percent = (rand(0, $dist * 2) - $dist) * 0.001; // new expire ttl $new_ttl = (int) round($ttl + $ttl * $percent); $item->expiresAfter($new_ttl); } return true; }
php
public function distributeExpire(EventInterface $event)/*# : bool */ { $dist = $this->distribution; $item = $event->getParam('item'); if ($item instanceof CacheItemExtendedInterface) { // expire ttl $ttl = $item->getExpiration()->getTimestamp() - time(); // percentage $percent = (rand(0, $dist * 2) - $dist) * 0.001; // new expire ttl $new_ttl = (int) round($ttl + $ttl * $percent); $item->expiresAfter($new_ttl); } return true; }
[ "public", "function", "distributeExpire", "(", "EventInterface", "$", "event", ")", "/*# : bool */", "{", "$", "dist", "=", "$", "this", "->", "distribution", ";", "$", "item", "=", "$", "event", "->", "getParam", "(", "'item'", ")", ";", "if", "(", "$", "item", "instanceof", "CacheItemExtendedInterface", ")", "{", "// expire ttl", "$", "ttl", "=", "$", "item", "->", "getExpiration", "(", ")", "->", "getTimestamp", "(", ")", "-", "time", "(", ")", ";", "// percentage", "$", "percent", "=", "(", "rand", "(", "0", ",", "$", "dist", "*", "2", ")", "-", "$", "dist", ")", "*", "0.001", ";", "// new expire ttl", "$", "new_ttl", "=", "(", "int", ")", "round", "(", "$", "ttl", "+", "$", "ttl", "*", "$", "percent", ")", ";", "$", "item", "->", "expiresAfter", "(", "$", "new_ttl", ")", ";", "}", "return", "true", ";", "}" ]
Evenly distribute the expiration time @param EventInterface $event @return bool @access public
[ "Evenly", "distribute", "the", "expiration", "time" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/Extension/DistributedExpiration.php#L86-L104
238,183
mtoolkit/mtoolkit-core
src/MDir.php
MDir.count
public function count(): int { if ($this->count == null) { $this->count = 0; if ($handle = opendir($this->fileInfo->getAbsoluteFilePath())) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..'))) { $this->count++; } } closedir($handle); } } return $this->count; }
php
public function count(): int { if ($this->count == null) { $this->count = 0; if ($handle = opendir($this->fileInfo->getAbsoluteFilePath())) { while (($file = readdir($handle)) !== false) { if (!in_array($file, array('.', '..'))) { $this->count++; } } closedir($handle); } } return $this->count; }
[ "public", "function", "count", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "count", "==", "null", ")", "{", "$", "this", "->", "count", "=", "0", ";", "if", "(", "$", "handle", "=", "opendir", "(", "$", "this", "->", "fileInfo", "->", "getAbsoluteFilePath", "(", ")", ")", ")", "{", "while", "(", "(", "$", "file", "=", "readdir", "(", "$", "handle", ")", ")", "!==", "false", ")", "{", "if", "(", "!", "in_array", "(", "$", "file", ",", "array", "(", "'.'", ",", "'..'", ")", ")", ")", "{", "$", "this", "->", "count", "++", ";", "}", "}", "closedir", "(", "$", "handle", ")", ";", "}", "}", "return", "$", "this", "->", "count", ";", "}" ]
Returns the total number of directories and files in the directory. @return int
[ "Returns", "the", "total", "number", "of", "directories", "and", "files", "in", "the", "directory", "." ]
66c53273288a8652ff38240e063bdcffdf7c30aa
https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MDir.php#L146-L163
238,184
puli/asset-plugin
src/Api/Installer/NoSuchInstallerException.php
NoSuchInstallerException.forInstallerNameAndPackageName
public static function forInstallerNameAndPackageName($installerName, $packageName, Exception $cause = null) { return new static(sprintf( 'The installer "%s" does not exist in package "%s".', $installerName, $packageName ), 0, $cause); }
php
public static function forInstallerNameAndPackageName($installerName, $packageName, Exception $cause = null) { return new static(sprintf( 'The installer "%s" does not exist in package "%s".', $installerName, $packageName ), 0, $cause); }
[ "public", "static", "function", "forInstallerNameAndPackageName", "(", "$", "installerName", ",", "$", "packageName", ",", "Exception", "$", "cause", "=", "null", ")", "{", "return", "new", "static", "(", "sprintf", "(", "'The installer \"%s\" does not exist in package \"%s\".'", ",", "$", "installerName", ",", "$", "packageName", ")", ",", "0", ",", "$", "cause", ")", ";", "}" ]
Creates an exception for an installer name that was not found in a given package. @param string $installerName The installer name. @param string $packageName The package name. @param Exception $cause The exception that caused this exception. @return static The created exception.
[ "Creates", "an", "exception", "for", "an", "installer", "name", "that", "was", "not", "found", "in", "a", "given", "package", "." ]
f36c4a403a2173aced54376690a399884cde2627
https://github.com/puli/asset-plugin/blob/f36c4a403a2173aced54376690a399884cde2627/src/Api/Installer/NoSuchInstallerException.php#L50-L57
238,185
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.getModelsPathList
public function getModelsPathList() { if ($this->_modelsPath === null) { $this->_modelsPath = $this->getBasePath() . DIRECTORY_SEPARATOR . static::$modelsSubdir; // default $pathList = $this->getBasePathList(); foreach ($pathList as $path) { $resultPath = $path . DIRECTORY_SEPARATOR . static::$modelsSubdir; if (is_dir($resultPath)) { $this->_modelsPath = $resultPath; break; } } } return $this->_modelsPath; }
php
public function getModelsPathList() { if ($this->_modelsPath === null) { $this->_modelsPath = $this->getBasePath() . DIRECTORY_SEPARATOR . static::$modelsSubdir; // default $pathList = $this->getBasePathList(); foreach ($pathList as $path) { $resultPath = $path . DIRECTORY_SEPARATOR . static::$modelsSubdir; if (is_dir($resultPath)) { $this->_modelsPath = $resultPath; break; } } } return $this->_modelsPath; }
[ "public", "function", "getModelsPathList", "(", ")", "{", "if", "(", "$", "this", "->", "_modelsPath", "===", "null", ")", "{", "$", "this", "->", "_modelsPath", "=", "$", "this", "->", "getBasePath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "static", "::", "$", "modelsSubdir", ";", "// default", "$", "pathList", "=", "$", "this", "->", "getBasePathList", "(", ")", ";", "foreach", "(", "$", "pathList", "as", "$", "path", ")", "{", "$", "resultPath", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "static", "::", "$", "modelsSubdir", ";", "if", "(", "is_dir", "(", "$", "resultPath", ")", ")", "{", "$", "this", "->", "_modelsPath", "=", "$", "resultPath", ";", "break", ";", "}", "}", "}", "return", "$", "this", "->", "_modelsPath", ";", "}" ]
Will find first exists models directory from current and inheritance modules. @return string directory of models files. Defaults to "[[basePath]]/models".
[ "Will", "find", "first", "exists", "models", "directory", "from", "current", "and", "inheritance", "modules", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L131-L145
238,186
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.addRoutes
public function addRoutes() { list($rulesBefore, $rulesAfter) = $this->collectRoutes(); Yii::$app->urlManager->addRules($rulesBefore, false); Yii::$app->urlManager->addRules($rulesAfter, true); //echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit; }
php
public function addRoutes() { list($rulesBefore, $rulesAfter) = $this->collectRoutes(); Yii::$app->urlManager->addRules($rulesBefore, false); Yii::$app->urlManager->addRules($rulesAfter, true); //echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit; }
[ "public", "function", "addRoutes", "(", ")", "{", "list", "(", "$", "rulesBefore", ",", "$", "rulesAfter", ")", "=", "$", "this", "->", "collectRoutes", "(", ")", ";", "Yii", "::", "$", "app", "->", "urlManager", "->", "addRules", "(", "$", "rulesBefore", ",", "false", ")", ";", "Yii", "::", "$", "app", "->", "urlManager", "->", "addRules", "(", "$", "rulesAfter", ",", "true", ")", ";", "//echo'<pre>'.RoutesInfo::showRoutes($this->uniqueId).'</pre>';exit;", "}" ]
Add module routes defined in config.
[ "Add", "module", "routes", "defined", "in", "config", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L150-L156
238,187
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.setStartLink
protected function setStartLink($routeConfig) { if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) { $routeConfig['startLink'] = [ 'label' => $routeConfig['startLinkLabel'], 'link' => '', // default ]; } if (!empty($routeConfig['startLink'])) { if (!empty($routeConfig['startLink']['action'])) { $action = '/' . $routeConfig['moduleUid'] . '/' . $routeConfig['startLink']['action']; $route = [$action]; $url = Url::toRoute($action); } elseif (isset($routeConfig['startLink']['link'])) { $link = $routeConfig['startLink']['link']; $link = '/' . $routeConfig['urlPrefix'] . ( ($link == '' || $link == '?') ? '' : ('/' . $link) ) ; //$route = ??; $url = Url::toRoute($link); } else { throw new Exception("Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig"); } $tcCat = TranslationsBuilder::getBaseTransCategory($this); $label = $routeConfig['startLink']['label']; $linkData = [ 'label' => $label, 'tcCat' => $tcCat, 'link' => $url, ]; if (isset($route)) $linkData['route'] = $route; static::$_startLinks[$this->uniqueId][$routeConfig['routesType']] = $linkData; } }
php
protected function setStartLink($routeConfig) { if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) { $routeConfig['startLink'] = [ 'label' => $routeConfig['startLinkLabel'], 'link' => '', // default ]; } if (!empty($routeConfig['startLink'])) { if (!empty($routeConfig['startLink']['action'])) { $action = '/' . $routeConfig['moduleUid'] . '/' . $routeConfig['startLink']['action']; $route = [$action]; $url = Url::toRoute($action); } elseif (isset($routeConfig['startLink']['link'])) { $link = $routeConfig['startLink']['link']; $link = '/' . $routeConfig['urlPrefix'] . ( ($link == '' || $link == '?') ? '' : ('/' . $link) ) ; //$route = ??; $url = Url::toRoute($link); } else { throw new Exception("Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig"); } $tcCat = TranslationsBuilder::getBaseTransCategory($this); $label = $routeConfig['startLink']['label']; $linkData = [ 'label' => $label, 'tcCat' => $tcCat, 'link' => $url, ]; if (isset($route)) $linkData['route'] = $route; static::$_startLinks[$this->uniqueId][$routeConfig['routesType']] = $linkData; } }
[ "protected", "function", "setStartLink", "(", "$", "routeConfig", ")", "{", "if", "(", "empty", "(", "$", "routeConfig", "[", "'startLink'", "]", ")", "&&", "!", "empty", "(", "$", "routeConfig", "[", "'startLinkLabel'", "]", ")", ")", "{", "$", "routeConfig", "[", "'startLink'", "]", "=", "[", "'label'", "=>", "$", "routeConfig", "[", "'startLinkLabel'", "]", ",", "'link'", "=>", "''", ",", "// default", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "routeConfig", "[", "'startLink'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "routeConfig", "[", "'startLink'", "]", "[", "'action'", "]", ")", ")", "{", "$", "action", "=", "'/'", ".", "$", "routeConfig", "[", "'moduleUid'", "]", ".", "'/'", ".", "$", "routeConfig", "[", "'startLink'", "]", "[", "'action'", "]", ";", "$", "route", "=", "[", "$", "action", "]", ";", "$", "url", "=", "Url", "::", "toRoute", "(", "$", "action", ")", ";", "}", "elseif", "(", "isset", "(", "$", "routeConfig", "[", "'startLink'", "]", "[", "'link'", "]", ")", ")", "{", "$", "link", "=", "$", "routeConfig", "[", "'startLink'", "]", "[", "'link'", "]", ";", "$", "link", "=", "'/'", ".", "$", "routeConfig", "[", "'urlPrefix'", "]", ".", "(", "(", "$", "link", "==", "''", "||", "$", "link", "==", "'?'", ")", "?", "''", ":", "(", "'/'", ".", "$", "link", ")", ")", ";", "//$route = ??;", "$", "url", "=", "Url", "::", "toRoute", "(", "$", "link", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig\"", ")", ";", "}", "$", "tcCat", "=", "TranslationsBuilder", "::", "getBaseTransCategory", "(", "$", "this", ")", ";", "$", "label", "=", "$", "routeConfig", "[", "'startLink'", "]", "[", "'label'", "]", ";", "$", "linkData", "=", "[", "'label'", "=>", "$", "label", ",", "'tcCat'", "=>", "$", "tcCat", ",", "'link'", "=>", "$", "url", ",", "]", ";", "if", "(", "isset", "(", "$", "route", ")", ")", "$", "linkData", "[", "'route'", "]", "=", "$", "route", ";", "static", "::", "$", "_startLinks", "[", "$", "this", "->", "uniqueId", "]", "[", "$", "routeConfig", "[", "'routesType'", "]", "]", "=", "$", "linkData", ";", "}", "}" ]
Set start link for module.
[ "Set", "start", "link", "for", "module", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L274-L309
238,188
asbsoft/yii2-common_2_170212
base/BaseModule.php
BaseModule.startLink
public static function startLink($moduleUid, $routesType) { if (!empty(static::$_startLinks[$moduleUid][$routesType])) { $linkData = static::$_startLinks[$moduleUid][$routesType]; $tcCat = $linkData['tcCat']; $tc = "{$tcCat}/module"; if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) { $label = $linkData['label']; $linkData['label'] = Yii::t($tc, $label); } return $linkData; } return false; }
php
public static function startLink($moduleUid, $routesType) { if (!empty(static::$_startLinks[$moduleUid][$routesType])) { $linkData = static::$_startLinks[$moduleUid][$routesType]; $tcCat = $linkData['tcCat']; $tc = "{$tcCat}/module"; if (!empty(Yii::$app->i18n->translations["{$tcCat}*"])) { $label = $linkData['label']; $linkData['label'] = Yii::t($tc, $label); } return $linkData; } return false; }
[ "public", "static", "function", "startLink", "(", "$", "moduleUid", ",", "$", "routesType", ")", "{", "if", "(", "!", "empty", "(", "static", "::", "$", "_startLinks", "[", "$", "moduleUid", "]", "[", "$", "routesType", "]", ")", ")", "{", "$", "linkData", "=", "static", "::", "$", "_startLinks", "[", "$", "moduleUid", "]", "[", "$", "routesType", "]", ";", "$", "tcCat", "=", "$", "linkData", "[", "'tcCat'", "]", ";", "$", "tc", "=", "\"{$tcCat}/module\"", ";", "if", "(", "!", "empty", "(", "Yii", "::", "$", "app", "->", "i18n", "->", "translations", "[", "\"{$tcCat}*\"", "]", ")", ")", "{", "$", "label", "=", "$", "linkData", "[", "'label'", "]", ";", "$", "linkData", "[", "'label'", "]", "=", "Yii", "::", "t", "(", "$", "tc", ",", "$", "label", ")", ";", "}", "return", "$", "linkData", ";", "}", "return", "false", ";", "}" ]
Get start link for module. @var string $moduleUid unique id of module @var string $routesType type of routes collection
[ "Get", "start", "link", "for", "module", "." ]
6c58012ff89225d7d4e42b200cf39e009e9d9dac
https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/base/BaseModule.php#L315-L329
238,189
integratedfordevelopers/integrated-comment-bundle
Form/DataTransformer/CommentTagTransformer.php
CommentTagTransformer.transform
public function transform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace comments with span so that we can add a nice style to the commented section $content = StripTagsUtil::replaceCommentWith($content, StripTagsUtil::SPAN_REPLACEMENT); return $content; }
php
public function transform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace comments with span so that we can add a nice style to the commented section $content = StripTagsUtil::replaceCommentWith($content, StripTagsUtil::SPAN_REPLACEMENT); return $content; }
[ "public", "function", "transform", "(", "$", "content", ")", "{", "if", "(", "null", "===", "$", "content", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "sprintf", "(", "'Expected string, %s given'", ",", "gettype", "(", "$", "content", ")", ")", ")", ";", "}", "//replace comments with span so that we can add a nice style to the commented section", "$", "content", "=", "StripTagsUtil", "::", "replaceCommentWith", "(", "$", "content", ",", "StripTagsUtil", "::", "SPAN_REPLACEMENT", ")", ";", "return", "$", "content", ";", "}" ]
Transforms html comments to span elements @param string|null $content @return string|null @throws TransformationFailedException
[ "Transforms", "html", "comments", "to", "span", "elements" ]
c337cb937040d4bf94674ade767db0931a522f5d
https://github.com/integratedfordevelopers/integrated-comment-bundle/blob/c337cb937040d4bf94674ade767db0931a522f5d/Form/DataTransformer/CommentTagTransformer.php#L31-L48
238,190
integratedfordevelopers/integrated-comment-bundle
Form/DataTransformer/CommentTagTransformer.php
CommentTagTransformer.reverseTransform
public function reverseTransform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace span with comment tag, so no weird style is added on front-end $content = StripTagsUtil::replaceSpanWith($content, StripTagsUtil::COMMENT_REPLACEMENT); return $content; }
php
public function reverseTransform($content) { if (null === $content) { return null; } if (!is_string($content)) { throw new TransformationFailedException(sprintf( 'Expected string, %s given', gettype($content) )); } //replace span with comment tag, so no weird style is added on front-end $content = StripTagsUtil::replaceSpanWith($content, StripTagsUtil::COMMENT_REPLACEMENT); return $content; }
[ "public", "function", "reverseTransform", "(", "$", "content", ")", "{", "if", "(", "null", "===", "$", "content", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "sprintf", "(", "'Expected string, %s given'", ",", "gettype", "(", "$", "content", ")", ")", ")", ";", "}", "//replace span with comment tag, so no weird style is added on front-end", "$", "content", "=", "StripTagsUtil", "::", "replaceSpanWith", "(", "$", "content", ",", "StripTagsUtil", "::", "COMMENT_REPLACEMENT", ")", ";", "return", "$", "content", ";", "}" ]
Transforms span elements to html comments @param string|null $content @return string|null @throws TransformationFailedException
[ "Transforms", "span", "elements", "to", "html", "comments" ]
c337cb937040d4bf94674ade767db0931a522f5d
https://github.com/integratedfordevelopers/integrated-comment-bundle/blob/c337cb937040d4bf94674ade767db0931a522f5d/Form/DataTransformer/CommentTagTransformer.php#L57-L74
238,191
IVIR3zaM/ObjectArrayTools
src/Traits/IteratorTrait.php
IteratorTrait.current
public function current() { if ($this->valid()) { $key = $this->baseArrayMap[$this->iteratorIterationPosition]; $value = $this->baseConcreteData[$key]; return $this->internalFilterHooks($key, $value, 'output') ? $this->internalSanitizeHooks($key, $value, 'output') : null; } }
php
public function current() { if ($this->valid()) { $key = $this->baseArrayMap[$this->iteratorIterationPosition]; $value = $this->baseConcreteData[$key]; return $this->internalFilterHooks($key, $value, 'output') ? $this->internalSanitizeHooks($key, $value, 'output') : null; } }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "valid", "(", ")", ")", "{", "$", "key", "=", "$", "this", "->", "baseArrayMap", "[", "$", "this", "->", "iteratorIterationPosition", "]", ";", "$", "value", "=", "$", "this", "->", "baseConcreteData", "[", "$", "key", "]", ";", "return", "$", "this", "->", "internalFilterHooks", "(", "$", "key", ",", "$", "value", ",", "'output'", ")", "?", "$", "this", "->", "internalSanitizeHooks", "(", "$", "key", ",", "$", "value", ",", "'output'", ")", ":", "null", ";", "}", "}" ]
this is necessary for Iterator Interface and return current element @return mixed current element or null
[ "this", "is", "necessary", "for", "Iterator", "Interface", "and", "return", "current", "element" ]
31c12fc6f8a40a36873c074409ae4299b35f9177
https://github.com/IVIR3zaM/ObjectArrayTools/blob/31c12fc6f8a40a36873c074409ae4299b35f9177/src/Traits/IteratorTrait.php#L42-L50
238,192
gossi/trixionary
src/model/Map/SkillGroupTableMap.php
SkillGroupTableMap.doInsert
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillGroupTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillGroup object } // Set the correct dbName $query = SkillGroupQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
php
public static function doInsert($criteria, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(SkillGroupTableMap::DATABASE_NAME); } if ($criteria instanceof Criteria) { $criteria = clone $criteria; // rename for clarity } else { $criteria = $criteria->buildCriteria(); // build Criteria from SkillGroup object } // Set the correct dbName $query = SkillGroupQuery::create()->mergeWith($criteria); // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) return $con->transaction(function () use ($con, $query) { return $query->doInsert($con); }); }
[ "public", "static", "function", "doInsert", "(", "$", "criteria", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "SkillGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "criteria", ";", "// rename for clarity", "}", "else", "{", "$", "criteria", "=", "$", "criteria", "->", "buildCriteria", "(", ")", ";", "// build Criteria from SkillGroup object", "}", "// Set the correct dbName", "$", "query", "=", "SkillGroupQuery", "::", "create", "(", ")", "->", "mergeWith", "(", "$", "criteria", ")", ";", "// use transaction because $criteria could contain info", "// for more than one table (I guess, conceivably)", "return", "$", "con", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "con", ",", "$", "query", ")", "{", "return", "$", "query", "->", "doInsert", "(", "$", "con", ")", ";", "}", ")", ";", "}" ]
Performs an INSERT on the database, given a SkillGroup or Criteria object. @param mixed $criteria Criteria or SkillGroup object containing data that is used to create the INSERT statement. @param ConnectionInterface $con the ConnectionInterface connection to use @return mixed The new primary key. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "INSERT", "on", "the", "database", "given", "a", "SkillGroup", "or", "Criteria", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Map/SkillGroupTableMap.php#L478-L499
238,193
webriq/core
module/Core/src/Grid/Core/View/Widget/AbstractWidget.php
AbstractWidget.render
public function render( RendererInterface $renderer, $content, array $params ) { return $renderer->render( $this->getTemplate(), $this->getVariables( array_merge( $params, array( 'content' => $content, ) ) ) ); }
php
public function render( RendererInterface $renderer, $content, array $params ) { return $renderer->render( $this->getTemplate(), $this->getVariables( array_merge( $params, array( 'content' => $content, ) ) ) ); }
[ "public", "function", "render", "(", "RendererInterface", "$", "renderer", ",", "$", "content", ",", "array", "$", "params", ")", "{", "return", "$", "renderer", "->", "render", "(", "$", "this", "->", "getTemplate", "(", ")", ",", "$", "this", "->", "getVariables", "(", "array_merge", "(", "$", "params", ",", "array", "(", "'content'", "=>", "$", "content", ",", ")", ")", ")", ")", ";", "}" ]
Render the widget @param RendererInterface $renderer @param string $content @param array $params @return string
[ "Render", "the", "widget" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/View/Widget/AbstractWidget.php#L59-L67
238,194
indigophp-archive/http-adapter
src/Adapter/Cache.php
Cache.setModifiedSince
private function setModifiedSince(Request $request, Item $item) { if ($modifiedAt = $item->getCreation()) { $modifiedAt->setTimezone(new DateTimeZone('GMT')); $date = sprintf('%s GMT', $modifiedAt->format('l, d-M-y H:i:s')); $request->addHeader('If-Modified-Since', $date); } }
php
private function setModifiedSince(Request $request, Item $item) { if ($modifiedAt = $item->getCreation()) { $modifiedAt->setTimezone(new DateTimeZone('GMT')); $date = sprintf('%s GMT', $modifiedAt->format('l, d-M-y H:i:s')); $request->addHeader('If-Modified-Since', $date); } }
[ "private", "function", "setModifiedSince", "(", "Request", "$", "request", ",", "Item", "$", "item", ")", "{", "if", "(", "$", "modifiedAt", "=", "$", "item", "->", "getCreation", "(", ")", ")", "{", "$", "modifiedAt", "->", "setTimezone", "(", "new", "DateTimeZone", "(", "'GMT'", ")", ")", ";", "$", "date", "=", "sprintf", "(", "'%s GMT'", ",", "$", "modifiedAt", "->", "format", "(", "'l, d-M-y H:i:s'", ")", ")", ";", "$", "request", "->", "addHeader", "(", "'If-Modified-Since'", ",", "$", "date", ")", ";", "}", "}" ]
Sets If-Modified-Since header if creation time is available @param Request $request @param Item $item
[ "Sets", "If", "-", "Modified", "-", "Since", "header", "if", "creation", "time", "is", "available" ]
2233e8329a0704e020857228c2b538438e127475
https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Adapter/Cache.php#L65-L74
238,195
indigophp-archive/http-adapter
src/Adapter/Cache.php
Cache.setEtag
private function setEtag(Request $request, Response $cachedResponse) { if ($etag = $cachedResponse->getHeader('ETag')) { $request->addHeader('If-None-Match', $etag); } }
php
private function setEtag(Request $request, Response $cachedResponse) { if ($etag = $cachedResponse->getHeader('ETag')) { $request->addHeader('If-None-Match', $etag); } }
[ "private", "function", "setEtag", "(", "Request", "$", "request", ",", "Response", "$", "cachedResponse", ")", "{", "if", "(", "$", "etag", "=", "$", "cachedResponse", "->", "getHeader", "(", "'ETag'", ")", ")", "{", "$", "request", "->", "addHeader", "(", "'If-None-Match'", ",", "$", "etag", ")", ";", "}", "}" ]
Sets ETag if available in the cached response @param Request $request @param Response $cachedResponse
[ "Sets", "ETag", "if", "available", "in", "the", "cached", "response" ]
2233e8329a0704e020857228c2b538438e127475
https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Adapter/Cache.php#L82-L87
238,196
naturalweb/FileStorage
src/NaturalWeb/FileStorage/FileStorage.php
FileStorage.save
public function save($name, $source, $folder, $override = false) { $return = false; try { if (!$this->storage->exists($folder)) { $this->storage->createFolder($folder); } $path = $this->setFilename($name, $folder, $override); $this->storage->upload($source, $path, $override); $return = array( 'name' => $name, 'path' => $path, 'url' => $this->storage->getUrl($path), ); $this->error = null; } catch(Exception $e) { $this->error = $e; $return = false; } return $return; }
php
public function save($name, $source, $folder, $override = false) { $return = false; try { if (!$this->storage->exists($folder)) { $this->storage->createFolder($folder); } $path = $this->setFilename($name, $folder, $override); $this->storage->upload($source, $path, $override); $return = array( 'name' => $name, 'path' => $path, 'url' => $this->storage->getUrl($path), ); $this->error = null; } catch(Exception $e) { $this->error = $e; $return = false; } return $return; }
[ "public", "function", "save", "(", "$", "name", ",", "$", "source", ",", "$", "folder", ",", "$", "override", "=", "false", ")", "{", "$", "return", "=", "false", ";", "try", "{", "if", "(", "!", "$", "this", "->", "storage", "->", "exists", "(", "$", "folder", ")", ")", "{", "$", "this", "->", "storage", "->", "createFolder", "(", "$", "folder", ")", ";", "}", "$", "path", "=", "$", "this", "->", "setFilename", "(", "$", "name", ",", "$", "folder", ",", "$", "override", ")", ";", "$", "this", "->", "storage", "->", "upload", "(", "$", "source", ",", "$", "path", ",", "$", "override", ")", ";", "$", "return", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'path'", "=>", "$", "path", ",", "'url'", "=>", "$", "this", "->", "storage", "->", "getUrl", "(", "$", "path", ")", ",", ")", ";", "$", "this", "->", "error", "=", "null", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "error", "=", "$", "e", ";", "$", "return", "=", "false", ";", "}", "return", "$", "return", ";", "}" ]
Salva o arquivo no storage @param string $name Name Original @param string $source Source File @param string $folder Remote Folder @param bool $override Override? @return array [name,path,url]|false
[ "Salva", "o", "arquivo", "no", "storage" ]
3d2c9b0187685da8fc71bdf08456da8732f751dd
https://github.com/naturalweb/FileStorage/blob/3d2c9b0187685da8fc71bdf08456da8732f751dd/src/NaturalWeb/FileStorage/FileStorage.php#L54-L79
238,197
naturalweb/FileStorage
src/NaturalWeb/FileStorage/FileStorage.php
FileStorage.setFilename
protected function setFilename(&$name, $folder, $override = false) { $folder = trim($folder, '/'); $extension = strrchr($name, '.'); $len = mb_strlen($name) - mb_strlen($extension); $nameOrig = substr($name,0,$len); $num = 0; do { if (!$override && $num > 0) { $name = "{$nameOrig}-{$num}{$extension}"; } $num++; $filename = "/{$folder}/{$name}"; } while ($this->storage->exists($filename)); return $filename; }
php
protected function setFilename(&$name, $folder, $override = false) { $folder = trim($folder, '/'); $extension = strrchr($name, '.'); $len = mb_strlen($name) - mb_strlen($extension); $nameOrig = substr($name,0,$len); $num = 0; do { if (!$override && $num > 0) { $name = "{$nameOrig}-{$num}{$extension}"; } $num++; $filename = "/{$folder}/{$name}"; } while ($this->storage->exists($filename)); return $filename; }
[ "protected", "function", "setFilename", "(", "&", "$", "name", ",", "$", "folder", ",", "$", "override", "=", "false", ")", "{", "$", "folder", "=", "trim", "(", "$", "folder", ",", "'/'", ")", ";", "$", "extension", "=", "strrchr", "(", "$", "name", ",", "'.'", ")", ";", "$", "len", "=", "mb_strlen", "(", "$", "name", ")", "-", "mb_strlen", "(", "$", "extension", ")", ";", "$", "nameOrig", "=", "substr", "(", "$", "name", ",", "0", ",", "$", "len", ")", ";", "$", "num", "=", "0", ";", "do", "{", "if", "(", "!", "$", "override", "&&", "$", "num", ">", "0", ")", "{", "$", "name", "=", "\"{$nameOrig}-{$num}{$extension}\"", ";", "}", "$", "num", "++", ";", "$", "filename", "=", "\"/{$folder}/{$name}\"", ";", "}", "while", "(", "$", "this", "->", "storage", "->", "exists", "(", "$", "filename", ")", ")", ";", "return", "$", "filename", ";", "}" ]
Crypt filename and concat with folder @param string $name Name Original, Return Referer @param string $folder Remote Folder @return string @throws
[ "Crypt", "filename", "and", "concat", "with", "folder" ]
3d2c9b0187685da8fc71bdf08456da8732f751dd
https://github.com/naturalweb/FileStorage/blob/3d2c9b0187685da8fc71bdf08456da8732f751dd/src/NaturalWeb/FileStorage/FileStorage.php#L100-L117
238,198
jakew/cases
src/Dictionary.php
Dictionary.addWord
public function addWord(string $capitalCase, string $lowerCase = null) { if ($lowerCase == null) { $lowerCase = strtolower($capitalCase); } $index = strtolower($lowerCase); $record = [$capitalCase, $lowerCase]; $this->words[$index] = $record; if ($index !== strtolower($capitalCase)) { $this->words[strtolower($capitalCase)] = $record; } }
php
public function addWord(string $capitalCase, string $lowerCase = null) { if ($lowerCase == null) { $lowerCase = strtolower($capitalCase); } $index = strtolower($lowerCase); $record = [$capitalCase, $lowerCase]; $this->words[$index] = $record; if ($index !== strtolower($capitalCase)) { $this->words[strtolower($capitalCase)] = $record; } }
[ "public", "function", "addWord", "(", "string", "$", "capitalCase", ",", "string", "$", "lowerCase", "=", "null", ")", "{", "if", "(", "$", "lowerCase", "==", "null", ")", "{", "$", "lowerCase", "=", "strtolower", "(", "$", "capitalCase", ")", ";", "}", "$", "index", "=", "strtolower", "(", "$", "lowerCase", ")", ";", "$", "record", "=", "[", "$", "capitalCase", ",", "$", "lowerCase", "]", ";", "$", "this", "->", "words", "[", "$", "index", "]", "=", "$", "record", ";", "if", "(", "$", "index", "!==", "strtolower", "(", "$", "capitalCase", ")", ")", "{", "$", "this", "->", "words", "[", "strtolower", "(", "$", "capitalCase", ")", "]", "=", "$", "record", ";", "}", "}" ]
Add a word to the singletons dictionary. @param string $capitalCase The capital version of the word. @param string|null $lowerCase The lowercase version, in case it is different from the capital case but all lower.
[ "Add", "a", "word", "to", "the", "singletons", "dictionary", "." ]
949bd1933c8dceac5543e9758daf11d93b2bb69e
https://github.com/jakew/cases/blob/949bd1933c8dceac5543e9758daf11d93b2bb69e/src/Dictionary.php#L31-L45
238,199
jakew/cases
src/Dictionary.php
Dictionary.getWord
public function getWord(string $word) { if (isset($this->words[strtolower($word)])) { return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]); } return new Word($word); }
php
public function getWord(string $word) { if (isset($this->words[strtolower($word)])) { return new SpecialWord($word, $this->words[strtolower($word)][0], $this->words[strtolower($word)][1]); } return new Word($word); }
[ "public", "function", "getWord", "(", "string", "$", "word", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "words", "[", "strtolower", "(", "$", "word", ")", "]", ")", ")", "{", "return", "new", "SpecialWord", "(", "$", "word", ",", "$", "this", "->", "words", "[", "strtolower", "(", "$", "word", ")", "]", "[", "0", "]", ",", "$", "this", "->", "words", "[", "strtolower", "(", "$", "word", ")", "]", "[", "1", "]", ")", ";", "}", "return", "new", "Word", "(", "$", "word", ")", ";", "}" ]
Returns an instance of Word or SpecialWord for the word provided. @param string $word The word we are looking to get. @return SpecialWord|Word The Word instance if it is normal, and SpecialWord if it exists in our store.
[ "Returns", "an", "instance", "of", "Word", "or", "SpecialWord", "for", "the", "word", "provided", "." ]
949bd1933c8dceac5543e9758daf11d93b2bb69e
https://github.com/jakew/cases/blob/949bd1933c8dceac5543e9758daf11d93b2bb69e/src/Dictionary.php#L53-L60