id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
3,600
coolms/common
src/Form/View/Helper/FormRow.php
FormRow.getStaticElementHelper
protected function getStaticElementHelper() { if ($this->staticElementHelper) { return $this->staticElementHelper; } $renderer = $this->getView(); if (method_exists($this->view, 'plugin')) { $this->staticElementHelper = $renderer->plugin($this->defaultStaticElementHelper); } if (!$this->staticElementHelper instanceof FormStatic) { $this->staticElementHelper = new FormStatic(); $this->staticElementHelper->setView($renderer); } return $this->staticElementHelper; }
php
protected function getStaticElementHelper() { if ($this->staticElementHelper) { return $this->staticElementHelper; } $renderer = $this->getView(); if (method_exists($this->view, 'plugin')) { $this->staticElementHelper = $renderer->plugin($this->defaultStaticElementHelper); } if (!$this->staticElementHelper instanceof FormStatic) { $this->staticElementHelper = new FormStatic(); $this->staticElementHelper->setView($renderer); } return $this->staticElementHelper; }
[ "protected", "function", "getStaticElementHelper", "(", ")", "{", "if", "(", "$", "this", "->", "staticElementHelper", ")", "{", "return", "$", "this", "->", "staticElementHelper", ";", "}", "$", "renderer", "=", "$", "this", "->", "getView", "(", ")", ";", "if", "(", "method_exists", "(", "$", "this", "->", "view", ",", "'plugin'", ")", ")", "{", "$", "this", "->", "staticElementHelper", "=", "$", "renderer", "->", "plugin", "(", "$", "this", "->", "defaultStaticElementHelper", ")", ";", "}", "if", "(", "!", "$", "this", "->", "staticElementHelper", "instanceof", "FormStatic", ")", "{", "$", "this", "->", "staticElementHelper", "=", "new", "FormStatic", "(", ")", ";", "$", "this", "->", "staticElementHelper", "->", "setView", "(", "$", "renderer", ")", ";", "}", "return", "$", "this", "->", "staticElementHelper", ";", "}" ]
Retrieve the FormStatic helper @return FormStatic
[ "Retrieve", "the", "FormStatic", "helper" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/View/Helper/FormRow.php#L243-L260
3,601
sellerlabs/nucleus
src/SellerLabs/Nucleus/View/Node.php
Node.renderAttribute
protected function renderAttribute($name, $value = null) { if ($value === null) { return $name; } if (is_array($value)) { $value = implode(' ', $value); } return vsprintf('%s="%s"', [ $name, Html::escape((string) $value), ]); }
php
protected function renderAttribute($name, $value = null) { if ($value === null) { return $name; } if (is_array($value)) { $value = implode(' ', $value); } return vsprintf('%s="%s"', [ $name, Html::escape((string) $value), ]); }
[ "protected", "function", "renderAttribute", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "return", "$", "name", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "' '", ",", "$", "value", ")", ";", "}", "return", "vsprintf", "(", "'%s=\"%s\"'", ",", "[", "$", "name", ",", "Html", "::", "escape", "(", "(", "string", ")", "$", "value", ")", ",", "]", ")", ";", "}" ]
Render a single attribute in a node. @param string $name @param null|string $value @return string
[ "Render", "a", "single", "attribute", "in", "a", "node", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/View/Node.php#L118-L132
3,602
sellerlabs/nucleus
src/SellerLabs/Nucleus/View/Node.php
Node.renderAttributes
protected function renderAttributes() { return ArrayMap::of($this->attributes) ->map(function ($value, $name) { return $this->renderAttribute($name, $value); }) ->join(' '); }
php
protected function renderAttributes() { return ArrayMap::of($this->attributes) ->map(function ($value, $name) { return $this->renderAttribute($name, $value); }) ->join(' '); }
[ "protected", "function", "renderAttributes", "(", ")", "{", "return", "ArrayMap", "::", "of", "(", "$", "this", "->", "attributes", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "name", ")", "{", "return", "$", "this", "->", "renderAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "}", ")", "->", "join", "(", "' '", ")", ";", "}" ]
Render the attributes part of the opening tag. @return string
[ "Render", "the", "attributes", "part", "of", "the", "opening", "tag", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/View/Node.php#L139-L146
3,603
sellerlabs/nucleus
src/SellerLabs/Nucleus/View/Node.php
Node.renderContent
protected function renderContent() { if (is_string($this->content) || $this->content instanceof SafeHtmlWrapper || $this->content instanceof SafeHtmlProducerInterface ) { return Html::escape($this->content); } elseif ($this->content instanceof RenderableInterface) { return Html::escape($this->content->render()); } elseif (is_array($this->content) || $this->content instanceof ArrayableInterface ) { return ArrayList::of($this->content) ->map(function ($child) { if (is_string($child) || $child instanceof SafeHtmlWrapper || $child instanceof SafeHtmlProducerInterface ) { return Html::escape($child); } elseif ($child instanceof RenderableInterface) { return Html::escape($child->render()); } throw new NodeChildRenderingException($child); }) ->join(); } throw new NodeRenderingException($this->content); }
php
protected function renderContent() { if (is_string($this->content) || $this->content instanceof SafeHtmlWrapper || $this->content instanceof SafeHtmlProducerInterface ) { return Html::escape($this->content); } elseif ($this->content instanceof RenderableInterface) { return Html::escape($this->content->render()); } elseif (is_array($this->content) || $this->content instanceof ArrayableInterface ) { return ArrayList::of($this->content) ->map(function ($child) { if (is_string($child) || $child instanceof SafeHtmlWrapper || $child instanceof SafeHtmlProducerInterface ) { return Html::escape($child); } elseif ($child instanceof RenderableInterface) { return Html::escape($child->render()); } throw new NodeChildRenderingException($child); }) ->join(); } throw new NodeRenderingException($this->content); }
[ "protected", "function", "renderContent", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "content", ")", "||", "$", "this", "->", "content", "instanceof", "SafeHtmlWrapper", "||", "$", "this", "->", "content", "instanceof", "SafeHtmlProducerInterface", ")", "{", "return", "Html", "::", "escape", "(", "$", "this", "->", "content", ")", ";", "}", "elseif", "(", "$", "this", "->", "content", "instanceof", "RenderableInterface", ")", "{", "return", "Html", "::", "escape", "(", "$", "this", "->", "content", "->", "render", "(", ")", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "this", "->", "content", ")", "||", "$", "this", "->", "content", "instanceof", "ArrayableInterface", ")", "{", "return", "ArrayList", "::", "of", "(", "$", "this", "->", "content", ")", "->", "map", "(", "function", "(", "$", "child", ")", "{", "if", "(", "is_string", "(", "$", "child", ")", "||", "$", "child", "instanceof", "SafeHtmlWrapper", "||", "$", "child", "instanceof", "SafeHtmlProducerInterface", ")", "{", "return", "Html", "::", "escape", "(", "$", "child", ")", ";", "}", "elseif", "(", "$", "child", "instanceof", "RenderableInterface", ")", "{", "return", "Html", "::", "escape", "(", "$", "child", "->", "render", "(", ")", ")", ";", "}", "throw", "new", "NodeChildRenderingException", "(", "$", "child", ")", ";", "}", ")", "->", "join", "(", ")", ";", "}", "throw", "new", "NodeRenderingException", "(", "$", "this", "->", "content", ")", ";", "}" ]
Render the content of the tag. @throws CoreException @return string
[ "Render", "the", "content", "of", "the", "tag", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/View/Node.php#L154-L183
3,604
sellerlabs/nucleus
src/SellerLabs/Nucleus/View/Node.php
Node.render
public function render() { $result = $this->spec->check($this->attributes); if ($result->failed()) { throw new InvalidAttributesException($result); } $attributes = $this->renderAttributes(); if (strlen($attributes)) { $attributes = ' ' . $attributes; } if ($this->selfClosing) { return vsprintf( '<%s%s/>', [$this->tagName, $attributes] ); } return vsprintf( '<%s%s>%s</%s>', [ $this->tagName, $attributes, $this->renderContent(), $this->tagName, ] ); }
php
public function render() { $result = $this->spec->check($this->attributes); if ($result->failed()) { throw new InvalidAttributesException($result); } $attributes = $this->renderAttributes(); if (strlen($attributes)) { $attributes = ' ' . $attributes; } if ($this->selfClosing) { return vsprintf( '<%s%s/>', [$this->tagName, $attributes] ); } return vsprintf( '<%s%s>%s</%s>', [ $this->tagName, $attributes, $this->renderContent(), $this->tagName, ] ); }
[ "public", "function", "render", "(", ")", "{", "$", "result", "=", "$", "this", "->", "spec", "->", "check", "(", "$", "this", "->", "attributes", ")", ";", "if", "(", "$", "result", "->", "failed", "(", ")", ")", "{", "throw", "new", "InvalidAttributesException", "(", "$", "result", ")", ";", "}", "$", "attributes", "=", "$", "this", "->", "renderAttributes", "(", ")", ";", "if", "(", "strlen", "(", "$", "attributes", ")", ")", "{", "$", "attributes", "=", "' '", ".", "$", "attributes", ";", "}", "if", "(", "$", "this", "->", "selfClosing", ")", "{", "return", "vsprintf", "(", "'<%s%s/>'", ",", "[", "$", "this", "->", "tagName", ",", "$", "attributes", "]", ")", ";", "}", "return", "vsprintf", "(", "'<%s%s>%s</%s>'", ",", "[", "$", "this", "->", "tagName", ",", "$", "attributes", ",", "$", "this", "->", "renderContent", "(", ")", ",", "$", "this", "->", "tagName", ",", "]", ")", ";", "}" ]
Render the Node. @throws CoreException @throws InvalidAttributesException @return string
[ "Render", "the", "Node", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/View/Node.php#L192-L220
3,605
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.dispatch
public function dispatch($url, Request $request, Response $response) { $output = $this->resolveOutput($url, $request->isAjax()); if(is_object($output)) { if($output instanceof ElementInterface) { $response->addHeader("X-Loops-ID", $output->getLoopsId()); } $output = $this->display($output, $request, $response); } $response->setHeader(); return $output; }
php
public function dispatch($url, Request $request, Response $response) { $output = $this->resolveOutput($url, $request->isAjax()); if(is_object($output)) { if($output instanceof ElementInterface) { $response->addHeader("X-Loops-ID", $output->getLoopsId()); } $output = $this->display($output, $request, $response); } $response->setHeader(); return $output; }
[ "public", "function", "dispatch", "(", "$", "url", ",", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "output", "=", "$", "this", "->", "resolveOutput", "(", "$", "url", ",", "$", "request", "->", "isAjax", "(", ")", ")", ";", "if", "(", "is_object", "(", "$", "output", ")", ")", "{", "if", "(", "$", "output", "instanceof", "ElementInterface", ")", "{", "$", "response", "->", "addHeader", "(", "\"X-Loops-ID\"", ",", "$", "output", "->", "getLoopsId", "(", ")", ")", ";", "}", "$", "output", "=", "$", "this", "->", "display", "(", "$", "output", ",", "$", "request", ",", "$", "response", ")", ";", "}", "$", "response", "->", "setHeader", "(", ")", ";", "return", "$", "output", ";", "}" ]
Dispatches a web request to an url and returns the contents to display To generate the output, other resources are used such as the request service. After the page element is resolved (see resolvePage method for detail) its action method is called to determine if the requests could be handled. Depending on the result of the action method the output is generated. Strings will be displayed as they are. Integers will be used to create a Loops\ErrorPage object that is going to be displayed. Returned objects will be displayed unless this is an ajax request, where the page object is going to be displayed instead. The Loopsid of the finally selected object will be set in the response header as "X-Loops-ID" @param string $url The accessed URL @return string The content that should be displayed for this request.
[ "Dispatches", "a", "web", "request", "to", "an", "url", "and", "returns", "the", "contents", "to", "display" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L93-L107
3,606
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.getParameterCount
public static function getParameterCount($pageclass) { if(is_object($pageclass)) { $pageclass = get_class($pageclass); } $count = array_count_values(explode("\\", $pageclass)); return array_key_exists("_", $count) ? $count["_"] : 0; }
php
public static function getParameterCount($pageclass) { if(is_object($pageclass)) { $pageclass = get_class($pageclass); } $count = array_count_values(explode("\\", $pageclass)); return array_key_exists("_", $count) ? $count["_"] : 0; }
[ "public", "static", "function", "getParameterCount", "(", "$", "pageclass", ")", "{", "if", "(", "is_object", "(", "$", "pageclass", ")", ")", "{", "$", "pageclass", "=", "get_class", "(", "$", "pageclass", ")", ";", "}", "$", "count", "=", "array_count_values", "(", "explode", "(", "\"\\\\\"", ",", "$", "pageclass", ")", ")", ";", "return", "array_key_exists", "(", "\"_\"", ",", "$", "count", ")", "?", "$", "count", "[", "\"_\"", "]", ":", "0", ";", "}" ]
Counts the number of the needed page parameter given the classname or an object See method resolvePage for details @param string $pageclass @return integer The number of needed page parameter.
[ "Counts", "the", "number", "of", "the", "needed", "page", "parameter", "given", "the", "classname", "or", "an", "object" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L162-L168
3,607
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.display
private function display($element, Request $request, Response $response) { $loops = $this->getLoops(); $renderer = $loops->getService("renderer"); $appearance = []; if($request->isAjax()) { $renderer->addExtraAppearance("ajax"); } $renderer->addExtraAppearance((string)$response->status_code); return $renderer->render($element, $appearance); }
php
private function display($element, Request $request, Response $response) { $loops = $this->getLoops(); $renderer = $loops->getService("renderer"); $appearance = []; if($request->isAjax()) { $renderer->addExtraAppearance("ajax"); } $renderer->addExtraAppearance((string)$response->status_code); return $renderer->render($element, $appearance); }
[ "private", "function", "display", "(", "$", "element", ",", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "$", "loops", "=", "$", "this", "->", "getLoops", "(", ")", ";", "$", "renderer", "=", "$", "loops", "->", "getService", "(", "\"renderer\"", ")", ";", "$", "appearance", "=", "[", "]", ";", "if", "(", "$", "request", "->", "isAjax", "(", ")", ")", "{", "$", "renderer", "->", "addExtraAppearance", "(", "\"ajax\"", ")", ";", "}", "$", "renderer", "->", "addExtraAppearance", "(", "(", "string", ")", "$", "response", "->", "status_code", ")", ";", "return", "$", "renderer", "->", "render", "(", "$", "element", ",", "$", "appearance", ")", ";", "}" ]
Renders an object with the renderer
[ "Renders", "an", "object", "with", "the", "renderer" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L173-L186
3,608
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.getPagePathFromClassname
public static function getPagePathFromClassname($classname, $page_parameter = [], Loops $loops = NULL) { $count = count($page_parameter); if(!$routes = self::getRoutes($loops ?: Loops::getCurrentLoops())) { return FALSE; } $routes = array_filter($routes, function($value, $key) use ($classname, $count) { if($classname != str_replace("*", "_", $value)) { return FALSE; } if(substr_count($key, "*") > $count) { return FALSE; } return TRUE; }, ARRAY_FILTER_USE_BOTH); if(!$routes) { return FALSE; } $pagepath = key($routes); while($page_parameter && (($pos = strpos($pagepath, "*")) !== FALSE)) { $pagepath = substr($pagepath, 0, $pos).array_shift($page_parameter).substr($pagepath, $pos+1); } return ltrim($pagepath, "/"); }
php
public static function getPagePathFromClassname($classname, $page_parameter = [], Loops $loops = NULL) { $count = count($page_parameter); if(!$routes = self::getRoutes($loops ?: Loops::getCurrentLoops())) { return FALSE; } $routes = array_filter($routes, function($value, $key) use ($classname, $count) { if($classname != str_replace("*", "_", $value)) { return FALSE; } if(substr_count($key, "*") > $count) { return FALSE; } return TRUE; }, ARRAY_FILTER_USE_BOTH); if(!$routes) { return FALSE; } $pagepath = key($routes); while($page_parameter && (($pos = strpos($pagepath, "*")) !== FALSE)) { $pagepath = substr($pagepath, 0, $pos).array_shift($page_parameter).substr($pagepath, $pos+1); } return ltrim($pagepath, "/"); }
[ "public", "static", "function", "getPagePathFromClassname", "(", "$", "classname", ",", "$", "page_parameter", "=", "[", "]", ",", "Loops", "$", "loops", "=", "NULL", ")", "{", "$", "count", "=", "count", "(", "$", "page_parameter", ")", ";", "if", "(", "!", "$", "routes", "=", "self", "::", "getRoutes", "(", "$", "loops", "?", ":", "Loops", "::", "getCurrentLoops", "(", ")", ")", ")", "{", "return", "FALSE", ";", "}", "$", "routes", "=", "array_filter", "(", "$", "routes", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "classname", ",", "$", "count", ")", "{", "if", "(", "$", "classname", "!=", "str_replace", "(", "\"*\"", ",", "\"_\"", ",", "$", "value", ")", ")", "{", "return", "FALSE", ";", "}", "if", "(", "substr_count", "(", "$", "key", ",", "\"*\"", ")", ">", "$", "count", ")", "{", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "if", "(", "!", "$", "routes", ")", "{", "return", "FALSE", ";", "}", "$", "pagepath", "=", "key", "(", "$", "routes", ")", ";", "while", "(", "$", "page_parameter", "&&", "(", "(", "$", "pos", "=", "strpos", "(", "$", "pagepath", ",", "\"*\"", ")", ")", "!==", "FALSE", ")", ")", "{", "$", "pagepath", "=", "substr", "(", "$", "pagepath", ",", "0", ",", "$", "pos", ")", ".", "array_shift", "(", "$", "page_parameter", ")", ".", "substr", "(", "$", "pagepath", ",", "$", "pos", "+", "1", ")", ";", "}", "return", "ltrim", "(", "$", "pagepath", ",", "\"/\"", ")", ";", "}" ]
Generates the page path for a page element This function also replaces the page parameter placeholders with given arguments @param string|object $classname The classname of the element or an object @param array<string> $page_parameter The page parameter that will be filled into the placeholders @param Loops Use this loops context instead of the default one
[ "Generates", "the", "page", "path", "for", "a", "page", "element" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L197-L227
3,609
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.getRoutes
private static function getRoutes($loops) { $cache = $loops->getService("cache"); $key = "Loops-WebCore-getRoutes"; if($cache->contains($key)) { return $cache->fetch($key); } if(!$loops->hasService("application")) { return FALSE; } $classnames = $loops->getService("application")->definedClasses(); $classnames = array_filter($classnames, function($classname) { return substr($classname, 0, 6) == "Pages\\"; }); $routes = []; foreach($classnames as $classname) { if(!in_array("Loops\ElementInterface", class_implements($classname))) { continue; } if(!$classname::isPage()) { continue; } $reflection = new ReflectionClass($classname); if($reflection->isAbstract()) { continue; } if(substr($reflection->getFileName(), -strlen($classname)-4, strlen($classname)) != str_replace("\\", "/", $classname)) { continue; } $classbase = substr(str_replace("\\", "/", strtolower($classname)), 5); if(substr($classbase, -6) == "/index") { $classbase = substr($classbase, 0, -5); } $routes[str_replace("_", "*", substr($classbase, 1))] = $classname; } uksort($routes, function($a, $b) { return substr_count($b, "/") - substr_count($a, "/") ?: strlen($b) - strlen($a); }); $cache->save($key, $routes); return $routes; }
php
private static function getRoutes($loops) { $cache = $loops->getService("cache"); $key = "Loops-WebCore-getRoutes"; if($cache->contains($key)) { return $cache->fetch($key); } if(!$loops->hasService("application")) { return FALSE; } $classnames = $loops->getService("application")->definedClasses(); $classnames = array_filter($classnames, function($classname) { return substr($classname, 0, 6) == "Pages\\"; }); $routes = []; foreach($classnames as $classname) { if(!in_array("Loops\ElementInterface", class_implements($classname))) { continue; } if(!$classname::isPage()) { continue; } $reflection = new ReflectionClass($classname); if($reflection->isAbstract()) { continue; } if(substr($reflection->getFileName(), -strlen($classname)-4, strlen($classname)) != str_replace("\\", "/", $classname)) { continue; } $classbase = substr(str_replace("\\", "/", strtolower($classname)), 5); if(substr($classbase, -6) == "/index") { $classbase = substr($classbase, 0, -5); } $routes[str_replace("_", "*", substr($classbase, 1))] = $classname; } uksort($routes, function($a, $b) { return substr_count($b, "/") - substr_count($a, "/") ?: strlen($b) - strlen($a); }); $cache->save($key, $routes); return $routes; }
[ "private", "static", "function", "getRoutes", "(", "$", "loops", ")", "{", "$", "cache", "=", "$", "loops", "->", "getService", "(", "\"cache\"", ")", ";", "$", "key", "=", "\"Loops-WebCore-getRoutes\"", ";", "if", "(", "$", "cache", "->", "contains", "(", "$", "key", ")", ")", "{", "return", "$", "cache", "->", "fetch", "(", "$", "key", ")", ";", "}", "if", "(", "!", "$", "loops", "->", "hasService", "(", "\"application\"", ")", ")", "{", "return", "FALSE", ";", "}", "$", "classnames", "=", "$", "loops", "->", "getService", "(", "\"application\"", ")", "->", "definedClasses", "(", ")", ";", "$", "classnames", "=", "array_filter", "(", "$", "classnames", ",", "function", "(", "$", "classname", ")", "{", "return", "substr", "(", "$", "classname", ",", "0", ",", "6", ")", "==", "\"Pages\\\\\"", ";", "}", ")", ";", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "classnames", "as", "$", "classname", ")", "{", "if", "(", "!", "in_array", "(", "\"Loops\\ElementInterface\"", ",", "class_implements", "(", "$", "classname", ")", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "classname", "::", "isPage", "(", ")", ")", "{", "continue", ";", "}", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "classname", ")", ";", "if", "(", "$", "reflection", "->", "isAbstract", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "substr", "(", "$", "reflection", "->", "getFileName", "(", ")", ",", "-", "strlen", "(", "$", "classname", ")", "-", "4", ",", "strlen", "(", "$", "classname", ")", ")", "!=", "str_replace", "(", "\"\\\\\"", ",", "\"/\"", ",", "$", "classname", ")", ")", "{", "continue", ";", "}", "$", "classbase", "=", "substr", "(", "str_replace", "(", "\"\\\\\"", ",", "\"/\"", ",", "strtolower", "(", "$", "classname", ")", ")", ",", "5", ")", ";", "if", "(", "substr", "(", "$", "classbase", ",", "-", "6", ")", "==", "\"/index\"", ")", "{", "$", "classbase", "=", "substr", "(", "$", "classbase", ",", "0", ",", "-", "5", ")", ";", "}", "$", "routes", "[", "str_replace", "(", "\"_\"", ",", "\"*\"", ",", "substr", "(", "$", "classbase", ",", "1", ")", ")", "]", "=", "$", "classname", ";", "}", "uksort", "(", "$", "routes", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "substr_count", "(", "$", "b", ",", "\"/\"", ")", "-", "substr_count", "(", "$", "a", ",", "\"/\"", ")", "?", ":", "strlen", "(", "$", "b", ")", "-", "strlen", "(", "$", "a", ")", ";", "}", ")", ";", "$", "cache", "->", "save", "(", "$", "key", ",", "$", "routes", ")", ";", "return", "$", "routes", ";", "}" ]
Generates an array with all available routes
[ "Generates", "an", "array", "with", "all", "available", "routes" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L232-L286
3,610
loopsframework/base
src/Loops/Service/WebCore.php
WebCore.resolvePage
private function resolvePage($url, $processing = []) { $path = ltrim($url, "/"); $routes = self::getRoutes($this->getLoops()); foreach($routes as $route => $pageclass) { $regexp = "/^".str_replace("\*", "([^\/]+)", preg_quote($route, "/"))."/"; if(!preg_match($regexp, $path, $match)) { continue; } $page_parameter = array_slice($match, 1); //check if regexp conditions are defined via annotations if($page_parameter) { $reqs = $this->getLoops()->getService("annotations")->get($pageclass)->find("PageParameter"); foreach($page_parameter as $parameter) { if($req = array_pop($reqs)) { if($req->regexp) { if(!preg_match($req->regexp, $parameter)) { continue 2; } } if(is_array($req->allow)) { if(!in_array($parameter, $req->allow)) { continue 2; } } if(is_array($req->exclude)) { if(in_array($parameter, $req->exclude)) { continue 2; } } if($req->callback) { if(!call_user_func([$pageclass, $req->callback], $parameter)) { continue 2; } } } } } $parameter = ltrim(substr($path, strlen($match[0])), "/"); $parameter = strlen($parameter) ? array_values(explode("/", $parameter)) : []; yield [ $pageclass, $page_parameter, $parameter ]; } }
php
private function resolvePage($url, $processing = []) { $path = ltrim($url, "/"); $routes = self::getRoutes($this->getLoops()); foreach($routes as $route => $pageclass) { $regexp = "/^".str_replace("\*", "([^\/]+)", preg_quote($route, "/"))."/"; if(!preg_match($regexp, $path, $match)) { continue; } $page_parameter = array_slice($match, 1); //check if regexp conditions are defined via annotations if($page_parameter) { $reqs = $this->getLoops()->getService("annotations")->get($pageclass)->find("PageParameter"); foreach($page_parameter as $parameter) { if($req = array_pop($reqs)) { if($req->regexp) { if(!preg_match($req->regexp, $parameter)) { continue 2; } } if(is_array($req->allow)) { if(!in_array($parameter, $req->allow)) { continue 2; } } if(is_array($req->exclude)) { if(in_array($parameter, $req->exclude)) { continue 2; } } if($req->callback) { if(!call_user_func([$pageclass, $req->callback], $parameter)) { continue 2; } } } } } $parameter = ltrim(substr($path, strlen($match[0])), "/"); $parameter = strlen($parameter) ? array_values(explode("/", $parameter)) : []; yield [ $pageclass, $page_parameter, $parameter ]; } }
[ "private", "function", "resolvePage", "(", "$", "url", ",", "$", "processing", "=", "[", "]", ")", "{", "$", "path", "=", "ltrim", "(", "$", "url", ",", "\"/\"", ")", ";", "$", "routes", "=", "self", "::", "getRoutes", "(", "$", "this", "->", "getLoops", "(", ")", ")", ";", "foreach", "(", "$", "routes", "as", "$", "route", "=>", "$", "pageclass", ")", "{", "$", "regexp", "=", "\"/^\"", ".", "str_replace", "(", "\"\\*\"", ",", "\"([^\\/]+)\"", ",", "preg_quote", "(", "$", "route", ",", "\"/\"", ")", ")", ".", "\"/\"", ";", "if", "(", "!", "preg_match", "(", "$", "regexp", ",", "$", "path", ",", "$", "match", ")", ")", "{", "continue", ";", "}", "$", "page_parameter", "=", "array_slice", "(", "$", "match", ",", "1", ")", ";", "//check if regexp conditions are defined via annotations", "if", "(", "$", "page_parameter", ")", "{", "$", "reqs", "=", "$", "this", "->", "getLoops", "(", ")", "->", "getService", "(", "\"annotations\"", ")", "->", "get", "(", "$", "pageclass", ")", "->", "find", "(", "\"PageParameter\"", ")", ";", "foreach", "(", "$", "page_parameter", "as", "$", "parameter", ")", "{", "if", "(", "$", "req", "=", "array_pop", "(", "$", "reqs", ")", ")", "{", "if", "(", "$", "req", "->", "regexp", ")", "{", "if", "(", "!", "preg_match", "(", "$", "req", "->", "regexp", ",", "$", "parameter", ")", ")", "{", "continue", "2", ";", "}", "}", "if", "(", "is_array", "(", "$", "req", "->", "allow", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "parameter", ",", "$", "req", "->", "allow", ")", ")", "{", "continue", "2", ";", "}", "}", "if", "(", "is_array", "(", "$", "req", "->", "exclude", ")", ")", "{", "if", "(", "in_array", "(", "$", "parameter", ",", "$", "req", "->", "exclude", ")", ")", "{", "continue", "2", ";", "}", "}", "if", "(", "$", "req", "->", "callback", ")", "{", "if", "(", "!", "call_user_func", "(", "[", "$", "pageclass", ",", "$", "req", "->", "callback", "]", ",", "$", "parameter", ")", ")", "{", "continue", "2", ";", "}", "}", "}", "}", "}", "$", "parameter", "=", "ltrim", "(", "substr", "(", "$", "path", ",", "strlen", "(", "$", "match", "[", "0", "]", ")", ")", ",", "\"/\"", ")", ";", "$", "parameter", "=", "strlen", "(", "$", "parameter", ")", "?", "array_values", "(", "explode", "(", "\"/\"", ",", "$", "parameter", ")", ")", ":", "[", "]", ";", "yield", "[", "$", "pageclass", ",", "$", "page_parameter", ",", "$", "parameter", "]", ";", "}", "}" ]
Find the page object that should be displayed based on the accessed url This method will resolve the url to a page class. It will try to find and autoload the class with the same name as the url (including namespaces) inside the "Pages" namespace. The first letter of every part of the url is capitalized to honor the loops coding standard. Ex: 'subdir/deep/deeper/myclass' -> "Pages\Subdir\Deep\Deeper\Myclass" A trailing '/' in the url tells loops to look for a class named 'Index' inside that namespace. Ex: 'subdir/deep/deeper/myclass/' -> 'Pages\Subdir\Deep\Deeper\Myclass\Index' If no class with that name is found, less deep namespaces will be searched for appropriate classes or Index classes. The above url ('/subdir/deep/deeper/myclass/') will search for page classes in the following order: - Pages\Subdir\Deep\Deeper\Myclass\Index - Pages\Subdir\Deep\Deeper\Myclass - Pages\Subdir\Deep\Deeper\Index - Pages\Subdir\Deep\Deeper - Pages\Subdir\Deep\Index - Pages\Subdir\Deep - Pages\Subdir\Index - Pages\Subdir - Pages\Index All parts of the url that are not part of the classname will be saved in an array as parameters. These parameters will be divided into 'page parameter' and 'action parameter'. If the classname contains namespaces called '_' (a single underbar namespace), the first n parameters will be used as page parameters with n being the number of such namespaces. If the classname is called '_' another parameter will be used as page parameter. These parameters will be passed to the page class constructor. The remaining parameters, if any, will be passed to the action method of that page class while dispatching the request. The classes must be non abstract or they will be taken into account. You can make a page class abstract if other pages inherit from it but should not be displayed directly.
[ "Find", "the", "page", "object", "that", "should", "be", "displayed", "based", "on", "the", "accessed", "url" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Service/WebCore.php#L322-L373
3,611
php-rest-server/core
src/Core/Helpers/UrlHelper.php
UrlHelper.dashToCamelCase
public static function dashToCamelCase($string) { $result = ''; $urlPart = explode('-', $string); foreach ($urlPart as $word) { $result .= ucfirst(strtolower($word)); } return $result; }
php
public static function dashToCamelCase($string) { $result = ''; $urlPart = explode('-', $string); foreach ($urlPart as $word) { $result .= ucfirst(strtolower($word)); } return $result; }
[ "public", "static", "function", "dashToCamelCase", "(", "$", "string", ")", "{", "$", "result", "=", "''", ";", "$", "urlPart", "=", "explode", "(", "'-'", ",", "$", "string", ")", ";", "foreach", "(", "$", "urlPart", "as", "$", "word", ")", "{", "$", "result", ".=", "ucfirst", "(", "strtolower", "(", "$", "word", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Replace dashes to CamelCase string format @param string $string @return string
[ "Replace", "dashes", "to", "CamelCase", "string", "format" ]
4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888
https://github.com/php-rest-server/core/blob/4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888/src/Core/Helpers/UrlHelper.php#L28-L36
3,612
php-rest-server/core
src/Core/Helpers/UrlHelper.php
UrlHelper.routeParse
public static function routeParse($from, $to, $url) { // validation and parse route pattern $result = preg_match('/^(\(([^\)]+)\)|[^\/]*)(.*)/', $from, $data); if ($result !== 1) { return false; } // prepare patter to test url and replacement $pattern = '/^' . str_replace('/', '\/', $data[3]) . '$/'; // test route pattern match $result = preg_match($pattern, $url); if ($result !== 1) { return false; } // create RouteInfo object and fill fields $route = new RouteInfo(); // make array of supported methods $route->methods = empty($data[2]) ? [] : explode('|', $data[2]); // replace pattern url $route->url = preg_replace($pattern, $to, $url); return $route; }
php
public static function routeParse($from, $to, $url) { // validation and parse route pattern $result = preg_match('/^(\(([^\)]+)\)|[^\/]*)(.*)/', $from, $data); if ($result !== 1) { return false; } // prepare patter to test url and replacement $pattern = '/^' . str_replace('/', '\/', $data[3]) . '$/'; // test route pattern match $result = preg_match($pattern, $url); if ($result !== 1) { return false; } // create RouteInfo object and fill fields $route = new RouteInfo(); // make array of supported methods $route->methods = empty($data[2]) ? [] : explode('|', $data[2]); // replace pattern url $route->url = preg_replace($pattern, $to, $url); return $route; }
[ "public", "static", "function", "routeParse", "(", "$", "from", ",", "$", "to", ",", "$", "url", ")", "{", "// validation and parse route pattern", "$", "result", "=", "preg_match", "(", "'/^(\\(([^\\)]+)\\)|[^\\/]*)(.*)/'", ",", "$", "from", ",", "$", "data", ")", ";", "if", "(", "$", "result", "!==", "1", ")", "{", "return", "false", ";", "}", "// prepare patter to test url and replacement", "$", "pattern", "=", "'/^'", ".", "str_replace", "(", "'/'", ",", "'\\/'", ",", "$", "data", "[", "3", "]", ")", ".", "'$/'", ";", "// test route pattern match", "$", "result", "=", "preg_match", "(", "$", "pattern", ",", "$", "url", ")", ";", "if", "(", "$", "result", "!==", "1", ")", "{", "return", "false", ";", "}", "// create RouteInfo object and fill fields", "$", "route", "=", "new", "RouteInfo", "(", ")", ";", "// make array of supported methods", "$", "route", "->", "methods", "=", "empty", "(", "$", "data", "[", "2", "]", ")", "?", "[", "]", ":", "explode", "(", "'|'", ",", "$", "data", "[", "2", "]", ")", ";", "// replace pattern url", "$", "route", "->", "url", "=", "preg_replace", "(", "$", "pattern", ",", "$", "to", ",", "$", "url", ")", ";", "return", "$", "route", ";", "}" ]
Parse route and return object RouteInfo with information about accepted route or return false if route pattern does not math @param string $from @param string $to @param string $url @return bool|RouteInfo
[ "Parse", "route", "and", "return", "object", "RouteInfo", "with", "information", "about", "accepted", "route", "or", "return", "false", "if", "route", "pattern", "does", "not", "math" ]
4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888
https://github.com/php-rest-server/core/blob/4d1ee0d4b6bd7d170cf1ec924a8b743b5d486888/src/Core/Helpers/UrlHelper.php#L48-L75
3,613
ischenko/yii2-jsloader
src/Behavior.php
Behavior.processBundles
public function processBundles() { $loader = $this->getLoader(); $view = $this->ensureView($this->owner); foreach (array_keys($view->assetBundles) as $name) { $loader->registerAssetBundle($name); } }
php
public function processBundles() { $loader = $this->getLoader(); $view = $this->ensureView($this->owner); foreach (array_keys($view->assetBundles) as $name) { $loader->registerAssetBundle($name); } }
[ "public", "function", "processBundles", "(", ")", "{", "$", "loader", "=", "$", "this", "->", "getLoader", "(", ")", ";", "$", "view", "=", "$", "this", "->", "ensureView", "(", "$", "this", "->", "owner", ")", ";", "foreach", "(", "array_keys", "(", "$", "view", "->", "assetBundles", ")", "as", "$", "name", ")", "{", "$", "loader", "->", "registerAssetBundle", "(", "$", "name", ")", ";", "}", "}" ]
Registers asset bundles in the JS loader
[ "Registers", "asset", "bundles", "in", "the", "JS", "loader" ]
873242c4ab80eb160519d8ba0c4afb92aa89edfb
https://github.com/ischenko/yii2-jsloader/blob/873242c4ab80eb160519d8ba0c4afb92aa89edfb/src/Behavior.php#L55-L63
3,614
face-orm/face
lib/Face/Sql/Reader/QueryArrayReader.php
QueryArrayReader.read
public function read(\PDOStatement $stmt) { $this->unfoundPrecedence=array(); $preparedReader = new PreparedOperations($this->FQuery); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // loop over joined faces foreach ($preparedReader->getPreparedFaces() as $basePath => $preparedFace) { $identity = $preparedFace->rowIdentity($row, $basePath); if ($identity) { // if already instantiated then get it from ikeeper and try the forwards if ($this->instancesKeeper->hasInstance($preparedFace->getFace()->getClass(), $identity)) { $instance = $this->instancesKeeper->getInstance($preparedFace->getFace()->getClass(), $identity); $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence); if (!$this->resultSet->pathHasIdentity($basePath, $identity)) { $this->resultSet->addInstanceByPath($basePath, $instance, $identity); } // else create the instance and hydrate it } else { $instance = $this->createInstance($preparedFace->getFace()); $this->instancesKeeper->addInstance($instance, $identity); $this->resultSet->addInstanceByPath($basePath, $instance, $identity); $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence); } } } } // set unset instances. To be improved ? foreach ($this->unfoundPrecedence as $unfound) { if(!$this->instancesKeeper->hasInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement'])){ var_dump($unfound['elementToSet']->getClass()); var_dump($unfound['identityOfElement']); var_dump(get_class($instance)); } $unfoundInstance = $this->instancesKeeper->getInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement']); $unfound['instance']->faceSetter($unfound['elementToSet'], $unfoundInstance); } return $this->resultSet; }
php
public function read(\PDOStatement $stmt) { $this->unfoundPrecedence=array(); $preparedReader = new PreparedOperations($this->FQuery); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { // loop over joined faces foreach ($preparedReader->getPreparedFaces() as $basePath => $preparedFace) { $identity = $preparedFace->rowIdentity($row, $basePath); if ($identity) { // if already instantiated then get it from ikeeper and try the forwards if ($this->instancesKeeper->hasInstance($preparedFace->getFace()->getClass(), $identity)) { $instance = $this->instancesKeeper->getInstance($preparedFace->getFace()->getClass(), $identity); $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence); if (!$this->resultSet->pathHasIdentity($basePath, $identity)) { $this->resultSet->addInstanceByPath($basePath, $instance, $identity); } // else create the instance and hydrate it } else { $instance = $this->createInstance($preparedFace->getFace()); $this->instancesKeeper->addInstance($instance, $identity); $this->resultSet->addInstanceByPath($basePath, $instance, $identity); $preparedFace->runOperations($instance,$row,$this->instancesKeeper, $this->unfoundPrecedence); } } } } // set unset instances. To be improved ? foreach ($this->unfoundPrecedence as $unfound) { if(!$this->instancesKeeper->hasInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement'])){ var_dump($unfound['elementToSet']->getClass()); var_dump($unfound['identityOfElement']); var_dump(get_class($instance)); } $unfoundInstance = $this->instancesKeeper->getInstance($unfound['elementToSet']->getClass(), $unfound['identityOfElement']); $unfound['instance']->faceSetter($unfound['elementToSet'], $unfoundInstance); } return $this->resultSet; }
[ "public", "function", "read", "(", "\\", "PDOStatement", "$", "stmt", ")", "{", "$", "this", "->", "unfoundPrecedence", "=", "array", "(", ")", ";", "$", "preparedReader", "=", "new", "PreparedOperations", "(", "$", "this", "->", "FQuery", ")", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ")", "{", "// loop over joined faces", "foreach", "(", "$", "preparedReader", "->", "getPreparedFaces", "(", ")", "as", "$", "basePath", "=>", "$", "preparedFace", ")", "{", "$", "identity", "=", "$", "preparedFace", "->", "rowIdentity", "(", "$", "row", ",", "$", "basePath", ")", ";", "if", "(", "$", "identity", ")", "{", "// if already instantiated then get it from ikeeper and try the forwards", "if", "(", "$", "this", "->", "instancesKeeper", "->", "hasInstance", "(", "$", "preparedFace", "->", "getFace", "(", ")", "->", "getClass", "(", ")", ",", "$", "identity", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "instancesKeeper", "->", "getInstance", "(", "$", "preparedFace", "->", "getFace", "(", ")", "->", "getClass", "(", ")", ",", "$", "identity", ")", ";", "$", "preparedFace", "->", "runOperations", "(", "$", "instance", ",", "$", "row", ",", "$", "this", "->", "instancesKeeper", ",", "$", "this", "->", "unfoundPrecedence", ")", ";", "if", "(", "!", "$", "this", "->", "resultSet", "->", "pathHasIdentity", "(", "$", "basePath", ",", "$", "identity", ")", ")", "{", "$", "this", "->", "resultSet", "->", "addInstanceByPath", "(", "$", "basePath", ",", "$", "instance", ",", "$", "identity", ")", ";", "}", "// else create the instance and hydrate it", "}", "else", "{", "$", "instance", "=", "$", "this", "->", "createInstance", "(", "$", "preparedFace", "->", "getFace", "(", ")", ")", ";", "$", "this", "->", "instancesKeeper", "->", "addInstance", "(", "$", "instance", ",", "$", "identity", ")", ";", "$", "this", "->", "resultSet", "->", "addInstanceByPath", "(", "$", "basePath", ",", "$", "instance", ",", "$", "identity", ")", ";", "$", "preparedFace", "->", "runOperations", "(", "$", "instance", ",", "$", "row", ",", "$", "this", "->", "instancesKeeper", ",", "$", "this", "->", "unfoundPrecedence", ")", ";", "}", "}", "}", "}", "// set unset instances. To be improved ?", "foreach", "(", "$", "this", "->", "unfoundPrecedence", "as", "$", "unfound", ")", "{", "if", "(", "!", "$", "this", "->", "instancesKeeper", "->", "hasInstance", "(", "$", "unfound", "[", "'elementToSet'", "]", "->", "getClass", "(", ")", ",", "$", "unfound", "[", "'identityOfElement'", "]", ")", ")", "{", "var_dump", "(", "$", "unfound", "[", "'elementToSet'", "]", "->", "getClass", "(", ")", ")", ";", "var_dump", "(", "$", "unfound", "[", "'identityOfElement'", "]", ")", ";", "var_dump", "(", "get_class", "(", "$", "instance", ")", ")", ";", "}", "$", "unfoundInstance", "=", "$", "this", "->", "instancesKeeper", "->", "getInstance", "(", "$", "unfound", "[", "'elementToSet'", "]", "->", "getClass", "(", ")", ",", "$", "unfound", "[", "'identityOfElement'", "]", ")", ";", "$", "unfound", "[", "'instance'", "]", "->", "faceSetter", "(", "$", "unfound", "[", "'elementToSet'", "]", ",", "$", "unfoundInstance", ")", ";", "}", "return", "$", "this", "->", "resultSet", ";", "}" ]
parse the pdo statement of the fquery @param \PDOStatement $stmt @return \Face\Sql\Result\ResultSet
[ "parse", "the", "pdo", "statement", "of", "the", "fquery" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Reader/QueryArrayReader.php#L60-L119
3,615
face-orm/face
lib/Face/Sql/Reader/QueryArrayReader.php
QueryArrayReader.createInstance
protected function createInstance(\Face\Core\EntityFace $face) { $className = $face->getClass(); $instance = new $className(); return $instance; }
php
protected function createInstance(\Face\Core\EntityFace $face) { $className = $face->getClass(); $instance = new $className(); return $instance; }
[ "protected", "function", "createInstance", "(", "\\", "Face", "\\", "Core", "\\", "EntityFace", "$", "face", ")", "{", "$", "className", "=", "$", "face", "->", "getClass", "(", ")", ";", "$", "instance", "=", "new", "$", "className", "(", ")", ";", "return", "$", "instance", ";", "}" ]
Create an instance from an assoc array returned by sql @param \Face\Core\EntityFace $face the face that describes the entity @param array $array the array of data @param string $basePath @param array $faceList @return object the new instance of the element
[ "Create", "an", "instance", "from", "an", "assoc", "array", "returned", "by", "sql" ]
85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428
https://github.com/face-orm/face/blob/85b412c66ff41d0fe73b7e7b69bc9a5ac5f7f428/lib/Face/Sql/Reader/QueryArrayReader.php#L130-L136
3,616
unyx/console
output/formatting/Style.php
Style.fromString
public static function fromString(string $string, array $properties = null) : ?Style { if (!preg_match_all('/([^:]+):([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { return null; } // H-okay, seems we got a match. $style = new Style(null); foreach ($matches as $match) { // Be forgiving regarding whitespaces (or lack thereof) in the string. $property = trim($match[1]); $value = trim($match[2]); if ($property === ($properties['foreground'] ?? 'color')) { $style->setForeground($value); } elseif ($property === ($properties['background'] ?? 'bg')) { $style->setBackground($value); } else { $style->setEmphasis([$value]); } } return $style; }
php
public static function fromString(string $string, array $properties = null) : ?Style { if (!preg_match_all('/([^:]+):([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { return null; } // H-okay, seems we got a match. $style = new Style(null); foreach ($matches as $match) { // Be forgiving regarding whitespaces (or lack thereof) in the string. $property = trim($match[1]); $value = trim($match[2]); if ($property === ($properties['foreground'] ?? 'color')) { $style->setForeground($value); } elseif ($property === ($properties['background'] ?? 'bg')) { $style->setBackground($value); } else { $style->setEmphasis([$value]); } } return $style; }
[ "public", "static", "function", "fromString", "(", "string", "$", "string", ",", "array", "$", "properties", "=", "null", ")", ":", "?", "Style", "{", "if", "(", "!", "preg_match_all", "(", "'/([^:]+):([^;]+)(;|$)/'", ",", "strtolower", "(", "$", "string", ")", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ")", "{", "return", "null", ";", "}", "// H-okay, seems we got a match.", "$", "style", "=", "new", "Style", "(", "null", ")", ";", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "// Be forgiving regarding whitespaces (or lack thereof) in the string.", "$", "property", "=", "trim", "(", "$", "match", "[", "1", "]", ")", ";", "$", "value", "=", "trim", "(", "$", "match", "[", "2", "]", ")", ";", "if", "(", "$", "property", "===", "(", "$", "properties", "[", "'foreground'", "]", "??", "'color'", ")", ")", "{", "$", "style", "->", "setForeground", "(", "$", "value", ")", ";", "}", "elseif", "(", "$", "property", "===", "(", "$", "properties", "[", "'background'", "]", "??", "'bg'", ")", ")", "{", "$", "style", "->", "setBackground", "(", "$", "value", ")", ";", "}", "else", "{", "$", "style", "->", "setEmphasis", "(", "[", "$", "value", "]", ")", ";", "}", "}", "return", "$", "style", ";", "}" ]
Factory which attempts to create a new Style based on an inline styling syntax. @param string $string The string to parse. @param array $properties An array containing at most 2 keys: 'foreground' and 'background', denoting the names those properties will be sought for to in the string. Defaults to: ['foreground' => 'color', 'background' => 'bg']. @return Style The Style that was created based on it.
[ "Factory", "which", "attempts", "to", "create", "a", "new", "Style", "based", "on", "an", "inline", "styling", "syntax", "." ]
b4a76e08bbb5428b0349c0ec4259a914f81a2957
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/Style.php#L87-L112
3,617
unyx/console
output/formatting/Style.php
Style.setColor
protected function setColor(string $type, ?string $color) : interfaces\Style { if (isset($color) && !isset(static::${$type.'s'}[$color])) { throw new \InvalidArgumentException("The $type color [$color] is not recognized."); } $this->$type = $color; return $this; }
php
protected function setColor(string $type, ?string $color) : interfaces\Style { if (isset($color) && !isset(static::${$type.'s'}[$color])) { throw new \InvalidArgumentException("The $type color [$color] is not recognized."); } $this->$type = $color; return $this; }
[ "protected", "function", "setColor", "(", "string", "$", "type", ",", "?", "string", "$", "color", ")", ":", "interfaces", "\\", "Style", "{", "if", "(", "isset", "(", "$", "color", ")", "&&", "!", "isset", "(", "static", "::", "$", "{", "$", "type", ".", "'s'", "}", "[", "$", "color", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The $type color [$color] is not recognized.\"", ")", ";", "}", "$", "this", "->", "$", "type", "=", "$", "color", ";", "return", "$", "this", ";", "}" ]
Sets a specific type of color on this Style. @param string $type The type of the color to set. @param string $color The color to set. @return $this
[ "Sets", "a", "specific", "type", "of", "color", "on", "this", "Style", "." ]
b4a76e08bbb5428b0349c0ec4259a914f81a2957
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/Style.php#L209-L218
3,618
mikeshiyan/iterate
src/Scenario/ConsoleProgressBarTrait.php
ConsoleProgressBarTrait.preRun
public function preRun(): void { if ($output = $this->getOutput()) { $max = 0; $iterator = $this->getIterator(); if ($iterator instanceof \SplFileObject) { $max = $iterator->getSize(); } elseif ($iterator instanceof \Countable) { $max = count($iterator); } $this->progress = new ProgressBar($output, $max); if ($output->isDecorated()) { // If output is not decorated, the redraw frequency would automatically // be set to $max/10 by default. $this->progress->setRedrawFrequency($max / 100); } $this->progress->start(); } }
php
public function preRun(): void { if ($output = $this->getOutput()) { $max = 0; $iterator = $this->getIterator(); if ($iterator instanceof \SplFileObject) { $max = $iterator->getSize(); } elseif ($iterator instanceof \Countable) { $max = count($iterator); } $this->progress = new ProgressBar($output, $max); if ($output->isDecorated()) { // If output is not decorated, the redraw frequency would automatically // be set to $max/10 by default. $this->progress->setRedrawFrequency($max / 100); } $this->progress->start(); } }
[ "public", "function", "preRun", "(", ")", ":", "void", "{", "if", "(", "$", "output", "=", "$", "this", "->", "getOutput", "(", ")", ")", "{", "$", "max", "=", "0", ";", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "if", "(", "$", "iterator", "instanceof", "\\", "SplFileObject", ")", "{", "$", "max", "=", "$", "iterator", "->", "getSize", "(", ")", ";", "}", "elseif", "(", "$", "iterator", "instanceof", "\\", "Countable", ")", "{", "$", "max", "=", "count", "(", "$", "iterator", ")", ";", "}", "$", "this", "->", "progress", "=", "new", "ProgressBar", "(", "$", "output", ",", "$", "max", ")", ";", "if", "(", "$", "output", "->", "isDecorated", "(", ")", ")", "{", "// If output is not decorated, the redraw frequency would automatically", "// be set to $max/10 by default.", "$", "this", "->", "progress", "->", "setRedrawFrequency", "(", "$", "max", "/", "100", ")", ";", "}", "$", "this", "->", "progress", "->", "start", "(", ")", ";", "}", "}" ]
Starts a new progress bar output in the pre-run phase. @see \Shiyan\Iterate\Scenario\ScenarioInterface::preRun()
[ "Starts", "a", "new", "progress", "bar", "output", "in", "the", "pre", "-", "run", "phase", "." ]
595fc2e23eead334b4f333621b2995bfe649f1f2
https://github.com/mikeshiyan/iterate/blob/595fc2e23eead334b4f333621b2995bfe649f1f2/src/Scenario/ConsoleProgressBarTrait.php#L71-L91
3,619
mikeshiyan/iterate
src/Scenario/ConsoleProgressBarTrait.php
ConsoleProgressBarTrait.postSearch
public function postSearch(): void { if ($this->progress) { $iterator = $this->getIterator(); if ($iterator instanceof \SplFileObject) { // Get current byte offset, after the line was read. $this->progress->setProgress($iterator->ftell()); } elseif (is_int($key = $iterator->key())) { // Add one to the current index, because we're in the post-search phase. $this->progress->setProgress($key + 1); } else { // If iterator's key is not integer, just advance the progress with 1. $this->progress->advance(); } } }
php
public function postSearch(): void { if ($this->progress) { $iterator = $this->getIterator(); if ($iterator instanceof \SplFileObject) { // Get current byte offset, after the line was read. $this->progress->setProgress($iterator->ftell()); } elseif (is_int($key = $iterator->key())) { // Add one to the current index, because we're in the post-search phase. $this->progress->setProgress($key + 1); } else { // If iterator's key is not integer, just advance the progress with 1. $this->progress->advance(); } } }
[ "public", "function", "postSearch", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "progress", ")", "{", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "if", "(", "$", "iterator", "instanceof", "\\", "SplFileObject", ")", "{", "// Get current byte offset, after the line was read.", "$", "this", "->", "progress", "->", "setProgress", "(", "$", "iterator", "->", "ftell", "(", ")", ")", ";", "}", "elseif", "(", "is_int", "(", "$", "key", "=", "$", "iterator", "->", "key", "(", ")", ")", ")", "{", "// Add one to the current index, because we're in the post-search phase.", "$", "this", "->", "progress", "->", "setProgress", "(", "$", "key", "+", "1", ")", ";", "}", "else", "{", "// If iterator's key is not integer, just advance the progress with 1.", "$", "this", "->", "progress", "->", "advance", "(", ")", ";", "}", "}", "}" ]
Updates the current progress in the post-search phase. @see \Shiyan\Iterate\Scenario\ScenarioInterface::postSearch()
[ "Updates", "the", "current", "progress", "in", "the", "post", "-", "search", "phase", "." ]
595fc2e23eead334b4f333621b2995bfe649f1f2
https://github.com/mikeshiyan/iterate/blob/595fc2e23eead334b4f333621b2995bfe649f1f2/src/Scenario/ConsoleProgressBarTrait.php#L98-L115
3,620
mikeshiyan/iterate
src/Scenario/ConsoleProgressBarTrait.php
ConsoleProgressBarTrait.postRun
public function postRun(): void { if ($this->progress) { $this->progress->finish(); // Progress bar does not print a new-line at the end. $this->getOutput()->writeln(''); } }
php
public function postRun(): void { if ($this->progress) { $this->progress->finish(); // Progress bar does not print a new-line at the end. $this->getOutput()->writeln(''); } }
[ "public", "function", "postRun", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "progress", ")", "{", "$", "this", "->", "progress", "->", "finish", "(", ")", ";", "// Progress bar does not print a new-line at the end.", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "''", ")", ";", "}", "}" ]
Finishes the progress output in the post-run phase. @see \Shiyan\Iterate\Scenario\ScenarioInterface::postRun()
[ "Finishes", "the", "progress", "output", "in", "the", "post", "-", "run", "phase", "." ]
595fc2e23eead334b4f333621b2995bfe649f1f2
https://github.com/mikeshiyan/iterate/blob/595fc2e23eead334b4f333621b2995bfe649f1f2/src/Scenario/ConsoleProgressBarTrait.php#L122-L128
3,621
mikeshiyan/iterate
src/Scenario/ConsoleProgressBarTrait.php
ConsoleProgressBarTrait.outputInProgress
protected function outputInProgress(string $line): void { if ($this->progress) { $this->progress->clear(); $this->getOutput()->writeln($line); $this->progress->display(); } }
php
protected function outputInProgress(string $line): void { if ($this->progress) { $this->progress->clear(); $this->getOutput()->writeln($line); $this->progress->display(); } }
[ "protected", "function", "outputInProgress", "(", "string", "$", "line", ")", ":", "void", "{", "if", "(", "$", "this", "->", "progress", ")", "{", "$", "this", "->", "progress", "->", "clear", "(", ")", ";", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "$", "line", ")", ";", "$", "this", "->", "progress", "->", "display", "(", ")", ";", "}", "}" ]
Outputs a line of text while a progress bar is running. @param string $line Text to output.
[ "Outputs", "a", "line", "of", "text", "while", "a", "progress", "bar", "is", "running", "." ]
595fc2e23eead334b4f333621b2995bfe649f1f2
https://github.com/mikeshiyan/iterate/blob/595fc2e23eead334b4f333621b2995bfe649f1f2/src/Scenario/ConsoleProgressBarTrait.php#L136-L142
3,622
zepi/turbo-base
Zepi/Core/AccessControl/src/Entity/AccessEntity.php
AccessEntity.getMetaData
public function getMetaData($key) { if (!isset($this->metaData[$key])) { return false; } return $this->metaData[$key]; }
php
public function getMetaData($key) { if (!isset($this->metaData[$key])) { return false; } return $this->metaData[$key]; }
[ "public", "function", "getMetaData", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "metaData", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "metaData", "[", "$", "key", "]", ";", "}" ]
Returns the meta data value for the given key @access public @param string $key @return mixed
[ "Returns", "the", "meta", "data", "value", "for", "the", "given", "key" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Entity/AccessEntity.php#L195-L202
3,623
zepi/turbo-base
Zepi/Core/AccessControl/src/Entity/AccessEntity.php
AccessEntity.hasAccess
public function hasAccess($accessLevel) { foreach ($this->permissions as $permission) { /** * If the user has the \Globa\* access level he can * do everything */ if ($permission == '\\Global\\*') { return true; } if ($permission == $accessLevel) { return true; } // If there is a star in the permission and everything before // the star is equal with the access level, the user has access // to the given access level. $posStar = strpos($permission, '*'); if ($posStar !== false) { $startPermission = substr($permission, 0, $posStar); $startAccessLevel = substr($accessLevel, 0, $posStar); if ($startPermission == $startAccessLevel) { return true; } } } return false; }
php
public function hasAccess($accessLevel) { foreach ($this->permissions as $permission) { /** * If the user has the \Globa\* access level he can * do everything */ if ($permission == '\\Global\\*') { return true; } if ($permission == $accessLevel) { return true; } // If there is a star in the permission and everything before // the star is equal with the access level, the user has access // to the given access level. $posStar = strpos($permission, '*'); if ($posStar !== false) { $startPermission = substr($permission, 0, $posStar); $startAccessLevel = substr($accessLevel, 0, $posStar); if ($startPermission == $startAccessLevel) { return true; } } } return false; }
[ "public", "function", "hasAccess", "(", "$", "accessLevel", ")", "{", "foreach", "(", "$", "this", "->", "permissions", "as", "$", "permission", ")", "{", "/**\n * If the user has the \\Globa\\* access level he can\n * do everything\n */", "if", "(", "$", "permission", "==", "'\\\\Global\\\\*'", ")", "{", "return", "true", ";", "}", "if", "(", "$", "permission", "==", "$", "accessLevel", ")", "{", "return", "true", ";", "}", "// If there is a star in the permission and everything before ", "// the star is equal with the access level, the user has access", "// to the given access level.", "$", "posStar", "=", "strpos", "(", "$", "permission", ",", "'*'", ")", ";", "if", "(", "$", "posStar", "!==", "false", ")", "{", "$", "startPermission", "=", "substr", "(", "$", "permission", ",", "0", ",", "$", "posStar", ")", ";", "$", "startAccessLevel", "=", "substr", "(", "$", "accessLevel", ",", "0", ",", "$", "posStar", ")", ";", "if", "(", "$", "startPermission", "==", "$", "startAccessLevel", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns true if the access entity has access to the given permission access level @access public @param string $accessLevel @return boolean
[ "Returns", "true", "if", "the", "access", "entity", "has", "access", "to", "the", "given", "permission", "access", "level" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/Entity/AccessEntity.php#L257-L287
3,624
gossi/trixionary
src/model/Base/SkillGroup.php
SkillGroup.setGroup
public function setGroup(ChildGroup $v = null) { // aggregate_column_relation behavior if (null !== $this->aGroup && $v !== $this->aGroup) { $this->oldGroupSkillCount = $this->aGroup; } if ($v === null) { $this->setGroupId(NULL); } else { $this->setGroupId($v->getId()); } $this->aGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildGroup object, it will not be re-added. if ($v !== null) { $v->addSkillGroup($this); } return $this; }
php
public function setGroup(ChildGroup $v = null) { // aggregate_column_relation behavior if (null !== $this->aGroup && $v !== $this->aGroup) { $this->oldGroupSkillCount = $this->aGroup; } if ($v === null) { $this->setGroupId(NULL); } else { $this->setGroupId($v->getId()); } $this->aGroup = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the ChildGroup object, it will not be re-added. if ($v !== null) { $v->addSkillGroup($this); } return $this; }
[ "public", "function", "setGroup", "(", "ChildGroup", "$", "v", "=", "null", ")", "{", "// aggregate_column_relation behavior", "if", "(", "null", "!==", "$", "this", "->", "aGroup", "&&", "$", "v", "!==", "$", "this", "->", "aGroup", ")", "{", "$", "this", "->", "oldGroupSkillCount", "=", "$", "this", "->", "aGroup", ";", "}", "if", "(", "$", "v", "===", "null", ")", "{", "$", "this", "->", "setGroupId", "(", "NULL", ")", ";", "}", "else", "{", "$", "this", "->", "setGroupId", "(", "$", "v", "->", "getId", "(", ")", ")", ";", "}", "$", "this", "->", "aGroup", "=", "$", "v", ";", "// Add binding for other direction of this n:n relationship.", "// If this object has already been added to the ChildGroup object, it will not be re-added.", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "->", "addSkillGroup", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Declares an association between this object and a ChildGroup object. @param ChildGroup $v @return $this|\gossi\trixionary\model\SkillGroup The current object (for fluent API support) @throws PropelException
[ "Declares", "an", "association", "between", "this", "object", "and", "a", "ChildGroup", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillGroup.php#L1074-L1096
3,625
gossi/trixionary
src/model/Base/SkillGroup.php
SkillGroup.getGroup
public function getGroup(ConnectionInterface $con = null) { if ($this->aGroup === null && ($this->group_id !== null)) { $this->aGroup = ChildGroupQuery::create()->findPk($this->group_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->aGroup->addSkillGroups($this); */ } return $this->aGroup; }
php
public function getGroup(ConnectionInterface $con = null) { if ($this->aGroup === null && ($this->group_id !== null)) { $this->aGroup = ChildGroupQuery::create()->findPk($this->group_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->aGroup->addSkillGroups($this); */ } return $this->aGroup; }
[ "public", "function", "getGroup", "(", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "$", "this", "->", "aGroup", "===", "null", "&&", "(", "$", "this", "->", "group_id", "!==", "null", ")", ")", "{", "$", "this", "->", "aGroup", "=", "ChildGroupQuery", "::", "create", "(", ")", "->", "findPk", "(", "$", "this", "->", "group_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->aGroup->addSkillGroups($this);\n */", "}", "return", "$", "this", "->", "aGroup", ";", "}" ]
Get the associated ChildGroup object @param ConnectionInterface $con Optional Connection object. @return ChildGroup The associated ChildGroup object. @throws PropelException
[ "Get", "the", "associated", "ChildGroup", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillGroup.php#L1106-L1120
3,626
gossi/trixionary
src/model/Base/SkillGroup.php
SkillGroup.updateRelatedGroupSkillCount
protected function updateRelatedGroupSkillCount(ConnectionInterface $con) { if ($group = $this->getGroup()) { $group->updateSkillCount($con); } if ($this->oldGroupSkillCount) { $this->oldGroupSkillCount->updateSkillCount($con); $this->oldGroupSkillCount = null; } }
php
protected function updateRelatedGroupSkillCount(ConnectionInterface $con) { if ($group = $this->getGroup()) { $group->updateSkillCount($con); } if ($this->oldGroupSkillCount) { $this->oldGroupSkillCount->updateSkillCount($con); $this->oldGroupSkillCount = null; } }
[ "protected", "function", "updateRelatedGroupSkillCount", "(", "ConnectionInterface", "$", "con", ")", "{", "if", "(", "$", "group", "=", "$", "this", "->", "getGroup", "(", ")", ")", "{", "$", "group", "->", "updateSkillCount", "(", "$", "con", ")", ";", "}", "if", "(", "$", "this", "->", "oldGroupSkillCount", ")", "{", "$", "this", "->", "oldGroupSkillCount", "->", "updateSkillCount", "(", "$", "con", ")", ";", "$", "this", "->", "oldGroupSkillCount", "=", "null", ";", "}", "}" ]
Update the aggregate column in the related Group object @param ConnectionInterface $con A connection object
[ "Update", "the", "aggregate", "column", "in", "the", "related", "Group", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/SkillGroup.php#L1229-L1238
3,627
ellipsephp/validation
src/Validator.php
Validator.withLabels
public function withLabels(array $labels): Validator { $translator = $this->translator->withLabels($labels); return new Validator($this->rules, $this->parser, $translator); }
php
public function withLabels(array $labels): Validator { $translator = $this->translator->withLabels($labels); return new Validator($this->rules, $this->parser, $translator); }
[ "public", "function", "withLabels", "(", "array", "$", "labels", ")", ":", "Validator", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withLabels", "(", "$", "labels", ")", ";", "return", "new", "Validator", "(", "$", "this", "->", "rules", ",", "$", "this", "->", "parser", ",", "$", "translator", ")", ";", "}" ]
Return a new validator with the given list of labels added to the translator. @param array $labels @return \Ellipse\Validation\Validator
[ "Return", "a", "new", "validator", "with", "the", "given", "list", "of", "labels", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Validator.php#L50-L55
3,628
ellipsephp/validation
src/Validator.php
Validator.withTemplates
public function withTemplates(array $templates): Validator { $translator = $this->translator->withTemplates($templates); return new Validator($this->rules, $this->parser, $translator); }
php
public function withTemplates(array $templates): Validator { $translator = $this->translator->withTemplates($templates); return new Validator($this->rules, $this->parser, $translator); }
[ "public", "function", "withTemplates", "(", "array", "$", "templates", ")", ":", "Validator", "{", "$", "translator", "=", "$", "this", "->", "translator", "->", "withTemplates", "(", "$", "templates", ")", ";", "return", "new", "Validator", "(", "$", "this", "->", "rules", ",", "$", "this", "->", "parser", ",", "$", "translator", ")", ";", "}" ]
Return a new validator with the given list of templates added to the translator. @param array $templates @return \Ellipse\Validation\Validator
[ "Return", "a", "new", "validator", "with", "the", "given", "list", "of", "templates", "added", "to", "the", "translator", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Validator.php#L64-L69
3,629
ellipsephp/validation
src/Validator.php
Validator.validate
public function validate(array $input = []): ValidationResult { $results = []; foreach ($this->rules as $key => $definition) { $rules = $this->parser->parseRulesDefinition($definition); $results[$key] = $rules->validate($key, $input); } return new ValidationResult($results, $this->translator); }
php
public function validate(array $input = []): ValidationResult { $results = []; foreach ($this->rules as $key => $definition) { $rules = $this->parser->parseRulesDefinition($definition); $results[$key] = $rules->validate($key, $input); } return new ValidationResult($results, $this->translator); }
[ "public", "function", "validate", "(", "array", "$", "input", "=", "[", "]", ")", ":", "ValidationResult", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "rules", "as", "$", "key", "=>", "$", "definition", ")", "{", "$", "rules", "=", "$", "this", "->", "parser", "->", "parseRulesDefinition", "(", "$", "definition", ")", ";", "$", "results", "[", "$", "key", "]", "=", "$", "rules", "->", "validate", "(", "$", "key", ",", "$", "input", ")", ";", "}", "return", "new", "ValidationResult", "(", "$", "results", ",", "$", "this", "->", "translator", ")", ";", "}" ]
Validate the given input against the rules. @param array $input @return \Ellipse\Validation\ValidationResult
[ "Validate", "the", "given", "input", "against", "the", "rules", "." ]
5a7e11807099165ff6217bf8c38df4b21d99599d
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Validator.php#L77-L90
3,630
monolyth-php/formulaic
src/Validate/Required.php
Required.isRequired
public function isRequired() : Testable { $this->attributes['required'] = true; return $this->addTest('required', function ($value) { if (is_array($value)) { return $value; } return strlen(trim($value)); }); }
php
public function isRequired() : Testable { $this->attributes['required'] = true; return $this->addTest('required', function ($value) { if (is_array($value)) { return $value; } return strlen(trim($value)); }); }
[ "public", "function", "isRequired", "(", ")", ":", "Testable", "{", "$", "this", "->", "attributes", "[", "'required'", "]", "=", "true", ";", "return", "$", "this", "->", "addTest", "(", "'required'", ",", "function", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "return", "strlen", "(", "trim", "(", "$", "value", ")", ")", ";", "}", ")", ";", "}" ]
This is a required field. @return self
[ "This", "is", "a", "required", "field", "." ]
4bf7853a0c29cc17957f1b26c79f633867742c14
https://github.com/monolyth-php/formulaic/blob/4bf7853a0c29cc17957f1b26c79f633867742c14/src/Validate/Required.php#L14-L23
3,631
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeModel
protected function serializeModel(Model $model, AdapterInterface $adapter) { $metadata = $model->getMetadata(); $serialized = [ 'type' => $model->getType(), 'id' => $model->getId(), ]; if ($this->depth > 0) { // $this->includeResource($resource); return $serialized; } foreach ($metadata->getAttributes() as $key => $attrMeta) { if (false === $attrMeta->shouldSerialize()) { continue; } $value = $model->get($key); $serialized['attributes'][$key] = $this->serializeAttribute($value, $attrMeta); } foreach ($metadata->getEmbeds() as $key => $embeddedPropMeta) { if (false === $attrMeta->shouldSerialize()) { continue; } $value = $model->get($key); $serialized['attributes'][$key] = $this->serializeEmbed($value, $embeddedPropMeta); } $serialized['links'] = ['self' => $adapter->buildUrl($metadata, $model->getId())]; $model->enableCollectionAutoInit(false); $this->increaseDepth(); foreach ($metadata->getRelationships() as $key => $relMeta) { if (false === $relMeta->shouldSerialize()) { continue; } $relationship = $model->get($key); $serialized['relationships'][$key] = $this->serializeRelationship($model, $relationship, $relMeta, $adapter); } $this->decreaseDepth(); $model->enableCollectionAutoInit(true); return $serialized; }
php
protected function serializeModel(Model $model, AdapterInterface $adapter) { $metadata = $model->getMetadata(); $serialized = [ 'type' => $model->getType(), 'id' => $model->getId(), ]; if ($this->depth > 0) { // $this->includeResource($resource); return $serialized; } foreach ($metadata->getAttributes() as $key => $attrMeta) { if (false === $attrMeta->shouldSerialize()) { continue; } $value = $model->get($key); $serialized['attributes'][$key] = $this->serializeAttribute($value, $attrMeta); } foreach ($metadata->getEmbeds() as $key => $embeddedPropMeta) { if (false === $attrMeta->shouldSerialize()) { continue; } $value = $model->get($key); $serialized['attributes'][$key] = $this->serializeEmbed($value, $embeddedPropMeta); } $serialized['links'] = ['self' => $adapter->buildUrl($metadata, $model->getId())]; $model->enableCollectionAutoInit(false); $this->increaseDepth(); foreach ($metadata->getRelationships() as $key => $relMeta) { if (false === $relMeta->shouldSerialize()) { continue; } $relationship = $model->get($key); $serialized['relationships'][$key] = $this->serializeRelationship($model, $relationship, $relMeta, $adapter); } $this->decreaseDepth(); $model->enableCollectionAutoInit(true); return $serialized; }
[ "protected", "function", "serializeModel", "(", "Model", "$", "model", ",", "AdapterInterface", "$", "adapter", ")", "{", "$", "metadata", "=", "$", "model", "->", "getMetadata", "(", ")", ";", "$", "serialized", "=", "[", "'type'", "=>", "$", "model", "->", "getType", "(", ")", ",", "'id'", "=>", "$", "model", "->", "getId", "(", ")", ",", "]", ";", "if", "(", "$", "this", "->", "depth", ">", "0", ")", "{", "// $this->includeResource($resource);", "return", "$", "serialized", ";", "}", "foreach", "(", "$", "metadata", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$", "attrMeta", ")", "{", "if", "(", "false", "===", "$", "attrMeta", "->", "shouldSerialize", "(", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "model", "->", "get", "(", "$", "key", ")", ";", "$", "serialized", "[", "'attributes'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "serializeAttribute", "(", "$", "value", ",", "$", "attrMeta", ")", ";", "}", "foreach", "(", "$", "metadata", "->", "getEmbeds", "(", ")", "as", "$", "key", "=>", "$", "embeddedPropMeta", ")", "{", "if", "(", "false", "===", "$", "attrMeta", "->", "shouldSerialize", "(", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "model", "->", "get", "(", "$", "key", ")", ";", "$", "serialized", "[", "'attributes'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "serializeEmbed", "(", "$", "value", ",", "$", "embeddedPropMeta", ")", ";", "}", "$", "serialized", "[", "'links'", "]", "=", "[", "'self'", "=>", "$", "adapter", "->", "buildUrl", "(", "$", "metadata", ",", "$", "model", "->", "getId", "(", ")", ")", "]", ";", "$", "model", "->", "enableCollectionAutoInit", "(", "false", ")", ";", "$", "this", "->", "increaseDepth", "(", ")", ";", "foreach", "(", "$", "metadata", "->", "getRelationships", "(", ")", "as", "$", "key", "=>", "$", "relMeta", ")", "{", "if", "(", "false", "===", "$", "relMeta", "->", "shouldSerialize", "(", ")", ")", "{", "continue", ";", "}", "$", "relationship", "=", "$", "model", "->", "get", "(", "$", "key", ")", ";", "$", "serialized", "[", "'relationships'", "]", "[", "$", "key", "]", "=", "$", "this", "->", "serializeRelationship", "(", "$", "model", ",", "$", "relationship", ",", "$", "relMeta", ",", "$", "adapter", ")", ";", "}", "$", "this", "->", "decreaseDepth", "(", ")", ";", "$", "model", "->", "enableCollectionAutoInit", "(", "true", ")", ";", "return", "$", "serialized", ";", "}" ]
Serializes the "interior" of a model. This is the serialization that takes place outside of a "data" container. Can be used for root model and relationship model serialization. @param Model $model @param AdapterInterface $adapter @return array
[ "Serializes", "the", "interior", "of", "a", "model", ".", "This", "is", "the", "serialization", "that", "takes", "place", "outside", "of", "a", "data", "container", ".", "Can", "be", "used", "for", "root", "model", "and", "relationship", "model", "serialization", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L135-L177
3,632
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeAttribute
protected function serializeAttribute($value, AttributeMetadata $attrMeta) { if ('date' === $attrMeta->dataType && $value instanceof \DateTime) { $milliseconds = sprintf('%03d', round($value->format('u') / 1000, 0)); return gmdate(sprintf('Y-m-d\TH:i:s.%s\Z', $milliseconds), $value->getTimestamp()); } if ('array' === $attrMeta->dataType && empty($value)) { return []; } if ('object' === $attrMeta->dataType) { return (array) $value; } return $value; }
php
protected function serializeAttribute($value, AttributeMetadata $attrMeta) { if ('date' === $attrMeta->dataType && $value instanceof \DateTime) { $milliseconds = sprintf('%03d', round($value->format('u') / 1000, 0)); return gmdate(sprintf('Y-m-d\TH:i:s.%s\Z', $milliseconds), $value->getTimestamp()); } if ('array' === $attrMeta->dataType && empty($value)) { return []; } if ('object' === $attrMeta->dataType) { return (array) $value; } return $value; }
[ "protected", "function", "serializeAttribute", "(", "$", "value", ",", "AttributeMetadata", "$", "attrMeta", ")", "{", "if", "(", "'date'", "===", "$", "attrMeta", "->", "dataType", "&&", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "$", "milliseconds", "=", "sprintf", "(", "'%03d'", ",", "round", "(", "$", "value", "->", "format", "(", "'u'", ")", "/", "1000", ",", "0", ")", ")", ";", "return", "gmdate", "(", "sprintf", "(", "'Y-m-d\\TH:i:s.%s\\Z'", ",", "$", "milliseconds", ")", ",", "$", "value", "->", "getTimestamp", "(", ")", ")", ";", "}", "if", "(", "'array'", "===", "$", "attrMeta", "->", "dataType", "&&", "empty", "(", "$", "value", ")", ")", "{", "return", "[", "]", ";", "}", "if", "(", "'object'", "===", "$", "attrMeta", "->", "dataType", ")", "{", "return", "(", "array", ")", "$", "value", ";", "}", "return", "$", "value", ";", "}" ]
Serializes an attribute value. @param mixed $value @param AttributeMetadata $attrMeta @return mixed
[ "Serializes", "an", "attribute", "value", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L186-L199
3,633
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeEmbed
protected function serializeEmbed($value, EmbeddedPropMetadata $embeddedPropMeta) { $embedMeta = $embeddedPropMeta->embedMeta; if (true === $embeddedPropMeta->isOne()) { return $this->serializeEmbedOne($embedMeta, $value); } return $this->serializeEmbedMany($embedMeta, $value); }
php
protected function serializeEmbed($value, EmbeddedPropMetadata $embeddedPropMeta) { $embedMeta = $embeddedPropMeta->embedMeta; if (true === $embeddedPropMeta->isOne()) { return $this->serializeEmbedOne($embedMeta, $value); } return $this->serializeEmbedMany($embedMeta, $value); }
[ "protected", "function", "serializeEmbed", "(", "$", "value", ",", "EmbeddedPropMetadata", "$", "embeddedPropMeta", ")", "{", "$", "embedMeta", "=", "$", "embeddedPropMeta", "->", "embedMeta", ";", "if", "(", "true", "===", "$", "embeddedPropMeta", "->", "isOne", "(", ")", ")", "{", "return", "$", "this", "->", "serializeEmbedOne", "(", "$", "embedMeta", ",", "$", "value", ")", ";", "}", "return", "$", "this", "->", "serializeEmbedMany", "(", "$", "embedMeta", ",", "$", "value", ")", ";", "}" ]
Serializes an embed value. @param Embed|EmbedCollection|null $value @param EmbeddedPropMetadata $embeddedPropMeta @return array|null
[ "Serializes", "an", "embed", "value", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L208-L215
3,634
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeEmbedOne
protected function serializeEmbedOne(EmbedMetadata $embedMeta, Embed $embed = null) { if (null === $embed) { return; } $serialized = []; foreach ($embedMeta->getAttributes() as $key => $attrMeta) { $serialized[$key] = $this->serializeAttribute($embed->get($key), $attrMeta); } foreach ($embedMeta->getEmbeds() as $key => $embeddedPropMeta) { $serialized[$key] = $this->serializeEmbed($embed->get($key), $embeddedPropMeta); } return empty($serialized) ? null : $serialized; }
php
protected function serializeEmbedOne(EmbedMetadata $embedMeta, Embed $embed = null) { if (null === $embed) { return; } $serialized = []; foreach ($embedMeta->getAttributes() as $key => $attrMeta) { $serialized[$key] = $this->serializeAttribute($embed->get($key), $attrMeta); } foreach ($embedMeta->getEmbeds() as $key => $embeddedPropMeta) { $serialized[$key] = $this->serializeEmbed($embed->get($key), $embeddedPropMeta); } return empty($serialized) ? null : $serialized; }
[ "protected", "function", "serializeEmbedOne", "(", "EmbedMetadata", "$", "embedMeta", ",", "Embed", "$", "embed", "=", "null", ")", "{", "if", "(", "null", "===", "$", "embed", ")", "{", "return", ";", "}", "$", "serialized", "=", "[", "]", ";", "foreach", "(", "$", "embedMeta", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$", "attrMeta", ")", "{", "$", "serialized", "[", "$", "key", "]", "=", "$", "this", "->", "serializeAttribute", "(", "$", "embed", "->", "get", "(", "$", "key", ")", ",", "$", "attrMeta", ")", ";", "}", "foreach", "(", "$", "embedMeta", "->", "getEmbeds", "(", ")", "as", "$", "key", "=>", "$", "embeddedPropMeta", ")", "{", "$", "serialized", "[", "$", "key", "]", "=", "$", "this", "->", "serializeEmbed", "(", "$", "embed", "->", "get", "(", "$", "key", ")", ",", "$", "embeddedPropMeta", ")", ";", "}", "return", "empty", "(", "$", "serialized", ")", "?", "null", ":", "$", "serialized", ";", "}" ]
Serializes an embed one value. @param EmbedMetadata $embedMeta @param Embed|null $embed @return array|null
[ "Serializes", "an", "embed", "one", "value", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L224-L238
3,635
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeEmbedMany
protected function serializeEmbedMany(EmbedMetadata $embedMeta, EmbedCollection $collection) { $serialized = []; foreach ($collection as $embed) { if (!$embed instanceof Embed) { continue; } $serialized[] = $this->serializeEmbedOne($embedMeta, $embed); } return $serialized; }
php
protected function serializeEmbedMany(EmbedMetadata $embedMeta, EmbedCollection $collection) { $serialized = []; foreach ($collection as $embed) { if (!$embed instanceof Embed) { continue; } $serialized[] = $this->serializeEmbedOne($embedMeta, $embed); } return $serialized; }
[ "protected", "function", "serializeEmbedMany", "(", "EmbedMetadata", "$", "embedMeta", ",", "EmbedCollection", "$", "collection", ")", "{", "$", "serialized", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", "$", "embed", ")", "{", "if", "(", "!", "$", "embed", "instanceof", "Embed", ")", "{", "continue", ";", "}", "$", "serialized", "[", "]", "=", "$", "this", "->", "serializeEmbedOne", "(", "$", "embedMeta", ",", "$", "embed", ")", ";", "}", "return", "$", "serialized", ";", "}" ]
Serializes an embed many value. @param EmbedMetadata $embedMeta @param EmbedCollection $embed @return array
[ "Serializes", "an", "embed", "many", "value", "." ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L247-L257
3,636
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeRelationship
protected function serializeRelationship(Model $owner, $relationship = null, RelationshipMetadata $relMeta, AdapterInterface $adapter) { if ($relMeta->isOne()) { if (is_array($relationship)) { throw SerializerException::badRequest('Invalid relationship value.'); } $serialized = $this->serializeHasOne($owner, $relationship, $adapter); } elseif (is_array($relationship) || null === $relationship) { $serialized = $this->serializeHasMany($owner, $relationship, $adapter); } else { throw SerializerException::badRequest('Invalid relationship value.'); } $ownerMeta = $owner->getMetadata(); $serialized['links'] = [ 'self' => $adapter->buildUrl($ownerMeta, $owner->getId(), $relMeta->getKey()), 'related' => $adapter->buildUrl($ownerMeta, $owner->getId(), $relMeta->getKey(), true), ]; return $serialized; }
php
protected function serializeRelationship(Model $owner, $relationship = null, RelationshipMetadata $relMeta, AdapterInterface $adapter) { if ($relMeta->isOne()) { if (is_array($relationship)) { throw SerializerException::badRequest('Invalid relationship value.'); } $serialized = $this->serializeHasOne($owner, $relationship, $adapter); } elseif (is_array($relationship) || null === $relationship) { $serialized = $this->serializeHasMany($owner, $relationship, $adapter); } else { throw SerializerException::badRequest('Invalid relationship value.'); } $ownerMeta = $owner->getMetadata(); $serialized['links'] = [ 'self' => $adapter->buildUrl($ownerMeta, $owner->getId(), $relMeta->getKey()), 'related' => $adapter->buildUrl($ownerMeta, $owner->getId(), $relMeta->getKey(), true), ]; return $serialized; }
[ "protected", "function", "serializeRelationship", "(", "Model", "$", "owner", ",", "$", "relationship", "=", "null", ",", "RelationshipMetadata", "$", "relMeta", ",", "AdapterInterface", "$", "adapter", ")", "{", "if", "(", "$", "relMeta", "->", "isOne", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "relationship", ")", ")", "{", "throw", "SerializerException", "::", "badRequest", "(", "'Invalid relationship value.'", ")", ";", "}", "$", "serialized", "=", "$", "this", "->", "serializeHasOne", "(", "$", "owner", ",", "$", "relationship", ",", "$", "adapter", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "relationship", ")", "||", "null", "===", "$", "relationship", ")", "{", "$", "serialized", "=", "$", "this", "->", "serializeHasMany", "(", "$", "owner", ",", "$", "relationship", ",", "$", "adapter", ")", ";", "}", "else", "{", "throw", "SerializerException", "::", "badRequest", "(", "'Invalid relationship value.'", ")", ";", "}", "$", "ownerMeta", "=", "$", "owner", "->", "getMetadata", "(", ")", ";", "$", "serialized", "[", "'links'", "]", "=", "[", "'self'", "=>", "$", "adapter", "->", "buildUrl", "(", "$", "ownerMeta", ",", "$", "owner", "->", "getId", "(", ")", ",", "$", "relMeta", "->", "getKey", "(", ")", ")", ",", "'related'", "=>", "$", "adapter", "->", "buildUrl", "(", "$", "ownerMeta", ",", "$", "owner", "->", "getId", "(", ")", ",", "$", "relMeta", "->", "getKey", "(", ")", ",", "true", ")", ",", "]", ";", "return", "$", "serialized", ";", "}" ]
Serializes a relationship value @param Model $owner @param Model|Model[]|null $relationship @param RelationshipMetadata $relMeta @param AdapterInterface $adapter @return array
[ "Serializes", "a", "relationship", "value" ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L268-L287
3,637
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeHasMany
protected function serializeHasMany(Model $owner, array $models = null, AdapterInterface $adapter) { if (empty($models)) { return $this->serialize(null, $adapter); } return $this->serializeArray($models, $adapter); }
php
protected function serializeHasMany(Model $owner, array $models = null, AdapterInterface $adapter) { if (empty($models)) { return $this->serialize(null, $adapter); } return $this->serializeArray($models, $adapter); }
[ "protected", "function", "serializeHasMany", "(", "Model", "$", "owner", ",", "array", "$", "models", "=", "null", ",", "AdapterInterface", "$", "adapter", ")", "{", "if", "(", "empty", "(", "$", "models", ")", ")", "{", "return", "$", "this", "->", "serialize", "(", "null", ",", "$", "adapter", ")", ";", "}", "return", "$", "this", "->", "serializeArray", "(", "$", "models", ",", "$", "adapter", ")", ";", "}" ]
Serializes a has-many relationship value @param Model $owner @param Model[]|null $models @param AdapterInterface $adapter @return array
[ "Serializes", "a", "has", "-", "many", "relationship", "value" ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L297-L303
3,638
as3io/modlr-api-jsonapiorg
src/Serializer.php
Serializer.serializeHasOne
protected function serializeHasOne(Model $owner, Model $model = null, AdapterInterface $adapter) { return $this->serialize($model, $adapter); }
php
protected function serializeHasOne(Model $owner, Model $model = null, AdapterInterface $adapter) { return $this->serialize($model, $adapter); }
[ "protected", "function", "serializeHasOne", "(", "Model", "$", "owner", ",", "Model", "$", "model", "=", "null", ",", "AdapterInterface", "$", "adapter", ")", "{", "return", "$", "this", "->", "serialize", "(", "$", "model", ",", "$", "adapter", ")", ";", "}" ]
Serializes a has-one relationship value @param Model $owner @param Model|null $model @param AdapterInterface $adapter @return array
[ "Serializes", "a", "has", "-", "one", "relationship", "value" ]
f53163c315a6a7be09e514a4c81af24aa665634b
https://github.com/as3io/modlr-api-jsonapiorg/blob/f53163c315a6a7be09e514a4c81af24aa665634b/src/Serializer.php#L313-L316
3,639
zugoripls/laravel-framework
src/Illuminate/Console/Scheduling/Event.php
Event.buildCommand
public function buildCommand() { if ($this->withoutOverlapping) { $command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().') > '.$this->output.' 2>&1 &'; } else { $command = $this->command.' > '.$this->output.' 2>&1 &'; } return $this->user ? 'sudo -u '.$this->user.' '.$command : $command; }
php
public function buildCommand() { if ($this->withoutOverlapping) { $command = '(touch '.$this->mutexPath().'; '.$this->command.'; rm '.$this->mutexPath().') > '.$this->output.' 2>&1 &'; } else { $command = $this->command.' > '.$this->output.' 2>&1 &'; } return $this->user ? 'sudo -u '.$this->user.' '.$command : $command; }
[ "public", "function", "buildCommand", "(", ")", "{", "if", "(", "$", "this", "->", "withoutOverlapping", ")", "{", "$", "command", "=", "'(touch '", ".", "$", "this", "->", "mutexPath", "(", ")", ".", "'; '", ".", "$", "this", "->", "command", ".", "'; rm '", ".", "$", "this", "->", "mutexPath", "(", ")", ".", "') > '", ".", "$", "this", "->", "output", ".", "' 2>&1 &'", ";", "}", "else", "{", "$", "command", "=", "$", "this", "->", "command", ".", "' > '", ".", "$", "this", "->", "output", ".", "' 2>&1 &'", ";", "}", "return", "$", "this", "->", "user", "?", "'sudo -u '", ".", "$", "this", "->", "user", ".", "' '", ".", "$", "command", ":", "$", "command", ";", "}" ]
Build the comand string. @return string
[ "Build", "the", "comand", "string", "." ]
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Console/Scheduling/Event.php#L174-L187
3,640
Ocelot-Framework/ocelot-mvc
src/Util/AntPathMatcher.php
AntPathMatcher.tokenizePath
protected function tokenizePath($path) { $parts = explode($this->pathSeparator, $path); if ($this->trimTokens) { for ($i = 0; $i < count($parts); $i++) { $parts[$i] = trim($parts[$i]); if ($parts[$i] === "") { unset($parts[$i]); } } } return array_values($parts); }
php
protected function tokenizePath($path) { $parts = explode($this->pathSeparator, $path); if ($this->trimTokens) { for ($i = 0; $i < count($parts); $i++) { $parts[$i] = trim($parts[$i]); if ($parts[$i] === "") { unset($parts[$i]); } } } return array_values($parts); }
[ "protected", "function", "tokenizePath", "(", "$", "path", ")", "{", "$", "parts", "=", "explode", "(", "$", "this", "->", "pathSeparator", ",", "$", "path", ")", ";", "if", "(", "$", "this", "->", "trimTokens", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "parts", ")", ";", "$", "i", "++", ")", "{", "$", "parts", "[", "$", "i", "]", "=", "trim", "(", "$", "parts", "[", "$", "i", "]", ")", ";", "if", "(", "$", "parts", "[", "$", "i", "]", "===", "\"\"", ")", "{", "unset", "(", "$", "parts", "[", "$", "i", "]", ")", ";", "}", "}", "}", "return", "array_values", "(", "$", "parts", ")", ";", "}" ]
Tokenize the given path String into parts, based on this matcher's settings. @param string $path the path to tokenize @return string[] the tokenized path parts
[ "Tokenize", "the", "given", "path", "String", "into", "parts", "based", "on", "this", "matcher", "s", "settings", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Util/AntPathMatcher.php#L323-L335
3,641
Ocelot-Framework/ocelot-mvc
src/Util/AntPathMatcher.php
AntPathMatcher.matchStrings
protected function matchStrings($pattern, $str, &$uriTemplateVariables) { return $this->getStringMatcher($pattern)->matchStrings($str, $uriTemplateVariables); }
php
protected function matchStrings($pattern, $str, &$uriTemplateVariables) { return $this->getStringMatcher($pattern)->matchStrings($str, $uriTemplateVariables); }
[ "protected", "function", "matchStrings", "(", "$", "pattern", ",", "$", "str", ",", "&", "$", "uriTemplateVariables", ")", "{", "return", "$", "this", "->", "getStringMatcher", "(", "$", "pattern", ")", "->", "matchStrings", "(", "$", "str", ",", "$", "uriTemplateVariables", ")", ";", "}" ]
Tests whether or not a string matches against a pattern. @param string $pattern the pattern to match against (never {@code null}) @param string $str the String which must be matched against the pattern (never {@code null}) @param array $uriTemplateVariables the array in which to store uri template variables @return boolean {@code true} if the string matches against the pattern, or {@code false} otherwise
[ "Tests", "whether", "or", "not", "a", "string", "matches", "against", "a", "pattern", "." ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Util/AntPathMatcher.php#L345-L348
3,642
Ocelot-Framework/ocelot-mvc
src/Util/AntPathMatcher.php
AntPathMatcher.concat
protected function concat($path1, $path2) { if (substr($path1, -1) == $this->pathSeparator || substr($path2, 0, 1) == $this->pathSeparator) { return $path1 . $path2; } return $path1 . $this->pathSeparator . $path2; }
php
protected function concat($path1, $path2) { if (substr($path1, -1) == $this->pathSeparator || substr($path2, 0, 1) == $this->pathSeparator) { return $path1 . $path2; } return $path1 . $this->pathSeparator . $path2; }
[ "protected", "function", "concat", "(", "$", "path1", ",", "$", "path2", ")", "{", "if", "(", "substr", "(", "$", "path1", ",", "-", "1", ")", "==", "$", "this", "->", "pathSeparator", "||", "substr", "(", "$", "path2", ",", "0", ",", "1", ")", "==", "$", "this", "->", "pathSeparator", ")", "{", "return", "$", "path1", ".", "$", "path2", ";", "}", "return", "$", "path1", ".", "$", "this", "->", "pathSeparator", ".", "$", "path2", ";", "}" ]
Concats two paths using the path separator @param string $path1 The first path @param string $path2 The second path @return string
[ "Concats", "two", "paths", "using", "the", "path", "separator" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Util/AntPathMatcher.php#L515-L521
3,643
szmnmichalowski/SzmNotification
src/Controller/Plugin/Notification.php
Notification.getAllCurrent
public function getAllCurrent() { $notifications = []; $container = $this->getContainer(); foreach ($container as $namespace => $notification) { $notifications[$namespace] = $this->getCurrent($namespace); } return $notifications; }
php
public function getAllCurrent() { $notifications = []; $container = $this->getContainer(); foreach ($container as $namespace => $notification) { $notifications[$namespace] = $this->getCurrent($namespace); } return $notifications; }
[ "public", "function", "getAllCurrent", "(", ")", "{", "$", "notifications", "=", "[", "]", ";", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "foreach", "(", "$", "container", "as", "$", "namespace", "=>", "$", "notification", ")", "{", "$", "notifications", "[", "$", "namespace", "]", "=", "$", "this", "->", "getCurrent", "(", "$", "namespace", ")", ";", "}", "return", "$", "notifications", ";", "}" ]
Get all current notifications @return array
[ "Get", "all", "current", "notifications" ]
0cc79dca9a928d5c9ab806de5465f5b879e5b30b
https://github.com/szmnmichalowski/SzmNotification/blob/0cc79dca9a928d5c9ab806de5465f5b879e5b30b/src/Controller/Plugin/Notification.php#L310-L320
3,644
szmnmichalowski/SzmNotification
src/Controller/Plugin/Notification.php
Notification.getNotificationsFromContainer
protected function getNotificationsFromContainer() { if (!empty($this->notifications) || $this->isAdded) { return; } $container = $this->getContainer(); $namespaces = []; foreach ($container as $namespace => $notification) { $this->notifications[$namespace] = $notification; $namespaces[] = $namespace; } $this->clearNotificationsFromContainer($namespaces); }
php
protected function getNotificationsFromContainer() { if (!empty($this->notifications) || $this->isAdded) { return; } $container = $this->getContainer(); $namespaces = []; foreach ($container as $namespace => $notification) { $this->notifications[$namespace] = $notification; $namespaces[] = $namespace; } $this->clearNotificationsFromContainer($namespaces); }
[ "protected", "function", "getNotificationsFromContainer", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "notifications", ")", "||", "$", "this", "->", "isAdded", ")", "{", "return", ";", "}", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "$", "namespaces", "=", "[", "]", ";", "foreach", "(", "$", "container", "as", "$", "namespace", "=>", "$", "notification", ")", "{", "$", "this", "->", "notifications", "[", "$", "namespace", "]", "=", "$", "notification", ";", "$", "namespaces", "[", "]", "=", "$", "namespace", ";", "}", "$", "this", "->", "clearNotificationsFromContainer", "(", "$", "namespaces", ")", ";", "}" ]
Clear notifications from container
[ "Clear", "notifications", "from", "container" ]
0cc79dca9a928d5c9ab806de5465f5b879e5b30b
https://github.com/szmnmichalowski/SzmNotification/blob/0cc79dca9a928d5c9ab806de5465f5b879e5b30b/src/Controller/Plugin/Notification.php#L453-L468
3,645
szmnmichalowski/SzmNotification
src/Controller/Plugin/Notification.php
Notification.clearCurrent
public function clearCurrent($namespace = null) { $container = $this->getContainer(); if ($namespace) { if (!$container->offsetExists($namespace)) { return false; } unset($container->{$namespace}); return true; } foreach ($container as $namespace => $notifications) { $container->offsetUnset($namespace); } return true; }
php
public function clearCurrent($namespace = null) { $container = $this->getContainer(); if ($namespace) { if (!$container->offsetExists($namespace)) { return false; } unset($container->{$namespace}); return true; } foreach ($container as $namespace => $notifications) { $container->offsetUnset($namespace); } return true; }
[ "public", "function", "clearCurrent", "(", "$", "namespace", "=", "null", ")", "{", "$", "container", "=", "$", "this", "->", "getContainer", "(", ")", ";", "if", "(", "$", "namespace", ")", "{", "if", "(", "!", "$", "container", "->", "offsetExists", "(", "$", "namespace", ")", ")", "{", "return", "false", ";", "}", "unset", "(", "$", "container", "->", "{", "$", "namespace", "}", ")", ";", "return", "true", ";", "}", "foreach", "(", "$", "container", "as", "$", "namespace", "=>", "$", "notifications", ")", "{", "$", "container", "->", "offsetUnset", "(", "$", "namespace", ")", ";", "}", "return", "true", ";", "}" ]
Clear notifications from container if namespace is provided or clear all notifications added during this request if namespace is not provided. @param null $namespace @return bool
[ "Clear", "notifications", "from", "container", "if", "namespace", "is", "provided", "or", "clear", "all", "notifications", "added", "during", "this", "request", "if", "namespace", "is", "not", "provided", "." ]
0cc79dca9a928d5c9ab806de5465f5b879e5b30b
https://github.com/szmnmichalowski/SzmNotification/blob/0cc79dca9a928d5c9ab806de5465f5b879e5b30b/src/Controller/Plugin/Notification.php#L490-L508
3,646
szmnmichalowski/SzmNotification
src/Controller/Plugin/Notification.php
Notification.clear
public function clear($namespace = null) { $this->getNotificationsFromContainer(); if ($namespace) { if (isset($this->notifications[$namespace])) { unset($this->notifications[$namespace]); return true; } return false; } foreach ($this->notifications as $nm => $type) { unset($this->notifications[$nm]); } return true; }
php
public function clear($namespace = null) { $this->getNotificationsFromContainer(); if ($namespace) { if (isset($this->notifications[$namespace])) { unset($this->notifications[$namespace]); return true; } return false; } foreach ($this->notifications as $nm => $type) { unset($this->notifications[$nm]); } return true; }
[ "public", "function", "clear", "(", "$", "namespace", "=", "null", ")", "{", "$", "this", "->", "getNotificationsFromContainer", "(", ")", ";", "if", "(", "$", "namespace", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "notifications", "[", "$", "namespace", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "notifications", "[", "$", "namespace", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "notifications", "as", "$", "nm", "=>", "$", "type", ")", "{", "unset", "(", "$", "this", "->", "notifications", "[", "$", "nm", "]", ")", ";", "}", "return", "true", ";", "}" ]
Clear notifications from previous request by provided namespace or clear all notifications if namespace is not provided @param null $namespace @return bool
[ "Clear", "notifications", "from", "previous", "request", "by", "provided", "namespace", "or", "clear", "all", "notifications", "if", "namespace", "is", "not", "provided" ]
0cc79dca9a928d5c9ab806de5465f5b879e5b30b
https://github.com/szmnmichalowski/SzmNotification/blob/0cc79dca9a928d5c9ab806de5465f5b879e5b30b/src/Controller/Plugin/Notification.php#L517-L535
3,647
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/References.php
References.updateOne
public function updateOne(string $referenceName, string $value) : array { return $this->sendPatch( sprintf('/profiles/%s/references/%s', $this->userName, $referenceName), [], [ 'value' => $value ] ); }
php
public function updateOne(string $referenceName, string $value) : array { return $this->sendPatch( sprintf('/profiles/%s/references/%s', $this->userName, $referenceName), [], [ 'value' => $value ] ); }
[ "public", "function", "updateOne", "(", "string", "$", "referenceName", ",", "string", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPatch", "(", "sprintf", "(", "'/profiles/%s/references/%s'", ",", "$", "this", "->", "userName", ",", "$", "referenceName", ")", ",", "[", "]", ",", "[", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Updates a reference given its slug. @param bool $value @return array Response
[ "Updates", "a", "reference", "given", "its", "slug", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/References.php#L68-L76
3,648
YiMAproject/yimaLocalize
src/yimaLocalize/LocaliPlugins/DateTime/Calendar/Persian.php
Persian.calculateDate
public function calculateDate($gYear, $gMonth, $gDay) { return $this->getPoirotPersian()->calculateDate($gYear, $gMonth, $gDay); }
php
public function calculateDate($gYear, $gMonth, $gDay) { return $this->getPoirotPersian()->calculateDate($gYear, $gMonth, $gDay); }
[ "public", "function", "calculateDate", "(", "$", "gYear", ",", "$", "gMonth", ",", "$", "gDay", ")", "{", "return", "$", "this", "->", "getPoirotPersian", "(", ")", "->", "calculateDate", "(", "$", "gYear", ",", "$", "gMonth", ",", "$", "gDay", ")", ";", "}" ]
Calculate date to calendar system @param int $gYear Year in gregorian system @param int $gMonth Month in gregorian system @param int $gDay Day in gregorian system @return CalendarInterval|false
[ "Calculate", "date", "to", "calendar", "system" ]
1ea10bd0cedfdad5f45e945ac9833a128712e5e2
https://github.com/YiMAproject/yimaLocalize/blob/1ea10bd0cedfdad5f45e945ac9833a128712e5e2/src/yimaLocalize/LocaliPlugins/DateTime/Calendar/Persian.php#L55-L58
3,649
phossa2/libs
src/Phossa2/Session/Driver/CookieDriver.php
CookieDriver.syncCookies
protected function syncCookies() { foreach ($this->cookies as $name => $id) { if (null === $id) { setcookie($name, '', time() - 3600); } else { setcookie( $name, $id, $this->ttl ? (time() + $this->ttl) : 0, $this->path, $this->domain, $this->secure, $this->httponly ); } } }
php
protected function syncCookies() { foreach ($this->cookies as $name => $id) { if (null === $id) { setcookie($name, '', time() - 3600); } else { setcookie( $name, $id, $this->ttl ? (time() + $this->ttl) : 0, $this->path, $this->domain, $this->secure, $this->httponly ); } } }
[ "protected", "function", "syncCookies", "(", ")", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "name", "=>", "$", "id", ")", "{", "if", "(", "null", "===", "$", "id", ")", "{", "setcookie", "(", "$", "name", ",", "''", ",", "time", "(", ")", "-", "3600", ")", ";", "}", "else", "{", "setcookie", "(", "$", "name", ",", "$", "id", ",", "$", "this", "->", "ttl", "?", "(", "time", "(", ")", "+", "$", "this", "->", "ttl", ")", ":", "0", ",", "$", "this", "->", "path", ",", "$", "this", "->", "domain", ",", "$", "this", "->", "secure", ",", "$", "this", "->", "httponly", ")", ";", "}", "}", "}" ]
Sync session cookies with the client @access protected
[ "Sync", "session", "cookies", "with", "the", "client" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Session/Driver/CookieDriver.php#L118-L135
3,650
gentlero/embeddables
src/Date.php
Date.getDaysInMonth
private function getDaysInMonth(Month $month, Year $year) { return (int)date('t', mktime(0, 0, 0, (string)$month, 1, (string)$year)); }
php
private function getDaysInMonth(Month $month, Year $year) { return (int)date('t', mktime(0, 0, 0, (string)$month, 1, (string)$year)); }
[ "private", "function", "getDaysInMonth", "(", "Month", "$", "month", ",", "Year", "$", "year", ")", "{", "return", "(", "int", ")", "date", "(", "'t'", ",", "mktime", "(", "0", ",", "0", ",", "0", ",", "(", "string", ")", "$", "month", ",", "1", ",", "(", "string", ")", "$", "year", ")", ")", ";", "}" ]
Get number of days in specified month. @access private @param Month $month @param Year $year @return int
[ "Get", "number", "of", "days", "in", "specified", "month", "." ]
69255fa45983106cda4467f502849e9d402408ab
https://github.com/gentlero/embeddables/blob/69255fa45983106cda4467f502849e9d402408ab/src/Date.php#L174-L177
3,651
kevindierkx/elicit
src/ConnectionResolver.php
ConnectionResolver.connection
public function connection($name = null) { if (is_null($name)) { $name = $this->getDefaultConnection(); } if (! isset($this->connections[$name])) { throw new InvalidArgumentException("Connection [{$name}] is not registered."); } return $this->connections[$name]; }
php
public function connection($name = null) { if (is_null($name)) { $name = $this->getDefaultConnection(); } if (! isset($this->connections[$name])) { throw new InvalidArgumentException("Connection [{$name}] is not registered."); } return $this->connections[$name]; }
[ "public", "function", "connection", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getDefaultConnection", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Connection [{$name}] is not registered.\"", ")", ";", "}", "return", "$", "this", "->", "connections", "[", "$", "name", "]", ";", "}" ]
Get an API connection instance. @param string $name @return ConnectionInterface
[ "Get", "an", "API", "connection", "instance", "." ]
c277942f5f5f63b175bc37e9d392faa946888f65
https://github.com/kevindierkx/elicit/blob/c277942f5f5f63b175bc37e9d392faa946888f65/src/ConnectionResolver.php#L42-L53
3,652
petrknap/php-enum
src/Enum.php
Enum.getMembers
public static function getMembers() { $className = static::class; $members = &self::$members[$className]; if (empty($members)) { new $className(null); } return $members; }
php
public static function getMembers() { $className = static::class; $members = &self::$members[$className]; if (empty($members)) { new $className(null); } return $members; }
[ "public", "static", "function", "getMembers", "(", ")", "{", "$", "className", "=", "static", "::", "class", ";", "$", "members", "=", "&", "self", "::", "$", "members", "[", "$", "className", "]", ";", "if", "(", "empty", "(", "$", "members", ")", ")", "{", "new", "$", "className", "(", "null", ")", ";", "}", "return", "$", "members", ";", "}" ]
Returns members of enum NOTE: Can not be merged with non-static {@link members()} due to its inner logic @return mixed[] [first_name => first_value, second_name => second_value,...]
[ "Returns", "members", "of", "enum" ]
f82a50ea7ac6d70a9a325b12783cfbffd36dc175
https://github.com/petrknap/php-enum/blob/f82a50ea7ac6d70a9a325b12783cfbffd36dc175/src/Enum.php#L112-L123
3,653
alfredoem/ragnarok
app/Ragnarok/Soul/RagnarokCurl.php
RagnarokCurl.httpGetRequest
public function httpGetRequest($url) { // create curl resource $curl = curl_init(); // set url curl_setopt($curl, CURLOPT_URL, $url); //return the transfer as a string curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $response = curl_exec($curl); $resolve = $this->curlResponse->resolve($curl, $response); curl_close($curl); return $resolve; }
php
public function httpGetRequest($url) { // create curl resource $curl = curl_init(); // set url curl_setopt($curl, CURLOPT_URL, $url); //return the transfer as a string curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $response = curl_exec($curl); $resolve = $this->curlResponse->resolve($curl, $response); curl_close($curl); return $resolve; }
[ "public", "function", "httpGetRequest", "(", "$", "url", ")", "{", "// create curl resource", "$", "curl", "=", "curl_init", "(", ")", ";", "// set url", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "//return the transfer as a string", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "// $output contains the output string", "$", "response", "=", "curl_exec", "(", "$", "curl", ")", ";", "$", "resolve", "=", "$", "this", "->", "curlResponse", "->", "resolve", "(", "$", "curl", ",", "$", "response", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "return", "$", "resolve", ";", "}" ]
Make a GET HTTP request @param $url @return \Alfredoem\Ragnarok\Soul\RagnarokCurlResponse
[ "Make", "a", "GET", "HTTP", "request" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/RagnarokCurl.php#L22-L41
3,654
alfredoem/ragnarok
app/Ragnarok/Soul/RagnarokCurl.php
RagnarokCurl.httpStatusConnection
public function httpStatusConnection($url) { if ( ! filter_var($url, FILTER_VALIDATE_URL)) {// check, if a valid url is provided return false; } $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);// 301 solved $response = curl_exec($handle); $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); curl_close($handle); return $httpCode == 200 ? true : false; }
php
public function httpStatusConnection($url) { if ( ! filter_var($url, FILTER_VALIDATE_URL)) {// check, if a valid url is provided return false; } $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);// 301 solved $response = curl_exec($handle); $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); curl_close($handle); return $httpCode == 200 ? true : false; }
[ "public", "function", "httpStatusConnection", "(", "$", "url", ")", "{", "if", "(", "!", "filter_var", "(", "$", "url", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "// check, if a valid url is provided", "return", "false", ";", "}", "$", "handle", "=", "curl_init", "(", "$", "url", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "handle", ",", "CURLOPT_FOLLOWLOCATION", ",", "true", ")", ";", "// 301 solved", "$", "response", "=", "curl_exec", "(", "$", "handle", ")", ";", "$", "httpCode", "=", "curl_getinfo", "(", "$", "handle", ",", "CURLINFO_HTTP_CODE", ")", ";", "curl_close", "(", "$", "handle", ")", ";", "return", "$", "httpCode", "==", "200", "?", "true", ":", "false", ";", "}" ]
Check the connection status @param $url @return bool
[ "Check", "the", "connection", "status" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/RagnarokCurl.php#L48-L62
3,655
alfredoem/ragnarok
app/Ragnarok/Soul/RagnarokCurl.php
RagnarokCurl.httpPosRequest
public function httpPosRequest($url, $data) { $enc = EncryptAes::encrypt($data); $dataEncrypt = 'data='.$enc; $dataEncrypt = str_replace('+', '%2B', $dataEncrypt); $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, count($dataEncrypt)); curl_setopt($curl, CURLOPT_POSTFIELDS, $dataEncrypt); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_URL, $url); $response = curl_exec($curl); $resolve = $this->curlResponse->resolve($curl, $response); curl_close($curl); return $resolve; }
php
public function httpPosRequest($url, $data) { $enc = EncryptAes::encrypt($data); $dataEncrypt = 'data='.$enc; $dataEncrypt = str_replace('+', '%2B', $dataEncrypt); $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_POST, count($dataEncrypt)); curl_setopt($curl, CURLOPT_POSTFIELDS, $dataEncrypt); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FAILONERROR, true); curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_URL, $url); $response = curl_exec($curl); $resolve = $this->curlResponse->resolve($curl, $response); curl_close($curl); return $resolve; }
[ "public", "function", "httpPosRequest", "(", "$", "url", ",", "$", "data", ")", "{", "$", "enc", "=", "EncryptAes", "::", "encrypt", "(", "$", "data", ")", ";", "$", "dataEncrypt", "=", "'data='", ".", "$", "enc", ";", "$", "dataEncrypt", "=", "str_replace", "(", "'+'", ",", "'%2B'", ",", "$", "dataEncrypt", ")", ";", "$", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HEADER", ",", "0", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POST", ",", "count", "(", "$", "dataEncrypt", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POSTFIELDS", ",", "$", "dataEncrypt", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_FAILONERROR", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_FRESH_CONNECT", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "$", "response", "=", "curl_exec", "(", "$", "curl", ")", ";", "$", "resolve", "=", "$", "this", "->", "curlResponse", "->", "resolve", "(", "$", "curl", ",", "$", "response", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "return", "$", "resolve", ";", "}" ]
Make a POST HTTP request @param $url @param $data @return \Alfredoem\Ragnarok\Soul\RagnarokCurlResponse
[ "Make", "a", "POST", "HTTP", "request" ]
e7de18cbe7a64e6ce480093d9d98d64078d35dff
https://github.com/alfredoem/ragnarok/blob/e7de18cbe7a64e6ce480093d9d98d64078d35dff/app/Ragnarok/Soul/RagnarokCurl.php#L70-L91
3,656
Flowpack/Flowpack.SingleSignOn.Server
Classes/Flowpack/SingleSignOn/Server/Controller/AccessTokenController.php
AccessTokenController.redeemAction
public function redeemAction($accessToken) { if ($this->request->getHttpRequest()->getMethod() !== 'POST') { $this->response->setStatus(405); $this->response->setHeader('Allow', 'POST'); return; } $accessTokenObject = $this->accessTokenRepository->findByIdentifier($accessToken); if (!$accessTokenObject instanceof AccessToken) { $this->response->setStatus(404); $this->view->assign('value', array('message' => 'Invalid access token')); return; } $sessionId = $accessTokenObject->getSessionId(); $session = $this->sessionManager->getSession($sessionId); if (!$this->sessionIsActive($session)) { $this->response->setStatus(403); $this->view->assign('value', array('message' => 'Session expired')); return; } $this->accessTokenRepository->remove($accessTokenObject); // TODO Move the actual logic of redemption to a service $ssoClient = $accessTokenObject->getSsoClient(); $this->singleSignOnSessionManager->registerSsoClient($session, $ssoClient); // TODO Get the account from the global session // TODO What to do with multiple accounts? $account = $accessTokenObject->getAccount(); $accountData = $this->clientAccountMapper->getAccountData($accessTokenObject->getSsoClient(), $account); if ($this->ssoLogger !== NULL) { $this->ssoLogger->log('Redeemed access token "' . $accessToken . '" from client "' . $ssoClient->getServiceBaseUri() . '" for session "' . $sessionId . '" and account "' . $account->getAccountIdentifier() . '"', LOG_INFO); } $this->response->setStatus(201); $this->view->assign('value', array( 'account' => $accountData, 'sessionId' => $sessionId )); }
php
public function redeemAction($accessToken) { if ($this->request->getHttpRequest()->getMethod() !== 'POST') { $this->response->setStatus(405); $this->response->setHeader('Allow', 'POST'); return; } $accessTokenObject = $this->accessTokenRepository->findByIdentifier($accessToken); if (!$accessTokenObject instanceof AccessToken) { $this->response->setStatus(404); $this->view->assign('value', array('message' => 'Invalid access token')); return; } $sessionId = $accessTokenObject->getSessionId(); $session = $this->sessionManager->getSession($sessionId); if (!$this->sessionIsActive($session)) { $this->response->setStatus(403); $this->view->assign('value', array('message' => 'Session expired')); return; } $this->accessTokenRepository->remove($accessTokenObject); // TODO Move the actual logic of redemption to a service $ssoClient = $accessTokenObject->getSsoClient(); $this->singleSignOnSessionManager->registerSsoClient($session, $ssoClient); // TODO Get the account from the global session // TODO What to do with multiple accounts? $account = $accessTokenObject->getAccount(); $accountData = $this->clientAccountMapper->getAccountData($accessTokenObject->getSsoClient(), $account); if ($this->ssoLogger !== NULL) { $this->ssoLogger->log('Redeemed access token "' . $accessToken . '" from client "' . $ssoClient->getServiceBaseUri() . '" for session "' . $sessionId . '" and account "' . $account->getAccountIdentifier() . '"', LOG_INFO); } $this->response->setStatus(201); $this->view->assign('value', array( 'account' => $accountData, 'sessionId' => $sessionId )); }
[ "public", "function", "redeemAction", "(", "$", "accessToken", ")", "{", "if", "(", "$", "this", "->", "request", "->", "getHttpRequest", "(", ")", "->", "getMethod", "(", ")", "!==", "'POST'", ")", "{", "$", "this", "->", "response", "->", "setStatus", "(", "405", ")", ";", "$", "this", "->", "response", "->", "setHeader", "(", "'Allow'", ",", "'POST'", ")", ";", "return", ";", "}", "$", "accessTokenObject", "=", "$", "this", "->", "accessTokenRepository", "->", "findByIdentifier", "(", "$", "accessToken", ")", ";", "if", "(", "!", "$", "accessTokenObject", "instanceof", "AccessToken", ")", "{", "$", "this", "->", "response", "->", "setStatus", "(", "404", ")", ";", "$", "this", "->", "view", "->", "assign", "(", "'value'", ",", "array", "(", "'message'", "=>", "'Invalid access token'", ")", ")", ";", "return", ";", "}", "$", "sessionId", "=", "$", "accessTokenObject", "->", "getSessionId", "(", ")", ";", "$", "session", "=", "$", "this", "->", "sessionManager", "->", "getSession", "(", "$", "sessionId", ")", ";", "if", "(", "!", "$", "this", "->", "sessionIsActive", "(", "$", "session", ")", ")", "{", "$", "this", "->", "response", "->", "setStatus", "(", "403", ")", ";", "$", "this", "->", "view", "->", "assign", "(", "'value'", ",", "array", "(", "'message'", "=>", "'Session expired'", ")", ")", ";", "return", ";", "}", "$", "this", "->", "accessTokenRepository", "->", "remove", "(", "$", "accessTokenObject", ")", ";", "// TODO Move the actual logic of redemption to a service", "$", "ssoClient", "=", "$", "accessTokenObject", "->", "getSsoClient", "(", ")", ";", "$", "this", "->", "singleSignOnSessionManager", "->", "registerSsoClient", "(", "$", "session", ",", "$", "ssoClient", ")", ";", "// TODO Get the account from the global session", "// TODO What to do with multiple accounts?", "$", "account", "=", "$", "accessTokenObject", "->", "getAccount", "(", ")", ";", "$", "accountData", "=", "$", "this", "->", "clientAccountMapper", "->", "getAccountData", "(", "$", "accessTokenObject", "->", "getSsoClient", "(", ")", ",", "$", "account", ")", ";", "if", "(", "$", "this", "->", "ssoLogger", "!==", "NULL", ")", "{", "$", "this", "->", "ssoLogger", "->", "log", "(", "'Redeemed access token \"'", ".", "$", "accessToken", ".", "'\" from client \"'", ".", "$", "ssoClient", "->", "getServiceBaseUri", "(", ")", ".", "'\" for session \"'", ".", "$", "sessionId", ".", "'\" and account \"'", ".", "$", "account", "->", "getAccountIdentifier", "(", ")", ".", "'\"'", ",", "LOG_INFO", ")", ";", "}", "$", "this", "->", "response", "->", "setStatus", "(", "201", ")", ";", "$", "this", "->", "view", "->", "assign", "(", "'value'", ",", "array", "(", "'account'", "=>", "$", "accountData", ",", "'sessionId'", "=>", "$", "sessionId", ")", ")", ";", "}" ]
Redeem an access token and return global account data for the authenticated account and a global session id. POST token/{accessToken}/redeem?clientSessionId=abc @param string $accessToken
[ "Redeem", "an", "access", "token", "and", "return", "global", "account", "data", "for", "the", "authenticated", "account", "and", "a", "global", "session", "id", "." ]
b1fa014f31d0d101a79cb95d5585b9973f35347d
https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Controller/AccessTokenController.php#L71-L115
3,657
Puzzlout/FrameworkMvcLegacy
src/Dal/Modules/CommonDal.php
CommonDal.GetListOfTablesInDatabase
public function GetListOfTablesInDatabase() { $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::SHOWTABLES, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("SHOW TABLES;"); $this->addDbConfigItem($dbConfig); return $this->BindParametersAndExecute(); }
php
public function GetListOfTablesInDatabase() { $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::SHOWTABLES, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("SHOW TABLES;"); $this->addDbConfigItem($dbConfig); return $this->BindParametersAndExecute(); }
[ "public", "function", "GetListOfTablesInDatabase", "(", ")", "{", "$", "dbConfig", "=", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbStatementConfig", "(", "null", ",", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbExecutionType", "::", "SHOWTABLES", ",", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbQueryFilters", "(", ")", ")", ";", "$", "dbConfig", "->", "setQuery", "(", "\"SHOW TABLES;\"", ")", ";", "$", "this", "->", "addDbConfigItem", "(", "$", "dbConfig", ")", ";", "return", "$", "this", "->", "BindParametersAndExecute", "(", ")", ";", "}" ]
Gets the list of table names in a database. @return array The list of table names.
[ "Gets", "the", "list", "of", "table", "names", "in", "a", "database", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Modules/CommonDal.php#L23-L28
3,658
Puzzlout/FrameworkMvcLegacy
src/Dal/Modules/CommonDal.php
CommonDal.GetTableColumnsMeta
public function GetTableColumnsMeta($tableName, $columnNames) { $tableColumnsMetadata = array(); foreach ($columnNames as $columnName) { $this->setDbConfigList(array()); $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::COLUMNMETAS, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("SHOW COLUMNS FROM `$tableName` WHERE `Field` = '$columnName';"); $this->addDbConfigItem($dbConfig); $tableColumnsMetadata[$columnName] = $this->BindParametersAndExecute(); } return $tableColumnsMetadata; }
php
public function GetTableColumnsMeta($tableName, $columnNames) { $tableColumnsMetadata = array(); foreach ($columnNames as $columnName) { $this->setDbConfigList(array()); $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::COLUMNMETAS, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("SHOW COLUMNS FROM `$tableName` WHERE `Field` = '$columnName';"); $this->addDbConfigItem($dbConfig); $tableColumnsMetadata[$columnName] = $this->BindParametersAndExecute(); } return $tableColumnsMetadata; }
[ "public", "function", "GetTableColumnsMeta", "(", "$", "tableName", ",", "$", "columnNames", ")", "{", "$", "tableColumnsMetadata", "=", "array", "(", ")", ";", "foreach", "(", "$", "columnNames", "as", "$", "columnName", ")", "{", "$", "this", "->", "setDbConfigList", "(", "array", "(", ")", ")", ";", "$", "dbConfig", "=", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbStatementConfig", "(", "null", ",", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbExecutionType", "::", "COLUMNMETAS", ",", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbQueryFilters", "(", ")", ")", ";", "$", "dbConfig", "->", "setQuery", "(", "\"SHOW COLUMNS FROM `$tableName` WHERE `Field` = '$columnName';\"", ")", ";", "$", "this", "->", "addDbConfigItem", "(", "$", "dbConfig", ")", ";", "$", "tableColumnsMetadata", "[", "$", "columnName", "]", "=", "$", "this", "->", "BindParametersAndExecute", "(", ")", ";", "}", "return", "$", "tableColumnsMetadata", ";", "}" ]
Gets the list of column metadata for a table. @param type $tableName The table name. @param type $columnNames The array of columns. @return array The associative array of the metadata of the table columns.
[ "Gets", "the", "list", "of", "column", "metadata", "for", "a", "table", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Modules/CommonDal.php#L37-L47
3,659
Puzzlout/FrameworkMvcLegacy
src/Dal/Modules/CommonDal.php
CommonDal.GetTableColumnNames
public function GetTableColumnNames($tableName) { $this->setDbConfigList(array()); $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::COLUMNNAMES, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("DESCRIBE `$tableName`;"); $this->addDbConfigItem($dbConfig); return $this->BindParametersAndExecute(); }
php
public function GetTableColumnNames($tableName) { $this->setDbConfigList(array()); $dbConfig = new \Puzzlout\Framework\Dal\DbStatementConfig(null, \Puzzlout\Framework\Dal\DbExecutionType::COLUMNNAMES, new \Puzzlout\Framework\Dal\DbQueryFilters()); $dbConfig->setQuery("DESCRIBE `$tableName`;"); $this->addDbConfigItem($dbConfig); return $this->BindParametersAndExecute(); }
[ "public", "function", "GetTableColumnNames", "(", "$", "tableName", ")", "{", "$", "this", "->", "setDbConfigList", "(", "array", "(", ")", ")", ";", "$", "dbConfig", "=", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbStatementConfig", "(", "null", ",", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbExecutionType", "::", "COLUMNNAMES", ",", "new", "\\", "Puzzlout", "\\", "Framework", "\\", "Dal", "\\", "DbQueryFilters", "(", ")", ")", ";", "$", "dbConfig", "->", "setQuery", "(", "\"DESCRIBE `$tableName`;\"", ")", ";", "$", "this", "->", "addDbConfigItem", "(", "$", "dbConfig", ")", ";", "return", "$", "this", "->", "BindParametersAndExecute", "(", ")", ";", "}" ]
Gets the column names for a table. @param type $tableName The table name @return array The list of column names for a table.
[ "Gets", "the", "column", "names", "for", "a", "table", "." ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Dal/Modules/CommonDal.php#L55-L61
3,660
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
DocumentPersister.prepareSortOrProjection
public function prepareSortOrProjection(array $fields) { $preparedFields = array(); foreach ($fields as $key => $value) { $preparedFields[$this->prepareFieldName($key)] = $value; } return $preparedFields; }
php
public function prepareSortOrProjection(array $fields) { $preparedFields = array(); foreach ($fields as $key => $value) { $preparedFields[$this->prepareFieldName($key)] = $value; } return $preparedFields; }
[ "public", "function", "prepareSortOrProjection", "(", "array", "$", "fields", ")", "{", "$", "preparedFields", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "preparedFields", "[", "$", "this", "->", "prepareFieldName", "(", "$", "key", ")", "]", "=", "$", "value", ";", "}", "return", "$", "preparedFields", ";", "}" ]
Prepare a sort or projection array by converting keys, which are PHP property names, to MongoDB field names. @param array $fields @return array
[ "Prepare", "a", "sort", "or", "projection", "array", "by", "converting", "keys", "which", "are", "PHP", "property", "names", "to", "MongoDB", "field", "names", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php#L818-L827
3,661
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
DocumentPersister.addFilterToPreparedQuery
public function addFilterToPreparedQuery(array $preparedQuery) { /* If filter criteria exists for this class, prepare it and merge * over the existing query. * * @todo Consider recursive merging in case the filter criteria and * prepared query both contain top-level $and/$or operators. */ if ($filterCriteria = $this->dm->getFilterCollection()->getFilterCriteria($this->class)) { $preparedQuery = $this->cm->merge($preparedQuery, $this->prepareQueryOrNewObj($filterCriteria)); } return $preparedQuery; }
php
public function addFilterToPreparedQuery(array $preparedQuery) { /* If filter criteria exists for this class, prepare it and merge * over the existing query. * * @todo Consider recursive merging in case the filter criteria and * prepared query both contain top-level $and/$or operators. */ if ($filterCriteria = $this->dm->getFilterCollection()->getFilterCriteria($this->class)) { $preparedQuery = $this->cm->merge($preparedQuery, $this->prepareQueryOrNewObj($filterCriteria)); } return $preparedQuery; }
[ "public", "function", "addFilterToPreparedQuery", "(", "array", "$", "preparedQuery", ")", "{", "/* If filter criteria exists for this class, prepare it and merge\n * over the existing query.\n *\n * @todo Consider recursive merging in case the filter criteria and\n * prepared query both contain top-level $and/$or operators.\n */", "if", "(", "$", "filterCriteria", "=", "$", "this", "->", "dm", "->", "getFilterCollection", "(", ")", "->", "getFilterCriteria", "(", "$", "this", "->", "class", ")", ")", "{", "$", "preparedQuery", "=", "$", "this", "->", "cm", "->", "merge", "(", "$", "preparedQuery", ",", "$", "this", "->", "prepareQueryOrNewObj", "(", "$", "filterCriteria", ")", ")", ";", "}", "return", "$", "preparedQuery", ";", "}" ]
Adds filter criteria to an already-prepared query. This method should be used once for query criteria and not be used for nested expressions. It should be called after {@link DocumentPerister::addDiscriminatorToPreparedQuery()}. @param array $preparedQuery @return array
[ "Adds", "filter", "criteria", "to", "an", "already", "-", "prepared", "query", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php#L875-L888
3,662
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
DocumentPersister.getClassDiscriminatorValues
private function getClassDiscriminatorValues(ClassMetadata $metadata) { $discriminatorValues = array($metadata->discriminatorValue); foreach ($metadata->subClasses as $className) { if ($key = array_search($className, $metadata->discriminatorMap)) { $discriminatorValues[] = $key; } } return $discriminatorValues; }
php
private function getClassDiscriminatorValues(ClassMetadata $metadata) { $discriminatorValues = array($metadata->discriminatorValue); foreach ($metadata->subClasses as $className) { if ($key = array_search($className, $metadata->discriminatorMap)) { $discriminatorValues[] = $key; } } return $discriminatorValues; }
[ "private", "function", "getClassDiscriminatorValues", "(", "ClassMetadata", "$", "metadata", ")", "{", "$", "discriminatorValues", "=", "array", "(", "$", "metadata", "->", "discriminatorValue", ")", ";", "foreach", "(", "$", "metadata", "->", "subClasses", "as", "$", "className", ")", "{", "if", "(", "$", "key", "=", "array_search", "(", "$", "className", ",", "$", "metadata", "->", "discriminatorMap", ")", ")", "{", "$", "discriminatorValues", "[", "]", "=", "$", "key", ";", "}", "}", "return", "$", "discriminatorValues", ";", "}" ]
Gets the array of discriminator values for the given ClassMetadata @param ClassMetadata $metadata @return array
[ "Gets", "the", "array", "of", "discriminator", "values", "for", "the", "given", "ClassMetadata" ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php#L1207-L1216
3,663
Briareos/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php
DocumentPersister.guardMissingShardKey
private function guardMissingShardKey($document, $shardKeyField, $actualDocumentData) { $dcs = $this->uow->getDocumentChangeSet($document); $isUpdate = $this->uow->isScheduledForUpdate($document); $fieldMapping = $this->class->getFieldMappingByDbFieldName($shardKeyField); $fieldName = $fieldMapping['fieldName']; if ($isUpdate && isset($dcs[$fieldName]) && isset($dcs[$fieldName][0]) && $dcs[$fieldName][0] != $dcs[$fieldName][1]) { throw MongoDBException::shardKeyFieldCannotBeChanged($shardKeyField, $this->class->getName(), $dcs); } if (!isset($actualDocumentData[$fieldName])) { throw MongoDBException::shardKeyFieldMissing($shardKeyField, $this->class->getName()); } }
php
private function guardMissingShardKey($document, $shardKeyField, $actualDocumentData) { $dcs = $this->uow->getDocumentChangeSet($document); $isUpdate = $this->uow->isScheduledForUpdate($document); $fieldMapping = $this->class->getFieldMappingByDbFieldName($shardKeyField); $fieldName = $fieldMapping['fieldName']; if ($isUpdate && isset($dcs[$fieldName]) && isset($dcs[$fieldName][0]) && $dcs[$fieldName][0] != $dcs[$fieldName][1]) { throw MongoDBException::shardKeyFieldCannotBeChanged($shardKeyField, $this->class->getName(), $dcs); } if (!isset($actualDocumentData[$fieldName])) { throw MongoDBException::shardKeyFieldMissing($shardKeyField, $this->class->getName()); } }
[ "private", "function", "guardMissingShardKey", "(", "$", "document", ",", "$", "shardKeyField", ",", "$", "actualDocumentData", ")", "{", "$", "dcs", "=", "$", "this", "->", "uow", "->", "getDocumentChangeSet", "(", "$", "document", ")", ";", "$", "isUpdate", "=", "$", "this", "->", "uow", "->", "isScheduledForUpdate", "(", "$", "document", ")", ";", "$", "fieldMapping", "=", "$", "this", "->", "class", "->", "getFieldMappingByDbFieldName", "(", "$", "shardKeyField", ")", ";", "$", "fieldName", "=", "$", "fieldMapping", "[", "'fieldName'", "]", ";", "if", "(", "$", "isUpdate", "&&", "isset", "(", "$", "dcs", "[", "$", "fieldName", "]", ")", "&&", "isset", "(", "$", "dcs", "[", "$", "fieldName", "]", "[", "0", "]", ")", "&&", "$", "dcs", "[", "$", "fieldName", "]", "[", "0", "]", "!=", "$", "dcs", "[", "$", "fieldName", "]", "[", "1", "]", ")", "{", "throw", "MongoDBException", "::", "shardKeyFieldCannotBeChanged", "(", "$", "shardKeyField", ",", "$", "this", "->", "class", "->", "getName", "(", ")", ",", "$", "dcs", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "actualDocumentData", "[", "$", "fieldName", "]", ")", ")", "{", "throw", "MongoDBException", "::", "shardKeyFieldMissing", "(", "$", "shardKeyField", ",", "$", "this", "->", "class", "->", "getName", "(", ")", ")", ";", "}", "}" ]
If the document is new, ignore shard key field value, otherwise throw an exception. Also, shard key field should be presented in actual document data. @param object $document @param string $shardKeyField @param array $actualDocumentData @throws MongoDBException
[ "If", "the", "document", "is", "new", "ignore", "shard", "key", "field", "value", "otherwise", "throw", "an", "exception", ".", "Also", "shard", "key", "field", "should", "be", "presented", "in", "actual", "document", "data", "." ]
29e28bed9a265efd7d05473b0a909fb7c83f76e0
https://github.com/Briareos/mongodb-odm/blob/29e28bed9a265efd7d05473b0a909fb7c83f76e0/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php#L1228-L1243
3,664
FrenzelGmbH/appcommon
nlpclassifier/EndOfSentence.php
EndOfSentence.classify
public function classify(array $classes, DocumentInterface $d) { list($token,$before,$after) = $d->getDocumentData(); $dotcnt = count(explode('.',$token))-1; $lastdot = substr($token,-1)=='.' OR substr($token,-1)=='?' OR substr($token,-1)=='!'; if (!$lastdot) // assume that all sentences end in full stops return 'O'; if ($dotcnt>1 && $dotcnt <3) // to catch some naive abbreviations U.S.A. return 'O'; return 'EOW'; }
php
public function classify(array $classes, DocumentInterface $d) { list($token,$before,$after) = $d->getDocumentData(); $dotcnt = count(explode('.',$token))-1; $lastdot = substr($token,-1)=='.' OR substr($token,-1)=='?' OR substr($token,-1)=='!'; if (!$lastdot) // assume that all sentences end in full stops return 'O'; if ($dotcnt>1 && $dotcnt <3) // to catch some naive abbreviations U.S.A. return 'O'; return 'EOW'; }
[ "public", "function", "classify", "(", "array", "$", "classes", ",", "DocumentInterface", "$", "d", ")", "{", "list", "(", "$", "token", ",", "$", "before", ",", "$", "after", ")", "=", "$", "d", "->", "getDocumentData", "(", ")", ";", "$", "dotcnt", "=", "count", "(", "explode", "(", "'.'", ",", "$", "token", ")", ")", "-", "1", ";", "$", "lastdot", "=", "substr", "(", "$", "token", ",", "-", "1", ")", "==", "'.'", "OR", "substr", "(", "$", "token", ",", "-", "1", ")", "==", "'?'", "OR", "substr", "(", "$", "token", ",", "-", "1", ")", "==", "'!'", ";", "if", "(", "!", "$", "lastdot", ")", "// assume that all sentences end in full stops", "return", "'O'", ";", "if", "(", "$", "dotcnt", ">", "1", "&&", "$", "dotcnt", "<", "3", ")", "// to catch some naive abbreviations U.S.A.", "return", "'O'", ";", "return", "'EOW'", ";", "}" ]
Splits up a certain text into a sentence array @param array $classes [description] @param Document $d [description] @return [type] [description]
[ "Splits", "up", "a", "certain", "text", "into", "a", "sentence", "array" ]
d6d137b4c92b53832ce4b2e517644ed9fb545b7a
https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/nlpclassifier/EndOfSentence.php#L16-L29
3,665
emhar/SearchDoctrineBundle
Mapping/MappingException.php
MappingException.invalidMappingType
public static function invalidMappingType($itemClass, $attributeName, $type, $ownerName = null) { return new self('The mapping attribute "' . $attributeName . (isset($ownerName) ? ' of "' . $ownerName . '"' : '') . ' is not a valid "' . $type . '" in "' . $itemClass . '".' ); }
php
public static function invalidMappingType($itemClass, $attributeName, $type, $ownerName = null) { return new self('The mapping attribute "' . $attributeName . (isset($ownerName) ? ' of "' . $ownerName . '"' : '') . ' is not a valid "' . $type . '" in "' . $itemClass . '".' ); }
[ "public", "static", "function", "invalidMappingType", "(", "$", "itemClass", ",", "$", "attributeName", ",", "$", "type", ",", "$", "ownerName", "=", "null", ")", "{", "return", "new", "self", "(", "'The mapping attribute \"'", ".", "$", "attributeName", ".", "(", "isset", "(", "$", "ownerName", ")", "?", "' of \"'", ".", "$", "ownerName", ".", "'\"'", ":", "''", ")", ".", "' is not a valid \"'", ".", "$", "type", ".", "'\" in \"'", ".", "$", "itemClass", ".", "'\".'", ")", ";", "}" ]
Return MappingException with invalid type mapping message @param string $itemClass @param string $attributeName @param string $type @param string $ownerName @return MappingException
[ "Return", "MappingException", "with", "invalid", "type", "mapping", "message" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/MappingException.php#L22-L28
3,666
emhar/SearchDoctrineBundle
Mapping/MappingException.php
MappingException.requiredMapping
public static function requiredMapping($itemClass, $attributeName, $ownerName = null) { return new self('The mapping attribute "' . $attributeName . '"' . (isset($ownerName) ? ' of "' . $ownerName . '"' : '') . ' is required in "' . $itemClass . '".' ); }
php
public static function requiredMapping($itemClass, $attributeName, $ownerName = null) { return new self('The mapping attribute "' . $attributeName . '"' . (isset($ownerName) ? ' of "' . $ownerName . '"' : '') . ' is required in "' . $itemClass . '".' ); }
[ "public", "static", "function", "requiredMapping", "(", "$", "itemClass", ",", "$", "attributeName", ",", "$", "ownerName", "=", "null", ")", "{", "return", "new", "self", "(", "'The mapping attribute \"'", ".", "$", "attributeName", ".", "'\"'", ".", "(", "isset", "(", "$", "ownerName", ")", "?", "' of \"'", ".", "$", "ownerName", ".", "'\"'", ":", "''", ")", ".", "' is required in \"'", ".", "$", "itemClass", ".", "'\".'", ")", ";", "}" ]
Return MappingException with required mapping message @param string $itemClass @param string $attributeName @param string $ownerName @return MappingException
[ "Return", "MappingException", "with", "required", "mapping", "message" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/MappingException.php#L38-L44
3,667
slickframework/filter
src/StaticFilter.php
StaticFilter.filter
public static function filter($alias, $value) { $filter = self::create($alias); return $filter->filter($value); }
php
public static function filter($alias, $value) { $filter = self::create($alias); return $filter->filter($value); }
[ "public", "static", "function", "filter", "(", "$", "alias", ",", "$", "value", ")", "{", "$", "filter", "=", "self", "::", "create", "(", "$", "alias", ")", ";", "return", "$", "filter", "->", "filter", "(", "$", "value", ")", ";", "}" ]
Creates the filter in the alias or class name and applies it to the provided value. @param string $alias Filter alias or FQ class name @param mixed $value Value to filter @throws InvalidArgumentException If the class does not exists or if class does not implements the FilterInterface. @return mixed
[ "Creates", "the", "filter", "in", "the", "alias", "or", "class", "name", "and", "applies", "it", "to", "the", "provided", "value", "." ]
535eaec933623e921b974af6470e92104572fe60
https://github.com/slickframework/filter/blob/535eaec933623e921b974af6470e92104572fe60/src/StaticFilter.php#L45-L49
3,668
slickframework/filter
src/StaticFilter.php
StaticFilter.getClass
protected static function getClass($alias) { if (array_key_exists($alias, self::$filters)) { return self::$filters[$alias]; } if (!class_exists($alias)) { throw new InvalidArgumentException( "Class {$alias} does not exists." ); } return $alias; }
php
protected static function getClass($alias) { if (array_key_exists($alias, self::$filters)) { return self::$filters[$alias]; } if (!class_exists($alias)) { throw new InvalidArgumentException( "Class {$alias} does not exists." ); } return $alias; }
[ "protected", "static", "function", "getClass", "(", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "self", "::", "$", "filters", ")", ")", "{", "return", "self", "::", "$", "filters", "[", "$", "alias", "]", ";", "}", "if", "(", "!", "class_exists", "(", "$", "alias", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Class {$alias} does not exists.\"", ")", ";", "}", "return", "$", "alias", ";", "}" ]
Returns the class name for provided alias @param string $alias The FQ class name or one of known filter alias @return string @throws InvalidArgumentException If the class does not exists.
[ "Returns", "the", "class", "name", "for", "provided", "alias" ]
535eaec933623e921b974af6470e92104572fe60
https://github.com/slickframework/filter/blob/535eaec933623e921b974af6470e92104572fe60/src/StaticFilter.php#L76-L88
3,669
codebobbly/dvoconnector
Classes/Service/GenericApiService.php
GenericApiService.queryXml
protected function queryXml($apiUrl, $apiServiceFilter = null) { $useCache = self::$useCache; if ($apiServiceFilter) { $url = $apiUrl . $apiServiceFilter->getURLQuery(); } else { $url = $apiUrl; } // no cache, so query from server if (!$useCache || $this->cacheManager->has(md5($url)) == false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // additional headers $headers = [ 'User-Agent: ' . \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getHttpUserAgent(), ]; if (!$useCache) { $headers[] = 'Cache-Control: no-cache'; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); // separate response into header and body list($header, $body) = explode("\r\n\r\n", $response, 2); // check for response-code 200 $headers = explode("\r\n", $header); $responseCode = preg_replace('/HTTP\/.* ([0-9]+) .*/', '${1}', $headers[0]); if ($responseCode{0} != '2') { throw new \Exception('Unexpected HTTP response code: ' . $responseCode . '|' . $url); } // caching if (!preg_match('/.*Cache-Control: .*no-cache.*/sm', $header)) { // check for Cache-Control max-age param $maxAge = preg_replace('/.*Cache-Control: .*max-age=(\d+).*/sm', '${1}', $header); // cache response $this->writeCache(md5($url), $body, ($maxAge == '') ? \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getCachetime() : (int)$maxAge); } } elseif ($useCache && $this->cacheManager->has(md5($url)) == true) { $body = $this->readCache(md5($url)); } try { $xml = new \SimpleXMLElement($body); } catch (\Exception $e) { throw $e; } return $xml; }
php
protected function queryXml($apiUrl, $apiServiceFilter = null) { $useCache = self::$useCache; if ($apiServiceFilter) { $url = $apiUrl . $apiServiceFilter->getURLQuery(); } else { $url = $apiUrl; } // no cache, so query from server if (!$useCache || $this->cacheManager->has(md5($url)) == false) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // additional headers $headers = [ 'User-Agent: ' . \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getHttpUserAgent(), ]; if (!$useCache) { $headers[] = 'Cache-Control: no-cache'; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); // separate response into header and body list($header, $body) = explode("\r\n\r\n", $response, 2); // check for response-code 200 $headers = explode("\r\n", $header); $responseCode = preg_replace('/HTTP\/.* ([0-9]+) .*/', '${1}', $headers[0]); if ($responseCode{0} != '2') { throw new \Exception('Unexpected HTTP response code: ' . $responseCode . '|' . $url); } // caching if (!preg_match('/.*Cache-Control: .*no-cache.*/sm', $header)) { // check for Cache-Control max-age param $maxAge = preg_replace('/.*Cache-Control: .*max-age=(\d+).*/sm', '${1}', $header); // cache response $this->writeCache(md5($url), $body, ($maxAge == '') ? \RGU\Dvoconnector\Utility\EmConfiguration::getSettings()->getCachetime() : (int)$maxAge); } } elseif ($useCache && $this->cacheManager->has(md5($url)) == true) { $body = $this->readCache(md5($url)); } try { $xml = new \SimpleXMLElement($body); } catch (\Exception $e) { throw $e; } return $xml; }
[ "protected", "function", "queryXml", "(", "$", "apiUrl", ",", "$", "apiServiceFilter", "=", "null", ")", "{", "$", "useCache", "=", "self", "::", "$", "useCache", ";", "if", "(", "$", "apiServiceFilter", ")", "{", "$", "url", "=", "$", "apiUrl", ".", "$", "apiServiceFilter", "->", "getURLQuery", "(", ")", ";", "}", "else", "{", "$", "url", "=", "$", "apiUrl", ";", "}", "// no cache, so query from server", "if", "(", "!", "$", "useCache", "||", "$", "this", "->", "cacheManager", "->", "has", "(", "md5", "(", "$", "url", ")", ")", "==", "false", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HEADER", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "// additional headers", "$", "headers", "=", "[", "'User-Agent: '", ".", "\\", "RGU", "\\", "Dvoconnector", "\\", "Utility", "\\", "EmConfiguration", "::", "getSettings", "(", ")", "->", "getHttpUserAgent", "(", ")", ",", "]", ";", "if", "(", "!", "$", "useCache", ")", "{", "$", "headers", "[", "]", "=", "'Cache-Control: no-cache'", ";", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "$", "response", "=", "curl_exec", "(", "$", "ch", ")", ";", "// separate response into header and body", "list", "(", "$", "header", ",", "$", "body", ")", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "response", ",", "2", ")", ";", "// check for response-code 200", "$", "headers", "=", "explode", "(", "\"\\r\\n\"", ",", "$", "header", ")", ";", "$", "responseCode", "=", "preg_replace", "(", "'/HTTP\\/.* ([0-9]+) .*/'", ",", "'${1}'", ",", "$", "headers", "[", "0", "]", ")", ";", "if", "(", "$", "responseCode", "{", "0", "}", "!=", "'2'", ")", "{", "throw", "new", "\\", "Exception", "(", "'Unexpected HTTP response code: '", ".", "$", "responseCode", ".", "'|'", ".", "$", "url", ")", ";", "}", "// caching", "if", "(", "!", "preg_match", "(", "'/.*Cache-Control: .*no-cache.*/sm'", ",", "$", "header", ")", ")", "{", "// check for Cache-Control max-age param", "$", "maxAge", "=", "preg_replace", "(", "'/.*Cache-Control: .*max-age=(\\d+).*/sm'", ",", "'${1}'", ",", "$", "header", ")", ";", "// cache response", "$", "this", "->", "writeCache", "(", "md5", "(", "$", "url", ")", ",", "$", "body", ",", "(", "$", "maxAge", "==", "''", ")", "?", "\\", "RGU", "\\", "Dvoconnector", "\\", "Utility", "\\", "EmConfiguration", "::", "getSettings", "(", ")", "->", "getCachetime", "(", ")", ":", "(", "int", ")", "$", "maxAge", ")", ";", "}", "}", "elseif", "(", "$", "useCache", "&&", "$", "this", "->", "cacheManager", "->", "has", "(", "md5", "(", "$", "url", ")", ")", "==", "true", ")", "{", "$", "body", "=", "$", "this", "->", "readCache", "(", "md5", "(", "$", "url", ")", ")", ";", "}", "try", "{", "$", "xml", "=", "new", "\\", "SimpleXMLElement", "(", "$", "body", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "return", "$", "xml", ";", "}" ]
Queries XML data from server or cache @param string API URL @param \RGU\Dvoconnector\Service\ApiServiceFilter $apiServiceFilter @return object \SimpleXMLElement
[ "Queries", "XML", "data", "from", "server", "or", "cache" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/GenericApiService.php#L56-L113
3,670
codebobbly/dvoconnector
Classes/Service/GenericApiService.php
GenericApiService.writeCache
protected function writeCache($key, &$data, $lifetime) { $this->cacheManager->set($key, $data, [], $lifetime); }
php
protected function writeCache($key, &$data, $lifetime) { $this->cacheManager->set($key, $data, [], $lifetime); }
[ "protected", "function", "writeCache", "(", "$", "key", ",", "&", "$", "data", ",", "$", "lifetime", ")", "{", "$", "this", "->", "cacheManager", "->", "set", "(", "$", "key", ",", "$", "data", ",", "[", "]", ",", "$", "lifetime", ")", ";", "}" ]
Caches the HTTP response body into database @param string $key A unique key for storing the data, e.g. request URI @param string $data The data itself, e.g. XML data @param int $lifetime How long the entry should be valid
[ "Caches", "the", "HTTP", "response", "body", "into", "database" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/GenericApiService.php#L122-L125
3,671
marando/phpSOFA
src/Marando/IAU/iauGd2gce.php
iauGd2gce.Gd2gce
public static function Gd2gce($a, $f, $elong, $phi, $height, array &$xyz) { $sp; $cp; $w; $d; $ac; $as; $r; /* Functions of geodetic latitude. */ $sp = sin($phi); $cp = cos($phi); $w = 1.0 - $f; $w = $w * $w; $d = $cp * $cp + $w * $sp * $sp; if ($d <= 0.0) return -1; $ac = $a / sqrt($d); $as = $w * $ac; /* Geocentric vector. */ $r = ($ac + $height) * $cp; $xyz[0] = $r * cos($elong); $xyz[1] = $r * sin($elong); $xyz[2] = ($as + $height) * $sp; /* Success. */ return 0; }
php
public static function Gd2gce($a, $f, $elong, $phi, $height, array &$xyz) { $sp; $cp; $w; $d; $ac; $as; $r; /* Functions of geodetic latitude. */ $sp = sin($phi); $cp = cos($phi); $w = 1.0 - $f; $w = $w * $w; $d = $cp * $cp + $w * $sp * $sp; if ($d <= 0.0) return -1; $ac = $a / sqrt($d); $as = $w * $ac; /* Geocentric vector. */ $r = ($ac + $height) * $cp; $xyz[0] = $r * cos($elong); $xyz[1] = $r * sin($elong); $xyz[2] = ($as + $height) * $sp; /* Success. */ return 0; }
[ "public", "static", "function", "Gd2gce", "(", "$", "a", ",", "$", "f", ",", "$", "elong", ",", "$", "phi", ",", "$", "height", ",", "array", "&", "$", "xyz", ")", "{", "$", "sp", ";", "$", "cp", ";", "$", "w", ";", "$", "d", ";", "$", "ac", ";", "$", "as", ";", "$", "r", ";", "/* Functions of geodetic latitude. */", "$", "sp", "=", "sin", "(", "$", "phi", ")", ";", "$", "cp", "=", "cos", "(", "$", "phi", ")", ";", "$", "w", "=", "1.0", "-", "$", "f", ";", "$", "w", "=", "$", "w", "*", "$", "w", ";", "$", "d", "=", "$", "cp", "*", "$", "cp", "+", "$", "w", "*", "$", "sp", "*", "$", "sp", ";", "if", "(", "$", "d", "<=", "0.0", ")", "return", "-", "1", ";", "$", "ac", "=", "$", "a", "/", "sqrt", "(", "$", "d", ")", ";", "$", "as", "=", "$", "w", "*", "$", "ac", ";", "/* Geocentric vector. */", "$", "r", "=", "(", "$", "ac", "+", "$", "height", ")", "*", "$", "cp", ";", "$", "xyz", "[", "0", "]", "=", "$", "r", "*", "cos", "(", "$", "elong", ")", ";", "$", "xyz", "[", "1", "]", "=", "$", "r", "*", "sin", "(", "$", "elong", ")", ";", "$", "xyz", "[", "2", "]", "=", "(", "$", "as", "+", "$", "height", ")", "*", "$", "sp", ";", "/* Success. */", "return", "0", ";", "}" ]
- - - - - - - - - - i a u G d 2 g c e - - - - - - - - - - Transform geodetic coordinates to geocentric for a reference ellipsoid of specified form. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: a double equatorial radius (Notes 1,4) f double flattening (Notes 2,4) elong double longitude (radians, east +ve) phi double latitude (geodetic, radians, Note 4) height double height above ellipsoid (geodetic, Notes 3,4) Returned: xyz double[3] geocentric vector (Note 3) Returned (function value): int status: 0 = OK -1 = illegal case (Note 4) Notes: 1) The equatorial radius, a, can be in any units, but meters is the conventional choice. 2) The flattening, f, is (for the Earth) a value around 0.00335, i.e. around 1/298. 3) The equatorial radius, a, and the height, height, must be given in the same units, and determine the units of the returned geocentric vector, xyz. 4) No validation is performed on individual arguments. The error status -1 protects against (unrealistic) cases that would lead to arithmetic exceptions. If an error occurs, xyz is unchanged. 5) The inverse transformation is performed in the function iauGc2gde. 6) The transformation for a standard ellipsoid (such as WGS84) can more conveniently be performed by calling iauGd2gc, which uses a numerical code to identify the required a and f values. References: Green, R.M., Spherical Astronomy, Cambridge University Press, (1985) Section 4.5, p96. Explanatory Supplement to the Astronomical Almanac, P. Kenneth Seidelmann (ed), University Science Books (1992), Section 4.22, p202. This revision: 2013 June 18 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "i", "a", "u", "G", "d", "2", "g", "c", "e", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGd2gce.php#L71-L99
3,672
devbr/pack-blog
Model/Base.php
Base.checkLink
function checkLink($link, $id) { $result = $this->db->query('SELECT link FROM '.$this->articleTable.' WHERE link = :link AND id != :id', [':link'=>$link, ':id'=>0+$id]); if (isset($result[0])) { return $result[0]->get('link'); } $this->db->query('UPDATE '.$this->articleTable.' SET link = :link WHERE id = :id', [':link'=>$link, ':id'=>0+$id]); return false; }
php
function checkLink($link, $id) { $result = $this->db->query('SELECT link FROM '.$this->articleTable.' WHERE link = :link AND id != :id', [':link'=>$link, ':id'=>0+$id]); if (isset($result[0])) { return $result[0]->get('link'); } $this->db->query('UPDATE '.$this->articleTable.' SET link = :link WHERE id = :id', [':link'=>$link, ':id'=>0+$id]); return false; }
[ "function", "checkLink", "(", "$", "link", ",", "$", "id", ")", "{", "$", "result", "=", "$", "this", "->", "db", "->", "query", "(", "'SELECT link \n FROM '", ".", "$", "this", "->", "articleTable", ".", "' \n WHERE link = :link \n AND id != :id'", ",", "[", "':link'", "=>", "$", "link", ",", "':id'", "=>", "0", "+", "$", "id", "]", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "0", "]", ")", ")", "{", "return", "$", "result", "[", "0", "]", "->", "get", "(", "'link'", ")", ";", "}", "$", "this", "->", "db", "->", "query", "(", "'UPDATE '", ".", "$", "this", "->", "articleTable", ".", "'\n SET link = :link\n WHERE id = :id'", ",", "[", "':link'", "=>", "$", "link", ",", "':id'", "=>", "0", "+", "$", "id", "]", ")", ";", "return", "false", ";", "}" ]
Check link and if ID is diferent @param [type] $link [description] @param [type] $id [description] @return [type] [description]
[ "Check", "link", "and", "if", "ID", "is", "diferent" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Base.php#L79-L99
3,673
devbr/pack-blog
Model/Base.php
Base.getCategory
function getCategory($id) { $result = $this->db->query('SELECT * FROM category WHERE id = :id', [':id'=>(0+$id)]); if (isset($result[0])) { return ['name'=>$result[0]->get('name'), 'description'=>$result[0]->get('description')]; } return false; }
php
function getCategory($id) { $result = $this->db->query('SELECT * FROM category WHERE id = :id', [':id'=>(0+$id)]); if (isset($result[0])) { return ['name'=>$result[0]->get('name'), 'description'=>$result[0]->get('description')]; } return false; }
[ "function", "getCategory", "(", "$", "id", ")", "{", "$", "result", "=", "$", "this", "->", "db", "->", "query", "(", "'SELECT * FROM category WHERE id = :id'", ",", "[", "':id'", "=>", "(", "0", "+", "$", "id", ")", "]", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "0", "]", ")", ")", "{", "return", "[", "'name'", "=>", "$", "result", "[", "0", "]", "->", "get", "(", "'name'", ")", ",", "'description'", "=>", "$", "result", "[", "0", "]", "->", "get", "(", "'description'", ")", "]", ";", "}", "return", "false", ";", "}" ]
Get Category by id @param integer $id Id for category @return bool|array Array of the name and description or false
[ "Get", "Category", "by", "id" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Base.php#L124-L132
3,674
devbr/pack-blog
Model/Base.php
Base.comList
private function comList($result) { foreach ($result as $res) { $data[$res->get('id')]['title'] = $res->get('title'); $data[$res->get('id')]['resume'] = $res->get('resume'); $data[$res->get('id')]['author'] = $res->get('author'); $data[$res->get('id')]['autor'] = $res->get('autor'); $data[$res->get('id')]['category'] = $res->get('category'); $data[$res->get('id')]['categoria'] = $res->get('categoria'); $data[$res->get('id')]['link'] = $res->get('link'); $data[$res->get('id')]['pubdate'] = $res->get('pubdate'); //$data[$res->get('id')]['image'] = ['type'=>'picture', 'src'=>'/media/blog.png']; $media = json_decode($res->get('media')); foreach ($media as $img) { if (isset($img->type) && $img->type == 'image') { $data[$res->get('id')]['image'] = '/media/article/'.$res->get('id').'/mini_'.basename($img->src); break; } if (isset($img->type) && $img->type == 'video') { $data[$res->get('id')]['image'] = '/media/v.png'; } } } return $data; }
php
private function comList($result) { foreach ($result as $res) { $data[$res->get('id')]['title'] = $res->get('title'); $data[$res->get('id')]['resume'] = $res->get('resume'); $data[$res->get('id')]['author'] = $res->get('author'); $data[$res->get('id')]['autor'] = $res->get('autor'); $data[$res->get('id')]['category'] = $res->get('category'); $data[$res->get('id')]['categoria'] = $res->get('categoria'); $data[$res->get('id')]['link'] = $res->get('link'); $data[$res->get('id')]['pubdate'] = $res->get('pubdate'); //$data[$res->get('id')]['image'] = ['type'=>'picture', 'src'=>'/media/blog.png']; $media = json_decode($res->get('media')); foreach ($media as $img) { if (isset($img->type) && $img->type == 'image') { $data[$res->get('id')]['image'] = '/media/article/'.$res->get('id').'/mini_'.basename($img->src); break; } if (isset($img->type) && $img->type == 'video') { $data[$res->get('id')]['image'] = '/media/v.png'; } } } return $data; }
[ "private", "function", "comList", "(", "$", "result", ")", "{", "foreach", "(", "$", "result", "as", "$", "res", ")", "{", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'title'", "]", "=", "$", "res", "->", "get", "(", "'title'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'resume'", "]", "=", "$", "res", "->", "get", "(", "'resume'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'author'", "]", "=", "$", "res", "->", "get", "(", "'author'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'autor'", "]", "=", "$", "res", "->", "get", "(", "'autor'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'category'", "]", "=", "$", "res", "->", "get", "(", "'category'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'categoria'", "]", "=", "$", "res", "->", "get", "(", "'categoria'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'link'", "]", "=", "$", "res", "->", "get", "(", "'link'", ")", ";", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'pubdate'", "]", "=", "$", "res", "->", "get", "(", "'pubdate'", ")", ";", "//$data[$res->get('id')]['image'] = ['type'=>'picture', 'src'=>'/media/blog.png'];", "$", "media", "=", "json_decode", "(", "$", "res", "->", "get", "(", "'media'", ")", ")", ";", "foreach", "(", "$", "media", "as", "$", "img", ")", "{", "if", "(", "isset", "(", "$", "img", "->", "type", ")", "&&", "$", "img", "->", "type", "==", "'image'", ")", "{", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'image'", "]", "=", "'/media/article/'", ".", "$", "res", "->", "get", "(", "'id'", ")", ".", "'/mini_'", ".", "basename", "(", "$", "img", "->", "src", ")", ";", "break", ";", "}", "if", "(", "isset", "(", "$", "img", "->", "type", ")", "&&", "$", "img", "->", "type", "==", "'video'", ")", "{", "$", "data", "[", "$", "res", "->", "get", "(", "'id'", ")", "]", "[", "'image'", "]", "=", "'/media/v.png'", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Private util function @param array $result Array of the Row object @return array result data
[ "Private", "util", "function" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Base.php#L302-L330
3,675
devbr/pack-blog
Model/Base.php
Base.listByCategory
public function listByCategory($cat = null) { $result = $this->db->query('SELECT id, title, resume, category, author, link FROM '.$this->articleTable.' WHERE category = :cat', [':cat'=>$cat]); if (isset($result[0])) { return $this->comList($result); } return false; }
php
public function listByCategory($cat = null) { $result = $this->db->query('SELECT id, title, resume, category, author, link FROM '.$this->articleTable.' WHERE category = :cat', [':cat'=>$cat]); if (isset($result[0])) { return $this->comList($result); } return false; }
[ "public", "function", "listByCategory", "(", "$", "cat", "=", "null", ")", "{", "$", "result", "=", "$", "this", "->", "db", "->", "query", "(", "'SELECT id, title, resume, category, author, link \n FROM '", ".", "$", "this", "->", "articleTable", ".", "' \n WHERE category = :cat'", ",", "[", "':cat'", "=>", "$", "cat", "]", ")", ";", "if", "(", "isset", "(", "$", "result", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "comList", "(", "$", "result", ")", ";", "}", "return", "false", ";", "}" ]
List ao article in this category @param integer $cat category id @return array|bool data result or false
[ "List", "ao", "article", "in", "this", "category" ]
4693e36521ee3d08077f0db3e013afb99785cc9d
https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Base.php#L360-L369
3,676
bishopb/vanilla
applications/dashboard/controllers/class.statisticscontroller.php
StatisticsController.Index
public function Index() { $this->Permission('Garden.Settings.Manage'); $this->AddSideMenu('dashboard/statistics'); //$this->AddJsFile('statistics.js'); $this->Title(T('Vanilla Statistics')); $this->EnableSlicing($this); if ($this->Form->IsPostBack()) { $Flow = TRUE; if ($Flow && $this->Form->GetFormValue('Reregister')) { Gdn::Statistics()->Register(); } if ($Flow && $this->Form->GetFormValue('Save')) { Gdn::InstallationID($this->Form->GetFormValue('InstallationID')); Gdn::InstallationSecret($this->Form->GetFormValue('InstallationSecret')); $this->InformMessage(T("Your settings have been saved.")); } if ($Flow && $this->Form->GetFormValue('AllowLocal')) { SaveToConfig('Garden.Analytics.AllowLocal', TRUE); } if ($Flow && $this->Form->GetFormValue('Allow')) { SaveToConfig('Garden.Analytics.Enabled', TRUE); } if ($Flow && $this->Form->GetFormValue('ClearCredentials')) { Gdn::InstallationID(FALSE); Gdn::InstallationSecret(FALSE); Gdn::Statistics()->Tick(); $Flow = FALSE; } } $AnalyticsEnabled = Gdn_Statistics::CheckIsEnabled(); if ($AnalyticsEnabled) { $ConfFile = PATH_CONF.'/config.php'; $this->SetData('ConfWritable', $ConfWritable = is_writable($ConfFile)); if (!$ConfWritable) $AnalyticsEnabled = FALSE; } $this->SetData('AnalyticsEnabled', $AnalyticsEnabled); $NotifyMessage = Gdn::Get('Garden.Analytics.Notify', FALSE); $this->SetData('NotifyMessage', $NotifyMessage); if ($NotifyMessage !== FALSE) Gdn::Set('Garden.Analytics.Notify', NULL); $this->Form->SetFormValue('InstallationID', Gdn::InstallationID()); $this->Form->SetFormValue('InstallationSecret', Gdn::InstallationSecret()); $this->Render(); }
php
public function Index() { $this->Permission('Garden.Settings.Manage'); $this->AddSideMenu('dashboard/statistics'); //$this->AddJsFile('statistics.js'); $this->Title(T('Vanilla Statistics')); $this->EnableSlicing($this); if ($this->Form->IsPostBack()) { $Flow = TRUE; if ($Flow && $this->Form->GetFormValue('Reregister')) { Gdn::Statistics()->Register(); } if ($Flow && $this->Form->GetFormValue('Save')) { Gdn::InstallationID($this->Form->GetFormValue('InstallationID')); Gdn::InstallationSecret($this->Form->GetFormValue('InstallationSecret')); $this->InformMessage(T("Your settings have been saved.")); } if ($Flow && $this->Form->GetFormValue('AllowLocal')) { SaveToConfig('Garden.Analytics.AllowLocal', TRUE); } if ($Flow && $this->Form->GetFormValue('Allow')) { SaveToConfig('Garden.Analytics.Enabled', TRUE); } if ($Flow && $this->Form->GetFormValue('ClearCredentials')) { Gdn::InstallationID(FALSE); Gdn::InstallationSecret(FALSE); Gdn::Statistics()->Tick(); $Flow = FALSE; } } $AnalyticsEnabled = Gdn_Statistics::CheckIsEnabled(); if ($AnalyticsEnabled) { $ConfFile = PATH_CONF.'/config.php'; $this->SetData('ConfWritable', $ConfWritable = is_writable($ConfFile)); if (!$ConfWritable) $AnalyticsEnabled = FALSE; } $this->SetData('AnalyticsEnabled', $AnalyticsEnabled); $NotifyMessage = Gdn::Get('Garden.Analytics.Notify', FALSE); $this->SetData('NotifyMessage', $NotifyMessage); if ($NotifyMessage !== FALSE) Gdn::Set('Garden.Analytics.Notify', NULL); $this->Form->SetFormValue('InstallationID', Gdn::InstallationID()); $this->Form->SetFormValue('InstallationSecret', Gdn::InstallationSecret()); $this->Render(); }
[ "public", "function", "Index", "(", ")", "{", "$", "this", "->", "Permission", "(", "'Garden.Settings.Manage'", ")", ";", "$", "this", "->", "AddSideMenu", "(", "'dashboard/statistics'", ")", ";", "//$this->AddJsFile('statistics.js');", "$", "this", "->", "Title", "(", "T", "(", "'Vanilla Statistics'", ")", ")", ";", "$", "this", "->", "EnableSlicing", "(", "$", "this", ")", ";", "if", "(", "$", "this", "->", "Form", "->", "IsPostBack", "(", ")", ")", "{", "$", "Flow", "=", "TRUE", ";", "if", "(", "$", "Flow", "&&", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'Reregister'", ")", ")", "{", "Gdn", "::", "Statistics", "(", ")", "->", "Register", "(", ")", ";", "}", "if", "(", "$", "Flow", "&&", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'Save'", ")", ")", "{", "Gdn", "::", "InstallationID", "(", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'InstallationID'", ")", ")", ";", "Gdn", "::", "InstallationSecret", "(", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'InstallationSecret'", ")", ")", ";", "$", "this", "->", "InformMessage", "(", "T", "(", "\"Your settings have been saved.\"", ")", ")", ";", "}", "if", "(", "$", "Flow", "&&", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'AllowLocal'", ")", ")", "{", "SaveToConfig", "(", "'Garden.Analytics.AllowLocal'", ",", "TRUE", ")", ";", "}", "if", "(", "$", "Flow", "&&", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'Allow'", ")", ")", "{", "SaveToConfig", "(", "'Garden.Analytics.Enabled'", ",", "TRUE", ")", ";", "}", "if", "(", "$", "Flow", "&&", "$", "this", "->", "Form", "->", "GetFormValue", "(", "'ClearCredentials'", ")", ")", "{", "Gdn", "::", "InstallationID", "(", "FALSE", ")", ";", "Gdn", "::", "InstallationSecret", "(", "FALSE", ")", ";", "Gdn", "::", "Statistics", "(", ")", "->", "Tick", "(", ")", ";", "$", "Flow", "=", "FALSE", ";", "}", "}", "$", "AnalyticsEnabled", "=", "Gdn_Statistics", "::", "CheckIsEnabled", "(", ")", ";", "if", "(", "$", "AnalyticsEnabled", ")", "{", "$", "ConfFile", "=", "PATH_CONF", ".", "'/config.php'", ";", "$", "this", "->", "SetData", "(", "'ConfWritable'", ",", "$", "ConfWritable", "=", "is_writable", "(", "$", "ConfFile", ")", ")", ";", "if", "(", "!", "$", "ConfWritable", ")", "$", "AnalyticsEnabled", "=", "FALSE", ";", "}", "$", "this", "->", "SetData", "(", "'AnalyticsEnabled'", ",", "$", "AnalyticsEnabled", ")", ";", "$", "NotifyMessage", "=", "Gdn", "::", "Get", "(", "'Garden.Analytics.Notify'", ",", "FALSE", ")", ";", "$", "this", "->", "SetData", "(", "'NotifyMessage'", ",", "$", "NotifyMessage", ")", ";", "if", "(", "$", "NotifyMessage", "!==", "FALSE", ")", "Gdn", "::", "Set", "(", "'Garden.Analytics.Notify'", ",", "NULL", ")", ";", "$", "this", "->", "Form", "->", "SetFormValue", "(", "'InstallationID'", ",", "Gdn", "::", "InstallationID", "(", ")", ")", ";", "$", "this", "->", "Form", "->", "SetFormValue", "(", "'InstallationSecret'", ",", "Gdn", "::", "InstallationSecret", "(", ")", ")", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Statistics setup & configuration. @since 2.0.17 @access public
[ "Statistics", "setup", "&", "configuration", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.statisticscontroller.php#L50-L105
3,677
bishopb/vanilla
applications/dashboard/controllers/class.statisticscontroller.php
StatisticsController.Verify
public function Verify() { $CredentialsValid = Gdn::Statistics()->ValidateCredentials(); $this->SetData('StatisticsVerified', $CredentialsValid); $this->Render(); }
php
public function Verify() { $CredentialsValid = Gdn::Statistics()->ValidateCredentials(); $this->SetData('StatisticsVerified', $CredentialsValid); $this->Render(); }
[ "public", "function", "Verify", "(", ")", "{", "$", "CredentialsValid", "=", "Gdn", "::", "Statistics", "(", ")", "->", "ValidateCredentials", "(", ")", ";", "$", "this", "->", "SetData", "(", "'StatisticsVerified'", ",", "$", "CredentialsValid", ")", ";", "$", "this", "->", "Render", "(", ")", ";", "}" ]
Verify connection credentials. @since 2.0.17 @access public
[ "Verify", "connection", "credentials", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.statisticscontroller.php#L113-L117
3,678
binsoul/net-http-message-message
src/Collection/ParameterCollection.php
ParameterCollection.has
public function has(string $name): bool { $parts = explode('[', $name); $lastKey = trim(array_pop($parts), ']'); $current = &$this->parameters; foreach ($parts as $part) { $target = trim($part, ']'); if (!is_array($current) || !array_key_exists($target, $current)) { return false; } $current = &$current[$target]; } if (!array_key_exists($lastKey, $current)) { return false; } return true; }
php
public function has(string $name): bool { $parts = explode('[', $name); $lastKey = trim(array_pop($parts), ']'); $current = &$this->parameters; foreach ($parts as $part) { $target = trim($part, ']'); if (!is_array($current) || !array_key_exists($target, $current)) { return false; } $current = &$current[$target]; } if (!array_key_exists($lastKey, $current)) { return false; } return true; }
[ "public", "function", "has", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "parts", "=", "explode", "(", "'['", ",", "$", "name", ")", ";", "$", "lastKey", "=", "trim", "(", "array_pop", "(", "$", "parts", ")", ",", "']'", ")", ";", "$", "current", "=", "&", "$", "this", "->", "parameters", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "target", "=", "trim", "(", "$", "part", ",", "']'", ")", ";", "if", "(", "!", "is_array", "(", "$", "current", ")", "||", "!", "array_key_exists", "(", "$", "target", ",", "$", "current", ")", ")", "{", "return", "false", ";", "}", "$", "current", "=", "&", "$", "current", "[", "$", "target", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "lastKey", ",", "$", "current", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if a parameter exists. @param string $name name of the parameter @return bool
[ "Checks", "if", "a", "parameter", "exists", "." ]
b367ecdfda28570f849fc7e0723125a951d915a7
https://github.com/binsoul/net-http-message-message/blob/b367ecdfda28570f849fc7e0723125a951d915a7/src/Collection/ParameterCollection.php#L70-L89
3,679
binsoul/net-http-message-message
src/Collection/ParameterCollection.php
ParameterCollection.get
public function get(string $name, $default = null) { $parts = explode('[', $name); $lastKey = trim(array_pop($parts), ']'); $current = &$this->parameters; foreach ($parts as $part) { $target = trim($part, ']'); if (!is_array($current) || !array_key_exists($target, $current)) { return $default; } $current = &$current[$target]; } if (!array_key_exists($lastKey, $current)) { return $default; } return $current[$lastKey]; }
php
public function get(string $name, $default = null) { $parts = explode('[', $name); $lastKey = trim(array_pop($parts), ']'); $current = &$this->parameters; foreach ($parts as $part) { $target = trim($part, ']'); if (!is_array($current) || !array_key_exists($target, $current)) { return $default; } $current = &$current[$target]; } if (!array_key_exists($lastKey, $current)) { return $default; } return $current[$lastKey]; }
[ "public", "function", "get", "(", "string", "$", "name", ",", "$", "default", "=", "null", ")", "{", "$", "parts", "=", "explode", "(", "'['", ",", "$", "name", ")", ";", "$", "lastKey", "=", "trim", "(", "array_pop", "(", "$", "parts", ")", ",", "']'", ")", ";", "$", "current", "=", "&", "$", "this", "->", "parameters", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "target", "=", "trim", "(", "$", "part", ",", "']'", ")", ";", "if", "(", "!", "is_array", "(", "$", "current", ")", "||", "!", "array_key_exists", "(", "$", "target", ",", "$", "current", ")", ")", "{", "return", "$", "default", ";", "}", "$", "current", "=", "&", "$", "current", "[", "$", "target", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "lastKey", ",", "$", "current", ")", ")", "{", "return", "$", "default", ";", "}", "return", "$", "current", "[", "$", "lastKey", "]", ";", "}" ]
Returns the value of a parameter. @param string $name name of the parameter @param mixed $default return value if the parameter doesn't exist @return mixed
[ "Returns", "the", "value", "of", "a", "parameter", "." ]
b367ecdfda28570f849fc7e0723125a951d915a7
https://github.com/binsoul/net-http-message-message/blob/b367ecdfda28570f849fc7e0723125a951d915a7/src/Collection/ParameterCollection.php#L99-L118
3,680
digitalkaoz/issues
src/Tracker/SearchableTracker.php
SearchableTracker.requestProjects
protected function requestProjects($name, \Closure $finder, $nameKey) { $projects = []; if ($this->repoParser->isConcrete($name)) { $project = $this->getProject($name); $projects[$project->getName()] = $project; } else { $repos = $finder($name); if (true === $this->repoParser->isWildcard($name)) { foreach ((array) $repos as $repo) { $project = $this->getProject($repo[$nameKey]); $projects[$project->getName()] = $project; } } else { foreach ((array) $repos as $repo) { if (false === $this->repoParser->matchesRegex($name, $repo[$nameKey])) { continue; } $project = $this->getProject($repo[$nameKey]); $projects[$project->getName()] = $project; } } } return $projects; }
php
protected function requestProjects($name, \Closure $finder, $nameKey) { $projects = []; if ($this->repoParser->isConcrete($name)) { $project = $this->getProject($name); $projects[$project->getName()] = $project; } else { $repos = $finder($name); if (true === $this->repoParser->isWildcard($name)) { foreach ((array) $repos as $repo) { $project = $this->getProject($repo[$nameKey]); $projects[$project->getName()] = $project; } } else { foreach ((array) $repos as $repo) { if (false === $this->repoParser->matchesRegex($name, $repo[$nameKey])) { continue; } $project = $this->getProject($repo[$nameKey]); $projects[$project->getName()] = $project; } } } return $projects; }
[ "protected", "function", "requestProjects", "(", "$", "name", ",", "\\", "Closure", "$", "finder", ",", "$", "nameKey", ")", "{", "$", "projects", "=", "[", "]", ";", "if", "(", "$", "this", "->", "repoParser", "->", "isConcrete", "(", "$", "name", ")", ")", "{", "$", "project", "=", "$", "this", "->", "getProject", "(", "$", "name", ")", ";", "$", "projects", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "$", "project", ";", "}", "else", "{", "$", "repos", "=", "$", "finder", "(", "$", "name", ")", ";", "if", "(", "true", "===", "$", "this", "->", "repoParser", "->", "isWildcard", "(", "$", "name", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "repos", "as", "$", "repo", ")", "{", "$", "project", "=", "$", "this", "->", "getProject", "(", "$", "repo", "[", "$", "nameKey", "]", ")", ";", "$", "projects", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "$", "project", ";", "}", "}", "else", "{", "foreach", "(", "(", "array", ")", "$", "repos", "as", "$", "repo", ")", "{", "if", "(", "false", "===", "$", "this", "->", "repoParser", "->", "matchesRegex", "(", "$", "name", ",", "$", "repo", "[", "$", "nameKey", "]", ")", ")", "{", "continue", ";", "}", "$", "project", "=", "$", "this", "->", "getProject", "(", "$", "repo", "[", "$", "nameKey", "]", ")", ";", "$", "projects", "[", "$", "project", "->", "getName", "(", ")", "]", "=", "$", "project", ";", "}", "}", "}", "return", "$", "projects", ";", "}" ]
searches for projects. @param string $name @param \Closure $finder @param string $nameKey @return Project[]
[ "searches", "for", "projects", "." ]
c5ac5c907ec981669619780747a55251d65310d6
https://github.com/digitalkaoz/issues/blob/c5ac5c907ec981669619780747a55251d65310d6/src/Tracker/SearchableTracker.php#L79-L106
3,681
osflab/container
OsfContainer.php
OsfContainer.getViewHelper
public static function getViewHelper($appName = null, bool $layout = false) { if ($appName === false) { $class = '\Osf\View\Helper'; $instance = 'osf'; } else { $appName = $appName === null ? Router::getDefaultControllerName(true) : $appName; $class = "\\App\\" . $appName . '\View\Helper'; $instance = $appName; } $viewName = $layout ? 'layout' : 'view'; $instance .= $layout ? '_l' : '_v'; return self::buildObject($class, [$viewName]); //, $instance); }
php
public static function getViewHelper($appName = null, bool $layout = false) { if ($appName === false) { $class = '\Osf\View\Helper'; $instance = 'osf'; } else { $appName = $appName === null ? Router::getDefaultControllerName(true) : $appName; $class = "\\App\\" . $appName . '\View\Helper'; $instance = $appName; } $viewName = $layout ? 'layout' : 'view'; $instance .= $layout ? '_l' : '_v'; return self::buildObject($class, [$viewName]); //, $instance); }
[ "public", "static", "function", "getViewHelper", "(", "$", "appName", "=", "null", ",", "bool", "$", "layout", "=", "false", ")", "{", "if", "(", "$", "appName", "===", "false", ")", "{", "$", "class", "=", "'\\Osf\\View\\Helper'", ";", "$", "instance", "=", "'osf'", ";", "}", "else", "{", "$", "appName", "=", "$", "appName", "===", "null", "?", "Router", "::", "getDefaultControllerName", "(", "true", ")", ":", "$", "appName", ";", "$", "class", "=", "\"\\\\App\\\\\"", ".", "$", "appName", ".", "'\\View\\Helper'", ";", "$", "instance", "=", "$", "appName", ";", "}", "$", "viewName", "=", "$", "layout", "?", "'layout'", ":", "'view'", ";", "$", "instance", ".=", "$", "layout", "?", "'_l'", ":", "'_v'", ";", "return", "self", "::", "buildObject", "(", "$", "class", ",", "[", "$", "viewName", "]", ")", ";", "//, $instance);", "}" ]
Get a view helpers object with a context @param string|null|false $appName if null : common app. if false : Osf view helper @param bool $layout @return \Osf\View\Helper @task [HELPERS] simplifier
[ "Get", "a", "view", "helpers", "object", "with", "a", "context" ]
415b374260ad377df00f8b3683b99f08bb4d25b6
https://github.com/osflab/container/blob/415b374260ad377df00f8b3683b99f08bb4d25b6/OsfContainer.php#L99-L112
3,682
osflab/container
OsfContainer.php
OsfContainer.getCrypt
public static function getCrypt($cryptKey = Crypt::DEFAULT_KEY, $mode = Crypt::MODE_ASCII): \Osf\Crypt\Crypt { return self::buildObject('\Osf\Crypt\Crypt', [$cryptKey, $mode]); }
php
public static function getCrypt($cryptKey = Crypt::DEFAULT_KEY, $mode = Crypt::MODE_ASCII): \Osf\Crypt\Crypt { return self::buildObject('\Osf\Crypt\Crypt', [$cryptKey, $mode]); }
[ "public", "static", "function", "getCrypt", "(", "$", "cryptKey", "=", "Crypt", "::", "DEFAULT_KEY", ",", "$", "mode", "=", "Crypt", "::", "MODE_ASCII", ")", ":", "\\", "Osf", "\\", "Crypt", "\\", "Crypt", "{", "return", "self", "::", "buildObject", "(", "'\\Osf\\Crypt\\Crypt'", ",", "[", "$", "cryptKey", ",", "$", "mode", "]", ")", ";", "}" ]
Get Osf Crypt object. Parameters are usefull ONLY for the first call @param string $cryptKey @param string $mode @return \Osf\Crypt\Crypt
[ "Get", "Osf", "Crypt", "object", ".", "Parameters", "are", "usefull", "ONLY", "for", "the", "first", "call" ]
415b374260ad377df00f8b3683b99f08bb4d25b6
https://github.com/osflab/container/blob/415b374260ad377df00f8b3683b99f08bb4d25b6/OsfContainer.php#L173-L176
3,683
routegroup/native-media
src/Concerns/Thumbnail.php
Thumbnail.thumbnail
public function thumbnail($width, $height = null) { if ($this->type != 'image') { throw new \LogicException("Tried to create thumbnail for not image file.", 500); } $thumbnail = new \Routegroup\Media\Helpers\Thumbnail($this); $filename = $thumbnail->name($width, $height); if ($thumbnail->exists($filename)) { return $this->storage->url($this->path($filename)); } return $thumbnail->create($filename, $width, $height); }
php
public function thumbnail($width, $height = null) { if ($this->type != 'image') { throw new \LogicException("Tried to create thumbnail for not image file.", 500); } $thumbnail = new \Routegroup\Media\Helpers\Thumbnail($this); $filename = $thumbnail->name($width, $height); if ($thumbnail->exists($filename)) { return $this->storage->url($this->path($filename)); } return $thumbnail->create($filename, $width, $height); }
[ "public", "function", "thumbnail", "(", "$", "width", ",", "$", "height", "=", "null", ")", "{", "if", "(", "$", "this", "->", "type", "!=", "'image'", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Tried to create thumbnail for not image file.\"", ",", "500", ")", ";", "}", "$", "thumbnail", "=", "new", "\\", "Routegroup", "\\", "Media", "\\", "Helpers", "\\", "Thumbnail", "(", "$", "this", ")", ";", "$", "filename", "=", "$", "thumbnail", "->", "name", "(", "$", "width", ",", "$", "height", ")", ";", "if", "(", "$", "thumbnail", "->", "exists", "(", "$", "filename", ")", ")", "{", "return", "$", "this", "->", "storage", "->", "url", "(", "$", "this", "->", "path", "(", "$", "filename", ")", ")", ";", "}", "return", "$", "thumbnail", "->", "create", "(", "$", "filename", ",", "$", "width", ",", "$", "height", ")", ";", "}" ]
Gets thumbnail for given sizes. @param integer $width @param integer $height @return string
[ "Gets", "thumbnail", "for", "given", "sizes", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Concerns/Thumbnail.php#L28-L43
3,684
franzip/serp-fetcher
src/Helpers/GenericValidator.php
GenericValidator.argsValidation
public static function argsValidation($cacheDir, $cacheTTL, $caching, $cacheForever, $charset) { if (!self::validateDirName($cacheDir)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheDir: please supply a valid non-empty string.'); if (!self::validateExpirationTime($cacheTTL)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheTTL: please supply a positive integer.'); if (!self::validateCacheOpt($caching)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $caching: please supply a boolean value.'); if (!self::validateCacheOpt($cacheForever)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheForever: please supply a boolean value.'); if (!self::validateCharset($charset)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $charset: please supply a valid non-empty string.'); }
php
public static function argsValidation($cacheDir, $cacheTTL, $caching, $cacheForever, $charset) { if (!self::validateDirName($cacheDir)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheDir: please supply a valid non-empty string.'); if (!self::validateExpirationTime($cacheTTL)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheTTL: please supply a positive integer.'); if (!self::validateCacheOpt($caching)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $caching: please supply a boolean value.'); if (!self::validateCacheOpt($cacheForever)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $cacheForever: please supply a boolean value.'); if (!self::validateCharset($charset)) throw new \Franzip\SerpFetcher\Exceptions\InvalidArgumentException('Invalid SerpFetcher $charset: please supply a valid non-empty string.'); }
[ "public", "static", "function", "argsValidation", "(", "$", "cacheDir", ",", "$", "cacheTTL", ",", "$", "caching", ",", "$", "cacheForever", ",", "$", "charset", ")", "{", "if", "(", "!", "self", "::", "validateDirName", "(", "$", "cacheDir", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpFetcher", "\\", "Exceptions", "\\", "InvalidArgumentException", "(", "'Invalid SerpFetcher $cacheDir: please supply a valid non-empty string.'", ")", ";", "if", "(", "!", "self", "::", "validateExpirationTime", "(", "$", "cacheTTL", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpFetcher", "\\", "Exceptions", "\\", "InvalidArgumentException", "(", "'Invalid SerpFetcher $cacheTTL: please supply a positive integer.'", ")", ";", "if", "(", "!", "self", "::", "validateCacheOpt", "(", "$", "caching", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpFetcher", "\\", "Exceptions", "\\", "InvalidArgumentException", "(", "'Invalid SerpFetcher $caching: please supply a boolean value.'", ")", ";", "if", "(", "!", "self", "::", "validateCacheOpt", "(", "$", "cacheForever", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpFetcher", "\\", "Exceptions", "\\", "InvalidArgumentException", "(", "'Invalid SerpFetcher $cacheForever: please supply a boolean value.'", ")", ";", "if", "(", "!", "self", "::", "validateCharset", "(", "$", "charset", ")", ")", "throw", "new", "\\", "Franzip", "\\", "SerpFetcher", "\\", "Exceptions", "\\", "InvalidArgumentException", "(", "'Invalid SerpFetcher $charset: please supply a valid non-empty string.'", ")", ";", "}" ]
Perform validation on SerpFetcher constructor arguments. @param string $cacheDir @param int $cacheTTL @param bool $caching @param bool $cacheForever @param string $charset
[ "Perform", "validation", "on", "SerpFetcher", "constructor", "arguments", "." ]
0554b682a8e4aec6e5d615866087b34e731e0d88
https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Helpers/GenericValidator.php#L30-L47
3,685
gap-db/orm
GapOrm/Drivers/PdoDriver.php
PdoDriver.tableExists
public function tableExists($tableName) { if (is_null($this->dbh)) { throw new NoConnectionException(); } $mrSql = "SHOW TABLES LIKE :table_name"; $mrStmt = $this->dbh->prepare($mrSql); // protect from injection attacks $mrStmt->bindParam(":table_name", $tableName, \PDO::PARAM_STR); $sqlResult = $mrStmt->execute(); if ($sqlResult) { $row = $mrStmt->fetch(\PDO::FETCH_NUM); if ($row[0]) { return true; } } return false; }
php
public function tableExists($tableName) { if (is_null($this->dbh)) { throw new NoConnectionException(); } $mrSql = "SHOW TABLES LIKE :table_name"; $mrStmt = $this->dbh->prepare($mrSql); // protect from injection attacks $mrStmt->bindParam(":table_name", $tableName, \PDO::PARAM_STR); $sqlResult = $mrStmt->execute(); if ($sqlResult) { $row = $mrStmt->fetch(\PDO::FETCH_NUM); if ($row[0]) { return true; } } return false; }
[ "public", "function", "tableExists", "(", "$", "tableName", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dbh", ")", ")", "{", "throw", "new", "NoConnectionException", "(", ")", ";", "}", "$", "mrSql", "=", "\"SHOW TABLES LIKE :table_name\"", ";", "$", "mrStmt", "=", "$", "this", "->", "dbh", "->", "prepare", "(", "$", "mrSql", ")", ";", "// protect from injection attacks", "$", "mrStmt", "->", "bindParam", "(", "\":table_name\"", ",", "$", "tableName", ",", "\\", "PDO", "::", "PARAM_STR", ")", ";", "$", "sqlResult", "=", "$", "mrStmt", "->", "execute", "(", ")", ";", "if", "(", "$", "sqlResult", ")", "{", "$", "row", "=", "$", "mrStmt", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_NUM", ")", ";", "if", "(", "$", "row", "[", "0", "]", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
This function checks if the table exists in the passed PDO database connection @param $tableName @return boolean - true if table was found, false if not @throws \GapOrm\Exceptions\NoConnectionException
[ "This", "function", "checks", "if", "the", "table", "exists", "in", "the", "passed", "PDO", "database", "connection" ]
bcd8e3d27b19b14814d3207489071c4a250a6ac5
https://github.com/gap-db/orm/blob/bcd8e3d27b19b14814d3207489071c4a250a6ac5/GapOrm/Drivers/PdoDriver.php#L244-L267
3,686
LasseHaslev/image-handler
src/Handlers/ImageHandler.php
ImageHandler.deleteCrops
public static function deleteCrops( $originalFilePath, $cropsFolder = null ) { $self = static::create( $originalFilePath, $cropsFolder ); return $self->removeCrops(); }
php
public static function deleteCrops( $originalFilePath, $cropsFolder = null ) { $self = static::create( $originalFilePath, $cropsFolder ); return $self->removeCrops(); }
[ "public", "static", "function", "deleteCrops", "(", "$", "originalFilePath", ",", "$", "cropsFolder", "=", "null", ")", "{", "$", "self", "=", "static", "::", "create", "(", "$", "originalFilePath", ",", "$", "cropsFolder", ")", ";", "return", "$", "self", "->", "removeCrops", "(", ")", ";", "}" ]
Quickly remove crops @return $instance
[ "Quickly", "remove", "crops" ]
dfc4fc7417617169d2483d62e5d27d3dd6a12235
https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/ImageHandler.php#L78-L82
3,687
LasseHaslev/image-handler
src/Handlers/ImageHandler.php
ImageHandler.removeCrops
public function removeCrops() { // Get original file name $justTheName = pathinfo($this->originalImagePath, PATHINFO_FILENAME); // Get all the files to remove $filesToRemove = glob( sprintf( '%s/%s-*', $this->cropsFolder, $justTheName ) ); // Delete the crops from list foreach($filesToRemove as $file){ // iterate files // Check if this is a file if(is_file($file)) unlink($file); // delete file } // Return $this for chaning return $this; }
php
public function removeCrops() { // Get original file name $justTheName = pathinfo($this->originalImagePath, PATHINFO_FILENAME); // Get all the files to remove $filesToRemove = glob( sprintf( '%s/%s-*', $this->cropsFolder, $justTheName ) ); // Delete the crops from list foreach($filesToRemove as $file){ // iterate files // Check if this is a file if(is_file($file)) unlink($file); // delete file } // Return $this for chaning return $this; }
[ "public", "function", "removeCrops", "(", ")", "{", "// Get original file name", "$", "justTheName", "=", "pathinfo", "(", "$", "this", "->", "originalImagePath", ",", "PATHINFO_FILENAME", ")", ";", "// Get all the files to remove", "$", "filesToRemove", "=", "glob", "(", "sprintf", "(", "'%s/%s-*'", ",", "$", "this", "->", "cropsFolder", ",", "$", "justTheName", ")", ")", ";", "// Delete the crops from list", "foreach", "(", "$", "filesToRemove", "as", "$", "file", ")", "{", "// iterate files", "// Check if this is a file", "if", "(", "is_file", "(", "$", "file", ")", ")", "unlink", "(", "$", "file", ")", ";", "// delete file", "}", "// Return $this for chaning", "return", "$", "this", ";", "}" ]
Reset all created crops for the image @return $this
[ "Reset", "all", "created", "crops", "for", "the", "image" ]
dfc4fc7417617169d2483d62e5d27d3dd6a12235
https://github.com/LasseHaslev/image-handler/blob/dfc4fc7417617169d2483d62e5d27d3dd6a12235/src/Handlers/ImageHandler.php#L89-L107
3,688
inceddy/ieu_http
src/ieu/Http/Request.php
Request.server
public function server(string $key, $default = null) { return $this->server->has($key) ? $this->server->get($key) : $default; }
php
public function server(string $key, $default = null) { return $this->server->has($key) ? $this->server->get($key) : $default; }
[ "public", "function", "server", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "server", "->", "has", "(", "$", "key", ")", "?", "$", "this", "->", "server", "->", "get", "(", "$", "key", ")", ":", "$", "default", ";", "}" ]
Shortcut to fetch a SERVER-parameter with optional default value @param string $key the key to look for @param mixed $default the value thar will be returned if the key is not set @return mixed the found or the default value
[ "Shortcut", "to", "fetch", "a", "SERVER", "-", "parameter", "with", "optional", "default", "value" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L229-L232
3,689
inceddy/ieu_http
src/ieu/Http/Request.php
Request.cookie
public function cookie(string $key, $default = null) { return $this->cookie->has($key) ? $this->cookie->get($key) : $default; }
php
public function cookie(string $key, $default = null) { return $this->cookie->has($key) ? $this->cookie->get($key) : $default; }
[ "public", "function", "cookie", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "cookie", "->", "has", "(", "$", "key", ")", "?", "$", "this", "->", "cookie", "->", "get", "(", "$", "key", ")", ":", "$", "default", ";", "}" ]
Shortcut to fetch a COOKIE-parameter with optional default value @param string $key the key to look for @param mixed $default the value thar will be returned if the key is not set @return mixed the found or the default value
[ "Shortcut", "to", "fetch", "a", "COOKIE", "-", "parameter", "with", "optional", "default", "value" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L245-L248
3,690
inceddy/ieu_http
src/ieu/Http/Request.php
Request.session
public function session(string $key, $default = null) { if (null === $this->session) { throw new \Exception('No session object set. Use \'Request::setSession\'.'); } return $this->session->has($key) ? $this->session->get($key) : $default; }
php
public function session(string $key, $default = null) { if (null === $this->session) { throw new \Exception('No session object set. Use \'Request::setSession\'.'); } return $this->session->has($key) ? $this->session->get($key) : $default; }
[ "public", "function", "session", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "null", "===", "$", "this", "->", "session", ")", "{", "throw", "new", "\\", "Exception", "(", "'No session object set. Use \\'Request::setSession\\'.'", ")", ";", "}", "return", "$", "this", "->", "session", "->", "has", "(", "$", "key", ")", "?", "$", "this", "->", "session", "->", "get", "(", "$", "key", ")", ":", "$", "default", ";", "}" ]
Shortcut to fetch a SESSION-parameter with optional default value. The session object must me manualy set and started! @param string $key the key to look for @param mixed $default the value thar will be returned if the key is not set @return mixed the found or the default value
[ "Shortcut", "to", "fetch", "a", "SESSION", "-", "parameter", "with", "optional", "default", "value", ".", "The", "session", "object", "must", "me", "manualy", "set", "and", "started!" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L264-L271
3,691
inceddy/ieu_http
src/ieu/Http/Request.php
Request.header
public function header(string $key, $default = null) { return $this->header->has($key) ? $this->header->get($key) : $default; }
php
public function header(string $key, $default = null) { return $this->header->has($key) ? $this->header->get($key) : $default; }
[ "public", "function", "header", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "header", "->", "has", "(", "$", "key", ")", "?", "$", "this", "->", "header", "->", "get", "(", "$", "key", ")", ":", "$", "default", ";", "}" ]
Shortcut to fetch a HEADER-parameter with optional default value. @param string $key the key to look for @param mixed $default the value thar will be returned if the key is not set @return mixed the found or the default value
[ "Shortcut", "to", "fetch", "a", "HEADER", "-", "parameter", "with", "optional", "default", "value", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L286-L289
3,692
inceddy/ieu_http
src/ieu/Http/Request.php
Request.getMethod
public function getMethod() :? int { switch($this->server('REQUEST_METHOD')) { case 'GET': return self::HTTP_GET; case 'POST': return self::HTTP_POST; case 'HEAD': return self::HTTP_HEAD; case 'PUT': return self::HTTP_PUT; case 'DELETE': return self::HTTP_DELETE; case 'TRACE': return self::HTTP_TRACE; case 'OPTIONS': return self::HTTP_OPTIONS; case 'CONNECT': return self::HTTP_CONNECT; } return null; }
php
public function getMethod() :? int { switch($this->server('REQUEST_METHOD')) { case 'GET': return self::HTTP_GET; case 'POST': return self::HTTP_POST; case 'HEAD': return self::HTTP_HEAD; case 'PUT': return self::HTTP_PUT; case 'DELETE': return self::HTTP_DELETE; case 'TRACE': return self::HTTP_TRACE; case 'OPTIONS': return self::HTTP_OPTIONS; case 'CONNECT': return self::HTTP_CONNECT; } return null; }
[ "public", "function", "getMethod", "(", ")", ":", "?", "int", "{", "switch", "(", "$", "this", "->", "server", "(", "'REQUEST_METHOD'", ")", ")", "{", "case", "'GET'", ":", "return", "self", "::", "HTTP_GET", ";", "case", "'POST'", ":", "return", "self", "::", "HTTP_POST", ";", "case", "'HEAD'", ":", "return", "self", "::", "HTTP_HEAD", ";", "case", "'PUT'", ":", "return", "self", "::", "HTTP_PUT", ";", "case", "'DELETE'", ":", "return", "self", "::", "HTTP_DELETE", ";", "case", "'TRACE'", ":", "return", "self", "::", "HTTP_TRACE", ";", "case", "'OPTIONS'", ":", "return", "self", "::", "HTTP_OPTIONS", ";", "case", "'CONNECT'", ":", "return", "self", "::", "HTTP_CONNECT", ";", "}", "return", "null", ";", "}" ]
Returns the bit-code of the request method or null if the method is unknown. @return int|null
[ "Returns", "the", "bit", "-", "code", "of", "the", "request", "method", "or", "null", "if", "the", "method", "is", "unknown", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L318-L340
3,693
inceddy/ieu_http
src/ieu/Http/Request.php
Request.protocolWithActiveSsl
protected function protocolWithActiveSsl($protocol) : bool { $protocol = strtolower((string)$protocol); return in_array($protocol, ['on', '1', 'https', 'ssl'], true); }
php
protected function protocolWithActiveSsl($protocol) : bool { $protocol = strtolower((string)$protocol); return in_array($protocol, ['on', '1', 'https', 'ssl'], true); }
[ "protected", "function", "protocolWithActiveSsl", "(", "$", "protocol", ")", ":", "bool", "{", "$", "protocol", "=", "strtolower", "(", "(", "string", ")", "$", "protocol", ")", ";", "return", "in_array", "(", "$", "protocol", ",", "[", "'on'", ",", "'1'", ",", "'https'", ",", "'ssl'", "]", ",", "true", ")", ";", "}" ]
Detects an active SSL protocol value. @param string $protocol @return boolean
[ "Detects", "an", "active", "SSL", "protocol", "value", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L435-L439
3,694
inceddy/ieu_http
src/ieu/Http/Request.php
Request.getPort
public function getPort() : string { // Check for proxy first $port = self::server('HTTP_X_FORWARDED_PORT'); if ($port) { return (string)$port; } $protocol = (string)self::server('HTTP_X_FORWARDED_PROTO'); if ($protocol === 'https') { return '443'; } return (string)self::server('SERVER_PORT'); }
php
public function getPort() : string { // Check for proxy first $port = self::server('HTTP_X_FORWARDED_PORT'); if ($port) { return (string)$port; } $protocol = (string)self::server('HTTP_X_FORWARDED_PROTO'); if ($protocol === 'https') { return '443'; } return (string)self::server('SERVER_PORT'); }
[ "public", "function", "getPort", "(", ")", ":", "string", "{", "// Check for proxy first\r", "$", "port", "=", "self", "::", "server", "(", "'HTTP_X_FORWARDED_PORT'", ")", ";", "if", "(", "$", "port", ")", "{", "return", "(", "string", ")", "$", "port", ";", "}", "$", "protocol", "=", "(", "string", ")", "self", "::", "server", "(", "'HTTP_X_FORWARDED_PROTO'", ")", ";", "if", "(", "$", "protocol", "===", "'https'", ")", "{", "return", "'443'", ";", "}", "return", "(", "string", ")", "self", "::", "server", "(", "'SERVER_PORT'", ")", ";", "}" ]
Get the port of this request as string. @return string
[ "Get", "the", "port", "of", "this", "request", "as", "string", "." ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L505-L519
3,695
inceddy/ieu_http
src/ieu/Http/Request.php
Request.getUrl
public function getUrl() : Url { return Url::from( $this->getHttpScheme() . '://' . $this->getHost() . $this->server('REQUEST_URI') ); }
php
public function getUrl() : Url { return Url::from( $this->getHttpScheme() . '://' . $this->getHost() . $this->server('REQUEST_URI') ); }
[ "public", "function", "getUrl", "(", ")", ":", "Url", "{", "return", "Url", "::", "from", "(", "$", "this", "->", "getHttpScheme", "(", ")", ".", "'://'", ".", "$", "this", "->", "getHost", "(", ")", ".", "$", "this", "->", "server", "(", "'REQUEST_URI'", ")", ")", ";", "}" ]
Gets a new `ieu\Http\Url` object based on the request URL @throws InvalidArgumentException If the request URL is invalid @return ieu\Http\Url
[ "Gets", "a", "new", "ieu", "\\", "Http", "\\", "Url", "object", "based", "on", "the", "request", "URL" ]
4c9b097ee1e31ca45acfb79a855462d78b5c979c
https://github.com/inceddy/ieu_http/blob/4c9b097ee1e31ca45acfb79a855462d78b5c979c/src/ieu/Http/Request.php#L530-L535
3,696
emhar/SearchDoctrineBundle
Query/Query.php
Query.getResults
public function getResults(EntityManager $em, Request $request, $page) { $query = $this->buildResultQuery($em, $request, $page); return $query->getResult(); }
php
public function getResults(EntityManager $em, Request $request, $page) { $query = $this->buildResultQuery($em, $request, $page); return $query->getResult(); }
[ "public", "function", "getResults", "(", "EntityManager", "$", "em", ",", "Request", "$", "request", ",", "$", "page", ")", "{", "$", "query", "=", "$", "this", "->", "buildResultQuery", "(", "$", "em", ",", "$", "request", ",", "$", "page", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Get results for request @param EntityManager $em @param Request $request @param int $page @return array
[ "Get", "results", "for", "request" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L102-L106
3,697
emhar/SearchDoctrineBundle
Query/Query.php
Query.getCount
public function getCount(EntityManager $em, Request $request) { $stmt = $this->buildCountQuery($em, $request); $stmt->execute(); return (int) $stmt->fetchColumn(); }
php
public function getCount(EntityManager $em, Request $request) { $stmt = $this->buildCountQuery($em, $request); $stmt->execute(); return (int) $stmt->fetchColumn(); }
[ "public", "function", "getCount", "(", "EntityManager", "$", "em", ",", "Request", "$", "request", ")", "{", "$", "stmt", "=", "$", "this", "->", "buildCountQuery", "(", "$", "em", ",", "$", "request", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "return", "(", "int", ")", "$", "stmt", "->", "fetchColumn", "(", ")", ";", "}" ]
Get result count for request @param EntityManager $em @param Request $request @return int
[ "Get", "result", "count", "for", "request" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L115-L120
3,698
emhar/SearchDoctrineBundle
Query/Query.php
Query.buildResultQuery
protected function buildResultQuery(EntityManager $em, Request $request, $page) { $searchWords = preg_split('/[^[:alnum:]]+/', $request->getSearchText()); $offset = $request->getLimit() * ($page - 1); $limit = $request->getLimit(); $selects = array(); foreach($this->databaseMapping as $key => $tableMapping) { $tableMapping['columns'][$this->scorePos] = $this->buildScoreColumn($tableMapping['columns'], count($searchWords)); //For constructor parameter order of searchitem ksort($tableMapping['columns']); $hitExpressions = $this->buildHitExpressions($tableMapping['columns']); $joinsExpressions = $this->buildJoinExpressions($tableMapping['joins']); $selects[] = 'SELECT * FROM (SELECT ' . implode($hitExpressions, ', ') . ' ' . 'FROM ' . $tableMapping['table'] . ' ' . $tableMapping['tableAlias'] . ' ' . implode(' ', $joinsExpressions) . ' ' . 'ORDER BY c' . $this->scorePos . ' DESC ' . 'LIMIT ' . ($offset + $limit) . ') AS DT' . $key . ' ' . 'WHERE c' . $this->scorePos . '<>0 ' ; } $bigSelect = '' . implode($selects, ' UNION ') . ' ' . 'ORDER BY c' . $this->scorePos . ' DESC ' . 'LIMIT ' . $limit . ' ' . 'OFFSET ' . $offset ; $query = $em->createNativeQuery($bigSelect, $this->rsm); foreach($searchWords as $key => $searchWord) { $query->setParameter('p' . $key, $searchWord); } return $query; }
php
protected function buildResultQuery(EntityManager $em, Request $request, $page) { $searchWords = preg_split('/[^[:alnum:]]+/', $request->getSearchText()); $offset = $request->getLimit() * ($page - 1); $limit = $request->getLimit(); $selects = array(); foreach($this->databaseMapping as $key => $tableMapping) { $tableMapping['columns'][$this->scorePos] = $this->buildScoreColumn($tableMapping['columns'], count($searchWords)); //For constructor parameter order of searchitem ksort($tableMapping['columns']); $hitExpressions = $this->buildHitExpressions($tableMapping['columns']); $joinsExpressions = $this->buildJoinExpressions($tableMapping['joins']); $selects[] = 'SELECT * FROM (SELECT ' . implode($hitExpressions, ', ') . ' ' . 'FROM ' . $tableMapping['table'] . ' ' . $tableMapping['tableAlias'] . ' ' . implode(' ', $joinsExpressions) . ' ' . 'ORDER BY c' . $this->scorePos . ' DESC ' . 'LIMIT ' . ($offset + $limit) . ') AS DT' . $key . ' ' . 'WHERE c' . $this->scorePos . '<>0 ' ; } $bigSelect = '' . implode($selects, ' UNION ') . ' ' . 'ORDER BY c' . $this->scorePos . ' DESC ' . 'LIMIT ' . $limit . ' ' . 'OFFSET ' . $offset ; $query = $em->createNativeQuery($bigSelect, $this->rsm); foreach($searchWords as $key => $searchWord) { $query->setParameter('p' . $key, $searchWord); } return $query; }
[ "protected", "function", "buildResultQuery", "(", "EntityManager", "$", "em", ",", "Request", "$", "request", ",", "$", "page", ")", "{", "$", "searchWords", "=", "preg_split", "(", "'/[^[:alnum:]]+/'", ",", "$", "request", "->", "getSearchText", "(", ")", ")", ";", "$", "offset", "=", "$", "request", "->", "getLimit", "(", ")", "*", "(", "$", "page", "-", "1", ")", ";", "$", "limit", "=", "$", "request", "->", "getLimit", "(", ")", ";", "$", "selects", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "databaseMapping", "as", "$", "key", "=>", "$", "tableMapping", ")", "{", "$", "tableMapping", "[", "'columns'", "]", "[", "$", "this", "->", "scorePos", "]", "=", "$", "this", "->", "buildScoreColumn", "(", "$", "tableMapping", "[", "'columns'", "]", ",", "count", "(", "$", "searchWords", ")", ")", ";", "//For constructor parameter order of searchitem", "ksort", "(", "$", "tableMapping", "[", "'columns'", "]", ")", ";", "$", "hitExpressions", "=", "$", "this", "->", "buildHitExpressions", "(", "$", "tableMapping", "[", "'columns'", "]", ")", ";", "$", "joinsExpressions", "=", "$", "this", "->", "buildJoinExpressions", "(", "$", "tableMapping", "[", "'joins'", "]", ")", ";", "$", "selects", "[", "]", "=", "'SELECT * FROM (SELECT '", ".", "implode", "(", "$", "hitExpressions", ",", "', '", ")", ".", "' '", ".", "'FROM '", ".", "$", "tableMapping", "[", "'table'", "]", ".", "' '", ".", "$", "tableMapping", "[", "'tableAlias'", "]", ".", "' '", ".", "implode", "(", "' '", ",", "$", "joinsExpressions", ")", ".", "' '", ".", "'ORDER BY c'", ".", "$", "this", "->", "scorePos", ".", "' DESC '", ".", "'LIMIT '", ".", "(", "$", "offset", "+", "$", "limit", ")", ".", "') AS DT'", ".", "$", "key", ".", "' '", ".", "'WHERE c'", ".", "$", "this", "->", "scorePos", ".", "'<>0 '", ";", "}", "$", "bigSelect", "=", "''", ".", "implode", "(", "$", "selects", ",", "' UNION '", ")", ".", "' '", ".", "'ORDER BY c'", ".", "$", "this", "->", "scorePos", ".", "' DESC '", ".", "'LIMIT '", ".", "$", "limit", ".", "' '", ".", "'OFFSET '", ".", "$", "offset", ";", "$", "query", "=", "$", "em", "->", "createNativeQuery", "(", "$", "bigSelect", ",", "$", "this", "->", "rsm", ")", ";", "foreach", "(", "$", "searchWords", "as", "$", "key", "=>", "$", "searchWord", ")", "{", "$", "query", "->", "setParameter", "(", "'p'", ".", "$", "key", ",", "$", "searchWord", ")", ";", "}", "return", "$", "query", ";", "}" ]
Build result query @param EntityManager $em @param Request $request @param int $page @return \Doctrine\ORM\NativeQuery
[ "Build", "result", "query" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L130-L168
3,699
emhar/SearchDoctrineBundle
Query/Query.php
Query.buildCountQuery
protected function buildCountQuery(EntityManager $em, Request $request) { $searchWords = preg_split('/[^[:alnum:]]+/', $request->getSearchText()); $selects = array(); foreach($this->databaseMapping as $tableMapping) { $score = $this->buildScoreColumn($tableMapping['columns'], count($searchWords)); $joinsExpressions = $this->buildJoinExpressions($tableMapping['joins']); $selects[] = 'SELECT COUNT(*) ' . 'FROM ' . $tableMapping['table'] . ' ' . $tableMapping['tableAlias'] . ' ' . implode(' ', $joinsExpressions) . ' ' . 'WHERE ' . $score['expression'] . '<>0 ' ; } $bigSelect = 'SELECT (' . implode(')+(', $selects) . ')'; $stmt = $em->getConnection()->prepare($bigSelect); foreach($searchWords as $key => $searchWord) { $stmt->bindValue('p' . $key, $searchWord); } return $stmt; }
php
protected function buildCountQuery(EntityManager $em, Request $request) { $searchWords = preg_split('/[^[:alnum:]]+/', $request->getSearchText()); $selects = array(); foreach($this->databaseMapping as $tableMapping) { $score = $this->buildScoreColumn($tableMapping['columns'], count($searchWords)); $joinsExpressions = $this->buildJoinExpressions($tableMapping['joins']); $selects[] = 'SELECT COUNT(*) ' . 'FROM ' . $tableMapping['table'] . ' ' . $tableMapping['tableAlias'] . ' ' . implode(' ', $joinsExpressions) . ' ' . 'WHERE ' . $score['expression'] . '<>0 ' ; } $bigSelect = 'SELECT (' . implode(')+(', $selects) . ')'; $stmt = $em->getConnection()->prepare($bigSelect); foreach($searchWords as $key => $searchWord) { $stmt->bindValue('p' . $key, $searchWord); } return $stmt; }
[ "protected", "function", "buildCountQuery", "(", "EntityManager", "$", "em", ",", "Request", "$", "request", ")", "{", "$", "searchWords", "=", "preg_split", "(", "'/[^[:alnum:]]+/'", ",", "$", "request", "->", "getSearchText", "(", ")", ")", ";", "$", "selects", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "databaseMapping", "as", "$", "tableMapping", ")", "{", "$", "score", "=", "$", "this", "->", "buildScoreColumn", "(", "$", "tableMapping", "[", "'columns'", "]", ",", "count", "(", "$", "searchWords", ")", ")", ";", "$", "joinsExpressions", "=", "$", "this", "->", "buildJoinExpressions", "(", "$", "tableMapping", "[", "'joins'", "]", ")", ";", "$", "selects", "[", "]", "=", "'SELECT COUNT(*) '", ".", "'FROM '", ".", "$", "tableMapping", "[", "'table'", "]", ".", "' '", ".", "$", "tableMapping", "[", "'tableAlias'", "]", ".", "' '", ".", "implode", "(", "' '", ",", "$", "joinsExpressions", ")", ".", "' '", ".", "'WHERE '", ".", "$", "score", "[", "'expression'", "]", ".", "'<>0 '", ";", "}", "$", "bigSelect", "=", "'SELECT ('", ".", "implode", "(", "')+('", ",", "$", "selects", ")", ".", "')'", ";", "$", "stmt", "=", "$", "em", "->", "getConnection", "(", ")", "->", "prepare", "(", "$", "bigSelect", ")", ";", "foreach", "(", "$", "searchWords", "as", "$", "key", "=>", "$", "searchWord", ")", "{", "$", "stmt", "->", "bindValue", "(", "'p'", ".", "$", "key", ",", "$", "searchWord", ")", ";", "}", "return", "$", "stmt", ";", "}" ]
Build count query @param \Doctrine\ORM\EntityManager $em @param \Emhar\SearchDoctrineBundle\Request\Request $request @return \Doctrine\DBAL\Statement;
[ "Build", "count", "query" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L177-L199